| 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 f67f8483ae156519f327d1851d27d2dfc5c91bae..cbe106ecbbfcbe3116be5aef716cf2de47f1479f 100644
|
| --- a/pkg/analyzer/test/generated/resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/resolver_test.dart
|
| @@ -5,31 +5,66 @@
|
| library engine.resolver_test;
|
|
|
| import 'dart:collection';
|
| +
|
| +import 'package:analyzer/src/generated/ast.dart';
|
| +import 'package:analyzer/src/generated/element.dart';
|
| +import 'package:analyzer/src/generated/element_resolver.dart';
|
| +import 'package:analyzer/src/generated/engine.dart';
|
| +import 'package:analyzer/src/generated/error.dart';
|
| import 'package:analyzer/src/generated/java_core.dart';
|
| import 'package:analyzer/src/generated/java_engine.dart';
|
| import 'package:analyzer/src/generated/java_engine_io.dart';
|
| -import 'package:analyzer/src/generated/source_io.dart';
|
| -import 'package:analyzer/src/generated/error.dart';
|
| -import 'package:analyzer/src/generated/scanner.dart';
|
| -import 'package:analyzer/src/generated/ast.dart';
|
| +import 'package:analyzer/src/generated/java_io.dart';
|
| import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
|
| -import 'package:analyzer/src/generated/element.dart';
|
| -import 'package:analyzer/src/generated/element_resolver.dart';
|
| import 'package:analyzer/src/generated/resolver.dart';
|
| -import 'package:analyzer/src/generated/static_type_analyzer.dart';
|
| -import 'package:analyzer/src/generated/engine.dart';
|
| -import 'package:analyzer/src/generated/utilities_dart.dart';
|
| +import 'package:analyzer/src/generated/scanner.dart';
|
| import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
|
| -import 'package:unittest/unittest.dart';
|
| -import 'test_support.dart';
|
| +import 'package:analyzer/src/generated/source_io.dart';
|
| +import 'package:analyzer/src/generated/static_type_analyzer.dart';
|
| import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
| import 'package:analyzer/src/generated/testing/element_factory.dart';
|
| -import 'package:analyzer/src/generated/java_io.dart';
|
| +import 'package:analyzer/src/generated/utilities_dart.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| import '../reflective_tests.dart';
|
| import 'parser_test.dart';
|
| +import 'test_support.dart';
|
|
|
|
|
| +main() {
|
| + groupSep = ' | ';
|
| + runReflectiveTests(AnalysisDeltaTest);
|
| + runReflectiveTests(ChangeSetTest);
|
| + runReflectiveTests(EnclosedScopeTest);
|
| + runReflectiveTests(LibraryImportScopeTest);
|
| + runReflectiveTests(LibraryScopeTest);
|
| + runReflectiveTests(ScopeBuilderTest);
|
| + runReflectiveTests(ScopeTest);
|
| + runReflectiveTests(DeclarationMatcherTest);
|
| + runReflectiveTests(ElementResolverTest);
|
| + runReflectiveTests(IncrementalResolverTest);
|
| + runReflectiveTests(InheritanceManagerTest);
|
| + runReflectiveTests(LibraryElementBuilderTest);
|
| + runReflectiveTests(LibraryResolver2Test);
|
| + runReflectiveTests(LibraryResolverTest);
|
| + runReflectiveTests(LibraryTest);
|
| + runReflectiveTests(StaticTypeAnalyzerTest);
|
| + runReflectiveTests(StaticTypeAnalyzer2Test);
|
| + runReflectiveTests(SubtypeManagerTest);
|
| + runReflectiveTests(TypeOverrideManagerTest);
|
| + runReflectiveTests(TypeProviderImplTest);
|
| + runReflectiveTests(TypeResolverVisitorTest);
|
| + runReflectiveTests(CheckedModeCompileTimeErrorCodeTest);
|
| + runReflectiveTests(ErrorResolverTest);
|
| + runReflectiveTests(HintCodeTest);
|
| + runReflectiveTests(MemberMapTest);
|
| + runReflectiveTests(NonHintCodeTest);
|
| + runReflectiveTests(SimpleResolverTest);
|
| + runReflectiveTests(StrictModeTest);
|
| + runReflectiveTests(TypePropagationTest);
|
| +}
|
| +
|
| /**
|
| * The class `AnalysisContextFactory` defines utility methods used to create analysis contexts
|
| * for testing purposes.
|
| @@ -58,7 +93,8 @@ class AnalysisContextFactory {
|
| * @param options the options to be applied to the context
|
| * @return the analysis context that was created
|
| */
|
| - static AnalysisContextImpl contextWithCoreAndOptions(AnalysisOptions options) {
|
| + static AnalysisContextImpl
|
| + contextWithCoreAndOptions(AnalysisOptions options) {
|
| AnalysisContextForTests context = new AnalysisContextForTests();
|
| context._internalSetAnalysisOptions(options);
|
| return initContextWithCore(context);
|
| @@ -71,20 +107,23 @@ class AnalysisContextFactory {
|
| * @return the analysis context that was created
|
| */
|
| static AnalysisContextImpl initContextWithCore(AnalysisContextImpl context) {
|
| - DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk_AnalysisContextFactory_initContextWithCore(new JavaFile("/fake/sdk"));
|
| - SourceFactory sourceFactory = new SourceFactory([new DartUriResolver(sdk), new FileUriResolver()]);
|
| + DirectoryBasedDartSdk sdk =
|
| + new _AnalysisContextFactory_initContextWithCore(new JavaFile("/fake/sdk"));
|
| + SourceFactory sourceFactory =
|
| + new SourceFactory([new DartUriResolver(sdk), new FileUriResolver()]);
|
| context.sourceFactory = sourceFactory;
|
| AnalysisContext coreContext = sdk.context;
|
| //
|
| // dart:core
|
| //
|
| TestTypeProvider provider = new TestTypeProvider();
|
| - CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.dart");
|
| + CompilationUnitElementImpl coreUnit =
|
| + new CompilationUnitElementImpl("core.dart");
|
| Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
|
| coreContext.setContents(coreSource, "");
|
| coreUnit.source = coreSource;
|
| ClassElementImpl proxyClassElement = ElementFactory.classElement2("_Proxy");
|
| - coreUnit.types = <ClassElement> [
|
| + coreUnit.types = <ClassElement>[
|
| provider.boolType.element,
|
| provider.deprecatedType.element,
|
| provider.doubleType.element,
|
| @@ -100,76 +139,128 @@ class AnalysisContextFactory {
|
| provider.stringType.element,
|
| provider.symbolType.element,
|
| provider.typeType.element];
|
| - coreUnit.functions = <FunctionElement> [ElementFactory.functionElement3("identical", provider.boolType.element, <ClassElement> [provider.objectType.element, provider.objectType.element], null)];
|
| - TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory.topLevelVariableElement3("proxy", true, false, proxyClassElement.type);
|
| - TopLevelVariableElement deprecatedTopLevelVariableElt = ElementFactory.topLevelVariableElement3("deprecated", true, false, provider.deprecatedType);
|
| - coreUnit.accessors = <PropertyAccessorElement> [
|
| + coreUnit.functions = <FunctionElement>[
|
| + ElementFactory.functionElement3(
|
| + "identical",
|
| + provider.boolType.element,
|
| + <ClassElement>[provider.objectType.element, provider.objectType.element],
|
| + null)];
|
| + TopLevelVariableElement proxyTopLevelVariableElt =
|
| + ElementFactory.topLevelVariableElement3(
|
| + "proxy",
|
| + true,
|
| + false,
|
| + proxyClassElement.type);
|
| + TopLevelVariableElement deprecatedTopLevelVariableElt =
|
| + ElementFactory.topLevelVariableElement3(
|
| + "deprecated",
|
| + true,
|
| + false,
|
| + provider.deprecatedType);
|
| + coreUnit.accessors = <PropertyAccessorElement>[
|
| proxyTopLevelVariableElt.getter,
|
| proxyTopLevelVariableElt.setter,
|
| deprecatedTopLevelVariableElt.getter,
|
| deprecatedTopLevelVariableElt.setter];
|
| - coreUnit.topLevelVariables = <TopLevelVariableElement> [proxyTopLevelVariableElt, deprecatedTopLevelVariableElt];
|
| - LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(coreContext, AstFactory.libraryIdentifier2(["dart", "core"]));
|
| + coreUnit.topLevelVariables = <TopLevelVariableElement>[
|
| + proxyTopLevelVariableElt,
|
| + deprecatedTopLevelVariableElt];
|
| + LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
|
| + coreContext,
|
| + AstFactory.libraryIdentifier2(["dart", "core"]));
|
| coreLibrary.definingCompilationUnit = coreUnit;
|
| //
|
| // dart:async
|
| //
|
| - CompilationUnitElementImpl asyncUnit = new CompilationUnitElementImpl("async.dart");
|
| + CompilationUnitElementImpl asyncUnit =
|
| + new CompilationUnitElementImpl("async.dart");
|
| Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
|
| coreContext.setContents(asyncSource, "");
|
| asyncUnit.source = asyncSource;
|
| // Future
|
| - ClassElementImpl futureElement = ElementFactory.classElement2("Future", ["T"]);
|
| + ClassElementImpl futureElement =
|
| + ElementFactory.classElement2("Future", ["T"]);
|
| InterfaceType futureType = futureElement.type;
|
| // factory Future.value([value])
|
| - ConstructorElementImpl futureConstructor = ElementFactory.constructorElement2(futureElement, "value");
|
| - futureConstructor.parameters = <ParameterElement> [ElementFactory.positionalParameter2("value", provider.dynamicType)];
|
| + ConstructorElementImpl futureConstructor =
|
| + ElementFactory.constructorElement2(futureElement, "value");
|
| + futureConstructor.parameters = <ParameterElement>[
|
| + ElementFactory.positionalParameter2("value", provider.dynamicType)];
|
| futureConstructor.factory = true;
|
| - (futureConstructor.type as FunctionTypeImpl).typeArguments = futureElement.type.typeArguments;
|
| - futureElement.constructors = <ConstructorElement> [futureConstructor];
|
| + (futureConstructor.type as FunctionTypeImpl).typeArguments =
|
| + futureElement.type.typeArguments;
|
| + futureElement.constructors = <ConstructorElement>[futureConstructor];
|
| // Future then(onValue(T value), { Function onError });
|
| - List<ParameterElement> parameters = <ParameterElement> [ElementFactory.requiredParameter2("value", futureElement.typeParameters[0].type)];
|
| - FunctionTypeAliasElementImpl aliasElement = new FunctionTypeAliasElementImpl.forNode(null);
|
| + List<ParameterElement> parameters = <ParameterElement>[
|
| + ElementFactory.requiredParameter2(
|
| + "value",
|
| + futureElement.typeParameters[0].type)];
|
| + FunctionTypeAliasElementImpl aliasElement =
|
| + new FunctionTypeAliasElementImpl.forNode(null);
|
| aliasElement.synthetic = true;
|
| aliasElement.shareParameters(parameters);
|
| aliasElement.returnType = provider.dynamicType;
|
| FunctionTypeImpl aliasType = new FunctionTypeImpl.con2(aliasElement);
|
| aliasElement.shareTypeParameters(futureElement.typeParameters);
|
| aliasType.typeArguments = futureElement.type.typeArguments;
|
| - MethodElement thenMethod = ElementFactory.methodElementWithParameters("then", futureElement.type.typeArguments, futureType, [
|
| - ElementFactory.requiredParameter2("onValue", aliasType),
|
| - ElementFactory.namedParameter2("onError", provider.functionType)]);
|
| - futureElement.methods = <MethodElement> [thenMethod];
|
| + MethodElement thenMethod = ElementFactory.methodElementWithParameters(
|
| + "then",
|
| + futureElement.type.typeArguments,
|
| + futureType,
|
| + [
|
| + ElementFactory.requiredParameter2("onValue", aliasType),
|
| + ElementFactory.namedParameter2("onError", provider.functionType)]);
|
| + futureElement.methods = <MethodElement>[thenMethod];
|
| // Completer
|
| - ClassElementImpl completerElement = ElementFactory.classElement2("Completer", ["T"]);
|
| - ConstructorElementImpl completerConstructor = ElementFactory.constructorElement2(completerElement, null);
|
| - (completerConstructor.type as FunctionTypeImpl).typeArguments = completerElement.type.typeArguments;
|
| - completerElement.constructors = <ConstructorElement> [completerConstructor];
|
| - asyncUnit.types = <ClassElement> [
|
| + ClassElementImpl completerElement =
|
| + ElementFactory.classElement2("Completer", ["T"]);
|
| + ConstructorElementImpl completerConstructor =
|
| + ElementFactory.constructorElement2(completerElement, null);
|
| + (completerConstructor.type as FunctionTypeImpl).typeArguments =
|
| + completerElement.type.typeArguments;
|
| + completerElement.constructors = <ConstructorElement>[completerConstructor];
|
| + asyncUnit.types = <ClassElement>[
|
| completerElement,
|
| futureElement,
|
| ElementFactory.classElement2("Stream", ["T"])];
|
| - LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode(coreContext, AstFactory.libraryIdentifier2(["dart", "async"]));
|
| + LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode(
|
| + coreContext,
|
| + AstFactory.libraryIdentifier2(["dart", "async"]));
|
| asyncLibrary.definingCompilationUnit = asyncUnit;
|
| //
|
| // dart:html
|
| //
|
| - CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_dartium.dart");
|
| + CompilationUnitElementImpl htmlUnit =
|
| + new CompilationUnitElementImpl("html_dartium.dart");
|
| Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
|
| coreContext.setContents(htmlSource, "");
|
| htmlUnit.source = htmlSource;
|
| ClassElementImpl elementElement = ElementFactory.classElement2("Element");
|
| InterfaceType elementType = elementElement.type;
|
| - ClassElementImpl canvasElement = ElementFactory.classElement("CanvasElement", elementType);
|
| - ClassElementImpl contextElement = ElementFactory.classElement2("CanvasRenderingContext");
|
| + ClassElementImpl canvasElement =
|
| + ElementFactory.classElement("CanvasElement", elementType);
|
| + ClassElementImpl contextElement =
|
| + ElementFactory.classElement2("CanvasRenderingContext");
|
| InterfaceType contextElementType = contextElement.type;
|
| - ClassElementImpl context2dElement = ElementFactory.classElement("CanvasRenderingContext2D", contextElementType);
|
| - canvasElement.methods = <MethodElement> [ElementFactory.methodElement("getContext", contextElementType, [provider.stringType])];
|
| - canvasElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("context2D", false, context2dElement.type)];
|
| - ClassElementImpl documentElement = ElementFactory.classElement("Document", elementType);
|
| - ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocument", documentElement.type);
|
| - htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement("query", elementType, <DartType> [provider.stringType])];
|
| - htmlUnit.types = <ClassElement> [
|
| + ClassElementImpl context2dElement =
|
| + ElementFactory.classElement("CanvasRenderingContext2D", contextElementType);
|
| + canvasElement.methods = <MethodElement>[
|
| + ElementFactory.methodElement(
|
| + "getContext",
|
| + contextElementType,
|
| + [provider.stringType])];
|
| + canvasElement.accessors = <PropertyAccessorElement>[
|
| + ElementFactory.getterElement("context2D", false, context2dElement.type)];
|
| + ClassElementImpl documentElement =
|
| + ElementFactory.classElement("Document", elementType);
|
| + ClassElementImpl htmlDocumentElement =
|
| + ElementFactory.classElement("HtmlDocument", documentElement.type);
|
| + htmlDocumentElement.methods = <MethodElement>[
|
| + ElementFactory.methodElement(
|
| + "query",
|
| + elementType,
|
| + <DartType>[provider.stringType])];
|
| + htmlUnit.types = <ClassElement>[
|
| ElementFactory.classElement("AnchorElement", elementType),
|
| ElementFactory.classElement("BodyElement", elementType),
|
| ElementFactory.classElement("ButtonElement", elementType),
|
| @@ -182,38 +273,77 @@ class AnalysisContextFactory {
|
| htmlDocumentElement,
|
| ElementFactory.classElement("InputElement", elementType),
|
| ElementFactory.classElement("SelectElement", elementType)];
|
| - htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("query", elementElement, <ClassElement> [provider.stringType.element], ClassElementImpl.EMPTY_ARRAY)];
|
| - TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElement3("document", false, true, htmlDocumentElement.type);
|
| - htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
|
| - htmlUnit.accessors = <PropertyAccessorElement> [document.getter];
|
| - LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode(coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"]));
|
| + htmlUnit.functions = <FunctionElement>[
|
| + ElementFactory.functionElement3(
|
| + "query",
|
| + elementElement,
|
| + <ClassElement>[provider.stringType.element],
|
| + ClassElementImpl.EMPTY_ARRAY)];
|
| + TopLevelVariableElementImpl document =
|
| + ElementFactory.topLevelVariableElement3(
|
| + "document",
|
| + false,
|
| + true,
|
| + htmlDocumentElement.type);
|
| + htmlUnit.topLevelVariables = <TopLevelVariableElement>[document];
|
| + htmlUnit.accessors = <PropertyAccessorElement>[document.getter];
|
| + LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode(
|
| + coreContext,
|
| + AstFactory.libraryIdentifier2(["dart", "dom", "html"]));
|
| htmlLibrary.definingCompilationUnit = htmlUnit;
|
| //
|
| // dart:math
|
| //
|
| - CompilationUnitElementImpl mathUnit = new CompilationUnitElementImpl("math.dart");
|
| + CompilationUnitElementImpl mathUnit =
|
| + new CompilationUnitElementImpl("math.dart");
|
| Source mathSource = sourceFactory.forUri(_DART_MATH);
|
| coreContext.setContents(mathSource, "");
|
| mathUnit.source = mathSource;
|
| - FunctionElement cosElement = ElementFactory.functionElement3("cos", provider.doubleType.element, <ClassElement>[provider.numType.element], ClassElementImpl.EMPTY_ARRAY);
|
| - TopLevelVariableElement ln10Element = ElementFactory.topLevelVariableElement3("LN10", true, false, provider.doubleType);
|
| - TopLevelVariableElement piElement = ElementFactory.topLevelVariableElement3("PI", true, false, provider.doubleType);
|
| + FunctionElement cosElement = ElementFactory.functionElement3(
|
| + "cos",
|
| + provider.doubleType.element,
|
| + <ClassElement>[provider.numType.element],
|
| + ClassElementImpl.EMPTY_ARRAY);
|
| + TopLevelVariableElement ln10Element =
|
| + ElementFactory.topLevelVariableElement3(
|
| + "LN10",
|
| + true,
|
| + false,
|
| + provider.doubleType);
|
| + TopLevelVariableElement piElement = ElementFactory.topLevelVariableElement3(
|
| + "PI",
|
| + true,
|
| + false,
|
| + provider.doubleType);
|
| ClassElementImpl randomElement = ElementFactory.classElement2("Random");
|
| randomElement.abstract = true;
|
| - ConstructorElementImpl randomConstructor = ElementFactory.constructorElement2(randomElement, null);
|
| + ConstructorElementImpl randomConstructor =
|
| + ElementFactory.constructorElement2(randomElement, null);
|
| randomConstructor.factory = true;
|
| ParameterElementImpl seedParam = new ParameterElementImpl("seed", 0);
|
| seedParam.parameterKind = ParameterKind.POSITIONAL;
|
| seedParam.type = provider.intType;
|
| - randomConstructor.parameters = <ParameterElement> [seedParam];
|
| - randomElement.constructors = <ConstructorElement> [randomConstructor];
|
| - FunctionElement sinElement = ElementFactory.functionElement3("sin", 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);
|
| - mathUnit.accessors = <PropertyAccessorElement> [ln10Element.getter, piElement.getter];
|
| - mathUnit.functions = <FunctionElement> [cosElement, sinElement, sqrtElement];
|
| - mathUnit.topLevelVariables = <TopLevelVariableElement> [ln10Element, piElement];
|
| - mathUnit.types = <ClassElement> [randomElement];
|
| - LibraryElementImpl mathLibrary = new LibraryElementImpl.forNode(coreContext, AstFactory.libraryIdentifier2(["dart", "math"]));
|
| + randomConstructor.parameters = <ParameterElement>[seedParam];
|
| + randomElement.constructors = <ConstructorElement>[randomConstructor];
|
| + FunctionElement sinElement = ElementFactory.functionElement3(
|
| + "sin",
|
| + 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);
|
| + mathUnit.accessors =
|
| + <PropertyAccessorElement>[ln10Element.getter, piElement.getter];
|
| + mathUnit.functions = <FunctionElement>[cosElement, sinElement, sqrtElement];
|
| + mathUnit.topLevelVariables =
|
| + <TopLevelVariableElement>[ln10Element, piElement];
|
| + mathUnit.types = <ClassElement>[randomElement];
|
| + LibraryElementImpl mathLibrary = new LibraryElementImpl.forNode(
|
| + coreContext,
|
| + AstFactory.libraryIdentifier2(["dart", "math"]));
|
| mathLibrary.definingCompilationUnit = mathUnit;
|
| //
|
| // Set empty sources for the rest of the libraries.
|
| @@ -225,7 +355,8 @@ class AnalysisContextFactory {
|
| //
|
| // Record the elements.
|
| //
|
| - HashMap<Source, LibraryElement> elementMap = new HashMap<Source, LibraryElement>();
|
| + HashMap<Source, LibraryElement> elementMap =
|
| + new HashMap<Source, LibraryElement>();
|
| elementMap[coreSource] = coreLibrary;
|
| elementMap[asyncSource] = asyncLibrary;
|
| elementMap[htmlSource] = htmlLibrary;
|
| @@ -241,7 +372,27 @@ class AnalysisContextFactory {
|
| */
|
| class AnalysisContextForTests extends AnalysisContextImpl {
|
| @override
|
| - bool exists(Source source) => super.exists(source) || sourceFactory.dartSdk.context.exists(source);
|
| + void set analysisOptions(AnalysisOptions options) {
|
| + AnalysisOptions currentOptions = analysisOptions;
|
| + bool needsRecompute =
|
| + currentOptions.analyzeFunctionBodies != options.analyzeFunctionBodies ||
|
| + currentOptions.generateSdkErrors != options.generateSdkErrors ||
|
| + currentOptions.enableAsync != options.enableAsync ||
|
| + currentOptions.enableDeferredLoading != options.enableDeferredLoading ||
|
| + currentOptions.enableEnum != options.enableEnum ||
|
| + currentOptions.dart2jsHint != options.dart2jsHint ||
|
| + (currentOptions.hint && !options.hint) ||
|
| + currentOptions.preserveComments != options.preserveComments;
|
| + if (needsRecompute) {
|
| + fail(
|
| + "Cannot set options that cause the sources to be reanalyzed in a test context");
|
| + }
|
| + super.analysisOptions = options;
|
| + }
|
| +
|
| + @override
|
| + bool exists(Source source) =>
|
| + super.exists(source) || sourceFactory.dartSdk.context.exists(source);
|
|
|
| @override
|
| TimestampedData<String> getContents(Source source) {
|
| @@ -259,16 +410,6 @@ class AnalysisContextForTests extends AnalysisContextImpl {
|
| return super.getModificationStamp(source);
|
| }
|
|
|
| - @override
|
| - void set analysisOptions(AnalysisOptions options) {
|
| - AnalysisOptions currentOptions = analysisOptions;
|
| - bool needsRecompute = currentOptions.analyzeFunctionBodies != options.analyzeFunctionBodies || currentOptions.generateSdkErrors != options.generateSdkErrors || currentOptions.enableAsync != options.enableAsync || currentOptions.enableDeferredLoading != options.enableDeferredLoading || currentOptions.enableEnum != options.enableEnum || currentOptions.dart2jsHint != options.dart2jsHint || (currentOptions.hint && !options.hint) || currentOptions.preserveComments != options.preserveComments;
|
| - if (needsRecompute) {
|
| - fail("Cannot set options that cause the sources to be reanalyzed in a test context");
|
| - }
|
| - super.analysisOptions = options;
|
| - }
|
| -
|
| /**
|
| * Set the analysis options, even if they would force re-analysis. This method should only be
|
| * invoked before the fake SDK is initialized.
|
| @@ -291,7 +432,8 @@ class AnalysisContextHelper {
|
| */
|
| AnalysisContextHelper() {
|
| context = AnalysisContextFactory.contextWithCore();
|
| - AnalysisOptionsImpl options = new AnalysisOptionsImpl.con1(context.analysisOptions);
|
| + AnalysisOptionsImpl options =
|
| + new AnalysisOptionsImpl.con1(context.analysisOptions);
|
| options.cacheSize = 256;
|
| context.analysisOptions = options;
|
| }
|
| @@ -307,7 +449,8 @@ class AnalysisContextHelper {
|
| return source;
|
| }
|
|
|
| - CompilationUnitElement getDefiningUnitElement(Source source) => context.getCompilationUnitElement(source, source);
|
| + CompilationUnitElement getDefiningUnitElement(Source source) =>
|
| + context.getCompilationUnitElement(source, source);
|
|
|
| CompilationUnit resolveDefiningUnit(Source source) {
|
| LibraryElement libraryElement = context.computeLibraryElement(source);
|
| @@ -407,7 +550,8 @@ class ChangeSetTest extends EngineTestCase {
|
| changeSet.changedRange(new TestSource(), "", 0, 0, 0);
|
| changeSet.deletedSource(new TestSource());
|
| changeSet.removedSource(new TestSource());
|
| - changeSet.removedContainer(new SourceContainer_ChangeSetTest_test_toString());
|
| + changeSet.removedContainer(
|
| + new SourceContainer_ChangeSetTest_test_toString());
|
| expect(changeSet.toString(), isNotNull);
|
| }
|
| }
|
| @@ -444,8 +588,7 @@ class A {
|
| }
|
| var v = const A(null);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| @@ -558,20 +701,6 @@ var v = const A(null);''');
|
| verify([source]);
|
| }
|
|
|
| - void test_fieldFormalParameterAssignableToField_typeSubstitution() {
|
| - // foo has the runtime type dynamic -> dynamic, so it should be assignable
|
| - // to A.f.
|
| - Source source = addSource(r'''
|
| -class A<T> {
|
| - final T x;
|
| - const A(this.x);
|
| -}
|
| -var v = const A<int>(3);''');
|
| - resolve(source);
|
| - assertNoErrors(source);
|
| - verify([source]);
|
| - }
|
| -
|
| void test_fieldFormalParameterAssignableToField_typedef() {
|
| // foo has the runtime type dynamic -> dynamic, so it should be assignable
|
| // to A.f.
|
| @@ -588,45 +717,33 @@ var v = const A(foo);''');
|
| verify([source]);
|
| }
|
|
|
| - void test_fieldFormalParameterNotAssignableToField() {
|
| + void test_fieldFormalParameterAssignableToField_typeSubstitution() {
|
| + // foo has the runtime type dynamic -> dynamic, so it should be assignable
|
| + // to A.f.
|
| Source source = addSource(r'''
|
| -class A {
|
| - final int x;
|
| +class A<T> {
|
| + final T x;
|
| const A(this.x);
|
| }
|
| -var v = const A('foo');''');
|
| +var v = const A<int>(3);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| + assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_fieldFormalParameterNotAssignableToField_fieldType() {
|
| + void test_fieldFormalParameterNotAssignableToField() {
|
| Source source = addSource(r'''
|
| class A {
|
| final int x;
|
| - const A(String this.x);
|
| -}
|
| -var v = const A('foo');''');
|
| - resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]);
|
| - verify([source]);
|
| - }
|
| -
|
| - void test_fieldFormalParameterNotAssignableToField_fieldType_unresolved() {
|
| - Source source = addSource(r'''
|
| -class A {
|
| - final Unresolved x;
|
| - const A(String this.x);
|
| + const A(this.x);
|
| }
|
| var v = const A('foo');''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| @@ -647,8 +764,41 @@ class C {
|
| }
|
| var v = const C(const A());''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_fieldFormalParameterNotAssignableToField_fieldType() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + final int x;
|
| + const A(String this.x);
|
| +}
|
| +var v = const A('foo');''');
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_fieldFormalParameterNotAssignableToField_fieldType_unresolved() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + final Unresolved x;
|
| + const A(String this.x);
|
| +}
|
| +var v = const A('foo');''');
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| @@ -667,8 +817,9 @@ class C {
|
| }
|
| var v = const C(const A());''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -680,8 +831,9 @@ class A {
|
| }
|
| var x = const A(const <num>[1, 2, 3]);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -694,8 +846,9 @@ class A {
|
| }
|
| var x = const A(const <num, int>{1: 2});''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -708,8 +861,9 @@ class A {
|
| }
|
| var x = const A(const <int, num>{1: 2});''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -721,9 +875,11 @@ class A {
|
| }
|
| var v = const A();''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticTypeWarningCode.INVALID_ASSIGNMENT]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticTypeWarningCode.INVALID_ASSIGNMENT]);
|
| verify([source]);
|
| }
|
|
|
| @@ -739,9 +895,11 @@ class A {
|
| int foo(String x) => 1;
|
| var v = const A(foo);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| @@ -752,9 +910,11 @@ class A {
|
| const A() : x = '';
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
|
| - StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
|
| + StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| @@ -766,8 +926,9 @@ class A {
|
| }
|
| var v = const A('foo');''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -779,9 +940,11 @@ class A {
|
| }
|
| var v = const A('foo');''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
|
| + StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| @@ -807,58 +970,61 @@ class A {
|
| }
|
| var v = const A(null);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| void test_listElementTypeNotAssignable() {
|
| Source source = addSource("var v = const <String> [42];");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
|
| - StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
|
| + StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| void test_mapKeyTypeNotAssignable() {
|
| Source source = addSource("var v = const <String, int > {1 : 2};");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
|
| - StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
|
| + StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| void test_mapValueTypeNotAssignable() {
|
| Source source = addSource("var v = const <String, String> {'a' : 2};");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
|
| - StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
|
| + StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_redirectingConstructor_paramTypeMismatch() {
|
| + void test_parameterAssignable_null() {
|
| + // Null is assignable to anything.
|
| Source source = addSource(r'''
|
| class A {
|
| - const A.a1(x) : this.a2(x);
|
| - const A.a2(String x);
|
| + const A(int x);
|
| }
|
| -var v = const A.a1(0);''');
|
| +var v = const A(null);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| + assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_parameterAssignable_null() {
|
| - // Null is assignable to anything.
|
| + void test_parameterAssignable_typeSubstitution() {
|
| Source source = addSource(r'''
|
| -class A {
|
| - const A(int x);
|
| +class A<T> {
|
| + const A(T x);
|
| }
|
| -var v = const A(null);''');
|
| +var v = const A<int>(3);''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| @@ -873,32 +1039,37 @@ class A {
|
| }
|
| var v = const A(null);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| - void test_parameterAssignable_typeSubstitution() {
|
| + void test_parameterNotAssignable() {
|
| Source source = addSource(r'''
|
| -class A<T> {
|
| - const A(T x);
|
| +class A {
|
| + const A(int x);
|
| }
|
| -var v = const A<int>(3);''');
|
| +var v = const A('foo');''');
|
| resolve(source);
|
| - assertNoErrors(source);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_parameterNotAssignable() {
|
| + void test_parameterNotAssignable_typeSubstitution() {
|
| Source source = addSource(r'''
|
| -class A {
|
| - const A(int x);
|
| +class A<T> {
|
| + const A(T x);
|
| }
|
| -var v = const A('foo');''');
|
| +var v = const A<int>('foo');''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| verify([source]);
|
| }
|
|
|
| @@ -909,22 +1080,25 @@ class A {
|
| }
|
| var v = const A('foo');''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| + StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| - void test_parameterNotAssignable_typeSubstitution() {
|
| + void test_redirectingConstructor_paramTypeMismatch() {
|
| Source source = addSource(r'''
|
| -class A<T> {
|
| - const A(T x);
|
| +class A {
|
| + const A.a1(x) : this.a2(x);
|
| + const A.a2(String x);
|
| }
|
| -var v = const A<int>('foo');''');
|
| +var v = const A.a1(0);''');
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
|
| - StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
|
| + assertErrors(
|
| + source,
|
| + [CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]);
|
| verify([source]);
|
| }
|
|
|
| @@ -940,26 +1114,29 @@ var v = const A<int>('foo');''');
|
| // unresolved.
|
| Source source = addSource("const Unresolved x = null;");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
|
|
| void test_topLevelVarNotAssignable() {
|
| Source source = addSource("const int x = 'foo';");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
|
| - StaticTypeWarningCode.INVALID_ASSIGNMENT]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
|
| + StaticTypeWarningCode.INVALID_ASSIGNMENT]);
|
| verify([source]);
|
| }
|
|
|
| void test_topLevelVarNotAssignable_undefined() {
|
| Source source = addSource("const Unresolved x = 'foo';");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
|
| - StaticWarningCode.UNDEFINED_CLASS]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
|
| + StaticWarningCode.UNDEFINED_CLASS]);
|
| verify([source]);
|
| }
|
| }
|
| @@ -1057,7 +1234,8 @@ class C {
|
| _assertMethodMatches(true, content, content);
|
| }
|
|
|
| - void _assertCompilationUnitMatches(bool expectMatch, String oldContent, String newContent) {
|
| + void _assertCompilationUnitMatches(bool expectMatch, String oldContent,
|
| + String newContent) {
|
| Source source = addSource(oldContent);
|
| LibraryElement library = resolve(source);
|
| CompilationUnit oldUnit = resolveCompilationUnit(source, library);
|
| @@ -1066,7 +1244,8 @@ class C {
|
| expect(matcher.matches(newUnit, oldUnit.element), expectMatch);
|
| }
|
|
|
| - void _assertMethodMatches(bool expectMatch, String oldContent, String newContent) {
|
| + void _assertMethodMatches(bool expectMatch, String oldContent,
|
| + String newContent) {
|
| Source source = addSource(oldContent);
|
| LibraryElement library = resolve(source);
|
| CompilationUnit oldUnit = resolveCompilationUnit(source, library);
|
| @@ -1085,31 +1264,6 @@ class C {
|
| }
|
| }
|
|
|
| -class DirectoryBasedDartSdk_AnalysisContextFactory_initContextWithCore extends DirectoryBasedDartSdk {
|
| - DirectoryBasedDartSdk_AnalysisContextFactory_initContextWithCore(JavaFile arg0) : super(arg0);
|
| -
|
| - @override
|
| - LibraryMap initialLibraryMap(bool useDart2jsPaths) {
|
| - LibraryMap map = new LibraryMap();
|
| - _addLibrary(map, DartSdk.DART_ASYNC, false, "async.dart");
|
| - _addLibrary(map, DartSdk.DART_CORE, false, "core.dart");
|
| - _addLibrary(map, DartSdk.DART_HTML, false, "html_dartium.dart");
|
| - _addLibrary(map, AnalysisContextFactory._DART_MATH, false, "math.dart");
|
| - _addLibrary(map, AnalysisContextFactory._DART_INTERCEPTORS, true, "_interceptors.dart");
|
| - _addLibrary(map, AnalysisContextFactory._DART_JS_HELPER, true, "_js_helper.dart");
|
| - return map;
|
| - }
|
| -
|
| - void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) {
|
| - SdkLibraryImpl library = new SdkLibraryImpl(uri);
|
| - if (isInternal) {
|
| - library.category = "Internal";
|
| - }
|
| - library.path = path;
|
| - map.setLibrary(uri, library);
|
| - }
|
| -}
|
| -
|
| class ElementResolverTest extends EngineTestCase {
|
| /**
|
| * The error listener to which errors will be reported.
|
| @@ -1138,8 +1292,10 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void fail_visitExportDirective_combinators() {
|
| 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"])]);
|
| + // Need to set up the exported library so that the identifier can be
|
| + // resolved.
|
| + ExportDirective directive =
|
| + AstFactory.exportDirective2(null, [AstFactory.hideCombinator2(["A"])]);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1151,20 +1307,25 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void fail_visitImportDirective_combinators_noPrefix() {
|
| 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"])]);
|
| + // Need to set up the imported library so that the identifier can be
|
| + // resolved.
|
| + ImportDirective directive =
|
| + AstFactory.importDirective3(null, null, [AstFactory.showCombinator2(["A"])]);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void fail_visitImportDirective_combinators_prefix() {
|
| fail("Not yet tested");
|
| - // Need to set up the imported library so that the identifiers can be resolved
|
| + // Need to set up the imported library so that the identifiers can be
|
| + // resolved.
|
| String prefixName = "p";
|
| - _definingLibrary.imports = <ImportElement> [ElementFactory.importFor(null, ElementFactory.prefix(prefixName))];
|
| - ImportDirective directive = AstFactory.importDirective3(null, prefixName, [
|
| - AstFactory.showCombinator2(["A"]),
|
| - AstFactory.hideCombinator2(["B"])]);
|
| + _definingLibrary.imports = <ImportElement>[
|
| + ElementFactory.importFor(null, ElementFactory.prefix(prefixName))];
|
| + ImportDirective directive = AstFactory.importDirective3(
|
| + null,
|
| + prefixName,
|
| + [AstFactory.showCombinator2(["A"]), AstFactory.hideCombinator2(["B"])]);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1187,18 +1348,19 @@ class ElementResolverTest extends EngineTestCase {
|
| // abstract class A { int operator[](int index); }
|
| //
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - MethodElement operator = ElementFactory.methodElement("[]", intType, [intType]);
|
| - classA.methods = <MethodElement> [operator];
|
| + MethodElement operator =
|
| + ElementFactory.methodElement("[]", intType, [intType]);
|
| + classA.methods = <MethodElement>[operator];
|
| //
|
| // class B implements A {}
|
| //
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| //
|
| // class C extends Object with B {}
|
| //
|
| ClassElementImpl classC = ElementFactory.classElement2("C");
|
| - classC.mixins = <InterfaceType> [classB.type];
|
| + classC.mixins = <InterfaceType>[classB.type];
|
| //
|
| // class D extends C {}
|
| //
|
| @@ -1209,7 +1371,8 @@ class ElementResolverTest extends EngineTestCase {
|
| //
|
| SimpleIdentifier array = AstFactory.identifier3("a");
|
| array.staticType = classD.type;
|
| - IndexExpression expression = AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| + IndexExpression expression =
|
| + AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| expect(_resolveIndexExpression(expression), same(operator));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1218,14 +1381,22 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType intType = _typeProvider.intType;
|
| SimpleIdentifier leftHandSide = AstFactory.identifier3("a");
|
| leftHandSide.staticType = intType;
|
| - AssignmentExpression assignment = AstFactory.assignmentExpression(leftHandSide, TokenType.PLUS_EQ, AstFactory.integer(1));
|
| + AssignmentExpression assignment = AstFactory.assignmentExpression(
|
| + leftHandSide,
|
| + TokenType.PLUS_EQ,
|
| + AstFactory.integer(1));
|
| _resolveNode(assignment);
|
| - expect(assignment.staticElement, same(getMethod(_typeProvider.numType, "+")));
|
| + expect(
|
| + assignment.staticElement,
|
| + same(getMethod(_typeProvider.numType, "+")));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitAssignmentExpression_simple() {
|
| - AssignmentExpression expression = AstFactory.assignmentExpression(AstFactory.identifier3("x"), TokenType.EQ, AstFactory.integer(0));
|
| + AssignmentExpression expression = AstFactory.assignmentExpression(
|
| + AstFactory.identifier3("x"),
|
| + TokenType.EQ,
|
| + AstFactory.integer(0));
|
| _resolveNode(expression);
|
| expect(expression.staticElement, isNull);
|
| _listener.assertNoErrors();
|
| @@ -1238,7 +1409,8 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType numType = _typeProvider.numType;
|
| SimpleIdentifier left = AstFactory.identifier3("i");
|
| left.staticType = numType;
|
| - BinaryExpression expression = AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3("j"));
|
| + BinaryExpression expression =
|
| + AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3("j"));
|
| _resolveNode(expression);
|
| expect(expression.staticElement, getMethod(numType, "+"));
|
| expect(expression.propagatedElement, isNull);
|
| @@ -1252,7 +1424,8 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType numType = _typeProvider.numType;
|
| SimpleIdentifier left = AstFactory.identifier3("i");
|
| left.propagatedType = numType;
|
| - BinaryExpression expression = AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3("j"));
|
| + BinaryExpression expression =
|
| + AstFactory.binaryExpression(left, TokenType.PLUS, AstFactory.identifier3("j"));
|
| _resolveNode(expression);
|
| expect(expression.staticElement, isNull);
|
| expect(expression.propagatedElement, getMethod(numType, "+"));
|
| @@ -1261,7 +1434,8 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitBreakStatement_withLabel() {
|
| String label = "loop";
|
| - LabelElementImpl labelElement = new LabelElementImpl(AstFactory.identifier3(label), false, false);
|
| + LabelElementImpl labelElement =
|
| + new LabelElementImpl(AstFactory.identifier3(label), false, false);
|
| BreakStatement statement = AstFactory.breakStatement2(label);
|
| expect(_resolveBreak(statement, labelElement), same(labelElement));
|
| _listener.assertNoErrors();
|
| @@ -1276,9 +1450,11 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitConstructorName_named() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String constructorName = "a";
|
| - ConstructorElement constructor = ElementFactory.constructorElement2(classA, constructorName);
|
| - classA.constructors = <ConstructorElement> [constructor];
|
| - ConstructorName name = AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| + ConstructorElement constructor =
|
| + ElementFactory.constructorElement2(classA, constructorName);
|
| + classA.constructors = <ConstructorElement>[constructor];
|
| + ConstructorName name =
|
| + AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| _resolveNode(name);
|
| expect(name.staticElement, same(constructor));
|
| _listener.assertNoErrors();
|
| @@ -1287,9 +1463,11 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitConstructorName_unnamed() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String constructorName = null;
|
| - ConstructorElement constructor = ElementFactory.constructorElement2(classA, constructorName);
|
| - classA.constructors = <ConstructorElement> [constructor];
|
| - ConstructorName name = AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| + ConstructorElement constructor =
|
| + ElementFactory.constructorElement2(classA, constructorName);
|
| + classA.constructors = <ConstructorElement>[constructor];
|
| + ConstructorName name =
|
| + AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| _resolveNode(name);
|
| expect(name.staticElement, same(constructor));
|
| _listener.assertNoErrors();
|
| @@ -1297,7 +1475,8 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitContinueStatement_withLabel() {
|
| String label = "loop";
|
| - LabelElementImpl labelElement = new LabelElementImpl(AstFactory.identifier3(label), false, false);
|
| + LabelElementImpl labelElement =
|
| + new LabelElementImpl(AstFactory.identifier3(label), false, false);
|
| ContinueStatement statement = AstFactory.continueStatement(label);
|
| expect(_resolveContinue(statement, labelElement), same(labelElement));
|
| _listener.assertNoErrors();
|
| @@ -1311,7 +1490,8 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitExportDirective_noCombinators() {
|
| ExportDirective directive = AstFactory.exportDirective2(null);
|
| - directive.element = ElementFactory.exportFor(ElementFactory.library(_definingLibrary.context, "lib"));
|
| + directive.element = ElementFactory.exportFor(
|
| + ElementFactory.library(_definingLibrary.context, "lib"));
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1319,11 +1499,14 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitFieldFormalParameter() {
|
| String fieldName = "f";
|
| InterfaceType intType = _typeProvider.intType;
|
| - FieldElementImpl fieldElement = ElementFactory.fieldElement(fieldName, false, false, false, intType);
|
| + FieldElementImpl fieldElement =
|
| + ElementFactory.fieldElement(fieldName, false, false, false, intType);
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.fields = <FieldElement> [fieldElement];
|
| - FieldFormalParameter parameter = AstFactory.fieldFormalParameter2(fieldName);
|
| - FieldFormalParameterElementImpl parameterElement = ElementFactory.fieldFormalParameter(parameter.identifier);
|
| + classA.fields = <FieldElement>[fieldElement];
|
| + FieldFormalParameter parameter =
|
| + AstFactory.fieldFormalParameter2(fieldName);
|
| + FieldFormalParameterElementImpl parameterElement =
|
| + ElementFactory.fieldFormalParameter(parameter.identifier);
|
| parameterElement.field = fieldElement;
|
| parameterElement.type = intType;
|
| parameter.identifier.staticElement = parameterElement;
|
| @@ -1333,15 +1516,19 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitImportDirective_noCombinators_noPrefix() {
|
| ImportDirective directive = AstFactory.importDirective3(null, null);
|
| - directive.element = ElementFactory.importFor(ElementFactory.library(_definingLibrary.context, "lib"), null);
|
| + directive.element = ElementFactory.importFor(
|
| + ElementFactory.library(_definingLibrary.context, "lib"),
|
| + null);
|
| _resolveNode(directive);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitImportDirective_noCombinators_prefix() {
|
| String prefixName = "p";
|
| - ImportElement importElement = ElementFactory.importFor(ElementFactory.library(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName));
|
| - _definingLibrary.imports = <ImportElement> [importElement];
|
| + ImportElement importElement = ElementFactory.importFor(
|
| + ElementFactory.library(_definingLibrary.context, "lib"),
|
| + ElementFactory.prefix(prefixName));
|
| + _definingLibrary.imports = <ImportElement>[importElement];
|
| ImportDirective directive = AstFactory.importDirective3(null, prefixName);
|
| directive.element = importElement;
|
| _resolveNode(directive);
|
| @@ -1350,14 +1537,21 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitImportDirective_withCombinators() {
|
| ShowCombinator combinator = AstFactory.showCombinator2(["A", "B", "C"]);
|
| - ImportDirective directive = AstFactory.importDirective3(null, null, [combinator]);
|
| - LibraryElementImpl library = ElementFactory.library(_definingLibrary.context, "lib");
|
| - TopLevelVariableElementImpl varA = ElementFactory.topLevelVariableElement2("A");
|
| - TopLevelVariableElementImpl varB = ElementFactory.topLevelVariableElement2("B");
|
| - TopLevelVariableElementImpl varC = ElementFactory.topLevelVariableElement2("C");
|
| - CompilationUnitElementImpl unit = library.definingCompilationUnit as CompilationUnitElementImpl;
|
| - unit.accessors = <PropertyAccessorElement> [varA.getter, varA.setter, varB.getter, varC.setter];
|
| - unit.topLevelVariables = <TopLevelVariableElement> [varA, varB, varC];
|
| + ImportDirective directive =
|
| + AstFactory.importDirective3(null, null, [combinator]);
|
| + LibraryElementImpl library =
|
| + ElementFactory.library(_definingLibrary.context, "lib");
|
| + TopLevelVariableElementImpl varA =
|
| + ElementFactory.topLevelVariableElement2("A");
|
| + TopLevelVariableElementImpl varB =
|
| + ElementFactory.topLevelVariableElement2("B");
|
| + TopLevelVariableElementImpl varC =
|
| + ElementFactory.topLevelVariableElement2("C");
|
| + CompilationUnitElementImpl unit =
|
| + library.definingCompilationUnit as CompilationUnitElementImpl;
|
| + unit.accessors =
|
| + <PropertyAccessorElement>[varA.getter, varA.setter, varB.getter, varC.setter];
|
| + unit.topLevelVariables = <TopLevelVariableElement>[varA, varB, varC];
|
| directive.element = ElementFactory.importFor(library, null);
|
| _resolveNode(directive);
|
| expect(combinator.shownNames[0].staticElement, same(varA));
|
| @@ -1369,11 +1563,13 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitIndexExpression_get() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| InterfaceType intType = _typeProvider.intType;
|
| - MethodElement getter = ElementFactory.methodElement("[]", intType, [intType]);
|
| - classA.methods = <MethodElement> [getter];
|
| + MethodElement getter =
|
| + ElementFactory.methodElement("[]", intType, [intType]);
|
| + classA.methods = <MethodElement>[getter];
|
| SimpleIdentifier array = AstFactory.identifier3("a");
|
| array.staticType = classA.type;
|
| - IndexExpression expression = AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| + IndexExpression expression =
|
| + AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| expect(_resolveIndexExpression(expression), same(getter));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1381,12 +1577,17 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitIndexExpression_set() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| InterfaceType intType = _typeProvider.intType;
|
| - MethodElement setter = ElementFactory.methodElement("[]=", intType, [intType]);
|
| - classA.methods = <MethodElement> [setter];
|
| + MethodElement setter =
|
| + ElementFactory.methodElement("[]=", intType, [intType]);
|
| + classA.methods = <MethodElement>[setter];
|
| SimpleIdentifier array = AstFactory.identifier3("a");
|
| array.staticType = classA.type;
|
| - IndexExpression expression = AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| - AstFactory.assignmentExpression(expression, TokenType.EQ, AstFactory.integer(0));
|
| + IndexExpression expression =
|
| + AstFactory.indexExpression(array, AstFactory.identifier3("i"));
|
| + AstFactory.assignmentExpression(
|
| + expression,
|
| + TokenType.EQ,
|
| + AstFactory.integer(0));
|
| expect(_resolveIndexExpression(expression), same(setter));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -1394,11 +1595,14 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitInstanceCreationExpression_named() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String constructorName = "a";
|
| - ConstructorElement constructor = ElementFactory.constructorElement2(classA, constructorName);
|
| - classA.constructors = <ConstructorElement> [constructor];
|
| - ConstructorName name = AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| + ConstructorElement constructor =
|
| + ElementFactory.constructorElement2(classA, constructorName);
|
| + classA.constructors = <ConstructorElement>[constructor];
|
| + ConstructorName name =
|
| + AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| name.staticElement = constructor;
|
| - InstanceCreationExpression creation = AstFactory.instanceCreationExpression(Keyword.NEW, name);
|
| + InstanceCreationExpression creation =
|
| + AstFactory.instanceCreationExpression(Keyword.NEW, name);
|
| _resolveNode(creation);
|
| expect(creation.staticElement, same(constructor));
|
| _listener.assertNoErrors();
|
| @@ -1407,11 +1611,14 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitInstanceCreationExpression_unnamed() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String constructorName = null;
|
| - ConstructorElement constructor = ElementFactory.constructorElement2(classA, constructorName);
|
| - classA.constructors = <ConstructorElement> [constructor];
|
| - ConstructorName name = AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| + ConstructorElement constructor =
|
| + ElementFactory.constructorElement2(classA, constructorName);
|
| + classA.constructors = <ConstructorElement>[constructor];
|
| + ConstructorName name =
|
| + AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| name.staticElement = constructor;
|
| - InstanceCreationExpression creation = AstFactory.instanceCreationExpression(Keyword.NEW, name);
|
| + InstanceCreationExpression creation =
|
| + AstFactory.instanceCreationExpression(Keyword.NEW, name);
|
| _resolveNode(creation);
|
| expect(creation.staticElement, same(constructor));
|
| _listener.assertNoErrors();
|
| @@ -1420,17 +1627,25 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitInstanceCreationExpression_unnamed_namedParameter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String constructorName = null;
|
| - ConstructorElementImpl constructor = ElementFactory.constructorElement2(classA, constructorName);
|
| + ConstructorElementImpl constructor =
|
| + ElementFactory.constructorElement2(classA, constructorName);
|
| String parameterName = "a";
|
| ParameterElement parameter = ElementFactory.namedParameter(parameterName);
|
| - constructor.parameters = <ParameterElement> [parameter];
|
| - classA.constructors = <ConstructorElement> [constructor];
|
| - ConstructorName name = AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| + constructor.parameters = <ParameterElement>[parameter];
|
| + classA.constructors = <ConstructorElement>[constructor];
|
| + ConstructorName name =
|
| + AstFactory.constructorName(AstFactory.typeName(classA), constructorName);
|
| name.staticElement = constructor;
|
| - InstanceCreationExpression creation = AstFactory.instanceCreationExpression(Keyword.NEW, name, [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| + InstanceCreationExpression creation = AstFactory.instanceCreationExpression(
|
| + 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();
|
| }
|
|
|
| @@ -1441,7 +1656,9 @@ class ElementResolverTest extends EngineTestCase {
|
| String methodName = "abs";
|
| MethodInvocation invocation = AstFactory.methodInvocation(left, methodName);
|
| _resolveNode(invocation);
|
| - expect(invocation.methodName.staticElement, same(getMethod(numType, methodName)));
|
| + expect(
|
| + invocation.methodName.staticElement,
|
| + same(getMethod(numType, methodName)));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -1451,14 +1668,20 @@ class ElementResolverTest extends EngineTestCase {
|
| String parameterName = "p";
|
| MethodElementImpl method = ElementFactory.methodElement(methodName, null);
|
| ParameterElement parameter = ElementFactory.namedParameter(parameterName);
|
| - method.parameters = <ParameterElement> [parameter];
|
| - classA.methods = <MethodElement> [method];
|
| + method.parameters = <ParameterElement>[parameter];
|
| + classA.methods = <MethodElement>[method];
|
| SimpleIdentifier left = AstFactory.identifier3("i");
|
| left.staticType = classA.type;
|
| - MethodInvocation invocation = AstFactory.methodInvocation(left, methodName, [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| + MethodInvocation invocation = AstFactory.methodInvocation(
|
| + left,
|
| + methodName,
|
| + [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();
|
| }
|
|
|
| @@ -1466,7 +1689,8 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType numType = _typeProvider.numType;
|
| SimpleIdentifier operand = AstFactory.identifier3("i");
|
| operand.staticType = numType;
|
| - PostfixExpression expression = AstFactory.postfixExpression(operand, TokenType.PLUS_PLUS);
|
| + PostfixExpression expression =
|
| + AstFactory.postfixExpression(operand, TokenType.PLUS_PLUS);
|
| _resolveNode(expression);
|
| expect(expression.staticElement, getMethod(numType, "+"));
|
| _listener.assertNoErrors();
|
| @@ -1479,7 +1703,8 @@ class ElementResolverTest extends EngineTestCase {
|
| variable.type = dynamicType;
|
| target.staticElement = variable;
|
| target.staticType = dynamicType;
|
| - PrefixedIdentifier identifier = AstFactory.identifier(target, AstFactory.identifier3("b"));
|
| + PrefixedIdentifier identifier =
|
| + AstFactory.identifier(target, AstFactory.identifier3("b"));
|
| _resolveNode(identifier);
|
| expect(identifier.staticElement, isNull);
|
| expect(identifier.identifier.staticElement, isNull);
|
| @@ -1489,14 +1714,16 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitPrefixedIdentifier_nonDynamic() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "b";
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getter];
|
| SimpleIdentifier target = AstFactory.identifier3("a");
|
| VariableElementImpl variable = ElementFactory.localVariableElement(target);
|
| variable.type = classA.type;
|
| target.staticElement = variable;
|
| target.staticType = classA.type;
|
| - PrefixedIdentifier identifier = AstFactory.identifier(target, AstFactory.identifier3(getterName));
|
| + PrefixedIdentifier identifier =
|
| + AstFactory.identifier(target, AstFactory.identifier3(getterName));
|
| _resolveNode(identifier);
|
| expect(identifier.staticElement, same(getter));
|
| expect(identifier.identifier.staticElement, same(getter));
|
| @@ -1507,14 +1734,17 @@ class ElementResolverTest extends EngineTestCase {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| // set accessors
|
| String propName = "b";
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(propName, false, _typeProvider.intType);
|
| - PropertyAccessorElement setter = ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getter, setter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(propName, false, _typeProvider.intType);
|
| + PropertyAccessorElement setter =
|
| + ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getter, setter];
|
| // prepare "A.m"
|
| SimpleIdentifier target = AstFactory.identifier3("A");
|
| target.staticElement = classA;
|
| target.staticType = classA.type;
|
| - PrefixedIdentifier identifier = AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| + PrefixedIdentifier identifier =
|
| + AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| // resolve
|
| _resolveNode(identifier);
|
| expect(identifier.staticElement, same(getter));
|
| @@ -1526,17 +1756,23 @@ class ElementResolverTest extends EngineTestCase {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| // set accessors
|
| String propName = "m";
|
| - PropertyAccessorElement setter = ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setter];
|
| + PropertyAccessorElement setter =
|
| + ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setter];
|
| // set methods
|
| - MethodElement method = ElementFactory.methodElement("m", _typeProvider.intType);
|
| - classA.methods = <MethodElement> [method];
|
| + MethodElement method =
|
| + ElementFactory.methodElement("m", _typeProvider.intType);
|
| + classA.methods = <MethodElement>[method];
|
| // prepare "A.m"
|
| SimpleIdentifier target = AstFactory.identifier3("A");
|
| target.staticElement = classA;
|
| target.staticType = classA.type;
|
| - PrefixedIdentifier identifier = AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| - AstFactory.assignmentExpression(identifier, TokenType.EQ, AstFactory.nullLiteral());
|
| + PrefixedIdentifier identifier =
|
| + AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| + AstFactory.assignmentExpression(
|
| + identifier,
|
| + TokenType.EQ,
|
| + AstFactory.nullLiteral());
|
| // resolve
|
| _resolveNode(identifier);
|
| expect(identifier.staticElement, same(method));
|
| @@ -1548,15 +1784,21 @@ class ElementResolverTest extends EngineTestCase {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| // set accessors
|
| String propName = "b";
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(propName, false, _typeProvider.intType);
|
| - PropertyAccessorElement setter = ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getter, setter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(propName, false, _typeProvider.intType);
|
| + PropertyAccessorElement setter =
|
| + ElementFactory.setterElement(propName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getter, setter];
|
| // prepare "A.b = null"
|
| SimpleIdentifier target = AstFactory.identifier3("A");
|
| target.staticElement = classA;
|
| target.staticType = classA.type;
|
| - PrefixedIdentifier identifier = AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| - AstFactory.assignmentExpression(identifier, TokenType.EQ, AstFactory.nullLiteral());
|
| + PrefixedIdentifier identifier =
|
| + AstFactory.identifier(target, AstFactory.identifier3(propName));
|
| + AstFactory.assignmentExpression(
|
| + identifier,
|
| + TokenType.EQ,
|
| + AstFactory.nullLiteral());
|
| // resolve
|
| _resolveNode(identifier);
|
| expect(identifier.staticElement, same(setter));
|
| @@ -1568,7 +1810,8 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType numType = _typeProvider.numType;
|
| SimpleIdentifier operand = AstFactory.identifier3("i");
|
| operand.staticType = numType;
|
| - PrefixExpression expression = AstFactory.prefixExpression(TokenType.PLUS_PLUS, operand);
|
| + PrefixExpression expression =
|
| + AstFactory.prefixExpression(TokenType.PLUS_PLUS, operand);
|
| _resolveNode(expression);
|
| expect(expression.staticElement, getMethod(numType, "+"));
|
| _listener.assertNoErrors();
|
| @@ -1577,8 +1820,9 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitPropertyAccess_getter_identifier() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "b";
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getter];
|
| SimpleIdentifier target = AstFactory.identifier3("a");
|
| target.staticType = classA.type;
|
| PropertyAccess access = AstFactory.propertyAccess2(target, getterName);
|
| @@ -1598,12 +1842,20 @@ class ElementResolverTest extends EngineTestCase {
|
| //
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "b";
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getter];
|
| 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.expressionFunctionBody(access));
|
| + AstFactory.methodDeclaration2(
|
| + null,
|
| + null,
|
| + null,
|
| + null,
|
| + AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList(),
|
| + AstFactory.expressionFunctionBody(access));
|
| _resolveNode(access);
|
| expect(access.propertyName.staticElement, same(getter));
|
| _listener.assertNoErrors();
|
| @@ -1612,12 +1864,16 @@ class ElementResolverTest extends EngineTestCase {
|
| void test_visitPropertyAccess_setter_this() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "b";
|
| - PropertyAccessorElement setter = ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setter];
|
| + PropertyAccessorElement setter =
|
| + ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setter];
|
| ThisExpression target = AstFactory.thisExpression();
|
| target.staticType = classA.type;
|
| PropertyAccess access = AstFactory.propertyAccess2(target, setterName);
|
| - AstFactory.assignmentExpression(access, TokenType.EQ, AstFactory.integer(0));
|
| + AstFactory.assignmentExpression(
|
| + access,
|
| + TokenType.EQ,
|
| + AstFactory.integer(0));
|
| _resolveNode(access);
|
| expect(access.propertyName.staticElement, same(setter));
|
| _listener.assertNoErrors();
|
| @@ -1651,26 +1907,34 @@ class ElementResolverTest extends EngineTestCase {
|
| InterfaceType intType = _typeProvider.intType;
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String fieldName = "a";
|
| - FieldElement field = ElementFactory.fieldElement(fieldName, false, false, false, intType);
|
| - classA.fields = <FieldElement> [field];
|
| - classA.accessors = <PropertyAccessorElement> [field.getter, field.setter];
|
| + FieldElement field =
|
| + ElementFactory.fieldElement(fieldName, false, false, false, intType);
|
| + classA.fields = <FieldElement>[field];
|
| + classA.accessors = <PropertyAccessorElement>[field.getter, field.setter];
|
| SimpleIdentifier node = AstFactory.identifier3(fieldName);
|
| AstFactory.assignmentExpression(node, TokenType.EQ, AstFactory.integer(0));
|
| _resolveInClass(node, classA);
|
| Element element = node.staticElement;
|
| - EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, PropertyAccessorElement, element);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is PropertyAccessorElement,
|
| + PropertyAccessorElement,
|
| + element);
|
| expect((element as PropertyAccessorElement).isSetter, isTrue);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitSuperConstructorInvocation() {
|
| ClassElementImpl superclass = ElementFactory.classElement2("A");
|
| - ConstructorElementImpl superConstructor = ElementFactory.constructorElement2(superclass, null);
|
| - superclass.constructors = <ConstructorElement> [superConstructor];
|
| - ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type);
|
| - ConstructorElementImpl subConstructor = ElementFactory.constructorElement2(subclass, null);
|
| - subclass.constructors = <ConstructorElement> [subConstructor];
|
| - SuperConstructorInvocation invocation = AstFactory.superConstructorInvocation();
|
| + ConstructorElementImpl superConstructor =
|
| + ElementFactory.constructorElement2(superclass, null);
|
| + superclass.constructors = <ConstructorElement>[superConstructor];
|
| + ClassElementImpl subclass =
|
| + ElementFactory.classElement("B", superclass.type);
|
| + ConstructorElementImpl subConstructor =
|
| + ElementFactory.constructorElement2(subclass, null);
|
| + subclass.constructors = <ConstructorElement>[subConstructor];
|
| + SuperConstructorInvocation invocation =
|
| + AstFactory.superConstructorInvocation();
|
| _resolveInClass(invocation, subclass);
|
| expect(invocation.staticElement, superConstructor);
|
| _listener.assertNoErrors();
|
| @@ -1678,18 +1942,26 @@ class ElementResolverTest extends EngineTestCase {
|
|
|
| void test_visitSuperConstructorInvocation_namedParameter() {
|
| ClassElementImpl superclass = ElementFactory.classElement2("A");
|
| - ConstructorElementImpl superConstructor = ElementFactory.constructorElement2(superclass, null);
|
| + ConstructorElementImpl superConstructor =
|
| + ElementFactory.constructorElement2(superclass, null);
|
| String parameterName = "p";
|
| ParameterElement parameter = ElementFactory.namedParameter(parameterName);
|
| - superConstructor.parameters = <ParameterElement> [parameter];
|
| - superclass.constructors = <ConstructorElement> [superConstructor];
|
| - ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type);
|
| - ConstructorElementImpl subConstructor = ElementFactory.constructorElement2(subclass, null);
|
| - subclass.constructors = <ConstructorElement> [subConstructor];
|
| - SuperConstructorInvocation invocation = AstFactory.superConstructorInvocation([AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| + superConstructor.parameters = <ParameterElement>[parameter];
|
| + superclass.constructors = <ConstructorElement>[superConstructor];
|
| + ClassElementImpl subclass =
|
| + ElementFactory.classElement("B", superclass.type);
|
| + ConstructorElementImpl subConstructor =
|
| + ElementFactory.constructorElement2(subclass, null);
|
| + subclass.constructors = <ConstructorElement>[subConstructor];
|
| + SuperConstructorInvocation invocation =
|
| + AstFactory.superConstructorInvocation(
|
| + [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]);
|
| _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();
|
| }
|
|
|
| @@ -1700,10 +1972,13 @@ class ElementResolverTest extends EngineTestCase {
|
| */
|
| ElementResolver _createResolver() {
|
| AnalysisContextImpl context = new AnalysisContextImpl();
|
| - SourceFactory sourceFactory = new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
| + SourceFactory sourceFactory =
|
| + new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
| context.sourceFactory = sourceFactory;
|
| - FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| - CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
|
| + FileBasedSource source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| + CompilationUnitElementImpl definingCompilationUnit =
|
| + new CompilationUnitElementImpl("test.dart");
|
| definingCompilationUnit.source = source;
|
| _definingLibrary = ElementFactory.library(context, "test");
|
| _definingLibrary.definingCompilationUnit = definingCompilationUnit;
|
| @@ -1713,7 +1988,9 @@ class ElementResolverTest extends EngineTestCase {
|
| try {
|
| return _visitor.elementResolver_J2DAccessor as ElementResolver;
|
| } catch (exception) {
|
| - throw new IllegalArgumentException("Could not create resolver", exception);
|
| + throw new IllegalArgumentException(
|
| + "Could not create resolver",
|
| + exception);
|
| }
|
| }
|
|
|
| @@ -1725,7 +2002,8 @@ class ElementResolverTest extends EngineTestCase {
|
| * @param labelElement the label element to be defined in the statement's label scope
|
| * @return the element to which the statement's label was resolved
|
| */
|
| - Element _resolveBreak(BreakStatement statement, LabelElementImpl labelElement) {
|
| + Element _resolveBreak(BreakStatement statement,
|
| + LabelElementImpl labelElement) {
|
| _resolveStatement(statement, labelElement);
|
| return statement.label.staticElement;
|
| }
|
| @@ -1738,7 +2016,8 @@ class ElementResolverTest extends EngineTestCase {
|
| * @param labelElement the label element to be defined in the statement's label scope
|
| * @return the element to which the statement's label was resolved
|
| */
|
| - Element _resolveContinue(ContinueStatement statement, LabelElementImpl labelElement) {
|
| + Element _resolveContinue(ContinueStatement statement,
|
| + LabelElementImpl labelElement) {
|
| _resolveStatement(statement, labelElement);
|
| return statement.label.staticElement;
|
| }
|
| @@ -1770,7 +2049,9 @@ class ElementResolverTest extends EngineTestCase {
|
| Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
|
| try {
|
| _visitor.enclosingClass_J2DAccessor = enclosingClass;
|
| - EnclosedScope innerScope = new ClassScope(new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
|
| + EnclosedScope innerScope = new ClassScope(
|
| + new TypeParameterScope(outerScope, enclosingClass),
|
| + enclosingClass);
|
| _visitor.nameScope_J2DAccessor = innerScope;
|
| node.accept(_resolver);
|
| } finally {
|
| @@ -1791,7 +2072,8 @@ class ElementResolverTest extends EngineTestCase {
|
| * being resolved
|
| * @return the element to which the expression was resolved
|
| */
|
| - Element _resolveIndexExpression(IndexExpression node, [List<Element> definedElements]) {
|
| + Element _resolveIndexExpression(IndexExpression node,
|
| + [List<Element> definedElements]) {
|
| _resolveNode(node, definedElements);
|
| return node.staticElement;
|
| }
|
| @@ -1841,7 +2123,8 @@ class ElementResolverTest extends EngineTestCase {
|
| if (labelElement == null) {
|
| innerScope = new LabelScope.con1(outerScope, false, false);
|
| } else {
|
| - innerScope = new LabelScope.con2(outerScope, labelElement.name, labelElement);
|
| + innerScope =
|
| + new LabelScope.con2(outerScope, labelElement.name, labelElement);
|
| }
|
| _visitor.labelScope_J2DAccessor = innerScope;
|
| statement.accept(_resolver);
|
| @@ -1857,10 +2140,13 @@ class ElementResolverTest extends EngineTestCase {
|
| class EnclosedScopeTest extends ResolverTestCase {
|
| void test_define_duplicate() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope rootScope = new Scope_EnclosedScopeTest_test_define_duplicate(listener);
|
| + Scope rootScope =
|
| + new Scope_EnclosedScopeTest_test_define_duplicate(listener);
|
| EnclosedScope scope = new EnclosedScope(rootScope);
|
| - VariableElement element1 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| - VariableElement element2 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element1 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element2 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| scope.define(element1);
|
| scope.define(element2);
|
| listener.assertErrorsWithSeverities([ErrorSeverity.ERROR]);
|
| @@ -1871,8 +2157,10 @@ class EnclosedScopeTest extends ResolverTestCase {
|
| Scope rootScope = new Scope_EnclosedScopeTest_test_define_normal(listener);
|
| EnclosedScope outerScope = new EnclosedScope(rootScope);
|
| EnclosedScope innerScope = new EnclosedScope(outerScope);
|
| - VariableElement element1 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| - VariableElement element2 = ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
|
| + VariableElement element1 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element2 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
|
| outerScope.define(element1);
|
| innerScope.define(element2);
|
| listener.assertNoErrors();
|
| @@ -2030,7 +2318,9 @@ class A {
|
| void test_argumentTypeNotAssignable_message() {
|
| // The implementation of HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE assumes that
|
| // StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE has the same message.
|
| - expect(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message, HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message);
|
| + expect(
|
| + StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message,
|
| + HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE.message);
|
| }
|
|
|
| void test_argumentTypeNotAssignable_type() {
|
| @@ -2722,7 +3012,9 @@ A a;''');
|
| library lib1;
|
| class A {}''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]);
|
| + assertErrors(
|
| + source,
|
| + [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]);
|
| verify([source]);
|
| }
|
|
|
| @@ -2742,15 +3034,15 @@ class B {}''');
|
| }
|
|
|
| void test_importDeferredLibraryWithLoadFunction() {
|
| - resolveWithAndWithoutExperimental(<String> [
|
| - r'''
|
| + resolveWithAndWithoutExperimental(<String>[r'''
|
| library lib1;
|
| loadLibrary() {}
|
| -f() {}''',
|
| - r'''
|
| +f() {}''', r'''
|
| library root;
|
| import 'lib1.dart' deferred as lib1;
|
| -main() { lib1.f(); }'''], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode> [HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION]);
|
| +main() { lib1.f(); }'''],
|
| + <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
|
| + <ErrorCode>[HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION]);
|
| }
|
|
|
| void test_invalidAssignment_instanceVariable() {
|
| @@ -2784,7 +3076,9 @@ f(var y) {
|
| void test_invalidAssignment_message() {
|
| // The implementation of HintCode.INVALID_ASSIGNMENT assumes that
|
| // StaticTypeWarningCode.INVALID_ASSIGNMENT has the same message.
|
| - expect(StaticTypeWarningCode.INVALID_ASSIGNMENT.message, HintCode.INVALID_ASSIGNMENT.message);
|
| + expect(
|
| + StaticTypeWarningCode.INVALID_ASSIGNMENT.message,
|
| + HintCode.INVALID_ASSIGNMENT.message);
|
| }
|
|
|
| void test_invalidAssignment_staticVariable() {
|
| @@ -2931,9 +3225,12 @@ f(var a) {
|
| }
|
|
|
| void test_undefinedGetter_message() {
|
| - // The implementation of HintCode.UNDEFINED_SETTER assumes that UNDEFINED_SETTER in
|
| - // StaticTypeWarningCode and StaticWarningCode are the same, this verifies that assumption.
|
| - expect(StaticWarningCode.UNDEFINED_GETTER.message, StaticTypeWarningCode.UNDEFINED_GETTER.message);
|
| + // The implementation of HintCode.UNDEFINED_SETTER assumes that
|
| + // UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the
|
| + // same, this verifies that assumption.
|
| + expect(
|
| + StaticWarningCode.UNDEFINED_GETTER.message,
|
| + StaticTypeWarningCode.UNDEFINED_GETTER.message);
|
| }
|
|
|
| void test_undefinedMethod() {
|
| @@ -3067,9 +3364,12 @@ f(var a) {
|
| }
|
|
|
| void test_undefinedSetter_message() {
|
| - // The implementation of HintCode.UNDEFINED_SETTER assumes that UNDEFINED_SETTER in
|
| - // StaticTypeWarningCode and StaticWarningCode are the same, this verifies that assumption.
|
| - expect(StaticWarningCode.UNDEFINED_SETTER.message, StaticTypeWarningCode.UNDEFINED_SETTER.message);
|
| + // The implementation of HintCode.UNDEFINED_SETTER assumes that
|
| + // UNDEFINED_SETTER in StaticTypeWarningCode and StaticWarningCode are the
|
| + // same, this verifies that assumption.
|
| + expect(
|
| + StaticWarningCode.UNDEFINED_SETTER.message,
|
| + StaticTypeWarningCode.UNDEFINED_SETTER.message);
|
| }
|
|
|
| void test_unnecessaryCast_type_supertype() {
|
| @@ -3146,106 +3446,38 @@ m(i) {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedImport() {
|
| + void test_unusedElement_class_inClassMember() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -library L;
|
| -import 'lib1.dart';''');
|
| - Source source2 = addNamedSource("/lib1.dart", "library lib1;");
|
| +class _A {
|
| + static staticMethod() {
|
| + new _A();
|
| + }
|
| + instanceMethod() {
|
| + new _A();
|
| + }
|
| +}
|
| +''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| - assertNoErrors(source2);
|
| - verify([source, source2]);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| + verify([source]);
|
| }
|
|
|
| - void test_unusedImport_as() {
|
| + void test_unusedElement_class_inConstructorName() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -library L;
|
| -import 'lib1.dart';
|
| -import 'lib1.dart' as one;
|
| -one.A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| -library lib1;
|
| -class A {}''');
|
| +class _A {
|
| + _A() {}
|
| + _A.named() {}
|
| +}
|
| +''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| - assertNoErrors(source2);
|
| - verify([source, source2]);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| + verify([source]);
|
| }
|
|
|
| - void test_unusedImport_hide() {
|
| - Source source = addSource(r'''
|
| -library L;
|
| -import 'lib1.dart';
|
| -import 'lib1.dart' hide A;
|
| -A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| -library lib1;
|
| -class A {}''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| - assertNoErrors(source2);
|
| - verify([source, source2]);
|
| - }
|
| -
|
| - void test_unusedImport_show() {
|
| - Source source = addSource(r'''
|
| -library L;
|
| -import 'lib1.dart' show A;
|
| -import 'lib1.dart' show B;
|
| -A a;''');
|
| - Source source2 = addNamedSource("/lib1.dart", r'''
|
| -library lib1;
|
| -class A {}
|
| -class B {}''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| - assertNoErrors(source2);
|
| - verify([source, source2]);
|
| - }
|
| -
|
| - void test_unusedElement_class_noReference() {
|
| - enableUnusedElement = true;
|
| - Source source = addSource(r'''
|
| -class _A {}
|
| -main() {
|
| -}''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| - verify([source]);
|
| - }
|
| -
|
| - void test_unusedElement_class_inConstructorName() {
|
| - enableUnusedElement = true;
|
| - Source source = addSource(r'''
|
| -class _A {
|
| - _A() {}
|
| - _A.named() {}
|
| -}
|
| -''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| - verify([source]);
|
| - }
|
| -
|
| - void test_unusedElement_class_inClassMember() {
|
| - enableUnusedElement = true;
|
| - Source source = addSource(r'''
|
| -class _A {
|
| - static staticMethod() {
|
| - new _A();
|
| - }
|
| - instanceMethod() {
|
| - new _A();
|
| - }
|
| -}
|
| -''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| - verify([source]);
|
| - }
|
| -
|
| - void test_unusedElement_class_isExpression() {
|
| - enableUnusedElement = true;
|
| + void test_unusedElement_class_isExpression() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class _A {}
|
| main(p) {
|
| @@ -3258,21 +3490,6 @@ main(p) {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_class_variableDeclaration() {
|
| - enableUnusedElement = true;
|
| - Source source = addSource(r'''
|
| -class _A {}
|
| -main() {
|
| - _A v;
|
| - print(v);
|
| -}
|
| -print(x) {}
|
| -''');
|
| - resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| - verify([source]);
|
| - }
|
| -
|
| void test_unusedElement_class_isUsed_extends() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| @@ -3335,61 +3552,63 @@ main() {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionLocal_notUsed_noReference() {
|
| + void test_unusedElement_class_noReference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| +class _A {}
|
| main() {
|
| - f() {}
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionLocal_notUsed_referenceFromItself() {
|
| + void test_unusedElement_class_variableDeclaration() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| +class _A {}
|
| main() {
|
| - _f(int p) {
|
| - _f(p - 1);
|
| - }
|
| -}''');
|
| + _A v;
|
| + print(v);
|
| +}
|
| +print(x) {}
|
| +''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionLocal_isUsed_invocation() {
|
| + void test_unusedElement_functionLocal_isUsed_closure() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| main() {
|
| - f() {}
|
| - f();
|
| -}''');
|
| + print(() {});
|
| +}
|
| +print(x) {}
|
| +''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionLocal_isUsed_reference() {
|
| + void test_unusedElement_functionLocal_isUsed_invocation() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| main() {
|
| f() {}
|
| - print(f);
|
| -}
|
| -print(x) {}
|
| -''');
|
| + f();
|
| +}''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionLocal_isUsed_closure() {
|
| + void test_unusedElement_functionLocal_isUsed_reference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| main() {
|
| - print(() {});
|
| + f() {}
|
| + print(f);
|
| }
|
| print(x) {}
|
| ''');
|
| @@ -3398,24 +3617,24 @@ print(x) {}
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionTop_notUsed_noReference() {
|
| + void test_unusedElement_functionLocal_notUsed_noReference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -_f() {}
|
| main() {
|
| + f() {}
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_functionTop_notUsed_referenceFromItself() {
|
| + void test_unusedElement_functionLocal_notUsed_referenceFromItself() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -_f(int p) {
|
| - _f(p - 1);
|
| -}
|
| main() {
|
| + _f(int p) {
|
| + _f(p - 1);
|
| + }
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| @@ -3448,24 +3667,24 @@ print(x) {}
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_getter_notUsed_noReference() {
|
| + void test_unusedElement_functionTop_notUsed_noReference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - get _g => null;
|
| +_f() {}
|
| +main() {
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_getter_notUsed_referenceFromItself() {
|
| + void test_unusedElement_functionTop_notUsed_referenceFromItself() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - get _g {
|
| - return _g;
|
| - }
|
| +_f(int p) {
|
| + _f(p - 1);
|
| +}
|
| +main() {
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| @@ -3516,25 +3735,23 @@ main() {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_setter_notUsed_noReference() {
|
| + void test_unusedElement_getter_notUsed_noReference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - set _s(x) {}
|
| + get _g => null;
|
| }''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_setter_notUsed_referenceFromItself() {
|
| + void test_unusedElement_getter_notUsed_referenceFromItself() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - set _s(int x) {
|
| - if (x > 5) {
|
| - _s = x - 1;
|
| - }
|
| + get _g {
|
| + return _g;
|
| }
|
| }''');
|
| resolve(source);
|
| @@ -3542,125 +3759,137 @@ class A {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_setter_isUsed_invocation_implicitThis() {
|
| + void test_unusedElement_method_isUsed_hasReference_implicitThis() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - set _s(x) {}
|
| - useSetter() {
|
| - _s = 42;
|
| + _m() {}
|
| + useMethod() {
|
| + print(_m);
|
| }
|
| -}''');
|
| +}
|
| +print(x) {}
|
| +''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_setter_isUsed_invocation_PrefixedIdentifier() {
|
| + void test_unusedElement_method_isUsed_hasReference_implicitThis_subclass() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - set _s(x) {}
|
| + _m() {}
|
| + useMethod() {
|
| + print(_m);
|
| + }
|
| }
|
| -main(A a) {
|
| - a._s = 42;
|
| +class B extends A {
|
| + _m() {}
|
| }
|
| +print(x) {}
|
| ''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_setter_isUsed_invocation_PropertyAccess() {
|
| + void test_unusedElement_method_isUsed_hasReference_PrefixedIdentifier() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - set _s(x) {}
|
| -}
|
| -main() {
|
| - new A()._s = 42;
|
| + _m() {}
|
| }
|
| -''');
|
| +main(A a) {
|
| + a._m;
|
| +}''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_notUsed_noReference() {
|
| + void test_unusedElement_method_isUsed_hasReference_PropertyAccess() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - static _m() {}
|
| + _m() {}
|
| +}
|
| +main() {
|
| + new A()._m;
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| + assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_notUsed_referenceFromItself() {
|
| + void test_unusedElement_method_isUsed_invocation_implicitThis() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - static _m(int p) {
|
| - _m(p - 1);
|
| + _m() {}
|
| + useMethod() {
|
| + _m();
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| + assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_staticInvocation() {
|
| + void test_unusedElement_method_isUsed_invocation_implicitThis_subclass() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - static _m() {}
|
| + _m() {}
|
| + useMethod() {
|
| + _m();
|
| + }
|
| }
|
| -main() {
|
| - A._m();
|
| +class B extends A {
|
| + _m() {}
|
| }''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_invocation_static() {
|
| + void test_unusedElement_method_isUsed_invocation_MemberElement() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - _m() {}
|
| +class A<T> {
|
| + _m(T t) {}
|
| }
|
| -main() {
|
| - A a = new A();
|
| - a._m();
|
| +main(A<int> a) {
|
| + a._m(0);
|
| }''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_invocation_implicitThis() {
|
| + void test_unusedElement_method_isUsed_invocation_propagated() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| _m() {}
|
| - useMethod() {
|
| - _m();
|
| - }
|
| +}
|
| +main() {
|
| + var a = new A();
|
| + a._m();
|
| }''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_invocation_propagated() {
|
| + void test_unusedElement_method_isUsed_invocation_static() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| _m() {}
|
| }
|
| main() {
|
| - var a = new A();
|
| + A a = new A();
|
| a._m();
|
| }''');
|
| resolve(source);
|
| @@ -3685,181 +3914,180 @@ main(A a) {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_invocation_implicitThis_subclass() {
|
| + void test_unusedElement_method_isUsed_notPrivate() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - _m() {}
|
| - useMethod() {
|
| - _m();
|
| - }
|
| + m() {}
|
| }
|
| -class B extends A {
|
| - _m() {}
|
| +main() {
|
| }''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_invocation_MemberElement() {
|
| + void test_unusedElement_method_isUsed_staticInvocation() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -class A<T> {
|
| - _m(T t) {}
|
| +class A {
|
| + static _m() {}
|
| }
|
| -main(A<int> a) {
|
| - a._m(0);
|
| +main() {
|
| + A._m();
|
| }''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_notPrivate() {
|
| + void test_unusedElement_method_notUsed_noReference() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - m() {}
|
| -}
|
| -main() {
|
| + static _m() {}
|
| }''');
|
| resolve(source);
|
| - assertNoErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_hasReference_implicitThis() {
|
| + void test_unusedElement_method_notUsed_referenceFromItself() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - _m() {}
|
| - useMethod() {
|
| - print(_m);
|
| + static _m(int p) {
|
| + _m(p - 1);
|
| }
|
| -}
|
| -print(x) {}
|
| -''');
|
| +}''');
|
| resolve(source);
|
| - assertNoErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_hasReference_implicitThis_subclass() {
|
| + void test_unusedElement_setter_isUsed_invocation_implicitThis() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - _m() {}
|
| - useMethod() {
|
| - print(_m);
|
| + set _s(x) {}
|
| + useSetter() {
|
| + _s = 42;
|
| }
|
| -}
|
| -class B extends A {
|
| - _m() {}
|
| -}
|
| -print(x) {}
|
| -''');
|
| +}''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_hasReference_PropertyAccess() {
|
| + void test_unusedElement_setter_isUsed_invocation_PrefixedIdentifier() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - _m() {}
|
| + set _s(x) {}
|
| }
|
| -main() {
|
| - new A()._m;
|
| -}''');
|
| +main(A a) {
|
| + a._s = 42;
|
| +}
|
| +''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedElement_method_isUsed_hasReference_PrefixedIdentifier() {
|
| + void test_unusedElement_setter_isUsed_invocation_PropertyAccess() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - _m() {}
|
| + set _s(x) {}
|
| }
|
| -main(A a) {
|
| - a._m;
|
| -}''');
|
| +main() {
|
| + new A()._s = 42;
|
| +}
|
| +''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_inFunction() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedElement_setter_notUsed_noReference() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - var v = 1;
|
| - v = 2;
|
| +class A {
|
| + set _s(x) {}
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_inMethod() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedElement_setter_notUsed_referenceFromItself() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - foo() {
|
| - var v = 1;
|
| - v = 2;
|
| + set _s(int x) {
|
| + if (x > 5) {
|
| + _s = x - 1;
|
| + }
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source, [HintCode.UNUSED_ELEMENT]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isRead_notUsed_compoundAssign() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_argument() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - var v = 1;
|
| - v += 2;
|
| -}''');
|
| +class A {
|
| + int _f = 0;
|
| + main() {
|
| + print(++_f);
|
| + }
|
| +}
|
| +print(x) {}''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isRead_notUsed_postfixExpr() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_implicitThis() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - var v = 1;
|
| - v++;
|
| -}''');
|
| +class A {
|
| + int _f;
|
| + main() {
|
| + print(_f);
|
| + }
|
| +}
|
| +print(x) {}''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isRead_notUsed_prefixExpr() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_implicitThis_expressionFunctionBody() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - var v = 1;
|
| - ++v;
|
| +class A {
|
| + int _f;
|
| + m() => _f;
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isRead_usedArgument() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_implicitThis_subclass() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - var v = 1;
|
| - print(++v);
|
| +class A {
|
| + int _f;
|
| + main() {
|
| + print(_f);
|
| + }
|
| +}
|
| +class B extends A {
|
| + int _f;
|
| }
|
| print(x) {}''');
|
| resolve(source);
|
| @@ -3867,83 +4095,102 @@ print(x) {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isRead_usedInvocationTarget() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_qualified_propagatedElement() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - foo() {}
|
| + int _f;
|
| }
|
| main() {
|
| var a = new A();
|
| - a.foo();
|
| + print(a._f);
|
| }
|
| -''');
|
| +print(x) {}''');
|
| resolve(source);
|
| assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_isInvoked() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_qualified_staticElement() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -typedef Foo();
|
| +class A {
|
| + int _f;
|
| +}
|
| main() {
|
| - Foo foo;
|
| - foo();
|
| -}''');
|
| + A a = new A();
|
| + print(a._f);
|
| +}
|
| +print(x) {}''');
|
| resolve(source);
|
| assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_inCatch_exception() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_isUsed_reference_qualified_unresolved() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - try {
|
| - } catch (exception) {
|
| - }
|
| -}''');
|
| +class A {
|
| + int _f;
|
| +}
|
| +main(a) {
|
| + print(a._f);
|
| +}
|
| +print(x) {}''');
|
| resolve(source);
|
| assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_inCatch_stackTrace() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_notUsed_compoundAssign() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - try {
|
| - } catch (exception, stackTrace) {
|
| +class A {
|
| + int _f;
|
| + main() {
|
| + _f += 2;
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedLocalVariable_inCatch_stackTrace_used() {
|
| - enableUnusedLocalVariable = true;
|
| + void test_unusedField_notUsed_noReference() {
|
| + enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| -main() {
|
| - try {
|
| - } catch (exception, stackTrace) {
|
| - print('exception at $stackTrace');
|
| - }
|
| +class A {
|
| + int _f;
|
| }
|
| -print(x) {}''');
|
| +''');
|
| resolve(source);
|
| - assertErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_notUsed_noReference() {
|
| + void test_unusedField_notUsed_postfixExpr() {
|
| enableUnusedElement = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - int _f;
|
| -}
|
| -''');
|
| + int _f = 0;
|
| + main() {
|
| + _f++;
|
| + }
|
| +}''');
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unusedField_notUsed_prefixExpr() {
|
| + enableUnusedElement = true;
|
| + Source source = addSource(r'''
|
| +class A {
|
| + int _f = 0;
|
| + main() {
|
| + ++_f;
|
| + }
|
| +}''');
|
| resolve(source);
|
| assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| verify([source]);
|
| @@ -3967,133 +4214,185 @@ main(A a) {
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_notUsed_compoundAssign() {
|
| - enableUnusedElement = true;
|
| + void test_unusedImport() {
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f;
|
| - main() {
|
| - _f += 2;
|
| +library L;
|
| +import 'lib1.dart';''');
|
| + Source source2 = addNamedSource("/lib1.dart", "library lib1;");
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| + assertNoErrors(source2);
|
| + verify([source, source2]);
|
| }
|
| -}''');
|
| +
|
| + void test_unusedImport_as() {
|
| + Source source = addSource(r'''
|
| +library L;
|
| +import 'lib1.dart';
|
| +import 'lib1.dart' as one;
|
| +one.A a;''');
|
| + Source source2 = addNamedSource("/lib1.dart", r'''
|
| +library lib1;
|
| +class A {}''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| - verify([source]);
|
| + assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| + assertNoErrors(source2);
|
| + verify([source, source2]);
|
| }
|
|
|
| - void test_unusedField_notUsed_postfixExpr() {
|
| - enableUnusedElement = true;
|
| + void test_unusedImport_hide() {
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f = 0;
|
| - main() {
|
| - _f++;
|
| +library L;
|
| +import 'lib1.dart';
|
| +import 'lib1.dart' hide A;
|
| +A a;''');
|
| + Source source2 = addNamedSource("/lib1.dart", r'''
|
| +library lib1;
|
| +class A {}''');
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| + assertNoErrors(source2);
|
| + verify([source, source2]);
|
| + }
|
| +
|
| + void test_unusedImport_show() {
|
| + Source source = addSource(r'''
|
| +library L;
|
| +import 'lib1.dart' show A;
|
| +import 'lib1.dart' show B;
|
| +A a;''');
|
| + Source source2 = addNamedSource("/lib1.dart", r'''
|
| +library lib1;
|
| +class A {}
|
| +class B {}''');
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_IMPORT]);
|
| + assertNoErrors(source2);
|
| + verify([source, source2]);
|
| + }
|
| +
|
| + void test_unusedLocalVariable_inCatch_exception() {
|
| + enableUnusedLocalVariable = true;
|
| + Source source = addSource(r'''
|
| +main() {
|
| + try {
|
| + } catch (exception) {
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| + assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_notUsed_prefixExpr() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_inCatch_stackTrace() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f = 0;
|
| - main() {
|
| - ++_f;
|
| +main() {
|
| + try {
|
| + } catch (exception, stackTrace) {
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.UNUSED_FIELD]);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_argument() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_inCatch_stackTrace_used() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f = 0;
|
| - main() {
|
| - print(++_f);
|
| +main() {
|
| + try {
|
| + } catch (exception, stackTrace) {
|
| + print('exception at $stackTrace');
|
| }
|
| }
|
| print(x) {}''');
|
| resolve(source);
|
| - assertErrors(source);
|
| + assertErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unusedLocalVariable_inFunction() {
|
| + enableUnusedLocalVariable = true;
|
| + Source source = addSource(r'''
|
| +main() {
|
| + var v = 1;
|
| + v = 2;
|
| +}''');
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_implicitThis() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_inMethod() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - int _f;
|
| - main() {
|
| - print(_f);
|
| + foo() {
|
| + var v = 1;
|
| + v = 2;
|
| }
|
| -}
|
| -print(x) {}''');
|
| +}''');
|
| resolve(source);
|
| - assertErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_implicitThis_expressionFunctionBody() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_isInvoked() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f;
|
| - m() => _f;
|
| +typedef Foo();
|
| +main() {
|
| + Foo foo;
|
| + foo();
|
| }''');
|
| resolve(source);
|
| assertErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_implicitThis_subclass() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_isRead_notUsed_compoundAssign() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f;
|
| - main() {
|
| - print(_f);
|
| +main() {
|
| + var v = 1;
|
| + v += 2;
|
| +}''');
|
| + resolve(source);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| + verify([source]);
|
| }
|
| -}
|
| -class B extends A {
|
| - int _f;
|
| -}
|
| -print(x) {}''');
|
| +
|
| + void test_unusedLocalVariable_isRead_notUsed_postfixExpr() {
|
| + enableUnusedLocalVariable = true;
|
| + Source source = addSource(r'''
|
| +main() {
|
| + var v = 1;
|
| + v++;
|
| +}''');
|
| resolve(source);
|
| - assertErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_qualified_staticElement() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_isRead_notUsed_prefixExpr() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f;
|
| -}
|
| main() {
|
| - A a = new A();
|
| - print(a._f);
|
| -}
|
| -print(x) {}''');
|
| + var v = 1;
|
| + ++v;
|
| +}''');
|
| resolve(source);
|
| - assertErrors(source);
|
| + assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_qualified_propagatedElement() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_isRead_usedArgument() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| -class A {
|
| - int _f;
|
| -}
|
| main() {
|
| - var a = new A();
|
| - print(a._f);
|
| + var v = 1;
|
| + print(++v);
|
| }
|
| print(x) {}''');
|
| resolve(source);
|
| @@ -4101,16 +4400,17 @@ print(x) {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedField_isUsed_reference_qualified_unresolved() {
|
| - enableUnusedElement = true;
|
| + void test_unusedLocalVariable_isRead_usedInvocationTarget() {
|
| + enableUnusedLocalVariable = true;
|
| Source source = addSource(r'''
|
| class A {
|
| - int _f;
|
| + foo() {}
|
| }
|
| -main(a) {
|
| - print(a._f);
|
| +main() {
|
| + var a = new A();
|
| + a.foo();
|
| }
|
| -print(x) {}''');
|
| +''');
|
| resolve(source);
|
| assertErrors(source);
|
| verify([source]);
|
| @@ -4192,7 +4492,9 @@ class A {
|
| }
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
|
| + assertErrors(
|
| + source,
|
| + [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
|
| verify([source]);
|
| }
|
| }
|
| @@ -4224,7 +4526,8 @@ class C {
|
| MethodDeclaration method = classNode.members[0] as MethodDeclaration;
|
| method.body.accept(new ResolutionEraser());
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| - IncrementalResolver resolver = new IncrementalResolver(library, source, typeProvider, errorListener);
|
| + IncrementalResolver resolver =
|
| + new IncrementalResolver(library, source, typeProvider, errorListener);
|
| resolver.resolve(method.body);
|
| return method;
|
| }
|
| @@ -4256,7 +4559,8 @@ class InheritanceManagerTest extends EngineTestCase {
|
| _typeProvider = new TestTypeProvider();
|
| _inheritanceManager = _createInheritanceManager();
|
| InterfaceType objectType = _typeProvider.objectType;
|
| - _numOfMembersInObject = objectType.methods.length + objectType.accessors.length;
|
| + _numOfMembersInObject =
|
| + objectType.methods.length + objectType.accessors.length;
|
| }
|
|
|
| void test_getMapOfMembersInheritedFromClasses_accessor_extends() {
|
| @@ -4264,11 +4568,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(getterName), same(getterG));
|
| @@ -4281,12 +4588,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B implements A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject);
|
| expect(mapB.get(getterName), isNull);
|
| @@ -4299,12 +4609,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends Object with A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(getterName), same(getterG));
|
| @@ -4315,7 +4628,8 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_getMapOfMembersInheritedFromClasses_implicitExtends() {
|
| // class A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| _assertNoErrors(classA);
|
| }
|
| @@ -4325,12 +4639,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| classB.supertype = classA.type;
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(methodName), same(methodM));
|
| @@ -4343,12 +4660,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B implements A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject);
|
| expect(mapB.get(methodName), isNull);
|
| @@ -4361,12 +4681,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends Object with A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromClasses(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(methodName), same(methodM));
|
| @@ -4379,11 +4702,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(getterName), same(getterG));
|
| @@ -4396,12 +4722,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B implements A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(getterName), same(getterG));
|
| @@ -4414,12 +4743,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends Object with A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(getterName), same(getterG));
|
| @@ -4430,121 +4762,158 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() {
|
| // class A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_getter_method() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_getter_method() {
|
| // class I1 { int m(); }
|
| // class I2 { int get m; }
|
| // class A implements I2, I1 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(methodName, false, _typeProvider.intType);
|
| - classI2.accessors = <PropertyAccessorElement> [getter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(methodName, false, _typeProvider.intType);
|
| + classI2.accessors = <PropertyAccessorElement>[getter];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI2.type, classI1.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI2.type, classI1.type];
|
| + MemberMap mapA =
|
| + _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() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_int_str() {
|
| // class I1 { int m(); }
|
| // class I2 { String m(); }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_typeProvider.intType]);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName, null, [_typeProvider.intType]);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_typeProvider.stringType]);
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + MethodElement methodM2 =
|
| + ElementFactory.methodElement(methodName, null, [_typeProvider.stringType]);
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapA.get(methodName), isNull);
|
| - _assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| + _assertErrors(
|
| + classA,
|
| + [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_method_getter() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_method_getter() {
|
| // class I1 { int m(); }
|
| // class I2 { int get m; }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement getter = ElementFactory.getterElement(methodName, false, _typeProvider.intType);
|
| - classI2.accessors = <PropertyAccessorElement> [getter];
|
| + PropertyAccessorElement getter =
|
| + ElementFactory.getterElement(methodName, false, _typeProvider.intType);
|
| + classI2.accessors = <PropertyAccessorElement>[getter];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _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() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_numOfRequiredParams() {
|
| // class I1 { dynamic m(int, [int]); }
|
| // class I2 { dynamic m(int, int, int); }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElementImpl methodM1 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| + MethodElementImpl methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| parameter1.type = _typeProvider.intType;
|
| parameter1.parameterKind = ParameterKind.REQUIRED;
|
| - ParameterElementImpl parameter2 = new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| + ParameterElementImpl parameter2 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| parameter2.type = _typeProvider.intType;
|
| parameter2.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM1.parameters = <ParameterElement> [parameter1, parameter2];
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + methodM1.parameters = <ParameterElement>[parameter1, parameter2];
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElementImpl methodM2 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter3 = new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| + MethodElementImpl methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter3 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| parameter3.type = _typeProvider.intType;
|
| parameter3.parameterKind = ParameterKind.REQUIRED;
|
| - ParameterElementImpl parameter4 = new ParameterElementImpl.forNode(AstFactory.identifier3("a4"));
|
| + ParameterElementImpl parameter4 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a4"));
|
| parameter4.type = _typeProvider.intType;
|
| parameter4.parameterKind = ParameterKind.REQUIRED;
|
| - ParameterElementImpl parameter5 = new ParameterElementImpl.forNode(AstFactory.identifier3("a5"));
|
| + ParameterElementImpl parameter5 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a5"));
|
| parameter5.type = _typeProvider.intType;
|
| parameter5.parameterKind = ParameterKind.REQUIRED;
|
| - methodM2.parameters = <ParameterElement> [parameter3, parameter4, parameter5];
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + methodM2.parameters =
|
| + <ParameterElement>[parameter3, parameter4, parameter5];
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapA.get(methodName), isNull);
|
| - _assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| + _assertErrors(
|
| + classA,
|
| + [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_str_int() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_inconsistentMethodInheritance_str_int() {
|
| // class I1 { int m(); }
|
| // class I2 { String m(); }
|
| // class A implements I2, I1 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_typeProvider.stringType]);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName, null, [_typeProvider.stringType]);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_typeProvider.intType]);
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + MethodElement methodM2 =
|
| + ElementFactory.methodElement(methodName, null, [_typeProvider.intType]);
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI2.type, classI1.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI2.type, classI1.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapA.get(methodName), isNull);
|
| - _assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| + _assertErrors(
|
| + classA,
|
| + [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
|
| }
|
|
|
| void test_getMapOfMembersInheritedFromInterfaces_method_extends() {
|
| @@ -4552,11 +4921,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(methodName), same(methodM));
|
| @@ -4569,12 +4941,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B implements A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(methodName), same(methodM));
|
| @@ -4587,12 +4962,15 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class B extends Object with A {}
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + MemberMap mapB =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classB);
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject);
|
| expect(mapB.size, _numOfMembersInObject + 1);
|
| expect(mapB.get(methodName), same(methodM));
|
| @@ -4606,91 +4984,114 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName1 = "m1";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName1, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| String methodName2 = "m2";
|
| - MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProvider.intType);
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + MethodElement methodM2 =
|
| + ElementFactory.methodElement(methodName2, _typeProvider.intType);
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 2);
|
| expect(mapA.get(methodName1), same(methodM1));
|
| expect(mapA.get(methodName2), same(methodM2));
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_getters() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_getters() {
|
| // class I1 { int get g; }
|
| // class I2 { num get g; }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String accessorName = "g";
|
| - PropertyAccessorElement getter1 = ElementFactory.getterElement(accessorName, false, _typeProvider.intType);
|
| - classI1.accessors = <PropertyAccessorElement> [getter1];
|
| + PropertyAccessorElement getter1 =
|
| + ElementFactory.getterElement(accessorName, false, _typeProvider.intType);
|
| + classI1.accessors = <PropertyAccessorElement>[getter1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement getter2 = ElementFactory.getterElement(accessorName, false, _typeProvider.numType);
|
| - classI2.accessors = <PropertyAccessorElement> [getter2];
|
| + PropertyAccessorElement getter2 =
|
| + ElementFactory.getterElement(accessorName, false, _typeProvider.numType);
|
| + classI2.accessors = <PropertyAccessorElement>[getter2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| - PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement(accessorName, false, _typeProvider.dynamicType);
|
| + PropertyAccessorElement syntheticAccessor =
|
| + ElementFactory.getterElement(accessorName, false, _typeProvider.dynamicType);
|
| expect(mapA.get(accessorName).type, syntheticAccessor.type);
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_methods() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_methods() {
|
| // class I1 { dynamic m(int); }
|
| // class I2 { dynamic m(num); }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElementImpl methodM1 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| + MethodElementImpl methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| parameter1.type = _typeProvider.intType;
|
| parameter1.parameterKind = ParameterKind.REQUIRED;
|
| - methodM1.parameters = <ParameterElement> [parameter1];
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + methodM1.parameters = <ParameterElement>[parameter1];
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElementImpl methodM2 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter2 = new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| + MethodElementImpl methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter2 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| parameter2.type = _typeProvider.numType;
|
| parameter2.parameterKind = ParameterKind.REQUIRED;
|
| - methodM2.parameters = <ParameterElement> [parameter2];
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + methodM2.parameters = <ParameterElement>[parameter2];
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| - MethodElement syntheticMethod = ElementFactory.methodElement(methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]);
|
| + MethodElement syntheticMethod = ElementFactory.methodElement(
|
| + methodName,
|
| + _typeProvider.dynamicType,
|
| + [_typeProvider.dynamicType]);
|
| expect(mapA.get(methodName).type, syntheticMethod.type);
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_setters() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_2_setters() {
|
| // class I1 { set s(int); }
|
| // class I2 { set s(num); }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String accessorName = "s";
|
| - PropertyAccessorElement setter1 = ElementFactory.setterElement(accessorName, false, _typeProvider.intType);
|
| - classI1.accessors = <PropertyAccessorElement> [setter1];
|
| + PropertyAccessorElement setter1 =
|
| + ElementFactory.setterElement(accessorName, false, _typeProvider.intType);
|
| + classI1.accessors = <PropertyAccessorElement>[setter1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement setter2 = ElementFactory.setterElement(accessorName, false, _typeProvider.numType);
|
| - classI2.accessors = <PropertyAccessorElement> [setter2];
|
| + PropertyAccessorElement setter2 =
|
| + ElementFactory.setterElement(accessorName, false, _typeProvider.numType);
|
| + classI2.accessors = <PropertyAccessorElement>[setter2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| - PropertyAccessorElementImpl syntheticAccessor = ElementFactory.setterElement(accessorName, false, _typeProvider.dynamicType);
|
| + PropertyAccessorElementImpl syntheticAccessor =
|
| + ElementFactory.setterElement(accessorName, false, _typeProvider.dynamicType);
|
| syntheticAccessor.returnType = _typeProvider.dynamicType;
|
| expect(mapA.get("$accessorName=").type, syntheticAccessor.type);
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_getters() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_getters() {
|
| // class A {}
|
| // class B extends A {}
|
| // class C extends B {}
|
| @@ -4703,24 +5104,31 @@ class InheritanceManagerTest extends EngineTestCase {
|
| ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String accessorName = "g";
|
| - PropertyAccessorElement getter1 = ElementFactory.getterElement(accessorName, false, classA.type);
|
| - classI1.accessors = <PropertyAccessorElement> [getter1];
|
| + PropertyAccessorElement getter1 =
|
| + ElementFactory.getterElement(accessorName, false, classA.type);
|
| + classI1.accessors = <PropertyAccessorElement>[getter1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement getter2 = ElementFactory.getterElement(accessorName, false, classB.type);
|
| - classI2.accessors = <PropertyAccessorElement> [getter2];
|
| + PropertyAccessorElement getter2 =
|
| + ElementFactory.getterElement(accessorName, false, classB.type);
|
| + classI2.accessors = <PropertyAccessorElement>[getter2];
|
| ClassElementImpl classI3 = ElementFactory.classElement2("I3");
|
| - PropertyAccessorElement getter3 = ElementFactory.getterElement(accessorName, false, classC.type);
|
| - classI3.accessors = <PropertyAccessorElement> [getter3];
|
| + PropertyAccessorElement getter3 =
|
| + ElementFactory.getterElement(accessorName, false, classC.type);
|
| + classI3.accessors = <PropertyAccessorElement>[getter3];
|
| ClassElementImpl classD = ElementFactory.classElement2("D");
|
| - classD.interfaces = <InterfaceType> [classI1.type, classI2.type, classI3.type];
|
| - MemberMap mapD = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| + classD.interfaces =
|
| + <InterfaceType>[classI1.type, classI2.type, classI3.type];
|
| + MemberMap mapD =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| expect(mapD.size, _numOfMembersInObject + 1);
|
| - PropertyAccessorElement syntheticAccessor = ElementFactory.getterElement(accessorName, false, _typeProvider.dynamicType);
|
| + PropertyAccessorElement syntheticAccessor =
|
| + ElementFactory.getterElement(accessorName, false, _typeProvider.dynamicType);
|
| expect(mapD.get(accessorName).type, syntheticAccessor.type);
|
| _assertNoErrors(classD);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_methods() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_methods() {
|
| // class A {}
|
| // class B extends A {}
|
| // class C extends B {}
|
| @@ -4733,36 +5141,48 @@ class InheritanceManagerTest extends EngineTestCase {
|
| ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElementImpl methodM1 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| + MethodElementImpl methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| parameter1.type = classA.type;
|
| parameter1.parameterKind = ParameterKind.REQUIRED;
|
| - methodM1.parameters = <ParameterElement> [parameter1];
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + methodM1.parameters = <ParameterElement>[parameter1];
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElementImpl methodM2 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter2 = new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| + MethodElementImpl methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter2 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| parameter2.type = classB.type;
|
| parameter2.parameterKind = ParameterKind.REQUIRED;
|
| - methodM2.parameters = <ParameterElement> [parameter2];
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + methodM2.parameters = <ParameterElement>[parameter2];
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classI3 = ElementFactory.classElement2("I3");
|
| - MethodElementImpl methodM3 = ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| - ParameterElementImpl parameter3 = new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| + MethodElementImpl methodM3 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.dynamicType);
|
| + ParameterElementImpl parameter3 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a0"));
|
| parameter3.type = classC.type;
|
| parameter3.parameterKind = ParameterKind.REQUIRED;
|
| - methodM3.parameters = <ParameterElement> [parameter3];
|
| - classI3.methods = <MethodElement> [methodM3];
|
| + methodM3.parameters = <ParameterElement>[parameter3];
|
| + classI3.methods = <MethodElement>[methodM3];
|
| ClassElementImpl classD = ElementFactory.classElement2("D");
|
| - classD.interfaces = <InterfaceType> [classI1.type, classI2.type, classI3.type];
|
| - MemberMap mapD = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| + classD.interfaces =
|
| + <InterfaceType>[classI1.type, classI2.type, classI3.type];
|
| + MemberMap mapD =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| expect(mapD.size, _numOfMembersInObject + 1);
|
| - MethodElement syntheticMethod = ElementFactory.methodElement(methodName, _typeProvider.dynamicType, [_typeProvider.dynamicType]);
|
| + MethodElement syntheticMethod = ElementFactory.methodElement(
|
| + methodName,
|
| + _typeProvider.dynamicType,
|
| + [_typeProvider.dynamicType]);
|
| expect(mapD.get(methodName).type, syntheticMethod.type);
|
| _assertNoErrors(classD);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_setters() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_multipleSubtypes_3_setters() {
|
| // class A {}
|
| // class B extends A {}
|
| // class C extends B {}
|
| @@ -4775,82 +5195,103 @@ class InheritanceManagerTest extends EngineTestCase {
|
| ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String accessorName = "s";
|
| - PropertyAccessorElement setter1 = ElementFactory.setterElement(accessorName, false, classA.type);
|
| - classI1.accessors = <PropertyAccessorElement> [setter1];
|
| + PropertyAccessorElement setter1 =
|
| + ElementFactory.setterElement(accessorName, false, classA.type);
|
| + classI1.accessors = <PropertyAccessorElement>[setter1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - PropertyAccessorElement setter2 = ElementFactory.setterElement(accessorName, false, classB.type);
|
| - classI2.accessors = <PropertyAccessorElement> [setter2];
|
| + PropertyAccessorElement setter2 =
|
| + ElementFactory.setterElement(accessorName, false, classB.type);
|
| + classI2.accessors = <PropertyAccessorElement>[setter2];
|
| ClassElementImpl classI3 = ElementFactory.classElement2("I3");
|
| - PropertyAccessorElement setter3 = ElementFactory.setterElement(accessorName, false, classC.type);
|
| - classI3.accessors = <PropertyAccessorElement> [setter3];
|
| + PropertyAccessorElement setter3 =
|
| + ElementFactory.setterElement(accessorName, false, classC.type);
|
| + classI3.accessors = <PropertyAccessorElement>[setter3];
|
| ClassElementImpl classD = ElementFactory.classElement2("D");
|
| - classD.interfaces = <InterfaceType> [classI1.type, classI2.type, classI3.type];
|
| - MemberMap mapD = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| + classD.interfaces =
|
| + <InterfaceType>[classI1.type, classI2.type, classI3.type];
|
| + MemberMap mapD =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classD);
|
| expect(mapD.size, _numOfMembersInObject + 1);
|
| - PropertyAccessorElementImpl syntheticAccessor = ElementFactory.setterElement(accessorName, false, _typeProvider.dynamicType);
|
| + PropertyAccessorElementImpl syntheticAccessor =
|
| + ElementFactory.setterElement(accessorName, false, _typeProvider.dynamicType);
|
| syntheticAccessor.returnType = _typeProvider.dynamicType;
|
| expect(mapD.get("$accessorName=").type, syntheticAccessor.type);
|
| _assertNoErrors(classD);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_2_methods() {
|
| // class I1 { int m(); }
|
| // class I2 { int m([int]); }
|
| // class A implements I1, I2 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElementImpl methodM2 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| + MethodElementImpl methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| parameter1.type = _typeProvider.intType;
|
| parameter1.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM2.parameters = <ParameterElement> [parameter1];
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + methodM2.parameters = <ParameterElement>[parameter1];
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces = <InterfaceType>[classI1.type, classI2.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| expect(mapA.get(methodName), same(methodM2));
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_3_methods() {
|
| // class I1 { int m(); }
|
| // class I2 { int m([int]); }
|
| // class I3 { int m([int, int]); }
|
| // class A implements I1, I2, I3 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElementImpl methodM1 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElementImpl methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElementImpl methodM2 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| + MethodElementImpl methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| parameter1.type = _typeProvider.intType;
|
| parameter1.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM1.parameters = <ParameterElement> [parameter1];
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + methodM1.parameters = <ParameterElement>[parameter1];
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classI3 = ElementFactory.classElement2("I3");
|
| - MethodElementImpl methodM3 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - ParameterElementImpl parameter2 = new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| + MethodElementImpl methodM3 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + ParameterElementImpl parameter2 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| parameter2.type = _typeProvider.intType;
|
| parameter2.parameterKind = ParameterKind.POSITIONAL;
|
| - ParameterElementImpl parameter3 = new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| + ParameterElementImpl parameter3 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| parameter3.type = _typeProvider.intType;
|
| parameter3.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM3.parameters = <ParameterElement> [parameter2, parameter3];
|
| - classI3.methods = <MethodElement> [methodM3];
|
| + methodM3.parameters = <ParameterElement>[parameter2, parameter3];
|
| + classI3.methods = <MethodElement>[methodM3];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type, classI3.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces =
|
| + <InterfaceType>[classI1.type, classI2.type, classI3.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| expect(mapA.get(methodName), same(methodM3));
|
| _assertNoErrors(classA);
|
| }
|
|
|
| - void test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() {
|
| + void
|
| + test_getMapOfMembersInheritedFromInterfaces_union_oneSubtype_4_methods() {
|
| // class I1 { int m(); }
|
| // class I2 { int m(); }
|
| // class I3 { int m([int]); }
|
| @@ -4858,31 +5299,40 @@ class InheritanceManagerTest extends EngineTestCase {
|
| // class A implements I1, I2, I3, I4 {}
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName = "m";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| - MethodElement methodM2 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classI2.methods = <MethodElement> [methodM2];
|
| + MethodElement methodM2 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classI2.methods = <MethodElement>[methodM2];
|
| ClassElementImpl classI3 = ElementFactory.classElement2("I3");
|
| - MethodElementImpl methodM3 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - ParameterElementImpl parameter1 = new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| + MethodElementImpl methodM3 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + ParameterElementImpl parameter1 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a1"));
|
| parameter1.type = _typeProvider.intType;
|
| parameter1.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM3.parameters = <ParameterElement> [parameter1];
|
| - classI3.methods = <MethodElement> [methodM3];
|
| + methodM3.parameters = <ParameterElement>[parameter1];
|
| + classI3.methods = <MethodElement>[methodM3];
|
| ClassElementImpl classI4 = ElementFactory.classElement2("I4");
|
| - MethodElementImpl methodM4 = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - ParameterElementImpl parameter2 = new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| + MethodElementImpl methodM4 =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + ParameterElementImpl parameter2 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a2"));
|
| parameter2.type = _typeProvider.intType;
|
| parameter2.parameterKind = ParameterKind.POSITIONAL;
|
| - ParameterElementImpl parameter3 = new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| + ParameterElementImpl parameter3 =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("a3"));
|
| parameter3.type = _typeProvider.intType;
|
| parameter3.parameterKind = ParameterKind.POSITIONAL;
|
| - methodM4.parameters = <ParameterElement> [parameter2, parameter3];
|
| - classI4.methods = <MethodElement> [methodM4];
|
| + methodM4.parameters = <ParameterElement>[parameter2, parameter3];
|
| + classI4.methods = <MethodElement>[methodM4];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI1.type, classI2.type, classI3.type, classI4.type];
|
| - MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| + classA.interfaces =
|
| + <InterfaceType>[classI1.type, classI2.type, classI3.type, classI4.type];
|
| + MemberMap mapA =
|
| + _inheritanceManager.getMapOfMembersInheritedFromInterfaces(classA);
|
| expect(mapA.size, _numOfMembersInObject + 1);
|
| expect(mapA.get(methodName), same(methodM4));
|
| _assertNoErrors(classA);
|
| @@ -4891,11 +5341,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interface_getter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, getterName), same(getterG));
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, getterName),
|
| + same(getterG));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -4903,11 +5356,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interface_method() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, methodName), same(methodM));
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, methodName),
|
| + same(methodM));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -4915,11 +5371,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interface_setter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "s";
|
| - PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setterS];
|
| + PropertyAccessorElement setterS =
|
| + ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setterS];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), same(setterS));
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, "$setterName="),
|
| + same(setterS));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -4927,11 +5386,12 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interface_staticMember() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| (methodM as MethodElementImpl).static = true;
|
| - classA.methods = <MethodElement> [methodM];
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull);
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| @@ -4939,7 +5399,7 @@ class InheritanceManagerTest extends EngineTestCase {
|
|
|
| void test_lookupInheritance_interfaces_infiniteLoop() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classA.type];
|
| + classA.interfaces = <InterfaceType>[classA.type];
|
| expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull);
|
| _assertNoErrors(classA);
|
| }
|
| @@ -4947,8 +5407,8 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interfaces_infiniteLoop2() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classA.interfaces = <InterfaceType> [classB.type];
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| + classA.interfaces = <InterfaceType>[classB.type];
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| expect(_inheritanceManager.lookupInheritance(classA, "name"), isNull);
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| @@ -4957,17 +5417,23 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_interfaces_union2() {
|
| ClassElementImpl classI1 = ElementFactory.classElement2("I1");
|
| String methodName1 = "m1";
|
| - MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProvider.intType);
|
| - classI1.methods = <MethodElement> [methodM1];
|
| + MethodElement methodM1 =
|
| + ElementFactory.methodElement(methodName1, _typeProvider.intType);
|
| + classI1.methods = <MethodElement>[methodM1];
|
| ClassElementImpl classI2 = ElementFactory.classElement2("I2");
|
| String methodName2 = "m2";
|
| - MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProvider.intType);
|
| - classI2.methods = <MethodElement> [methodM2];
|
| - classI2.interfaces = <InterfaceType> [classI1.type];
|
| + MethodElement methodM2 =
|
| + ElementFactory.methodElement(methodName2, _typeProvider.intType);
|
| + classI2.methods = <MethodElement>[methodM2];
|
| + classI2.interfaces = <InterfaceType>[classI1.type];
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - classA.interfaces = <InterfaceType> [classI2.type];
|
| - expect(_inheritanceManager.lookupInheritance(classA, methodName1), same(methodM1));
|
| - expect(_inheritanceManager.lookupInheritance(classA, methodName2), same(methodM2));
|
| + classA.interfaces = <InterfaceType>[classI2.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classA, methodName1),
|
| + same(methodM1));
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classA, methodName2),
|
| + same(methodM2));
|
| _assertNoErrors(classI1);
|
| _assertNoErrors(classI2);
|
| _assertNoErrors(classA);
|
| @@ -4976,11 +5442,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_mixin_getter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, getterName), same(getterG));
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, getterName),
|
| + same(getterG));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -4988,11 +5457,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_mixin_method() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, methodName), same(methodM));
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, methodName),
|
| + same(methodM));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -5000,11 +5472,14 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_mixin_setter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "s";
|
| - PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setterS];
|
| + PropertyAccessorElement setterS =
|
| + ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setterS];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| - expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), same(setterS));
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, "$setterName="),
|
| + same(setterS));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -5012,11 +5487,12 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_mixin_staticMember() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| (methodM as MethodElementImpl).static = true;
|
| - classA.methods = <MethodElement> [methodM];
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.mixins = <InterfaceType> [classA.type];
|
| + classB.mixins = <InterfaceType>[classA.type];
|
| expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull);
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| @@ -5031,10 +5507,13 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_superclass_getter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - expect(_inheritanceManager.lookupInheritance(classB, getterName), same(getterG));
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, getterName),
|
| + same(getterG));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -5059,10 +5538,13 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_superclass_method() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - expect(_inheritanceManager.lookupInheritance(classB, methodName), same(methodM));
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, methodName),
|
| + same(methodM));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -5070,10 +5552,13 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_superclass_setter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "s";
|
| - PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setterS];
|
| + PropertyAccessorElement setterS =
|
| + ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setterS];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - expect(_inheritanceManager.lookupInheritance(classB, "$setterName="), same(setterS));
|
| + expect(
|
| + _inheritanceManager.lookupInheritance(classB, "$setterName="),
|
| + same(setterS));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| }
|
| @@ -5081,9 +5566,10 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupInheritance_superclass_staticMember() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| (methodM as MethodElementImpl).static = true;
|
| - classA.methods = <MethodElement> [methodM];
|
| + classA.methods = <MethodElement>[methodM];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| expect(_inheritanceManager.lookupInheritance(classB, methodName), isNull);
|
| _assertNoErrors(classA);
|
| @@ -5093,8 +5579,9 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupMember_getter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| expect(_inheritanceManager.lookupMember(classA, getterName), same(getterG));
|
| _assertNoErrors(classA);
|
| }
|
| @@ -5102,8 +5589,9 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupMember_getter_static() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String getterName = "g";
|
| - PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, true, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [getterG];
|
| + PropertyAccessorElement getterG =
|
| + ElementFactory.getterElement(getterName, true, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[getterG];
|
| expect(_inheritanceManager.lookupMember(classA, getterName), isNull);
|
| _assertNoErrors(classA);
|
| }
|
| @@ -5111,8 +5599,9 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupMember_method() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| expect(_inheritanceManager.lookupMember(classA, methodName), same(methodM));
|
| _assertNoErrors(classA);
|
| }
|
| @@ -5120,9 +5609,10 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupMember_method_static() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + MethodElement methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| (methodM as MethodElementImpl).static = true;
|
| - classA.methods = <MethodElement> [methodM];
|
| + classA.methods = <MethodElement>[methodM];
|
| expect(_inheritanceManager.lookupMember(classA, methodName), isNull);
|
| _assertNoErrors(classA);
|
| }
|
| @@ -5136,17 +5626,21 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupMember_setter() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "s";
|
| - PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setterS];
|
| - expect(_inheritanceManager.lookupMember(classA, "$setterName="), same(setterS));
|
| + PropertyAccessorElement setterS =
|
| + ElementFactory.setterElement(setterName, false, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setterS];
|
| + expect(
|
| + _inheritanceManager.lookupMember(classA, "$setterName="),
|
| + same(setterS));
|
| _assertNoErrors(classA);
|
| }
|
|
|
| void test_lookupMember_setter_static() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String setterName = "s";
|
| - PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, true, _typeProvider.intType);
|
| - classA.accessors = <PropertyAccessorElement> [setterS];
|
| + PropertyAccessorElement setterS =
|
| + ElementFactory.setterElement(setterName, true, _typeProvider.intType);
|
| + classA.accessors = <PropertyAccessorElement>[setterS];
|
| expect(_inheritanceManager.lookupMember(classA, setterName), isNull);
|
| _assertNoErrors(classA);
|
| }
|
| @@ -5154,21 +5648,27 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupOverrides_noParentClasses() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElementImpl methodM = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodM];
|
| - expect(_inheritanceManager.lookupOverrides(classA, methodName), hasLength(0));
|
| + MethodElementImpl methodM =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodM];
|
| + expect(
|
| + _inheritanceManager.lookupOverrides(classA, methodName),
|
| + hasLength(0));
|
| _assertNoErrors(classA);
|
| }
|
|
|
| void test_lookupOverrides_overrideBaseClass() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElementImpl methodMinA = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodMinA];
|
| + MethodElementImpl methodMinA =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodMinA];
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - MethodElementImpl methodMinB = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classB.methods = <MethodElement> [methodMinB];
|
| - List<ExecutableElement> overrides = _inheritanceManager.lookupOverrides(classB, methodName);
|
| + MethodElementImpl methodMinB =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classB.methods = <MethodElement>[methodMinB];
|
| + List<ExecutableElement> overrides =
|
| + _inheritanceManager.lookupOverrides(classB, methodName);
|
| expect(overrides, unorderedEquals([methodMinA]));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| @@ -5177,13 +5677,16 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupOverrides_overrideInterface() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElementImpl methodMinA = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodMinA];
|
| + MethodElementImpl methodMinA =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodMinA];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - classB.interfaces = <InterfaceType> [classA.type];
|
| - MethodElementImpl methodMinB = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classB.methods = <MethodElement> [methodMinB];
|
| - List<ExecutableElement> overrides = _inheritanceManager.lookupOverrides(classB, methodName);
|
| + classB.interfaces = <InterfaceType>[classA.type];
|
| + MethodElementImpl methodMinB =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classB.methods = <MethodElement>[methodMinB];
|
| + List<ExecutableElement> overrides =
|
| + _inheritanceManager.lookupOverrides(classB, methodName);
|
| expect(overrides, unorderedEquals([methodMinA]));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| @@ -5192,25 +5695,31 @@ class InheritanceManagerTest extends EngineTestCase {
|
| void test_lookupOverrides_overrideTwoInterfaces() {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| String methodName = "m";
|
| - MethodElementImpl methodMinA = ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| - classA.methods = <MethodElement> [methodMinA];
|
| + MethodElementImpl methodMinA =
|
| + ElementFactory.methodElement(methodName, _typeProvider.intType);
|
| + classA.methods = <MethodElement>[methodMinA];
|
| ClassElementImpl classB = ElementFactory.classElement2("B");
|
| - MethodElementImpl methodMinB = ElementFactory.methodElement(methodName, _typeProvider.doubleType);
|
| - classB.methods = <MethodElement> [methodMinB];
|
| + MethodElementImpl methodMinB =
|
| + ElementFactory.methodElement(methodName, _typeProvider.doubleType);
|
| + classB.methods = <MethodElement>[methodMinB];
|
| ClassElementImpl classC = ElementFactory.classElement2("C");
|
| - classC.interfaces = <InterfaceType> [classA.type, classB.type];
|
| - MethodElementImpl methodMinC = ElementFactory.methodElement(methodName, _typeProvider.numType);
|
| - classC.methods = <MethodElement> [methodMinC];
|
| - List<ExecutableElement> overrides = _inheritanceManager.lookupOverrides(classC, methodName);
|
| + classC.interfaces = <InterfaceType>[classA.type, classB.type];
|
| + MethodElementImpl methodMinC =
|
| + ElementFactory.methodElement(methodName, _typeProvider.numType);
|
| + classC.methods = <MethodElement>[methodMinC];
|
| + List<ExecutableElement> overrides =
|
| + _inheritanceManager.lookupOverrides(classC, methodName);
|
| expect(overrides, unorderedEquals([methodMinA, methodMinB]));
|
| _assertNoErrors(classA);
|
| _assertNoErrors(classB);
|
| _assertNoErrors(classC);
|
| }
|
|
|
| - void _assertErrors(ClassElement classElt, [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) {
|
| + void _assertErrors(ClassElement classElt, [List<ErrorCode> expectedErrorCodes
|
| + = ErrorCode.EMPTY_LIST]) {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| - HashSet<AnalysisError> actualErrors = _inheritanceManager.getErrors(classElt);
|
| + HashSet<AnalysisError> actualErrors =
|
| + _inheritanceManager.getErrors(classElt);
|
| if (actualErrors != null) {
|
| for (AnalysisError error in actualErrors) {
|
| errorListener.onError(error);
|
| @@ -5230,8 +5739,10 @@ class InheritanceManagerTest extends EngineTestCase {
|
| */
|
| InheritanceManager _createInheritanceManager() {
|
| AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
|
| - FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| - CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
|
| + FileBasedSource source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| + CompilationUnitElementImpl definingCompilationUnit =
|
| + new CompilationUnitElementImpl("test.dart");
|
| definingCompilationUnit.source = source;
|
| _definingLibrary = ElementFactory.library(context, "test");
|
| _definingLibrary.definingCompilationUnit = definingCompilationUnit;
|
| @@ -5245,15 +5756,34 @@ class LibraryElementBuilderTest extends EngineTestCase {
|
| */
|
| AnalysisContextImpl _context;
|
|
|
| + /**
|
| + * Add a source file to the content provider. The file path should be absolute.
|
| + *
|
| + * @param filePath the path of the file being added
|
| + * @param contents the contents to be returned by the content provider for the specified file
|
| + * @return the source object representing the added file
|
| + */
|
| + Source addSource(String filePath, String contents) {
|
| + Source source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile(filePath));
|
| + _context.setContents(source, contents);
|
| + return source;
|
| + }
|
| +
|
| @override
|
| void setUp() {
|
| - SourceFactory sourceFactory = new SourceFactory([
|
| - new DartUriResolver(DirectoryBasedDartSdk.defaultSdk),
|
| - new FileUriResolver()]);
|
| + SourceFactory sourceFactory = new SourceFactory(
|
| + [new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), new FileUriResolver()]);
|
| _context = new AnalysisContextImpl();
|
| _context.sourceFactory = sourceFactory;
|
| }
|
|
|
| + @override
|
| + void tearDown() {
|
| + _context = null;
|
| + super.tearDown();
|
| + }
|
| +
|
| void test_accessorsAcrossFiles() {
|
| Source librarySource = addSource("/lib.dart", r'''
|
| library lib;
|
| @@ -5301,7 +5831,9 @@ void set V(int v) {}''');
|
| void test_missingLibraryDirectiveWithPart() {
|
| addSource("/a.dart", "part of lib;");
|
| Source librarySource = addSource("/lib.dart", "part 'a.dart';");
|
| - LibraryElement element = _buildLibrary(librarySource, [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
|
| + LibraryElement element = _buildLibrary(
|
| + librarySource,
|
| + [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
|
| expect(element, isNotNull);
|
| }
|
|
|
| @@ -5311,7 +5843,8 @@ void set V(int v) {}''');
|
| library lib;
|
|
|
| part 'a.dart';''');
|
| - LibraryElement element = _buildLibrary(librarySource, [CompileTimeErrorCode.PART_OF_NON_PART]);
|
| + LibraryElement element =
|
| + _buildLibrary(librarySource, [CompileTimeErrorCode.PART_OF_NON_PART]);
|
| expect(element, isNotNull);
|
| }
|
|
|
| @@ -5353,25 +5886,6 @@ class A {}''');
|
| }
|
|
|
| /**
|
| - * Add a source file to the content provider. The file path should be absolute.
|
| - *
|
| - * @param filePath the path of the file being added
|
| - * @param contents the contents to be returned by the content provider for the specified file
|
| - * @return the source object representing the added file
|
| - */
|
| - Source addSource(String filePath, String contents) {
|
| - Source source = new FileBasedSource.con1(FileUtilities2.createFile(filePath));
|
| - _context.setContents(source, contents);
|
| - return source;
|
| - }
|
| -
|
| - @override
|
| - void tearDown() {
|
| - _context = null;
|
| - super.tearDown();
|
| - }
|
| -
|
| - /**
|
| * Ensure that there are elements representing all of the types in the given array of type names.
|
| *
|
| * @param unit the compilation unit containing the types
|
| @@ -5405,9 +5919,11 @@ class A {}''');
|
| * @return the element model that was built for the library
|
| * @throws Exception if the element model could not be built
|
| */
|
| - LibraryElement _buildLibrary(Source librarySource, [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) {
|
| + LibraryElement _buildLibrary(Source librarySource,
|
| + [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) {
|
| LibraryResolver resolver = new LibraryResolver(_context);
|
| - LibraryElementBuilder builder = new LibraryElementBuilder(resolver.analysisContext, resolver.errorListener);
|
| + LibraryElementBuilder builder =
|
| + new LibraryElementBuilder(resolver.analysisContext, resolver.errorListener);
|
| Library library = resolver.createLibrary(librarySource);
|
| LibraryElement element = builder.buildLibrary(library);
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| @@ -5429,24 +5945,38 @@ 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];
|
| - ImportElementImpl import1 = ElementFactory.importFor(importedLibrary1, null);
|
| + (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];
|
| - ImportElementImpl import2 = ElementFactory.importFor(importedLibrary2, null);
|
| - LibraryElementImpl importingLibrary = createTestLibrary(context, "importing");
|
| - importingLibrary.imports = <ImportElement> [import1, import2];
|
| + (importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| + <ClassElement>[typeB2, typeC];
|
| + ImportElementImpl import2 =
|
| + ElementFactory.importFor(importedLibrary2, null);
|
| + LibraryElementImpl importingLibrary =
|
| + createTestLibrary(context, "importing");
|
| + importingLibrary.imports = <ImportElement>[import1, import2];
|
| {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(importingLibrary, errorListener);
|
| - expect(scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary), typeA);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary),
|
| + typeA);
|
| errorListener.assertNoErrors();
|
| - expect(scope.lookup(AstFactory.identifier3(typeNameC), importingLibrary), typeC);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(typeNameC), importingLibrary),
|
| + typeC);
|
| errorListener.assertNoErrors();
|
| - Element element = scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary);
|
| + Element element =
|
| + scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary);
|
| errorListener.assertErrorsWithCodes([StaticWarningCode.AMBIGUOUS_IMPORT]);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, element);
|
| - List<Element> conflictingElements = (element as MultiplyDefinedElement).conflictingElements;
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is MultiplyDefinedElement,
|
| + MultiplyDefinedElement,
|
| + element);
|
| + List<Element> conflictingElements =
|
| + (element as MultiplyDefinedElement).conflictingElements;
|
| expect(conflictingElements, hasLength(2));
|
| if (identical(conflictingElements[0], typeB1)) {
|
| expect(conflictingElements[1], same(typeB2));
|
| @@ -5460,10 +5990,19 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(importingLibrary, errorListener);
|
| Identifier identifier = AstFactory.identifier3(typeNameB);
|
| - AstFactory.methodDeclaration(null, AstFactory.typeName3(identifier), null, null, AstFactory.identifier3("foo"), null);
|
| + AstFactory.methodDeclaration(
|
| + null,
|
| + AstFactory.typeName3(identifier),
|
| + null,
|
| + null,
|
| + AstFactory.identifier3("foo"),
|
| + null);
|
| Element element = scope.lookup(identifier, importingLibrary);
|
| errorListener.assertErrorsWithCodes([StaticWarningCode.AMBIGUOUS_IMPORT]);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, MultiplyDefinedElement, element);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is MultiplyDefinedElement,
|
| + MultiplyDefinedElement,
|
| + element);
|
| }
|
| }
|
|
|
| @@ -5477,22 +6016,28 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| AnalysisContext context = new AnalysisContextImpl();
|
| context.sourceFactory = new SourceFactory([]);
|
| String importedTypeName = "A";
|
| - ClassElement importedType = new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| + ClassElement importedType =
|
| + new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| LibraryElement importedLibrary = createTestLibrary(context, "imported");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types = <ClassElement> [importedType];
|
| - LibraryElementImpl definingLibrary = createTestLibrary(context, "importing");
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| + <ClassElement>[importedType];
|
| + LibraryElementImpl definingLibrary =
|
| + createTestLibrary(context, "importing");
|
| ImportElementImpl importElement = new ImportElementImpl(0);
|
| importElement.importedLibrary = importedLibrary;
|
| - definingLibrary.imports = <ImportElement> [importElement];
|
| + definingLibrary.imports = <ImportElement>[importElement];
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(definingLibrary, errorListener);
|
| - expect(scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), importedType);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary),
|
| + importedType);
|
| }
|
|
|
| void test_getErrorListener() {
|
| LibraryElement definingLibrary = createDefaultTestLibrary();
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| - LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorListener);
|
| + LibraryImportScope scope =
|
| + new LibraryImportScope(definingLibrary, errorListener);
|
| expect(scope.errorListener, errorListener);
|
| }
|
|
|
| @@ -5501,15 +6046,23 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| String typeName = "List";
|
| ClassElement type = ElementFactory.classElement2(typeName);
|
| LibraryElement importedLibrary = createTestLibrary(context, "lib");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types = <ClassElement> [type];
|
| - ImportElementImpl importCore = ElementFactory.importFor(context.getLibraryElement(context.sourceFactory.forUri("dart:core")), null);
|
| - ImportElementImpl importLib = ElementFactory.importFor(importedLibrary, null);
|
| - LibraryElementImpl importingLibrary = createTestLibrary(context, "importing");
|
| - importingLibrary.imports = <ImportElement> [importCore, importLib];
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| + <ClassElement>[type];
|
| + ImportElementImpl importCore = ElementFactory.importFor(
|
| + context.getLibraryElement(context.sourceFactory.forUri("dart:core")),
|
| + null);
|
| + ImportElementImpl importLib =
|
| + ElementFactory.importFor(importedLibrary, null);
|
| + LibraryElementImpl importingLibrary =
|
| + createTestLibrary(context, "importing");
|
| + importingLibrary.imports = <ImportElement>[importCore, importLib];
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(importingLibrary, errorListener);
|
| - expect(scope.lookup(AstFactory.identifier3(typeName), importingLibrary), type);
|
| - errorListener.assertErrorsWithCodes([StaticWarningCode.CONFLICTING_DART_IMPORT]);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(typeName), importingLibrary),
|
| + type);
|
| + errorListener.assertErrorsWithCodes(
|
| + [StaticWarningCode.CONFLICTING_DART_IMPORT]);
|
| }
|
|
|
| void test_nonConflictingImports_sameElement() {
|
| @@ -5520,16 +6073,22 @@ 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 = createTestLibrary(context, "importing");
|
| - importingLibrary.imports = <ImportElement> [import1, import2];
|
| + LibraryElementImpl importingLibrary =
|
| + createTestLibrary(context, "importing");
|
| + importingLibrary.imports = <ImportElement>[import1, import2];
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(importingLibrary, errorListener);
|
| - expect(scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary), typeA);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(typeNameA), importingLibrary),
|
| + typeA);
|
| errorListener.assertNoErrors();
|
| - expect(scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary), typeB);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(typeNameB), importingLibrary),
|
| + typeB);
|
| errorListener.assertNoErrors();
|
| }
|
|
|
| @@ -5540,20 +6099,30 @@ class LibraryImportScopeTest extends ResolverTestCase {
|
| String prefixName = "p";
|
| ClassElement prefixedType = ElementFactory.classElement2(typeName);
|
| ClassElement nonPrefixedType = ElementFactory.classElement2(typeName);
|
| - LibraryElement prefixedLibrary = createTestLibrary(context, "import.prefixed");
|
| - (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];
|
| - ImportElementImpl nonPrefixedImport = ElementFactory.importFor(nonPrefixedLibrary, null);
|
| - LibraryElementImpl importingLibrary = createTestLibrary(context, "importing");
|
| - importingLibrary.imports = <ImportElement> [prefixedImport, nonPrefixedImport];
|
| + LibraryElement prefixedLibrary =
|
| + createTestLibrary(context, "import.prefixed");
|
| + (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];
|
| + ImportElementImpl nonPrefixedImport =
|
| + ElementFactory.importFor(nonPrefixedLibrary, null);
|
| + LibraryElementImpl importingLibrary =
|
| + createTestLibrary(context, "importing");
|
| + importingLibrary.imports =
|
| + <ImportElement>[prefixedImport, nonPrefixedImport];
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryImportScope(importingLibrary, errorListener);
|
| - Element prefixedElement = scope.lookup(AstFactory.identifier5(prefixName, typeName), importingLibrary);
|
| + Element prefixedElement =
|
| + scope.lookup(AstFactory.identifier5(prefixName, typeName), importingLibrary);
|
| errorListener.assertNoErrors();
|
| expect(prefixedElement, same(prefixedType));
|
| - Element nonPrefixedElement = scope.lookup(AstFactory.identifier3(typeName), importingLibrary);
|
| + Element nonPrefixedElement =
|
| + scope.lookup(AstFactory.identifier3(typeName), importingLibrary);
|
| errorListener.assertNoErrors();
|
| expect(nonPrefixedElement, same(nonPrefixedType));
|
| }
|
| @@ -5568,7 +6137,8 @@ class LibraryResolver2Test extends ResolverTestCase {
|
| void setUp() {
|
| super.setUp();
|
| _resolver = new LibraryResolver2(analysisContext2);
|
| - _coreLibrarySource = analysisContext2.sourceFactory.forUri(DartSdk.DART_CORE);
|
| + _coreLibrarySource =
|
| + analysisContext2.sourceFactory.forUri(DartSdk.DART_CORE);
|
| }
|
|
|
| void test_imports_relative() {
|
| @@ -5582,11 +6152,12 @@ import 'test.dart
|
| class B {}''');
|
| List<ResolvableLibrary> cycle = new List<ResolvableLibrary>();
|
| ResolvableLibrary coreLib = _createResolvableLibrary(_coreLibrarySource);
|
| - coreLib.libraryElement = analysisContext2.computeLibraryElement(_coreLibrarySource) as LibraryElementImpl;
|
| + coreLib.libraryElement = analysisContext2.computeLibraryElement(
|
| + _coreLibrarySource) as LibraryElementImpl;
|
| ResolvableLibrary libA = _createResolvableLibrary(sourceA);
|
| ResolvableLibrary libB = _createResolvableLibrary(sourceB);
|
| - libA.importedLibraries = <ResolvableLibrary> [coreLib, libB];
|
| - libB.importedLibraries = <ResolvableLibrary> [coreLib, libA];
|
| + libA.importedLibraries = <ResolvableLibrary>[coreLib, libB];
|
| + libB.importedLibraries = <ResolvableLibrary>[coreLib, libA];
|
| cycle.add(libA);
|
| cycle.add(libB);
|
| LibraryElement library = _resolver.resolveLibrary(sourceA, cycle);
|
| @@ -5597,9 +6168,8 @@ class B {}''');
|
| ResolvableLibrary _createResolvableLibrary(Source source) {
|
| CompilationUnit unit = analysisContext2.parseCompilationUnit(source);
|
| ResolvableLibrary resolvableLibrary = new ResolvableLibrary(source);
|
| - resolvableLibrary.resolvableCompilationUnits = <ResolvableCompilationUnit>[
|
| - new ResolvableCompilationUnit(source, unit)
|
| - ];
|
| + resolvableLibrary.resolvableCompilationUnits =
|
| + <ResolvableCompilationUnit>[new ResolvableCompilationUnit(source, unit)];
|
| return resolvableLibrary;
|
| }
|
| }
|
| @@ -5655,16 +6225,21 @@ class LibraryScopeTest extends ResolverTestCase {
|
| AnalysisContext context = new AnalysisContextImpl();
|
| context.sourceFactory = new SourceFactory([]);
|
| String importedTypeName = "A";
|
| - ClassElement importedType = new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| + ClassElement importedType =
|
| + new ClassElementImpl.forNode(AstFactory.identifier3(importedTypeName));
|
| LibraryElement importedLibrary = createTestLibrary(context, "imported");
|
| - (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types = <ClassElement> [importedType];
|
| - LibraryElementImpl definingLibrary = createTestLibrary(context, "importing");
|
| + (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).types =
|
| + <ClassElement>[importedType];
|
| + LibraryElementImpl definingLibrary =
|
| + createTestLibrary(context, "importing");
|
| ImportElementImpl importElement = new ImportElementImpl(0);
|
| importElement.importedLibrary = importedLibrary;
|
| - definingLibrary.imports = <ImportElement> [importElement];
|
| + definingLibrary.imports = <ImportElement>[importElement];
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| Scope scope = new LibraryScope(definingLibrary, errorListener);
|
| - expect(scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary), importedType);
|
| + expect(
|
| + scope.lookup(AstFactory.identifier3(importedTypeName), definingLibrary),
|
| + importedType);
|
| }
|
|
|
| void test_getErrorListener() {
|
| @@ -5705,6 +6280,15 @@ class LibraryTest extends EngineTestCase {
|
| _library = _createLibrary("/lib.dart");
|
| }
|
|
|
| + @override
|
| + void tearDown() {
|
| + _errorListener = null;
|
| + _sourceFactory = null;
|
| + _analysisContext = null;
|
| + _library = null;
|
| + super.tearDown();
|
| + }
|
| +
|
| void test_getExplicitlyImportsCore() {
|
| expect(_library.explicitlyImportsCore, isFalse);
|
| _errorListener.assertNoErrors();
|
| @@ -5721,15 +6305,18 @@ class LibraryTest extends EngineTestCase {
|
| }
|
|
|
| void test_getImportsAndExports() {
|
| - _library.importedLibraries = <Library> [_createLibrary("/imported.dart")];
|
| - _library.exportedLibraries = <Library> [_createLibrary("/exported.dart")];
|
| + _library.importedLibraries = <Library>[_createLibrary("/imported.dart")];
|
| + _library.exportedLibraries = <Library>[_createLibrary("/exported.dart")];
|
| expect(_library.importsAndExports, hasLength(2));
|
| _errorListener.assertNoErrors();
|
| }
|
|
|
| void test_getLibraryScope() {
|
| - LibraryElementImpl element = new LibraryElementImpl.forNode(_analysisContext, AstFactory.libraryIdentifier2(["lib"]));
|
| - element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart");
|
| + LibraryElementImpl element = new LibraryElementImpl.forNode(
|
| + _analysisContext,
|
| + AstFactory.libraryIdentifier2(["lib"]));
|
| + element.definingCompilationUnit =
|
| + new CompilationUnitElementImpl("lib.dart");
|
| _library.libraryElement = element;
|
| expect(_library.libraryScope, isNotNull);
|
| _errorListener.assertNoErrors();
|
| @@ -5747,7 +6334,7 @@ class LibraryTest extends EngineTestCase {
|
|
|
| void test_setExportedLibraries() {
|
| Library exportLibrary = _createLibrary("/exported.dart");
|
| - _library.exportedLibraries = <Library> [exportLibrary];
|
| + _library.exportedLibraries = <Library>[exportLibrary];
|
| List<Library> exports = _library.exports;
|
| expect(exports, hasLength(1));
|
| expect(exports[0], same(exportLibrary));
|
| @@ -5756,7 +6343,7 @@ class LibraryTest extends EngineTestCase {
|
|
|
| void test_setImportedLibraries() {
|
| Library importLibrary = _createLibrary("/imported.dart");
|
| - _library.importedLibraries = <Library> [importLibrary];
|
| + _library.importedLibraries = <Library>[importLibrary];
|
| List<Library> imports = _library.imports;
|
| expect(imports, hasLength(1));
|
| expect(imports[0], same(importLibrary));
|
| @@ -5764,21 +6351,19 @@ class LibraryTest extends EngineTestCase {
|
| }
|
|
|
| void test_setLibraryElement() {
|
| - LibraryElementImpl element = new LibraryElementImpl.forNode(_analysisContext, AstFactory.libraryIdentifier2(["lib"]));
|
| + LibraryElementImpl element = new LibraryElementImpl.forNode(
|
| + _analysisContext,
|
| + AstFactory.libraryIdentifier2(["lib"]));
|
| _library.libraryElement = element;
|
| expect(_library.libraryElement, same(element));
|
| }
|
|
|
| - @override
|
| - void tearDown() {
|
| - _errorListener = null;
|
| - _sourceFactory = null;
|
| - _analysisContext = null;
|
| - _library = null;
|
| - super.tearDown();
|
| - }
|
| -
|
| - Library _createLibrary(String definingCompilationUnitPath) => new Library(_analysisContext, _errorListener, new FileBasedSource.con1(FileUtilities2.createFile(definingCompilationUnitPath)));
|
| + Library _createLibrary(String definingCompilationUnitPath) =>
|
| + new Library(
|
| + _analysisContext,
|
| + _errorListener,
|
| + new FileBasedSource.con1(
|
| + FileUtilities2.createFile(definingCompilationUnitPath)));
|
| }
|
|
|
| class MemberMapTest {
|
| @@ -6044,14 +6629,14 @@ class B {}''');
|
| }
|
|
|
| void test_importDeferredLibraryWithLoadFunction() {
|
| - resolveWithAndWithoutExperimental(<String> [
|
| - r'''
|
| + resolveWithAndWithoutExperimental(<String>[r'''
|
| library lib1;
|
| -f() {}''',
|
| - r'''
|
| +f() {}''', r'''
|
| library root;
|
| import 'lib1.dart' deferred as lib1;
|
| -main() { lib1.f(); }'''], <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], ErrorCode.EMPTY_LIST);
|
| +main() { lib1.f(); }'''],
|
| + <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
|
| + ErrorCode.EMPTY_LIST);
|
| }
|
|
|
| void test_issue20904BuggyTypePromotionAtIfJoin_1() {
|
| @@ -6631,11 +7216,11 @@ class Two {}''');
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedImport_export_infiniteLoop() {
|
| + void test_unusedImport_export2() {
|
| Source source = addSource(r'''
|
| library L;
|
| import 'lib1.dart';
|
| -Two two;''');
|
| +Three three;''');
|
| addNamedSource("/lib1.dart", r'''
|
| library lib1;
|
| export 'lib2.dart';
|
| @@ -6646,18 +7231,17 @@ export 'lib3.dart';
|
| class Two {}''');
|
| addNamedSource("/lib3.dart", r'''
|
| library lib3;
|
| -export 'lib2.dart';
|
| class Three {}''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| verify([source]);
|
| }
|
|
|
| - void test_unusedImport_export2() {
|
| + void test_unusedImport_export_infiniteLoop() {
|
| Source source = addSource(r'''
|
| library L;
|
| import 'lib1.dart';
|
| -Three three;''');
|
| +Two two;''');
|
| addNamedSource("/lib1.dart", r'''
|
| library lib1;
|
| export 'lib2.dart';
|
| @@ -6668,6 +7252,7 @@ export 'lib3.dart';
|
| class Two {}''');
|
| addNamedSource("/lib3.dart", r'''
|
| library lib3;
|
| +export 'lib2.dart';
|
| class Three {}''');
|
| resolve(source);
|
| assertNoErrors(source);
|
| @@ -6746,30 +7331,38 @@ class PubSuggestionCodeTest extends ResolverTestCase {
|
| void test_import_packageWithDotDot() {
|
| Source source = addSource("import 'package:somepackage/../other.dart';");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| - HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| + HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
|
| }
|
|
|
| void test_import_packageWithLeadingDotDot() {
|
| Source source = addSource("import 'package:../other.dart';");
|
| resolve(source);
|
| - assertErrors(source, [
|
| - CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| - HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
|
| + assertErrors(
|
| + source,
|
| + [
|
| + CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| + HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
|
| }
|
|
|
| void test_import_referenceIntoLibDirectory() {
|
| cacheSource("/myproj/pubspec.yaml", "");
|
| cacheSource("/myproj/lib/other.dart", "");
|
| - Source source = addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
|
| resolve(source);
|
| - assertErrors(source, [HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]);
|
| + assertErrors(
|
| + source,
|
| + [HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]);
|
| }
|
|
|
| void test_import_referenceIntoLibDirectory_no_pubspec() {
|
| cacheSource("/myproj/lib/other.dart", "");
|
| - Source source = addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/web/test.dart", "import '../lib/other.dart';");
|
| resolve(source);
|
| assertNoErrors(source);
|
| }
|
| @@ -6777,14 +7370,18 @@ class PubSuggestionCodeTest extends ResolverTestCase {
|
| void test_import_referenceOutOfLibDirectory() {
|
| cacheSource("/myproj/pubspec.yaml", "");
|
| cacheSource("/myproj/web/other.dart", "");
|
| - Source source = addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
|
| resolve(source);
|
| - assertErrors(source, [HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]);
|
| + assertErrors(
|
| + source,
|
| + [HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]);
|
| }
|
|
|
| void test_import_referenceOutOfLibDirectory_no_pubspec() {
|
| cacheSource("/myproj/web/other.dart", "");
|
| - Source source = addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/lib/test.dart", "import '../web/other.dart';");
|
| resolve(source);
|
| assertNoErrors(source);
|
| }
|
| @@ -6792,7 +7389,8 @@ class PubSuggestionCodeTest extends ResolverTestCase {
|
| void test_import_valid_inside_lib1() {
|
| cacheSource("/myproj/pubspec.yaml", "");
|
| cacheSource("/myproj/lib/other.dart", "");
|
| - Source source = addNamedSource("/myproj/lib/test.dart", "import 'other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/lib/test.dart", "import 'other.dart';");
|
| resolve(source);
|
| assertNoErrors(source);
|
| }
|
| @@ -6800,7 +7398,8 @@ class PubSuggestionCodeTest extends ResolverTestCase {
|
| void test_import_valid_inside_lib2() {
|
| cacheSource("/myproj/pubspec.yaml", "");
|
| cacheSource("/myproj/lib/bar/other.dart", "");
|
| - Source source = addNamedSource("/myproj/lib/foo/test.dart", "import '../bar/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/lib/foo/test.dart", "import '../bar/other.dart';");
|
| resolve(source);
|
| assertNoErrors(source);
|
| }
|
| @@ -6808,40 +7407,13 @@ class PubSuggestionCodeTest extends ResolverTestCase {
|
| void test_import_valid_outside_lib() {
|
| cacheSource("/myproj/pubspec.yaml", "");
|
| cacheSource("/myproj/web/other.dart", "");
|
| - Source source = addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';");
|
| + Source source =
|
| + addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';");
|
| resolve(source);
|
| assertNoErrors(source);
|
| }
|
| }
|
|
|
| -class RecursiveAstVisitor_SimpleResolverTest_test_localVariable_types_invoked extends RecursiveAstVisitor<Object> {
|
| - final SimpleResolverTest SimpleResolverTest_this;
|
| -
|
| - List<bool> found;
|
| -
|
| - List<CaughtException> thrownException;
|
| -
|
| - RecursiveAstVisitor_SimpleResolverTest_test_localVariable_types_invoked(this.SimpleResolverTest_this, this.found, this.thrownException) : super();
|
| -
|
| - @override
|
| - Object visitSimpleIdentifier(SimpleIdentifier node) {
|
| - if (node.name == "myVar" && node.parent is MethodInvocation) {
|
| - try {
|
| - found[0] = true;
|
| - // check static type
|
| - DartType staticType = node.staticType;
|
| - expect(staticType, same(SimpleResolverTest_this.typeProvider.dynamicType));
|
| - // check propagated type
|
| - FunctionType propagatedType = node.propagatedType as FunctionType;
|
| - expect(propagatedType.returnType, SimpleResolverTest_this.typeProvider.stringType);
|
| - } on AnalysisException catch (e, stackTrace) {
|
| - thrownException[0] = new CaughtException(e, stackTrace);
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -}
|
| -
|
| /**
|
| * Instances of the class `ResolutionVerifier` verify that all of the nodes in an AST
|
| * structure that should have been resolved were resolved.
|
| @@ -6926,7 +7498,10 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| if (operandType == null || operandType.isDynamic) {
|
| return null;
|
| }
|
| - return _checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
| + return _checkResolved(
|
| + node,
|
| + node.staticElement,
|
| + (node) => node is MethodElement);
|
| }
|
|
|
| @override
|
| @@ -6935,11 +7510,15 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| @override
|
| Object visitCompilationUnit(CompilationUnit node) {
|
| node.visitChildren(this);
|
| - return _checkResolved(node, node.element, (node) => node is CompilationUnitElement);
|
| + return _checkResolved(
|
| + node,
|
| + node.element,
|
| + (node) => node is CompilationUnitElement);
|
| }
|
|
|
| @override
|
| - Object visitExportDirective(ExportDirective node) => _checkResolved(node, node.element, (node) => node is ExportElement);
|
| + Object visitExportDirective(ExportDirective node) =>
|
| + _checkResolved(node, node.element, (node) => node is ExportElement);
|
|
|
| @override
|
| Object visitFunctionDeclaration(FunctionDeclaration node) {
|
| @@ -6953,21 +7532,25 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| @override
|
| Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
|
| node.visitChildren(this);
|
| - // TODO(brianwilkerson) If we start resolving function expressions, then conditionally check to
|
| - // see whether the node was resolved correctly.
|
| + // TODO(brianwilkerson) If we start resolving function expressions, then
|
| + // conditionally check to see whether the node was resolved correctly.
|
| return null;
|
| //checkResolved(node, node.getElement(), FunctionElement.class);
|
| }
|
|
|
| @override
|
| Object visitImportDirective(ImportDirective node) {
|
| - // Not sure how to test the combinators given that it isn't an error if the names are not defined.
|
| + // Not sure how to test the combinators given that it isn't an error if the
|
| + // names are not defined.
|
| _checkResolved(node, node.element, (node) => node is ImportElement);
|
| SimpleIdentifier prefix = node.prefix;
|
| if (prefix == null) {
|
| return null;
|
| }
|
| - return _checkResolved(prefix, prefix.staticElement, (node) => node is PrefixElement);
|
| + return _checkResolved(
|
| + prefix,
|
| + prefix.staticElement,
|
| + (node) => node is PrefixElement);
|
| }
|
|
|
| @override
|
| @@ -6977,20 +7560,27 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| if (targetType == null || targetType.isDynamic) {
|
| return null;
|
| }
|
| - return _checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
| + return _checkResolved(
|
| + node,
|
| + node.staticElement,
|
| + (node) => node is MethodElement);
|
| }
|
|
|
| @override
|
| - Object visitLibraryDirective(LibraryDirective node) => _checkResolved(node, node.element, (node) => node is LibraryElement);
|
| + Object visitLibraryDirective(LibraryDirective node) =>
|
| + _checkResolved(node, node.element, (node) => node is LibraryElement);
|
|
|
| @override
|
| - Object visitNamedExpression(NamedExpression node) => node.expression.accept(this);
|
| + Object visitNamedExpression(NamedExpression node) =>
|
| + node.expression.accept(this);
|
|
|
| @override
|
| - Object visitPartDirective(PartDirective node) => _checkResolved(node, node.element, (node) => node is CompilationUnitElement);
|
| + Object visitPartDirective(PartDirective node) =>
|
| + _checkResolved(node, node.element, (node) => node is CompilationUnitElement);
|
|
|
| @override
|
| - Object visitPartOfDirective(PartOfDirective node) => _checkResolved(node, node.element, (node) => node is LibraryElement);
|
| + Object visitPartOfDirective(PartOfDirective node) =>
|
| + _checkResolved(node, node.element, (node) => node is LibraryElement);
|
|
|
| @override
|
| Object visitPostfixExpression(PostfixExpression node) {
|
| @@ -7002,7 +7592,10 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| if (operandType == null || operandType.isDynamic) {
|
| return null;
|
| }
|
| - return _checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
| + return _checkResolved(
|
| + node,
|
| + node.staticElement,
|
| + (node) => node is MethodElement);
|
| }
|
|
|
| @override
|
| @@ -7026,7 +7619,10 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| if (operandType == null || operandType.isDynamic) {
|
| return null;
|
| }
|
| - return _checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
| + return _checkResolved(
|
| + node,
|
| + node.staticElement,
|
| + (node) => node is MethodElement);
|
| }
|
|
|
| @override
|
| @@ -7059,7 +7655,8 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| return _checkResolved(node, node.staticElement, null);
|
| }
|
|
|
| - Object _checkResolved(AstNode node, Element element, Predicate<Element> predicate) {
|
| + Object _checkResolved(AstNode node, Element element,
|
| + Predicate<Element> predicate) {
|
| if (element == null) {
|
| if (_knownExceptions == null || !_knownExceptions.contains(node)) {
|
| _unresolvedNodes.add(node);
|
| @@ -7073,8 +7670,8 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| String _getFileName(AstNode node) {
|
| - // TODO (jwren) there are two copies of this method, one here and one in StaticTypeVerifier,
|
| - // they should be resolved into a single method
|
| + // TODO (jwren) there are two copies of this method, one here and one in
|
| + // StaticTypeVerifier, they should be resolved into a single method
|
| if (node != null) {
|
| AstNode root = node.root;
|
| if (root is CompilationUnit) {
|
| @@ -7085,7 +7682,8 @@ class ResolutionVerifier extends RecursiveAstVisitor<Object> {
|
| return "<unknown file- CompilationUnit.getElement() returned null>";
|
| }
|
| } else {
|
| - return "<unknown file- CompilationUnit.getRoot() is not a CompilationUnit>";
|
| + return
|
| + "<unknown file- CompilationUnit.getRoot() is not a CompilationUnit>";
|
| }
|
| }
|
| return "<unknown file- ASTNode is null>";
|
| @@ -7121,10 +7719,15 @@ class ResolverTestCase extends EngineTestCase {
|
| */
|
| bool enableUnusedLocalVariable = false;
|
|
|
| - @override
|
| - void setUp() {
|
| - reset();
|
| - }
|
| + AnalysisContext get analysisContext => analysisContext2;
|
| +
|
| + /**
|
| + * Return a type provider that can be used to test the results of resolution.
|
| + *
|
| + * @return a type provider
|
| + * @throws AnalysisException if dart:core cannot be resolved
|
| + */
|
| + TypeProvider get typeProvider => analysisContext2.typeProvider;
|
|
|
| /**
|
| * Add a source file to the content provider. The file path should be absolute.
|
| @@ -7160,7 +7763,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @throws AssertionFailedError if a different number of errors have been reported than were
|
| * expected
|
| */
|
| - void assertErrors(Source source, [List<ErrorCode> expectedErrorCodes = ErrorCode.EMPTY_LIST]) {
|
| + void assertErrors(Source source, [List<ErrorCode> expectedErrorCodes =
|
| + ErrorCode.EMPTY_LIST]) {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| for (AnalysisError error in analysisContext2.computeErrors(source)) {
|
| ErrorCode errorCode = error.errorCode;
|
| @@ -7197,7 +7801,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @return the source object representing the cached file
|
| */
|
| Source cacheSource(String filePath, String contents) {
|
| - Source source = new FileBasedSource.con1(FileUtilities2.createFile(filePath));
|
| + Source source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile(filePath));
|
| analysisContext2.setContents(source, contents);
|
| return source;
|
| }
|
| @@ -7208,7 +7813,8 @@ class ResolverTestCase extends EngineTestCase {
|
| *
|
| * @return the library element that was created
|
| */
|
| - LibraryElementImpl createDefaultTestLibrary() => createTestLibrary(new AnalysisContextImpl(), "test");
|
| + LibraryElementImpl createDefaultTestLibrary() =>
|
| + createTestLibrary(new AnalysisContextImpl(), "test");
|
|
|
| /**
|
| * Create a library element that represents a library with the given name containing a single
|
| @@ -7217,7 +7823,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @param libraryName the name of the library to be created
|
| * @return the library element that was created
|
| */
|
| - LibraryElementImpl createTestLibrary(AnalysisContext context, String libraryName, [List<String> typeNames]) {
|
| + LibraryElementImpl createTestLibrary(AnalysisContext context,
|
| + String libraryName, [List<String> typeNames]) {
|
| List<CompilationUnitElement> sourcedCompilationUnits;
|
| if (typeNames == null) {
|
| sourcedCompilationUnits = CompilationUnitElementImpl.EMPTY_ARRAY;
|
| @@ -7226,18 +7833,23 @@ class ResolverTestCase extends EngineTestCase {
|
| sourcedCompilationUnits = new List<CompilationUnitElement>(count);
|
| for (int i = 0; i < count; i++) {
|
| String typeName = typeNames[i];
|
| - ClassElementImpl type = new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
|
| + ClassElementImpl type =
|
| + new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
|
| String fileName = "$typeName.dart";
|
| - CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl(fileName);
|
| + CompilationUnitElementImpl compilationUnit =
|
| + new CompilationUnitElementImpl(fileName);
|
| compilationUnit.source = _createNamedSource(fileName);
|
| - compilationUnit.types = <ClassElement> [type];
|
| + compilationUnit.types = <ClassElement>[type];
|
| sourcedCompilationUnits[i] = compilationUnit;
|
| }
|
| }
|
| String fileName = "$libraryName.dart";
|
| - CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl(fileName);
|
| + CompilationUnitElementImpl compilationUnit =
|
| + new CompilationUnitElementImpl(fileName);
|
| compilationUnit.source = _createNamedSource(fileName);
|
| - LibraryElementImpl library = new LibraryElementImpl.forNode(context, AstFactory.libraryIdentifier2([libraryName]));
|
| + LibraryElementImpl library = new LibraryElementImpl.forNode(
|
| + context,
|
| + AstFactory.libraryIdentifier2([libraryName]));
|
| library.definingCompilationUnit = compilationUnit;
|
| library.parts = sourcedCompilationUnits;
|
| return library;
|
| @@ -7253,9 +7865,12 @@ class ResolverTestCase extends EngineTestCase {
|
| AnalysisEngine.instance.strictUnionTypes = strictUnionTypes;
|
| }
|
|
|
| - Expression findTopLevelConstantExpression(CompilationUnit compilationUnit, String name) => findTopLevelDeclaration(compilationUnit, name).initializer;
|
| + Expression findTopLevelConstantExpression(CompilationUnit compilationUnit,
|
| + String name) =>
|
| + findTopLevelDeclaration(compilationUnit, name).initializer;
|
|
|
| - VariableDeclaration findTopLevelDeclaration(CompilationUnit compilationUnit, String name) {
|
| + VariableDeclaration findTopLevelDeclaration(CompilationUnit compilationUnit,
|
| + String name) {
|
| for (CompilationUnitMember member in compilationUnit.declarations) {
|
| if (member is TopLevelVariableDeclaration) {
|
| for (VariableDeclaration variable in member.variables.variables) {
|
| @@ -7269,16 +7884,6 @@ class ResolverTestCase extends EngineTestCase {
|
| // Not found
|
| }
|
|
|
| - AnalysisContext get analysisContext => analysisContext2;
|
| -
|
| - /**
|
| - * Return a type provider that can be used to test the results of resolution.
|
| - *
|
| - * @return a type provider
|
| - * @throws AnalysisException if dart:core cannot be resolved
|
| - */
|
| - TypeProvider get typeProvider => analysisContext2.typeProvider;
|
| -
|
| /**
|
| * In the rare cases we want to group several tests into single "test_" method, so need a way to
|
| * reset test instance to reuse it.
|
| @@ -7297,7 +7902,8 @@ class ResolverTestCase extends EngineTestCase {
|
| void resetWithAsync() {
|
| AnalysisOptionsImpl options = new AnalysisOptionsImpl();
|
| options.enableAsync = true;
|
| - analysisContext2 = AnalysisContextFactory.contextWithCoreAndOptions(options);
|
| + analysisContext2 =
|
| + AnalysisContextFactory.contextWithCoreAndOptions(options);
|
| }
|
|
|
| /**
|
| @@ -7306,7 +7912,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @param options the analysis options to be applied to the context
|
| */
|
| void resetWithOptions(AnalysisOptions options) {
|
| - analysisContext2 = AnalysisContextFactory.contextWithCoreAndOptions(options);
|
| + analysisContext2 =
|
| + AnalysisContextFactory.contextWithCoreAndOptions(options);
|
| }
|
|
|
| /**
|
| @@ -7318,7 +7925,8 @@ class ResolverTestCase extends EngineTestCase {
|
| * @return the element representing the resolved library
|
| * @throws AnalysisException if the analysis could not be performed
|
| */
|
| - LibraryElement resolve(Source librarySource) => analysisContext2.computeLibraryElement(librarySource);
|
| + LibraryElement resolve(Source librarySource) =>
|
| + analysisContext2.computeLibraryElement(librarySource);
|
|
|
| /**
|
| * Return the resolved compilation unit corresponding to the given source in the given library.
|
| @@ -7328,9 +7936,12 @@ class ResolverTestCase extends EngineTestCase {
|
| * @return the resolved compilation unit
|
| * @throws Exception if the compilation unit could not be resolved
|
| */
|
| - CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => analysisContext2.resolveCompilationUnit(source, library);
|
| + CompilationUnit resolveCompilationUnit(Source source,
|
| + LibraryElement library) =>
|
| + analysisContext2.resolveCompilationUnit(source, library);
|
|
|
| - CompilationUnit resolveSource(String sourceText) => resolveSource2("/test.dart", sourceText);
|
| + CompilationUnit resolveSource(String sourceText) =>
|
| + resolveSource2("/test.dart", sourceText);
|
|
|
| CompilationUnit resolveSource2(String fileName, String sourceText) {
|
| Source source = addNamedSource(fileName, sourceText);
|
| @@ -7340,7 +7951,8 @@ class ResolverTestCase extends EngineTestCase {
|
|
|
| Source resolveSources(List<String> sourceTexts) {
|
| for (int i = 0; i < sourceTexts.length; i++) {
|
| - CompilationUnit unit = resolveSource2("/lib${i + 1}.dart", sourceTexts[i]);
|
| + CompilationUnit unit =
|
| + resolveSource2("/lib${i + 1}.dart", sourceTexts[i]);
|
| // reference the source if this is the last source
|
| if (i + 1 == sourceTexts.length) {
|
| return unit.element.source;
|
| @@ -7349,7 +7961,9 @@ class ResolverTestCase extends EngineTestCase {
|
| return null;
|
| }
|
|
|
| - void resolveWithAndWithoutExperimental(List<String> strSources, List<ErrorCode> codesWithoutExperimental, List<ErrorCode> codesWithExperimental) {
|
| + void resolveWithAndWithoutExperimental(List<String> strSources,
|
| + List<ErrorCode> codesWithoutExperimental,
|
| + List<ErrorCode> codesWithExperimental) {
|
| // Setup analysis context as non-experimental
|
| AnalysisOptionsImpl options = new AnalysisOptionsImpl();
|
| options.enableDeferredLoading = false;
|
| @@ -7367,6 +7981,11 @@ class ResolverTestCase extends EngineTestCase {
|
| }
|
|
|
| @override
|
| + void setUp() {
|
| + reset();
|
| + }
|
| +
|
| + @override
|
| void tearDown() {
|
| analysisContext2 = null;
|
| super.tearDown();
|
| @@ -7396,77 +8015,152 @@ class ResolverTestCase extends EngineTestCase {
|
| * @return the source that was created
|
| */
|
| FileBasedSource _createNamedSource(String fileName) {
|
| - FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile(fileName));
|
| + FileBasedSource source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile(fileName));
|
| analysisContext2.setContents(source, "");
|
| return source;
|
| }
|
| }
|
|
|
| +class Scope_EnclosedScopeTest_test_define_duplicate extends Scope {
|
| + GatheringErrorListener listener;
|
| +
|
| + Scope_EnclosedScopeTest_test_define_duplicate(this.listener) : super();
|
| +
|
| + @override
|
| + AnalysisErrorListener get errorListener => listener;
|
| +
|
| + @override
|
| + Element internalLookup(Identifier identifier, String name,
|
| + LibraryElement referencingLibrary) =>
|
| + null;
|
| +}
|
| +
|
| +class Scope_EnclosedScopeTest_test_define_normal extends Scope {
|
| + GatheringErrorListener listener;
|
| +
|
| + Scope_EnclosedScopeTest_test_define_normal(this.listener) : super();
|
| +
|
| + @override
|
| + AnalysisErrorListener get errorListener => listener;
|
| +
|
| + @override
|
| + Element internalLookup(Identifier identifier, String name,
|
| + LibraryElement referencingLibrary) =>
|
| + null;
|
| +}
|
| +
|
| class ScopeBuilderTest extends EngineTestCase {
|
| void test_scopeFor_ClassDeclaration() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedClassDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is LibraryScope, LibraryScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedClassDeclaration(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryScope,
|
| + LibraryScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_ClassTypeAlias() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedClassTypeAlias(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is LibraryScope, LibraryScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedClassTypeAlias(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryScope,
|
| + LibraryScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_CompilationUnit() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedCompilationUnit(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is LibraryScope, LibraryScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedCompilationUnit(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryScope,
|
| + LibraryScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_ConstructorDeclaration() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedConstructorDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is ClassScope, ClassScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedConstructorDeclaration(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is ClassScope,
|
| + ClassScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_ConstructorDeclaration_parameters() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedConstructorDeclaration().parameters, listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionScope, FunctionScope, scope);
|
| + Scope scope = ScopeBuilder.scopeFor(
|
| + _createResolvedConstructorDeclaration().parameters,
|
| + listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is FunctionScope,
|
| + FunctionScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_FunctionDeclaration() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedFunctionDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is LibraryScope, LibraryScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedFunctionDeclaration(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryScope,
|
| + LibraryScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_FunctionDeclaration_parameters() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedFunctionDeclaration().functionExpression.parameters, listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionScope, FunctionScope, scope);
|
| + Scope scope = ScopeBuilder.scopeFor(
|
| + _createResolvedFunctionDeclaration().functionExpression.parameters,
|
| + listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is FunctionScope,
|
| + FunctionScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_FunctionTypeAlias() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is LibraryScope, LibraryScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryScope,
|
| + LibraryScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_FunctionTypeAlias_parameters() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias().parameters, listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionTypeScope, FunctionTypeScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias().parameters, listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is FunctionTypeScope,
|
| + FunctionTypeScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_MethodDeclaration() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedMethodDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is ClassScope, ClassScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedMethodDeclaration(), listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is ClassScope,
|
| + ClassScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_MethodDeclaration_body() {
|
| GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(_createResolvedMethodDeclaration().body, listener);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionScope, FunctionScope, scope);
|
| + Scope scope =
|
| + ScopeBuilder.scopeFor(_createResolvedMethodDeclaration().body, listener);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is FunctionScope,
|
| + FunctionScope,
|
| + scope);
|
| }
|
|
|
| void test_scopeFor_notInCompilationUnit() {
|
| @@ -7502,28 +8196,43 @@ class ScopeBuilderTest extends EngineTestCase {
|
| ClassDeclaration _createResolvedClassDeclaration() {
|
| CompilationUnit unit = _createResolvedCompilationUnit();
|
| String className = "C";
|
| - ClassDeclaration classNode = AstFactory.classDeclaration(null, className, AstFactory.typeParameterList(), null, null, null);
|
| + ClassDeclaration classNode = AstFactory.classDeclaration(
|
| + null,
|
| + className,
|
| + AstFactory.typeParameterList(),
|
| + null,
|
| + null,
|
| + null);
|
| unit.declarations.add(classNode);
|
| ClassElement classElement = ElementFactory.classElement2(className);
|
| classNode.name.staticElement = classElement;
|
| - (unit.element as CompilationUnitElementImpl).types = <ClassElement> [classElement];
|
| + (unit.element as CompilationUnitElementImpl).types =
|
| + <ClassElement>[classElement];
|
| return classNode;
|
| }
|
|
|
| ClassTypeAlias _createResolvedClassTypeAlias() {
|
| CompilationUnit unit = _createResolvedCompilationUnit();
|
| String className = "C";
|
| - ClassTypeAlias classNode = AstFactory.classTypeAlias(className, AstFactory.typeParameterList(), null, null, null, null);
|
| + ClassTypeAlias classNode = AstFactory.classTypeAlias(
|
| + className,
|
| + AstFactory.typeParameterList(),
|
| + null,
|
| + null,
|
| + null,
|
| + null);
|
| unit.declarations.add(classNode);
|
| ClassElement classElement = ElementFactory.classElement2(className);
|
| classNode.name.staticElement = classElement;
|
| - (unit.element as CompilationUnitElementImpl).types = <ClassElement> [classElement];
|
| + (unit.element as CompilationUnitElementImpl).types =
|
| + <ClassElement>[classElement];
|
| return classNode;
|
| }
|
|
|
| CompilationUnit _createResolvedCompilationUnit() {
|
| CompilationUnit unit = AstFactory.compilationUnit();
|
| - LibraryElementImpl library = ElementFactory.library(AnalysisContextFactory.contextWithCore(), "lib");
|
| + LibraryElementImpl library =
|
| + ElementFactory.library(AnalysisContextFactory.contextWithCore(), "lib");
|
| unit.element = library.definingCompilationUnit;
|
| return unit;
|
| }
|
| @@ -7531,44 +8240,70 @@ class ScopeBuilderTest extends EngineTestCase {
|
| ConstructorDeclaration _createResolvedConstructorDeclaration() {
|
| ClassDeclaration classNode = _createResolvedClassDeclaration();
|
| String constructorName = "f";
|
| - ConstructorDeclaration constructorNode = AstFactory.constructorDeclaration(AstFactory.identifier3(constructorName), null, AstFactory.formalParameterList(), null);
|
| + ConstructorDeclaration constructorNode = AstFactory.constructorDeclaration(
|
| + AstFactory.identifier3(constructorName),
|
| + null,
|
| + AstFactory.formalParameterList(),
|
| + null);
|
| classNode.members.add(constructorNode);
|
| - ConstructorElement constructorElement = ElementFactory.constructorElement2(classNode.element, null);
|
| + ConstructorElement constructorElement =
|
| + ElementFactory.constructorElement2(classNode.element, null);
|
| constructorNode.element = constructorElement;
|
| - (classNode.element as ClassElementImpl).constructors = <ConstructorElement> [constructorElement];
|
| + (classNode.element as ClassElementImpl).constructors =
|
| + <ConstructorElement>[constructorElement];
|
| return constructorNode;
|
| }
|
|
|
| FunctionDeclaration _createResolvedFunctionDeclaration() {
|
| CompilationUnit unit = _createResolvedCompilationUnit();
|
| String functionName = "f";
|
| - FunctionDeclaration functionNode = AstFactory.functionDeclaration(null, null, functionName, AstFactory.functionExpression());
|
| + FunctionDeclaration functionNode = AstFactory.functionDeclaration(
|
| + null,
|
| + null,
|
| + functionName,
|
| + AstFactory.functionExpression());
|
| unit.declarations.add(functionNode);
|
| - FunctionElement functionElement = ElementFactory.functionElement(functionName);
|
| + FunctionElement functionElement =
|
| + ElementFactory.functionElement(functionName);
|
| functionNode.name.staticElement = functionElement;
|
| - (unit.element as CompilationUnitElementImpl).functions = <FunctionElement> [functionElement];
|
| + (unit.element as CompilationUnitElementImpl).functions =
|
| + <FunctionElement>[functionElement];
|
| return functionNode;
|
| }
|
|
|
| FunctionTypeAlias _createResolvedFunctionTypeAlias() {
|
| CompilationUnit unit = _createResolvedCompilationUnit();
|
| - FunctionTypeAlias aliasNode = AstFactory.typeAlias(AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(), AstFactory.formalParameterList());
|
| + FunctionTypeAlias aliasNode = AstFactory.typeAlias(
|
| + AstFactory.typeName4("A"),
|
| + "F",
|
| + AstFactory.typeParameterList(),
|
| + AstFactory.formalParameterList());
|
| unit.declarations.add(aliasNode);
|
| SimpleIdentifier aliasName = aliasNode.name;
|
| - FunctionTypeAliasElement aliasElement = new FunctionTypeAliasElementImpl.forNode(aliasName);
|
| + FunctionTypeAliasElement aliasElement =
|
| + new FunctionTypeAliasElementImpl.forNode(aliasName);
|
| aliasName.staticElement = aliasElement;
|
| - (unit.element as CompilationUnitElementImpl).typeAliases = <FunctionTypeAliasElement> [aliasElement];
|
| + (unit.element as CompilationUnitElementImpl).typeAliases =
|
| + <FunctionTypeAliasElement>[aliasElement];
|
| return aliasNode;
|
| }
|
|
|
| MethodDeclaration _createResolvedMethodDeclaration() {
|
| ClassDeclaration classNode = _createResolvedClassDeclaration();
|
| String methodName = "f";
|
| - MethodDeclaration methodNode = AstFactory.methodDeclaration(null, null, null, null, AstFactory.identifier3(methodName), AstFactory.formalParameterList());
|
| + MethodDeclaration methodNode = AstFactory.methodDeclaration(
|
| + null,
|
| + null,
|
| + null,
|
| + null,
|
| + AstFactory.identifier3(methodName),
|
| + AstFactory.formalParameterList());
|
| classNode.members.add(methodNode);
|
| - MethodElement methodElement = ElementFactory.methodElement(methodName, null);
|
| + MethodElement methodElement =
|
| + ElementFactory.methodElement(methodName, null);
|
| methodNode.name.staticElement = methodElement;
|
| - (classNode.element as ClassElementImpl).methods = <MethodElement> [methodElement];
|
| + (classNode.element as ClassElementImpl).methods =
|
| + <MethodElement>[methodElement];
|
| return methodNode;
|
| }
|
| }
|
| @@ -7577,8 +8312,10 @@ class ScopeTest extends ResolverTestCase {
|
| void test_define_duplicate() {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
|
| - VariableElement element1 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| - VariableElement element2 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element1 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element2 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| scope.define(element1);
|
| scope.define(element2);
|
| errorListener.assertErrorsWithSeverities([ErrorSeverity.ERROR]);
|
| @@ -7587,8 +8324,10 @@ class ScopeTest extends ResolverTestCase {
|
| void test_define_normal() {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
|
| - VariableElement element1 = ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| - VariableElement element2 = ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
|
| + VariableElement element1 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
|
| + VariableElement element2 =
|
| + ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
|
| scope.define(element1);
|
| scope.define(element2);
|
| errorListener.assertNoErrors();
|
| @@ -7618,34 +8357,12 @@ class ScopeTest_TestScope extends Scope {
|
| */
|
| final AnalysisErrorListener errorListener;
|
|
|
| - ScopeTest_TestScope(this.errorListener);
|
| -
|
| - @override
|
| - Element internalLookup(Identifier identifier, String name, LibraryElement referencingLibrary) => localLookup(name, referencingLibrary);
|
| -}
|
| -
|
| -class Scope_EnclosedScopeTest_test_define_duplicate extends Scope {
|
| - GatheringErrorListener listener;
|
| -
|
| - Scope_EnclosedScopeTest_test_define_duplicate(this.listener) : super();
|
| -
|
| - @override
|
| - AnalysisErrorListener get errorListener => listener;
|
| -
|
| - @override
|
| - Element internalLookup(Identifier identifier, String name, LibraryElement referencingLibrary) => null;
|
| -}
|
| -
|
| -class Scope_EnclosedScopeTest_test_define_normal extends Scope {
|
| - GatheringErrorListener listener;
|
| -
|
| - Scope_EnclosedScopeTest_test_define_normal(this.listener) : super();
|
| -
|
| - @override
|
| - AnalysisErrorListener get errorListener => listener;
|
| + ScopeTest_TestScope(this.errorListener);
|
|
|
| @override
|
| - Element internalLookup(Identifier identifier, String name, LibraryElement referencingLibrary) => null;
|
| + Element internalLookup(Identifier identifier, String name,
|
| + LibraryElement referencingLibrary) =>
|
| + localLookup(name, referencingLibrary);
|
| }
|
|
|
| class SimpleResolverTest extends ResolverTestCase {
|
| @@ -7780,7 +8497,8 @@ class A {
|
| FunctionElement mainElement = unit.functions[0];
|
| FunctionBody mainBody = mainElement.node.functionExpression.body;
|
| Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
|
| - ExpressionStatement expressionStatement = statement as ExpressionStatement;
|
| + ExpressionStatement expressionStatement =
|
| + statement as ExpressionStatement;
|
| assignment = expressionStatement.expression as AssignmentExpression;
|
| }
|
| // get parameter
|
| @@ -7815,7 +8533,8 @@ class B {
|
| FunctionElement mainElement = unit.functions[0];
|
| FunctionBody mainBody = mainElement.node.functionExpression.body;
|
| Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
|
| - ExpressionStatement expressionStatement = statement as ExpressionStatement;
|
| + ExpressionStatement expressionStatement =
|
| + statement as ExpressionStatement;
|
| assignment = expressionStatement.expression as AssignmentExpression;
|
| }
|
| // get parameter
|
| @@ -7847,7 +8566,8 @@ class A {
|
| FunctionElement mainElement = unit.functions[0];
|
| FunctionBody mainBody = mainElement.node.functionExpression.body;
|
| Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
|
| - ExpressionStatement expressionStatement = statement as ExpressionStatement;
|
| + ExpressionStatement expressionStatement =
|
| + statement as ExpressionStatement;
|
| assignment = expressionStatement.expression as AssignmentExpression;
|
| }
|
| // get parameter
|
| @@ -7881,7 +8601,8 @@ class B {
|
| FunctionElement mainElement = unit.functions[0];
|
| FunctionBody mainBody = mainElement.node.functionExpression.body;
|
| Statement statement = (mainBody as BlockFunctionBody).block.statements[1];
|
| - ExpressionStatement expressionStatement = statement as ExpressionStatement;
|
| + ExpressionStatement expressionStatement =
|
| + statement as ExpressionStatement;
|
| assignment = expressionStatement.expression as AssignmentExpression;
|
| }
|
| // get parameter
|
| @@ -8073,7 +8794,9 @@ g (A a) {
|
| a.f = a.f.toString();
|
| }''');
|
| resolve(source);
|
| - assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
|
| + assertErrors(
|
| + source,
|
| + [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
|
| verify([source]);
|
| }
|
|
|
| @@ -8296,13 +9019,20 @@ main() {
|
| }''');
|
| LibraryElement library = resolve(source);
|
| expect(library, isNotNull);
|
| - CompilationUnit unit = analysisContext.getResolvedCompilationUnit(source, library);
|
| + CompilationUnit unit =
|
| + analysisContext.getResolvedCompilationUnit(source, library);
|
| expect(unit, isNotNull);
|
| List<bool> found = [false];
|
| List<CaughtException> thrownException = new List<CaughtException>(1);
|
| - unit.accept(new RecursiveAstVisitor_SimpleResolverTest_test_localVariable_types_invoked(this, found, thrownException));
|
| + unit.accept(
|
| + new _SimpleResolverTest_localVariable_types_invoked(
|
| + this,
|
| + found,
|
| + thrownException));
|
| if (thrownException[0] != null) {
|
| - throw new AnalysisException("Exception", new CaughtException(thrownException[0], null));
|
| + throw new AnalysisException(
|
| + "Exception",
|
| + new CaughtException(thrownException[0], null));
|
| }
|
| expect(found[0], isTrue);
|
| }
|
| @@ -8324,10 +9054,16 @@ 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;
|
| - EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, PropertyInducingElement, expectedElement);
|
| + Element expectedElement =
|
| + (declarations[0] as
|
| + TopLevelVariableDeclaration).variables.variables[0].name.staticElement;
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is PropertyInducingElement,
|
| + PropertyInducingElement,
|
| + expectedElement);
|
| expectedElement = (expectedElement as PropertyInducingElement).getter;
|
| - Element actualElement = (declarations[1] as ClassDeclaration).metadata[0].name.staticElement;
|
| + Element actualElement =
|
| + (declarations[1] as ClassDeclaration).metadata[0].name.staticElement;
|
| expect(actualElement, same(expectedElement));
|
| }
|
|
|
| @@ -8511,10 +9247,16 @@ 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;
|
| - EngineTestCase.assertInstanceOf((obj) => obj is PropertyInducingElement, PropertyInducingElement, expectedElement);
|
| + Element expectedElement =
|
| + (declarations[0] as
|
| + TopLevelVariableDeclaration).variables.variables[0].name.staticElement;
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is PropertyInducingElement,
|
| + PropertyInducingElement,
|
| + expectedElement);
|
| expectedElement = (expectedElement as PropertyInducingElement).getter;
|
| - Element actualElement = (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement;
|
| + Element actualElement =
|
| + (declarations[1] as FunctionTypeAlias).metadata[0].name.staticElement;
|
| expect(actualElement, same(expectedElement));
|
| }
|
|
|
| @@ -8653,8 +9395,10 @@ main() {
|
| List<ParameterElement> parameters = classElement.methods[1].parameters;
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| expect(unit, isNotNull);
|
| - ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration;
|
| - MethodDeclaration methodDeclaration = classDeclaration.members[0] as MethodDeclaration;
|
| + ClassDeclaration classDeclaration =
|
| + unit.declarations[0] as ClassDeclaration;
|
| + MethodDeclaration methodDeclaration =
|
| + classDeclaration.members[0] as MethodDeclaration;
|
| Block block = (methodDeclaration.body as BlockFunctionBody).block;
|
| ExpressionStatement statement = block.statements[0] as ExpressionStatement;
|
| MethodInvocation invocation = statement.expression as MethodInvocation;
|
| @@ -8679,6 +9423,81 @@ class SourceContainer_ChangeSetTest_test_toString implements SourceContainer {
|
| bool contains(Source source) => false;
|
| }
|
|
|
| +/**
|
| + * Like [StaticTypeAnalyzerTest], but as end-to-end tests.
|
| + */
|
| +class StaticTypeAnalyzer2Test extends ResolverTestCase {
|
| + String testCode;
|
| + Source testSource;
|
| + CompilationUnit testUnit;
|
| +
|
| + void test_MethodInvocation_nameType_localVariable() {
|
| + String code = r"""
|
| +typedef Foo();
|
| +main() {
|
| + Foo foo;
|
| + foo();
|
| +}
|
| +""";
|
| + _resolveTestUnit(code);
|
| + // "foo" should be resolved to the "Foo" type
|
| + SimpleIdentifier identifier = _findIdentifier("foo();");
|
| + DartType type = identifier.staticType;
|
| + expect(type, new isInstanceOf<FunctionType>());
|
| + }
|
| +
|
| + void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
|
| + String code = r"""
|
| +typedef Foo();
|
| +main(Foo foo) {
|
| + foo();
|
| +}
|
| +""";
|
| + _resolveTestUnit(code);
|
| + // "foo" should be resolved to the "Foo" type
|
| + SimpleIdentifier identifier = _findIdentifier("foo();");
|
| + DartType type = identifier.staticType;
|
| + expect(type, new isInstanceOf<FunctionType>());
|
| + }
|
| +
|
| + void test_MethodInvocation_nameType_parameter_propagatedType() {
|
| + String code = r"""
|
| +typedef Foo();
|
| +main(p) {
|
| + if (p is Foo) {
|
| + p();
|
| + }
|
| +}
|
| +""";
|
| + _resolveTestUnit(code);
|
| + SimpleIdentifier identifier = _findIdentifier("p()");
|
| + expect(identifier.staticType, DynamicTypeImpl.instance);
|
| + {
|
| + FunctionType type = identifier.propagatedType;
|
| + expect(type, isNotNull);
|
| + expect(type.name, 'Foo');
|
| + }
|
| + }
|
| +
|
| + SimpleIdentifier _findIdentifier(String search) {
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + testUnit,
|
| + testCode,
|
| + search,
|
| + (node) => node is SimpleIdentifier);
|
| + return identifier;
|
| + }
|
| +
|
| + void _resolveTestUnit(String code) {
|
| + testCode = code;
|
| + testSource = addSource(testCode);
|
| + LibraryElement library = resolve(testSource);
|
| + assertNoErrors(testSource);
|
| + verify([testSource]);
|
| + testUnit = resolveCompilationUnit(testSource, library);
|
| + }
|
| +}
|
| +
|
| class StaticTypeAnalyzerTest extends EngineTestCase {
|
| /**
|
| * The error listener to which errors will be reported.
|
| @@ -8724,7 +9543,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitAdjacentStrings() {
|
| // "a" "b"
|
| - Expression node = AstFactory.adjacentStrings([_resolvedString("a"), _resolvedString("b")]);
|
| + Expression node =
|
| + AstFactory.adjacentStrings([_resolvedString("a"), _resolvedString("b")]);
|
| expect(_analyze(node), same(_typeProvider.stringType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -8735,7 +9555,9 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| ClassElement superclass = ElementFactory.classElement2("A");
|
| InterfaceType superclassType = superclass.type;
|
| ClassElement subclass = ElementFactory.classElement("B", superclassType);
|
| - Expression node = AstFactory.asExpression(AstFactory.thisExpression(), AstFactory.typeName(subclass));
|
| + Expression node = AstFactory.asExpression(
|
| + AstFactory.thisExpression(),
|
| + AstFactory.typeName(subclass));
|
| expect(_analyze3(node, superclassType), same(subclass.type));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -8744,7 +9566,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // i += 1
|
| InterfaceType numType = _typeProvider.numType;
|
| SimpleIdentifier identifier = _resolvedVariable(_typeProvider.intType, "i");
|
| - AssignmentExpression node = AstFactory.assignmentExpression(identifier, TokenType.PLUS_EQ, _resolvedInteger(1));
|
| + AssignmentExpression node = AstFactory.assignmentExpression(
|
| + identifier,
|
| + TokenType.PLUS_EQ,
|
| + _resolvedInteger(1));
|
| MethodElement plusMethod = getMethod(numType, "+");
|
| node.staticElement = plusMethod;
|
| expect(_analyze(node), same(numType));
|
| @@ -8754,42 +9579,60 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitAssignmentExpression_simple() {
|
| // i = 0
|
| InterfaceType intType = _typeProvider.intType;
|
| - Expression node = AstFactory.assignmentExpression(_resolvedVariable(intType, "i"), TokenType.EQ, _resolvedInteger(0));
|
| + Expression node = AstFactory.assignmentExpression(
|
| + _resolvedVariable(intType, "i"),
|
| + TokenType.EQ,
|
| + _resolvedInteger(0));
|
| expect(_analyze(node), same(intType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitBinaryExpression_equals() {
|
| // 2 == 3
|
| - Expression node = AstFactory.binaryExpression(_resolvedInteger(2), TokenType.EQ_EQ, _resolvedInteger(3));
|
| + Expression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(2),
|
| + TokenType.EQ_EQ,
|
| + _resolvedInteger(3));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitBinaryExpression_logicalAnd() {
|
| // false && true
|
| - Expression node = AstFactory.binaryExpression(AstFactory.booleanLiteral(false), TokenType.AMPERSAND_AMPERSAND, AstFactory.booleanLiteral(true));
|
| + Expression node = AstFactory.binaryExpression(
|
| + AstFactory.booleanLiteral(false),
|
| + TokenType.AMPERSAND_AMPERSAND,
|
| + AstFactory.booleanLiteral(true));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitBinaryExpression_logicalOr() {
|
| // false || true
|
| - Expression node = AstFactory.binaryExpression(AstFactory.booleanLiteral(false), TokenType.BAR_BAR, AstFactory.booleanLiteral(true));
|
| + Expression node = AstFactory.binaryExpression(
|
| + AstFactory.booleanLiteral(false),
|
| + TokenType.BAR_BAR,
|
| + AstFactory.booleanLiteral(true));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitBinaryExpression_notEquals() {
|
| // 2 != 3
|
| - Expression node = AstFactory.binaryExpression(_resolvedInteger(2), TokenType.BANG_EQ, _resolvedInteger(3));
|
| + Expression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(2),
|
| + TokenType.BANG_EQ,
|
| + _resolvedInteger(3));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitBinaryExpression_plusID() {
|
| // 1 + 2.0
|
| - BinaryExpression node = AstFactory.binaryExpression(_resolvedInteger(1), TokenType.PLUS, _resolvedDouble(2.0));
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(1),
|
| + TokenType.PLUS,
|
| + _resolvedDouble(2.0));
|
| node.staticElement = getMethod(_typeProvider.numType, "+");
|
| expect(_analyze(node), same(_typeProvider.doubleType));
|
| _listener.assertNoErrors();
|
| @@ -8797,7 +9640,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitBinaryExpression_plusII() {
|
| // 1 + 2
|
| - BinaryExpression node = AstFactory.binaryExpression(_resolvedInteger(1), TokenType.PLUS, _resolvedInteger(2));
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(1),
|
| + TokenType.PLUS,
|
| + _resolvedInteger(2));
|
| node.staticElement = getMethod(_typeProvider.numType, "+");
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| @@ -8805,7 +9651,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitBinaryExpression_slash() {
|
| // 2 / 2
|
| - BinaryExpression node = AstFactory.binaryExpression(_resolvedInteger(2), TokenType.SLASH, _resolvedInteger(2));
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(2),
|
| + TokenType.SLASH,
|
| + _resolvedInteger(2));
|
| node.staticElement = getMethod(_typeProvider.numType, "/");
|
| expect(_analyze(node), same(_typeProvider.doubleType));
|
| _listener.assertNoErrors();
|
| @@ -8818,9 +9667,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // (a as A) * 2.0
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| InterfaceType typeA = classA.type;
|
| - MethodElement operator = ElementFactory.methodElement("*", typeA, [_typeProvider.doubleType]);
|
| - classA.methods = <MethodElement> [operator];
|
| - BinaryExpression node = AstFactory.binaryExpression(AstFactory.asExpression(AstFactory.identifier3("a"), AstFactory.typeName(classA)), TokenType.PLUS, _resolvedDouble(2.0));
|
| + MethodElement operator =
|
| + ElementFactory.methodElement("*", typeA, [_typeProvider.doubleType]);
|
| + classA.methods = <MethodElement>[operator];
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + AstFactory.asExpression(
|
| + AstFactory.identifier3("a"),
|
| + AstFactory.typeName(classA)),
|
| + TokenType.PLUS,
|
| + _resolvedDouble(2.0));
|
| node.staticElement = operator;
|
| expect(_analyze(node), same(typeA));
|
| _listener.assertNoErrors();
|
| @@ -8828,7 +9683,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitBinaryExpression_starID() {
|
| // 1 * 2.0
|
| - BinaryExpression node = AstFactory.binaryExpression(_resolvedInteger(1), TokenType.PLUS, _resolvedDouble(2.0));
|
| + BinaryExpression node = AstFactory.binaryExpression(
|
| + _resolvedInteger(1),
|
| + TokenType.PLUS,
|
| + _resolvedDouble(2.0));
|
| node.staticElement = getMethod(_typeProvider.numType, "*");
|
| expect(_analyze(node), same(_typeProvider.doubleType));
|
| _listener.assertNoErrors();
|
| @@ -8850,21 +9708,29 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitCascadeExpression() {
|
| // a..length
|
| - Expression node = AstFactory.cascadeExpression(_resolvedString("a"), [AstFactory.propertyAccess2(null, "length")]);
|
| + Expression node = AstFactory.cascadeExpression(
|
| + _resolvedString("a"),
|
| + [AstFactory.propertyAccess2(null, "length")]);
|
| expect(_analyze(node), same(_typeProvider.stringType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitConditionalExpression_differentTypes() {
|
| // true ? 1.0 : 0
|
| - Expression node = AstFactory.conditionalExpression(AstFactory.booleanLiteral(true), _resolvedDouble(1.0), _resolvedInteger(0));
|
| + Expression node = AstFactory.conditionalExpression(
|
| + AstFactory.booleanLiteral(true),
|
| + _resolvedDouble(1.0),
|
| + _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.numType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitConditionalExpression_sameTypes() {
|
| // true ? 1 : 0
|
| - Expression node = AstFactory.conditionalExpression(AstFactory.booleanLiteral(true), _resolvedInteger(1), _resolvedInteger(0));
|
| + Expression node = AstFactory.conditionalExpression(
|
| + AstFactory.booleanLiteral(true),
|
| + _resolvedInteger(1),
|
| + _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -8879,32 +9745,52 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitFunctionExpression_named_block() {
|
| // ({p1 : 0, p2 : 0}) {}
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| - FormalParameter p1 = AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p1"), _resolvedInteger(0));
|
| + FormalParameter p1 = AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p1"),
|
| + _resolvedInteger(0));
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.blockFunctionBody2());
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.blockFunctionBody2());
|
| _analyze5(p1);
|
| _analyze5(p2);
|
| DartType resultType = _analyze(node);
|
| Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
|
| expectedNamedTypes["p1"] = dynamicType;
|
| expectedNamedTypes["p2"] = dynamicType;
|
| - _assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType);
|
| + _assertFunctionType(
|
| + dynamicType,
|
| + null,
|
| + null,
|
| + expectedNamedTypes,
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitFunctionExpression_named_expression() {
|
| // ({p : 0}) -> 0;
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| - FormalParameter p = AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p"), _resolvedInteger(0));
|
| + FormalParameter p = AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"),
|
| + _resolvedInteger(0));
|
| _setType(p, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p]), AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p]),
|
| + AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| _analyze5(p);
|
| DartType resultType = _analyze(node);
|
| Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
|
| expectedNamedTypes["p"] = dynamicType;
|
| - _assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, resultType);
|
| + _assertFunctionType(
|
| + _typeProvider.intType,
|
| + null,
|
| + null,
|
| + expectedNamedTypes,
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -8915,11 +9801,18 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| _setType(p1, dynamicType);
|
| FormalParameter p2 = AstFactory.simpleFormalParameter3("p2");
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.blockFunctionBody2());
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.blockFunctionBody2());
|
| _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();
|
| }
|
|
|
| @@ -8928,10 +9821,17 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| FormalParameter p = AstFactory.simpleFormalParameter3("p");
|
| _setType(p, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p]), AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p]),
|
| + AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| _analyze5(p);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(_typeProvider.intType, <DartType> [dynamicType], null, null, resultType);
|
| + _assertFunctionType(
|
| + _typeProvider.intType,
|
| + <DartType>[dynamicType],
|
| + null,
|
| + null,
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -8940,14 +9840,23 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| FormalParameter p1 = AstFactory.simpleFormalParameter3("p1");
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.blockFunctionBody2());
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.blockFunctionBody2());
|
| _analyze5(p2);
|
| 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();
|
| }
|
|
|
| @@ -8956,14 +9865,23 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| FormalParameter p1 = AstFactory.simpleFormalParameter3("p1");
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| _analyze5(p2);
|
| 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();
|
| }
|
|
|
| @@ -8972,13 +9890,22 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| FormalParameter p1 = AstFactory.simpleFormalParameter3("p1");
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.blockFunctionBody2());
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.blockFunctionBody2());
|
| _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();
|
| }
|
|
|
| @@ -8987,40 +9914,69 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| FormalParameter p1 = AstFactory.simpleFormalParameter3("p1");
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| _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();
|
| }
|
|
|
| void test_visitFunctionExpression_positional_block() {
|
| // ([p1 = 0, p2 = 0]) {}
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| - FormalParameter p1 = AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("p1"), _resolvedInteger(0));
|
| + FormalParameter p1 = AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p1"),
|
| + _resolvedInteger(0));
|
| _setType(p1, dynamicType);
|
| - FormalParameter p2 = AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("p2"), _resolvedInteger(0));
|
| + FormalParameter p2 = AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p2"),
|
| + _resolvedInteger(0));
|
| _setType(p2, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p1, p2]), AstFactory.blockFunctionBody2());
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p1, p2]),
|
| + AstFactory.blockFunctionBody2());
|
| _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();
|
| }
|
|
|
| void test_visitFunctionExpression_positional_expression() {
|
| // ([p1 = 0, p2 = 0]) -> 0
|
| DartType dynamicType = _typeProvider.dynamicType;
|
| - FormalParameter p = AstFactory.positionalFormalParameter(AstFactory.simpleFormalParameter3("p"), _resolvedInteger(0));
|
| + FormalParameter p = AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"),
|
| + _resolvedInteger(0));
|
| _setType(p, dynamicType);
|
| - FunctionExpression node = _resolvedFunctionExpression(AstFactory.formalParameterList([p]), AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| + FunctionExpression node = _resolvedFunctionExpression(
|
| + AstFactory.formalParameterList([p]),
|
| + AstFactory.expressionFunctionBody(_resolvedInteger(0)));
|
| _analyze5(p);
|
| DartType resultType = _analyze(node);
|
| - _assertFunctionType(_typeProvider.intType, null, <DartType> [dynamicType], null, resultType);
|
| + _assertFunctionType(
|
| + _typeProvider.intType,
|
| + null,
|
| + <DartType>[dynamicType],
|
| + null,
|
| + resultType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -9029,7 +9985,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // a[2]
|
| InterfaceType listType = _typeProvider.listType;
|
| SimpleIdentifier identifier = _resolvedVariable(listType, "a");
|
| - IndexExpression node = AstFactory.indexExpression(identifier, _resolvedInteger(2));
|
| + IndexExpression node =
|
| + AstFactory.indexExpression(identifier, _resolvedInteger(2));
|
| MethodElement indexMethod = listType.element.methods[0];
|
| node.staticElement = indexMethod;
|
| expect(_analyze(node), same(listType.typeArguments[0]));
|
| @@ -9041,7 +9998,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // a[2] = 0
|
| InterfaceType listType = _typeProvider.listType;
|
| SimpleIdentifier identifier = _resolvedVariable(listType, "a");
|
| - IndexExpression node = AstFactory.indexExpression(identifier, _resolvedInteger(2));
|
| + IndexExpression node =
|
| + AstFactory.indexExpression(identifier, _resolvedInteger(2));
|
| MethodElement indexMethod = listType.element.methods[1];
|
| node.staticElement = indexMethod;
|
| AstFactory.assignmentExpression(node, TokenType.EQ, AstFactory.integer(0));
|
| @@ -9058,10 +10016,11 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| MethodElement methodElement = getMethod(listType, "[]");
|
| // "list" has type List<int>
|
| SimpleIdentifier identifier = AstFactory.identifier3("list");
|
| - InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]);
|
| + InterfaceType listOfIntType = listType.substitute4(<DartType>[intType]);
|
| identifier.staticType = listOfIntType;
|
| // list[0] has MethodElement element (int) -> E
|
| - IndexExpression indexExpression = AstFactory.indexExpression(identifier, AstFactory.integer(0));
|
| + IndexExpression indexExpression =
|
| + AstFactory.indexExpression(identifier, AstFactory.integer(0));
|
| MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
|
| indexExpression.staticElement = indexMethod;
|
| // analyze and assert result of the index expression
|
| @@ -9078,14 +10037,18 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| MethodElement methodElement = getMethod(listType, "[]=");
|
| // "list" has type List<int>
|
| SimpleIdentifier identifier = AstFactory.identifier3("list");
|
| - InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]);
|
| + InterfaceType listOfIntType = listType.substitute4(<DartType>[intType]);
|
| identifier.staticType = listOfIntType;
|
| // list[0] has MethodElement element (int) -> E
|
| - IndexExpression indexExpression = AstFactory.indexExpression(identifier, AstFactory.integer(0));
|
| + IndexExpression indexExpression =
|
| + AstFactory.indexExpression(identifier, AstFactory.integer(0));
|
| MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
|
| indexExpression.staticElement = indexMethod;
|
| // list[0] should be in a setter context
|
| - AstFactory.assignmentExpression(indexExpression, TokenType.EQ, AstFactory.integer(0));
|
| + AstFactory.assignmentExpression(
|
| + indexExpression,
|
| + TokenType.EQ,
|
| + AstFactory.integer(0));
|
| // analyze and assert result of the index expression
|
| expect(_analyze(indexExpression), same(intType));
|
| _listener.assertNoErrors();
|
| @@ -9095,12 +10058,16 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // new C.m()
|
| ClassElementImpl classElement = ElementFactory.classElement2("C");
|
| String constructorName = "m";
|
| - ConstructorElementImpl constructor = ElementFactory.constructorElement2(classElement, constructorName);
|
| + ConstructorElementImpl constructor =
|
| + ElementFactory.constructorElement2(classElement, constructorName);
|
| constructor.returnType = classElement.type;
|
| FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
|
| constructor.type = constructorType;
|
| - classElement.constructors = <ConstructorElement> [constructor];
|
| - InstanceCreationExpression node = AstFactory.instanceCreationExpression2(null, AstFactory.typeName(classElement), [AstFactory.identifier3(constructorName)]);
|
| + classElement.constructors = <ConstructorElement>[constructor];
|
| + InstanceCreationExpression node = AstFactory.instanceCreationExpression2(
|
| + null,
|
| + AstFactory.typeName(classElement),
|
| + [AstFactory.identifier3(constructorName)]);
|
| node.staticElement = constructor;
|
| expect(_analyze(node), same(classElement.type));
|
| _listener.assertNoErrors();
|
| @@ -9110,14 +10077,17 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| // new C<I>()
|
| ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]);
|
| ClassElementImpl elementI = ElementFactory.classElement2("I");
|
| - ConstructorElementImpl constructor = ElementFactory.constructorElement2(elementC, null);
|
| - elementC.constructors = <ConstructorElement> [constructor];
|
| + ConstructorElementImpl constructor =
|
| + ElementFactory.constructorElement2(elementC, null);
|
| + elementC.constructors = <ConstructorElement>[constructor];
|
| constructor.returnType = elementC.type;
|
| FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
|
| constructor.type = constructorType;
|
| - TypeName typeName = AstFactory.typeName(elementC, [AstFactory.typeName(elementI)]);
|
| - typeName.type = elementC.type.substitute4(<DartType> [elementI.type]);
|
| - InstanceCreationExpression node = AstFactory.instanceCreationExpression2(null, typeName);
|
| + TypeName typeName =
|
| + AstFactory.typeName(elementC, [AstFactory.typeName(elementI)]);
|
| + typeName.type = elementC.type.substitute4(<DartType>[elementI.type]);
|
| + InstanceCreationExpression node =
|
| + AstFactory.instanceCreationExpression2(null, typeName);
|
| node.staticElement = constructor;
|
| InterfaceType interfaceType = _analyze(node) as InterfaceType;
|
| List<DartType> typeArgs = interfaceType.typeArguments;
|
| @@ -9129,12 +10099,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| void test_visitInstanceCreationExpression_unnamed() {
|
| // new C()
|
| ClassElementImpl classElement = ElementFactory.classElement2("C");
|
| - ConstructorElementImpl constructor = ElementFactory.constructorElement2(classElement, null);
|
| + ConstructorElementImpl constructor =
|
| + ElementFactory.constructorElement2(classElement, null);
|
| constructor.returnType = classElement.type;
|
| FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
|
| constructor.type = constructorType;
|
| - classElement.constructors = <ConstructorElement> [constructor];
|
| - InstanceCreationExpression node = AstFactory.instanceCreationExpression2(null, AstFactory.typeName(classElement));
|
| + classElement.constructors = <ConstructorElement>[constructor];
|
| + InstanceCreationExpression node = AstFactory.instanceCreationExpression2(
|
| + null,
|
| + AstFactory.typeName(classElement));
|
| node.staticElement = constructor;
|
| expect(_analyze(node), same(classElement.type));
|
| _listener.assertNoErrors();
|
| @@ -9149,14 +10122,20 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitIsExpression_negated() {
|
| // a is! String
|
| - Expression node = AstFactory.isExpression(_resolvedString("a"), true, AstFactory.typeName4("String"));
|
| + Expression node = AstFactory.isExpression(
|
| + _resolvedString("a"),
|
| + true,
|
| + AstFactory.typeName4("String"));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitIsExpression_notNegated() {
|
| // a is String
|
| - Expression node = AstFactory.isExpression(_resolvedString("a"), false, AstFactory.typeName4("String"));
|
| + Expression node = AstFactory.isExpression(
|
| + _resolvedString("a"),
|
| + false,
|
| + AstFactory.typeName4("String"));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -9165,7 +10144,9 @@ 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();
|
| }
|
|
|
| @@ -9173,7 +10154,9 @@ 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();
|
| }
|
|
|
| @@ -9181,15 +10164,22 @@ 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();
|
| }
|
|
|
| void test_visitMapLiteral_nonEmpty() {
|
| // {"k" : 0}
|
| - Expression node = AstFactory.mapLiteral2([AstFactory.mapLiteralEntry("k", _resolvedInteger(0))]);
|
| + 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();
|
| }
|
|
|
| @@ -9223,21 +10213,24 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPostfixExpression_minusMinus() {
|
| // 0--
|
| - PostfixExpression node = AstFactory.postfixExpression(_resolvedInteger(0), TokenType.MINUS_MINUS);
|
| + PostfixExpression node =
|
| + AstFactory.postfixExpression(_resolvedInteger(0), TokenType.MINUS_MINUS);
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitPostfixExpression_plusPlus() {
|
| // 0++
|
| - PostfixExpression node = AstFactory.postfixExpression(_resolvedInteger(0), TokenType.PLUS_PLUS);
|
| + PostfixExpression node =
|
| + AstFactory.postfixExpression(_resolvedInteger(0), TokenType.PLUS_PLUS);
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitPrefixedIdentifier_getter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false, boolType);
|
| + PropertyAccessorElementImpl getter =
|
| + ElementFactory.getterElement("b", false, boolType);
|
| PrefixedIdentifier node = AstFactory.identifier5("a", "b");
|
| node.identifier.staticElement = getter;
|
| expect(_analyze(node), same(boolType));
|
| @@ -9246,7 +10239,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPrefixedIdentifier_setter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - FieldElementImpl field = ElementFactory.fieldElement("b", false, false, false, boolType);
|
| + FieldElementImpl field =
|
| + ElementFactory.fieldElement("b", false, false, false, boolType);
|
| PropertyAccessorElement setter = field.setter;
|
| PrefixedIdentifier node = AstFactory.identifier5("a", "b");
|
| node.identifier.staticElement = setter;
|
| @@ -9265,14 +10259,16 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPrefixExpression_bang() {
|
| // !0
|
| - PrefixExpression node = AstFactory.prefixExpression(TokenType.BANG, _resolvedInteger(0));
|
| + PrefixExpression node =
|
| + AstFactory.prefixExpression(TokenType.BANG, _resolvedInteger(0));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitPrefixExpression_minus() {
|
| // -0
|
| - PrefixExpression node = AstFactory.prefixExpression(TokenType.MINUS, _resolvedInteger(0));
|
| + PrefixExpression node =
|
| + AstFactory.prefixExpression(TokenType.MINUS, _resolvedInteger(0));
|
| MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
|
| node.staticElement = minusMethod;
|
| expect(_analyze(node), same(_typeProvider.numType));
|
| @@ -9281,7 +10277,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPrefixExpression_minusMinus() {
|
| // --0
|
| - PrefixExpression node = AstFactory.prefixExpression(TokenType.MINUS_MINUS, _resolvedInteger(0));
|
| + PrefixExpression node =
|
| + AstFactory.prefixExpression(TokenType.MINUS_MINUS, _resolvedInteger(0));
|
| MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
|
| node.staticElement = minusMethod;
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| @@ -9290,14 +10287,16 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPrefixExpression_not() {
|
| // !true
|
| - Expression node = AstFactory.prefixExpression(TokenType.BANG, AstFactory.booleanLiteral(true));
|
| + Expression node =
|
| + AstFactory.prefixExpression(TokenType.BANG, AstFactory.booleanLiteral(true));
|
| expect(_analyze(node), same(_typeProvider.boolType));
|
| _listener.assertNoErrors();
|
| }
|
|
|
| void test_visitPrefixExpression_plusPlus() {
|
| // ++0
|
| - PrefixExpression node = AstFactory.prefixExpression(TokenType.PLUS_PLUS, _resolvedInteger(0));
|
| + PrefixExpression node =
|
| + AstFactory.prefixExpression(TokenType.PLUS_PLUS, _resolvedInteger(0));
|
| MethodElement plusMethod = getMethod(_typeProvider.numType, "+");
|
| node.staticElement = plusMethod;
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| @@ -9306,7 +10305,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPrefixExpression_tilde() {
|
| // ~0
|
| - PrefixExpression node = AstFactory.prefixExpression(TokenType.TILDE, _resolvedInteger(0));
|
| + PrefixExpression node =
|
| + AstFactory.prefixExpression(TokenType.TILDE, _resolvedInteger(0));
|
| MethodElement tildeMethod = getMethod(_typeProvider.intType, "~");
|
| node.staticElement = tildeMethod;
|
| expect(_analyze(node), same(_typeProvider.intType));
|
| @@ -9315,8 +10315,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPropertyAccess_propagated_getter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false, boolType);
|
| - PropertyAccess node = AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| + PropertyAccessorElementImpl getter =
|
| + ElementFactory.getterElement("b", false, boolType);
|
| + PropertyAccess node =
|
| + AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| node.propertyName.propagatedElement = getter;
|
| expect(_analyze2(node, false), same(boolType));
|
| _listener.assertNoErrors();
|
| @@ -9324,9 +10326,11 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPropertyAccess_propagated_setter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - FieldElementImpl field = ElementFactory.fieldElement("b", false, false, false, boolType);
|
| + FieldElementImpl field =
|
| + ElementFactory.fieldElement("b", false, false, false, boolType);
|
| PropertyAccessorElement setter = field.setter;
|
| - PropertyAccess node = AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| + PropertyAccess node =
|
| + AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| node.propertyName.propagatedElement = setter;
|
| expect(_analyze2(node, false), same(boolType));
|
| _listener.assertNoErrors();
|
| @@ -9334,8 +10338,10 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPropertyAccess_static_getter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false, boolType);
|
| - PropertyAccess node = AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| + PropertyAccessorElementImpl getter =
|
| + ElementFactory.getterElement("b", false, boolType);
|
| + PropertyAccess node =
|
| + AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| node.propertyName.staticElement = getter;
|
| expect(_analyze(node), same(boolType));
|
| _listener.assertNoErrors();
|
| @@ -9343,9 +10349,11 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitPropertyAccess_static_setter() {
|
| DartType boolType = _typeProvider.boolType;
|
| - FieldElementImpl field = ElementFactory.fieldElement("b", false, false, false, boolType);
|
| + FieldElementImpl field =
|
| + ElementFactory.fieldElement("b", false, false, false, boolType);
|
| PropertyAccessorElement setter = field.setter;
|
| - PropertyAccess node = AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| + PropertyAccess node =
|
| + AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b");
|
| node.propertyName.staticElement = setter;
|
| expect(_analyze(node), same(boolType));
|
| _listener.assertNoErrors();
|
| @@ -9370,10 +10378,11 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void test_visitStringInterpolation() {
|
| // "a${'b'}c"
|
| - Expression node = AstFactory.string([
|
| - AstFactory.interpolationString("a", "a"),
|
| - AstFactory.interpolationExpression(_resolvedString("b")),
|
| - AstFactory.interpolationString("c", "c")]);
|
| + Expression node = AstFactory.string(
|
| + [
|
| + AstFactory.interpolationString("a", "a"),
|
| + AstFactory.interpolationExpression(_resolvedString("b")),
|
| + AstFactory.interpolationString("c", "c")]);
|
| expect(_analyze(node), same(_typeProvider.stringType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -9388,12 +10397,15 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitSymbolLiteral() {
|
| - expect(_analyze(AstFactory.symbolLiteral(["a"])), same(_typeProvider.symbolType));
|
| + expect(
|
| + _analyze(AstFactory.symbolLiteral(["a"])),
|
| + same(_typeProvider.symbolType));
|
| }
|
|
|
| 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();
|
| @@ -9431,7 +10443,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| * the propagated type is being requested
|
| * @return the type associated with the expression
|
| */
|
| - DartType _analyze2(Expression node, bool useStaticType) => _analyze4(node, null, useStaticType);
|
| + DartType _analyze2(Expression node, bool useStaticType) =>
|
| + _analyze4(node, null, useStaticType);
|
|
|
| /**
|
| * Return the type associated with the given expression after the static type analyzer has
|
| @@ -9441,7 +10454,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| * @param thisType the type of 'this'
|
| * @return the type associated with the expression
|
| */
|
| - DartType _analyze3(Expression node, InterfaceType thisType) => _analyze4(node, thisType, true);
|
| + DartType _analyze3(Expression node, InterfaceType thisType) =>
|
| + _analyze4(node, thisType, true);
|
|
|
| /**
|
| * Return the type associated with the given expression after the static type analyzer has
|
| @@ -9453,11 +10467,14 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| * the propagated type is being requested
|
| * @return the type associated with the expression
|
| */
|
| - DartType _analyze4(Expression node, InterfaceType thisType, bool useStaticType) {
|
| + DartType _analyze4(Expression node, InterfaceType thisType,
|
| + bool useStaticType) {
|
| try {
|
| _analyzer.thisType_J2DAccessor = thisType;
|
| } catch (exception) {
|
| - throw new IllegalArgumentException("Could not set type of 'this'", exception);
|
| + throw new IllegalArgumentException(
|
| + "Could not set type of 'this'",
|
| + exception);
|
| }
|
| node.accept(_analyzer);
|
| if (useStaticType) {
|
| @@ -9488,8 +10505,13 @@ 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) {
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionType, FunctionType, 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;
|
| List<DartType> normalTypes = functionType.normalParameterTypes;
|
| if (expectedNormalTypes == null) {
|
| @@ -9523,7 +10545,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| expect(functionType.returnType, same(expectedReturnType));
|
| }
|
|
|
| - void _assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {
|
| + void _assertType(InterfaceTypeImpl expectedType,
|
| + InterfaceTypeImpl actualType) {
|
| expect(actualType.displayName, expectedType.displayName);
|
| expect(actualType.element, expectedType.element);
|
| List<DartType> expectedArguments = expectedType.typeArguments;
|
| @@ -9537,10 +10560,14 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
| void _assertType2(DartType expectedType, DartType actualType) {
|
| if (expectedType is InterfaceTypeImpl) {
|
| - EngineTestCase.assertInstanceOf((obj) => obj is InterfaceTypeImpl, InterfaceTypeImpl, actualType);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is InterfaceTypeImpl,
|
| + InterfaceTypeImpl,
|
| + actualType);
|
| _assertType(expectedType, actualType as InterfaceTypeImpl);
|
| }
|
| - // TODO(brianwilkerson) Compare other kinds of types then make this a shared utility method
|
| + // TODO(brianwilkerson) Compare other kinds of types then make this a shared
|
| + // utility method.
|
| }
|
|
|
| /**
|
| @@ -9550,12 +10577,16 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| */
|
| StaticTypeAnalyzer _createAnalyzer() {
|
| AnalysisContextImpl context = new AnalysisContextImpl();
|
| - SourceFactory sourceFactory = new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
| + SourceFactory sourceFactory =
|
| + new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)]);
|
| context.sourceFactory = sourceFactory;
|
| - FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile("/lib.dart"));
|
| - CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElementImpl("lib.dart");
|
| + FileBasedSource source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile("/lib.dart"));
|
| + CompilationUnitElementImpl definingCompilationUnit =
|
| + new CompilationUnitElementImpl("lib.dart");
|
| definingCompilationUnit.source = source;
|
| - LibraryElementImpl definingLibrary = new LibraryElementImpl.forNode(context, null);
|
| + LibraryElementImpl definingLibrary =
|
| + new LibraryElementImpl.forNode(context, null);
|
| definingLibrary.definingCompilationUnit = definingCompilationUnit;
|
| Library library = new Library(context, _listener, source);
|
| library.libraryElement = definingLibrary;
|
| @@ -9564,7 +10595,9 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| try {
|
| return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer;
|
| } catch (exception) {
|
| - throw new IllegalArgumentException("Could not create analyzer", exception);
|
| + throw new IllegalArgumentException(
|
| + "Could not create analyzer",
|
| + exception);
|
| }
|
| }
|
|
|
| @@ -9590,10 +10623,12 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| * @param body the body of the function
|
| * @return a resolved function expression
|
| */
|
| - FunctionExpression _resolvedFunctionExpression(FormalParameterList parameters, FunctionBody body) {
|
| + FunctionExpression _resolvedFunctionExpression(FormalParameterList parameters,
|
| + FunctionBody body) {
|
| List<ParameterElement> parameterElements = new List<ParameterElement>();
|
| for (FormalParameter parameter in parameters.parameters) {
|
| - ParameterElementImpl element = new ParameterElementImpl.forNode(parameter.identifier);
|
| + ParameterElementImpl element =
|
| + new ParameterElementImpl.forNode(parameter.identifier);
|
| element.parameterKind = parameter.kind;
|
| element.type = _typeProvider.dynamicType;
|
| parameter.identifier.staticElement = element;
|
| @@ -9640,7 +10675,8 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
| */
|
| SimpleIdentifier _resolvedVariable(InterfaceType type, String variableName) {
|
| SimpleIdentifier identifier = AstFactory.identifier3(variableName);
|
| - VariableElementImpl element = ElementFactory.localVariableElement(identifier);
|
| + VariableElementImpl element =
|
| + ElementFactory.localVariableElement(identifier);
|
| element.type = type;
|
| identifier.staticElement = element;
|
| identifier.staticType = type;
|
| @@ -9666,81 +10702,6 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
|
|
|
|
| /**
|
| - * Like [StaticTypeAnalyzerTest], but as end-to-end tests.
|
| - */
|
| -class StaticTypeAnalyzer2Test extends ResolverTestCase {
|
| - String testCode;
|
| - Source testSource;
|
| - CompilationUnit testUnit;
|
| -
|
| - void test_MethodInvocation_nameType_localVariable() {
|
| - String code = r"""
|
| -typedef Foo();
|
| -main() {
|
| - Foo foo;
|
| - foo();
|
| -}
|
| -""";
|
| - _resolveTestUnit(code);
|
| - // "foo" should be resolved to the "Foo" type
|
| - SimpleIdentifier identifier = _findIdentifier("foo();");
|
| - DartType type = identifier.staticType;
|
| - expect(type, new isInstanceOf<FunctionType>());
|
| - }
|
| -
|
| - void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
|
| - String code = r"""
|
| -typedef Foo();
|
| -main(Foo foo) {
|
| - foo();
|
| -}
|
| -""";
|
| - _resolveTestUnit(code);
|
| - // "foo" should be resolved to the "Foo" type
|
| - SimpleIdentifier identifier = _findIdentifier("foo();");
|
| - DartType type = identifier.staticType;
|
| - expect(type, new isInstanceOf<FunctionType>());
|
| - }
|
| -
|
| - void test_MethodInvocation_nameType_parameter_propagatedType() {
|
| - String code = r"""
|
| -typedef Foo();
|
| -main(p) {
|
| - if (p is Foo) {
|
| - p();
|
| - }
|
| -}
|
| -""";
|
| - _resolveTestUnit(code);
|
| - SimpleIdentifier identifier = _findIdentifier("p()");
|
| - expect(identifier.staticType, DynamicTypeImpl.instance);
|
| - {
|
| - FunctionType type = identifier.propagatedType;
|
| - expect(type, isNotNull);
|
| - expect(type.name, 'Foo');
|
| - }
|
| - }
|
| -
|
| - SimpleIdentifier _findIdentifier(String search) {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(
|
| - testUnit,
|
| - testCode,
|
| - search,
|
| - (node) => node is SimpleIdentifier);
|
| - return identifier;
|
| - }
|
| -
|
| - void _resolveTestUnit(String code) {
|
| - testCode = code;
|
| - testSource = addSource(testCode);
|
| - LibraryElement library = resolve(testSource);
|
| - assertNoErrors(testSource);
|
| - verify([testSource]);
|
| - testUnit = resolveCompilationUnit(testSource, library);
|
| - }
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `StaticTypeVerifier` verify that all of the nodes in an AST
|
| * structure that should have a static type associated with them do have a static type.
|
| */
|
| @@ -9816,7 +10777,8 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
| buffer.writeln(")");
|
| }
|
| }
|
| - int invalidlyPropagatedExpressionCount = _invalidlyPropagatedExpressions.length;
|
| + int invalidlyPropagatedExpressionCount =
|
| + _invalidlyPropagatedExpressions.length;
|
| if (invalidlyPropagatedExpressionCount > 0) {
|
| buffer.writeln("Incorrectly propagated ");
|
| buffer.write(invalidlyPropagatedExpressionCount);
|
| @@ -9884,8 +10846,8 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
|
|
| @override
|
| Object visitPrefixedIdentifier(PrefixedIdentifier node) {
|
| - // In cases where we have a prefixed identifier where the prefix is dynamic, we don't want to
|
| - // assert that the node will have a type.
|
| + // In cases where we have a prefixed identifier where the prefix is dynamic,
|
| + // we don't want to assert that the node will have a type.
|
| if (node.staticType == null && node.prefix.staticType.isDynamic) {
|
| return null;
|
| }
|
| @@ -9894,18 +10856,21 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
|
|
| @override
|
| Object visitSimpleIdentifier(SimpleIdentifier node) {
|
| - // In cases where identifiers are being used for something other than an expressions,
|
| - // then they can be ignored.
|
| + // In cases where identifiers are being used for something other than an
|
| + // expressions, then they can be ignored.
|
| AstNode parent = node.parent;
|
| if (parent is MethodInvocation && identical(node, parent.methodName)) {
|
| return null;
|
| - } else if (parent is RedirectingConstructorInvocation && identical(node, parent.constructorName)) {
|
| + } else if (parent is RedirectingConstructorInvocation &&
|
| + identical(node, parent.constructorName)) {
|
| return null;
|
| - } else if (parent is SuperConstructorInvocation && identical(node, parent.constructorName)) {
|
| + } else if (parent is SuperConstructorInvocation &&
|
| + identical(node, parent.constructorName)) {
|
| return null;
|
| } else if (parent is ConstructorName && identical(node, parent.name)) {
|
| return null;
|
| - } else if (parent is ConstructorFieldInitializer && identical(node, parent.fieldName)) {
|
| + } else if (parent is ConstructorFieldInitializer &&
|
| + identical(node, parent.fieldName)) {
|
| return null;
|
| } else if (node.staticElement is PrefixElement) {
|
| // Prefixes don't have a type.
|
| @@ -9916,8 +10881,8 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
|
|
| @override
|
| Object visitTypeName(TypeName node) {
|
| - // Note: do not visit children from this node, the child SimpleIdentifier in TypeName
|
| - // (i.e. "String") does not have a static type defined.
|
| + // Note: do not visit children from this node, the child SimpleIdentifier in
|
| + // TypeName (i.e. "String") does not have a static type defined.
|
| if (node.type == null) {
|
| _unresolvedTypes.add(node);
|
| } else {
|
| @@ -9927,8 +10892,8 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
| }
|
|
|
| String _getFileName(AstNode node) {
|
| - // TODO (jwren) there are two copies of this method, one here and one in ResolutionVerifier,
|
| - // they should be resolved into a single method
|
| + // TODO (jwren) there are two copies of this method, one here and one in
|
| + // ResolutionVerifier, they should be resolved into a single method
|
| if (node != null) {
|
| AstNode root = node.root;
|
| if (root is CompilationUnit) {
|
| @@ -9939,7 +10904,8 @@ class StaticTypeVerifier extends GeneralizingAstVisitor<Object> {
|
| return "<unknown file- CompilationUnit.getElement() returned null>";
|
| }
|
| } else {
|
| - return "<unknown file- CompilationUnit.getRoot() is not a CompilationUnit>";
|
| + return
|
| + "<unknown file- CompilationUnit.getRoot() is not a CompilationUnit>";
|
| }
|
| }
|
| return "<unknown file- ASTNode is null>";
|
| @@ -10112,6 +11078,20 @@ class SubtypeManagerTest extends EngineTestCase {
|
| */
|
| CompilationUnitElementImpl _definingCompilationUnit;
|
|
|
| + @override
|
| + void setUp() {
|
| + super.setUp();
|
| + AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
|
| + FileBasedSource source =
|
| + new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| + _definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
|
| + _definingCompilationUnit.source = source;
|
| + LibraryElementImpl definingLibrary =
|
| + ElementFactory.library(context, "test");
|
| + definingLibrary.definingCompilationUnit = _definingCompilationUnit;
|
| + _subtypeManager = new SubtypeManager();
|
| + }
|
| +
|
| void test_computeAllSubtypes_infiniteLoop() {
|
| //
|
| // class A extends B
|
| @@ -10120,8 +11100,9 @@ class SubtypeManagerTest extends EngineTestCase {
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| classA.supertype = classB.type;
|
| - _definingCompilationUnit.types = <ClassElement> [classA, classB];
|
| - HashSet<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
|
| + _definingCompilationUnit.types = <ClassElement>[classA, classB];
|
| + HashSet<ClassElement> subtypesOfA =
|
| + _subtypeManager.computeAllSubtypes(classA);
|
| List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
|
| expect(subtypesOfA, hasLength(2));
|
| expect(arraySubtypesOfA, unorderedEquals([classA, classB]));
|
| @@ -10140,10 +11121,13 @@ class SubtypeManagerTest extends EngineTestCase {
|
| ClassElementImpl classC = ElementFactory.classElement("C", classB.type);
|
| ClassElementImpl classD = ElementFactory.classElement("D", classB.type);
|
| ClassElementImpl classE = ElementFactory.classElement("E", classB.type);
|
| - _definingCompilationUnit.types = <ClassElement> [classA, classB, classC, classD, classE];
|
| - HashSet<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
|
| + _definingCompilationUnit.types =
|
| + <ClassElement>[classA, classB, classC, classD, classE];
|
| + HashSet<ClassElement> subtypesOfA =
|
| + _subtypeManager.computeAllSubtypes(classA);
|
| List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
|
| - HashSet<ClassElement> subtypesOfB = _subtypeManager.computeAllSubtypes(classB);
|
| + HashSet<ClassElement> subtypesOfB =
|
| + _subtypeManager.computeAllSubtypes(classB);
|
| List<ClassElement> arraySubtypesOfB = new List.from(subtypesOfB);
|
| expect(subtypesOfA, hasLength(4));
|
| expect(arraySubtypesOfA, unorderedEquals([classB, classC, classD, classE]));
|
| @@ -10156,8 +11140,9 @@ class SubtypeManagerTest extends EngineTestCase {
|
| // class A
|
| //
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| - _definingCompilationUnit.types = <ClassElement> [classA];
|
| - HashSet<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
|
| + _definingCompilationUnit.types = <ClassElement>[classA];
|
| + HashSet<ClassElement> subtypesOfA =
|
| + _subtypeManager.computeAllSubtypes(classA);
|
| expect(subtypesOfA, hasLength(0));
|
| }
|
|
|
| @@ -10168,24 +11153,13 @@ class SubtypeManagerTest extends EngineTestCase {
|
| //
|
| ClassElementImpl classA = ElementFactory.classElement2("A");
|
| ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
|
| - _definingCompilationUnit.types = <ClassElement> [classA, classB];
|
| - HashSet<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
|
| + _definingCompilationUnit.types = <ClassElement>[classA, classB];
|
| + HashSet<ClassElement> subtypesOfA =
|
| + _subtypeManager.computeAllSubtypes(classA);
|
| List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
|
| expect(subtypesOfA, hasLength(1));
|
| expect(arraySubtypesOfA, unorderedEquals([classB]));
|
| }
|
| -
|
| - @override
|
| - void setUp() {
|
| - super.setUp();
|
| - AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
|
| - FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
|
| - _definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
|
| - _definingCompilationUnit.source = source;
|
| - LibraryElementImpl definingLibrary = ElementFactory.library(context, "test");
|
| - definingLibrary.definingCompilationUnit = _definingCompilationUnit;
|
| - _subtypeManager = new SubtypeManager();
|
| - }
|
| }
|
|
|
| /**
|
| @@ -10293,12 +11267,13 @@ class TestTypeProvider implements TypeProvider {
|
| if (_boolType == null) {
|
| ClassElementImpl boolElement = ElementFactory.classElement2("bool");
|
| _boolType = boolElement.type;
|
| - ConstructorElementImpl fromEnvironment = ElementFactory.constructorElement(boolElement, "fromEnvironment", true);
|
| - fromEnvironment.parameters = <ParameterElement> [
|
| + ConstructorElementImpl fromEnvironment =
|
| + ElementFactory.constructorElement(boolElement, "fromEnvironment", true);
|
| + fromEnvironment.parameters = <ParameterElement>[
|
| ElementFactory.requiredParameter2("name", stringType),
|
| ElementFactory.namedParameter2("defaultValue", _boolType)];
|
| fromEnvironment.factory = true;
|
| - boolElement.constructors = <ConstructorElement> [fromEnvironment];
|
| + boolElement.constructors = <ConstructorElement>[fromEnvironment];
|
| }
|
| return _boolType;
|
| }
|
| @@ -10314,8 +11289,10 @@ class TestTypeProvider implements TypeProvider {
|
| @override
|
| InterfaceType get deprecatedType {
|
| if (_deprecatedType == null) {
|
| - ClassElementImpl deprecatedElement = ElementFactory.classElement2("Deprecated");
|
| - deprecatedElement.constructors = <ConstructorElement> [ElementFactory.constructorElement(deprecatedElement, null, true, [stringType])];
|
| + ClassElementImpl deprecatedElement =
|
| + ElementFactory.classElement2("Deprecated");
|
| + deprecatedElement.constructors = <ConstructorElement>[
|
| + ElementFactory.constructorElement(deprecatedElement, null, true, [stringType])];
|
| _deprecatedType = deprecatedElement.type;
|
| }
|
| return _deprecatedType;
|
| @@ -10355,11 +11332,15 @@ class TestTypeProvider implements TypeProvider {
|
|
|
| InterfaceType get iterableType {
|
| if (_iterableType == null) {
|
| - ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable", ["E"]);
|
| + ClassElementImpl iterableElement =
|
| + ElementFactory.classElement2("Iterable", ["E"]);
|
| _iterableType = iterableElement.type;
|
| DartType eType = iterableElement.typeParameters[0].type;
|
| - iterableElement.accessors = <PropertyAccessorElement> [
|
| - ElementFactory.getterElement("iterator", false, iteratorType.substitute4(<DartType> [eType])),
|
| + iterableElement.accessors = <PropertyAccessorElement>[
|
| + ElementFactory.getterElement(
|
| + "iterator",
|
| + false,
|
| + iteratorType.substitute4(<DartType>[eType])),
|
| ElementFactory.getterElement("last", false, eType)];
|
| _propagateTypeArguments(iterableElement);
|
| }
|
| @@ -10368,10 +11349,12 @@ class TestTypeProvider implements TypeProvider {
|
|
|
| InterfaceType get iteratorType {
|
| if (_iteratorType == null) {
|
| - ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator", ["E"]);
|
| + ClassElementImpl iteratorElement =
|
| + ElementFactory.classElement2("Iterator", ["E"]);
|
| _iteratorType = iteratorElement.type;
|
| DartType eType = iteratorElement.typeParameters[0].type;
|
| - iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("current", false, eType)];
|
| + iteratorElement.accessors = <PropertyAccessorElement>[
|
| + ElementFactory.getterElement("current", false, eType)];
|
| _propagateTypeArguments(iteratorElement);
|
| }
|
| return _iteratorType;
|
| @@ -10380,14 +11363,18 @@ class TestTypeProvider implements TypeProvider {
|
| @override
|
| InterfaceType get listType {
|
| if (_listType == null) {
|
| - ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]);
|
| - listElement.constructors = <ConstructorElement> [ElementFactory.constructorElement2(listElement, null)];
|
| + ClassElementImpl listElement =
|
| + ElementFactory.classElement2("List", ["E"]);
|
| + listElement.constructors =
|
| + <ConstructorElement>[ElementFactory.constructorElement2(listElement, null)];
|
| _listType = listElement.type;
|
| DartType eType = listElement.typeParameters[0].type;
|
| - InterfaceType iterableType = this.iterableType.substitute4(<DartType> [eType]);
|
| - listElement.interfaces = <InterfaceType> [iterableType];
|
| - listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("length", false, intType)];
|
| - listElement.methods = <MethodElement> [
|
| + InterfaceType iterableType =
|
| + this.iterableType.substitute4(<DartType>[eType]);
|
| + listElement.interfaces = <InterfaceType>[iterableType];
|
| + listElement.accessors = <PropertyAccessorElement>[
|
| + ElementFactory.getterElement("length", false, intType)];
|
| + listElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("[]", eType, [intType]),
|
| ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, eType]),
|
| ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])];
|
| @@ -10399,12 +11386,14 @@ class TestTypeProvider implements TypeProvider {
|
| @override
|
| InterfaceType get mapType {
|
| if (_mapType == null) {
|
| - ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V"]);
|
| + ClassElementImpl mapElement =
|
| + ElementFactory.classElement2("Map", ["K", "V"]);
|
| _mapType = mapElement.type;
|
| DartType kType = mapElement.typeParameters[0].type;
|
| DartType vType = mapElement.typeParameters[1].type;
|
| - mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("length", false, intType)];
|
| - mapElement.methods = <MethodElement> [
|
| + mapElement.accessors = <PropertyAccessorElement>[
|
| + ElementFactory.getterElement("length", false, intType)];
|
| + mapElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("[]", vType, [objectType]),
|
| ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [kType, vType])];
|
| _propagateTypeArguments(mapElement);
|
| @@ -10433,12 +11422,13 @@ class TestTypeProvider implements TypeProvider {
|
| if (_objectType == null) {
|
| ClassElementImpl objectElement = ElementFactory.object;
|
| _objectType = objectElement.type;
|
| - objectElement.constructors = <ConstructorElement> [ElementFactory.constructorElement2(objectElement, null)];
|
| - objectElement.methods = <MethodElement> [
|
| + objectElement.constructors =
|
| + <ConstructorElement>[ElementFactory.constructorElement2(objectElement, null)];
|
| + objectElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("toString", stringType),
|
| ElementFactory.methodElement("==", boolType, [_objectType]),
|
| ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType])];
|
| - objectElement.accessors = <PropertyAccessorElement> [
|
| + objectElement.accessors = <PropertyAccessorElement>[
|
| ElementFactory.getterElement("hashCode", false, intType),
|
| ElementFactory.getterElement("runtimeType", false, typeType)];
|
| }
|
| @@ -10458,20 +11448,24 @@ class TestTypeProvider implements TypeProvider {
|
| if (_stringType == null) {
|
| _stringType = ElementFactory.classElement2("String").type;
|
| ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
|
| - stringElement.accessors = <PropertyAccessorElement> [
|
| + stringElement.accessors = <PropertyAccessorElement>[
|
| ElementFactory.getterElement("isEmpty", false, boolType),
|
| ElementFactory.getterElement("length", false, intType),
|
| - ElementFactory.getterElement("codeUnits", false, listType.substitute4(<DartType> [intType]))];
|
| - stringElement.methods = <MethodElement> [
|
| + ElementFactory.getterElement(
|
| + "codeUnits",
|
| + false,
|
| + listType.substitute4(<DartType>[intType]))];
|
| + stringElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("+", _stringType, [_stringType]),
|
| ElementFactory.methodElement("toLowerCase", _stringType),
|
| ElementFactory.methodElement("toUpperCase", _stringType)];
|
| - ConstructorElementImpl fromEnvironment = ElementFactory.constructorElement(stringElement, "fromEnvironment", true);
|
| - fromEnvironment.parameters = <ParameterElement> [
|
| + ConstructorElementImpl fromEnvironment =
|
| + ElementFactory.constructorElement(stringElement, "fromEnvironment", true);
|
| + fromEnvironment.parameters = <ParameterElement>[
|
| ElementFactory.requiredParameter2("name", stringType),
|
| ElementFactory.namedParameter2("defaultValue", _stringType)];
|
| fromEnvironment.factory = true;
|
| - stringElement.constructors = <ConstructorElement> [fromEnvironment];
|
| + stringElement.constructors = <ConstructorElement>[fromEnvironment];
|
| }
|
| return _stringType;
|
| }
|
| @@ -10480,9 +11474,10 @@ class TestTypeProvider implements TypeProvider {
|
| InterfaceType get symbolType {
|
| if (_symbolType == null) {
|
| ClassElementImpl symbolClass = ElementFactory.classElement2("Symbol");
|
| - ConstructorElementImpl constructor = ElementFactory.constructorElement(symbolClass, null, true, [stringType]);
|
| + ConstructorElementImpl constructor =
|
| + ElementFactory.constructorElement(symbolClass, null, true, [stringType]);
|
| constructor.factory = true;
|
| - symbolClass.constructors = <ConstructorElement> [constructor];
|
| + symbolClass.constructors = <ConstructorElement>[constructor];
|
| _symbolType = symbolClass.type;
|
| }
|
| return _symbolType;
|
| @@ -10516,7 +11511,8 @@ class TestTypeProvider implements TypeProvider {
|
| _numType = numElement.type;
|
| ClassElementImpl intElement = ElementFactory.classElement("int", _numType);
|
| _intType = intElement.type;
|
| - ClassElementImpl doubleElement = ElementFactory.classElement("double", _numType);
|
| + ClassElementImpl doubleElement =
|
| + ElementFactory.classElement("double", _numType);
|
| _doubleType = doubleElement.type;
|
| //
|
| // Force the referenced types to be cached.
|
| @@ -10527,7 +11523,7 @@ class TestTypeProvider implements TypeProvider {
|
| //
|
| // Add the methods.
|
| //
|
| - numElement.methods = <MethodElement> [
|
| + numElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("+", _numType, [_numType]),
|
| ElementFactory.methodElement("-", _numType, [_numType]),
|
| ElementFactory.methodElement("*", _numType, [_numType]),
|
| @@ -10555,7 +11551,7 @@ class TestTypeProvider implements TypeProvider {
|
| ElementFactory.methodElement("toStringAsExponential", _stringType, [_intType]),
|
| ElementFactory.methodElement("toStringAsPrecision", _stringType, [_intType]),
|
| ElementFactory.methodElement("toRadixString", _stringType, [_intType])];
|
| - intElement.methods = <MethodElement> [
|
| + intElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("&", _intType, [_intType]),
|
| ElementFactory.methodElement("|", _intType, [_intType]),
|
| ElementFactory.methodElement("^", _intType, [_intType]),
|
| @@ -10569,26 +11565,33 @@ class TestTypeProvider implements TypeProvider {
|
| ElementFactory.methodElement("ceil", _intType),
|
| ElementFactory.methodElement("truncate", _intType),
|
| ElementFactory.methodElement("toString", _stringType)];
|
| - ConstructorElementImpl fromEnvironment = ElementFactory.constructorElement(intElement, "fromEnvironment", true);
|
| - fromEnvironment.parameters = <ParameterElement> [
|
| + ConstructorElementImpl fromEnvironment =
|
| + ElementFactory.constructorElement(intElement, "fromEnvironment", true);
|
| + fromEnvironment.parameters = <ParameterElement>[
|
| ElementFactory.requiredParameter2("name", stringType),
|
| ElementFactory.namedParameter2("defaultValue", _intType)];
|
| fromEnvironment.factory = true;
|
| - intElement.constructors = <ConstructorElement> [fromEnvironment];
|
| - List<FieldElement> fields = <FieldElement> [
|
| + intElement.constructors = <ConstructorElement>[fromEnvironment];
|
| + List<FieldElement> fields = <FieldElement>[
|
| ElementFactory.fieldElement("NAN", true, false, true, _doubleType),
|
| ElementFactory.fieldElement("INFINITY", true, false, true, _doubleType),
|
| - ElementFactory.fieldElement("NEGATIVE_INFINITY", true, false, true, _doubleType),
|
| + ElementFactory.fieldElement(
|
| + "NEGATIVE_INFINITY",
|
| + true,
|
| + false,
|
| + true,
|
| + _doubleType),
|
| ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType),
|
| ElementFactory.fieldElement("MAX_FINITE", true, false, true, _doubleType)];
|
| doubleElement.fields = fields;
|
| int fieldCount = fields.length;
|
| - List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>(fieldCount);
|
| + List<PropertyAccessorElement> accessors =
|
| + new List<PropertyAccessorElement>(fieldCount);
|
| for (int i = 0; i < fieldCount; i++) {
|
| accessors[i] = fields[i].getter;
|
| }
|
| doubleElement.accessors = accessors;
|
| - doubleElement.methods = <MethodElement> [
|
| + doubleElement.methods = <MethodElement>[
|
| ElementFactory.methodElement("remainder", _doubleType, [_numType]),
|
| ElementFactory.methodElement("+", _doubleType, [_numType]),
|
| ElementFactory.methodElement("-", _doubleType, [_numType]),
|
| @@ -10612,7 +11615,8 @@ class TestTypeProvider implements TypeProvider {
|
| * @param classElement the element representing the class with type parameters
|
| */
|
| void _propagateTypeArguments(ClassElementImpl classElement) {
|
| - List<DartType> typeArguments = TypeParameterTypeImpl.getTypes(classElement.typeParameters);
|
| + List<DartType> typeArguments =
|
| + TypeParameterTypeImpl.getTypes(classElement.typeParameters);
|
| for (PropertyAccessorElement accessor in classElement.accessors) {
|
| FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl;
|
| functionType.typeArguments = typeArguments;
|
| @@ -10667,7 +11671,8 @@ class TypeOverrideManagerTest extends EngineTestCase {
|
|
|
| void test_getType_enclosedOverride() {
|
| TypeOverrideManager manager = new TypeOverrideManager();
|
| - LocalVariableElementImpl element = ElementFactory.localVariableElement2("v");
|
| + LocalVariableElementImpl element =
|
| + ElementFactory.localVariableElement2("v");
|
| InterfaceType type = ElementFactory.classElement2("C").type;
|
| manager.enterScope();
|
| manager.setType(element, type);
|
| @@ -10677,7 +11682,8 @@ class TypeOverrideManagerTest extends EngineTestCase {
|
|
|
| void test_getType_immediateOverride() {
|
| TypeOverrideManager manager = new TypeOverrideManager();
|
| - LocalVariableElementImpl element = ElementFactory.localVariableElement2("v");
|
| + LocalVariableElementImpl element =
|
| + ElementFactory.localVariableElement2("v");
|
| InterfaceType type = ElementFactory.classElement2("C").type;
|
| manager.enterScope();
|
| manager.setType(element, type);
|
| @@ -10696,7 +11702,6 @@ class TypeOverrideManagerTest extends EngineTestCase {
|
| }
|
| }
|
|
|
| -
|
| class TypePropagationTest extends ResolverTestCase {
|
| void fail_mergePropagatedTypesAtJoinPoint_1() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| @@ -10764,7 +11769,8 @@ f6(x,y) {
|
| void fail_mergePropagatedTypesAtJoinPoint_7() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| //
|
| - // In general [continue]s are unsafe for the purposes of [isAbruptTerminationStatement].
|
| + // In general [continue]s are unsafe for the purposes of
|
| + // [isAbruptTerminationStatement].
|
| //
|
| // This is like example 6, but less tricky: the code in the branch that
|
| // [continue]s is in effect after the [if].
|
| @@ -10792,7 +11798,8 @@ f() {
|
| void fail_mergePropagatedTypesAtJoinPoint_8() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| //
|
| - // In nested loops [breaks]s are unsafe for the purposes of [isAbruptTerminationStatement].
|
| + // In nested loops [breaks]s are unsafe for the purposes of
|
| + // [isAbruptTerminationStatement].
|
| //
|
| // This is a combination of 6 and 7: we use an unlabeled [break]
|
| // like a continue for the outer loop / like a labeled [break] to
|
| @@ -10826,7 +11833,10 @@ f() {
|
| main() {
|
| var v = (() {return 42;})();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_as() {
|
| @@ -10848,9 +11858,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -10869,7 +11881,8 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| @@ -10887,7 +11900,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[2] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeProvider.intType));
|
| @@ -10905,7 +11919,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[2] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeProvider.doubleType));
|
| @@ -10927,17 +11942,29 @@ main() {
|
| unit = resolveCompilationUnit(source, library);
|
| }
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v; // declare", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v; // declare",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.staticType, same(typeProvider.intType));
|
| expect(identifier.propagatedType, same(null));
|
| }
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = null;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v = null;",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.staticType, same(typeProvider.intType));
|
| expect(identifier.propagatedType, same(null));
|
| }
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v; // return", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v; // return",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.staticType, same(typeProvider.intType));
|
| expect(identifier.propagatedType, same(null));
|
| }
|
| @@ -10954,7 +11981,11 @@ main(CanvasElement canvas) {
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "context", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "context",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.propagatedType.name, "CanvasRenderingContext2D");
|
| }
|
|
|
| @@ -10968,7 +11999,10 @@ import 'lib.dart';
|
| f(A a) {
|
| return a.v; // marker
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_finalPropertyInducingVariable_classMember_instance_inherited() {
|
| @@ -10983,10 +12017,14 @@ class B extends A {
|
| return v; // marker
|
| }
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| - void test_finalPropertyInducingVariable_classMember_instance_propagatedTarget() {
|
| + void
|
| + test_finalPropertyInducingVariable_classMember_instance_propagatedTarget() {
|
| addNamedSource("/lib.dart", r'''
|
| class A {
|
| final v = 0;
|
| @@ -10998,7 +12036,10 @@ f(p) {
|
| return p.v; // marker
|
| }
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_finalPropertyInducingVariable_classMember_static() {
|
| @@ -11011,7 +12052,10 @@ import 'lib.dart';
|
| f() {
|
| return A.V; // marker
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_finalPropertyInducingVariable_topLevelVaraible_prefixed() {
|
| @@ -11021,7 +12065,10 @@ import 'lib.dart' as p;
|
| f() {
|
| var v2 = p.V; // marker prefixed
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_finalPropertyInducingVariable_topLevelVaraible_simple() {
|
| @@ -11031,7 +12078,10 @@ import 'lib.dart';
|
| f() {
|
| return V; // marker simple
|
| }''';
|
| - _assertTypeOfMarkedExpression(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertTypeOfMarkedExpression(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_forEach() {
|
| @@ -11050,12 +12100,17 @@ main() {
|
| InterfaceType stringType = typeProvider.stringType;
|
| // in the declaration
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in", (node) => node is SimpleIdentifier);
|
| + 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);
|
| + SimpleIdentifier identifier =
|
| + EngineTestCase.findNode(unit, code, "e;", (node) => node is SimpleIdentifier);
|
| expect(identifier.propagatedType, same(stringType));
|
| }
|
| }
|
| @@ -11078,16 +12133,26 @@ f(MyMap<int, String> m) {
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // k
|
| DartType intType = typeProvider.intType;
|
| - FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", (node) => node is SimpleFormalParameter);
|
| + FormalParameter kParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "k, ",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(kParameter.identifier.propagatedType, same(intType));
|
| - SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier kIdentifier =
|
| + EngineTestCase.findNode(unit, code, "k;", (node) => node is SimpleIdentifier);
|
| expect(kIdentifier.propagatedType, same(intType));
|
| expect(kIdentifier.staticType, same(typeProvider.dynamicType));
|
| // v
|
| DartType stringType = typeProvider.stringType;
|
| - FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", (node) => node is SimpleFormalParameter);
|
| + FormalParameter vParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v)",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(vParameter.identifier.propagatedType, same(stringType));
|
| - SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier vIdentifier =
|
| + EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| expect(vIdentifier.propagatedType, same(stringType));
|
| expect(vIdentifier.staticType, same(typeProvider.dynamicType));
|
| }
|
| @@ -11108,15 +12173,24 @@ f(MyMap<int, String> m) {
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // k
|
| DartType intType = typeProvider.intType;
|
| - FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", (node) => node is SimpleFormalParameter);
|
| + FormalParameter kParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "k, ",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(kParameter.identifier.propagatedType, same(intType));
|
| // v
|
| DartType stringType = typeProvider.stringType;
|
| - FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", (node) => node is SimpleFormalParameter);
|
| + FormalParameter vParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v)",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(vParameter.identifier.propagatedType, same(stringType));
|
| }
|
|
|
| - void test_functionExpression_asInvocationArgument_functionExpressionInvocation() {
|
| + void
|
| + test_functionExpression_asInvocationArgument_functionExpressionInvocation() {
|
| String code = r'''
|
| main() {
|
| (f(String value)) {} ((v) {
|
| @@ -11131,10 +12205,12 @@ main() {
|
| // v
|
| DartType dynamicType = typeProvider.dynamicType;
|
| DartType stringType = typeProvider.stringType;
|
| - FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", (node) => node is FormalParameter);
|
| + FormalParameter vParameter =
|
| + EngineTestCase.findNode(unit, code, "v)", (node) => node is FormalParameter);
|
| expect(vParameter.identifier.propagatedType, same(stringType));
|
| expect(vParameter.identifier.staticType, same(dynamicType));
|
| - SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier vIdentifier =
|
| + EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| expect(vIdentifier.propagatedType, same(stringType));
|
| expect(vIdentifier.staticType, same(dynamicType));
|
| }
|
| @@ -11156,10 +12232,15 @@ f(MyList list) {
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // v
|
| DartType intType = typeProvider.intType;
|
| - FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", (node) => node is SimpleFormalParameter);
|
| + FormalParameter vParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v)",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(vParameter.identifier.propagatedType, same(null));
|
| expect(vParameter.identifier.staticType, same(intType));
|
| - SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier vIdentifier =
|
| + EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| expect(vIdentifier.staticType, same(intType));
|
| expect(vIdentifier.propagatedType, same(null));
|
| }
|
| @@ -11179,8 +12260,14 @@ x() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // () => 0
|
| - FunctionExpression functionExpression = EngineTestCase.findNode(unit, code, "() => 0)", (node) => node is FunctionExpression);
|
| - expect((functionExpression.staticType as FunctionType).parameters.length, same(0));
|
| + FunctionExpression functionExpression = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "() => 0)",
|
| + (node) => node is FunctionExpression);
|
| + expect(
|
| + (functionExpression.staticType as FunctionType).parameters.length,
|
| + same(0));
|
| expect(functionExpression.propagatedType, same(null));
|
| }
|
|
|
| @@ -11201,10 +12288,15 @@ f(MyList<String> list) {
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // v
|
| DartType stringType = typeProvider.stringType;
|
| - FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", (node) => node is SimpleFormalParameter);
|
| + FormalParameter vParameter = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v)",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(vParameter.identifier.propagatedType, same(stringType));
|
| expect(vParameter.identifier.staticType, same(typeProvider.objectType));
|
| - SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier vIdentifier =
|
| + EngineTestCase.findNode(unit, code, "v;", (node) => node is SimpleIdentifier);
|
| expect(vIdentifier.propagatedType, same(stringType));
|
| }
|
|
|
| @@ -11225,13 +12317,25 @@ main(Future<int> firstFuture) {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| // p1
|
| - FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", (node) => node is SimpleFormalParameter);
|
| + FormalParameter p1 = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "p1) {",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(p1.identifier.propagatedType, same(typeProvider.intType));
|
| // p2
|
| - FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", (node) => node is SimpleFormalParameter);
|
| + FormalParameter p2 = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "p2) {",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(p2.identifier.propagatedType, same(typeProvider.doubleType));
|
| // p3
|
| - FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", (node) => node is SimpleFormalParameter);
|
| + FormalParameter p3 = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "p3) {",
|
| + (node) => node is SimpleFormalParameter);
|
| expect(p3.identifier.propagatedType, same(typeProvider.stringType));
|
| }
|
|
|
| @@ -11246,11 +12350,13 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| NodeList<Statement> statements = body.block.statements;
|
| // Type of 'v' in declaration.
|
| {
|
| - VariableDeclarationStatement statement = statements[0] as VariableDeclarationStatement;
|
| + VariableDeclarationStatement statement =
|
| + statements[0] as VariableDeclarationStatement;
|
| SimpleIdentifier variableName = statement.variables.variables[0].name;
|
| expect(variableName.staticType, same(typeProvider.dynamicType));
|
| expect(variableName.propagatedType, same(typeProvider.intType));
|
| @@ -11272,8 +12378,10 @@ f() {
|
| LibraryElement library = resolve(source);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| - ExpressionStatement statement = body.block.statements[1] as ExpressionStatement;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| + ExpressionStatement statement =
|
| + body.block.statements[1] as ExpressionStatement;
|
| PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier;
|
| SimpleIdentifier variableName = invocation.prefix;
|
| expect(variableName.propagatedType, same(typeProvider.stringType));
|
| @@ -11294,12 +12402,20 @@ main() {
|
| unit = resolveCompilationUnit(source, library);
|
| }
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = null;", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v = null;",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.staticType, same(typeProvider.intType));
|
| expect(identifier.propagatedType, same(null));
|
| }
|
| {
|
| - SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v; // marker", (node) => node is SimpleIdentifier);
|
| + SimpleIdentifier identifier = EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + "v; // marker",
|
| + (node) => node is SimpleIdentifier);
|
| expect(identifier.staticType, same(typeProvider.intType));
|
| expect(identifier.propagatedType, same(null));
|
| }
|
| @@ -11318,10 +12434,13 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[0] as ReturnStatement;
|
| - ConditionalExpression conditional = statement.expression as ConditionalExpression;
|
| - SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifier;
|
| + ConditionalExpression conditional =
|
| + statement.expression as ConditionalExpression;
|
| + SimpleIdentifier variableName =
|
| + conditional.thenExpression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
|
|
| @@ -11342,9 +12461,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -11363,12 +12484,14 @@ A f(A p) {
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| - // ClassDeclaration classA = (ClassDeclaration) unit.getDeclarations().get(0);
|
| - // InterfaceType typeA = classA.getElement().getType();
|
| +// ClassDeclaration classA = (ClassDeclaration) unit.getDeclarations().get(0);
|
| +// InterfaceType typeA = classA.getElement().getType();
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(null));
|
| }
|
| @@ -11390,9 +12513,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -11411,7 +12536,8 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| @@ -11435,7 +12561,8 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| @@ -11457,9 +12584,11 @@ A f(A p) {
|
| assertNoErrors(source);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
|
| MethodInvocation invocation = statement.expression as MethodInvocation;
|
| expect(invocation.methodName.propagatedElement, isNotNull);
|
| }
|
| @@ -11480,9 +12609,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| WhileStatement whileStatement = body.block.statements[0] as WhileStatement;
|
| - ReturnStatement statement = (whileStatement.body as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (whileStatement.body as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -11500,10 +12631,13 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[0] as ReturnStatement;
|
| - ConditionalExpression conditional = statement.expression as ConditionalExpression;
|
| - SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifier;
|
| + ConditionalExpression conditional =
|
| + statement.expression as ConditionalExpression;
|
| + SimpleIdentifier variableName =
|
| + conditional.elseExpression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
|
|
| @@ -11524,9 +12658,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.elseStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.elseStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -11547,9 +12683,11 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| IfStatement ifStatement = body.block.statements[0] as IfStatement;
|
| - ReturnStatement statement = (ifStatement.elseStatement as Block).statements[0] as ReturnStatement;
|
| + ReturnStatement statement =
|
| + (ifStatement.elseStatement as Block).statements[0] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| }
|
| @@ -11568,7 +12706,8 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| @@ -11590,7 +12729,8 @@ A f(var p) {
|
| ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
|
| InterfaceType typeA = classA.element.type;
|
| FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
|
| expect(variableName.propagatedType, same(typeA));
|
| @@ -11622,8 +12762,10 @@ f(var message) {
|
| // more precise type would cause no hint. For example, for code like the
|
| // following, when the propagated type of [x] is [A] -- as happens for the
|
| // fix these tests aim to warn against -- there is no warning for
|
| - // calling a method defined on [B] but not [A] (there aren't any, but pretend),
|
| - // but there is for calling a method not defined on either.
|
| +
|
| +
|
| + // calling a method defined on [B] but not [A] (there aren't any, but
|
| + // pretend), but there is for calling a method not defined on either.
|
| // By not overriding the propagated type via an is-check that loses
|
| // precision, we get more precise completion under an is-check. However,
|
| // I can only imagine strange code would make use of this feature.
|
| @@ -11675,7 +12817,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| IndexExpression indexExpression = statement.expression as IndexExpression;
|
| expect(indexExpression.propagatedType, isNull);
|
| @@ -11692,7 +12835,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| IndexExpression indexExpression = statement.expression as IndexExpression;
|
| expect(indexExpression.propagatedType, isNull);
|
| @@ -11715,7 +12859,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
|
| InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
|
| @@ -11737,7 +12882,8 @@ f() {
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
|
| - BlockFunctionBody body = function.functionExpression.body as BlockFunctionBody;
|
| + BlockFunctionBody body =
|
| + function.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[1] as ReturnStatement;
|
| SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
|
| InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
|
| @@ -11766,7 +12912,8 @@ f5(x) {
|
| void test_mergePropagatedTypesAtJoinPoint_6() {
|
| // https://code.google.com/p/dart/issues/detail?id=19929
|
| //
|
| - // Labeled [break]s are unsafe for the purposes of [isAbruptTerminationStatement].
|
| + // Labeled [break]s are unsafe for the purposes of
|
| + // [isAbruptTerminationStatement].
|
| //
|
| // This is tricky: the [break] jumps back above the [if], making
|
| // it into a loop of sorts. The [if] type-propagation code assumes
|
| @@ -11837,7 +12984,10 @@ String f() => null;
|
| main() {
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.stringType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.stringType);
|
| }
|
|
|
| void test_propagatedReturnType_function_lessSpecificStaticReturnType() {
|
| @@ -11846,7 +12996,10 @@ Object f() => 42;
|
| main() {
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_propagatedReturnType_function_moreSpecificStaticReturnType() {
|
| @@ -11855,10 +13008,14 @@ int f(v) => (v as num);
|
| main() {
|
| var v = f(3);
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| - void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleReturns() {
|
| + void
|
| + test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleReturns() {
|
| String code = r'''
|
| f() {
|
| if (true) return 0;
|
| @@ -11867,10 +13024,14 @@ f() {
|
| main() {
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.numType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.numType);
|
| }
|
|
|
| - void test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn() {
|
| + void
|
| + test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn() {
|
| String code = r'''
|
| f() {
|
| var z = 42;
|
| @@ -11879,7 +13040,10 @@ f() {
|
| main() {
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_propagatedReturnType_function_noReturnTypeName_expressionBody() {
|
| @@ -11888,7 +13052,10 @@ f() => 42;
|
| main() {
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_propagatedReturnType_localFunction() {
|
| @@ -11897,7 +13064,10 @@ main() {
|
| f() => 42;
|
| var v = f();
|
| }''';
|
| - _assertPropagatedReturnType(code, typeProvider.dynamicType, typeProvider.intType);
|
| + _assertPropagatedReturnType(
|
| + code,
|
| + typeProvider.dynamicType,
|
| + typeProvider.intType);
|
| }
|
|
|
| void test_query() {
|
| @@ -11927,7 +13097,8 @@ main() {
|
| FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
|
| BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody;
|
| ReturnStatement statement = body.block.statements[11] as ReturnStatement;
|
| - NodeList<Expression> elements = (statement.expression as ListLiteral).elements;
|
| + NodeList<Expression> elements =
|
| + (statement.expression as ListLiteral).elements;
|
| expect(elements[0].propagatedType.name, "AnchorElement");
|
| expect(elements[1].propagatedType.name, "AnchorElement");
|
| expect(elements[2].propagatedType.name, "BodyElement");
|
| @@ -11945,7 +13116,8 @@ main() {
|
| * @param code the code that assigns the value to the variable "v", no matter how. We check that
|
| * "v" has expected static and propagated type.
|
| */
|
| - void _assertPropagatedReturnType(String code, DartType expectedStaticType, DartType expectedPropagatedType) {
|
| + void _assertPropagatedReturnType(String code, DartType expectedStaticType,
|
| + DartType expectedPropagatedType) {
|
| SimpleIdentifier identifier = _findMarkedIdentifier(code, "v = ");
|
| expect(identifier.staticType, same(expectedStaticType));
|
| expect(identifier.propagatedType, same(expectedPropagatedType));
|
| @@ -11959,7 +13131,8 @@ main() {
|
| * @param expectedPropagatedType if non-null, check actual static type is equal to this.
|
| * @throws Exception
|
| */
|
| - void _assertTypeOfMarkedExpression(String code, DartType expectedStaticType, DartType expectedPropagatedType) {
|
| + void _assertTypeOfMarkedExpression(String code, DartType expectedStaticType,
|
| + DartType expectedPropagatedType) {
|
| SimpleIdentifier identifier = _findMarkedIdentifier(code, "; // marker");
|
| if (expectedStaticType != null) {
|
| expect(identifier.staticType, expectedStaticType);
|
| @@ -11985,24 +13158,32 @@ main() {
|
| assertNoErrors(source);
|
| verify([source]);
|
| CompilationUnit unit = resolveCompilationUnit(source, library);
|
| - // Could generalize this further by making [SimpleIdentifier.class] a parameter.
|
| - return EngineTestCase.findNode(unit, code, marker, (node) => node is SimpleIdentifier);
|
| + // Could generalize this further by making [SimpleIdentifier.class] a
|
| + // parameter.
|
| + return EngineTestCase.findNode(
|
| + unit,
|
| + code,
|
| + marker,
|
| + (node) => node is SimpleIdentifier);
|
| } catch (exception) {
|
| - // Is there a better exception to throw here? The point is that an assertion failure
|
| - // here should be a failure, in both "test_*" and "fail_*" tests.
|
| - // However, an assertion failure is success for the purpose of "fail_*" tests, so
|
| - // without catching them here "fail_*" tests can succeed by failing for the wrong reason.
|
| + // Is there a better exception to throw here? The point is that an
|
| + // assertion failure here should be a failure, in both "test_*" and
|
| + // "fail_*" tests. However, an assertion failure is success for the
|
| + // purpose of "fail_*" tests, so without catching them here "fail_*" tests
|
| + // can succeed by failing for the wrong reason.
|
| throw new JavaException("Unexexpected assertion failure: $exception");
|
| }
|
| }
|
| }
|
|
|
| +
|
| class TypeProviderImplTest extends EngineTestCase {
|
| void test_creation() {
|
| //
|
| - // Create a mock library element with the types expected to be in dart:core. We cannot use
|
| - // either ElementFactory or TestTypeProvider (which uses ElementFactory) because we side-effect
|
| - // the elements in ways that would break other tests.
|
| + // Create a mock library element with the types expected to be in dart:core.
|
| + // We cannot use either ElementFactory or TestTypeProvider (which uses
|
| + // ElementFactory) because we side-effect the elements in ways that would
|
| + // break other tests.
|
| //
|
| InterfaceType objectType = _classElement("Object", null).type;
|
| InterfaceType boolType = _classElement("bool", objectType).type;
|
| @@ -12016,8 +13197,9 @@ class TypeProviderImplTest extends EngineTestCase {
|
| InterfaceType stringType = _classElement("String", objectType).type;
|
| InterfaceType symbolType = _classElement("Symbol", objectType).type;
|
| InterfaceType typeType = _classElement("Type", objectType).type;
|
| - CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.dart");
|
| - coreUnit.types = <ClassElement> [
|
| + CompilationUnitElementImpl coreUnit =
|
| + new CompilationUnitElementImpl("core.dart");
|
| + coreUnit.types = <ClassElement>[
|
| boolType.element,
|
| doubleType.element,
|
| functionType.element,
|
| @@ -12029,7 +13211,9 @@ class TypeProviderImplTest extends EngineTestCase {
|
| stringType.element,
|
| symbolType.element,
|
| typeType.element];
|
| - LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(new AnalysisContextImpl(), AstFactory.libraryIdentifier2(["dart.core"]));
|
| + LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
|
| + new AnalysisContextImpl(),
|
| + AstFactory.libraryIdentifier2(["dart.core"]));
|
| coreLibrary.definingCompilationUnit = coreUnit;
|
| //
|
| // Create a type provider and ensure that it can return the expected types.
|
| @@ -12050,18 +13234,23 @@ class TypeProviderImplTest extends EngineTestCase {
|
| expect(provider.typeType, same(typeType));
|
| }
|
|
|
| - ClassElement _classElement(String typeName, InterfaceType superclassType, [List<String> parameterNames]) {
|
| - ClassElementImpl element = new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
|
| + ClassElement _classElement(String typeName, InterfaceType superclassType,
|
| + [List<String> parameterNames]) {
|
| + ClassElementImpl element =
|
| + new ClassElementImpl.forNode(AstFactory.identifier3(typeName));
|
| element.supertype = superclassType;
|
| InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element);
|
| element.type = type;
|
| if (parameterNames != null) {
|
| int count = parameterNames.length;
|
| if (count > 0) {
|
| - List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElementImpl>(count);
|
| - List<TypeParameterTypeImpl> typeArguments = new List<TypeParameterTypeImpl>(count);
|
| + List<TypeParameterElementImpl> typeParameters =
|
| + new List<TypeParameterElementImpl>(count);
|
| + List<TypeParameterTypeImpl> typeArguments =
|
| + new List<TypeParameterTypeImpl>(count);
|
| for (int i = 0; i < count; i++) {
|
| - TypeParameterElementImpl typeParameter = new TypeParameterElementImpl.forNode(AstFactory.identifier3(parameterNames[i]));
|
| + TypeParameterElementImpl typeParameter =
|
| + new TypeParameterElementImpl.forNode(AstFactory.identifier3(parameterNames[i]));
|
| typeParameters[i] = typeParameter;
|
| typeArguments[i] = new TypeParameterTypeImpl(typeParameter);
|
| typeParameter.type = typeArguments[i];
|
| @@ -12142,21 +13331,28 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| SourceFactory factory = new SourceFactory([new FileUriResolver()]);
|
| AnalysisContextImpl context = new AnalysisContextImpl();
|
| context.sourceFactory = factory;
|
| - Source librarySource = new FileBasedSource.con1(FileUtilities2.createFile("/lib.dart"));
|
| + Source librarySource =
|
| + new FileBasedSource.con1(FileUtilities2.createFile("/lib.dart"));
|
| _library = new Library(context, _listener, librarySource);
|
| - LibraryElementImpl element = new LibraryElementImpl.forNode(context, AstFactory.libraryIdentifier2(["lib"]));
|
| - element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart");
|
| + LibraryElementImpl element = new LibraryElementImpl.forNode(
|
| + context,
|
| + AstFactory.libraryIdentifier2(["lib"]));
|
| + element.definingCompilationUnit =
|
| + new CompilationUnitElementImpl("lib.dart");
|
| _library.libraryElement = element;
|
| _typeProvider = new TestTypeProvider();
|
| - _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvider);
|
| - _implicitConstructorBuilder = new ImplicitConstructorBuilder.con1(_library, librarySource, _typeProvider);
|
| + _visitor =
|
| + new TypeResolverVisitor.con1(_library, librarySource, _typeProvider);
|
| + _implicitConstructorBuilder =
|
| + new ImplicitConstructorBuilder.con1(_library, librarySource, _typeProvider);
|
| }
|
|
|
| void test_visitCatchClause_exception() {
|
| // catch (e)
|
| CatchClause clause = AstFactory.catchClause("e");
|
| SimpleIdentifier exceptionParameter = clause.exceptionParameter;
|
| - exceptionParameter.staticElement = new LocalVariableElementImpl.forNode(exceptionParameter);
|
| + exceptionParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(exceptionParameter);
|
| _resolveCatchClause(clause, _typeProvider.dynamicType, null);
|
| _listener.assertNoErrors();
|
| }
|
| @@ -12165,10 +13361,15 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| // catch (e, s)
|
| CatchClause clause = AstFactory.catchClause2("e", "s");
|
| SimpleIdentifier exceptionParameter = clause.exceptionParameter;
|
| - exceptionParameter.staticElement = new LocalVariableElementImpl.forNode(exceptionParameter);
|
| + exceptionParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(exceptionParameter);
|
| SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
|
| - stackTraceParameter.staticElement = new LocalVariableElementImpl.forNode(stackTraceParameter);
|
| - _resolveCatchClause(clause, _typeProvider.dynamicType, _typeProvider.stackTraceType);
|
| + stackTraceParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(stackTraceParameter);
|
| + _resolveCatchClause(
|
| + clause,
|
| + _typeProvider.dynamicType,
|
| + _typeProvider.stackTraceType);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -12178,8 +13379,13 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| TypeName exceptionType = AstFactory.typeName(exceptionElement);
|
| CatchClause clause = AstFactory.catchClause4(exceptionType, "e");
|
| SimpleIdentifier exceptionParameter = clause.exceptionParameter;
|
| - exceptionParameter.staticElement = new LocalVariableElementImpl.forNode(exceptionParameter);
|
| - _resolveCatchClause(clause, exceptionElement.type, null, [exceptionElement]);
|
| + exceptionParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(exceptionParameter);
|
| + _resolveCatchClause(
|
| + clause,
|
| + exceptionElement.type,
|
| + null,
|
| + [exceptionElement]);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -12190,10 +13396,16 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| (exceptionType.name as SimpleIdentifier).staticElement = exceptionElement;
|
| CatchClause clause = AstFactory.catchClause5(exceptionType, "e", "s");
|
| SimpleIdentifier exceptionParameter = clause.exceptionParameter;
|
| - exceptionParameter.staticElement = new LocalVariableElementImpl.forNode(exceptionParameter);
|
| + exceptionParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(exceptionParameter);
|
| SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
|
| - stackTraceParameter.staticElement = new LocalVariableElementImpl.forNode(stackTraceParameter);
|
| - _resolveCatchClause(clause, exceptionElement.type, _typeProvider.stackTraceType, [exceptionElement]);
|
| + stackTraceParameter.staticElement =
|
| + new LocalVariableElementImpl.forNode(stackTraceParameter);
|
| + _resolveCatchClause(
|
| + clause,
|
| + exceptionElement.type,
|
| + _typeProvider.stackTraceType,
|
| + [exceptionElement]);
|
| _listener.assertNoErrors();
|
| }
|
|
|
| @@ -12206,10 +13418,19 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ClassElement elementB = ElementFactory.classElement2("B");
|
| ClassElement elementC = ElementFactory.classElement2("C");
|
| ClassElement elementD = ElementFactory.classElement2("D");
|
| - ExtendsClause extendsClause = AstFactory.extendsClause(AstFactory.typeName(elementB));
|
| - WithClause withClause = AstFactory.withClause([AstFactory.typeName(elementC)]);
|
| - ImplementsClause implementsClause = AstFactory.implementsClause([AstFactory.typeName(elementD)]);
|
| - ClassDeclaration declaration = AstFactory.classDeclaration(null, "A", null, extendsClause, withClause, implementsClause);
|
| + ExtendsClause extendsClause =
|
| + AstFactory.extendsClause(AstFactory.typeName(elementB));
|
| + WithClause withClause =
|
| + AstFactory.withClause([AstFactory.typeName(elementC)]);
|
| + ImplementsClause implementsClause =
|
| + AstFactory.implementsClause([AstFactory.typeName(elementD)]);
|
| + ClassDeclaration declaration = AstFactory.classDeclaration(
|
| + null,
|
| + "A",
|
| + null,
|
| + extendsClause,
|
| + withClause,
|
| + implementsClause);
|
| declaration.name.staticElement = elementA;
|
| _resolveNode(declaration, [elementA, elementB, elementC, elementD]);
|
| expect(elementA.supertype, same(elementB.type));
|
| @@ -12229,9 +13450,12 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| // }
|
| ClassElementImpl elementA = ElementFactory.classElement2("A");
|
| ClassElementImpl elementB = ElementFactory.classElement2("B");
|
| - elementB.methods = <MethodElement> [ElementFactory.methodElement("A", VoidTypeImpl.instance)];
|
| - ExtendsClause extendsClause = AstFactory.extendsClause(AstFactory.typeName(elementA));
|
| - ClassDeclaration declaration = AstFactory.classDeclaration(null, "B", null, extendsClause, null, null);
|
| + elementB.methods =
|
| + <MethodElement>[ElementFactory.methodElement("A", VoidTypeImpl.instance)];
|
| + ExtendsClause extendsClause =
|
| + AstFactory.extendsClause(AstFactory.typeName(elementA));
|
| + ClassDeclaration declaration =
|
| + AstFactory.classDeclaration(null, "B", null, extendsClause, null, null);
|
| declaration.name.staticElement = elementB;
|
| _resolveNode(declaration, [elementA, elementB]);
|
| expect(elementB.supertype, same(elementA.type));
|
| @@ -12244,9 +13468,17 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| ClassElement elementB = ElementFactory.classElement2("B");
|
| ClassElement elementC = ElementFactory.classElement2("C");
|
| ClassElement elementD = ElementFactory.classElement2("D");
|
| - WithClause withClause = AstFactory.withClause([AstFactory.typeName(elementC)]);
|
| - ImplementsClause implementsClause = AstFactory.implementsClause([AstFactory.typeName(elementD)]);
|
| - ClassTypeAlias alias = AstFactory.classTypeAlias("A", null, null, AstFactory.typeName(elementB), withClause, implementsClause);
|
| + WithClause withClause =
|
| + AstFactory.withClause([AstFactory.typeName(elementC)]);
|
| + ImplementsClause implementsClause =
|
| + AstFactory.implementsClause([AstFactory.typeName(elementD)]);
|
| + ClassTypeAlias alias = AstFactory.classTypeAlias(
|
| + "A",
|
| + null,
|
| + null,
|
| + AstFactory.typeName(elementB),
|
| + withClause,
|
| + implementsClause);
|
| alias.name.staticElement = elementA;
|
| _resolveNode(alias, [elementA, elementB, elementC, elementD]);
|
| expect(elementA.supertype, same(elementB.type));
|
| @@ -12285,8 +13517,13 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| WithClause withClause =
|
| AstFactory.withClause([AstFactory.typeName(classM, [])]);
|
| ClassElement classC = ElementFactory.classElement2('C', []);
|
| - ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
|
| - AstFactory.typeName(classB, []), withClause, null);
|
| + ClassTypeAlias alias = AstFactory.classTypeAlias(
|
| + 'C',
|
| + null,
|
| + null,
|
| + AstFactory.typeName(classB, []),
|
| + withClause,
|
| + null);
|
| alias.name.staticElement = classC;
|
| _resolveNode(alias, [classT, classB, classM, classC]);
|
| expect(classC.constructors, hasLength(1));
|
| @@ -12316,8 +13553,13 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| WithClause withClause =
|
| AstFactory.withClause([AstFactory.typeName(classM, [])]);
|
| ClassElement classC = ElementFactory.classElement2('C', []);
|
| - ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
|
| - AstFactory.typeName(classB, []), withClause, null);
|
| + ClassTypeAlias alias = AstFactory.classTypeAlias(
|
| + 'C',
|
| + null,
|
| + null,
|
| + AstFactory.typeName(classB, []),
|
| + withClause,
|
| + null);
|
| alias.name.staticElement = classC;
|
| _resolveNode(alias, [classT, classB, classM, classC]);
|
| expect(classC.constructors, hasLength(1));
|
| @@ -12330,7 +13572,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| expect(constructor.localVariables, hasLength(0));
|
| expect(constructor.parameters, hasLength(1));
|
| expect(constructor.parameters[0].type, equals(classT.type));
|
| - expect(constructor.parameters[0].name,
|
| + expect(
|
| + constructor.parameters[0].name,
|
| equals(constructorB.parameters[0].name));
|
| }
|
|
|
| @@ -12347,8 +13590,13 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| WithClause withClause =
|
| AstFactory.withClause([AstFactory.typeName(classM, [])]);
|
| ClassElement classC = ElementFactory.classElement2('C', []);
|
| - ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
|
| - AstFactory.typeName(classB, []), withClause, null);
|
| + ClassTypeAlias alias = AstFactory.classTypeAlias(
|
| + 'C',
|
| + null,
|
| + null,
|
| + AstFactory.typeName(classB, []),
|
| + withClause,
|
| + null);
|
| alias.name.staticElement = classC;
|
| _resolveNode(alias, [classB, classM, classC]);
|
| expect(classC.constructors, hasLength(1));
|
| @@ -12366,13 +13614,23 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| InterfaceType intType = _typeProvider.intType;
|
| TypeName intTypeName = AstFactory.typeName4("int");
|
| String innerParameterName = "a";
|
| - SimpleFormalParameter parameter = AstFactory.simpleFormalParameter3(innerParameterName);
|
| - parameter.identifier.staticElement = ElementFactory.requiredParameter(innerParameterName);
|
| + SimpleFormalParameter parameter =
|
| + AstFactory.simpleFormalParameter3(innerParameterName);
|
| + parameter.identifier.staticElement =
|
| + ElementFactory.requiredParameter(innerParameterName);
|
| String outerParameterName = "p";
|
| - FormalParameter node = AstFactory.fieldFormalParameter(null, intTypeName, outerParameterName, AstFactory.formalParameterList([parameter]));
|
| - node.identifier.staticElement = ElementFactory.requiredParameter(outerParameterName);
|
| + FormalParameter node = AstFactory.fieldFormalParameter(
|
| + null,
|
| + intTypeName,
|
| + outerParameterName,
|
| + AstFactory.formalParameterList([parameter]));
|
| + node.identifier.staticElement =
|
| + ElementFactory.requiredParameter(outerParameterName);
|
| DartType parameterType = _resolveFormalParameter(node, [intType.element]);
|
| - EngineTestCase.assertInstanceOf((obj) => obj is FunctionType, FunctionType, parameterType);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is FunctionType,
|
| + FunctionType,
|
| + parameterType);
|
| FunctionType functionType = parameterType as FunctionType;
|
| expect(functionType.returnType, same(intType));
|
| expect(functionType.parameters, hasLength(1));
|
| @@ -12381,8 +13639,10 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
|
|
| void test_visitFieldFormalParameter_noType() {
|
| String parameterName = "p";
|
| - FormalParameter node = AstFactory.fieldFormalParameter(Keyword.VAR, null, parameterName);
|
| - node.identifier.staticElement = ElementFactory.requiredParameter(parameterName);
|
| + FormalParameter node =
|
| + AstFactory.fieldFormalParameter(Keyword.VAR, null, parameterName);
|
| + node.identifier.staticElement =
|
| + ElementFactory.requiredParameter(parameterName);
|
| expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -12391,8 +13651,10 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| InterfaceType intType = _typeProvider.intType;
|
| TypeName intTypeName = AstFactory.typeName4("int");
|
| String parameterName = "p";
|
| - FormalParameter node = AstFactory.fieldFormalParameter(null, intTypeName, parameterName);
|
| - node.identifier.staticElement = ElementFactory.requiredParameter(parameterName);
|
| + FormalParameter node =
|
| + AstFactory.fieldFormalParameter(null, intTypeName, parameterName);
|
| + node.identifier.staticElement =
|
| + ElementFactory.requiredParameter(parameterName);
|
| expect(_resolveFormalParameter(node, [intType.element]), same(intType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -12400,7 +13662,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| void test_visitSimpleFormalParameter_noType() {
|
| // p
|
| FormalParameter node = AstFactory.simpleFormalParameter3("p");
|
| - node.identifier.staticElement = new ParameterElementImpl.forNode(AstFactory.identifier3("p"));
|
| + node.identifier.staticElement =
|
| + new ParameterElementImpl.forNode(AstFactory.identifier3("p"));
|
| expect(_resolveFormalParameter(node), same(_typeProvider.dynamicType));
|
| _listener.assertNoErrors();
|
| }
|
| @@ -12409,7 +13672,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| // int p
|
| InterfaceType intType = _typeProvider.intType;
|
| ClassElement intElement = intType.element;
|
| - FormalParameter node = AstFactory.simpleFormalParameter4(AstFactory.typeName(intElement), "p");
|
| + FormalParameter node =
|
| + AstFactory.simpleFormalParameter4(AstFactory.typeName(intElement), "p");
|
| SimpleIdentifier identifier = node.identifier;
|
| ParameterElementImpl element = new ParameterElementImpl.forNode(identifier);
|
| identifier.staticElement = element;
|
| @@ -12429,7 +13693,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| void test_visitTypeName_parameters_arguments() {
|
| ClassElement classA = ElementFactory.classElement2("A", ["E"]);
|
| ClassElement classB = ElementFactory.classElement2("B");
|
| - TypeName typeName = AstFactory.typeName(classA, [AstFactory.typeName(classB)]);
|
| + TypeName typeName =
|
| + AstFactory.typeName(classA, [AstFactory.typeName(classB)]);
|
| typeName.type = null;
|
| _resolveNode(typeName, [classA, classB]);
|
| InterfaceType resultType = typeName.type as InterfaceType;
|
| @@ -12472,7 +13737,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| * @param definedElements the elements that are to be defined in the scope in which the element is
|
| * being resolved
|
| */
|
| - void _resolveCatchClause(CatchClause node, DartType exceptionType, InterfaceType stackTraceType, [List<Element> definedElements]) {
|
| + void _resolveCatchClause(CatchClause node, DartType exceptionType,
|
| + InterfaceType stackTraceType, [List<Element> definedElements]) {
|
| _resolveNode(node, definedElements);
|
| SimpleIdentifier exceptionParameter = node.exceptionParameter;
|
| if (exceptionParameter != null) {
|
| @@ -12493,7 +13759,8 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| * being resolved
|
| * @return the type associated with the parameter
|
| */
|
| - DartType _resolveFormalParameter(FormalParameter node, [List<Element> definedElements]) {
|
| + DartType _resolveFormalParameter(FormalParameter node,
|
| + [List<Element> definedElements]) {
|
| _resolveNode(node, definedElements);
|
| return (node.identifier.staticElement as ParameterElement).type;
|
| }
|
| @@ -12518,35 +13785,69 @@ class TypeResolverVisitorTest extends EngineTestCase {
|
| }
|
| }
|
|
|
| -main() {
|
| - groupSep = ' | ';
|
| - runReflectiveTests(AnalysisDeltaTest);
|
| - runReflectiveTests(ChangeSetTest);
|
| - runReflectiveTests(EnclosedScopeTest);
|
| - runReflectiveTests(LibraryImportScopeTest);
|
| - runReflectiveTests(LibraryScopeTest);
|
| - runReflectiveTests(ScopeBuilderTest);
|
| - runReflectiveTests(ScopeTest);
|
| - runReflectiveTests(DeclarationMatcherTest);
|
| - runReflectiveTests(ElementResolverTest);
|
| - runReflectiveTests(IncrementalResolverTest);
|
| - runReflectiveTests(InheritanceManagerTest);
|
| - runReflectiveTests(LibraryElementBuilderTest);
|
| - runReflectiveTests(LibraryResolver2Test);
|
| - runReflectiveTests(LibraryResolverTest);
|
| - runReflectiveTests(LibraryTest);
|
| - runReflectiveTests(StaticTypeAnalyzerTest);
|
| - runReflectiveTests(StaticTypeAnalyzer2Test);
|
| - runReflectiveTests(SubtypeManagerTest);
|
| - runReflectiveTests(TypeOverrideManagerTest);
|
| - runReflectiveTests(TypeProviderImplTest);
|
| - runReflectiveTests(TypeResolverVisitorTest);
|
| - runReflectiveTests(CheckedModeCompileTimeErrorCodeTest);
|
| - runReflectiveTests(ErrorResolverTest);
|
| - runReflectiveTests(HintCodeTest);
|
| - runReflectiveTests(MemberMapTest);
|
| - runReflectiveTests(NonHintCodeTest);
|
| - runReflectiveTests(SimpleResolverTest);
|
| - runReflectiveTests(StrictModeTest);
|
| - runReflectiveTests(TypePropagationTest);
|
| +class _AnalysisContextFactory_initContextWithCore extends DirectoryBasedDartSdk
|
| + {
|
| +
|
| + _AnalysisContextFactory_initContextWithCore(JavaFile arg0)
|
| + : super(arg0);
|
| +
|
| + @override
|
| + LibraryMap initialLibraryMap(bool useDart2jsPaths) {
|
| + LibraryMap map = new LibraryMap();
|
| + _addLibrary(map, DartSdk.DART_ASYNC, false, "async.dart");
|
| + _addLibrary(map, DartSdk.DART_CORE, false, "core.dart");
|
| + _addLibrary(map, DartSdk.DART_HTML, false, "html_dartium.dart");
|
| + _addLibrary(map, AnalysisContextFactory._DART_MATH, false, "math.dart");
|
| + _addLibrary(
|
| + map,
|
| + AnalysisContextFactory._DART_INTERCEPTORS,
|
| + true,
|
| + "_interceptors.dart");
|
| + _addLibrary(
|
| + map,
|
| + AnalysisContextFactory._DART_JS_HELPER,
|
| + true,
|
| + "_js_helper.dart");
|
| + return map;
|
| + }
|
| +
|
| + void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) {
|
| + SdkLibraryImpl library = new SdkLibraryImpl(uri);
|
| + if (isInternal) {
|
| + library.category = "Internal";
|
| + }
|
| + library.path = path;
|
| + map.setLibrary(uri, library);
|
| + }
|
| +}
|
| +
|
| +class _SimpleResolverTest_localVariable_types_invoked extends
|
| + RecursiveAstVisitor<Object> {
|
| + final SimpleResolverTest test;
|
| +
|
| + List<bool> found;
|
| +
|
| + List<CaughtException> thrownException;
|
| +
|
| + _SimpleResolverTest_localVariable_types_invoked(this.test, this.found,
|
| + this.thrownException)
|
| + : super();
|
| +
|
| + @override
|
| + Object visitSimpleIdentifier(SimpleIdentifier node) {
|
| + if (node.name == "myVar" && node.parent is MethodInvocation) {
|
| + try {
|
| + found[0] = true;
|
| + // check static type
|
| + DartType staticType = node.staticType;
|
| + expect(staticType, same(test.typeProvider.dynamicType));
|
| + // check propagated type
|
| + FunctionType propagatedType = node.propagatedType as FunctionType;
|
| + expect(propagatedType.returnType, test.typeProvider.stringType);
|
| + } on AnalysisException catch (e, stackTrace) {
|
| + thrownException[0] = new CaughtException(e, stackTrace);
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| }
|
|
|