File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ trait ConstraintHandling[AbstractContext] {
345
345
else {
346
346
val saved = constraint
347
347
try
348
- c2 .forallParams(p =>
348
+ pre .forallParams(p =>
349
349
c1.contains(p) &&
350
350
c2.upper(p).forall(c1.isLess(p, _)) &&
351
351
isSubTypeWhenFrozen(c1.nonParamBounds(p), c2.nonParamBounds(p)))
Original file line number Diff line number Diff line change @@ -2,16 +2,26 @@ object Test {
2
2
trait T1 [A ] { def a : A }
3
3
trait T2 [B ] { def b : B }
4
4
5
- def foo [X , Y ](u : T1 [X ] | T2 [Y ]): X = u match {
5
+ def foo [X , Y ](v : T1 [X ] | T2 [Y ]): X = v match {
6
6
case t1 : T1 [t] =>
7
7
// consider: foo[Int, String](new T1[String] with T2[String] { ... })
8
8
t1.a // error
9
9
}
10
10
11
11
class T1Int extends T1 [Int ] { def a = 0 }
12
- def bar [X , Y ](u : T1 [X ] | T2 [Y ]): X = u match {
12
+ def bar [X , Y ](v : T1 [X ] | T2 [Y ]): X = v match {
13
13
case t1 : T1Int =>
14
14
// similar reasoning to above applies
15
15
t1.a // error
16
16
}
17
+
18
+ class T1IntT2String extends T1 [Int ] with T2 [String ] {
19
+ def a = 0
20
+ def b = " "
21
+ }
22
+ def baz [X ](v : T1 [X ] | T2 [X ]): Unit = v match {
23
+ case _ : T1IntT2String =>
24
+ val x1 : X = 0 // error
25
+ val x2 : X = " " // error
26
+ }
17
27
}
You can’t perform that action at this time.
0 commit comments