Closed
Description
reproduction steps
using Scala 2.13.3, 2.12.2, 2.11.12 or 2.10.7 (other versions not tested)
Clone https://github.com/OndrejSpanel/SpecRepro or use the files as below:
Buffer.scala:
trait ABuffer[@specialized(Float)T] {
def count: Int
}
class Buffer[@specialized(Float) T](array_par: Array[T]) extends ABuffer[T] {
var array: Array[T] = array_par
var count: Int = 0
}
class Float32Buffer(array_par: Array[Float]) extends Buffer[Float](array_par)
Main.scala:
object Main extends App {
val vertices = Array[Float]()
val attribute = new Float32Buffer(vertices)
println(attribute.count)
}
build.sbt:
name := "SpecRepro"
val commonSettings = Seq(scalaVersion := "2.13.3")
lazy val root = (project in file(".")).settings(commonSettings)
lazy val examples = (project in file("examples")).dependsOn(root).settings(commonSettings)
problem
When running Main, an exception java.lang.AbstractMethodError
is thrown.
Notes
This is extracted from a real-life problem, where the module root
is in fact a library used in a different sbt project.
- the issue cannot be seen if both sources are located in the same SBT module
- the issue goes away if you change
var count
todef count
- the issue goes away if you change
var array
tovar array: Array[T] = _
- the issue goes away if you remove any of the two
@specialized
annotations - if you change
var count
toval count
, an exceptionjava.lang.IllegalAccessError
si thrown instead
I was unable to reproduce the issue with Dotty 0.27.0-RC1