-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve handling of AndTypes on the LHS of subtype comparisons #18235
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0ef4944
Improve handling of AndTypes on the LHS of subtype comparisons
odersky 71dd329
Test case #12077
odersky 3a252a7
Fix new problem uncovered by AndType fix
odersky 9b73493
Consistent type naming in computeBase to avoid shadowing problems
odersky 655851c
Simplify logic in TypeComparer
odersky 5ecb8c0
Generalize logic by using `either`
odersky 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 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 @@ | ||
trait Wrapper[K] | ||
trait Has0[T] | ||
|
||
def test[R](v: Wrapper[Has0[String] with R]):R = ??? | ||
|
||
val zz:Wrapper[Has0[String] with Has0[Int]] = ??? | ||
val _ = test(zz) |
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,11 @@ | ||
trait F[-R] | ||
|
||
trait Row[A] | ||
|
||
def eliminateInt[R](f: F[R & Row[Int]]): F[R] = new F[R] {} | ||
|
||
val x = new F[Row[Int] & Row[String]] {} | ||
|
||
val _ = eliminateInt[Row[String]](x) // compiles OK when given explicit type | ||
val y = eliminateInt(x) // was error | ||
val _: F[Row[String]] = y |
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,19 @@ | ||
class Has[A] | ||
trait Foo | ||
|
||
class TestAspect[+LowerR, -UpperR] | ||
|
||
class Spec[-R] { | ||
def foo[R1 <: R](aspect: TestAspect[R1, R1]): Unit = {} | ||
} | ||
|
||
class SuiteBuilder[R <: Has[_]] { | ||
def toSpec( | ||
spec: Spec[R & Has[Foo]], | ||
aspect: TestAspect[ | ||
R & Has[Foo], | ||
R & Has[Foo] | ||
] | ||
) = | ||
spec.foo(aspect) | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call the operands
tp11
andtp12
to avoid shadowing the existing tp1/tp2.