File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -2771,7 +2771,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2771
2771
* @pre !(tp1 <: tp2) && !(tp2 <:< tp1) -- these cases were handled before
2772
2772
*/
2773
2773
private def distributeAnd (tp1 : Type , tp2 : Type ): Type = tp1 match {
2774
- case tp1 @ AppliedType (tycon1, args1) =>
2774
+ case tp1 @ AppliedType (tycon1, args1) if false =>
2775
2775
tp2 match {
2776
2776
case AppliedType (tycon2, args2)
2777
2777
if tycon1.typeSymbol == tycon2.typeSymbol && tycon1 =:= tycon2 =>
Original file line number Diff line number Diff line change
1
+
2
+ type Or [+ A , + B ] = A | B
3
+
4
+ object Test1 :
5
+ val x : Or [Int , String ] & Or [String , Int ] = 3
6
+ val y : Or [Int & String , String & Int ] = x // error
7
+ val z : String = y
8
+
9
+ // shows the distributeAnd logic should not be applied even when
10
+ // the targs are pairwise TypeComparer#singletonInterval
11
+ object Test2 :
12
+ val x : Or [" 3" , Singleton ] & Or [Singleton , " 3" ] = 3
13
+ val y : Or [" 3" , " 3" ] = x // error
14
+ val z : String = y
Original file line number Diff line number Diff line change
1
+
2
+ trait L [+ A ]{val a : A }
3
+ trait R [+ B ]{val b : B }
4
+
5
+ class LR (val a : Int , val b : String ) extends L [Int ] with R [String ]
6
+
7
+ type E [+ A ] = L [A ] | R [A ]
8
+
9
+ val x : E [Int ] & E [String ] = LR (4 , " hi" )
10
+ val y : E [Int & String ] = x // error
11
+
12
+ val z = y match
13
+ case l : L [Int & String ] => l.a
14
+ case r : R [Int & String ] => r.b
15
+
16
+ val _ = z: String // was: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String
You can’t perform that action at this time.
0 commit comments