From 2a7296e6a605d57bee827842314687c726f5db54 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Thu, 9 Apr 2020 20:26:37 +0200 Subject: [PATCH] Fix #8647: Remove TypeParamRef from instantiated test --- .../dotty/tools/dotc/core/TypeComparer.scala | 2 +- tests/pos/8647.scala | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/pos/8647.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index e2ba1745c1d3..5744461c1ca0 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -2359,7 +2359,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w x && { t match { case tp: TypeRef if tp.symbol.isAbstractOrParamType => false - case _: SkolemType | _: TypeVar | _: TypeParamRef => false + case _: SkolemType | _: TypeVar => false case _ => foldOver(x, t) } } diff --git a/tests/pos/8647.scala b/tests/pos/8647.scala new file mode 100644 index 000000000000..5e8f839b27ca --- /dev/null +++ b/tests/pos/8647.scala @@ -0,0 +1,53 @@ +final class Two[A, B]() + +final class Blaaa + +final class Bla[X] + +object Test1 { + + type Foo[X] = X match + case Two[Blaaa, _] => + String + case Two[String, _] => + Int + + def test: Foo[Two[String, String]] = 1 +} + +object Test2 { + type Foo[X] = X match + case Two[Bla[_], _] => + String + case Two[String, _] => + Int + + def test: Foo[Two[String, String]] = 1 +} + + +object Test3 { + type Id[W] = W + + type M[X, Y] = X match { + case Int => String + case Id[x] => Y match { + case Two[Bla[a], _] => Int + case _ => String + } + } + val x: M[Boolean, Two[Boolean, Boolean]] = "" +} + +object Test4 { + type Id[W] = W + + type M[X, Y] = X match { + case Int => String + case Id[x] => Y match { + case Two[Bla[`x`], _] => Int + case _ => String + } + } + val x: M[Boolean, Two[Bla[Boolean], Boolean]] = 1 +}