diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala | 4 | ||||
-rw-r--r-- | tests/neg/i1845.scala | 3 |
2 files changed, 6 insertions, 1 deletions
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) = { diff --git a/tests/neg/i1845.scala b/tests/neg/i1845.scala new file mode 100644 index 000000000..e3e5787e6 --- /dev/null +++ b/tests/neg/i1845.scala @@ -0,0 +1,3 @@ +object Test { + type X = FooBar22.this // error +} // error |