Closed steven-barnes closed 1 year 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:
Related: #14059
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?
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)
Is there any workaround for this issue? I am also experiencing it in monix-connect while running doc
task against awssdk modules.
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 }
Thank you @smarter, that would make it.
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?
Compiler version
3.1.2
Minimized code
Output (click arrow to expand)