| 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 89242b9e91d9a690a1eec2bb3271774c0dffbfc9..40340684150bdf4a92f2b0197ed03da60032b35b 100644
|
| --- a/pkg/analyzer/test/generated/resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/resolver_test.dart
|
| @@ -165,7 +165,8 @@ class AnalysisContextFactory {
|
| ElementFactory.topLevelVariableElement3(
|
| "deprecated", true, false, provider.deprecatedType);
|
| deprecatedTopLevelVariableElt.constantInitializer = AstFactory
|
| - .instanceCreationExpression2(Keyword.CONST,
|
| + .instanceCreationExpression2(
|
| + Keyword.CONST,
|
| AstFactory.typeName(provider.deprecatedType.element),
|
| [AstFactory.string2('next release')]);
|
| coreUnit.accessors = <PropertyAccessorElement>[
|
| @@ -229,10 +230,29 @@ class AnalysisContextFactory {
|
| (completerConstructor.type as FunctionTypeImpl).typeArguments =
|
| completerElement.type.typeArguments;
|
| completerElement.constructors = <ConstructorElement>[completerConstructor];
|
| + // StreamSubscription
|
| + ClassElementImpl streamSubscriptionElement =
|
| + ElementFactory.classElement2("StreamSubscription", ["T"]);
|
| + // Stream
|
| + ClassElementImpl streamElement =
|
| + ElementFactory.classElement2("Stream", ["T"]);
|
| + DartType returnType = streamSubscriptionElement.type
|
| + .substitute4(streamElement.type.typeArguments);
|
| + List<DartType> parameterTypes = <DartType>[
|
| + ElementFactory
|
| + .functionElement3('onData', VoidTypeImpl.instance.element,
|
| + <TypeDefiningElement>[streamElement.typeParameters[0]], null)
|
| + .type,
|
| + ];
|
| + // TODO(brianwilkerson) This is missing the optional parameters.
|
| + MethodElementImpl listenMethod =
|
| + ElementFactory.methodElement('listen', returnType, parameterTypes);
|
| + streamElement.methods = <MethodElement>[listenMethod];
|
| +
|
| asyncUnit.types = <ClassElement>[
|
| completerElement,
|
| futureElement,
|
| - ElementFactory.classElement2("Stream", ["T"])
|
| + streamElement
|
| ];
|
| LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode(
|
| coreContext, AstFactory.libraryIdentifier2(["dart", "async"]));
|
| @@ -306,8 +326,10 @@ class AnalysisContextFactory {
|
| Source mathSource = sourceFactory.forUri(_DART_MATH);
|
| coreContext.setContents(mathSource, "");
|
| mathUnit.librarySource = mathUnit.source = mathSource;
|
| - FunctionElement cosElement = ElementFactory.functionElement3("cos",
|
| - provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + FunctionElement cosElement = ElementFactory.functionElement3(
|
| + "cos",
|
| + provider.doubleType.element,
|
| + <ClassElement>[provider.numType.element],
|
| ClassElement.EMPTY_LIST);
|
| TopLevelVariableElement ln10Element = ElementFactory
|
| .topLevelVariableElement3("LN10", true, false, provider.doubleType);
|
| @@ -323,11 +345,15 @@ class AnalysisContextFactory {
|
| seedParam.type = provider.intType;
|
| randomConstructor.parameters = <ParameterElement>[seedParam];
|
| randomElement.constructors = <ConstructorElement>[randomConstructor];
|
| - FunctionElement sinElement = ElementFactory.functionElement3("sin",
|
| - provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + FunctionElement sinElement = ElementFactory.functionElement3(
|
| + "sin",
|
| + provider.doubleType.element,
|
| + <ClassElement>[provider.numType.element],
|
| ClassElement.EMPTY_LIST);
|
| - FunctionElement sqrtElement = ElementFactory.functionElement3("sqrt",
|
| - provider.doubleType.element, <ClassElement>[provider.numType.element],
|
| + FunctionElement sqrtElement = ElementFactory.functionElement3(
|
| + "sqrt",
|
| + provider.doubleType.element,
|
| + <ClassElement>[provider.numType.element],
|
| ClassElement.EMPTY_LIST);
|
| mathUnit.accessors = <PropertyAccessorElement>[
|
| ln10Element.getter,
|
| @@ -1208,8 +1234,9 @@ class ElementResolverTest extends EngineTestCase {
|
| fail("Not yet tested");
|
| // Need to set up the exported library so that the identifier can be
|
| // resolved.
|
| - ExportDirective directive =
|
| - AstFactory.exportDirective2(null, [AstFactory.hideCombinator2(["A"])]);
|
| + ExportDirective directive = AstFactory.exportDirective2(null, [
|
| + AstFactory.hideCombinator2(["A"])
|
| + ]);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1223,8 +1250,9 @@ class ElementResolverTest extends EngineTestCase {
|
| fail("Not yet tested");
|
| // Need to set up the imported library so that the identifier can be
|
| // resolved.
|
| - ImportDirective directive = AstFactory.importDirective3(
|
| - null, null, [AstFactory.showCombinator2(["A"])]);
|
| + ImportDirective directive = AstFactory.importDirective3(null, null, [
|
| + AstFactory.showCombinator2(["A"])
|
| + ]);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1324,8 +1352,10 @@ class ElementResolverTest extends EngineTestCase {
|
| _resolveNode(expression);
|
| var stringElement = stringType.element;
|
| expect(expression.staticElement, isNotNull);
|
| - expect(expression.staticElement, stringElement.lookUpMethod(
|
| - TokenType.EQ_EQ.lexeme, stringElement.library));
|
| + expect(
|
| + expression.staticElement,
|
| + stringElement.lookUpMethod(
|
| + TokenType.EQ_EQ.lexeme, stringElement.library));
|
| expect(expression.propagatedElement, isNull);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1341,8 +1371,10 @@ class ElementResolverTest extends EngineTestCase {
|
| left, TokenType.EQ_EQ, AstFactory.identifier3("j"));
|
| _resolveNode(expression);
|
| var stringElement = stringType.element;
|
| - expect(expression.staticElement, stringElement.lookUpMethod(
|
| - TokenType.EQ_EQ.lexeme, stringElement.library));
|
| + expect(
|
| + expression.staticElement,
|
| + stringElement.lookUpMethod(
|
| + TokenType.EQ_EQ.lexeme, stringElement.library));
|
| expect(expression.propagatedElement, isNull);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1613,12 +1645,17 @@ class ElementResolverTest extends EngineTestCase {
|
| AstFactory.typeName(classA), constructorName);
|
| name.staticElement = constructor;
|
| InstanceCreationExpression creation = AstFactory.instanceCreationExpression(
|
| - Keyword.NEW, name,
|
| + Keyword.NEW,
|
| + name,
|
| [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| _resolveNode(creation);
|
| expect(creation.staticElement, same(constructor));
|
| - expect((creation.argumentList.arguments[
|
| - 0] as NamedExpression).name.label.staticElement, same(parameter));
|
| + expect(
|
| + (creation.argumentList.arguments[0] as NamedExpression)
|
| + .name
|
| + .label
|
| + .staticElement,
|
| + same(parameter));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -1648,8 +1685,12 @@ class ElementResolverTest extends EngineTestCase {
|
| [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| _resolveNode(invocation);
|
| expect(invocation.methodName.staticElement, same(method));
|
| - expect((invocation.argumentList.arguments[
|
| - 0] as NamedExpression).name.label.staticElement, same(parameter));
|
| + expect(
|
| + (invocation.argumentList.arguments[0] as NamedExpression)
|
| + .name
|
| + .label
|
| + .staticElement,
|
| + same(parameter));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -1808,8 +1849,13 @@ class ElementResolverTest extends EngineTestCase {
|
| SuperExpression target = AstFactory.superExpression();
|
| target.staticType = ElementFactory.classElement("B", classA.type).type;
|
| PropertyAccess access = AstFactory.propertyAccess2(target, getterName);
|
| - AstFactory.methodDeclaration2(null, null, null, null,
|
| - AstFactory.identifier3("m"), AstFactory.formalParameterList(),
|
| + AstFactory.methodDeclaration2(
|
| + null,
|
| + null,
|
| + null,
|
| + null,
|
| + AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList(),
|
| AstFactory.expressionFunctionBody(access));
|
| _resolveNode(access);
|
| expect(access.propertyName.staticElement, same(getter));
|
| @@ -1910,8 +1956,12 @@ class ElementResolverTest extends EngineTestCase {
|
| ]);
|
| _resolveInClass(invocation, subclass);
|
| expect(invocation.staticElement, superConstructor);
|
| - expect((invocation.argumentList.arguments[
|
| - 0] as NamedExpression).name.label.staticElement, same(parameter));
|
| + expect(
|
| + (invocation.argumentList.arguments[0] as NamedExpression)
|
| + .name
|
| + .label
|
| + .staticElement,
|
| + same(parameter));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -2241,10 +2291,14 @@ library L;
|
| import 'lib1.dart' as one;
|
| import 'lib2.dart' as one;
|
| one.A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| - Source source3 = addNamedSource("/lib2.dart", r'''
|
| + Source source3 = addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| class B {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -2717,7 +2771,9 @@ class A {
|
|
|
| void test_deprecatedAnnotationUse_export() {
|
| Source source = addSource("export 'deprecated_library.dart';");
|
| - addNamedSource("/deprecated_library.dart", r'''
|
| + addNamedSource(
|
| + "/deprecated_library.dart",
|
| + r'''
|
| @deprecated
|
| library deprecated_library;
|
| class A {}''');
|
| @@ -2744,7 +2800,9 @@ f(A a) {
|
| Source source = addSource(r'''
|
| import 'deprecated_library.dart';
|
| f(A a) {}''');
|
| - addNamedSource("/deprecated_library.dart", r'''
|
| + addNamedSource(
|
| + "/deprecated_library.dart",
|
| + r'''
|
| @deprecated
|
| library deprecated_library;
|
| class A {}''');
|
| @@ -2901,7 +2959,9 @@ library L;
|
| import 'lib1.dart';
|
| import 'lib1.dart';
|
| A a;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -2916,7 +2976,9 @@ import 'lib1.dart';
|
| import 'lib1.dart';
|
| import 'lib1.dart';
|
| A a;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -2931,7 +2993,9 @@ library L;
|
| import 'lib1.dart' as M show A hide B;
|
| import 'lib1.dart' as M show A hide B;
|
| M.A a;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}
|
| class B {}''');
|
| @@ -2950,7 +3014,9 @@ f() {}''',
|
| library root;
|
| import 'lib1.dart' deferred as lib1;
|
| main() { lib1.f(); }'''
|
| - ], <ErrorCode>[HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION]);
|
| + ], <ErrorCode>[
|
| + HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION
|
| + ]);
|
| }
|
|
|
| void test_invalidAssignment_instanceVariable() {
|
| @@ -4221,7 +4287,9 @@ library L;
|
| import 'lib1.dart';
|
| import 'lib1.dart' as one;
|
| one.A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -4236,7 +4304,9 @@ library L;
|
| import 'lib1.dart';
|
| import 'lib1.dart' hide A;
|
| A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -4251,7 +4321,9 @@ library L;
|
| import 'lib1.dart' show A;
|
| import 'lib1.dart' show B;
|
| A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}
|
| class B {}''');
|
| @@ -5787,14 +5859,20 @@ class LibraryElementBuilderTest extends EngineTestCase {
|
| }
|
|
|
| void test_accessorsAcrossFiles() {
|
| - Source librarySource = addSource("/lib.dart", r'''
|
| + Source librarySource = addSource(
|
| + "/lib.dart",
|
| + r'''
|
| library lib;
|
| part 'first.dart';
|
| part 'second.dart';''');
|
| - addSource("/first.dart", r'''
|
| + addSource(
|
| + "/first.dart",
|
| + r'''
|
| part of lib;
|
| int get V => 0;''');
|
| - addSource("/second.dart", r'''
|
| + addSource(
|
| + "/second.dart",
|
| + r'''
|
| part of lib;
|
| void set V(int v) {}''');
|
| LibraryElement element = _buildLibrary(librarySource);
|
| @@ -5840,7 +5918,9 @@ void set V(int v) {}''');
|
|
|
| void test_missingPartOfDirective() {
|
| addSource("/a.dart", "class A {}");
|
| - Source librarySource = addSource("/lib.dart", r'''
|
| + Source librarySource = addSource(
|
| + "/lib.dart",
|
| + r'''
|
| library lib;
|
|
|
| part 'a.dart';''');
|
| @@ -5850,16 +5930,22 @@ part 'a.dart';''');
|
| }
|
|
|
| void test_multipleFiles() {
|
| - Source librarySource = addSource("/lib.dart", r'''
|
| + Source librarySource = addSource(
|
| + "/lib.dart",
|
| + r'''
|
| library lib;
|
| part 'first.dart';
|
| part 'second.dart';
|
|
|
| class A {}''');
|
| - addSource("/first.dart", r'''
|
| + addSource(
|
| + "/first.dart",
|
| + r'''
|
| part of lib;
|
| class B {}''');
|
| - addSource("/second.dart", r'''
|
| + addSource(
|
| + "/second.dart",
|
| + r'''
|
| part of lib;
|
| class C {}''');
|
| LibraryElement element = _buildLibrary(librarySource);
|
| @@ -5877,7 +5963,9 @@ class C {}''');
|
| }
|
|
|
| void test_singleFile() {
|
| - Source librarySource = addSource("/lib.dart", r'''
|
| + Source librarySource = addSource(
|
| + "/lib.dart",
|
| + r'''
|
| library lib;
|
|
|
| class A {}''');
|
| @@ -5946,13 +6034,13 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| ClassElement typeB2 = ElementFactory.classElement2(typeNameB);
|
| ClassElement typeC = ElementFactory.classElement2(typeNameC);
|
| LibraryElement importedLibrary1 = createTestLibrary(context, "imported1");
|
| - (importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[typeA, typeB1];
|
| + (importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[typeA, typeB1];
|
| ImportElementImpl import1 =
|
| ElementFactory.importFor(importedLibrary1, null);
|
| LibraryElement importedLibrary2 = createTestLibrary(context, "imported2");
|
| - (importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[typeB2, typeC];
|
| + (importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[typeB2, typeC];
|
| ImportElementImpl import2 =
|
| ElementFactory.importFor(importedLibrary2, null);
|
| LibraryElementImpl importingLibrary =
|
| @@ -6008,8 +6096,8 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| ClassElement importedType =
|
| new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| LibraryElement importedLibrary = createTestLibrary(context, "imported");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[importedType];
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[importedType];
|
| LibraryElementImpl definingLibrary =
|
| createTestLibrary(context, "importing");
|
| ImportElementImpl importElement = new ImportElementImpl(0);
|
| @@ -6035,8 +6123,8 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| String typeName = "List";
|
| ClassElement type = ElementFactory.classElement2(typeName);
|
| LibraryElement importedLibrary = createTestLibrary(context, "lib");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[type];
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[type];
|
| ImportElementImpl importCore = ElementFactory.importFor(
|
| context.getLibraryElement(context.sourceFactory.forUri("dart:core")),
|
| null);
|
| @@ -6060,8 +6148,8 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| ClassElement typeA = ElementFactory.classElement2(typeNameA);
|
| ClassElement typeB = ElementFactory.classElement2(typeNameB);
|
| LibraryElement importedLibrary = createTestLibrary(context, "imported");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[typeA, typeB];
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[typeA, typeB];
|
| ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null);
|
| ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null);
|
| LibraryElementImpl importingLibrary =
|
| @@ -6085,14 +6173,14 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| ClassElement nonPrefixedType = ElementFactory.classElement2(typeName);
|
| LibraryElement prefixedLibrary =
|
| createTestLibrary(context, "import.prefixed");
|
| - (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[prefixedType];
|
| + (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[prefixedType];
|
| ImportElementImpl prefixedImport = ElementFactory.importFor(
|
| prefixedLibrary, ElementFactory.prefix(prefixName));
|
| LibraryElement nonPrefixedLibrary =
|
| createTestLibrary(context, "import.nonPrefixed");
|
| - (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[nonPrefixedType];
|
| + (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[nonPrefixedType];
|
| ImportElementImpl nonPrefixedImport =
|
| ElementFactory.importFor(nonPrefixedLibrary, null);
|
| LibraryElementImpl importingLibrary =
|
| @@ -6137,7 +6225,9 @@ class LibraryResolver2Test extends ResolverTestCase {
|
| library libA;
|
| import 'libB.dart';
|
| class A {}''');
|
| - Source sourceB = addNamedSource("/libB.dart", r'''
|
| + Source sourceB = addNamedSource(
|
| + "/libB.dart",
|
| + r'''
|
| library libB;
|
| import 'test.dart
|
| class B {}''');
|
| @@ -6224,8 +6314,8 @@ class LibraryScopeTest extends ResolverTestCase {
|
| ClassElement importedType =
|
| new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| LibraryElement importedLibrary = createTestLibrary(context, "imported");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| - <ClassElement>[importedType];
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
|
| + .types = <ClassElement>[importedType];
|
| LibraryElementImpl definingLibrary =
|
| createTestLibrary(context, "importing");
|
| ImportElementImpl importElement = new ImportElementImpl(0);
|
| @@ -6346,7 +6436,9 @@ class LibraryTest extends EngineTestCase {
|
| }
|
|
|
| Library _createLibrary(String definingCompilationUnitPath) => new Library(
|
| - _analysisContext, _errorListener, new FileBasedSource(
|
| + _analysisContext,
|
| + _errorListener,
|
| + new FileBasedSource(
|
| FileUtilities2.createFile(definingCompilationUnitPath)));
|
| }
|
|
|
| @@ -6506,7 +6598,9 @@ import 'lib2.dart';
|
| f() {
|
| if(A.DEBUG) {}
|
| }''');
|
| - addNamedSource("/lib2.dart", r'''
|
| + addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| class A {
|
| static const bool DEBUG = false;
|
| @@ -6523,7 +6617,9 @@ import 'lib2.dart' as LIB;
|
| f() {
|
| if(LIB.A.DEBUG) {}
|
| }''');
|
| - addNamedSource("/lib2.dart", r'''
|
| + addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| class A {
|
| static const bool DEBUG = false;
|
| @@ -6629,7 +6725,9 @@ import 'lib1.dart';
|
| import 'lib1.dart' as one;
|
| A a;
|
| one.A a2;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -6644,7 +6742,9 @@ import 'lib1.dart';
|
| import 'lib1.dart' hide A;
|
| A a;
|
| B b;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}
|
| class B {}''');
|
| @@ -6660,7 +6760,9 @@ import 'lib1.dart';
|
| import 'lib1.dart' show A;
|
| A a;
|
| B b;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}
|
| class B {}''');
|
| @@ -7208,7 +7310,9 @@ m(v) {
|
| library L;
|
| @A()
|
| import 'lib1.dart';''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {
|
| const A() {}
|
| @@ -7226,10 +7330,14 @@ import 'lib1.dart' as one;
|
| import 'lib2.dart' as one;
|
| one.A a;
|
| one.B b;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| + Source source2 = addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class A {}''');
|
| - Source source3 = addNamedSource("/lib2.dart", r'''
|
| + Source source3 = addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| class B {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -7253,11 +7361,15 @@ import 'dart:core';''');
|
| library L;
|
| import 'lib1.dart';
|
| Two two;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| export 'lib2.dart';
|
| class One {}''');
|
| - addNamedSource("/lib2.dart", r'''
|
| + addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| class Two {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -7270,15 +7382,21 @@ class Two {}''');
|
| library L;
|
| import 'lib1.dart';
|
| Three three;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| export 'lib2.dart';
|
| class One {}''');
|
| - addNamedSource("/lib2.dart", r'''
|
| + addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| export 'lib3.dart';
|
| class Two {}''');
|
| - addNamedSource("/lib3.dart", r'''
|
| + addNamedSource(
|
| + "/lib3.dart",
|
| + r'''
|
| library lib3;
|
| class Three {}''');
|
| computeLibrarySourceErrors(source);
|
| @@ -7291,15 +7409,21 @@ class Three {}''');
|
| library L;
|
| import 'lib1.dart';
|
| Two two;''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| export 'lib2.dart';
|
| class One {}''');
|
| - addNamedSource("/lib2.dart", r'''
|
| + addNamedSource(
|
| + "/lib2.dart",
|
| + r'''
|
| library lib2;
|
| export 'lib3.dart';
|
| class Two {}''');
|
| - addNamedSource("/lib3.dart", r'''
|
| + addNamedSource(
|
| + "/lib3.dart",
|
| + r'''
|
| library lib3;
|
| export 'lib2.dart';
|
| class Three {}''');
|
| @@ -7317,7 +7441,9 @@ class A {
|
| final int value;
|
| const A(this.value);
|
| }''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| const x = 0;''');
|
| computeLibrarySourceErrors(source);
|
| @@ -7336,7 +7462,9 @@ class A {
|
| one.topLevelFunction();
|
| }
|
| }''');
|
| - addNamedSource("/lib1.dart", r'''
|
| + addNamedSource(
|
| + "/lib1.dart",
|
| + r'''
|
| library lib1;
|
| class One {}
|
| topLevelFunction() {}''');
|
| @@ -7860,7 +7988,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @return the library element that was created
|
| */
|
| LibraryElementImpl createTestLibrary(
|
| - AnalysisContext context, String libraryName, [List<String> typeNames]) {
|
| + AnalysisContext context, String libraryName,
|
| + [List<String> typeNames]) {
|
| String fileName = "$libraryName.dart";
|
| FileBasedSource definingCompilationUnitSource =
|
| _createNamedSource(fileName);
|
| @@ -7976,7 +8105,8 @@ class ResolverTestCase extends EngineTestCase {
|
| return null;
|
| }
|
|
|
| - void resolveWithAndWithoutExperimental(List<String> strSources,
|
| + void resolveWithAndWithoutExperimental(
|
| + List<String> strSources,
|
| List<ErrorCode> codesWithoutExperimental,
|
| List<ErrorCode> codesWithExperimental) {
|
| // Setup analysis context as non-experimental
|
| @@ -8052,7 +8182,8 @@ class Scope_EnclosedScopeTest_test_define_duplicate extends Scope {
|
|
|
| @override
|
| Element internalLookup(Identifier identifier, String name,
|
| - LibraryElement referencingLibrary) => null;
|
| + LibraryElement referencingLibrary) =>
|
| + null;
|
| }
|
|
|
| class Scope_EnclosedScopeTest_test_define_normal extends Scope {
|
| @@ -8065,7 +8196,8 @@ class Scope_EnclosedScopeTest_test_define_normal extends Scope {
|
|
|
| @override
|
| Element internalLookup(Identifier identifier, String name,
|
| - LibraryElement referencingLibrary) => null;
|
| + LibraryElement referencingLibrary) =>
|
| + null;
|
| }
|
|
|
| @reflectiveTest
|
| @@ -8161,7 +8293,8 @@ void main() {
|
| expect(
|
| propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2');
|
| expect(
|
| - propertyAccess.propertyName.auxiliaryElements.staticElement.enclosingElement.name,
|
| + propertyAccess
|
| + .propertyName.auxiliaryElements.staticElement.enclosingElement.name,
|
| 'M2');
|
| }
|
|
|
| @@ -8736,10 +8869,14 @@ void f() {
|
| }
|
|
|
| void test_entryPoint_exported() {
|
| - addNamedSource("/two.dart", r'''
|
| + addNamedSource(
|
| + "/two.dart",
|
| + r'''
|
| library two;
|
| main() {}''');
|
| - Source source = addNamedSource("/one.dart", r'''
|
| + Source source = addNamedSource(
|
| + "/one.dart",
|
| + r'''
|
| library one;
|
| export 'two.dart';''');
|
| LibraryElement library = resolve2(source);
|
| @@ -8752,7 +8889,9 @@ export 'two.dart';''');
|
| }
|
|
|
| void test_entryPoint_local() {
|
| - Source source = addNamedSource("/one.dart", r'''
|
| + Source source = addNamedSource(
|
| + "/one.dart",
|
| + r'''
|
| library one;
|
| main() {}''');
|
| LibraryElement library = resolve2(source);
|
| @@ -8774,7 +8913,9 @@ main() {}''');
|
| }
|
|
|
| void test_enum_externalLibrary() {
|
| - addNamedSource("/my_lib.dart", r'''
|
| + addNamedSource(
|
| + "/my_lib.dart",
|
| + r'''
|
| library my_lib;
|
| enum EEE {A, B, C}''');
|
| Source source = addSource(r'''
|
| @@ -8972,14 +9113,20 @@ class B {toString() => super.toString();}''');
|
| }
|
|
|
| void test_import_hide() {
|
| - addNamedSource("lib1.dart", r'''
|
| + addNamedSource(
|
| + "lib1.dart",
|
| + r'''
|
| library lib1;
|
| set foo(value) {}
|
| class A {}''');
|
| - addNamedSource("lib2.dart", r'''
|
| + addNamedSource(
|
| + "lib2.dart",
|
| + r'''
|
| library lib2;
|
| set foo(value) {}''');
|
| - Source source = addNamedSource("lib3.dart", r'''
|
| + Source source = addNamedSource(
|
| + "lib3.dart",
|
| + r'''
|
| import 'lib1.dart' hide foo;
|
| import 'lib2.dart';
|
|
|
| @@ -8993,12 +9140,16 @@ A a;''');
|
| }
|
|
|
| void test_import_prefix() {
|
| - addNamedSource("/two.dart", r'''
|
| + addNamedSource(
|
| + "/two.dart",
|
| + r'''
|
| library two;
|
| f(int x) {
|
| return x * x;
|
| }''');
|
| - Source source = addNamedSource("/one.dart", r'''
|
| + Source source = addNamedSource(
|
| + "/one.dart",
|
| + r'''
|
| library one;
|
| import 'two.dart' as _two;
|
| main() {
|
| @@ -9010,10 +9161,14 @@ main() {
|
| }
|
|
|
| void test_import_spaceInUri() {
|
| - addNamedSource("sub folder/lib.dart", r'''
|
| + addNamedSource(
|
| + "sub folder/lib.dart",
|
| + r'''
|
| library lib;
|
| foo() {}''');
|
| - Source source = addNamedSource("app.dart", r'''
|
| + Source source = addNamedSource(
|
| + "app.dart",
|
| + r'''
|
| import 'sub folder/lib.dart';
|
|
|
| main() {
|
| @@ -9205,9 +9360,9 @@ const A = null;
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| NodeList<CompilationUnitMember> declarations = unit.declarations;
|
| expect(declarations, hasLength(2));
|
| - Element expectedElement = (declarations[
|
| - 0] as TopLevelVariableDeclaration).variables.variables[
|
| - 0].name.staticElement;
|
| + Element expectedElement = (declarations[0] as TopLevelVariableDeclaration)
|
| + .variables
|
| + .variables[0].name.staticElement;
|
| EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement,
|
| PropertyInducingElement, expectedElement);
|
| expectedElement = (expectedElement as PropertyInducingElement).getter;
|
| @@ -9396,9 +9551,9 @@ const A = null;
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| NodeList<CompilationUnitMember> declarations = unit.declarations;
|
| expect(declarations, hasLength(2));
|
| - Element expectedElement = (declarations[
|
| - 0] as TopLevelVariableDeclaration).variables.variables[
|
| - 0].name.staticElement;
|
| + Element expectedElement = (declarations[0] as TopLevelVariableDeclaration)
|
| + .variables
|
| + .variables[0].name.staticElement;
|
| EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement,
|
| PropertyInducingElement, expectedElement);
|
| expectedElement = (expectedElement as PropertyInducingElement).getter;
|
| @@ -9919,11 +10074,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // class A extends Derived<int> implements Derived<num> { ... }
|
| ClassElementImpl classA =
|
| ElementFactory.classElement('A', derivedType.substitute4([intType]));
|
| - classA.interfaces = <InterfaceType>[derivedType.substitute4([numType])];
|
| + classA.interfaces = <InterfaceType>[
|
| + derivedType.substitute4([numType])
|
| + ];
|
| // class B extends Future<num> implements Future<int> { ... }
|
| ClassElementImpl classB =
|
| ElementFactory.classElement('B', derivedType.substitute4([numType]));
|
| - classB.interfaces = <InterfaceType>[derivedType.substitute4([intType])];
|
| + classB.interfaces = <InterfaceType>[
|
| + derivedType.substitute4([intType])
|
| + ];
|
| // flatten(A) = flatten(B) = int, since int is more specific than num.
|
| // The code in flatten() that inhibits infinite recursion shouldn't be
|
| // fooled by the fact that Derived appears twice in the type hierarchy.
|
| @@ -9938,11 +10097,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // class A extends Future<int> implements Future<num> { ... }
|
| ClassElementImpl classA =
|
| ElementFactory.classElement('A', futureType.substitute4([intType]));
|
| - classA.interfaces = <InterfaceType>[futureType.substitute4([numType])];
|
| + classA.interfaces = <InterfaceType>[
|
| + futureType.substitute4([numType])
|
| + ];
|
| // class B extends Future<num> implements Future<int> { ... }
|
| ClassElementImpl classB =
|
| ElementFactory.classElement('B', futureType.substitute4([numType]));
|
| - classB.interfaces = <InterfaceType>[futureType.substitute4([intType])];
|
| + classB.interfaces = <InterfaceType>[
|
| + futureType.substitute4([intType])
|
| + ];
|
| // flatten(A) = flatten(B) = int, since int is more specific than num.
|
| expect(_flatten(classA.type), intType);
|
| expect(_flatten(classB.type), intType);
|
| @@ -9979,11 +10142,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // class A extends Future<int> implements Future<String> { ... }
|
| ClassElementImpl classA =
|
| ElementFactory.classElement('A', futureType.substitute4([intType]));
|
| - classA.interfaces = <InterfaceType>[futureType.substitute4([stringType])];
|
| + classA.interfaces = <InterfaceType>[
|
| + futureType.substitute4([stringType])
|
| + ];
|
| // class B extends Future<String> implements Future<int> { ... }
|
| ClassElementImpl classB =
|
| ElementFactory.classElement('B', futureType.substitute4([stringType]));
|
| - classB.interfaces = <InterfaceType>[futureType.substitute4([intType])];
|
| + classB.interfaces = <InterfaceType>[
|
| + futureType.substitute4([intType])
|
| + ];
|
| // flatten(A) = A and flatten(B) = B, since neither string nor int is more
|
| // specific than the other.
|
| expect(_flatten(classA.type), classA.type);
|
| @@ -10026,7 +10193,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // double d; d ??= 0
|
| Expression node = AstFactory.assignmentExpression(
|
| _resolvedVariable(_typeProvider.doubleType, 'd'),
|
| - TokenType.QUESTION_QUESTION_EQ, _resolvedInteger(0));
|
| + TokenType.QUESTION_QUESTION_EQ,
|
| + _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.numType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -10035,7 +10203,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // int i; i ??= 0
|
| Expression node = AstFactory.assignmentExpression(
|
| _resolvedVariable(_typeProvider.intType, 'i'),
|
| - TokenType.QUESTION_QUESTION_EQ, _resolvedInteger(0));
|
| + TokenType.QUESTION_QUESTION_EQ,
|
| + _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -10092,7 +10261,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitBinaryExpression_logicalAnd() {
|
| // false && true
|
| Expression node = AstFactory.binaryExpression(
|
| - AstFactory.booleanLiteral(false), TokenType.AMPERSAND_AMPERSAND,
|
| + AstFactory.booleanLiteral(false),
|
| + TokenType.AMPERSAND_AMPERSAND,
|
| AstFactory.booleanLiteral(true));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| @@ -10101,7 +10271,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitBinaryExpression_logicalOr() {
|
| // false || true
|
| Expression node = AstFactory.binaryExpression(
|
| - AstFactory.booleanLiteral(false), TokenType.BAR_BAR,
|
| + AstFactory.booleanLiteral(false),
|
| + TokenType.BAR_BAR,
|
| AstFactory.booleanLiteral(true));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| @@ -10110,7 +10281,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitBinaryExpression_minusID_propagated() {
|
| // a - b
|
| BinaryExpression node = AstFactory.binaryExpression(
|
| - _propagatedVariable(_typeProvider.intType, 'a'), TokenType.MINUS,
|
| + _propagatedVariable(_typeProvider.intType, 'a'),
|
| + TokenType.MINUS,
|
| _propagatedVariable(_typeProvider.doubleType, 'b'));
|
| node.propagatedElement = getMethod(_typeProvider.numType, "+");
|
| _analyze(node);
|
| @@ -10147,7 +10319,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitBinaryExpression_plusII_propagated() {
|
| // a + b
|
| BinaryExpression node = AstFactory.binaryExpression(
|
| - _propagatedVariable(_typeProvider.intType, 'a'), TokenType.PLUS,
|
| + _propagatedVariable(_typeProvider.intType, 'a'),
|
| + TokenType.PLUS,
|
| _propagatedVariable(_typeProvider.intType, 'b'));
|
| node.propagatedElement = getMethod(_typeProvider.numType, "+");
|
| _analyze(node);
|
| @@ -10174,9 +10347,11 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| MethodElement operator =
|
| ElementFactory.methodElement("*", typeA, [_typeProvider.doubleType]);
|
| classA.methods = <MethodElement>[operator];
|
| - BinaryExpression node = AstFactory.binaryExpression(AstFactory.asExpression(
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + AstFactory.asExpression(
|
| AstFactory.identifier3("a"), AstFactory.typeName(classA)),
|
| - TokenType.PLUS, _resolvedDouble(2.0));
|
| + TokenType.PLUS,
|
| + _resolvedDouble(2.0));
|
| node.staticElement = operator;
|
| expect(_analyze(node), same(typeA));
|
| _listener.assertNoErrors();
|
| @@ -10216,7 +10391,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitConditionalExpression_differentTypes() {
|
| // true ? 1.0 : 0
|
| Expression node = AstFactory.conditionalExpression(
|
| - AstFactory.booleanLiteral(true), _resolvedDouble(1.0),
|
| + AstFactory.booleanLiteral(true),
|
| + _resolvedDouble(1.0),
|
| _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.numType));
|
| _listener.assertNoErrors();
|
| @@ -10225,7 +10401,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitConditionalExpression_sameTypes() {
|
| // true ? 1 : 0
|
| Expression node = AstFactory.conditionalExpression(
|
| - AstFactory.booleanLiteral(true), _resolvedInteger(1),
|
| + AstFactory.booleanLiteral(true),
|
| + _resolvedInteger(1),
|
| _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| @@ -10377,10 +10554,8 @@ 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();
|
| }
|
|
|
| @@ -10492,10 +10667,8 @@ 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();
|
| }
|
|
|
| @@ -10598,7 +10771,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| constructor.type = constructorType;
|
| classElement.constructors = <ConstructorElement>[constructor];
|
| InstanceCreationExpression node = AstFactory.instanceCreationExpression2(
|
| - null, AstFactory.typeName(classElement),
|
| + null,
|
| + AstFactory.typeName(classElement),
|
| [AstFactory.identifier3(constructorName)]);
|
| node.staticElement = constructor;
|
| expect(_analyze(node), same(classElement.type));
|
| @@ -10671,8 +10845,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // []
|
| Expression node = AstFactory.listLiteral();
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.listType
|
| - .substitute4(<DartType>[_typeProvider.dynamicType]), resultType);
|
| + _assertType2(
|
| + _typeProvider.listType
|
| + .substitute4(<DartType>[_typeProvider.dynamicType]),
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10680,8 +10856,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // [0]
|
| Expression node = AstFactory.listLiteral([_resolvedInteger(0)]);
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.listType
|
| - .substitute4(<DartType>[_typeProvider.dynamicType]), resultType);
|
| + _assertType2(
|
| + _typeProvider.listType
|
| + .substitute4(<DartType>[_typeProvider.dynamicType]),
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -10689,7 +10867,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // {}
|
| Expression node = AstFactory.mapLiteral2();
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.mapType.substitute4(
|
| + _assertType2(
|
| + _typeProvider.mapType.substitute4(
|
| <DartType>[_typeProvider.dynamicType, _typeProvider.dynamicType]),
|
| resultType);
|
| _listener.assertNoErrors();
|
| @@ -10700,7 +10879,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| Expression node = AstFactory
|
| .mapLiteral2([AstFactory.mapLiteralEntry("k", _resolvedInteger(0))]);
|
| DartType resultType = _analyze(node);
|
| - _assertType2(_typeProvider.mapType.substitute4(
|
| + _assertType2(
|
| + _typeProvider.mapType.substitute4(
|
| <DartType>[_typeProvider.dynamicType, _typeProvider.dynamicType]),
|
| resultType);
|
| _listener.assertNoErrors();
|
| @@ -10926,8 +11106,9 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitThisExpression() {
|
| // this
|
| - InterfaceType thisType = ElementFactory.classElement(
|
| - "B", ElementFactory.classElement2("A").type).type;
|
| + InterfaceType thisType = ElementFactory
|
| + .classElement("B", ElementFactory.classElement2("A").type)
|
| + .type;
|
| Expression node = AstFactory.thisExpression();
|
| expect(_analyze3(node, thisType), same(thisType));
|
| _listener.assertNoErrors();
|
| @@ -11026,9 +11207,12 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| * @param expectedNamedTypes the expected types of the named parameters
|
| * @param actualType the type being tested
|
| */
|
| - void _assertFunctionType(DartType expectedReturnType,
|
| - List<DartType> expectedNormalTypes, List<DartType> expectedOptionalTypes,
|
| - Map<String, DartType> expectedNamedTypes, DartType actualType) {
|
| + void _assertFunctionType(
|
| + DartType expectedReturnType,
|
| + List<DartType> expectedNormalTypes,
|
| + List<DartType> expectedOptionalTypes,
|
| + Map<String, DartType> expectedNamedTypes,
|
| + DartType actualType) {
|
| EngineTestCase.assertInstanceOf(
|
| (obj) => obj is FunctionType, FunctionType, actualType);
|
| FunctionType functionType = actualType as FunctionType;
|
| @@ -11781,7 +11965,9 @@ class TypeOverrideManagerTest extends EngineTestCase {
|
| @reflectiveTest
|
| class TypePropagationTest extends ResolverTestCase {
|
| void fail_finalPropertyInducingVariable_classMember_instance() {
|
| - addNamedSource("/lib.dart", r'''
|
| + addNamedSource(
|
| + "/lib.dart",
|
| + r'''
|
| class A {
|
| final v = 0;
|
| }''');
|
| @@ -11795,7 +11981,9 @@ f(A a) {
|
| }
|
|
|
| void fail_finalPropertyInducingVariable_classMember_instance_inherited() {
|
| - addNamedSource("/lib.dart", r'''
|
| + addNamedSource(
|
| + "/lib.dart",
|
| + r'''
|
| class A {
|
| final v = 0;
|
| }''');
|
| @@ -11811,7 +11999,9 @@ class B extends A {
|
| }
|
|
|
| void fail_finalPropertyInducingVariable_classMember_instance_propagatedTarget() {
|
| - addNamedSource("/lib.dart", r'''
|
| + addNamedSource(
|
| + "/lib.dart",
|
| + r'''
|
| class A {
|
| final v = 0;
|
| }''');
|
| @@ -11827,7 +12017,9 @@ f(p) {
|
| }
|
|
|
| void fail_finalPropertyInducingVariable_classMember_static() {
|
| - addNamedSource("/lib.dart", r'''
|
| + addNamedSource(
|
| + "/lib.dart",
|
| + r'''
|
| class A {
|
| static final V = 0;
|
| }''');
|
| @@ -11864,7 +12056,8 @@ f() {
|
|
|
| void fail_mergePropagatedTypesAtJoinPoint_1() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f1(x) {
|
| var y = [];
|
| if (x) {
|
| @@ -11875,12 +12068,15 @@ f1(x) {
|
| // Propagated type is [List] here: incorrect.
|
| // Best we can do is [Object]?
|
| return y; // marker
|
| -}''', null, typeProvider.dynamicType);
|
| +}''',
|
| + null,
|
| + typeProvider.dynamicType);
|
| }
|
|
|
| void fail_mergePropagatedTypesAtJoinPoint_2() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f2(x) {
|
| var y = [];
|
| if (x) {
|
| @@ -11890,12 +12086,15 @@ f2(x) {
|
| // Propagated type is [List] here: incorrect.
|
| // Best we can do is [Object]?
|
| return y; // marker
|
| -}''', null, typeProvider.dynamicType);
|
| +}''',
|
| + null,
|
| + typeProvider.dynamicType);
|
| }
|
|
|
| void fail_mergePropagatedTypesAtJoinPoint_3() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f4(x) {
|
| var y = [];
|
| if (x) {
|
| @@ -11907,12 +12106,15 @@ f4(x) {
|
| // A correct answer is the least upper bound of [int] and [double],
|
| // i.e. [num].
|
| return y; // marker
|
| -}''', null, typeProvider.numType);
|
| +}''',
|
| + null,
|
| + typeProvider.numType);
|
| }
|
|
|
| void fail_mergePropagatedTypesAtJoinPoint_5() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f6(x,y) {
|
| var z = [];
|
| if (x || (z = y) < 0) {
|
| @@ -11922,7 +12124,9 @@ f6(x,y) {
|
| // Propagated type is [List] here: incorrect.
|
| // Best we can do is [Object]?
|
| return z; // marker
|
| -}''', null, typeProvider.dynamicType);
|
| +}''',
|
| + null,
|
| + typeProvider.dynamicType);
|
| }
|
|
|
| void fail_mergePropagatedTypesAtJoinPoint_7() {
|
| @@ -12162,6 +12366,34 @@ main() {
|
| }
|
| }
|
|
|
| + void test_forEach_async() {
|
| + String code = r'''
|
| +import 'dart:async';
|
| +f(Stream<String> stream) async {
|
| + await for (var e in stream) {
|
| + e;
|
| + }
|
| +}''';
|
| + Source source = addSource(code);
|
| + LibraryElement library = resolve2(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + CompilationUnit unit = resolveCompilationUnit(source, library);
|
| + InterfaceType stringType = typeProvider.stringType;
|
| + // in the declaration
|
| + {
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit, code, "e in", (node) => node is SimpleIdentifier);
|
| + expect(identifier.propagatedType, same(stringType));
|
| + }
|
| + // in the loop body
|
| + {
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit, code, "e;", (node) => node is SimpleIdentifier);
|
| + expect(identifier.propagatedType, same(stringType));
|
| + }
|
| + }
|
| +
|
| void test_functionExpression_asInvocationArgument() {
|
| String code = r'''
|
| class MyMap<K, V> {
|
| @@ -12984,18 +13216,22 @@ main() {
|
| }
|
|
|
| void test_mergePropagatedTypes_afterIfThen_same() {
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| main() {
|
| var v = 1;
|
| if (v != null) {
|
| v = 2;
|
| }
|
| return v; // marker
|
| -}''', null, typeProvider.intType);
|
| +}''',
|
| + null,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_mergePropagatedTypes_afterIfThenElse_different() {
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| main() {
|
| var v = 1;
|
| if (v != null) {
|
| @@ -13004,11 +13240,14 @@ main() {
|
| v = '3';
|
| }
|
| return v; // marker
|
| -}''', null, null);
|
| +}''',
|
| + null,
|
| + null);
|
| }
|
|
|
| void test_mergePropagatedTypes_afterIfThenElse_same() {
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| main() {
|
| var v = 1;
|
| if (v != null) {
|
| @@ -13017,12 +13256,15 @@ main() {
|
| v = 3;
|
| }
|
| return v; // marker
|
| -}''', null, typeProvider.intType);
|
| +}''',
|
| + null,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_mergePropagatedTypesAtJoinPoint_4() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f5(x) {
|
| var y = [];
|
| if (x) {
|
| @@ -13032,7 +13274,9 @@ f5(x) {
|
| }
|
| // Propagated type is [int] here: correct.
|
| return y; // marker
|
| -}''', null, typeProvider.intType);
|
| +}''',
|
| + null,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_mutatedOutsideScope() {
|
| @@ -13073,38 +13317,50 @@ void g() {
|
| // static type of [bool] for [==] comparison and the implementation
|
| // was already consistent with the spec there. But, it's another
|
| // [Object] method, so it's included here.
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f1(x) {
|
| var v = (x == x);
|
| return v; // marker
|
| -}''', null, typeProvider.boolType);
|
| +}''',
|
| + null,
|
| + typeProvider.boolType);
|
| }
|
|
|
| void test_objectMethodOnDynamicExpression_hashCode() {
|
| // https://code.google.com/p/dart/issues/detail?id=20342
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f1(x) {
|
| var v = x.hashCode;
|
| return v; // marker
|
| -}''', null, typeProvider.intType);
|
| +}''',
|
| + null,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_objectMethodOnDynamicExpression_runtimeType() {
|
| // https://code.google.com/p/dart/issues/detail?id=20342
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f1(x) {
|
| var v = x.runtimeType;
|
| return v; // marker
|
| -}''', null, typeProvider.typeType);
|
| +}''',
|
| + null,
|
| + typeProvider.typeType);
|
| }
|
|
|
| void test_objectMethodOnDynamicExpression_toString() {
|
| // https://code.google.com/p/dart/issues/detail?id=20342
|
| - _assertTypeOfMarkedExpression(r'''
|
| + _assertTypeOfMarkedExpression(
|
| + r'''
|
| f1(x) {
|
| var v = x.toString();
|
| return v; // marker
|
| -}''', null, typeProvider.stringType);
|
| +}''',
|
| + null,
|
| + typeProvider.stringType);
|
| }
|
|
|
| void test_propagatedReturnType_function_hasReturnType_returnsNull() {
|
| @@ -13728,10 +13984,14 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ClassElement elementP = ElementFactory.classElement2('P');
|
| FunctionElement elementF = ElementFactory.functionElement('f');
|
| FunctionDeclaration declaration = AstFactory.functionDeclaration(
|
| - AstFactory.typeName4('R'), null, 'f', AstFactory.functionExpression2(
|
| + AstFactory.typeName4('R'),
|
| + null,
|
| + 'f',
|
| + AstFactory.functionExpression2(
|
| AstFactory.formalParameterList([
|
| - AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p')
|
| - ]), null));
|
| + AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p')
|
| + ]),
|
| + null));
|
| declaration.name.staticElement = elementF;
|
| _resolveNode(declaration, [elementR, elementP]);
|
| expect(declaration.returnType.type, elementR.type);
|
| @@ -13747,10 +14007,14 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| FunctionElementImpl elementF = ElementFactory.functionElement('f');
|
| elementF.typeParameters = <TypeParameterElement>[elementE];
|
| FunctionDeclaration declaration = AstFactory.functionDeclaration(
|
| - AstFactory.typeName4('E'), null, 'f', AstFactory.functionExpression2(
|
| + AstFactory.typeName4('E'),
|
| + null,
|
| + 'f',
|
| + AstFactory.functionExpression2(
|
| AstFactory.formalParameterList([
|
| - AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e')
|
| - ]), null));
|
| + AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e')
|
| + ]),
|
| + null));
|
| declaration.name.staticElement = elementF;
|
| _resolveNode(declaration, []);
|
| expect(declaration.returnType.type, elementE.type);
|
| @@ -13775,7 +14039,10 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ]);
|
| parameterDeclaration.identifier.staticElement = requiredParameter;
|
| FunctionDeclaration declaration = AstFactory.functionDeclaration(
|
| - AstFactory.typeName4('R'), null, 'f', AstFactory.functionExpression2(
|
| + AstFactory.typeName4('R'),
|
| + null,
|
| + 'f',
|
| + AstFactory.functionExpression2(
|
| AstFactory.formalParameterList([parameterDeclaration]), null));
|
| declaration.name.staticElement = elementF;
|
| _resolveNode(declaration, [elementR, elementP]);
|
| @@ -13803,7 +14070,10 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ]);
|
| parameterDeclaration.identifier.staticElement = requiredParameter;
|
| FunctionDeclaration declaration = AstFactory.functionDeclaration(
|
| - AstFactory.typeName4('R'), null, 'f', AstFactory.functionExpression2(
|
| + AstFactory.typeName4('R'),
|
| + null,
|
| + 'f',
|
| + AstFactory.functionExpression2(
|
| AstFactory.formalParameterList([parameterDeclaration]), null));
|
| declaration.name.staticElement = elementF;
|
| _resolveNode(declaration, [elementR]);
|
| @@ -13827,11 +14097,15 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ClassElement elementP = ElementFactory.classElement2('P');
|
| MethodElement elementM = ElementFactory.methodElement('m', null);
|
| elementA.methods = <MethodElement>[elementM];
|
| - MethodDeclaration declaration = AstFactory.methodDeclaration(null,
|
| - AstFactory.typeName4('R'), null, null, AstFactory.identifier3('m'),
|
| + MethodDeclaration declaration = AstFactory.methodDeclaration(
|
| + null,
|
| + AstFactory.typeName4('R'),
|
| + null,
|
| + null,
|
| + AstFactory.identifier3('m'),
|
| AstFactory.formalParameterList([
|
| - AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p')
|
| - ]));
|
| + AstFactory.simpleFormalParameter4(AstFactory.typeName4('P'), 'p')
|
| + ]));
|
| declaration.name.staticElement = elementM;
|
| _resolveNode(declaration, [elementA, elementR, elementP]);
|
| expect(declaration.returnType.type, elementR.type);
|
| @@ -13849,11 +14123,15 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| MethodElementImpl elementM = ElementFactory.methodElement('m', null);
|
| elementM.typeParameters = <TypeParameterElement>[elementE];
|
| elementA.methods = <MethodElement>[elementM];
|
| - MethodDeclaration declaration = AstFactory.methodDeclaration(null,
|
| - AstFactory.typeName4('E'), null, null, AstFactory.identifier3('m'),
|
| + MethodDeclaration declaration = AstFactory.methodDeclaration(
|
| + null,
|
| + AstFactory.typeName4('E'),
|
| + null,
|
| + null,
|
| + AstFactory.identifier3('m'),
|
| AstFactory.formalParameterList([
|
| - AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e')
|
| - ]));
|
| + AstFactory.simpleFormalParameter4(AstFactory.typeName4('E'), 'e')
|
| + ]));
|
| declaration.name.staticElement = elementM;
|
| _resolveNode(declaration, [elementA]);
|
| expect(declaration.returnType.type, elementE.type);
|
|
|