The implicit target of an expression may be "self", but that of a call is always "this".

Description

Currently:

That is confusing to the programmer.

The rules for expr disambiguation and call disambiguation are different.
Therefore:
Bla{p} // may be self.p
and
Bla{p()} // may never be self.p() - always defaults to "this"
I.e., expr and call resolve their implicit target to different things (the first might choose self or report an ambiguity) and the second resolves to "this".

These are the rules for disambiguation of expressions (not calls) as implemented in the compiler (see X10Disamb_c.disambiguateNoPrefix) :
In a constraint (DepType):

  • locals

  • property- if both self and this match then report an ambiguity

  • nullary property method

  • member type
    Otherwise:

  • local

  • fields - target is "this" (no ambiguity)

  • nullary property method

  • member type

  • package

These are the rules for disambiguation of calls as implemented in the compiler (see X10Call_c.typeCheck1):
Regardless of whether we are in a constraint or not (resolution is the same):

  • 1) closure call on a local or a field

  • 2) method call on a static or instance method

  • 3) struct constructor invocation

I think that calls in a constraint (deptype) should be:

  • 2) method call on a static or instance method. If in a deptype and we resolved to an instance method: try both self and this as a target (if both match then report an ambiguity)

Environment

None

Status

Assignee

Unassigned

Reporter

Imported User 24

Labels

None

Fix versions

Affects versions

Priority

High
Configure