File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -736,8 +736,12 @@ class TypeComparer(initctx: Context) extends DotClass {
736
736
def fourthTry (tp1 : Type , tp2 : Type ): Boolean = tp1 match {
737
737
case tp1 : TypeRef =>
738
738
tp1.info match {
739
- case TypeBounds (lo1, hi1) =>
740
- isSubType(hi1, tp2)
739
+ case TypeBounds (lo1, hi1) => tp2 match {
740
+ case tp2 : NamedType if tp1.name == tp2.name =>
741
+ isSubType(tp1.info, tp2.info)
742
+ case _ =>
743
+ isSubType(hi1, tp2)
744
+ }
741
745
case _ =>
742
746
(tp1.symbol eq NothingClass ) && tp2.isInstanceOf [ValueType ] ||
743
747
(tp1.symbol eq NullClass ) && tp2.dealias.typeSymbol.isNullableClass
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ class tests extends CompilerTest {
52
52
@ Test def pos_approximateUnion = compileFile(posDir, " approximateUnion" , doErase)
53
53
@ Test def pos_tailcall = compileDir(posDir + " tailcall/" , doErase)
54
54
@ Test def pos_nullarify = compileFile(posDir, " nullarify" , " -Ycheck:nullarify" :: doErase)
55
+ @ Test def pos_subtyping = compileFile(posDir, " subtyping" , doErase)
55
56
56
57
@ Test def pos_all = compileFiles(posDir, twice)
57
58
@ Test def new_all = compileFiles(newDir, twice)
Original file line number Diff line number Diff line change
1
+ class C1
2
+ class C2 extends C1
3
+ class C3 extends C2
4
+ class C4 extends C3
5
+
6
+ object Test {
7
+ // Test DOT rule TDECL-<:
8
+ def test_typebounds (): Unit = {
9
+ val c31 : { type T >: C3 <: C1 } = ???
10
+ val c41 : { type T >: C4 <: C1 } = ???
11
+ val c42 : { type T >: C4 <: C2 } = ???
12
+ implicitly[c31.T <:< c41.T ]
13
+ implicitly[c42.T <:< c41.T ]
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments