scala / scala3

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

Scaladoc crashes with cyclic reference error when analyzing code that uses an AWS builder class #15288

Closed steven-barnes closed 1 year ago

steven-barnes commented 2 years ago

Compiler version

3.1.2

Minimized code

import software.amazon.awssdk.services.dynamodb.model.*

class Test {
  private def makeQuery = QueryRequest.builder().tableName("table").build()
}

// in build.sbt
libraryDependencies ++= Seq(
  "software.amazon.awssdk" % "dynamodb" % "2.17.194"
)

Output (click arrow to expand)

```scala scaladoc-bug % sbt clean doc [info] welcome to sbt 1.6.2 (Oracle Corporation Java 1.8.0_181) [info] loading project definition from /Users/sbarne832/dev/scaladoc-bug/project [info] loading settings for project root from build.sbt ... [info] set current project to scaladoc-bug (in build file:/Users/sbarne832/dev/scaladoc-bug/) [success] Total time: 0 s, completed May 24, 2022 4:52:22 PM [info] compiling 1 Scala source to /Users/sbarne832/dev/scaladoc-bug/target/scala-3.1.2/classes ... [info] Main Scala API documentation to /Users/sbarne832/dev/scaladoc-bug/target/scala-3.1.2/api... exception caught when loading trait Builder: Cyclic reference involving object QueryRequest exception caught when loading module class QueryRequest$: Cyclic reference involving object QueryRequest Cyclic reference involving object QueryRequest while compiling /Users/sbarne832/dev/scaladoc-bug/target/scala-3.1.2/classes/Test.tasty [error] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [error] at xsbt.DottydocRunner.run(DottydocRunner.java:65) [error] at xsbt.ScaladocInterface.run(ScaladocInterface.java:11) [error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.lang.reflect.Method.invoke(Method.java:498) [error] at sbt.internal.inc.AnalyzingCompiler.invoke(AnalyzingCompiler.scala:329) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:175) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:133) [error] at sbt.Doc$.$anonfun$scaladoc$1(Doc.scala:52) [error] at sbt.Doc$.$anonfun$scaladoc$1$adapted(Doc.scala:40) [error] at sbt.RawCompileLike$.$anonfun$prepare$1(RawCompileLike.scala:79) [error] at sbt.RawCompileLike$.$anonfun$prepare$1$adapted(RawCompileLike.scala:72) [error] at sbt.RawCompileLike$.$anonfun$cached$4(RawCompileLike.scala:63) [error] at sbt.RawCompileLike$.$anonfun$cached$4$adapted(RawCompileLike.scala:61) [error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219) [error] at sbt.RawCompileLike$.$anonfun$cached$1(RawCompileLike.scala:68) [error] at sbt.RawCompileLike$.$anonfun$cached$1$adapted(RawCompileLike.scala:52) [error] at sbt.Defaults$.$anonfun$docTaskSettings$4(Defaults.scala:2159) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] at sbt.Execute.work(Execute.scala:291) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] Caused by: java.lang.reflect.InvocationTargetException [error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.lang.reflect.Method.invoke(Method.java:498) [error] at xsbt.DottydocRunner.run(DottydocRunner.java:61) [error] at xsbt.ScaladocInterface.run(ScaladocInterface.java:11) [error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.lang.reflect.Method.invoke(Method.java:498) [error] at sbt.internal.inc.AnalyzingCompiler.invoke(AnalyzingCompiler.scala:329) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:175) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:133) [error] at sbt.Doc$.$anonfun$scaladoc$1(Doc.scala:52) [error] at sbt.Doc$.$anonfun$scaladoc$1$adapted(Doc.scala:40) [error] at sbt.RawCompileLike$.$anonfun$prepare$1(RawCompileLike.scala:79) [error] at sbt.RawCompileLike$.$anonfun$prepare$1$adapted(RawCompileLike.scala:72) [error] at sbt.RawCompileLike$.$anonfun$cached$4(RawCompileLike.scala:63) [error] at sbt.RawCompileLike$.$anonfun$cached$4$adapted(RawCompileLike.scala:61) [error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219) [error] at sbt.RawCompileLike$.$anonfun$cached$1(RawCompileLike.scala:68) [error] at sbt.RawCompileLike$.$anonfun$cached$1$adapted(RawCompileLike.scala:52) [error] at sbt.Defaults$.$anonfun$docTaskSettings$4(Defaults.scala:2159) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] at sbt.Execute.work(Execute.scala:291) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] Caused by: dotty.tools.dotc.core.CyclicReference: [error] at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:155) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166) [error] at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188) [error] at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.getMember$1(ClassfileParser.scala:1089) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1101) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:115) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:397) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.processTypeArgs$1(ClassfileParser.scala:384) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:399) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.dotty$tools$dotc$core$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:523) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:666) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:191) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$1(ClassfileParser.scala:88) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:83) [error] at dotty.tools.dotc.core.ClassfileLoader.load(SymbolLoaders.scala:414) [error] at dotty.tools.dotc.core.Class [build.sbt.txt](https://github.com/lampepfl/dotty/files/8766946/build.sbt.txt) fileLoader.doComplete(SymbolLoaders.scala:409) [error] at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:343) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:168) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeOnce(SymDenotations.scala:362) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.unforcedDecls(SymDenotations.scala:386) [error] at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParamsFromDecls(SymDenotations.scala:1790) [error] at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParams(SymDenotations.scala:1803) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:39) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:38) [error] at scala.collection.immutable.List.mapConserve(List.scala:472) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:43) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:38) [error] at scala.collection.immutable.List.mapConserve(List.scala:472) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:48) [error] at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:692) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:191) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$1(ClassfileParser.scala:88) [error] at dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:83) [error] at dotty.tools.dotc.core.ClassfileLoader.load(SymbolLoaders.scala:414) [error] at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:409) [error] at dotty.tools.dotc.core.SymbolLoader$$anon$1.doComplete(SymbolLoaders.scala:328) [error] at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:343) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:168) [error] at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188) [error] at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:370) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:65) [error] at dotty.tools.dotc.core.SymDenotations$ModuleCompleter.complete(SymDenotations.scala:2690) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:168) [error] at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188) [error] at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:370) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:65) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.is(SymDenotations.scala:107) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.isStableMember(SymDenotations.scala:740) [error] at dotty.tools.dotc.core.Types$Type.widenIfUnstable(Types.scala:1256) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1204) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1139) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1200) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1139) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1200) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1139) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1299) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler.readRhs$1$$anonfun$1$$anonfun$1(TreeUnpickler.scala:810) [error] at dotty.tools.dotc.core.tasty.TreeUnpickler$LazyReader.complete(TreeUnpickler.scala:1438) [error] at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy(Trees.scala:1020) [error] at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy$(Trees.scala:1015) [error] at dotty.tools.dotc.ast.Trees$ValOrDefDef.forceIfLazy(Trees.scala:418) [error] at dotty.tools.dotc.ast.Trees$ValOrDefDef.rhs(Trees.scala:423) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1603) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1641) [error] at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:141) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1515) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1517) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1610) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1641) [error] at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:141) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1607) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1641) [error] at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:141) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1640) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1515) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1517) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1616) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1521) [error] at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1641) [error] at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:141) [error] at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:105) [error] at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:96) [error] at dotty.tools.dotc.fromtasty.ReadTasty.compilationUnit$1(ReadTasty.scala:42) [error] at dotty.tools.dotc.fromtasty.ReadTasty.readTASTY(ReadTasty.scala:70) [error] at dotty.tools.dotc.fromtasty.ReadTasty.runOn$$anonfun$1(ReadTasty.scala:25) [error] at scala.collection.immutable.List.flatMap(List.scala:293) [error] at dotty.tools.dotc.fromtasty.ReadTasty.runOn(ReadTasty.scala:25) [error] at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328) [error] at dotty.tools.dotc.Run.runPhases$1(Run.scala:270) [error] at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278) [error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) [error] at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68) [error] at dotty.tools.dotc.Run.compileUnits(Run.scala:287) [error] at dotty.tools.dotc.Run.compileUnits(Run.scala:226) [error] at dotty.tools.dotc.fromtasty.TASTYRun.compile(TASTYRun.scala:12) [error] at dotty.tools.dotc.Driver.doCompile(Driver.scala:39) [error] at dotty.tools.dotc.Driver.process(Driver.scala:199) [error] at scala.tasty.inspector.OldTastyInspector.inspectFilesInContext(OldTastyInspector.scala:72) [error] at scala.tasty.inspector.OldTastyInspector.inspectFilesInContext$(OldTastyInspector.scala:22) [error] at scala.tasty.inspector.DocTastyInspector.inspectFilesInContext(DocTastyInspector.scala:5) [error] at dotty.tools.scaladoc.tasty.ScaladocTastyInspector.result(TastyParser.scala:157) [error] at dotty.tools.scaladoc.ScalaModuleProvider$.mkModule(ScalaModuleProvider.scala:11) [error] at dotty.tools.scaladoc.Scaladoc$.run(Scaladoc.scala:248) [error] at dotty.tools.scaladoc.Scaladoc$.run$$anonfun$1(Scaladoc.scala:84) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] at scala.Option.map(Option.scala:242) [error] at dotty.tools.scaladoc.Scaladoc$.run(Scaladoc.scala:88) [error] at dotty.tools.dottydoc.Main$.process(Main.scala:25) [error] at dotty.tools.dottydoc.Main.process(Main.scala) [error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.lang.reflect.Method.invoke(Method.java:498) [error] at xsbt.DottydocRunner.run(DottydocRunner.java:61) [error] at xsbt.ScaladocInterface.run(ScaladocInterface.java:11) [error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.lang.reflect.Method.invoke(Method.java:498) [error] at sbt.internal.inc.AnalyzingCompiler.invoke(AnalyzingCompiler.scala:329) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:175) [error] at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:133) [error] at sbt.Doc$.$anonfun$scaladoc$1(Doc.scala:52) [error] at sbt.Doc$.$anonfun$scaladoc$1$adapted(Doc.scala:40) [error] at sbt.RawCompileLike$.$anonfun$prepare$1(RawCompileLike.scala:79) [error] at sbt.RawCompileLike$.$anonfun$prepare$1$adapted(RawCompileLike.scala:72) [error] at sbt.RawCompileLike$.$anonfun$cached$4(RawCompileLike.scala:63) [error] at sbt.RawCompileLike$.$anonfun$cached$4$adapted(RawCompileLike.scala:61) [error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219) [error] at sbt.RawCompileLike$.$anonfun$cached$1(RawCompileLike.scala:68) [error] at sbt.RawCompileLike$.$anonfun$cached$1$adapted(RawCompileLike.scala:52) [error] at sbt.Defaults$.$anonfun$docTaskSettings$4(Defaults.scala:2159) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] at sbt.Execute.work(Execute.scala:291) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (Compile / doc) java.lang.reflect.InvocationTargetException [error] Total time: 4 s, completed May 24, 2022 4:52:26 PM ```
griggt commented 2 years ago

