forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid forcing ctors & parents which caused cycles
- Loading branch information
Showing
21 changed files
with
238 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Like tests/neg/i15177.FakeEnum.min.scala | ||
// But with an actual upper-bound requirement | ||
// Which shouldn't be ignored as a part of overcoming the the cycle | ||
trait Foo | ||
trait X[T <: Foo] { trait Id } | ||
object A extends X[B] // error: Type argument B does not conform to upper bound Foo | ||
class B extends A.Id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// An example of how constructor _type_ parameters | ||
// Which can _not_ be passed to the extends part | ||
// That makes it part of the parent type, | ||
// which has been found to be unsound. | ||
class Foo[A] | ||
class Foo1(val x: Int) | ||
extends Foo[ // error: The type of a class parent cannot refer to constructor parameters, but Foo[(Foo1.this.x : Int)] refers to x | ||
x.type | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// like tests/pos/i15177.scala | ||
// but with T having an upper bound | ||
// that B doesn't conform to | ||
// just to be sure that not forcing B | ||
// doesn't backdoor an illegal X[B] | ||
class X[T <: C] { | ||
type Id | ||
} | ||
object A | ||
extends X[ // error | ||
B] // error | ||
class B(id: A.Id) | ||
class C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Like tests/neg/i15177.FakeEnum.min.scala | ||
// With an actual upper-bound requirement | ||
// But that is satisfied on class B | ||
trait Foo | ||
trait X[T <: Foo] { trait Id } | ||
object A extends X[B] | ||
class B extends A.Id with Foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Like tests/neg/i15177.FakeEnum.min.scala | ||
// With an actual upper-bound requirement | ||
// But that is satisfied on trait Id | ||
trait Foo | ||
trait X[T <: Foo] { trait Id extends Foo } | ||
object A extends X[B] | ||
class B extends A.Id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Minimisation of tests/neg/i15177.FakeEnum.scala | ||
trait X[T] { trait Id } | ||
object A extends X[B] | ||
class B extends A.Id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// From https://github.com/scala/scala3/issues/15177#issuecomment-1463088400 | ||
trait FakeEnum[A, @specialized(Byte, Short, Int, Long) B] | ||
{ | ||
trait Value { | ||
self: A => | ||
def name: String | ||
def id: B | ||
} | ||
} | ||
|
||
object FakeEnumType | ||
extends FakeEnum[FakeEnumType, Short] | ||
{ | ||
val MEMBER1 = new FakeEnumType((0: Short), "MEMBER1") {} | ||
val MEMBER2 = new FakeEnumType((1: Short), "MEMBER2") {} | ||
} | ||
|
||
sealed abstract | ||
class FakeEnumType(val id: Short, val name: String) | ||
extends FakeEnumType.Value | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// like tests/pos/i15177.scala | ||
// but with an applied type B[D] | ||
class X[T] { type Id } | ||
object A extends X[B[D]] | ||
class B[C](id: A.Id) | ||
class D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// An example of how constructor _term_ parameters | ||
// Can be passed to the extends part | ||
// But that doesn't mean the parent type, | ||
// it's just the super constructor call. | ||
class Bar(val y: Long) | ||
class Bar1(val z: Long) extends Bar(z) |
Oops, something went wrong.