scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.84k stars 1.05k forks source link

AssertionError when loading class file #18091

Open theosotr opened 1 year ago

theosotr commented 1 year ago

Compiler version

3.3.0

Minimized code

A compiler crash is triggered when parsing class file of the following library. Scala 2 successfully compiles the program.

import io.restassured.internal.support.ParameterUpdater;

object Test {
  def test() = {
    val x: ParameterUpdater = null;
  }
}

Output (click arrow to expand)

```scala exception caught when loading class ParameterUpdater: java.lang.AssertionError: io.restassured.internal.support.ParameterUpdater$Serializer$1 java.lang.AssertionError: io.restassured.internal.support.ParameterUpdater$Serializer$1 while typechecking test.scala exception occurred while typechecking test.scala exception occurred while compiling test.scala java.lang.AssertionError: io.restassured.internal.support.ParameterUpdater$Serializer$1 while compiling test.scala Exception in thread "main" java.lang.AssertionError: io.restassured.internal.support.ParameterUpdater$Serializer$1 at dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$12(ClassfileParser.scala:866) at scala.Option.getOrElse(Option.scala:201) at dotty.tools.dotc.core.classfile.ClassfileParser.enterOwnInnerClasses$$anonfun$1(ClassfileParser.scala:867) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:575) at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:573) at dotty.tools.dotc.util.GenericHashMap$EntryIterator.foreach(GenericHashMap.scala:167) at dotty.tools.dotc.core.classfile.ClassfileParser.enterOwnInnerClasses(ClassfileParser.scala:868) at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:195) at dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$1(ClassfileParser.scala:87) at dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:82) at dotty.tools.dotc.core.ClassfileLoader.load(SymbolLoaders.scala:412) at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:407) at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:341) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:382) at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAbsent(SymDenotations.scala:612) at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAccessibleFrom(SymDenotations.scala:922) at dotty.tools.dotc.core.Denotations$SingleDenotation.accessibleFrom(Denotations.scala:643) at dotty.tools.dotc.typer.Typer.selection$1(Typer.scala:248) at dotty.tools.dotc.typer.Typer.recur$1(Typer.scala:290) at dotty.tools.dotc.typer.Typer.namedImportRef$1(Typer.scala:297) at dotty.tools.dotc.typer.Typer.loop$1(Typer.scala:450) at dotty.tools.dotc.typer.Typer.findRefRecur$1(Typer.scala:472) at dotty.tools.dotc.typer.Typer.findRef(Typer.scala:475) at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:534) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2896) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3177) at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1616) at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1609) at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1616) at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1704) at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:783) at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:922) at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:810) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174) at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187) at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189) at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:390) at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2869) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2894) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130) at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1096) at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1100) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2936) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174) at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1619) at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1609) at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1619) at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1872) at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:249) at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1872) at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1880) at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1898) at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1899) at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1910) at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1657) at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1664) at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1755) at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:787) at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:922) at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:810) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174) at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187) at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189) at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:390) at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2869) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2894) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130) at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2562) at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2916) at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2920) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084) at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130) at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2692) at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2961) at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058) at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062) at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174) at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44) at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54) at scala.Function0.apply$mcV$sp(Function0.scala:42) at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:437) at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54) at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.immutable.List.foreach(List.scala:333) at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88) at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321) at dotty.tools.dotc.Run.runPhases$1(Run.scala:263) at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271) at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280) at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67) at dotty.tools.dotc.Run.compileUnits(Run.scala:280) at dotty.tools.dotc.Run.compileSources(Run.scala:195) at dotty.tools.dotc.Run.compile(Run.scala:179) at dotty.tools.dotc.Driver.doCompile(Driver.scala:35) at dotty.tools.dotc.Driver.process(Driver.scala:195) at dotty.tools.dotc.Driver.process(Driver.scala:163) at dotty.tools.dotc.Driver.process(Driver.scala:175) at dotty.tools.dotc.Driver.main(Driver.scala:205) at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162) at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186) at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala) ```
nicolasstucki commented 1 year ago

This class is defined in a .groovy file. I wonder if we can reproduce it with a java class.

https://github.com/rest-assured/rest-assured/blob/144a684989d4f00298cbca23c408f3d4ca9037fa/rest-assured/src/main/groovy/io/restassured/internal/support/ParameterUpdater.groovy#L26