Skip to content

Package objects extending traits can crash multi-stage compilation #15980

Closed
@WojciechMazur

Description

@WojciechMazur

Regression reproduced based on Open CB #4757 found in vitaliihonta/scala-ql (maintainer @vitaliihonta )
In the original build all files defined in submodules or tests placed in the same package (scalaql) were failing with large amount of errors related to cyclic references.

Part of the #15949 regression tracker

Compiler version

Fails in 3.2.1-RC1
Works in 3.2.0

Minimized code

The order of files within the compilation unit is important to reproduce:
Prefix ids combined with suffix unit id should allow to reproduce it in Vulpix
1st compilation unit:

// 1_syntax_1.scala
package scalaql.syntax

import scalaql.*

@forbiddenInheritance
trait ScalaqlSyntax
// 2_annotations_1.scala
package scalaql

import scala.annotation.StaticAnnotation

class forbiddenInheritance extends StaticAnnotation
// 3_package_1.scala
import scalaql.syntax.ScalaqlSyntax

package object scalaql extends ScalaqlSyntax

2nd compilation unit

// usage_2.scala
package scalaql

sealed trait Foo extends Product

Invocation:

scalac 1_syntax_1.scala 2_annotations_1.scala 3_package_1.scala 
scalac usage_2.scala 

Output

-- Error: usage_2.scala:3:25 -------------------------------------------------------------------------------------------------------------------
3 |sealed trait Foo extends Product
  |                         ^
  |                         Could not read definition of trait ScalaqlSyntax in ./scalaql/syntax/ScalaqlSyntax.class
  |                         An exception was encountered:
  |                           dotty.tools.dotc.core.CyclicReference: 
  |                         Run with -Ydebug-unpickling to see full stack trace.

Expectation

Should compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugregressionThis worked in a previous version but doesn't anymorestat:needs bisectionNeed to use nightly builds and git bisect to find out the commit where this issue was introduced

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions