-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"AssertionError: duplicate type ..." when importing traits from 2.13.4 compiled library #11173
Comments
A minimized standalone reproducer: Scala 2// s2/Lib.scala
package i11173
trait DU[A, B]
trait H[F[_]]
trait Foo[E] {
def foo: H[({type L[A] = DU[E, A]})#L]
}
trait Bar[E] extends Foo[E] {
def bar = foo // important note: return type not specified
} Scala 3// s3/Main.scala
import i11173.Bar
def test(x: Bar[_]): Unit = () These may be compiled using the following lazy val s2 = project.in(file("s2"))
.settings(scalaVersion := "2.13.4")
lazy val s3 = project.in(file("s3"))
.dependsOn(s2)
.settings(scalaVersion := "3.0.0-RC1-bin-20210117-65b17af-NIGHTLY") or directly on the command line:
Compiler output - click to expandexception caught when loading trait Bar: java.lang.AssertionError: assertion failed: duplicate type E#4433; previous was type E#4426
exception occurred while typechecking s3/Main.scala
exception occurred while compiling s3/Main.scala
java.lang.AssertionError: assertion failed: duplicate type E#4433; previous was type E#4426 while compiling s3/Main.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: duplicate type E#4433; previous was type E#4426
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.core.Scopes$MutableScope.enter(Scopes.scala:275)
at dotty.tools.dotc.core.SymDenotations$ClassDenotation.enterNoReplace(SymDenotations.scala:1867)
at dotty.tools.dotc.core.SymDenotations$ClassDenotation.enter(SymDenotations.scala:1858)
at dotty.tools.dotc.core.unpickleScala2.Scala2Unpickler.finishSym$1(Scala2Unpickler.scala:493)
at dotty.tools.dotc.core.unpickleScala2.Scala2Unpickler.readDisambiguatedSymbol(Scala2Unpickler.scala:546)
at dotty.tools.dotc.core.unpickleScala2.Scala2Unpickler.readSymbol(Scala2Unpickler.scala:327)
at dotty.tools.dotc.core.unpickleScala2.Scala2Unpickler.run(Scala2Unpickler.scala:182)
at dotty.tools.dotc.core.classfile.ClassfileParser.unpickleScala$1(ClassfileParser.scala:860)
at dotty.tools.dotc.core.classfile.ClassfileParser.unpickleOrParseInnerClasses(ClassfileParser.scala:966)
at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:165)
at dotty.tools.dotc.core.classfile.ClassfileParser.run$$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:414)
at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:409)
at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:343)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:361)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAbsent(SymDenotations.scala:570)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAccessibleFrom(SymDenotations.scala:863)
at dotty.tools.dotc.core.Denotations$SingleDenotation.accessibleFrom(Denotations.scala:613)
at dotty.tools.dotc.typer.Typer.selection$3(Typer.scala:213)
at dotty.tools.dotc.typer.Typer.recur$1(Typer.scala:247)
at dotty.tools.dotc.typer.Typer.namedImportRef$1(Typer.scala:254)
at dotty.tools.dotc.typer.Typer.loop$1(Typer.scala:393)
at dotty.tools.dotc.typer.Typer.findRefRecur$1(Typer.scala:415)
at dotty.tools.dotc.typer.Typer.findRef(Typer.scala:418)
at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:473)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2521)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedAppliedTypeTree(Typer.scala:1766)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2578)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1300)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1292)
at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1300)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1512)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:699)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:830)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:731)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2494)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2519)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1305)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1292)
at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1305)
at dotty.tools.dotc.typer.Namer.completeParams$$anonfun$1(Namer.scala:1321)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.typer.Namer.completeParams(Namer.scala:1321)
at dotty.tools.dotc.typer.Namer.defDefSig$$anonfun$3(Namer.scala:1550)
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.Namer.defDefSig(Namer.scala:1550)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:703)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:830)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:731)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2494)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2519)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2705)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2755)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2202)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2540)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2544)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2613)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2705)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2755)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2337)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2585)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2614)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2679)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2799)
at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:120)
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.FrontEnd.runOn(FrontEnd.scala:120)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
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:1323)
at dotty.tools.dotc.Run.runPhases$5(Run.scala:195)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
at dotty.tools.dotc.Run.compileUnits(Run.scala:210)
at dotty.tools.dotc.Run.compileSources(Run.scala:146)
at dotty.tools.dotc.Run.compile(Run.scala:130)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
at dotty.tools.dotc.Driver.process(Driver.scala:186)
at dotty.tools.dotc.Driver.process(Driver.scala:155)
at dotty.tools.dotc.Driver.process(Driver.scala:167)
at dotty.tools.dotc.Driver.main(Driver.scala:194)
at dotty.tools.dotc.Main.main(Main.scala) |
Another example of failure would be with the following
And the following
The code portion which is triggering the error is
|
Hi, I also encountered this issue and tried to make a very minimal but executable repro-case: https://github.com/felixbr/repro-case-11173 Hope this helps. Cheers |
Minimized code
This is peculiar case to minimize, because of the dependency. Scastie seems like the best option to me, I hope it's ok.
Link to minimized Scastie project.
Link to definitions of imported traits in the imported 2.13.4 library.
Link to definition of
DottyBug
in the imported 2.13.4 library.Now Scala 3 code. Some
import
statements trigger the error, some don't:Wildcard
import
does not trigger the error. But using the imported trait does:I modified the imported 2.13.4 library by putting cloned definitions of troublesome traits inside
object DottyBug {‥}
. Now importing works fine:Output (click arrow to expand)
This output comes from
3.0.0-RC1-bin-20210117-65b17af-NIGHTLY
.For
3.0.0-M3
output, please see provided Scastie link.The imported 2.13.4 dependency is:
The text was updated successfully, but these errors were encountered: