Skip to content

AbstractMethodError for setter in trait #10477

Closed
scala/scala
#7627
@szeiger

Description

@szeiger

The following fails on Scala 2.12 (tested with .0 and .3):

abstract class BasicBackend {
  type F
  val f: F
}

class DistributedBackend extends BasicBackend {
  type F = FImpl
  val f: F = new FImpl
  class FImpl
}

trait BasicProfile {
  type Backend <: BasicBackend
  val backend: Backend
  trait SimpleQL {
    val f: backend.F = backend.f
  }
}

trait DistributedProfile extends BasicProfile { _: DistributedDriver =>
  type Backend = DistributedBackend
  val backend: Backend = new DistributedBackend
  val simple: SimpleQL = new SimpleQL {}
}

class DistributedDriver extends DistributedProfile

object Test extends App {
  new DistributedDriver()
}

I was unable to minimize it further. Any small change makes it work. The error is:

java.lang.AbstractMethodError: DistributedProfile$$anon$1.BasicProfile$SimpleQL$_setter_$f_$eq(Ljava/lang/Object;)V
       	at BasicProfile$SimpleQL.$init$(Test.scala:16)
       	at DistributedProfile$$anon$1.<init>(Test.scala:23)
       	at DistributedProfile.$init$(Test.scala:23)
       	at DistributedDriver.<init>(Test.scala:26)
       	at Test$.<init>(Test.scala:29)
       	at Test$.<clinit>(Test.scala)
       	at Test.main(Test.scala)

The minimized test case is based on slick/slick@2.1...mr-git:2.1 which makes Slick 2.1 compile on Scala 2.12.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions