Skip to content

Should null aware operators chain when we move to NNBD? #155

@leafpetersen

Description

@leafpetersen

With NNBD, calling methods on the result of a null aware operator whatsIt?.frobIt().fiddleSticks() will always be a static error unless fiddleSticks is a method on Object.

Should we then just say that the ?. propagates? That is, that an unguarded method call on the result of a guarded method call is treated as guarded?

Arguments for:

  • It's always going to be an error otherwise, so why not just do the right thing?

Arguments against:

  • It's not very compositional: changing the code to var a = whatsIt?.frobIt(); a.fiddleSticks(); will fail.

Other issues/arguments?

Metadata

Metadata

Assignees

Labels

nnbdNNBD related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions