-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Avoid forcing ctors & parents which caused cycles #17086
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
{} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.