Skip to content
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

Strange Cyclic reference error with incremental compilation #21636

Open
OndrejSpanel opened this issue Sep 24, 2024 · 0 comments
Open

Strange Cyclic reference error with incremental compilation #21636

OndrejSpanel opened this issue Sep 24, 2024 · 0 comments
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@OndrejSpanel
Copy link
Member

OndrejSpanel commented Sep 24, 2024

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?
@OndrejSpanel OndrejSpanel added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant