Skip to content

Commit

Permalink
Fix #5044: guard against forward references in the TypeTree of New trees
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper-M committed Sep 28, 2018
1 parent 19cdeb4 commit e7c9fce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,14 @@ class RefChecks extends MiniPhase { thisPhase =>
}

override def transformNew(tree: New)(implicit ctx: Context) = {
val sym = tree.tpe.typeSymbol
val tpe = tree.tpe
val sym = tpe.typeSymbol
checkUndesiredProperties(sym, tree.pos)
currentLevel.enterReference(sym, tree.pos)
tpe.dealias.foreachPart {
case TermRef(_, s: Symbol) => currentLevel.enterReference(s, tree.pos)
case _ =>
}
tree
}
}
Expand Down Expand Up @@ -1643,4 +1648,3 @@ class RefChecks extends MiniPhase { thisPhase =>
}
}
*/

7 changes: 7 additions & 0 deletions tests/neg/i5044a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class I0 {
class I1
def i3 = {
val i4 = new i5.I1 // error: `i5` is a forward reference extending over the definition of `i4`
val i5 = new I0
}
}
8 changes: 8 additions & 0 deletions tests/neg/i5044b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class I0 {
class I1
def i3 = {
type T = i5.I1
val i4 = new T // error: `i5` is a forward reference extending over the definition of `i4`
val i5 = new I0
}
}

0 comments on commit e7c9fce

Please sign in to comment.