| Index: pkg/analyzer/test/generated/resolver_test.dart
|
| diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
|
| index b512ceb206dd68a9f4f6b381e8f19574688899e1..809eb2fb794604eee6ec73a4789ce8504232cb3f 100644
|
| --- a/pkg/analyzer/test/generated/resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/resolver_test.dart
|
| @@ -272,9 +272,9 @@ class AnalysisContextFactory {
|
| ElementFactory.classElement("SelectElement", elementType)
|
| ];
|
| htmlUnit.functions = <FunctionElement>[
|
| - ElementFactory.functionElement3("query", elementElement, <ClassElement>[
|
| - provider.stringType.element
|
| - ], ClassElementImpl.EMPTY_ARRAY)
|
| + ElementFactory.functionElement3("query", elementElement,
|
| + <ClassElement>[provider.stringType.element],
|
| + ClassElementImpl.EMPTY_ARRAY)
|
| ];
|
| TopLevelVariableElementImpl document = ElementFactory
|
| .topLevelVariableElement3(
|
| @@ -293,9 +293,8 @@ class AnalysisContextFactory {
|
| coreContext.setContents(mathSource, "");
|
| mathUnit.source = mathSource;
|
| FunctionElement cosElement = ElementFactory.functionElement3("cos",
|
| - provider.doubleType.element, <ClassElement>[
|
| - provider.numType.element
|
| - ], ClassElementImpl.EMPTY_ARRAY);
|
| + provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + ClassElementImpl.EMPTY_ARRAY);
|
| TopLevelVariableElement ln10Element = ElementFactory
|
| .topLevelVariableElement3("LN10", true, false, provider.doubleType);
|
| TopLevelVariableElement piElement = ElementFactory.topLevelVariableElement3(
|
| @@ -311,13 +310,11 @@ class AnalysisContextFactory {
|
| randomConstructor.parameters = <ParameterElement>[seedParam];
|
| randomElement.constructors = <ConstructorElement>[randomConstructor];
|
| FunctionElement sinElement = ElementFactory.functionElement3("sin",
|
| - provider.doubleType.element, <ClassElement>[
|
| - provider.numType.element
|
| - ], ClassElementImpl.EMPTY_ARRAY);
|
| + provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + ClassElementImpl.EMPTY_ARRAY);
|
| FunctionElement sqrtElement = ElementFactory.functionElement3("sqrt",
|
| - provider.doubleType.element, <ClassElement>[
|
| - provider.numType.element
|
| - ], ClassElementImpl.EMPTY_ARRAY);
|
| + provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + ClassElementImpl.EMPTY_ARRAY);
|
| mathUnit.accessors = <PropertyAccessorElement>[
|
| ln10Element.getter,
|
| piElement.getter
|
| @@ -1537,9 +1534,8 @@ class ElementResolverTest extends EngineTestCase {
|
| AstFactory.typeName(classA), constructorName);
|
| name.staticElement = constructor;
|
| InstanceCreationExpression creation = AstFactory.instanceCreationExpression(
|
| - Keyword.NEW, name, [
|
| - AstFactory.namedExpression2(parameterName, AstFactory.integer(0))
|
| - ]);
|
| + Keyword.NEW, name,
|
| + [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| _resolveNode(creation);
|
| expect(creation.staticElement, same(constructor));
|
| expect((creation.argumentList.arguments[
|
| @@ -4659,9 +4655,8 @@ class InheritanceManagerTest extends EngineTestCase {
|
| _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapA.get(methodName), isNull);
|
| - _assertErrors(classA, [
|
| - StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD
|
| - ]);
|
| + _assertErrors(classA,
|
| + [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]);
|
| }
|
|
|
| void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_int_str() {
|
| @@ -4706,9 +4701,8 @@ class InheritanceManagerTest extends EngineTestCase {
|
| _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapA.get(methodName), isNull);
|
| - _assertErrors(classA, [
|
| - StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD
|
| - ]);
|
| + _assertErrors(classA,
|
| + [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD]);
|
| }
|
|
|
| void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_numOfRequiredParams() {
|
| @@ -9563,6 +9557,50 @@ main() {
|
| expect(type, new isInstanceOf<FunctionType>());
|
| }
|
|
|
| + void test_FunctionExpressionInvocation_block() {
|
| + String code = r'''
|
| +main() {
|
| + var foo = (() { return 1; })();
|
| +}
|
| +''';
|
| + _resolveTestUnit(code);
|
| + SimpleIdentifier identifier = _findIdentifier('foo');
|
| + VariableDeclaration declaration =
|
| + identifier.getAncestor((node) => node is VariableDeclaration);
|
| + expect(declaration.initializer.staticType.isDynamic, isTrue);
|
| + expect(declaration.initializer.propagatedType, isNull);
|
| + }
|
| +
|
| + void test_FunctionExpressionInvocation_expression() {
|
| + String code = r'''
|
| +main() {
|
| + var foo = (() => 1)();
|
| +}
|
| +''';
|
| + _resolveTestUnit(code);
|
| + SimpleIdentifier identifier = _findIdentifier('foo');
|
| + VariableDeclaration declaration =
|
| + identifier.getAncestor((node) => node is VariableDeclaration);
|
| + expect(declaration.initializer.staticType.name, 'int');
|
| + expect(declaration.initializer.propagatedType, isNull);
|
| + }
|
| +
|
| + void test_FunctionExpressionInvocation_curried() {
|
| + String code = r'''
|
| +typedef int F();
|
| +F f() => null;
|
| +main() {
|
| + var foo = f()();
|
| +}
|
| +''';
|
| + _resolveTestUnit(code);
|
| + SimpleIdentifier identifier = _findIdentifier('foo');
|
| + VariableDeclaration declaration =
|
| + identifier.getAncestor((node) => node is VariableDeclaration);
|
| + expect(declaration.initializer.staticType.name, 'int');
|
| + expect(declaration.initializer.propagatedType, isNull);
|
| + }
|
| +
|
| void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
|
| String code = r"""
|
| typedef Foo();
|
| @@ -9995,8 +10033,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| _analyze5(p1);
|
| _analyze5(p2);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(dynamicType,
|
| - <DartType>[dynamicType, dynamicType], null, null, resultType);
|
| + _assertFunctionType(dynamicType, <DartType>[
|
| + dynamicType,
|
| + dynamicType
|
| + ], null, null, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10030,8 +10070,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType resultType = _analyze(node);
|
| Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
|
| expectedNamedTypes["p2"] = dynamicType;
|
| - _assertFunctionType(dynamicType,
|
| - <DartType>[dynamicType], null, expectedNamedTypes, resultType);
|
| + _assertFunctionType(dynamicType, <DartType>[dynamicType], null,
|
| + expectedNamedTypes, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10050,8 +10090,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType resultType = _analyze(node);
|
| Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
|
| expectedNamedTypes["p2"] = dynamicType;
|
| - _assertFunctionType(_typeProvider.intType,
|
| - <DartType>[dynamicType], null, expectedNamedTypes, resultType);
|
| + _assertFunctionType(_typeProvider.intType, <DartType>[dynamicType], null,
|
| + expectedNamedTypes, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10069,8 +10109,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| _analyze5(p1);
|
| _analyze5(p2);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(dynamicType,
|
| - <DartType>[dynamicType], <DartType>[dynamicType], null, resultType);
|
| + _assertFunctionType(dynamicType, <DartType>[dynamicType],
|
| + <DartType>[dynamicType], null, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10088,8 +10128,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| _analyze5(p1);
|
| _analyze5(p2);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(_typeProvider.intType,
|
| - <DartType>[dynamicType], <DartType>[dynamicType], null, resultType);
|
| + _assertFunctionType(_typeProvider.intType, <DartType>[dynamicType],
|
| + <DartType>[dynamicType], null, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10108,8 +10148,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| _analyze5(p1);
|
| _analyze5(p2);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(dynamicType,
|
| - null, <DartType>[dynamicType, dynamicType], null, resultType);
|
| + _assertFunctionType(dynamicType, null, <DartType>[
|
| + dynamicType,
|
| + dynamicType
|
| + ], null, resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10212,9 +10254,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| constructor.type = constructorType;
|
| classElement.constructors = <ConstructorElement>[constructor];
|
| InstanceCreationExpression node = AstFactory.instanceCreationExpression2(
|
| - null, AstFactory.typeName(classElement), [
|
| - AstFactory.identifier3(constructorName)
|
| - ]);
|
| + null, AstFactory.typeName(classElement),
|
| + [AstFactory.identifier3(constructorName)]);
|
| node.staticElement = constructor;
|
| expect(_analyze(node), same(classElement.type));
|
| _listener.assertNoErrors();
|
| @@ -10304,10 +10345,9 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // {}
|
| Expression node = AstFactory.mapLiteral2();
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.mapType.substitute4(<DartType>[
|
| - _typeProvider.dynamicType,
|
| - _typeProvider.dynamicType
|
| - ]), resultType);
|
| + _assertType2(_typeProvider.mapType.substitute4(
|
| + <DartType>[_typeProvider.dynamicType, _typeProvider.dynamicType]),
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10316,10 +10356,9 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| Expression node = AstFactory
|
| .mapLiteral2([AstFactory.mapLiteralEntry("k", _resolvedInteger(0))]);
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.mapType.substitute4(<DartType>[
|
| - _typeProvider.dynamicType,
|
| - _typeProvider.dynamicType
|
| - ]), resultType);
|
| + _assertType2(_typeProvider.mapType.substitute4(
|
| + <DartType>[_typeProvider.dynamicType, _typeProvider.dynamicType]),
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
|
|