Skip to content

Commit f61596b

Browse files
committed
Survive untyped trees in eta expansion
Untyped trees may appear in programs that already had some errors reported.
1 parent 33e6ca1 commit f61596b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10041004
def sameTypes(trees: List[tpd.Tree], trees1: List[tpd.Tree]): Boolean = {
10051005
if (trees.isEmpty) trees.isEmpty
10061006
else if (trees1.isEmpty) trees.isEmpty
1007-
else (trees.head.tpe eq trees1.head.tpe) && sameTypes(trees.tail, trees1.tail)
1007+
else (trees.head.typeOpt eq trees1.head.typeOpt) && sameTypes(trees.tail, trees1.tail)
10081008
}
10091009

10101010
def evalOnce(tree: Tree)(within: Tree => Tree)(implicit ctx: Context) = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class Lifter {
4343
protected def liftedDef(sym: TermSymbol, rhs: Tree)(implicit ctx: Context): MemberDef = ValDef(sym, rhs)
4444

4545
private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(implicit ctx: Context): Tree =
46-
if (noLift(expr)) expr
46+
if (noLift(expr) || !expr.hasType && ctx.reporter.errorsReported) expr
4747
else {
4848
val name = UniqueName.fresh(prefix)
4949
var liftedType = fullyDefinedType(expr.tpe.widen, "lifted expression", expr.pos)

tests/neg/parser-stability-6.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class x0 {
2+
1 + x1 * / |= 2 // error // error

0 commit comments

Comments
 (0)