Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scala.MatchError: NoType when combining if and _* #16562

Closed
erikvanoosten opened this issue Dec 20, 2022 · 1 comment · Fixed by #16569
Closed

scala.MatchError: NoType when combining if and _* #16562

erikvanoosten opened this issue Dec 20, 2022 · 1 comment · Fixed by #16569
Assignees
Milestone

Comments

@erikvanoosten
Copy link

erikvanoosten commented Dec 20, 2022

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.)

@erikvanoosten erikvanoosten added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 20, 2022
@dwijnand dwijnand removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Dec 21, 2022
@dwijnand dwijnand linked a pull request Dec 21, 2022 that will close this issue
@erikvanoosten
Copy link
Author

Thanks! 🚀

@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants