File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +45
-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
+ val c11 : { type T >: C1 <: C1 } = ???
8
+ val c21 : { type T >: C2 <: C1 } = ???
9
+ val c22 : { type T >: C2 <: C2 } = ???
10
+ val c31 : { type T >: C3 <: C1 } = ???
11
+ val c32 : { type T >: C3 <: C2 } = ???
12
+ val c33 : { type T >: C3 <: C3 } = ???
13
+ val c41 : { type T >: C4 <: C1 } = ???
14
+ val c42 : { type T >: C4 <: C2 } = ???
15
+ val c43 : { type T >: C4 <: C3 } = ???
16
+ val c44 : { type T >: C4 <: C4 } = ???
17
+
18
+ // Test DOT rule TDECL-<:
19
+ // This is different from scalac
20
+ def test_tdecl_lt_colon (): Unit = {
21
+ implicitly[c31.T <:< c41.T ]
22
+ implicitly[c42.T <:< c41.T ]
23
+ }
24
+
25
+ // Test DOT rule TSEL-<:
26
+ def test_tsel_lt_colon (): Unit = {
27
+ implicitly[c42.T <:< c11.T ]
28
+ implicitly[c42.T <:< c21.T ]
29
+ implicitly[c42.T <:< c22.T ]
30
+ }
31
+
32
+ // Test DOT rule <:-TSEL
33
+ def test_lt_colon_tsel (): Unit = {
34
+ implicitly[c33.T <:< c32.T ]
35
+ implicitly[c43.T <:< c32.T ]
36
+ implicitly[c44.T <:< c32.T ]
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments