Skip to content

Commit

Permalink
fix ResolutionCopier to copy staticInvokeType/propagatedInvokeType
Browse files Browse the repository at this point in the history
(these will be needed for DDC generic methods)

[email protected]

Review URL: https://codereview.chromium.org/1754873002 .
  • Loading branch information
John Messerly committed Mar 2, 2016
1 parent 1226c38 commit 02f8887
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
4 changes: 4 additions & 0 deletions pkg/analyzer/lib/src/generated/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10511,7 +10511,9 @@ class ResolutionCopier implements AstVisitor<bool> {
if (_and(_isEqualNodes(node.function, toNode.function),
_isEqualNodes(node.argumentList, toNode.argumentList))) {
toNode.propagatedElement = node.propagatedElement;
toNode.propagatedInvokeType = node.propagatedInvokeType;
toNode.propagatedType = node.propagatedType;
toNode.staticInvokeType = node.staticInvokeType;
toNode.staticElement = node.staticElement;
toNode.staticType = node.staticType;
return true;
Expand Down Expand Up @@ -10773,7 +10775,9 @@ class ResolutionCopier implements AstVisitor<bool> {
_isEqualTokens(node.operator, toNode.operator),
_isEqualNodes(node.methodName, toNode.methodName),
_isEqualNodes(node.argumentList, toNode.argumentList))) {
toNode.propagatedInvokeType = node.propagatedInvokeType;
toNode.propagatedType = node.propagatedType;
toNode.staticInvokeType = node.staticInvokeType;
toNode.staticType = node.staticType;
return true;
}
Expand Down
37 changes: 23 additions & 14 deletions pkg/analyzer/test/generated/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4474,20 +4474,16 @@ class ResolutionCopierTest extends EngineTestCase {
MethodElement propagatedElement = ElementFactory.methodElement(
"m", ElementFactory.classElement2("C").type);
fromNode.propagatedElement = propagatedElement;
DartType propagatedType = ElementFactory.classElement2("C").type;
fromNode.propagatedType = propagatedType;
MethodElement staticElement = ElementFactory.methodElement(
"m", ElementFactory.classElement2("C").type);
fromNode.staticElement = staticElement;
DartType staticType = ElementFactory.classElement2("C").type;
fromNode.staticType = staticType;
FunctionExpressionInvocation toNode =
AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"));
ResolutionCopier.copyResolutionData(fromNode, toNode);

_copyAndVerifyInvocation(fromNode, toNode);

expect(toNode.propagatedElement, same(propagatedElement));
expect(toNode.propagatedType, same(propagatedType));
expect(toNode.staticElement, same(staticElement));
expect(toNode.staticType, same(staticType));
}

void test_visitImportDirective() {
Expand Down Expand Up @@ -4609,14 +4605,8 @@ class ResolutionCopierTest extends EngineTestCase {

void test_visitMethodInvocation() {
MethodInvocation fromNode = AstFactory.methodInvocation2("m");
DartType propagatedType = ElementFactory.classElement2("C").type;
fromNode.propagatedType = propagatedType;
DartType staticType = ElementFactory.classElement2("C").type;
fromNode.staticType = staticType;
MethodInvocation toNode = AstFactory.methodInvocation2("m");
ResolutionCopier.copyResolutionData(fromNode, toNode);
expect(toNode.propagatedType, same(propagatedType));
expect(toNode.staticType, same(staticType));
_copyAndVerifyInvocation(fromNode, toNode);
}

void test_visitNamedExpression() {
Expand Down Expand Up @@ -4893,6 +4883,25 @@ class ResolutionCopierTest extends EngineTestCase {
ResolutionCopier.copyResolutionData(fromNode, toNode);
expect(toNode.type, same(type));
}

void _copyAndVerifyInvocation(
InvocationExpression fromNode, InvocationExpression toNode) {
DartType propagatedType = ElementFactory.classElement2("C").type;
fromNode.propagatedType = propagatedType;
DartType staticType = ElementFactory.classElement2("C").type;
fromNode.staticType = staticType;

DartType propagatedInvokeType = ElementFactory.classElement2("C").type;
fromNode.propagatedInvokeType = propagatedInvokeType;
DartType staticInvokeType = ElementFactory.classElement2("C").type;
fromNode.staticInvokeType = staticInvokeType;

ResolutionCopier.copyResolutionData(fromNode, toNode);
expect(toNode.propagatedType, same(propagatedType));
expect(toNode.staticType, same(staticType));
expect(toNode.propagatedInvokeType, same(propagatedInvokeType));
expect(toNode.staticInvokeType, same(staticInvokeType));
}
}

/**
Expand Down

0 comments on commit 02f8887

Please sign in to comment.