File tree 3 files changed +49
-4
lines changed 3 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -8700,9 +8700,10 @@ abstract final class FunctionReference
8700
8700
///
8701
8701
/// In error-free code, this is either a [SimpleIdentifier] (indicating a
8702
8702
/// function that is in scope), a [PrefixedIdentifier] (indicating a either
8703
- /// function imported via prefix or a static method in a class), or a
8703
+ /// function imported via prefix or a static method in a class), a
8704
8704
/// [PropertyAccess] (indicating a static method in a class imported via
8705
- /// prefix). In code with errors, this could be other kinds of expressions.
8705
+ /// prefix), or a [DotShorthandPropertyAccess] (indicating a static method in
8706
+ /// a class). In code with errors, this could be other kinds of expressions.
8706
8707
/// For example, `(...)<int>` parses as a [FunctionReference] whose referent
8707
8708
/// is a [ParenthesizedExpression].
8708
8709
Expression get function;
@@ -8720,6 +8721,7 @@ abstract final class FunctionReference
8720
8721
}
8721
8722
8722
8723
final class FunctionReferenceImpl extends CommentReferableExpressionImpl
8724
+ with DotShorthandMixin
8723
8725
implements FunctionReference {
8724
8726
ExpressionImpl _function;
8725
8727
Original file line number Diff line number Diff line change @@ -2967,11 +2967,22 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
2967
2967
2968
2968
@override
2969
2969
void visitFunctionReference (
2970
- FunctionReference node, {
2970
+ covariant FunctionReferenceImpl node, {
2971
2971
TypeImpl contextType = UnknownInferredType .instance,
2972
2972
}) {
2973
2973
inferenceLogWriter? .enterExpression (node, contextType);
2974
- _functionReferenceResolver.resolve (node as FunctionReferenceImpl );
2974
+
2975
+ // If [isDotShorthand] is set, cache the context type for resolution.
2976
+ if (isDotShorthand (node)) {
2977
+ pushDotShorthandContext (node, SharedTypeSchemaView (contextType));
2978
+ }
2979
+
2980
+ _functionReferenceResolver.resolve (node);
2981
+
2982
+ if (isDotShorthand (node)) {
2983
+ popDotShorthandContext ();
2984
+ }
2985
+
2975
2986
inferenceLogWriter? .exitExpression (node);
2976
2987
}
2977
2988
Original file line number Diff line number Diff line change @@ -398,6 +398,38 @@ DotShorthandPropertyAccess
398
398
''' );
399
399
}
400
400
401
+ test_functionReference () async {
402
+ await assertNoErrorsInCode (r'''
403
+ class C<T> {
404
+ static String foo<X>() => "C<$X>";
405
+
406
+ @override
407
+ bool operator ==(Object other) {
408
+ return false;
409
+ }
410
+ }
411
+
412
+ void test<T extends num>() {
413
+ C() == .foo<T>;
414
+ }
415
+
416
+ main() {
417
+ test<int>();
418
+ }
419
+ ''' );
420
+
421
+ var identifier = findNode.singleDotShorthandPropertyAccess;
422
+ assertResolvedNodeText (identifier, r'''
423
+ DotShorthandPropertyAccess
424
+ period: .
425
+ propertyName: SimpleIdentifier
426
+ token: foo
427
+ element: <testLibraryFragment>::@class::C::@method::foo#element
428
+ staticType: String Function<X>()
429
+ staticType: String Function<X>()
430
+ ''' );
431
+ }
432
+
401
433
test_futureOr () async {
402
434
await assertNoErrorsInCode ('''
403
435
import 'dart:async';
You can’t perform that action at this time.
0 commit comments