Closed
Description
Consider the following program:
class A {
List<X> m<X>(X x) => [x];
}
extension FunctionApplier on Function {
void applyAndPrint(List<Object?> positionalArguments) =>
print(Function.apply(this, positionalArguments, const {}));
}
void main() {
var a = A();
a.m<int>.applyAndPrint([2]);
a.m<String>.applyAndPrint(['three']);
}
This program is rejected by the CFE (as of ef8add0) with the following error messages:
n038.dart:12:3: Error: Method not found: 'a.m.applyAndPrint'.
a.m<int>.applyAndPrint([2]);
^^^^^^^^^^^^^
n038.dart:13:3: Error: Method not found: 'a.m.applyAndPrint'.
a.m<String>.applyAndPrint(['three']);
^^^^^^^^^^^^^
However, the analysis should have considered a.m<int>
and a.m<String>
as potential receivers of an extension method invocation and detected that applyAndPrint
is available and applicable, and accepted the program.
PS: The error location has a funny length, too (it's 13 in both cases, even though a.m<int>
and a.m<String>
do not have the same length).