From a54705475044a1d2998a805a6cc1e2ea560e838a Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Fri, 25 Nov 2016 13:38:05 +0100 Subject: [PATCH 1/2] fix #1743: fix typing of ValDef with anonymous class --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index ccc74cfff75b..7a902208ede8 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -588,7 +588,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit else pt.notApplied val expr1 = typedExpr(tree.expr, ept)(exprCtx) ensureNoLocalRefs( - assignType(cpy.Block(tree)(stats1, expr1), stats1, expr1), pt, localSyms(stats1)) + assignType(cpy.Block(tree)(stats1, expr1), stats1, expr1), pt, localSyms(stats1).filter(_.isTerm)) } def escapingRefs(block: Tree, localSyms: => List[Symbol])(implicit ctx: Context): collection.Set[NamedType] = { From 7adb33bf37c3f588f48fff40b935aa47b2a59886 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Fri, 25 Nov 2016 13:39:12 +0100 Subject: [PATCH 2/2] add test case --- tests/pos/i1743.scala | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/pos/i1743.scala diff --git a/tests/pos/i1743.scala b/tests/pos/i1743.scala new file mode 100644 index 000000000000..d1fb8c4db42b --- /dev/null +++ b/tests/pos/i1743.scala @@ -0,0 +1,9 @@ +object DepBug { + val dep = new { + val a = 3 + val b = 4 + } + + dep.a + dep.b +} +