From 629dae0d00a51c5bb097d968280238da72d01f91 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 14 Oct 2014 20:55:55 +0200 Subject: Fix subtyping checks involving ThisType and PolyParam --- src/dotty/tools/dotc/core/TypeComparer.scala | 2 +- test/dotc/tests.scala | 1 + tests/pos/subtyping.scala | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pos/subtyping.scala diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 5261f7dcf..feb4c6b74 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -486,7 +486,7 @@ class TypeComparer(initctx: Context) extends DotClass { if (solvedConstraint && (constraint contains tp2)) isSubType(tp1, bounds(tp2).lo) else isSubTypeWhenFrozen(tp1, bounds(tp2).lo) || { - if (isConstrained(tp2)) addConstraint(tp2, tp1.widen, fromBelow = true) + if (isConstrained(tp2)) addConstraint(tp2, tp1.widenExpr, fromBelow = true) else (ctx.mode is Mode.TypevarsMissContext) || secondTry(tp1, tp2) } } diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index aafd5e924..966c231e4 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -56,6 +56,7 @@ class tests extends CompilerTest { @Test def pos_approximateUnion = compileFile(posDir, "approximateUnion", doErase) @Test def pos_tailcall = compileDir(posDir + "tailcall/", doErase) @Test def pos_nullarify = compileFile(posDir, "nullarify", "-Ycheck:nullarify" :: doErase) + @Test def pos_subtyping = compileFile(posDir, "subtyping", doErase) @Test def pos_all = compileFiles(posDir, twice) @Test def new_all = compileFiles(newDir, twice) diff --git a/tests/pos/subtyping.scala b/tests/pos/subtyping.scala new file mode 100644 index 000000000..a5e156780 --- /dev/null +++ b/tests/pos/subtyping.scala @@ -0,0 +1,6 @@ +class A { + def test1(): Unit = { + implicitly[this.type <:< this.type] + implicitly[this.type <:< A] + } +} -- cgit v1.2.3