From d733e7089b86610d1b20b5c6b356e0ce14e19ecf Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 8 Jan 2018 18:21:38 +0100 Subject: [PATCH] Fix #3775: Fix RefChecks#upwardsThisType A non-applied class TypeRef is not a valid prefix for a TypeRef of a class type parameter, it causes an assertion error in NamedType#argDenot because args.nonEmpty ends up false. --- compiler/src/dotty/tools/dotc/typer/RefChecks.scala | 2 +- tests/neg/i3775.scala | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i3775.scala diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index aaadbb66ec12..b42f09da4bdc 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -86,7 +86,7 @@ object RefChecks { */ private def upwardsThisType(cls: Symbol)(implicit ctx: Context) = cls.info match { case ClassInfo(_, _, _, _, tp: Type) if (tp ne cls.typeRef) && !cls.is(ModuleOrFinal) => - SkolemType(cls.typeRef).withName(nme.this_) + SkolemType(cls.appliedRef).withName(nme.this_) case _ => cls.thisType } diff --git a/tests/neg/i3775.scala b/tests/neg/i3775.scala new file mode 100644 index 000000000000..0735e662d1af --- /dev/null +++ b/tests/neg/i3775.scala @@ -0,0 +1,8 @@ +trait Iterator[A] { + def next(): A +} + +class IntMapIterator[T] extends Iterator[T] { + def next: T = ??? // error: overriding method next in trait Iterator of type (): IntMapIterator.this.T; + // method next of type => IntMapIterator.this.T has incompatible type +}