Unclear java.lang.AbstractMethodError

This code works:

trait Inner :
  def switch: Boolean 
  inline def go1: String = inline if switch then "Yes" else "No"
  def go2: String = if switch then "Yes" else "No"

object Outer extends Inner :
  inline def switch: Boolean = true
  def test1 = go1
  def test2 = go2
  
println(Outer.test1)  
println(Outer.test2)  

However, if I move the definition of switch to a trait:

trait Settings :
  inline def switch: Boolean = true

trait Inner :
  def switch: Boolean
  inline def go1: String = inline if switch then "Yes" else "No"
  def go2: String = if switch then "Yes" else "No"

object Outer extends Settings, Inner :
  def test1 = go1
  def test2 = go2
  
println(Outer.test1)  
println(Outer.test2)  

it results in an java.lang.AbstractMethodError: Receiver class Outer$ does not define or inherit an implementation of the resolved method 'abstract boolean switch()' of interface Inner. The order of the traits in the object extension does not seem to matter.

Why is this?

1 Like

I think there is a ticket about unsoundness of overriding inline.

I am not in a position to look it up at the moment. (That position would be “upright”.)

Inlines don’t get bodies unless @publicInBinary or similar.

Edit: I guess that is for accessors to privates. Maybe there is a different mechanism for retaining the bytecode.

1 Like

Thank you for looking into this @som-snytt. Where others would spend the non-upright position sleeping or getting well, or … , you are helping others :grinning_face_with_smiling_eyes: so fantastic :+1: !!!

I played a little with this @publicInBinary annotation, but could not get it to work. So, or I am misunderstanding something, or some other force is at work here.

Anyway, imho this issue qualifies as compiler bug. If there are no objections, I will file one shortly (my second this week :grimacing:). When looking through the list of open issue i found AbstractMethodError with abstract override and super accessors (since min 2018!!) which indeed still fails.

1 Like