You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 to def count
the issue goes away if you change var array to var array: Array[T] = _
the issue goes away if you remove any of the two @specialized annotations
if you change var count to val count, an exception java.lang.IllegalAccessError si thrown instead
I was unable to reproduce the issue with Dotty 0.27.0-RC1
The text was updated successfully, but these errors were encountered:
Specialization in 2.10 has a problem of specializing constructors in some cases
With explanation and a workaround:
I won’t get into why the above fails the way it fails - suffices to say that the specialization creates specialized fields in the specialized variants of the class and does not properly rewire the bridges for the field accessor methods in the constructor body correctly. Here is the pattern to solve the above issues - create a method init in which you initialize the troublesome fields:
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:
Main.scala:
build.sbt:
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.var count
todef count
var array
tovar array: Array[T] = _
@specialized
annotationsvar count
toval count
, an exceptionjava.lang.IllegalAccessError
si thrown insteadI was unable to reproduce the issue with Dotty 0.27.0-RC1
The text was updated successfully, but these errors were encountered: