Skip to content

Commit 8d44da5

Browse files
committed
Merge pull request #192 from smarter/fix/ThisType-subtyping
Fix subtyping checks involving ThisType and PolyParam
2 parents b164b6d + 629dae0 commit 8d44da5

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class TypeComparer(initctx: Context) extends DotClass {
486486
if (solvedConstraint && (constraint contains tp2)) isSubType(tp1, bounds(tp2).lo)
487487
else
488488
isSubTypeWhenFrozen(tp1, bounds(tp2).lo) || {
489-
if (isConstrained(tp2)) addConstraint(tp2, tp1.widen, fromBelow = true)
489+
if (isConstrained(tp2)) addConstraint(tp2, tp1.widenExpr, fromBelow = true)
490490
else (ctx.mode is Mode.TypevarsMissContext) || secondTry(tp1, tp2)
491491
}
492492
}

test/dotc/tests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class tests extends CompilerTest {
5656
@Test def pos_approximateUnion = compileFile(posDir, "approximateUnion", doErase)
5757
@Test def pos_tailcall = compileDir(posDir + "tailcall/", doErase)
5858
@Test def pos_nullarify = compileFile(posDir, "nullarify", "-Ycheck:nullarify" :: doErase)
59+
@Test def pos_subtyping = compileFile(posDir, "subtyping", doErase)
5960

6061
@Test def pos_all = compileFiles(posDir, twice)
6162
@Test def new_all = compileFiles(newDir, twice)

tests/pos/subtyping.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
def test1(): Unit = {
3+
implicitly[this.type <:< this.type]
4+
implicitly[this.type <:< A]
5+
}
6+
}

0 commit comments

Comments
 (0)