Skip to content

Cyclic reference involving class, when using java packages #9492

Closed
@Swoorup

Description

@Swoorup

When inter-oping with java libraries I get a compiler bug. I have attached a minimal repo as an attachment. The code is as straightforward as borrowed from here: https://github.com/knowm/XChange/blob/b6ed6d1d2a/xchange-stream-btcmarkets/src/test/java/info/bitrich/xchangestream/btcmarkets/BTCMarketsManualExample.java#L16-L41

cyclic-reference-bug.zip

A more simple scastie repro: https://scastie.scala-lang.org/wmyqtC1KRQOiUG64Kicb0A

This doesn't happen with scala though.

dottyVersion = "0.26.0-RC1"

Output with -Ydebug-error

[error] Cyclic reference involving class LimitOrder 
[warn] one warning found 
[error] Cyclic reference involving class LimitOrder
java.lang.Exception: Stack trace
        at java.base/java.lang.Thread.dumpStack(Thread.java:1379)
        at dotty.tools.dotc.report$.error(report.scala:72)
        at dotty.tools.dotc.report$.error(report.scala:75)
        at dotty.tools.dotc.typer.ErrorReporting$.errorType(ErrorReporting.scala:34)
  | => cat dotty.tools.dotc.typer.ErrorReporting$.errorTree(ErrorReporting.scala:26)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2885)
        at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
        at dotty.tools.dotc.typer.Typer.typedNamedArg(Typer.scala:800)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2429)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2484)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$2(ProtoTypes.scala:337)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:293)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:338)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:818)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:818)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:540)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:611)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:363)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:713)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:817)
        at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1026)
        at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:233)
        at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:91)
        at dotty.tools.dotc.ast.Trees$Instance.applyOverloaded(Trees.scala:1585)
        at dotty.tools.dotc.ast.Trees$Instance.resolveConstructor(Trees.scala:1591)
        at dotty.tools.dotc.core.Annotations$Annotation$.deferredResolve$$anonfun$1(Annotations.scala:170)
        at dotty.tools.dotc.core.Annotations$.dotty$tools$dotc$core$Annotations$$anon$2$$_$$lessinit$greater$$anonfun$2(Annotations.scala:155)
        at dotty.tools.dotc.core.Annotations$LazyAnnotation.tree(Annotations.scala:79)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotArg$$anonfun$2(ClassfileParser.scala:531)
        at scala.Option.map(Option.scala:242)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotArg(ClassfileParser.scala:531)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotArg$$anonfun$3(ClassfileParser.scala:520)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotArg$$anonfun$adapted$1(ClassfileParser.scala:523)
        at scala.collection.immutable.Range.foreach(Range.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotArg(ClassfileParser.scala:523)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotation$$anonfun$3(ClassfileParser.scala:554)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotation$$anonfun$adapted$1(ClassfileParser.scala:558)
        at scala.collection.immutable.Range.foreach(Range.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotation(ClassfileParser.scala:558)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotations$2$$anonfun$1(ClassfileParser.scala:649)
        at dotty.runtime.function.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.java:12)
        at scala.collection.immutable.Range.foreach(Range.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAnnotations$1(ClassfileParser.scala:653)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAttribute$3(ClassfileParser.scala:607)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAttributes$$anonfun$1(ClassfileParser.scala:658)
        at dotty.runtime.function.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.java:12)
        at scala.collection.immutable.Range.foreach(Range.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:658)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:90)
        at dotty.tools.dotc.core.ClassfileLoader.load(SymbolLoaders.scala:402)
        at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:397)
        at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:342)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:344)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.unforcedDecls(SymDenotations.scala:368)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParamsFromDecls(SymDenotations.scala:1637)
        at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParams(SymDenotations.scala:1650)
        at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$3.apply(ClassfileParser.scala:38)
        at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$3.apply(ClassfileParser.scala:37)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$3.apply(ClassfileParser.scala:47)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:660)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:90)
        at dotty.tools.dotc.core.ClassfileLoader.load(SymbolLoaders.scala:402)
        at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:397)
        at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:342)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:344)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAbsent(SymDenotations.scala:536)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.isAccessibleFrom(SymDenotations.scala:834)
        at dotty.tools.dotc.core.Denotations$SingleDenotation.accessibleFrom(Denotations.scala:614)
        at dotty.tools.dotc.typer.Typer.selection$3(Typer.scala:202)
        at dotty.tools.dotc.typer.Typer.recur$1(Typer.scala:233)
        at dotty.tools.dotc.typer.Typer.namedImportRef$1(Typer.scala:240)
        at dotty.tools.dotc.typer.Typer.loop$2(Typer.scala:376)
        at dotty.tools.dotc.typer.Typer.findRefRecur$1(Typer.scala:398)
        at dotty.tools.dotc.typer.Typer.findRef(Typer.scala:401)
        at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:471)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2392)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2483)
        at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
        at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1220)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1212)
        at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1220)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1423)
        at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1475)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:684)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:801)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:712)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166)
        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:352)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2365)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2390)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2483)
        at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2579)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2627)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2081)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2411)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2415)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2483)
        at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2579)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2627)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2207)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2455)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2484)
        at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:2553)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2557)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2671)
        at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:78)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
        at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:119)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.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:119)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:181)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.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:191)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:199)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:64)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:206)
        at dotty.tools.dotc.Run.compileSources(Run.scala:143)
        at dotty.tools.dotc.Run.compile(Run.scala:125)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Main.process(Main.scala)
        at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
        at xsbt.CompilerInterface.run(CompilerInterface.java:41)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
        at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
        at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
        at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
        at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
        at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
        at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
        at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
        at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
        at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
        at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
        at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
        at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
        at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
        at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
        at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
        at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
        at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
        at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
        at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
        at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1765)
        at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1738)
        at scala.Function1.$anonfun$compose$1(Function1.scala:49)
        at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
        at sbt.std.Transform$$anon$4.work(Transform.scala:67)
        at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
        at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
        at sbt.Execute.work(Execute.scala:290)
        at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
        at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
[error] one error found
[
[error] one error found 
[error] (Compile / compileIncremental) Compilation failed 
[error] Total time: 2 s, completed 4 Aug 2020, 9:29:59 pm

Expectation

Compilation succeeds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions