The dot shorthand feature relies on the declaration denoted by a type schema to find a declaration even in the case where the context type is a union type (FutureOr or ?). For example:
import 'dart:async';
class A {
static A get fresh => A();
}
void main() {
FutureOr<A?>? a = .fresh;
}
This issue is a proposal that we should use the same rule with static extensions when we determine whether a given on type denotes a declaration:
extension E on FutureOr<A?> {
factory new name() => A(); // OK.
}
void main() {
A.name(); // OK.
}
The motivation would be that a developer may wish to introduce some extension members on, say, C?, and they also want to include some constructors of C in the same extension (e.g., in order to avoid having to mention two names in show or hide clauses). Also, the alignment with dot shorthands would make this kind of erasure unsurprising for many developers.
The dot shorthand feature relies on the declaration denoted by a type schema to find a declaration even in the case where the context type is a union type (
FutureOror?). For example:This issue is a proposal that we should use the same rule with static extensions when we determine whether a given
ontype denotes a declaration:The motivation would be that a developer may wish to introduce some extension members on, say,
C?, and they also want to include some constructors ofCin the same extension (e.g., in order to avoid having to mention two names inshoworhideclauses). Also, the alignment with dot shorthands would make this kind of erasure unsurprising for many developers.