summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 25af71be19..c599404025 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -233,7 +233,9 @@ trait NamesDefaults { self: Analyzer =>
})
List.map2(symPs, args)((symP, arg) => {
val (sym, byName) = symP
- val body = if (byName) blockTyper.typed(Function(List(), arg))
+ // resetAttrs required for #2290. given a block { val x = 1; x }, when wrapping into a function
+ // () => { val x = 1; x }, the owner of symbol x must change (to the apply method of the function).
+ val body = if (byName) blockTyper.typed(Function(List(), resetAttrs(arg)))
else arg
atPos(body.pos)(ValDef(sym, body).setType(NoType))
})