Closed
Description
Compiler version
3.2.1
3.2.2-RC2
Minimized code
Important: We need 2 separete files, or else the error won't happen.
Foo.scala:
final class Foo(_that: Foo) extends FooStub(_that)
FooStub.scala:
abstract class FooStub(val that: Foo):
val bar = 1337;
Output
Clean compile succeeds.
To trigger the error, do the following:
- Use
~compile
in sbt - Make a minor change to
FooStub
source: add or remove 1 digit frombar
[error] -- Error: /myproject/FooStub.scala:2:27
[error] 2 |abstract class FooStub(val that: Foo):
[error] | ^
[error] |Could not read definition of class Foo in /myproject/target/scala-3.2.2-RC2/classes/Foo.class
[error] |An exception was encountered:
[error] | dotty.tools.dotc.core.CyclicReference:
[error] |Run with -Ydebug-unpickling to see full stack trace.
Again, clean recompile succeeds. Until another minor change of source.
After adding suggested -Ydebug-unpickling
and -explain
options, got this:
[error] -- [E046] Cyclic Error: /myproject/FooStub.scala:3:27
[error] 3 |abstract class FooStub(val that: Foo):
[error] | ^
[error] | Cyclic reference involving method <init>
[error] |-----------------------------------------------------------------------------
[error] | Explanation (enabled by `-explain`)
[error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error] | constructor FooStub is declared as part of a cycle which makes it impossible for the
[error] | compiler to decide upon <init>'s type.
[error] | To avoid this error, try giving <init> an explicit type.
[error] -----------------------------------------------------------------------------
[error] Explanation
[error] ===========
[error] constructor FooStub is declared as part of a cycle which makes it impossible for the
[error] compiler to decide upon <init>'s type.
[error] To avoid this error, try giving <init> an explicit type.
Also, this thing showed up once:
OpenJDK 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
OpenJDK 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
CodeCache: size=131072Kb used=86902Kb max_used=127348Kb free=44169Kb
bounds [0x00007f8e00000000, 0x00007f8e08000000, 0x00007f8e08000000]
total_blobs=21123 nmethods=20197 adapters=828
compilation: enabled