File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 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) {
21502150 case _ =>
21512151 cas
21522152 }
2153- def widenAbstractTypes (tp : Type ) = new TypeMap {
2153+ def widenAbstractTypes (tp : Type ): Type = new TypeMap {
21542154 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 _ : TypeBounds => WildcardType
2163+ case _ => mapOver(tp)
2164+ }
21562165 case tp : TypeVar if ! tp.isInstantiated => WildcardType
2157- case _ : SkolemType | _ : TypeParamRef => WildcardType
2166+ case _ : TypeParamRef => WildcardType
21582167 case _ => mapOver(tp)
21592168 }
21602169 }.apply(tp)
Original file line number Diff line number Diff line change @@ -71,3 +71,28 @@ object Test3 {
7171 def apply (fa : Bar [X & Foo ]): Bar [Y & Foo ] = fa
7272 }
7373}
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