-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cyclic reference involving class, when using java packages #9492
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
This might be of interest: scala/bug#3809 |
More isolated bug repro thanks to @smarter // DerivedClass.java
package CyclicRefAnnArray;
import java.lang.*;
@interface BaseClassAnn {
Type[] value();
@interface Type {
Class<?> value();
}
}
@BaseClassAnn({
@BaseClassAnn.Type(value=DerivedClass.class)
})
abstract class BaseClass {}
class DerivedClass extends BaseClass {} // main.scala
package CyclicRefAnnArray;
object Main {
def oops: DerivedClass = ???
def main(args: Array[String]): Unit = {
println("ok")
}
} Compile and run with: |
Java allows annotations inside arrays inside annotations, when parsing the outer annotation, we need to produce an untyped tree for the array and therefore the nested annotations. Previously this was done using `Annotation#tree` which actually produces a typed tree, this works since typed trees can be used as untyped tree but it requires forcing the content of the nested annotation which can lead to cycles. Instead, we now use a dedicated subclass of Annotation with an extra `untpdTree` method we use for the purpose of generating a tree for the nested annotation without forcing anything.
Fix #9492: Avoid forcing nested annotation
I'm still getting this with The Java library I'm using is A minimal reproduction is def oops = org.apache.avro.SchemaBuilder.builder().fixed("foo") scastie reproduction (3.0.0-M1) Output with
|
@bplommer There's many different things that can cause cycles, please open a new issue for the problem you're encountering. |
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
Expectation
Compilation succeeds.
The text was updated successfully, but these errors were encountered: