scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Early Java pickling fails with static self-imports #12743

Open szeiger opened 1 year ago

szeiger commented 1 year ago

Early Java pickling (using -Ypickle-java) fails with static self-imports. Given C.java:

import static C.*;
import java.util.*;
public class C {}
$ ~/scala/scala-2.13.10/bin/scalac -Ypickle-java -Ypickle-write c-pickle.jar -d c.jar C.java
C.java:2: error: encountered unrecoverable cycle resolving import.
Note: this is often due in part to a class depending on a definition nested within its companion.
If applicable, you may wish to try moving some members into another object.
import java.util.*;
       ^
C.java:3: error: illegal cyclic reference involving class C
public class C {}
             ^
2 errors

The first error is a follow-on triggered by import java.util.*;. It only occurs together with the original error triggered by import static C.*;. I encountered this originally in 2.12.15 and it is reproducible in 2.13.10. The file compiles correctly without -Ypickle-java.