diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-09-26 22:11:40 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-09-28 10:17:53 +0200 |
commit | 19f6209e5b1db295320bfbd3ef00eeaa729c1eec (patch) | |
tree | 2d29641720f5eafacd9b020eab1a92c103282080 /spec | |
parent | 6df14e57a4980897d5517f002c04584b82e05b15 (diff) | |
download | scala-19f6209e5b1db295320bfbd3ef00eeaa729c1eec.tar.gz scala-19f6209e5b1db295320bfbd3ef00eeaa729c1eec.tar.bz2 scala-19f6209e5b1db295320bfbd3ef00eeaa729c1eec.zip |
SI-9697 / SD-229 Fix DelayedInit subclass capturing local value
When a class captures an outer value, a field for that value is created
in the class. The class also gets a constructor parameter for the
captured value, the constructor will assign the field.
LambdaLift re-writes accesses to the local value (Ident trees) to the
field. However, if the statement accessing the local value will end up
inside the constructor, the access is re-written to the constructor
parameter instead. This is the case for constructor statements:
class C {
{
println(capturedLocal)
}
}
If C extends DelayedInit, the statement does not end up in C's
constructor, but into a new synthetic method. The access to
`capturedLocal` needs to be re-written to the field instead of the
constructor parameter.
LambdaLift takes the decision (field or constructor parameter) based on
the owner chain of `currentOwner`. For the constructor statement block,
the owner is a local dummy, for which `logicallyEnclosingMember` returns
the constructor symbol.
This commit introduces a special case in LambdaLift for local dummies
of DelayedInit subclasses: instead of the constructor, we use a
temporary symbol representing the synthetic method holding the
initializer statements.
Diffstat (limited to 'spec')
0 files changed, 0 insertions, 0 deletions