File tree 2 files changed +37
-3
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -2150,11 +2150,20 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2150
2150
case _ =>
2151
2151
cas
2152
2152
}
2153
- def widenAbstractTypes (tp : Type ) = new TypeMap {
2153
+ def widenAbstractTypes (tp : Type ): Type = new TypeMap {
2154
2154
def apply (tp : Type ) = tp match {
2155
- case tp : TypeRef if tp.symbol.isAbstractOrParamType | tp.symbol.isOpaqueAlias => WildcardType
2155
+ case tp : TypeRef =>
2156
+ if (tp.symbol.isAbstractOrParamType | tp.symbol.isOpaqueAlias)
2157
+ WildcardType
2158
+ else tp.info match {
2159
+ case TypeAlias (alias) =>
2160
+ val alias1 = widenAbstractTypes(alias)
2161
+ if (alias1 ne alias) alias1 else tp
2162
+ case _ => mapOver(tp)
2163
+ }
2164
+
2156
2165
case tp : TypeVar if ! tp.isInstantiated => WildcardType
2157
- case _ : SkolemType | _ : TypeParamRef => WildcardType
2166
+ case _ : TypeParamRef => WildcardType
2158
2167
case _ => mapOver(tp)
2159
2168
}
2160
2169
}.apply(tp)
Original file line number Diff line number Diff line change @@ -71,3 +71,28 @@ object Test3 {
71
71
def apply (fa : Bar [X & Foo ]): Bar [Y & Foo ] = fa
72
72
}
73
73
}
74
+
75
+ object Test4 {
76
+ type Bar [A ] = A match {
77
+ case X => String
78
+ case Y => Int
79
+ }
80
+
81
+ trait XX {
82
+ type Foo
83
+ type FooAlias = Foo
84
+
85
+ val a : Bar [X & FooAlias ] = " hello"
86
+ val b : Bar [Y & FooAlias ] = 1 // error
87
+
88
+ def apply (fa : Bar [X & FooAlias ]): Bar [Y & FooAlias ]
89
+
90
+ def boom : Int = apply(a) // error
91
+ }
92
+
93
+ trait YY extends XX {
94
+ type Foo = X & Y
95
+
96
+ def apply (fa : Bar [X & FooAlias ]): Bar [Y & FooAlias ] = fa
97
+ }
98
+ }
You can’t perform that action at this time.
0 commit comments