From 9474382efe948da34c68bce9a76890bb22e367e4 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 22 Dec 2016 13:58:49 +0100 Subject: Fix #1845: Survive illegal this-type prefixes --- compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 4a97648f5..5c07b7bcf 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -282,7 +282,9 @@ trait TypeAssigner { def assignType(tree: untpd.This)(implicit ctx: Context) = { val cls = qualifyingClass(tree, tree.qual.name, packageOK = false) - tree.withType(cls.thisType) + tree.withType( + if (cls.isClass) cls.thisType + else errorType("not a legal qualifying class for this", tree.pos)) } def assignType(tree: untpd.Super, qual: Tree, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context) = { -- cgit v1.2.3