A self-contained example:

QueryRequest.java

interface CopyableBuilder<B extends CopyableBuilder<B, T>, T extends ToCopyableBuilder<B, T>> {}
interface ToCopyableBuilder<B extends CopyableBuilder<B, T>, T extends ToCopyableBuilder<B, T>> {}

public class QueryRequest implements ToCopyableBuilder<QueryRequest.Builder, QueryRequest> {
    public static Builder builder() { throw new UnsupportedOperationException(); }
    public interface Builder extends CopyableBuilder<Builder, QueryRequest> {
        void build();
    }
}

Test.scala

object Test:
  def makeQuery = QueryRequest.builder().build()
$ javac -version
javac 1.8.0_292

$ scalac -version
Scala compiler version 3.2.0-RC1-bin-SNAPSHOT-git-9101116 -- Copyright 2002-2022, LAMP/EPFL

$ javac -d out QueryRequest.java
$ scalac -d out -cp out Test.scala
$ scalac -d out -cp out -from-tasty out/Test.tasty

Output:

``` exception caught when loading trait Builder: Cyclic reference involving object QueryRequest exception caught when loading module class QueryRequest$: Cyclic reference involving object QueryRequest Cyclic reference involving object QueryRequest while compiling out/Test.tasty Exception in thread "main" 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:165) 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.classfile.ClassfileParser$innerClasses$.getMember$1(ClassfileParser.scala:1085) at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1106) at dotty.tools.dotc.core.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:116) at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:425) at dotty.tools.dotc.core.classfile.ClassfileParser.processTypeArgs$1(ClassfileParser.scala:412) at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:427) at dotty.tools.dotc.core.classfile.ClassfileParser.dotty$tools$dotc$core$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:551) at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:694) at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:219) 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:411) at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:406) at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:340) 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.unforcedDecls(SymDenotations.scala:385) at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParamsFromDecls(SymDenotations.scala:1790) at dotty.tools.dotc.core.SymDenotations$ClassDenotation.typeParams(SymDenotations.scala:1803) at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:38) at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:37) at scala.collection.immutable.List.mapConserve(List.scala:472) at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:42) at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:37) at scala.collection.immutable.List.mapConserve(List.scala:472) at dotty.tools.dotc.core.classfile.ClassfileParser$$anon$2.apply(ClassfileParser.scala:47) at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:720) at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:219) 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:411) at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:406) at dotty.tools.dotc.core.SymbolLoader$$anon$1.doComplete(SymbolLoaders.scala:325) at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:340) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167) 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:369) at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:64) at dotty.tools.dotc.core.SymDenotations$ModuleCompleter.complete(SymDenotations.scala:2690) at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167) 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:369) at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:64) at dotty.tools.dotc.core.SymDenotations$SymDenotation.is(SymDenotations.scala:106) at dotty.tools.dotc.core.SymDenotations$SymDenotation.isStableMember(SymDenotations.scala:739) at dotty.tools.dotc.core.Types$Type.widenIfUnstable(Types.scala:1257) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1278) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1210) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1274) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1210) at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1373) at dotty.tools.dotc.core.tasty.TreeUnpickler.readRhs$1$$anonfun$1$$anonfun$1(TreeUnpickler.scala:836) at dotty.tools.dotc.core.tasty.TreeUnpickler$LazyReader.complete(TreeUnpickler.scala:1510) at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy(Trees.scala:1029) at dotty.tools.dotc.ast.Trees$WithLazyField.forceIfLazy$(Trees.scala:1024) at dotty.tools.dotc.ast.Trees$ValOrDefDef.forceIfLazy(Trees.scala:418) at dotty.tools.dotc.ast.Trees$ValOrDefDef.rhs(Trees.scala:423) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1623) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1662) at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:146) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1535) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1537) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1630) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1662) at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:146) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1627) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1662) at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:146) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1661) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1535) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1537) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1636) at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1541) at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1662) at dotty.tools.dotc.CompilationUnit$Force.traverse(CompilationUnit.scala:146) at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:111) at dotty.tools.dotc.CompilationUnit$.apply(CompilationUnit.scala:102) at dotty.tools.dotc.fromtasty.ReadTasty.compilationUnit$1(ReadTasty.scala:42) at dotty.tools.dotc.fromtasty.ReadTasty.readTASTY(ReadTasty.scala:70) at dotty.tools.dotc.fromtasty.ReadTasty.runOn$$anonfun$1(ReadTasty.scala:25) at scala.collection.immutable.List.flatMap(List.scala:293) at dotty.tools.dotc.fromtasty.ReadTasty.runOn(ReadTasty.scala:25) at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225) 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:1328) at dotty.tools.dotc.Run.runPhases$1(Run.scala:236) at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244) at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253) at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68) at dotty.tools.dotc.Run.compileUnits(Run.scala:253) at dotty.tools.dotc.Run.compileUnits(Run.scala:192) at dotty.tools.dotc.fromtasty.TASTYRun.compile(TASTYRun.scala:14) 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) ```
griggt commented 2 years ago

