Skip to content

Strange Cyclic reference error with incremental compilation #21636

Open
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3.5.1

Minimized code

Not yet (and I doubt I am able to provide it). The issue happens about 1 in 5 compilations and when it happens, it usually goes away on subsequent compilation attempt.

Some relevant parts of the code are here:

case class PositionWithDirection(pos: Vector3f, dir: Option[Vector3f]) {
  def orientation: Quaternion = dir.map(simpleRotation(Vector3f.UNIT_Z, _)).getOrElse(Quaternion())
  def shift(fwd: Double): PositionWithDirection = copy(pos + fwd * dir.map(_.normalized).getOrElse(Vector3f.UNIT_Z))
  def invert: PositionWithDirection = copy(dir = dir.map(-_))
}

def failForBadDirection(pos: PositionWithDirection): Unit = {
???
}

opaque type Vector3f = threex.Vector3

object PlanManager {

  extension(plan: Plan) {
    def onSurface(pos: PositionWithDirection) = PositionWithDirection(plan.state.world.terrain.posOnSurface(pos.pos.xz), pos.dir)
  }

  export PlanExtensions.*
  object PlanExtensions {
    extension[T >: Null <: ES[T]](plan: APlan[T]) {
      def until(s: State, t: Long): APlan.APlanFuture[T, Plan.Done] = {
         ???
      }
  }
}

Output

Normally this compiles fine, but sometimes with incremental compilation I get following error:

case class PositionWithDirection(pos: Vector3f, dir: Option[Vector3f]) {
[error]     |                                        ^
[error]     |Cyclic reference involving val pos
[error]     |
[error]     |The error occurred while trying to compute the signature of method failForBadDirection
[error]     |  which required to compute the signature of class PositionWithDirection
[error]     |  which required to compute the signature of constructor PositionWithDirection
[error]     |  which required to compute the signature of parameter pos
[error]     |  which required to compute the signature of object PlanManager
[error]     |  which required to elaborate the export clause export net.gamatron.procas.game.state.PlanManager.PlanExtensions.*
[error]     |  which required to compute the signature of method onSurface
[error]     |  which required to type the right hand side of method onSurface since no explicit type was given
[error]     |  which required to compute the signature of method apply
[error]     |  which required to compute the signature of parameter pos
[error]     |  which required to compute the signature of parameter pos

Expectation

  • either the code compiles always or never. Incremental compilation should make no difference
  • the error information should be more specific: signature of method apply or signature of parameter pos - how can I know which object is this in?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions