- Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Open
Copy link
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-packageIssues related to package:analyzerIssues related to package:analyzer
Description
Consider the following example:
class B { void foo<T>(T a) {} } class C extends B { void bar() { foo.call; // OK. foo.call<int>(1); // OK. foo.call<int>; // Error. } } void main() {}This library is rejected by the analyzer (Dart SDK 3.11.0-93.0.dev), but accepted by the CFE. This implies that the explicit generic function instantiation is treated differently by the analyzer than the two other usages of foo.call, and the result is that it reports the error "Undefined name 'foo.call'".
This error is not reported if the declaration of foo is moved to C (such that foo is in the lexical scope).
A similar issue occurs in the following case:
extension on C { void foo<T>(T a) {} } class C { void bar() { foo.call; // OK. foo.call<int>(1); // OK. foo.call<int>; // Error. } } void main() {}Finally, yet another example illustrating that it isn't just about the magic call member:
typedef Exactly<X> = X Function(X); extension<X> on X { X expectStaticType<Y extends Exactly<X>>() => this; } class A { String x = ''; } class B extends A { void foo() { this.x.expectStaticType<Exactly<String>>; x.expectStaticType<Exactly<String>>; // Error. } } void main() {}Metadata
Metadata
Assignees
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-packageIssues related to package:analyzerIssues related to package:analyzer