-
Notifications
You must be signed in to change notification settings - Fork 1.1k
exception caught when loading class C: Cyclic reference involving class C #10888
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
Comments
Reproducible without involving a build tool by using coursier to set the classpath: scalac -classpath "$(cs fetch -p "com.badlogicgames.gdx:gdx:1.9.12")" i10888.scala The loop and stacktrace is: completing type DrawParticleEffect
completing val <init>
completing val effect
completing type ParticleEffectPool
completing val utils
completing type utils
completed utils in package com.badlogic.gdx
completed utils in package com.badlogic.gdx
completing type ParticleEffectPool
exception caught when loading class ParticleEffectPool: Cyclic reference involving class ParticleEffectPool
dotty.tools.dotc.core.CyclicReference:
at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:155)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:148)
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.Types$ThisType.underlying(Types.scala:2668)
at dotty.tools.dotc.core.Types$Type.widen(Types.scala:1160)
at dotty.tools.dotc.core.classfile.ClassfileParser.processInner$1(ClassfileParser.scala:354)
at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:392)
at dotty.tools.dotc.core.classfile.ClassfileParser.processClassType$1(ClassfileParser.scala:377)
at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:392)
at dotty.tools.dotc.core.classfile.ClassfileParser.dotty$tools$dotc$core$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:516)
at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:658)
at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:190)
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:416)
at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:411)
at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:343)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:152)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:362)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAbsent(SymDenotations.scala:571)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAccessibleFrom(SymDenotations.scala:864)
at dotty.tools.dotc.core.Denotations$SingleDenotation.accessibleFrom(Denotations.scala:613)
at dotty.tools.dotc.typer.Typer.selection$3(Typer.scala:212)
at dotty.tools.dotc.typer.Typer.recur$1(Typer.scala:246)
at dotty.tools.dotc.typer.Typer.namedImportRef$1(Typer.scala:253)
at dotty.tools.dotc.typer.Typer.loop$1(Typer.scala:389)
at dotty.tools.dotc.typer.Typer.findRefRecur$1(Typer.scala:411)
at dotty.tools.dotc.typer.Typer.findRef(Typer.scala:414)
at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:469)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2497)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2589)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1251)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1243)
at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1251)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1455)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:700)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:821)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:732)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:152)
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:370)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2470)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2495)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2589)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1256)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1243)
at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1256)
at dotty.tools.dotc.typer.Namer.completeParams$$anonfun$1(Namer.scala:1272)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.typer.Namer.completeParams(Namer.scala:1272)
at dotty.tools.dotc.typer.Namer.defDefSig$$anonfun$3(Namer.scala:1494)
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:1494)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:704)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:821)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:732)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:152)
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.typer.Namer$ClassCompleter.completeConstructor(Namer.scala:1112)
at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:1192)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:732)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:152)
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:370)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2470)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2495)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2589)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2685)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2735)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2313)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2561)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2590)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2659)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2663)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2779)
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.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
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) Looks like the problem goes away if I remove the The problematic Java class looks like: public class ParticleEffectPool extends Pool<PooledEffect> {
...
public class PooledEffect extends ParticleEffect { ... }
} So a class extends another class parameterized by a non-static inner class, I don't really know what that means. |
It's needed for https://github.com/lampepfl/dotty/tree/master/tests/pos/t4737 to compile, it translates diff --git compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index 05d2b29c5f9..9ae1bce5ac7 100644
--- compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -349,9 +349,15 @@ class ClassfileParser(
val tag = sig(index); index += 1
(tag: @switch) match {
case 'L' =>
+ /** Inner class references of A.this.B into A#B, do the same transformation recursively on `A` */
def processInner(tp: Type): Type = tp match {
case tp: TypeRef if !tp.symbol.owner.is(Flags.ModuleClass) =>
- TypeRef(processInner(tp.prefix), tp.symbol.asType)
+ val prefix = tp.prefix match
+ case ThisType(prefix) =>
+ println("tp.prefix: " + tp.prefix + " " + tp.prefix.hashCode)
+ prefix
+ case prefix => prefix
+ TypeRef(processInner(prefix), tp.symbol.asType)
case _ =>
tp
} But why do we have |
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
For Java inner classes, we should use `A#B` instead of `A.this.B`. Co-authored-by: Guillaume Martres <[email protected]>
Fix #10888: Avoid A.this.B for Java inner classes
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
scala file failing to compile:
mill build file build.sc, use this to fetch the ParticleEffectPool class which causes the issue :
use
mill __.compile
to compile and get the error.Output
Expectation
This should compile. It compiles ok with scala 2.13.4 but it could be a class file issue from the gdx library.
The text was updated successfully, but these errors were encountered: