File tree Expand file tree Collapse file tree 3 files changed +49
-4
lines changed Expand file tree Collapse file tree 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
87008700 ///
87018701 /// In error-free code, this is either a [SimpleIdentifier] (indicating a
87028702 /// 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
87048704 /// [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.
87068707 /// For example, `(...)<int>` parses as a [FunctionReference] whose referent
87078708 /// is a [ParenthesizedExpression].
87088709 Expression get function;
@@ -8720,6 +8721,7 @@ abstract final class FunctionReference
87208721}
87218722
87228723final class FunctionReferenceImpl extends CommentReferableExpressionImpl
8724+ with DotShorthandMixin
87238725 implements FunctionReference {
87248726 ExpressionImpl _function;
87258727
Original file line number Diff line number Diff line change @@ -2967,11 +2967,22 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
29672967
29682968 @override
29692969 void visitFunctionReference (
2970- FunctionReference node, {
2970+ covariant FunctionReferenceImpl node, {
29712971 TypeImpl contextType = UnknownInferredType .instance,
29722972 }) {
29732973 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+
29752986 inferenceLogWriter? .exitExpression (node);
29762987 }
29772988
Original file line number Diff line number Diff line change @@ -398,6 +398,38 @@ DotShorthandPropertyAccess
398398''' );
399399 }
400400
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+
401433 test_futureOr () async {
402434 await assertNoErrorsInCode ('''
403435import 'dart:async';
You can’t perform that action at this time.
0 commit comments