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 @@ -1905,11 +1905,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1905
1905
case (tp1 : ConstantType , tp2 : ConstantType ) =>
1906
1906
tp1 == tp2
1907
1907
case (tp1 : TypeRef , tp2 : TypeRef ) if tp1.symbol.isClass && tp2.symbol.isClass =>
1908
- if (isSubType(tp1, tp2) || isSubType(tp2, tp1)) {
1908
+ val cls1 = tp1.classSymbol
1909
+ val cls2 = tp2.classSymbol
1910
+ if (cls1.derivesFrom(cls2) || cls2.derivesFrom(cls1)) {
1909
1911
true
1910
1912
} else {
1911
- val cls1 = tp1.classSymbol
1912
- val cls2 = tp2.classSymbol
1913
1913
if (cls1.is(Final ) || cls2.is(Final ))
1914
1914
// One of these types is final and they are not mutually
1915
1915
// subtype, so they must be unrelated.
Original file line number Diff line number Diff line change @@ -143,3 +143,13 @@ object Test {
143
143
identity[TD [Box2_C [Int , Int , Int ]]](1 )
144
144
identity[TD [Box2_C [Int , Int , String ]]](" " ) // error
145
145
}
146
+
147
+ object Test2 {
148
+ type M [A ] = A match {
149
+ case Option [Int ] => String
150
+ case Some [_] => Int
151
+ }
152
+
153
+ def a [A ]: M [Some [A ]] = 1 // error
154
+ def b [A ]: M [Some [A ]] = " " // error
155
+ }
You can’t perform that action at this time.
0 commit comments