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

inappropriate cyclic aliasing #9568

Closed
scabug opened this issue Nov 24, 2015 · 1 comment · Fixed by scala/scala#10626
Closed

inappropriate cyclic aliasing #9568

scabug opened this issue Nov 24, 2015 · 1 comment · Fixed by scala/scala#10626
Assignees
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Milestone

Comments

@scabug
Copy link

scabug commented Nov 24, 2015

I catch strange type checker behavior that produce type error from nowhere.

object Cyclic {
  class Node[T]() {
    type Self = T
  }

  val nodeA = new Node[Int]()
  val nodeB = new NodeB(a => a)
  val nodeC = new NodeC(a => a)
  /*
  val nodeB = new NodeB(a => a + 1)
  val nodeC = new NodeC(a => a + 1)
  */
  val nodeD = new NodeD( (b,c) => b + c )

  class NodeB[T](fun : Function[nodeA.Self, T]) extends Node[T]
  class NodeC[T](fun : Function[nodeA.Self, T]) extends Node[T]
  class NodeD[T](fun : Function2[nodeB.Self, nodeC.Self, T]) extends Node[T]
}

The snipped produce following error:

CyclicAliasing.scala:98: error: cyclic aliasing or subtyping involving type Self
  val nodeD = new NodeD( (b,c) => b + c )
                          ^
CyclicAliasing.scala:98: error: cyclic aliasing or subtyping involving type Self
  val nodeD = new NodeD( (b,c) => b + c )
                            ^
two errors found

I could not reduce the example further. Small changes miraculously cure the code and it compiles. I gave two examples as comments. Small change i => i with i => i + 1 make type checker happy.

@scabug
Copy link
Author

scabug commented Nov 24, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9568?orig=1
Reporter: mordenkainen
Affected Versions: 2.11.7

@scabug scabug added the typer label Apr 7, 2017
@pabloazul pabloazul added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Nov 21, 2019
@pabloazul pabloazul added this to the Backlog milestone Nov 21, 2019
@lrytz lrytz modified the milestones: Backlog, 2.13.13 Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants