Language: Allow null-aware invocations.

Created on 17 Jun 2019  路  2Comments  路  Source: dart-lang/language

We already plan to allow o?.[v] as a null-aware index operator access (#376).

To complete the selectors, we will also allow o?.(args) and o?.<Types>(args) as null-aware invocations.

The current workaround is to use o?.call(args) and o?.call<Types>(args), which works, but is inconsistent with that we allow o(args) and o<Types>(args) directly. The ?.call(...) workaround is already in common use.

This change modifies the grammar to allow <argumentPart> as a <cascadeSelector> (allowing o..(args) and o?..(args)) and allowing an <argumentPart> after a ?. as well, in whichever way we already modify the grammar to allow ?.[e].
An <argumentPart> is still not an assignable selector.

nnbd state-backlog

Most helpful comment

Probably worth noting that for index operators, we decided to go with ?[] instead of ?.[]. So if we do null-aware invocations, we probably want ?() and ?<T>().

All 2 comments

We will not do this in the first release where nnbd is supported. We have the option to add it later. Adding the 'backlog' label to reflect that this issue is not currently active.

Probably worth noting that for index operators, we decided to go with ?[] instead of ?.[]. So if we do null-aware invocations, we probably want ?() and ?<T>().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

panthe picture panthe  路  4Comments

munificent picture munificent  路  5Comments

listepo picture listepo  路  3Comments

lrhn picture lrhn  路  4Comments

ShivamArora picture ShivamArora  路  3Comments