-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of AndTypes on the LHS of subtype comparisons (#18235)
- Loading branch information
Showing
6 changed files
with
72 additions
and
15 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
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) | ||
} |
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