object AbstractMethodErrorOnAnyVal {
trait MyTrait[A] extends Any {
protected def value: A
final def publicValue: A = {
value
}
}
final case class MyValueClass[A](override protected val value: A) extends AnyVal with MyTrait[A]
def main(arguments: Array[String]): Unit = {
MyValueClass(42).publicValue
}
}
$ scala -version
Scala code runner version #2.12.4 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.
java.lang.AbstractMethodError: Method Main$MyValueClass.value()Ljava/lang/Object; is abstract
at Main$MyValueClass.value(AbstractMethodErrorOnAnyVal.scala)
at Main$MyTrait.publicValue(AbstractMethodErrorOnAnyVal.scala:7)
at Main$MyTrait.publicValue$(AbstractMethodErrorOnAnyVal.scala:6)
at Main$MyValueClass.publicValue(AbstractMethodErrorOnAnyVal.scala:12)
at Main$.main(AbstractMethodErrorOnAnyVal.scala:15)
at Main.main(AbstractMethodErrorOnAnyVal.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at scala.reflect.internal.util.ScalaClassLoader.$anonfun$run$2(ScalaClassLoader.scala:99)
at scala.reflect.internal.util.ScalaClassLoader.asContext(ScalaClassLoader.scala:34)
at scala.reflect.internal.util.ScalaClassLoader.asContext$(ScalaClassLoader.scala:30)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:125)
at scala.reflect.internal.util.ScalaClassLoader.run(ScalaClassLoader.scala:99)
at scala.reflect.internal.util.ScalaClassLoader.run$(ScalaClassLoader.scala:91)
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:125)
at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:22)
at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:21)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)
at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:29)
at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39)
at scala.tools.nsc.ScriptRunner.runCompiled(ScriptRunner.scala:173)
at scala.tools.nsc.ScriptRunner.$anonfun$runScript$1(ScriptRunner.scala:190)
at scala.tools.nsc.ScriptRunner.$anonfun$runScript$1$adapted(ScriptRunner.scala:190)
at scala.tools.nsc.ScriptRunner.$anonfun$withCompiledScript$2(ScriptRunner.scala:159)
at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:127)
at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:203)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:85)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)