Skip to content

Enum compiler crash with -Ycheck:all #7734

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

Closed
sir-wabbit opened this issue Dec 13, 2019 · 0 comments · Fixed by #9151
Closed

Enum compiler crash with -Ycheck:all #7734

sir-wabbit opened this issue Dec 13, 2019 · 0 comments · Fixed by #9151

Comments

@sir-wabbit
Copy link

sir-wabbit commented Dec 13, 2019

minimized code

enum A(a: Double, t: Int*) extends java.lang.Enum[A] {
    case B extends A(10)
}
Stack trace
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:514)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:327)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:797)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:797)
	at dotty.tools.dotc.typer.Applications$Application.$anonfun$4$$anonfun$1(Applications.scala:594)
	at scala.collection.immutable.List.map(List.scala:219)
	at dotty.tools.dotc.typer.Applications$Application.$anonfun$2(Applications.scala:594)
	at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:1888)
	at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:82)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:594)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:603)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:354)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:694)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:796)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:870)
	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:923)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2298)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:934)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:969)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:82)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2157)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:301)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2193)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2205)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:286)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2290)
	at dotty.tools.dotc.typer.Typer.typedParent$2(Typer.scala:1719)
	at dotty.tools.dotc.typer.Typer.$anonfun$32(Typer.scala:1761)
Error message
sbt:dotty> dotc testing/Test.scala -Ycheck:all
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running (fork) dotty.tools.dotc.Main -classpath /Users/akonovalov/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.13.1.jar:/Users/akonovalov/Documents/projects/dotty-fork/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.21/dotty-library_0.21-0.21.0-bin-SNAPSHOT.jar testing/Test.scala -Ycheck:all
checking testing/Test.scala after phase frontend
checking testing/Test.scala after phase inlinedPositions
checking testing/Test.scala after phase staging
checking testing/Test.scala after phase posttyper
checking testing/Test.scala after phase pickler
checking testing/Test.scala after phase reifyQuotes
checking testing/Test.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, completeJavaEnums}
exception while typing new A(10.0, [ : Int]:Int*, "B", 0) of class class dotty.tools.dotc.ast.Trees$Apply # 1679
exception while typing final class $anon() extends A(10.0, [ : Int]:Int*, "B", 0),
  scala.deriving.Mirror.Singleton
 {
  def $ordinal: Int = 0
  override def toString: String = "B"
  A.$values.register(this)
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 1681
exception while typing {
  final class $anon() extends A(10.0, [ : Int]:Int*, "B", 0),
    scala.deriving.Mirror.Singleton
   {
    def $ordinal: Int = 0
    override def toString: String = "B"
    A.$values.register(this)
  }
  new A with scala.deriving.Mirror.Singleton {...}():A
} of class class dotty.tools.dotc.ast.Trees$Block # 1687
exception while typing @scala.annotation.static() case <static> val B: A =
  {
    final class $anon() extends A(10.0, [ : Int]:Int*, "B", 0),
      scala.deriving.Mirror.Singleton
     {
      def $ordinal: Int = 0
      override def toString: String = "B"
      A.$values.register(this)
    }
    new A with scala.deriving.Mirror.Singleton {...}():A
  } of class class dotty.tools.dotc.ast.Trees$ValDef # 1688
exception while typing @scala.annotation.internal.SourceFile("testing/Test.scala") final module class
  A$
() extends AnyRef(), Serializable, scala.deriving.Mirror.Sum {
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[A.type])
  def values: Array[A] =
    A.$values.values.toArray[A](scala.reflect.ClassTag.apply[A](classOf[A]))
  @scala.annotation.static() private[this] val $values:
    scala.runtime.EnumValues[A]
   = new scala.runtime.EnumValues[A]()
  def valueOf($name: String): A =
    try A.$values.fromName.apply($name) catch
      {
        case ex$ @ _:NoSuchElementException =>
          throw new IllegalArgumentException("key not found: ".concat($name))
      }
  @scala.annotation.static() case <static> val B: A =
    {
      final class $anon() extends A(10.0, [ : Int]:Int*, "B", 0),
        scala.deriving.Mirror.Singleton
       {
        def $ordinal: Int = 0
        override def toString: String = "B"
        A.$values.register(this)
      }
      new A with scala.deriving.Mirror.Singleton {...}():A
    }
  type MirroredMonoType = A
  def ordinal(x$0: A.MirroredMonoType): Int = x$0.ordinal()
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 1695
exception while typing package <empty> {
  @scala.annotation.internal.SourceFile("testing/Test.scala") @
    scala.annotation.internal.Child
  [(A.B : A)]() sealed abstract class A(a: Double, t: Seq[Int] @Repeated,
    _$name: String
  , _$ordinal: Int) extends Enum[A](A.this._$name, A.this._$ordinal), Enum {
    private[this] val a: Double
    private[this] val t: Seq[Int] @Repeated
    val _$name: String
    val _$ordinal: Int
  }
  final lazy module val A: A$ = new A$()
  @scala.annotation.internal.SourceFile("testing/Test.scala") final module class

  A$() extends AnyRef(), Serializable, scala.deriving.Mirror.Sum {
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[A.type])
    def values: Array[A] =
      A.$values.values.toArray[A](scala.reflect.ClassTag.apply[A](classOf[A]))
    @scala.annotation.static() private[this] val $values:
      scala.runtime.EnumValues[A]
     = new scala.runtime.EnumValues[A]()
    def valueOf($name: String): A =
      try A.$values.fromName.apply($name) catch
        {
          case ex$ @ _:NoSuchElementException =>
            throw new IllegalArgumentException("key not found: ".concat($name))
        }
    @scala.annotation.static() case xception occurred while compiling testing/Test.scala
Exception in thread "main" [33m<static> val B: A =
      {
        final class $anon() extends A(10.0, [ : Int]:Int*, "B", 0),
          scala.deriving.Mirror.Singleton
         {
          def $ordinal: Int = 0
          override def toString: String = "B"
          A.$values.register(this)
        }
        new A with scala.deriving.Mirror.Singleton {...}():A
      }
    type MirroredMonoType = A
    def ordinal(x$0: A.MirroredMonoType): Int = x$0.ordinal()
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 1696
java.lang.AssertionError: assertion failed: Found:    Int*
Required: Int
found: ??
expected: class Int in package scala with class Int, flags = final abstract <scala-2.x> <touched>, underlying = Int, AnyVal {...}
tree = [ : Int]:Int*
*** error while checking testing/Test.scala after phase completeJavaEnums ***
java.lang.AssertionError: assertion failed: Found:    Int*
Required: Int
found: ??
expected: class Int in package scala with class Int, flags = final abstract <scala-2.x> <touched>, underlying = Int, AnyVal {...}
tree = [ : Int]:Int* while compiling testing/Test.scala
@bishabosha bishabosha mentioned this issue Jun 8, 2020
22 tasks
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 10, 2020
@nicolasstucki nicolasstucki linked a pull request Jun 10, 2020 that will close this issue
bishabosha added a commit that referenced this issue Jun 10, 2020
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.

1 participant