Capturing a field (instead of capturing the entire container): implication on "this" escaping

Description

Currently, the definition of capture is too general:
we capture any final variables used.
For example: async a.f captures a.
I propose to capture a ref to the field a.f.

Note that if you have async a.f1.f2, then if f1 is a val field, then we can capture a ref to a.f1.f2, but if f1 is a var field, then we have to capture a.f1.
For example:

I propose to treat val and var identically, by saying that for a.f1.f2
we capture a ref to a.f1.
The exact definition of capture is proposed to be:
We capture any local used from the enclosing scope, unless that local is only used as the receiver of field accesses, in which case we capture a reference to these fields of that local.

Environment

None

Status

Assignee

VijayV

Reporter

Imported User 24

Labels

None

Components

Fix versions

Affects versions

Priority

High
Configure