Related: #14059

griggt commented 2 years ago

Likely also related, an older comment from scala-users Discord: https://discord.com/channels/632150470000902164/632150470000902166/914808520392712234

I've added cross-building against 3.1.0 to my project, however on the scaladoc phase of publishing I am now seeing exception caught when loading trait Builder: Cyclic reference involving object BatchWriteItemRequest, anyone seen anything like this before?

odersky commented 2 years ago

The error happens when trying to read the inner classes attribute in classfile parser

Cyclic reference involving object QueryRequest while compiling /Users/odersky/classes/Test.tasty
Exception in thread "main" 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:169)
    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.classfile.ClassfileParser$innerClasses$.getMember$1(ClassfileParser.scala:1088)
    at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1109)
    at dotty.tools.dotc.core.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:116)
    at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:425)
    at dotty.tools.dotc.core.classfile.ClassfileParser.processTypeArgs$1(ClassfileParser.scala:412)
    at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:427)
    at dotty.tools.dotc.core.classfile.ClassfileParser.dotty$tools$dotc$core$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:551)
    at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:694)
    at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:219)
    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:411)
    at dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:406)
    at dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:340)
paualarco commented 2 years ago

Is there any workaround for this issue? I am also experiencing it in monix-connect while running doc task against awssdk modules.

smarter commented 2 years ago

if you're cross-compiling, you could turn off scaladoc generation for scala 3 only:

Compile / doc / sources := { if (scalaVersion.value.startsWith("3.") Nil else (Compile / doc / sources).value }
paualarco commented 2 years ago

Thank you @smarter, that would make it.

mabasic commented 1 year ago

I have the same issue with this file:

https://github.com/mabasic/izradaweba/blob/master/src/main/scala/eu/izradaweba/mail/aws/v2/Ses.scala

Scala 3.2.0

In my build.sbt I have added this and now it works:

Compile / doc / sources := Nil

Thank you @smarter for the workaround and @armanbilge for pointing me in the right direction ❤️

For me the code compiles and runs correctly, but when I do sbt dist I get this error:

exception caught when loading trait Builder: Cyclic reference involving object Content
exception caught when loading module class Content$: Cyclic reference involving object Content

When using v1 of the aws sdk with similar code (https://github.com/mabasic/izradaweba/blob/master/src/main/scala/eu/izradaweba/mail/aws/v1/Ses.scala), I don't have this issue. Maybe the issue is in the aws sdk v2?