Skip to content

Commit 39c27b6

Browse files
authored
Merge pull request #1850 from dotty-staging/fix-#1845
Fix #1845: Survive illegal this-type prefixes
2 parents 5b984ac + 18bc638 commit 39c27b6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ trait TypeAssigner {
282282

283283
def assignType(tree: untpd.This)(implicit ctx: Context) = {
284284
val cls = qualifyingClass(tree, tree.qual.name, packageOK = false)
285-
tree.withType(cls.thisType)
285+
tree.withType(
286+
if (cls.isClass) cls.thisType
287+
else errorType("not a legal qualifying class for this", tree.pos))
286288
}
287289

288290
def assignType(tree: untpd.Super, qual: Tree, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context) = {

tests/neg/i1845.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
type X = FooBar22.this // error
3+
} // error

0 commit comments

Comments
 (0)