Skip to content

Commit

Permalink
Set id(s) for GenericFunctionType(s) in constructor initializers and …
Browse files Browse the repository at this point in the history
…default values.

R=brianwilkerson@google.com

Bug: dart-lang/sdk#38282
Change-Id: I05d5b5c003fa51cc5061ed2dd6883809b6f82cae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116490
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Sep 10, 2019
1 parent 300c333 commit 331271d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/analyzer/lib/src/summary2/reference_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class ReferenceResolver extends ThrowingAstVisitor<void> {
LinkingNodeContext(node, functionScope);

node.parameters?.accept(this);
node.initializers.accept(
_SetGenericFunctionTypeIdVisitor(this),
);

scope = outerScope;
reference = outerReference;
Expand All @@ -153,6 +156,9 @@ class ReferenceResolver extends ThrowingAstVisitor<void> {
@override
void visitDefaultFormalParameter(DefaultFormalParameter node) {
node.parameter.accept(this);
node.defaultValue?.accept(
_SetGenericFunctionTypeIdVisitor(this),
);
}

@override
Expand Down
47 changes: 47 additions & 0 deletions pkg/analyzer/test/src/summary/resynthesize_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4617,6 +4617,31 @@ class C {
''');
}

test_constructor_initializers_genericFunctionType() async {
var library = await checkLibrary('''
class A<T> {
const A();
}
class B {
const B(dynamic x);
const B.f()
: this(A<Function()>());
}
''');
if (isAstBasedSummary) {
checkElementText(library, r'''
class A<T> {
const A();
}
class B {
const B(dynamic x);
const B.f() = B : this(
A/*location: test.dart;A*/<Function()>());
}
''');
}
}

test_constructor_initializers_superInvocation_named() async {
var library = await checkLibrary('''
class A {
Expand Down Expand Up @@ -5261,6 +5286,28 @@ void defaultF<T>(T v) {}
''');
}

test_defaultValue_genericFunctionType() async {
var library = await checkLibrary('''
class A<T> {
const A();
}
class B {
void foo({a: const A<Function()>()}) {}
}
''');
if (isAstBasedSummary) {
checkElementText(library, r'''
class A<T> {
const A();
}
class B {
void foo({dynamic a: const
A/*location: test.dart;A*/<Function()>()}) {}
}
''');
}
}

test_defaultValue_refersToExtension_method_inside() async {
featureSet = enableExtensionMethods;
var library = await checkLibrary('''
Expand Down

0 comments on commit 331271d

Please sign in to comment.