Closed
Description
Compiler version
Scala 3.2.1, but also with 3.1.2.
Note, this compiles fine with 2.11, 2.12 and 2.13.
Minimized code
import java.lang.reflect.Constructor
class MinimalScala3Bug {
private val NO_ARG: Array[Class[_]] = Array.empty
private val STRING_ARG: Array[Class[_]] = Array(classOf[String])
def doesNotCompile(c: Class[_], useStringCTor: Boolean): Constructor[_] = {
c.getDeclaredConstructor((if (useStringCTor) STRING_ARG else NO_ARG): _*)
}
def doesCompile(c: Class[_], useStringCTor: Boolean): Constructor[_] = {
val array = if (useStringCTor) STRING_ARG else NO_ARG
c.getDeclaredConstructor(array: _*)
}
}
Output
First lines of the compiler output.
[warn] an unexpected type representation reached the compiler backend while compiling MinimalScala3Bug.scala: NoType. If possible, please file a bug on https://github.com/lampepfl/dotty/issues
Error while emitting MinimalScala3Bug.scala
scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$) while running genBCode on MinimalScala3Bug.scala
[info] exception occurred while compiling MinimalScala3Bug.scala
scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$) while compiling MinimalScala3Bug.scala
(Note: the output was slightly redacted to remove the full path to the scala file.)