| Index: pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer_experimental/lib/src/generated/resolver.dart b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| index b87c5afa0c5ac09b949f5bc4be0d327f9fccf11e..87480c7bafff437a1ad4db6fba6d3fe07f39ce79 100644
|
| --- a/pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| @@ -1,8 +1,6 @@
|
| // This code was auto-generated, is not intended to be edited, and is subject to
|
| // significant change. Please see the README file for more information.
|
| -
|
| library engine.resolver;
|
| -
|
| import 'dart:collection';
|
| import 'java_core.dart';
|
| import 'java_engine.dart';
|
| @@ -19,15 +17,13 @@ import 'html.dart' as ht;
|
| import 'engine.dart';
|
| import 'constant.dart';
|
| import 'element.dart' as __imp_combi show HideCombinator, ShowCombinator;
|
| -
|
| -
|
| /**
|
| * Instances of the class {@code CompilationUnitBuilder} build an element model for a single
|
| * compilation unit.
|
| * @coverage dart.engine.resolver
|
| */
|
| class CompilationUnitBuilder {
|
| -
|
| +
|
| /**
|
| * Build the compilation unit element for the given source.
|
| * @param source the source describing the compilation unit
|
| @@ -53,34 +49,33 @@ class CompilationUnitBuilder {
|
| return element;
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ElementBuilder} traverse an AST structure and build the element
|
| * model representing the AST structure.
|
| * @coverage dart.engine.resolver
|
| */
|
| class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * The element holder associated with the element that is currently being built.
|
| */
|
| ElementHolder _currentHolder;
|
| -
|
| +
|
| /**
|
| * A flag indicating whether a variable declaration is in the context of a field declaration.
|
| */
|
| bool _inFieldContext = false;
|
| -
|
| +
|
| /**
|
| * A flag indicating whether a variable declaration is within the body of a method or function.
|
| */
|
| bool _inFunction = false;
|
| -
|
| +
|
| /**
|
| * A flag indicating whether the class currently being visited can be used as a mixin.
|
| */
|
| bool _isValidMixin = false;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created element builder to build the elements for a compilation unit.
|
| * @param initialHolder the element holder associated with the compilation unit being built
|
| @@ -577,7 +572,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Creates the {@link ConstructorElement}s array with the single default constructor element.
|
| * @param interfaceType the interface type for which to create a default constructor
|
| @@ -602,7 +597,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| }
|
| return typeArguments;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the body of the function that contains the given parameter, or {@code null} if no
|
| * function body could be found.
|
| @@ -621,7 +616,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given token is a token for the given keyword.
|
| * @param token the token being tested
|
| @@ -629,7 +624,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| * @return {@code true} if the given token is a token for the given keyword
|
| */
|
| bool matches(sc.Token token, sc.Keyword keyword2) => token != null && identical(token.type, sc.TokenType.KEYWORD) && identical(((token as sc.KeywordToken)).keyword, keyword2);
|
| -
|
| +
|
| /**
|
| * Make the given holder be the current holder while visiting the given node.
|
| * @param holder the holder that will gather elements that are built while visiting the children
|
| @@ -646,7 +641,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Make the given holder be the current holder while visiting the children of the given node.
|
| * @param holder the holder that will gather elements that are built while visiting the children
|
| @@ -664,7 +659,6 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ElementHolder} hold on to elements created while traversing an AST
|
| * structure so that they can be accessed when creating their enclosing element.
|
| @@ -800,7 +794,6 @@ class ElementHolder {
|
| return new List.from(_typeVariables);
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code HtmlUnitBuilder} build an element model for a single HTML unit.
|
| */
|
| @@ -810,42 +803,42 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| static String _SCRIPT = "script";
|
| static String _SRC = "src";
|
| static String _TYPE = "type";
|
| -
|
| +
|
| /**
|
| * The analysis context in which the element model will be built.
|
| */
|
| InternalAnalysisContext _context;
|
| -
|
| +
|
| /**
|
| * The error listener to which errors will be reported.
|
| */
|
| RecordingErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * The line information associated with the source for which an element is being built, or{@code null} if we are not building an element.
|
| */
|
| LineInfo _lineInfo;
|
| -
|
| +
|
| /**
|
| * The HTML element being built.
|
| */
|
| HtmlElementImpl _htmlElement;
|
| -
|
| +
|
| /**
|
| * The elements in the path from the HTML unit to the current tag node.
|
| */
|
| List<ht.XmlTagNode> _parentNodes;
|
| -
|
| +
|
| /**
|
| * The script elements being built.
|
| */
|
| List<HtmlScriptElement> _scripts;
|
| -
|
| +
|
| /**
|
| * A set of the libraries that were resolved while resolving the HTML unit.
|
| */
|
| Set<Library> _resolvedLibraries = new Set<Library>();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created HTML unit builder.
|
| * @param context the analysis context in which the element model will be built
|
| @@ -854,7 +847,7 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| this._context = context;
|
| this._errorListener = new RecordingErrorListener();
|
| }
|
| -
|
| +
|
| /**
|
| * Build the HTML element for the given source.
|
| * @param source the source describing the compilation unit
|
| @@ -862,7 +855,7 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| * @throws AnalysisException if the analysis could not be performed
|
| */
|
| HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, _context.parseHtmlUnit(source));
|
| -
|
| +
|
| /**
|
| * Build the HTML element for the given source.
|
| * @param source the source describing the compilation unit
|
| @@ -879,13 +872,13 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| unit.element = result;
|
| return result;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the listener to which analysis errors will be reported.
|
| * @return the listener to which analysis errors will be reported
|
| */
|
| RecordingErrorListener get errorListener => _errorListener;
|
| -
|
| +
|
| /**
|
| * Return an array containing information about all of the libraries that were resolved.
|
| * @return an array containing the libraries that were resolved
|
| @@ -979,7 +972,7 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the first source attribute for the given tag node, or {@code null} if it does not exist.
|
| * @param node the node containing attributes
|
| @@ -993,7 +986,7 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Determine if the specified node is a Dart script.
|
| * @param node the node to be tested (not {@code null})
|
| @@ -1016,7 +1009,7 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Report an error with the given error code at the given location. Use the given arguments to
|
| * compose the error message.
|
| @@ -1029,42 +1022,41 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| _errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, length, errorCode, arguments));
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code DeclarationResolver} are used to resolve declarations in an AST
|
| * structure to already built elements.
|
| */
|
| class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * The compilation unit containing the AST nodes being visited.
|
| */
|
| CompilationUnitElement _enclosingUnit;
|
| -
|
| +
|
| /**
|
| * The function type alias containing the AST nodes being visited, or {@code null} if we are not
|
| * in the scope of a function type alias.
|
| */
|
| FunctionTypeAliasElement _enclosingAlias;
|
| -
|
| +
|
| /**
|
| * The class containing the AST nodes being visited, or {@code null} if we are not in the scope of
|
| * a class.
|
| */
|
| ClassElement _enclosingClass;
|
| -
|
| +
|
| /**
|
| * The method or function containing the AST nodes being visited, or {@code null} if we are not in
|
| * the scope of a method or function.
|
| */
|
| ExecutableElement _enclosingExecutable;
|
| -
|
| +
|
| /**
|
| * The parameter containing the AST nodes being visited, or {@code null} if we are not in the
|
| * scope of a parameter.
|
| */
|
| ParameterElement _enclosingParameter;
|
| -
|
| +
|
| /**
|
| * Resolve the declarations within the given compilation unit to the elements rooted at the given
|
| * element.
|
| @@ -1385,7 +1377,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| }
|
| return super.visitVariableDeclaration(node);
|
| }
|
| -
|
| +
|
| /**
|
| * Append the value of the given string literal to the given string builder.
|
| * @param builder the builder to which the string's value is to be appended
|
| @@ -1404,7 +1396,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| throw new IllegalArgumentException();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element for the part with the given source, or {@code null} if there is no element
|
| * for the given source.
|
| @@ -1420,7 +1412,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element in the given array of elements that was created for the declaration at the
|
| * given offset. This method should only be used when there is no name
|
| @@ -1429,7 +1421,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| * @return the element at the given offset
|
| */
|
| Element find2(List<Element> elements, int offset) => find4(elements, "", offset);
|
| -
|
| +
|
| /**
|
| * Return the element in the given array of elements that was created for the declaration with the
|
| * given name.
|
| @@ -1442,7 +1434,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| identifier.element = element;
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element in the given array of elements that was created for the declaration with the
|
| * given name at the given offset.
|
| @@ -1459,7 +1451,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the export element from the given array whose library has the given source, or{@code null} if there is no such export.
|
| * @param exports the export elements being searched
|
| @@ -1475,7 +1467,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the import element from the given array whose library has the given source and that has
|
| * the given prefix, or {@code null} if there is no such import.
|
| @@ -1502,7 +1494,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the value of the given string literal, or {@code null} if the string is not a constant
|
| * string without any string interpolation.
|
| @@ -1522,7 +1514,6 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| return builder.toString().trim();
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ElementResolver} are used by instances of {@link ResolverVisitor}to resolve references within the AST structure to the elements being referenced. The requirements
|
| * for the element resolver are:
|
| @@ -1571,7 +1562,7 @@ class DeclarationResolver extends RecursiveASTVisitor<Object> {
|
| * @coverage dart.engine.resolver
|
| */
|
| class ElementResolver extends SimpleASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * @return {@code true} if the given identifier is the return type of a constructor declaration.
|
| */
|
| @@ -1583,7 +1574,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * @return {@code true} if the given identifier is the return type of a factory constructor
|
| * declaration.
|
| @@ -1596,7 +1587,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks if the given 'super' expression is used in the valid context.
|
| * @param node the 'super' expression to analyze
|
| @@ -1621,30 +1612,37 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * The resolver driving this participant.
|
| */
|
| ResolverVisitor _resolver;
|
| -
|
| +
|
| + /**
|
| + * A flag indicating whether we are running in strict mode. In strict mode, error reporting is
|
| + * based exclusively on the static type information.
|
| + */
|
| + bool _strictMode = false;
|
| +
|
| /**
|
| * The name of the method that can be implemented by a class to allow its instances to be invoked
|
| * as if they were a function.
|
| */
|
| static String CALL_METHOD_NAME = "call";
|
| -
|
| +
|
| /**
|
| * The name of the method that will be invoked if an attempt is made to invoke an undefined method
|
| * on an object.
|
| */
|
| static String _NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod";
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param resolver the resolver driving this participant
|
| */
|
| ElementResolver(ResolverVisitor resolver) {
|
| this._resolver = resolver;
|
| + _strictMode = resolver.definingLibrary.context.analysisOptions.strictMode;
|
| }
|
| Object visitAssignmentExpression(AssignmentExpression node) {
|
| sc.Token operator2 = node.operator;
|
| @@ -1660,7 +1658,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| Type2 propagatedType = getPropagatedType(leftHandSide2);
|
| MethodElement propagatedMethod = lookUpMethod(leftHandSide2, propagatedType, methodName);
|
| node.element = select3(staticMethod, propagatedMethod);
|
| - if (shouldReportMissingMember(staticType, staticMethod) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| + if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operator2, [methodName, staticType.displayName]);
|
| }
|
| }
|
| @@ -1679,7 +1677,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| Type2 propagatedType = getPropagatedType(leftOperand2);
|
| MethodElement propagatedMethod = lookUpMethod(leftOperand2, propagatedType, methodName);
|
| node.element = select3(staticMethod, propagatedMethod);
|
| - if (shouldReportMissingMember(staticType, staticMethod) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| + if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operator2, [methodName, staticType.displayName]);
|
| }
|
| }
|
| @@ -2066,7 +2064,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| Type2 propagatedType = getPropagatedType(operand2);
|
| MethodElement propagatedMethod = lookUpMethod(operand2, propagatedType, methodName);
|
| node.element = select3(staticMethod, propagatedMethod);
|
| - if (shouldReportMissingMember(staticType, staticMethod) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| + if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.displayName]);
|
| }
|
| return null;
|
| @@ -2107,7 +2105,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| Type2 propagatedType = getPropagatedType(operand2);
|
| MethodElement propagatedMethod = lookUpMethod(operand2, propagatedType, methodName);
|
| node.element = select3(staticMethod, propagatedMethod);
|
| - if (shouldReportMissingMember(staticType, staticMethod) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| + if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operator2, [methodName, staticType.displayName]);
|
| }
|
| }
|
| @@ -2219,7 +2217,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| setMetadata(node.element, node);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Generate annotation elements for each of the annotations in the given node list and add them to
|
| * the given list of elements.
|
| @@ -2234,7 +2232,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Given that we have found code to invoke the given element, return the error code that should be
|
| * reported, or {@code null} if no error should be reported.
|
| @@ -2297,7 +2295,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given class declares a method named "noSuchMethod" and is not the
|
| * class 'Object'.
|
| @@ -2311,7 +2309,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| MethodElement methodElement = classElement.lookUpMethod(_NO_SUCH_METHOD_METHOD_NAME, _resolver.definingLibrary);
|
| return methodElement != null && methodElement.enclosingElement.supertype != null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given element represents a class that declares a method named
|
| * "noSuchMethod" and is not the class 'Object'.
|
| @@ -2325,7 +2323,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * If the given element is a setter, return the getter associated with it. Otherwise, return the
|
| * element unchanged.
|
| @@ -2338,7 +2336,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * Look for any declarations of the given identifier that are imported using a prefix. Return the
|
| * element that was found, or {@code null} if the name is not imported using a prefix.
|
| @@ -2365,14 +2363,14 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the name of the method invoked by the given postfix expression.
|
| * @param node the postfix expression being invoked
|
| * @return the name of the method invoked by the expression
|
| */
|
| String getPostfixOperator(PostfixExpression node) => (identical(node.operator.type, sc.TokenType.PLUS_PLUS)) ? sc.TokenType.PLUS.lexeme : sc.TokenType.MINUS.lexeme;
|
| -
|
| +
|
| /**
|
| * Return the name of the method invoked by the given postfix expression.
|
| * @param node the postfix expression being invoked
|
| @@ -2391,7 +2389,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| return operator2.lexeme;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated type of the given expression that is to be used for type analysis.
|
| * @param expression the expression whose type is to be returned
|
| @@ -2404,7 +2402,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return propagatedType2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the static type of the given expression that is to be used for type analysis.
|
| * @param expression the expression whose type is to be returned
|
| @@ -2420,7 +2418,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return staticType2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element representing the superclass of the given class.
|
| * @param targetClass the class whose superclass is to be returned
|
| @@ -2433,7 +2431,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return superType.element;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given type represents an object that could be invoked using the call
|
| * operator '()'.
|
| @@ -2450,7 +2448,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given element is a static element.
|
| * @param element the element being tested
|
| @@ -2464,7 +2462,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Looks up the method element with the given name for index expression, reports{@link StaticWarningCode#UNDEFINED_OPERATOR} if not found.
|
| * @param node the index expression to resolve
|
| @@ -2478,7 +2476,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| MethodElement propagatedMethod = lookUpMethod(target, propagatedType, methodName);
|
| node.staticElement = staticMethod;
|
| node.element = select3(staticMethod, propagatedMethod);
|
| - if (shouldReportMissingMember(staticType, staticMethod) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| + if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedMethod))) {
|
| sc.Token leftBracket2 = node.leftBracket;
|
| sc.Token rightBracket2 = node.rightBracket;
|
| if (leftBracket2 == null || rightBracket2 == null) {
|
| @@ -2493,7 +2491,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the getter with the given name in the given type. Return the element representing the
|
| * getter that was found, or {@code null} if there is no getter with the given name.
|
| @@ -2519,7 +2517,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the getter with the given name in the interfaces implemented by the given type, either
|
| * directly or indirectly. Return the element representing the getter that was found, or{@code null} if there is no getter with the given name.
|
| @@ -2554,7 +2552,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return lookUpGetterInInterfaces(superclass2, true, getterName, visitedInterfaces);
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the method or getter with the given name in the given type. Return the element
|
| * representing the method or getter that was found, or {@code null} if there is no method or
|
| @@ -2579,7 +2577,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the method or getter with the given name in the interfaces implemented by the given
|
| * type, either directly or indirectly. Return the element representing the method or getter that
|
| @@ -2619,7 +2617,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return lookUpGetterOrMethodInInterfaces(superclass2, true, memberName, visitedInterfaces);
|
| }
|
| -
|
| +
|
| /**
|
| * Find the element corresponding to the given label node in the current label scope.
|
| * @param parentNode the node containing the given label
|
| @@ -2658,7 +2656,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return labelElement;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the method with the given name in the given type. Return the element representing the
|
| * method that was found, or {@code null} if there is no method with the given name.
|
| @@ -2684,7 +2682,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the method with the given name in the interfaces implemented by the given type, either
|
| * directly or indirectly. Return the element representing the method that was found, or{@code null} if there is no method with the given name.
|
| @@ -2719,7 +2717,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return lookUpMethodInInterfaces(superclass2, true, methodName, visitedInterfaces);
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the setter with the given name in the given type. Return the element representing the
|
| * setter that was found, or {@code null} if there is no setter with the given name.
|
| @@ -2745,7 +2743,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Look up the setter with the given name in the interfaces implemented by the given type, either
|
| * directly or indirectly. Return the element representing the setter that was found, or{@code null} if there is no setter with the given name.
|
| @@ -2780,7 +2778,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return lookUpSetterInInterfaces(superclass2, true, setterName, visitedInterfaces);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the binary operator that is invoked by the given compound assignment operator.
|
| * @param operator the assignment operator being mapped
|
| @@ -2816,7 +2814,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| AnalysisEngine.instance.logger.logError("Failed to map ${operator.lexeme} to it's corresponding operator");
|
| return operator;
|
| }
|
| -
|
| +
|
| /**
|
| * Record the fact that the given AST node was resolved to the given element.
|
| * @param node the AST node that was resolved
|
| @@ -2826,7 +2824,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| node.staticElement = element2;
|
| node.element = element2;
|
| }
|
| -
|
| +
|
| /**
|
| * Record the fact that the given AST node was resolved to the given elements.
|
| * @param node the AST node that was resolved
|
| @@ -2842,7 +2840,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| node.element = element;
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * Given a list of arguments and the element that will be invoked using those argument, compute
|
| * the list of parameters that correspond to the list of arguments.
|
| @@ -2857,7 +2855,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| List<ParameterElement> parameters2 = executableElement.parameters;
|
| resolveArgumentsToParameters2(reportError, argumentList, parameters2);
|
| }
|
| -
|
| +
|
| /**
|
| * Given a list of arguments and the element that will be invoked using those argument, compute
|
| * the list of parameters that correspond to the list of arguments.
|
| @@ -2920,7 +2918,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| argumentList.correspondingParameters = resolvedParameters;
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the names in the given combinators in the scope of the given library.
|
| * @param library the library that defines the names
|
| @@ -2946,7 +2944,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Given an invocation of the form 'e.m(a1, ..., an)', resolve 'e.m' to the element being invoked.
|
| * If the returned element is a method, then the method will be invoked. If the returned element
|
| @@ -2978,7 +2976,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Given an invocation of the form 'm(a1, ..., an)', resolve 'm' to the element being invoked. If
|
| * the returned element is a method, then the method will be invoked. If the returned element is a
|
| @@ -3001,7 +2999,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * Given that we are accessing a property of the given type with the given name, return the
|
| * element that represents the property.
|
| @@ -3031,7 +3029,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| ExecutableElement propagatedElement = resolveProperty(target, propagatedType, propertyName);
|
| Element selectedElement = select2(staticElement, propagatedElement);
|
| propertyName.element = selectedElement;
|
| - if (shouldReportMissingMember(staticType, staticElement) && (propagatedType == null || shouldReportMissingMember(propagatedType, propagatedElement))) {
|
| + if (shouldReportMissingMember(staticType, staticElement) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedElement))) {
|
| bool staticNoSuchMethod = staticType != null && classDeclaresNoSuchMethod2(staticType.element);
|
| bool propagatedNoSuchMethod = propagatedType != null && classDeclaresNoSuchMethod2(propagatedType.element);
|
| if (!staticNoSuchMethod && !propagatedNoSuchMethod) {
|
| @@ -3054,7 +3052,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the given simple identifier if possible. Return the element to which it could be
|
| * resolved, or {@code null} if it could not be resolved. This does not record the results of the
|
| @@ -3096,7 +3094,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return element;
|
| }
|
| -
|
| +
|
| /**
|
| * If the given type is a type variable, resolve it to the type that should be used when looking
|
| * up members. Otherwise, return the original type.
|
| @@ -3114,7 +3112,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Given two possible error codes for the same piece of code, one computed using static type
|
| * information and the other using propagated type information, return the error code that should
|
| @@ -3129,7 +3127,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| return propagatedError;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated element if it is not {@code null}, or the static element if it is.
|
| * @param staticElement the element computed using static type information
|
| @@ -3137,7 +3135,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| * @return the more specific of the two elements
|
| */
|
| ExecutableElement select2(ExecutableElement staticElement, ExecutableElement propagatedElement) => propagatedElement != null ? propagatedElement : staticElement;
|
| -
|
| +
|
| /**
|
| * Return the propagated method if it is not {@code null}, or the static method if it is.
|
| * @param staticMethod the method computed using static type information
|
| @@ -3145,7 +3143,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| * @return the more specific of the two methods
|
| */
|
| MethodElement select3(MethodElement staticMethod, MethodElement propagatedMethod) => propagatedMethod != null ? propagatedMethod : staticMethod;
|
| -
|
| +
|
| /**
|
| * Given a node that can have annotations associated with it and the element to which that node
|
| * has been resolved, create the annotations in the element model representing the annotations on
|
| @@ -3174,7 +3172,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| ((element as ElementImpl)).metadata = new List.from(annotationList);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if we should report an error as a result of looking up a member in the
|
| * given type and not finding any member.
|
| @@ -3192,7 +3190,6 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| return true;
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code SyntheticIdentifier} implement an identifier that can be used to
|
| * look up names in the lexical scope when there is no identifier in the AST structure. There is
|
| @@ -3200,12 +3197,12 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| * an invocation of a top-level function imported with a prefix.
|
| */
|
| class ElementResolver_SyntheticIdentifier extends Identifier {
|
| -
|
| +
|
| /**
|
| * The name of the synthetic identifier.
|
| */
|
| String _name;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created synthetic identifier to have the given name.
|
| * @param name the name of the synthetic identifier
|
| @@ -3222,37 +3219,36 @@ class ElementResolver_SyntheticIdentifier extends Identifier {
|
| void visitChildren(ASTVisitor<Object> visitor) {
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code InheritanceManager} manage the knowledge of where class members
|
| * (methods, getters & setters) are inherited from.
|
| * @coverage dart.engine.resolver
|
| */
|
| class InheritanceManager {
|
| -
|
| +
|
| /**
|
| * The {@link LibraryElement} that is managed by this manager.
|
| */
|
| LibraryElement _library;
|
| -
|
| +
|
| /**
|
| * This is a mapping between each {@link ClassElement} and a map between the {@link String} member
|
| * names and the associated {@link ExecutableElement} in the mixin and superclass chain.
|
| */
|
| Map<ClassElement, Map<String, ExecutableElement>> _classLookup;
|
| -
|
| +
|
| /**
|
| * This is a mapping between each {@link ClassElement} and a map between the {@link String} member
|
| * names and the associated {@link ExecutableElement} in the interface set.
|
| */
|
| Map<ClassElement, Map<String, ExecutableElement>> _interfaceLookup;
|
| -
|
| +
|
| /**
|
| * A map between each visited {@link ClassElement} and the set of {@link AnalysisError}s found on
|
| * the class element.
|
| */
|
| Map<ClassElement, Set<AnalysisError>> _errorsInClassElement = new Map<ClassElement, Set<AnalysisError>>();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created inheritance manager.
|
| * @param library the library element context that the inheritance mappings are being generated
|
| @@ -3262,14 +3258,14 @@ class InheritanceManager {
|
| _classLookup = new Map<ClassElement, Map<String, ExecutableElement>>();
|
| _interfaceLookup = new Map<ClassElement, Map<String, ExecutableElement>>();
|
| }
|
| -
|
| +
|
| /**
|
| * Return the set of {@link AnalysisError}s found on the passed {@link ClassElement}, or{@code null} if there are none.
|
| * @param classElt the class element to query
|
| * @return the set of {@link AnalysisError}s found on the passed {@link ClassElement}, or{@code null} if there are none
|
| */
|
| Set<AnalysisError> getErrors(ClassElement classElt) => _errorsInClassElement[classElt];
|
| -
|
| +
|
| /**
|
| * Get and return a mapping between the set of all string names of the members inherited from the
|
| * passed {@link ClassElement} superclass hierarchy, and the associated {@link ExecutableElement}.
|
| @@ -3277,7 +3273,7 @@ class InheritanceManager {
|
| * @return a mapping between the set of all members inherited from the passed {@link ClassElement}superclass hierarchy, and the associated {@link ExecutableElement}
|
| */
|
| Map<String, ExecutableElement> getMapOfMembersInheritedFromClasses(ClassElement classElt) => computeClassChainLookupMap(classElt, new Set<ClassElement>());
|
| -
|
| +
|
| /**
|
| * Get and return a mapping between the set of all string names of the members inherited from the
|
| * passed {@link ClassElement} interface hierarchy, and the associated {@link ExecutableElement}.
|
| @@ -3285,7 +3281,7 @@ class InheritanceManager {
|
| * @return a mapping between the set of all string names of the members inherited from the passed{@link ClassElement} interface hierarchy, and the associated {@link ExecutableElement}.
|
| */
|
| Map<String, ExecutableElement> getMapOfMembersInheritedFromInterfaces(ClassElement classElt) => computeInterfaceLookupMap(classElt, new Set<ClassElement>());
|
| -
|
| +
|
| /**
|
| * Given some {@link ClassElement class element} and some member name, this returns the{@link ExecutableElement executable element} that the class inherits from the mixins,
|
| * superclasses or interfaces, that has the member name, if no member is inherited {@code null} is
|
| @@ -3305,7 +3301,7 @@ class InheritanceManager {
|
| }
|
| return executable;
|
| }
|
| -
|
| +
|
| /**
|
| * Given some {@link ClassElement class element} and some member name, this returns the{@link ExecutableElement executable element} that the class either declares itself, or
|
| * inherits, that has the member name, if no member is inherited {@code null} is returned.
|
| @@ -3321,7 +3317,7 @@ class InheritanceManager {
|
| }
|
| return lookupInheritance(classElt, memberName);
|
| }
|
| -
|
| +
|
| /**
|
| * Set the new library element context.
|
| * @param library the new library element
|
| @@ -3329,7 +3325,7 @@ class InheritanceManager {
|
| void set libraryElement(LibraryElement library2) {
|
| this._library = library2;
|
| }
|
| -
|
| +
|
| /**
|
| * This method takes some inherited {@link FunctionType}, and resolves all the parameterized types
|
| * in the function type, dependent on the class in which it is being overridden.
|
| @@ -3358,7 +3354,7 @@ class InheritanceManager {
|
| }
|
| return functionTypeToReturn;
|
| }
|
| -
|
| +
|
| /**
|
| * Compute and return a mapping between the set of all string names of the members inherited from
|
| * the passed {@link ClassElement} superclass hierarchy, and the associated{@link ExecutableElement}.
|
| @@ -3402,7 +3398,7 @@ class InheritanceManager {
|
| _classLookup[classElt] = resultMap;
|
| return resultMap;
|
| }
|
| -
|
| +
|
| /**
|
| * Compute and return the inheritance path given the context of a type and a member that is
|
| * overridden in the inheritance path (for which the type is in the path).
|
| @@ -3448,7 +3444,7 @@ class InheritanceManager {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Compute and return a mapping between the set of all string names of the members inherited from
|
| * the passed {@link ClassElement} interface hierarchy, and the associated{@link ExecutableElement}.
|
| @@ -3599,7 +3595,7 @@ class InheritanceManager {
|
| _interfaceLookup[classElt] = resultMap;
|
| return resultMap;
|
| }
|
| -
|
| +
|
| /**
|
| * Given some {@link ClassElement}, this method finds and returns the {@link ExecutableElement} of
|
| * the passed name in the class element. Static members, members in super types and members not
|
| @@ -3623,7 +3619,7 @@ class InheritanceManager {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Record the passed map with the set of all members (methods, getters and setters) in the class
|
| * into the passed map.
|
| @@ -3644,7 +3640,7 @@ class InheritanceManager {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * This method is used to report errors on when they are found computing inheritance information.
|
| * See {@link ErrorVerifier#checkForInconsistentMethodInheritance()} to see where these generated
|
| @@ -3664,7 +3660,6 @@ class InheritanceManager {
|
| javaSetAdd(errorSet, new AnalysisError.con2(classElt.source, offset, length, errorCode, arguments));
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code Library} represent the data about a single library during the
|
| * resolution of some (possibly different) library. They are not intended to be used except during
|
| @@ -3672,63 +3667,63 @@ class InheritanceManager {
|
| * @coverage dart.engine.resolver
|
| */
|
| class Library {
|
| -
|
| +
|
| /**
|
| * The analysis context in which this library is being analyzed.
|
| */
|
| InternalAnalysisContext _analysisContext;
|
| -
|
| +
|
| /**
|
| * The inheritance manager which is used for this member lookups in this library.
|
| */
|
| InheritanceManager _inheritanceManager;
|
| -
|
| +
|
| /**
|
| * The listener to which analysis errors will be reported.
|
| */
|
| AnalysisErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * The source specifying the defining compilation unit of this library.
|
| */
|
| Source _librarySource;
|
| -
|
| +
|
| /**
|
| * The library element representing this library.
|
| */
|
| LibraryElementImpl _libraryElement;
|
| -
|
| +
|
| /**
|
| * A list containing all of the libraries that are imported into this library.
|
| */
|
| Map<ImportDirective, Library> _importedLibraries = new Map<ImportDirective, Library>();
|
| -
|
| +
|
| /**
|
| * A table mapping URI-based directive to the actual URI value.
|
| */
|
| Map<UriBasedDirective, String> _directiveUris = new Map<UriBasedDirective, String>();
|
| -
|
| +
|
| /**
|
| * A flag indicating whether this library explicitly imports core.
|
| */
|
| bool _explicitlyImportsCore = false;
|
| -
|
| +
|
| /**
|
| * A list containing all of the libraries that are exported from this library.
|
| */
|
| Map<ExportDirective, Library> _exportedLibraries = new Map<ExportDirective, Library>();
|
| -
|
| +
|
| /**
|
| * A table mapping the sources for the compilation units in this library to their corresponding
|
| * AST structures.
|
| */
|
| Map<Source, CompilationUnit> _astMap = new Map<Source, CompilationUnit>();
|
| -
|
| +
|
| /**
|
| * The library scope used when resolving elements within this library's compilation units.
|
| */
|
| LibraryScope _libraryScope;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created data holder that can maintain the data associated with a library.
|
| * @param analysisContext the analysis context in which this library is being analyzed
|
| @@ -3741,7 +3736,7 @@ class Library {
|
| this._librarySource = librarySource;
|
| this._libraryElement = analysisContext.getLibraryElement(librarySource) as LibraryElementImpl;
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the given library is exported from this library.
|
| * @param importLibrary the library that is exported from this library
|
| @@ -3749,7 +3744,7 @@ class Library {
|
| void addExport(ExportDirective directive, Library exportLibrary) {
|
| _exportedLibraries[directive] = exportLibrary;
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the given library is imported into this library.
|
| * @param importLibrary the library that is imported into this library
|
| @@ -3757,7 +3752,7 @@ class Library {
|
| void addImport(ImportDirective directive, Library importLibrary) {
|
| _importedLibraries[directive] = importLibrary;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the AST structure associated with the given source.
|
| * @param source the source representing the compilation unit whose AST is to be returned
|
| @@ -3772,14 +3767,14 @@ class Library {
|
| }
|
| return unit;
|
| }
|
| -
|
| +
|
| /**
|
| * Return a collection containing the sources for the compilation units in this library, including
|
| * the defining compilation unit.
|
| * @return the sources for the compilation units in this library
|
| */
|
| Set<Source> get compilationUnitSources => _astMap.keys.toSet();
|
| -
|
| +
|
| /**
|
| * Return the AST structure associated with the defining compilation unit for this library.
|
| * @return the AST structure associated with the defining compilation unit for this library
|
| @@ -3787,20 +3782,20 @@ class Library {
|
| * unit
|
| */
|
| CompilationUnit get definingCompilationUnit => getAST(librarySource);
|
| -
|
| +
|
| /**
|
| * Return {@code true} if this library explicitly imports core.
|
| * @return {@code true} if this library explicitly imports core
|
| */
|
| bool get explicitlyImportsCore => _explicitlyImportsCore;
|
| -
|
| +
|
| /**
|
| * Return the library exported by the given directive.
|
| * @param directive the directive that exports the library to be returned
|
| * @return the library exported by the given directive
|
| */
|
| Library getExport(ExportDirective directive) => _exportedLibraries[directive];
|
| -
|
| +
|
| /**
|
| * Return an array containing the libraries that are exported from this library.
|
| * @return an array containing the libraries that are exported from this library
|
| @@ -3810,14 +3805,14 @@ class Library {
|
| libraries.addAll(_exportedLibraries.values);
|
| return new List.from(libraries);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the library imported by the given directive.
|
| * @param directive the directive that imports the library to be returned
|
| * @return the library imported by the given directive
|
| */
|
| Library getImport(ImportDirective directive) => _importedLibraries[directive];
|
| -
|
| +
|
| /**
|
| * Return an array containing the libraries that are imported into this library.
|
| * @return an array containing the libraries that are imported into this library
|
| @@ -3827,7 +3822,7 @@ class Library {
|
| libraries.addAll(_importedLibraries.values);
|
| return new List.from(libraries);
|
| }
|
| -
|
| +
|
| /**
|
| * Return an array containing the libraries that are either imported or exported from this
|
| * library.
|
| @@ -3839,7 +3834,7 @@ class Library {
|
| libraries.addAll(_exportedLibraries.values);
|
| return new List.from(libraries);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the inheritance manager for this library.
|
| * @return the inheritance manager for this library
|
| @@ -3850,7 +3845,7 @@ class Library {
|
| }
|
| return _inheritanceManager;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the library element representing this library, creating it if necessary.
|
| * @return the library element representing this library
|
| @@ -3865,7 +3860,7 @@ class Library {
|
| }
|
| return _libraryElement;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the library scope used when resolving elements within this library's compilation units.
|
| * @return the library scope used when resolving elements within this library's compilation units
|
| @@ -3876,13 +3871,13 @@ class Library {
|
| }
|
| return _libraryScope;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the source specifying the defining compilation unit of this library.
|
| * @return the source specifying the defining compilation unit of this library
|
| */
|
| Source get librarySource => _librarySource;
|
| -
|
| +
|
| /**
|
| * Return the result of resolving the URI of the given URI-based directive against the URI of the
|
| * library, or {@code null} if the URI is not valid. If the URI is not valid, report the error.
|
| @@ -3909,12 +3904,12 @@ class Library {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Returns the URI value of the given directive.
|
| */
|
| String getUri(UriBasedDirective directive) => _directiveUris[directive];
|
| -
|
| +
|
| /**
|
| * Set the AST structure associated with the defining compilation unit for this library to the
|
| * given AST structure.
|
| @@ -3923,7 +3918,7 @@ class Library {
|
| void set definingCompilationUnit(CompilationUnit unit) {
|
| _astMap[librarySource] = unit;
|
| }
|
| -
|
| +
|
| /**
|
| * Set whether this library explicitly imports core to match the given value.
|
| * @param explicitlyImportsCore {@code true} if this library explicitly imports core
|
| @@ -3931,7 +3926,7 @@ class Library {
|
| void set explicitlyImportsCore(bool explicitlyImportsCore2) {
|
| this._explicitlyImportsCore = explicitlyImportsCore2;
|
| }
|
| -
|
| +
|
| /**
|
| * Set the library element representing this library to the given library element.
|
| * @param libraryElement the library element representing this library
|
| @@ -3943,7 +3938,7 @@ class Library {
|
| }
|
| }
|
| String toString() => _librarySource.shortName;
|
| -
|
| +
|
| /**
|
| * Return the result of resolving the given URI against the URI of the library, or {@code null} if
|
| * the URI is not valid.
|
| @@ -3957,28 +3952,27 @@ class Library {
|
| return _analysisContext.sourceFactory.resolveUri(_librarySource, uri);
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code LibraryElementBuilder} build an element model for a single library.
|
| * @coverage dart.engine.resolver
|
| */
|
| class LibraryElementBuilder {
|
| -
|
| +
|
| /**
|
| * The analysis context in which the element model will be built.
|
| */
|
| InternalAnalysisContext _analysisContext;
|
| -
|
| +
|
| /**
|
| * The listener to which errors will be reported.
|
| */
|
| AnalysisErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * The name of the function used as an entry point.
|
| */
|
| static String _ENTRY_POINT_NAME = "main";
|
| -
|
| +
|
| /**
|
| * Initialize a newly created library element builder.
|
| * @param resolver the resolver for which the element model is being built
|
| @@ -3987,7 +3981,7 @@ class LibraryElementBuilder {
|
| this._analysisContext = resolver.analysisContext;
|
| this._errorListener = resolver.errorListener;
|
| }
|
| -
|
| +
|
| /**
|
| * Build the library element for the given library.
|
| * @param library the library for which an element model is to be built
|
| @@ -4053,7 +4047,7 @@ class LibraryElementBuilder {
|
| }
|
| return libraryElement;
|
| }
|
| -
|
| +
|
| /**
|
| * Add all of the non-synthetic getters and setters defined in the given compilation unit that
|
| * have no corresponding accessor to one of the given collections.
|
| @@ -4074,7 +4068,7 @@ class LibraryElementBuilder {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Search the top-level functions defined in the given compilation unit for the entry point.
|
| * @param element the compilation unit to be searched
|
| @@ -4089,7 +4083,7 @@ class LibraryElementBuilder {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the name of the library that the given part is declared to be a part of, or {@code null}if the part does not contain a part-of directive.
|
| * @param library the library containing the part
|
| @@ -4114,7 +4108,7 @@ class LibraryElementBuilder {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Look through all of the compilation units defined for the given library, looking for getters
|
| * and setters that are defined in different compilation units but that have the same names. If
|
| @@ -4138,50 +4132,49 @@ class LibraryElementBuilder {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code LibraryResolver} are used to resolve one or more mutually dependent
|
| * libraries within a single context.
|
| * @coverage dart.engine.resolver
|
| */
|
| class LibraryResolver {
|
| -
|
| +
|
| /**
|
| * The analysis context in which the libraries are being analyzed.
|
| */
|
| InternalAnalysisContext _analysisContext;
|
| -
|
| +
|
| /**
|
| * The listener to which analysis errors will be reported, this error listener is either
|
| * references {@link #recordingErrorListener}, or it unions the passed{@link AnalysisErrorListener} with the {@link #recordingErrorListener}.
|
| */
|
| RecordingErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * A source object representing the core library (dart:core).
|
| */
|
| Source _coreLibrarySource;
|
| -
|
| +
|
| /**
|
| * The object representing the core library.
|
| */
|
| Library _coreLibrary;
|
| -
|
| +
|
| /**
|
| * The object used to access the types from the core library.
|
| */
|
| TypeProvider _typeProvider;
|
| -
|
| +
|
| /**
|
| * A table mapping library sources to the information being maintained for those libraries.
|
| */
|
| Map<Source, Library> _libraryMap = new Map<Source, Library>();
|
| -
|
| +
|
| /**
|
| * A collection containing the libraries that are being resolved together.
|
| */
|
| Set<Library> _librariesInCycles;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created library resolver to resolve libraries within the given context.
|
| * @param analysisContext the analysis context in which the library is being analyzed
|
| @@ -4191,25 +4184,25 @@ class LibraryResolver {
|
| this._errorListener = new RecordingErrorListener();
|
| _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the analysis context in which the libraries are being analyzed.
|
| * @return the analysis context in which the libraries are being analyzed
|
| */
|
| InternalAnalysisContext get analysisContext => _analysisContext;
|
| -
|
| +
|
| /**
|
| * Return the listener to which analysis errors will be reported.
|
| * @return the listener to which analysis errors will be reported
|
| */
|
| RecordingErrorListener get errorListener => _errorListener;
|
| -
|
| +
|
| /**
|
| * Return an array containing information about all of the libraries that were resolved.
|
| * @return an array containing the libraries that were resolved
|
| */
|
| Set<Library> get resolvedLibraries => _librariesInCycles;
|
| -
|
| +
|
| /**
|
| * Resolve the library specified by the given source in the given context. The library is assumed
|
| * to be embedded in the given source.
|
| @@ -4257,7 +4250,7 @@ class LibraryResolver {
|
| instrumentation.log();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the library specified by the given source in the given context.
|
| * <p>
|
| @@ -4311,7 +4304,7 @@ class LibraryResolver {
|
| instrumentation.log();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add a dependency to the given map from the referencing library to the referenced library.
|
| * @param dependencyMap the map to which the dependency is to be added
|
| @@ -4326,7 +4319,7 @@ class LibraryResolver {
|
| }
|
| dependentLibraries.add(referencingLibrary);
|
| }
|
| -
|
| +
|
| /**
|
| * Given a library that is part of a cycle that includes the root library, add to the given set of
|
| * libraries all of the libraries reachable from the root library that are also included in the
|
| @@ -4346,7 +4339,7 @@ class LibraryResolver {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add the given library, and all libraries reachable from it that have not already been visited,
|
| * to the given dependency map.
|
| @@ -4366,7 +4359,7 @@ class LibraryResolver {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Build the element model representing the combinators declared by the given directive.
|
| * @param directive the directive that declares the combinators
|
| @@ -4387,7 +4380,7 @@ class LibraryResolver {
|
| }
|
| return new List.from(combinators);
|
| }
|
| -
|
| +
|
| /**
|
| * Every library now has a corresponding {@link LibraryElement}, so it is now possible to resolve
|
| * the import and export directives.
|
| @@ -4452,7 +4445,7 @@ class LibraryResolver {
|
| libraryElement2.exports = new List.from(exports);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Build element models for all of the libraries in the current cycle.
|
| * @throws AnalysisException if any of the element models cannot be built
|
| @@ -4464,7 +4457,7 @@ class LibraryResolver {
|
| library.libraryElement = libraryElement;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the type hierarchy across all of the types declared in the libraries in the current
|
| * cycle.
|
| @@ -4478,7 +4471,7 @@ class LibraryResolver {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Compute a dependency map of libraries reachable from the given library. A dependency map is a
|
| * table that maps individual libraries to a list of the libraries that either import or export
|
| @@ -4494,7 +4487,7 @@ class LibraryResolver {
|
| addToDependencyMap(library, dependencyMap, new Set<Library>());
|
| return dependencyMap;
|
| }
|
| -
|
| +
|
| /**
|
| * Return a collection containing all of the libraries reachable from the given library that are
|
| * contained in a cycle that includes the given library.
|
| @@ -4508,7 +4501,7 @@ class LibraryResolver {
|
| addLibrariesInCycle(library, librariesInCycle, dependencyMap);
|
| return librariesInCycle;
|
| }
|
| -
|
| +
|
| /**
|
| * Recursively traverse the libraries reachable from the given library, creating instances of the
|
| * class {@link Library} to represent them, and record the references in the library objects.
|
| @@ -4573,7 +4566,7 @@ class LibraryResolver {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Create an object to represent the information about the library defined by the compilation unit
|
| * with the given source.
|
| @@ -4587,7 +4580,7 @@ class LibraryResolver {
|
| _libraryMap[librarySource] = library;
|
| return library;
|
| }
|
| -
|
| +
|
| /**
|
| * Create an object to represent the information about the library defined by the compilation unit
|
| * with the given source.
|
| @@ -4601,7 +4594,7 @@ class LibraryResolver {
|
| _libraryMap[librarySource] = library;
|
| return library;
|
| }
|
| -
|
| +
|
| /**
|
| * Create an object to represent the information about the library defined by the compilation unit
|
| * with the given source. Return the library object that was created, or {@code null} if the
|
| @@ -4622,7 +4615,7 @@ class LibraryResolver {
|
| _libraryMap[librarySource] = library;
|
| return library;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if and only if the passed {@link CompilationUnit} has a part-of directive.
|
| * @param node the {@link CompilationUnit} to test
|
| @@ -4637,7 +4630,7 @@ class LibraryResolver {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Return an array containing the lexical identifiers associated with the nodes in the given list.
|
| * @param names the AST nodes representing the identifiers
|
| @@ -4651,7 +4644,7 @@ class LibraryResolver {
|
| }
|
| return identifiers;
|
| }
|
| -
|
| +
|
| /**
|
| * Compute a value for all of the constants in the libraries being analyzed.
|
| */
|
| @@ -4671,7 +4664,7 @@ class LibraryResolver {
|
| }
|
| computer.computeValues();
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the identifiers and perform type analysis in the libraries in the current cycle.
|
| * @throws AnalysisException if any of the identifiers could not be resolved or if any of the
|
| @@ -4682,7 +4675,7 @@ class LibraryResolver {
|
| resolveReferencesAndTypes2(library);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the identifiers and perform type analysis in the given library.
|
| * @param library the library to be resolved
|
| @@ -4695,7 +4688,7 @@ class LibraryResolver {
|
| library.getAST(source).accept(visitor);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Run additional analyses, such as the {@link ConstantVerifier} and {@link ErrorVerifier}analysis in the current cycle.
|
| * @throws AnalysisException if any of the identifiers could not be resolved or if the types in
|
| @@ -4706,7 +4699,7 @@ class LibraryResolver {
|
| runAdditionalAnalyses2(library);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Run additional analyses, such as the {@link ConstantVerifier} and {@link ErrorVerifier}analysis in the given library.
|
| * @param library the library to have the extra analyses processes run
|
| @@ -4719,46 +4712,46 @@ class LibraryResolver {
|
| CompilationUnit unit = library.getAST(source);
|
| ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.libraryElement, _typeProvider, library.inheritanceManager);
|
| unit.accept(errorVerifier);
|
| + unit.accept(new PubVerifier(errorReporter));
|
| ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _typeProvider);
|
| unit.accept(constantVerifier);
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ResolverVisitor} are used to resolve the nodes within a single
|
| * compilation unit.
|
| * @coverage dart.engine.resolver
|
| */
|
| class ResolverVisitor extends ScopedVisitor {
|
| -
|
| +
|
| /**
|
| * The object used to resolve the element associated with the current node.
|
| */
|
| ElementResolver _elementResolver;
|
| -
|
| +
|
| /**
|
| * The object used to compute the type associated with the current node.
|
| */
|
| StaticTypeAnalyzer _typeAnalyzer;
|
| -
|
| +
|
| /**
|
| * The class element representing the class containing the current node, or {@code null} if the
|
| * current node is not contained in a class.
|
| */
|
| ClassElement _enclosingClass = null;
|
| -
|
| +
|
| /**
|
| * The element representing the function containing the current node, or {@code null} if the
|
| * current node is not contained in a function.
|
| */
|
| ExecutableElement _enclosingFunction = null;
|
| -
|
| +
|
| /**
|
| * The object keeping track of which elements have had their types overridden.
|
| */
|
| TypeOverrideManager _overrideManager = new TypeOverrideManager();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param library the library containing the compilation unit being resolved
|
| @@ -4766,13 +4759,13 @@ class ResolverVisitor extends ScopedVisitor {
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider) : super.con1(library, source, typeProvider) {
|
| - _jtd_constructor_272_impl(library, source, typeProvider);
|
| + _jtd_constructor_273_impl(library, source, typeProvider);
|
| }
|
| - _jtd_constructor_272_impl(Library library, Source source, TypeProvider typeProvider) {
|
| + _jtd_constructor_273_impl(Library library, Source source, TypeProvider typeProvider) {
|
| this._elementResolver = new ElementResolver(this);
|
| this._typeAnalyzer = new StaticTypeAnalyzer(this);
|
| }
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param definingLibrary the element for the library containing the compilation unit being
|
| @@ -4783,13 +4776,13 @@ class ResolverVisitor extends ScopedVisitor {
|
| * during resolution
|
| */
|
| ResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) {
|
| - _jtd_constructor_273_impl(definingLibrary, source, typeProvider, errorListener);
|
| + _jtd_constructor_274_impl(definingLibrary, source, typeProvider, errorListener);
|
| }
|
| - _jtd_constructor_273_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
|
| + _jtd_constructor_274_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
|
| this._elementResolver = new ElementResolver(this);
|
| this._typeAnalyzer = new StaticTypeAnalyzer(this);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the object keeping track of which elements have had their types overridden.
|
| * @return the object keeping track of which elements have had their types overridden
|
| @@ -5162,21 +5155,21 @@ class ResolverVisitor extends ScopedVisitor {
|
| node.accept(_typeAnalyzer);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the class element representing the class containing the current node, or {@code null} if
|
| * the current node is not contained in a class.
|
| * @return the class element representing the class containing the current node
|
| */
|
| ClassElement get enclosingClass => _enclosingClass;
|
| -
|
| +
|
| /**
|
| * Return the element representing the function containing the current node, or {@code null} if
|
| * the current node is not contained in a function.
|
| * @return the element representing the function containing the current node
|
| */
|
| ExecutableElement get enclosingFunction => _enclosingFunction;
|
| -
|
| +
|
| /**
|
| * Return the element associated with the given expression whose type can be overridden, or{@code null} if there is no element whose type can be overridden.
|
| * @param expression the expression with which the element is associated
|
| @@ -5196,7 +5189,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * If it is appropriate to do so, override the current type of the given element with the given
|
| * type. Generally speaking, it is appropriate if the given type is more specific than the current
|
| @@ -5255,7 +5248,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| _overrideManager.exitScope();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the best type information available for the given element. If the type of the element
|
| * has been overridden, then return the overriding type. Otherwise, return the static type.
|
| @@ -5273,7 +5266,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| return bestType;
|
| }
|
| -
|
| +
|
| /**
|
| * The given expression is the expression used to compute the iterator for a for-each statement.
|
| * Attempt to compute the type of objects that will be assigned to the loop variable and return
|
| @@ -5299,7 +5292,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given expression terminates abruptly (that is, if any expression
|
| * following the given expression will not be reached).
|
| @@ -5312,7 +5305,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| return expression2 is ThrowExpression || expression2 is RethrowExpression;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given statement terminates abruptly (that is, if any statement
|
| * following the given statement will not be reached).
|
| @@ -5334,7 +5327,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Propagate any type information that results from knowing that the given condition will have
|
| * been evaluated to 'false'.
|
| @@ -5364,7 +5357,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| propagateFalseState(((condition as ParenthesizedExpression)).expression);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Propagate any type information that results from knowing that the given expression will have
|
| * been evaluated without altering the flow of execution.
|
| @@ -5372,7 +5365,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| */
|
| void propagateState(Expression expression) {
|
| }
|
| -
|
| +
|
| /**
|
| * Propagate any type information that results from knowing that the given condition will have
|
| * been evaluated to 'true'.
|
| @@ -5413,44 +5406,43 @@ class ResolverVisitor extends ScopedVisitor {
|
| get enclosingClass_J2DAccessor => _enclosingClass;
|
| set enclosingClass_J2DAccessor(__v) => _enclosingClass = __v;
|
| }
|
| -
|
| /**
|
| * The abstract class {@code ScopedVisitor} maintains name and label scopes as an AST structure is
|
| * being visited.
|
| * @coverage dart.engine.resolver
|
| */
|
| abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * The element for the library containing the compilation unit being visited.
|
| */
|
| LibraryElement _definingLibrary;
|
| -
|
| +
|
| /**
|
| * The source representing the compilation unit being visited.
|
| */
|
| Source _source;
|
| -
|
| +
|
| /**
|
| * The error listener that will be informed of any errors that are found during resolution.
|
| */
|
| AnalysisErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * The scope used to resolve identifiers.
|
| */
|
| Scope _nameScope;
|
| -
|
| +
|
| /**
|
| * The object used to access the types from the core library.
|
| */
|
| TypeProvider _typeProvider;
|
| -
|
| +
|
| /**
|
| * The scope used to resolve labels for {@code break} and {@code continue} statements, or{@code null} if no labels have been defined in the current context.
|
| */
|
| LabelScope _labelScope;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param library the library containing the compilation unit being resolved
|
| @@ -5458,9 +5450,9 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| ScopedVisitor.con1(Library library, Source source2, TypeProvider typeProvider2) {
|
| - _jtd_constructor_274_impl(library, source2, typeProvider2);
|
| + _jtd_constructor_275_impl(library, source2, typeProvider2);
|
| }
|
| - _jtd_constructor_274_impl(Library library, Source source2, TypeProvider typeProvider2) {
|
| + _jtd_constructor_275_impl(Library library, Source source2, TypeProvider typeProvider2) {
|
| this._definingLibrary = library.libraryElement;
|
| this._source = source2;
|
| LibraryScope libraryScope2 = library.libraryScope;
|
| @@ -5468,7 +5460,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| this._nameScope = libraryScope2;
|
| this._typeProvider = typeProvider2;
|
| }
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param definingLibrary the element for the library containing the compilation unit being
|
| @@ -5479,22 +5471,22 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| * during resolution
|
| */
|
| ScopedVisitor.con2(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
|
| - _jtd_constructor_275_impl(definingLibrary2, source2, typeProvider2, errorListener2);
|
| + _jtd_constructor_276_impl(definingLibrary2, source2, typeProvider2, errorListener2);
|
| }
|
| - _jtd_constructor_275_impl(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
|
| + _jtd_constructor_276_impl(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
|
| this._definingLibrary = definingLibrary2;
|
| this._source = source2;
|
| this._errorListener = errorListener2;
|
| this._nameScope = new LibraryScope(definingLibrary2, errorListener2);
|
| this._typeProvider = typeProvider2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the library element for the library containing the compilation unit being resolved.
|
| * @return the library element for the library containing the compilation unit being resolved
|
| */
|
| LibraryElement get definingLibrary => _definingLibrary;
|
| -
|
| +
|
| /**
|
| * Return the object used to access the types from the core library.
|
| * @return the object used to access the types from the core library
|
| @@ -5721,19 +5713,19 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the label scope in which the current node is being resolved.
|
| * @return the label scope in which the current node is being resolved
|
| */
|
| LabelScope get labelScope => _labelScope;
|
| -
|
| +
|
| /**
|
| * Return the name scope in which the current node is being resolved.
|
| * @return the name scope in which the current node is being resolved
|
| */
|
| Scope get nameScope => _nameScope;
|
| -
|
| +
|
| /**
|
| * Report an error with the given error code and arguments.
|
| * @param errorCode the error code of the error to be reported
|
| @@ -5743,7 +5735,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| void reportError(ErrorCode errorCode, ASTNode node, List<Object> arguments) {
|
| _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, arguments));
|
| }
|
| -
|
| +
|
| /**
|
| * Report an error with the given error code and arguments.
|
| * @param errorCode the error code of the error to be reported
|
| @@ -5754,7 +5746,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| void reportError5(ErrorCode errorCode, int offset, int length, List<Object> arguments) {
|
| _errorListener.onError(new AnalysisError.con2(_source, offset, length, errorCode, arguments));
|
| }
|
| -
|
| +
|
| /**
|
| * Report an error with the given error code and arguments.
|
| * @param errorCode the error code of the error to be reported
|
| @@ -5764,7 +5756,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| void reportError6(ErrorCode errorCode, sc.Token token, List<Object> arguments) {
|
| _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, arguments));
|
| }
|
| -
|
| +
|
| /**
|
| * Visit the given AST node if it is not null.
|
| * @param node the node to be visited
|
| @@ -5774,7 +5766,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| node.accept(this);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Visit the given statement after it's scope has been created. This replaces the normal call to
|
| * the inherited visit method so that ResolverVisitor can intervene when type propagation is
|
| @@ -5786,7 +5778,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| safelyVisit(node.loopVariable);
|
| safelyVisit(node.body);
|
| }
|
| -
|
| +
|
| /**
|
| * Visit the given statement after it's scope has been created. This replaces the normal call to
|
| * the inherited visit method so that ResolverVisitor can intervene when type propagation is
|
| @@ -5796,7 +5788,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| void visitForStatementInScope(ForStatement node) {
|
| super.visitForStatement(node);
|
| }
|
| -
|
| +
|
| /**
|
| * Add scopes for each of the given labels.
|
| * @param labels the labels for which new scopes are to be added
|
| @@ -5813,7 +5805,6 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| return outerScope;
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code StaticTypeAnalyzer} perform two type-related tasks. First, they
|
| * compute the static type of every expression. Second, they look for any static type errors or
|
| @@ -5825,7 +5816,7 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| * @coverage dart.engine.resolver
|
| */
|
| class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * Create a table mapping HTML tag names to the names of the classes (in 'dart:html') that
|
| * implement those tags.
|
| @@ -5893,39 +5884,39 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| map["video"] = "VideoElement";
|
| return map;
|
| }
|
| -
|
| +
|
| /**
|
| * The resolver driving the resolution and type analysis.
|
| */
|
| ResolverVisitor _resolver;
|
| -
|
| +
|
| /**
|
| * The object providing access to the types defined by the language.
|
| */
|
| TypeProvider _typeProvider;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'dynamic'.
|
| */
|
| Type2 _dynamicType;
|
| -
|
| +
|
| /**
|
| * The type representing the class containing the nodes being analyzed, or {@code null} if the
|
| * nodes are not within a class.
|
| */
|
| InterfaceType _thisType;
|
| -
|
| +
|
| /**
|
| * The object keeping track of which elements have had their types overridden.
|
| */
|
| TypeOverrideManager _overrideManager;
|
| -
|
| +
|
| /**
|
| * A table mapping HTML tag names to the names of the classes (in 'dart:html') that implement
|
| * those tags.
|
| */
|
| static Map<String, String> _HTML_ELEMENT_TO_CLASS_MAP = createHtmlTagToClassMap();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created type analyzer.
|
| * @param resolver the resolver driving this participant
|
| @@ -5936,7 +5927,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| _dynamicType = _typeProvider.dynamicType;
|
| _overrideManager = resolver.overrideManager;
|
| }
|
| -
|
| +
|
| /**
|
| * Set the type of the class being analyzed to the given type.
|
| * @param thisType the type representing the class containing the nodes being analyzed
|
| @@ -5944,7 +5935,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| void set thisType(InterfaceType thisType2) {
|
| this._thisType = thisType2;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is{@code String}.</blockquote>
|
| */
|
| @@ -5952,7 +5943,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.stringType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.33: <blockquote>The static type of an argument definition
|
| * test is {@code bool}.</blockquote>
|
| @@ -5961,7 +5952,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.boolType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.32: <blockquote>... the cast expression <i>e as T</i> ...
|
| * <p>
|
| @@ -5974,7 +5965,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, getType2(node.type));
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.18: <blockquote>... an assignment <i>a</i> of the form <i>v
|
| * = e</i> ...
|
| @@ -6046,7 +6037,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.20: <blockquote>The static type of a logical boolean
|
| * expression is {@code bool}.</blockquote>
|
| @@ -6098,7 +6089,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.4: <blockquote>The static type of a boolean literal is
|
| * bool.</blockquote>
|
| @@ -6107,7 +6098,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.boolType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.15.2: <blockquote>A cascaded method invocation expression
|
| * of the form <i>e..suffix</i> is equivalent to the expression <i>(t) {t.suffix; return
|
| @@ -6118,7 +6109,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordPropagatedType(node, getPropagatedType(node.target));
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.19: <blockquote> ... a conditional expression <i>c</i> of
|
| * the form <i>e<sub>1</sub> ? e<sub>2</sub> : e<sub>3</sub></i> ...
|
| @@ -6158,7 +6149,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.3: <blockquote>The static type of a literal double is
|
| * double.</blockquote>
|
| @@ -6174,7 +6165,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(function, functionType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.9: <blockquote>The static type of a function literal of the
|
| * form <i>(T<sub>1</sub> a<sub>1</sub>, …, T<sub>n</sub> a<sub>n</sub>, \[T<sub>n+1</sub>
|
| @@ -6214,7 +6205,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, functionType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.14.4: <blockquote>A function expression invocation <i>i</i>
|
| * has the form <i>e<sub>f</sub>(a<sub>1</sub>, …, a<sub>n</sub>, x<sub>n+1</sub>:
|
| @@ -6240,7 +6231,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.29: <blockquote>An assignable expression of the form
|
| * <i>e<sub>1</sub>\[e<sub>2</sub>\]</i> is evaluated as a method invocation of the operator method
|
| @@ -6272,7 +6263,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.11.1: <blockquote>The static type of a new expression of
|
| * either the form <i>new T.id(a<sub>1</sub>, …, a<sub>n</sub>)</i> or the form <i>new
|
| @@ -6296,7 +6287,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.3: <blockquote>The static type of an integer literal is{@code int}.</blockquote>
|
| */
|
| @@ -6304,7 +6295,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.intType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.31: <blockquote>It is a static warning if <i>T</i> does not
|
| * denote a type available in the current lexical scope.
|
| @@ -6315,7 +6306,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.boolType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.6: <blockquote>The static type of a list literal of the
|
| * form <i><b>const</b> <E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> or the form
|
| @@ -6358,7 +6349,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.7: <blockquote>The static type of a map literal of the form
|
| * <i><b>const</b> <String, V> {k<sub>1</sub>:e<sub>1</sub>, …,
|
| @@ -6432,7 +6423,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.15.1: <blockquote>An ordinary method invocation <i>i</i>
|
| * has the form <i>o.m(a<sub>1</sub>, …, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>,
|
| @@ -6551,7 +6542,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordPropagatedType(node, getPropagatedType(expression2));
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.2: <blockquote>The static type of {@code null} is bottom.
|
| * </blockquote>
|
| @@ -6566,7 +6557,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordPropagatedType(node, getPropagatedType(expression2));
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.28: <blockquote>A postfix expression of the form
|
| * <i>v++</i>, where <i>v</i> is an identifier, is equivalent to <i>(){var r = v; v = r + 1;
|
| @@ -6607,7 +6598,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordPropagatedType(node, getPropagatedType(operand2));
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * See {@link #visitSimpleIdentifier(SimpleIdentifier)}.
|
| */
|
| @@ -6643,7 +6634,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u</i> of the form
|
| * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>. An expression of the
|
| @@ -6673,7 +6664,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.13: <blockquote> Property extraction allows for a member of
|
| * an object to be concisely extracted from the object. If <i>o</i> is an object, and if <i>m</i>
|
| @@ -6735,7 +6726,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.9: <blockquote>The static type of a rethrow expression is
|
| * bottom.</blockquote>
|
| @@ -6744,7 +6735,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.bottomType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identifier expression
|
| * <i>e</i> of the form <i>id</i> proceeds as follows:
|
| @@ -6820,7 +6811,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is{@code String}.</blockquote>
|
| */
|
| @@ -6828,7 +6819,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| recordStaticType(node, _typeProvider.stringType);
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is{@code String}.</blockquote>
|
| */
|
| @@ -6844,7 +6835,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.10: <blockquote>The static type of {@code this} is the
|
| * interface of the immediately enclosing class.</blockquote>
|
| @@ -6857,7 +6848,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * The Dart Language Specification, 12.8: <blockquote>The static type of a throw expression is
|
| * bottom.</blockquote>
|
| @@ -6877,7 +6868,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the static type of the given node is the type of the second argument to the method
|
| * represented by the given element.
|
| @@ -6892,7 +6883,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return _dynamicType;
|
| }
|
| -
|
| +
|
| /**
|
| * Compute the return type of the method or function represented by the given element.
|
| * @param element the element representing the method or function invoked by the given node
|
| @@ -6936,7 +6927,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return _dynamicType;
|
| }
|
| -
|
| +
|
| /**
|
| * Given a function declaration, compute the return type of the function. The return type of
|
| * functions with a block body is {@code dynamicType}, with an expression body it is the type of
|
| @@ -6951,7 +6942,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return returnType2.type;
|
| }
|
| -
|
| +
|
| /**
|
| * Given a function expression, compute the return type of the function. The return type of
|
| * functions with a block body is {@code dynamicType}, with an expression body it is the type of
|
| @@ -6966,7 +6957,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return _dynamicType;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated type of the given expression if it is available, or the static type if
|
| * there is no propagated type.
|
| @@ -6983,7 +6974,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * If the given argument list contains at least one argument, and if the argument is a simple
|
| * string literal, then parse that argument as a query string and return the type specified by the
|
| @@ -7011,7 +7002,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * If the given argument list contains at least one argument, and if the argument is a simple
|
| * string literal, return the String value of the argument.
|
| @@ -7028,7 +7019,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * If the given argument list contains at least one argument, and if the argument is a simple
|
| * string literal, and if the value of the argument is the name of a class defined within the
|
| @@ -7038,7 +7029,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| * @return the type specified by the first argument in the argument list
|
| */
|
| Type2 getFirstArgumentAsType(LibraryElement library, ArgumentList argumentList) => getFirstArgumentAsType2(library, argumentList, null);
|
| -
|
| +
|
| /**
|
| * If the given argument list contains at least one argument, and if the argument is a simple
|
| * string literal, and if the value of the argument is the name of a class defined within the
|
| @@ -7060,7 +7051,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated type of the given expression.
|
| * @param expression the expression whose type is to be returned
|
| @@ -7070,7 +7061,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| Type2 type = expression.propagatedType;
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the static type of the given expression.
|
| * @param expression the expression whose type is to be returned
|
| @@ -7083,7 +7074,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the type that should be recorded for a node that resolved to the given accessor.
|
| * @param accessor the accessor that the node resolved to
|
| @@ -7126,7 +7117,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return returnType2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the type represented by the given type name.
|
| * @param typeName the type name representing the type to be returned
|
| @@ -7139,14 +7130,14 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return type2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given library is the 'dart:html' library.
|
| * @param library the library being tested
|
| * @return {@code true} if the library is 'dart:html'
|
| */
|
| bool isHtmlLibrary(LibraryElement library) => library.name == "dart.dom.html";
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given node is not a type literal.
|
| * @param node the node being tested
|
| @@ -7156,7 +7147,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| ASTNode parent2 = node.parent;
|
| return parent2 is TypeName || (parent2 is PrefixedIdentifier && (parent2.parent is TypeName || identical(((parent2 as PrefixedIdentifier)).prefix, node))) || (parent2 is PropertyAccess && identical(((parent2 as PropertyAccess)).target, node)) || (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInvocation)).target));
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the propagated type of the given node is the given type.
|
| * @param expression the node whose type is to be recorded
|
| @@ -7167,7 +7158,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| expression.propagatedType = type;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the static type of the given node is the given type.
|
| * @param expression the node whose type is to be recorded
|
| @@ -7180,7 +7171,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| expression.staticType = type;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Attempts to make a better guess for the static type of the given binary expression.
|
| * @param node the binary expression to analyze
|
| @@ -7206,7 +7197,7 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| }
|
| return staticType;
|
| }
|
| -
|
| +
|
| /**
|
| * Set the return type and parameter type information for the given function type based on the
|
| * given return type and parameter elements.
|
| @@ -7240,18 +7231,17 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| get thisType_J2DAccessor => _thisType;
|
| set thisType_J2DAccessor(__v) => _thisType = __v;
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code TypeOverrideManager} manage the ability to override the type of an
|
| * element within a given context.
|
| */
|
| class TypeOverrideManager {
|
| -
|
| +
|
| /**
|
| * The current override scope, or {@code null} if no scope has been entered.
|
| */
|
| TypeOverrideManager_TypeOverrideScope _currentScope;
|
| -
|
| +
|
| /**
|
| * Apply a set of overrides that were previously captured.
|
| * @param overrides the overrides to be applied
|
| @@ -7262,7 +7252,7 @@ class TypeOverrideManager {
|
| }
|
| _currentScope.applyOverrides(overrides);
|
| }
|
| -
|
| +
|
| /**
|
| * Return a table mapping the elements whose type is overridden in the current scope to the
|
| * overriding type.
|
| @@ -7274,7 +7264,7 @@ class TypeOverrideManager {
|
| }
|
| return _currentScope.captureLocalOverrides();
|
| }
|
| -
|
| +
|
| /**
|
| * Return a map from the elements for the variables in the given list that have their types
|
| * overridden to the overriding type.
|
| @@ -7287,14 +7277,14 @@ class TypeOverrideManager {
|
| }
|
| return _currentScope.captureOverrides(variableList);
|
| }
|
| -
|
| +
|
| /**
|
| * Enter a new override scope.
|
| */
|
| void enterScope() {
|
| _currentScope = new TypeOverrideManager_TypeOverrideScope(_currentScope);
|
| }
|
| -
|
| +
|
| /**
|
| * Exit the current override scope.
|
| */
|
| @@ -7304,7 +7294,7 @@ class TypeOverrideManager {
|
| }
|
| _currentScope = _currentScope._outerScope;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the overridden type of the given element, or {@code null} if the type of the element has
|
| * not been overridden.
|
| @@ -7317,7 +7307,7 @@ class TypeOverrideManager {
|
| }
|
| return _currentScope.getType(element);
|
| }
|
| -
|
| +
|
| /**
|
| * Set the overridden type of the given element to the given type
|
| * @param element the element whose type might have been overridden
|
| @@ -7330,23 +7320,22 @@ class TypeOverrideManager {
|
| _currentScope.setType(element, type);
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code TypeOverrideScope} represent a scope in which the types of
|
| * elements can be overridden.
|
| */
|
| class TypeOverrideManager_TypeOverrideScope {
|
| -
|
| +
|
| /**
|
| * The outer scope in which types might be overridden.
|
| */
|
| TypeOverrideManager_TypeOverrideScope _outerScope;
|
| -
|
| +
|
| /**
|
| * A table mapping elements to the overridden type of that element.
|
| */
|
| Map<Element, Type2> _overridenTypes = new Map<Element, Type2>();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope to be an empty child of the given scope.
|
| * @param outerScope the outer scope in which types might be overridden
|
| @@ -7354,7 +7343,7 @@ class TypeOverrideManager_TypeOverrideScope {
|
| TypeOverrideManager_TypeOverrideScope(TypeOverrideManager_TypeOverrideScope outerScope) {
|
| this._outerScope = outerScope;
|
| }
|
| -
|
| +
|
| /**
|
| * Apply a set of overrides that were previously captured.
|
| * @param overrides the overrides to be applied
|
| @@ -7364,14 +7353,14 @@ class TypeOverrideManager_TypeOverrideScope {
|
| _overridenTypes[entry.getKey()] = entry.getValue();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return a table mapping the elements whose type is overridden in the current scope to the
|
| * overriding type.
|
| * @return the overrides in the current scope
|
| */
|
| Map<Element, Type2> captureLocalOverrides() => _overridenTypes;
|
| -
|
| +
|
| /**
|
| * Return a map from the elements for the variables in the given list that have their types
|
| * overridden to the overriding type.
|
| @@ -7393,7 +7382,7 @@ class TypeOverrideManager_TypeOverrideScope {
|
| }
|
| return overrides;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the overridden type of the given element, or {@code null} if the type of the element
|
| * has not been overridden.
|
| @@ -7412,7 +7401,7 @@ class TypeOverrideManager_TypeOverrideScope {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Set the overridden type of the given element to the given type
|
| * @param element the element whose type might have been overridden
|
| @@ -7422,165 +7411,163 @@ class TypeOverrideManager_TypeOverrideScope {
|
| _overridenTypes[element] = type;
|
| }
|
| }
|
| -
|
| /**
|
| * The interface {@code TypeProvider} defines the behavior of objects that provide access to types
|
| * defined by the language.
|
| * @coverage dart.engine.resolver
|
| */
|
| abstract class TypeProvider {
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'bool'.
|
| * @return the type representing the built-in type 'bool'
|
| */
|
| InterfaceType get boolType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the type 'bottom'.
|
| * @return the type representing the type 'bottom'
|
| */
|
| Type2 get bottomType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'double'.
|
| * @return the type representing the built-in type 'double'
|
| */
|
| InterfaceType get doubleType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'dynamic'.
|
| * @return the type representing the built-in type 'dynamic'
|
| */
|
| Type2 get dynamicType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'Function'.
|
| * @return the type representing the built-in type 'Function'
|
| */
|
| InterfaceType get functionType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'int'.
|
| * @return the type representing the built-in type 'int'
|
| */
|
| InterfaceType get intType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'List'.
|
| * @return the type representing the built-in type 'List'
|
| */
|
| InterfaceType get listType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'Map'.
|
| * @return the type representing the built-in type 'Map'
|
| */
|
| InterfaceType get mapType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'num'.
|
| * @return the type representing the built-in type 'num'
|
| */
|
| InterfaceType get numType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'Object'.
|
| * @return the type representing the built-in type 'Object'
|
| */
|
| InterfaceType get objectType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'StackTrace'.
|
| * @return the type representing the built-in type 'StackTrace'
|
| */
|
| InterfaceType get stackTraceType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'String'.
|
| * @return the type representing the built-in type 'String'
|
| */
|
| InterfaceType get stringType;
|
| -
|
| +
|
| /**
|
| * Return the type representing the built-in type 'Type'.
|
| * @return the type representing the built-in type 'Type'
|
| */
|
| InterfaceType get typeType;
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code TypeProviderImpl} provide access to types defined by the language
|
| * by looking for those types in the element model for the core library.
|
| * @coverage dart.engine.resolver
|
| */
|
| class TypeProviderImpl implements TypeProvider {
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'bool'.
|
| */
|
| InterfaceType _boolType;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'bottom'.
|
| */
|
| Type2 _bottomType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'double'.
|
| */
|
| InterfaceType _doubleType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'dynamic'.
|
| */
|
| Type2 _dynamicType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'Function'.
|
| */
|
| InterfaceType _functionType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'int'.
|
| */
|
| InterfaceType _intType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'List'.
|
| */
|
| InterfaceType _listType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'Map'.
|
| */
|
| InterfaceType _mapType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'num'.
|
| */
|
| InterfaceType _numType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'Object'.
|
| */
|
| InterfaceType _objectType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'StackTrace'.
|
| */
|
| InterfaceType _stackTraceType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'String'.
|
| */
|
| InterfaceType _stringType;
|
| -
|
| +
|
| /**
|
| * The type representing the built-in type 'Type'.
|
| */
|
| InterfaceType _typeType;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created type provider to provide the types defined in the given library.
|
| * @param coreLibrary the element representing the core library (dart:core).
|
| @@ -7601,7 +7588,7 @@ class TypeProviderImpl implements TypeProvider {
|
| InterfaceType get stackTraceType => _stackTraceType;
|
| InterfaceType get stringType => _stringType;
|
| InterfaceType get typeType => _typeType;
|
| -
|
| +
|
| /**
|
| * Return the type with the given name from the given namespace, or {@code null} if there is no
|
| * class with the given name.
|
| @@ -7617,7 +7604,7 @@ class TypeProviderImpl implements TypeProvider {
|
| }
|
| return ((element as ClassElement)).type;
|
| }
|
| -
|
| +
|
| /**
|
| * Initialize the types provided by this type provider from the given library.
|
| * @param library the library containing the definitions of the core types
|
| @@ -7639,7 +7626,6 @@ class TypeProviderImpl implements TypeProvider {
|
| _typeType = getType(namespace, "Type");
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code TypeResolverVisitor} are used to resolve the types associated with
|
| * the elements in the element model. This includes the types of superclasses, mixins, interfaces,
|
| @@ -7648,17 +7634,17 @@ class TypeProviderImpl implements TypeProvider {
|
| * @coverage dart.engine.resolver
|
| */
|
| class TypeResolverVisitor extends ScopedVisitor {
|
| -
|
| +
|
| /**
|
| * The type representing the type 'dynamic'.
|
| */
|
| Type2 _dynamicType;
|
| -
|
| +
|
| /**
|
| * The flag specifying if currently visited class references 'super' expression.
|
| */
|
| bool _hasReferenceToSuper = false;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param library the library containing the compilation unit being resolved
|
| @@ -7666,12 +7652,12 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| TypeResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider) : super.con1(library, source, typeProvider) {
|
| - _jtd_constructor_280_impl(library, source, typeProvider);
|
| + _jtd_constructor_281_impl(library, source, typeProvider);
|
| }
|
| - _jtd_constructor_280_impl(Library library, Source source, TypeProvider typeProvider) {
|
| + _jtd_constructor_281_impl(Library library, Source source, TypeProvider typeProvider) {
|
| _dynamicType = typeProvider.dynamicType;
|
| }
|
| -
|
| +
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| * @param definingLibrary the element for the library containing the compilation unit being
|
| @@ -7682,9 +7668,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * during resolution
|
| */
|
| TypeResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) {
|
| - _jtd_constructor_281_impl(definingLibrary, source, typeProvider, errorListener);
|
| + _jtd_constructor_282_impl(definingLibrary, source, typeProvider, errorListener);
|
| }
|
| - _jtd_constructor_281_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
|
| + _jtd_constructor_282_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
|
| _dynamicType = typeProvider.dynamicType;
|
| }
|
| Object visitCatchClause(CatchClause node) {
|
| @@ -8035,7 +8021,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the class element that represents the class whose name was provided.
|
| * @param identifier the name from the declaration of a class
|
| @@ -8051,7 +8037,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return element2 as ClassElementImpl;
|
| }
|
| -
|
| +
|
| /**
|
| * Return an array containing all of the elements associated with the parameters in the given
|
| * list.
|
| @@ -8068,7 +8054,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return new List.from(elements);
|
| }
|
| -
|
| +
|
| /**
|
| * The number of type arguments in the given type name does not match the number of parameters in
|
| * the corresponding class element. Return the error code that should be used to report this
|
| @@ -8091,7 +8077,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
|
| }
|
| -
|
| +
|
| /**
|
| * Given the multiple elements to which a single name could potentially be resolved, return the
|
| * single interface type that should be used, or {@code null} if there is no clear choice.
|
| @@ -8110,7 +8096,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the type represented by the given type name.
|
| * @param typeName the type name representing the type to be returned
|
| @@ -8123,7 +8109,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return type2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the type arguments associated with the given type.
|
| * @param type the type whole type arguments are to be returned
|
| @@ -8137,7 +8123,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return TypeImpl.EMPTY_ARRAY;
|
| }
|
| -
|
| +
|
| /**
|
| * Returns the simple identifier of the given (may be qualified) type name.
|
| * @param typeName the (may be qualified) qualified type name
|
| @@ -8150,7 +8136,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| return ((typeName as PrefixedIdentifier)).identifier;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Checks if the given type name is used as the exception type in the catch clause.
|
| * @param typeName the type name to analyzer
|
| @@ -8164,7 +8150,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks if the given type name is used as the type in the instance creation expression.
|
| * @param typeName the type name to analyzer
|
| @@ -8179,7 +8165,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Record that the static type of the given node is the given type.
|
| * @param expression the node whose type is to be recorded
|
| @@ -8193,7 +8179,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the types in the given with and implements clauses and associate those types with the
|
| * given class element.
|
| @@ -8243,7 +8229,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the type specified by the given name.
|
| * @param typeName the type name specifying the type to be returned
|
| @@ -8262,7 +8248,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Resolve the types in the given list of type names.
|
| * @param typeNames the type names to be resolved
|
| @@ -8295,7 +8281,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Set the return type and parameter type information for the given function type based on the
|
| * given return type and parameter elements.
|
| @@ -8335,13 +8321,12 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ClassScope} implement the scope defined by a class.
|
| * @coverage dart.engine.resolver
|
| */
|
| class ClassScope extends EnclosedScope {
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope enclosed within another scope.
|
| * @param enclosingScope the scope in which this scope is lexically enclosed
|
| @@ -8361,7 +8346,7 @@ class ClassScope extends EnclosedScope {
|
| }
|
| return super.getErrorForDuplicate(existing, duplicate);
|
| }
|
| -
|
| +
|
| /**
|
| * Define the instance members defined by the class.
|
| * @param typeElement the element representing the type represented by this scope
|
| @@ -8374,7 +8359,7 @@ class ClassScope extends EnclosedScope {
|
| define(method);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Define the type parameters for the class.
|
| * @param typeElement the element representing the type represented by this scope
|
| @@ -8386,19 +8371,18 @@ class ClassScope extends EnclosedScope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code EnclosedScope} implement a scope that is lexically enclosed in
|
| * another scope.
|
| * @coverage dart.engine.resolver
|
| */
|
| class EnclosedScope extends Scope {
|
| -
|
| +
|
| /**
|
| * The scope in which this scope is lexically enclosed.
|
| */
|
| Scope _enclosingScope;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope enclosed within another scope.
|
| * @param enclosingScope the scope in which this scope is lexically enclosed
|
| @@ -8408,7 +8392,7 @@ class EnclosedScope extends Scope {
|
| }
|
| LibraryElement get definingLibrary => _enclosingScope.definingLibrary;
|
| AnalysisErrorListener get errorListener => _enclosingScope.errorListener;
|
| -
|
| +
|
| /**
|
| * Return the scope in which this scope is lexically enclosed.
|
| * @return the scope in which this scope is lexically enclosed
|
| @@ -8422,13 +8406,12 @@ class EnclosedScope extends Scope {
|
| return _enclosingScope.lookup3(identifier, name, referencingLibrary);
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code FunctionScope} implement the scope defined by a function.
|
| * @coverage dart.engine.resolver
|
| */
|
| class FunctionScope extends EnclosedScope {
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope enclosed within another scope.
|
| * @param enclosingScope the scope in which this scope is lexically enclosed
|
| @@ -8437,7 +8420,7 @@ class FunctionScope extends EnclosedScope {
|
| FunctionScope(Scope enclosingScope, ExecutableElement functionElement) : super(new EnclosedScope(enclosingScope)) {
|
| defineParameters(functionElement);
|
| }
|
| -
|
| +
|
| /**
|
| * Define the parameters for the given function in the scope that encloses this function.
|
| * @param functionElement the element representing the function represented by this scope
|
| @@ -8457,14 +8440,13 @@ class FunctionScope extends EnclosedScope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code FunctionTypeScope} implement the scope defined by a function type
|
| * alias.
|
| * @coverage dart.engine.resolver
|
| */
|
| class FunctionTypeScope extends EnclosedScope {
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope enclosed within another scope.
|
| * @param enclosingScope the scope in which this scope is lexically enclosed
|
| @@ -8474,7 +8456,7 @@ class FunctionTypeScope extends EnclosedScope {
|
| defineTypeVariables(typeElement);
|
| defineParameters(typeElement);
|
| }
|
| -
|
| +
|
| /**
|
| * Define the parameters for the function type alias.
|
| * @param typeElement the element representing the type represented by this scope
|
| @@ -8484,7 +8466,7 @@ class FunctionTypeScope extends EnclosedScope {
|
| define(parameter);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Define the type variables for the function type alias.
|
| * @param typeElement the element representing the type represented by this scope
|
| @@ -8496,38 +8478,37 @@ class FunctionTypeScope extends EnclosedScope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code LabelScope} represent a scope in which a single label is defined.
|
| * @coverage dart.engine.resolver
|
| */
|
| class LabelScope {
|
| -
|
| +
|
| /**
|
| * The label scope enclosing this label scope.
|
| */
|
| LabelScope _outerScope;
|
| -
|
| +
|
| /**
|
| * The label defined in this scope.
|
| */
|
| String _label;
|
| -
|
| +
|
| /**
|
| * The element to which the label resolves.
|
| */
|
| LabelElement _element;
|
| -
|
| +
|
| /**
|
| * The marker used to look up a label element for an unlabeled {@code break} or {@code continue}.
|
| */
|
| static String EMPTY_LABEL = "";
|
| -
|
| +
|
| /**
|
| * The label element returned for scopes that can be the target of an unlabeled {@code break} or{@code continue}.
|
| */
|
| static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(new sc.StringToken(sc.TokenType.IDENTIFIER, "", 0));
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope to represent the potential target of an unlabeled{@code break} or {@code continue}.
|
| * @param outerScope the label scope enclosing the new label scope
|
| @@ -8535,12 +8516,12 @@ class LabelScope {
|
| * @param onSwitchMember {@code true} if this label is associated with a {@code switch} member
|
| */
|
| LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| - _jtd_constructor_286_impl(outerScope, onSwitchStatement, onSwitchMember);
|
| + _jtd_constructor_287_impl(outerScope, onSwitchStatement, onSwitchMember);
|
| }
|
| - _jtd_constructor_286_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| - _jtd_constructor_287_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
|
| + _jtd_constructor_287_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| + _jtd_constructor_288_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
|
| }
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope to represent the given label.
|
| * @param outerScope the label scope enclosing the new label scope
|
| @@ -8548,14 +8529,14 @@ class LabelScope {
|
| * @param element the element to which the label resolves
|
| */
|
| LabelScope.con2(LabelScope outerScope2, String label2, LabelElement element2) {
|
| - _jtd_constructor_287_impl(outerScope2, label2, element2);
|
| + _jtd_constructor_288_impl(outerScope2, label2, element2);
|
| }
|
| - _jtd_constructor_287_impl(LabelScope outerScope2, String label2, LabelElement element2) {
|
| + _jtd_constructor_288_impl(LabelScope outerScope2, String label2, LabelElement element2) {
|
| this._outerScope = outerScope2;
|
| this._label = label2;
|
| this._element = element2;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the label element corresponding to the given label, or {@code null} if the given label
|
| * is not defined in this scope.
|
| @@ -8563,7 +8544,7 @@ class LabelScope {
|
| * @return the label element corresponding to the given label
|
| */
|
| LabelElement lookup(SimpleIdentifier targetLabel) => lookup2(targetLabel.name);
|
| -
|
| +
|
| /**
|
| * Return the label element corresponding to the given label, or {@code null} if the given label
|
| * is not defined in this scope.
|
| @@ -8580,14 +8561,13 @@ class LabelScope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code LibraryImportScope} represent the scope containing all of the names
|
| * available from imported libraries.
|
| * @coverage dart.engine.resolver
|
| */
|
| class LibraryImportScope extends Scope {
|
| -
|
| +
|
| /**
|
| * @return {@code true} if the given {@link Identifier} is the part of type annotation.
|
| */
|
| @@ -8632,23 +8612,23 @@ class LibraryImportScope extends Scope {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * The element representing the library in which this scope is enclosed.
|
| */
|
| LibraryElement _definingLibrary;
|
| -
|
| +
|
| /**
|
| * The listener that is to be informed when an error is encountered.
|
| */
|
| AnalysisErrorListener _errorListener;
|
| -
|
| +
|
| /**
|
| * A list of the namespaces representing the names that are available in this scope from imported
|
| * libraries.
|
| */
|
| List<Namespace> _importedNamespaces = new List<Namespace>();
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope representing the names imported into the given library.
|
| * @param definingLibrary the element representing the library that imports the names defined in
|
| @@ -8703,7 +8683,7 @@ class LibraryImportScope extends Scope {
|
| }
|
| return foundElement;
|
| }
|
| -
|
| +
|
| /**
|
| * Create all of the namespaces associated with the libraries imported into this library. The
|
| * names are not added to this scope, but are stored for later reference.
|
| @@ -8717,14 +8697,13 @@ class LibraryImportScope extends Scope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code LibraryScope} implement a scope containing all of the names defined
|
| * in a given library.
|
| * @coverage dart.engine.resolver
|
| */
|
| class LibraryScope extends EnclosedScope {
|
| -
|
| +
|
| /**
|
| * Initialize a newly created scope representing the names defined in the given library.
|
| * @param definingLibrary the element representing the library represented by this scope
|
| @@ -8746,7 +8725,7 @@ class LibraryScope extends EnclosedScope {
|
| }
|
| return super.getErrorForDuplicate(existing, duplicate);
|
| }
|
| -
|
| +
|
| /**
|
| * Add to this scope all of the public top-level names that are defined in the given compilation
|
| * unit.
|
| @@ -8767,7 +8746,7 @@ class LibraryScope extends EnclosedScope {
|
| define(element);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add to this scope all of the names that are explicitly defined in the given library.
|
| * @param definingLibrary the element representing the library that defines the names in this
|
| @@ -8783,25 +8762,24 @@ class LibraryScope extends EnclosedScope {
|
| }
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code Namespace} implement a mapping of identifiers to the elements
|
| * represented by those identifiers. Namespaces are the building blocks for scopes.
|
| * @coverage dart.engine.resolver
|
| */
|
| class Namespace {
|
| -
|
| +
|
| /**
|
| * A table mapping names that are defined in this namespace to the element representing the thing
|
| * declared with that name.
|
| */
|
| Map<String, Element> _definedNames;
|
| -
|
| +
|
| /**
|
| * An empty namespace.
|
| */
|
| static Namespace EMPTY = new Namespace(new Map<String, Element>());
|
| -
|
| +
|
| /**
|
| * Initialize a newly created namespace to have the given defined names.
|
| * @param definedNames the mapping from names that are defined in this namespace to the
|
| @@ -8810,7 +8788,7 @@ class Namespace {
|
| Namespace(Map<String, Element> definedNames) {
|
| this._definedNames = definedNames;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element in this namespace that is available to the containing scope using the given
|
| * name.
|
| @@ -8818,21 +8796,20 @@ class Namespace {
|
| * @return the element represented by the given identifier
|
| */
|
| Element get(String name) => _definedNames[name];
|
| -
|
| +
|
| /**
|
| * Return a table containing the same mappings as those defined by this namespace.
|
| * @return a table containing the same mappings as those defined by this namespace
|
| */
|
| Map<String, Element> get definedNames => new Map<String, Element>.from(_definedNames);
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code NamespaceBuilder} are used to build a {@code Namespace}. Namespace
|
| * builders are thread-safe and re-usable.
|
| * @coverage dart.engine.resolver
|
| */
|
| class NamespaceBuilder {
|
| -
|
| +
|
| /**
|
| * Create a namespace representing the export namespace of the given {@link ExportElement}.
|
| * @param element the export element whose export namespace is to be created
|
| @@ -8847,14 +8824,14 @@ class NamespaceBuilder {
|
| definedNames = apply(definedNames, element.combinators);
|
| return new Namespace(definedNames);
|
| }
|
| -
|
| +
|
| /**
|
| * Create a namespace representing the export namespace of the given library.
|
| * @param library the library whose export namespace is to be created
|
| * @return the export namespace that was created
|
| */
|
| Namespace createExportNamespace2(LibraryElement library) => new Namespace(createExportMapping(library, new Set<LibraryElement>()));
|
| -
|
| +
|
| /**
|
| * Create a namespace representing the import namespace of the given library.
|
| * @param library the library whose import namespace is to be created
|
| @@ -8870,7 +8847,7 @@ class NamespaceBuilder {
|
| definedNames = apply2(definedNames, element.prefix);
|
| return new Namespace(definedNames);
|
| }
|
| -
|
| +
|
| /**
|
| * Create a namespace representing the public namespace of the given library.
|
| * @param library the library whose public namespace is to be created
|
| @@ -8884,7 +8861,7 @@ class NamespaceBuilder {
|
| }
|
| return new Namespace(definedNames);
|
| }
|
| -
|
| +
|
| /**
|
| * Add all of the names in the given namespace to the given mapping table.
|
| * @param definedNames the mapping table to which the names in the given namespace are to be added
|
| @@ -8895,7 +8872,7 @@ class NamespaceBuilder {
|
| definedNames[entry.getKey()] = entry.getValue();
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add all of the names in the given namespace to the given mapping table.
|
| * @param definedNames the mapping table to which the names in the given namespace are to be added
|
| @@ -8906,7 +8883,7 @@ class NamespaceBuilder {
|
| addAll(definedNames2, namespace.definedNames);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add the given element to the given mapping table if it has a publicly visible name.
|
| * @param definedNames the mapping table to which the public name is to be added
|
| @@ -8918,7 +8895,7 @@ class NamespaceBuilder {
|
| definedNames[name2] = element;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Add to the given mapping table all of the public top-level names that are defined in the given
|
| * compilation unit.
|
| @@ -8940,7 +8917,7 @@ class NamespaceBuilder {
|
| addIfPublic(definedNames, element);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Apply the given combinators to all of the names in the given mapping table.
|
| * @param definedNames the mapping table to which the namespace operations are to be applied
|
| @@ -8958,7 +8935,7 @@ class NamespaceBuilder {
|
| }
|
| return definedNames;
|
| }
|
| -
|
| +
|
| /**
|
| * Apply the given prefix to all of the names in the table of defined names.
|
| * @param definedNames the names that were defined before this operation
|
| @@ -8976,7 +8953,7 @@ class NamespaceBuilder {
|
| return definedNames;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Create a mapping table representing the export namespace of the given library.
|
| * @param library the library whose public namespace is to be created
|
| @@ -9003,7 +8980,7 @@ class NamespaceBuilder {
|
| visitedElements.remove(library);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Hide all of the given names by removing them from the given collection of defined names.
|
| * @param definedNames the names that were defined before this operation
|
| @@ -9014,7 +8991,7 @@ class NamespaceBuilder {
|
| definedNames.remove(name);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Show only the given names by removing all other names from the given collection of defined
|
| * names.
|
| @@ -9032,44 +9009,43 @@ class NamespaceBuilder {
|
| return newNames;
|
| }
|
| }
|
| -
|
| /**
|
| * The abstract class {@code Scope} defines the behavior common to name scopes used by the resolver
|
| * to determine which names are visible at any given point in the code.
|
| * @coverage dart.engine.resolver
|
| */
|
| abstract class Scope {
|
| -
|
| +
|
| /**
|
| * The prefix used to mark an identifier as being private to its library.
|
| */
|
| static String PRIVATE_NAME_PREFIX = "_";
|
| -
|
| +
|
| /**
|
| * The suffix added to the declared name of a setter when looking up the setter. Used to
|
| * disambiguate between a getter and a setter that have the same name.
|
| */
|
| static String SETTER_SUFFIX = "=";
|
| -
|
| +
|
| /**
|
| * The name used to look up the method used to implement the unary minus operator. Used to
|
| * disambiguate between the unary and binary operators.
|
| */
|
| static String UNARY_MINUS = "unary-";
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given name is a library-private name.
|
| * @param name the name being tested
|
| * @return {@code true} if the given name is a library-private name
|
| */
|
| static bool isPrivateName(String name) => name != null && name.startsWith(PRIVATE_NAME_PREFIX);
|
| -
|
| +
|
| /**
|
| * A table mapping names that are defined in this scope to the element representing the thing
|
| * declared with that name.
|
| */
|
| Map<String, Element> _definedNames = new Map<String, Element>();
|
| -
|
| +
|
| /**
|
| * Add the given element to this scope. If there is already an element with the given name defined
|
| * in this scope, then an error will be generated and the original element will continue to be
|
| @@ -9087,7 +9063,7 @@ abstract class Scope {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element with which the given identifier is associated, or {@code null} if the name
|
| * is not defined within this scope.
|
| @@ -9097,7 +9073,7 @@ abstract class Scope {
|
| * @return the element with which the given identifier is associated
|
| */
|
| Element lookup(Identifier identifier, LibraryElement referencingLibrary) => lookup3(identifier, identifier.name, referencingLibrary);
|
| -
|
| +
|
| /**
|
| * Add the given element to this scope without checking for duplication or hiding.
|
| * @param element the element to be added to this scope
|
| @@ -9105,7 +9081,7 @@ abstract class Scope {
|
| void defineWithoutChecking(Element element) {
|
| _definedNames[getName(element)] = element;
|
| }
|
| -
|
| +
|
| /**
|
| * Add the given element to this scope without checking for duplication or hiding.
|
| * @param name the name of the element to be added
|
| @@ -9114,13 +9090,13 @@ abstract class Scope {
|
| void defineWithoutChecking2(String name, Element element) {
|
| _definedNames[name] = element;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the element representing the library in which this scope is enclosed.
|
| * @return the element representing the library in which this scope is enclosed
|
| */
|
| LibraryElement get definingLibrary;
|
| -
|
| +
|
| /**
|
| * Return the error code to be used when reporting that a name being defined locally conflicts
|
| * with another element of the same name in the local scope.
|
| @@ -9135,20 +9111,20 @@ abstract class Scope {
|
| }
|
| return new AnalysisError.con2(source2, duplicate.nameOffset, duplicate.displayName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName]);
|
| }
|
| -
|
| +
|
| /**
|
| * Return the listener that is to be informed when an error is encountered.
|
| * @return the listener that is to be informed when an error is encountered
|
| */
|
| AnalysisErrorListener get errorListener;
|
| -
|
| +
|
| /**
|
| * Return the source object representing the compilation unit with which errors related to this
|
| * scope should be associated.
|
| * @return the source object with which errors should be associated
|
| */
|
| Source get source => definingLibrary.definingCompilationUnit.source;
|
| -
|
| +
|
| /**
|
| * Return the element with which the given name is associated, or {@code null} if the name is not
|
| * defined within this scope. This method only returns elements that are directly defined within
|
| @@ -9159,7 +9135,7 @@ abstract class Scope {
|
| * @return the element with which the given name is associated
|
| */
|
| Element localLookup(String name, LibraryElement referencingLibrary) => _definedNames[name];
|
| -
|
| +
|
| /**
|
| * Return the element with which the given name is associated, or {@code null} if the name is not
|
| * defined within this scope.
|
| @@ -9171,7 +9147,7 @@ abstract class Scope {
|
| * @return the element with which the given name is associated
|
| */
|
| Element lookup3(Identifier identifier, String name, LibraryElement referencingLibrary);
|
| -
|
| +
|
| /**
|
| * Return the name that will be used to look up the given element.
|
| * @param element the element whose look-up name is to be returned
|
| @@ -9187,7 +9163,6 @@ abstract class Scope {
|
| return element.name;
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ConstantVerifier} traverse an AST structure looking for additional
|
| * errors and warnings not covered by the parser and resolver. In particular, it looks for errors
|
| @@ -9195,32 +9170,32 @@ abstract class Scope {
|
| * @coverage dart.engine.resolver
|
| */
|
| class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * The error reporter by which errors will be reported.
|
| */
|
| ErrorReporter _errorReporter;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'bool'.
|
| */
|
| InterfaceType _boolType;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'int'.
|
| */
|
| InterfaceType _intType;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'num'.
|
| */
|
| InterfaceType _numType;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'string'.
|
| */
|
| InterfaceType _stringType;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created constant verifier.
|
| * @param errorReporter the error reporter by which errors will be reported
|
| @@ -9321,7 +9296,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * Return {@code true} if the given value is the result of evaluating an expression whose value is
|
| * a valid key in a const map literal. Keys in const map literals must be either a string, number,
|
| @@ -9330,7 +9305,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| * @return {@code true} if the given value is a valid key in a const map literal
|
| */
|
| bool isValidConstMapKey(Object value) => true;
|
| -
|
| +
|
| /**
|
| * If the given result represents one or more errors, report those errors. Except for special
|
| * cases, use the given error code rather than the one reported in the error.
|
| @@ -9349,7 +9324,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Validate that the given expression is a compile time constant. Return the value of the compile
|
| * time constant, or {@code null} if the expression is not a compile time constant.
|
| @@ -9362,7 +9337,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| reportErrors(result, errorCode);
|
| return result;
|
| }
|
| -
|
| +
|
| /**
|
| * Validate that if the passed instance creation is 'const' then all its arguments are constant
|
| * expressions.
|
| @@ -9383,7 +9358,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| validate(argument, CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Validate that the default value associated with each of the parameters in the given list is a
|
| * compile time constant.
|
| @@ -9407,7 +9382,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Validates that the given expression is a compile time constant.
|
| * @param parameterElements the elements of parameters of constant constructor, they are
|
| @@ -9418,7 +9393,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| EvaluationResultImpl result = expression.accept(new ConstantVisitor_10(this, parameterElements));
|
| reportErrors(result, CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER);
|
| }
|
| -
|
| +
|
| /**
|
| * Validates that all of the arguments of a constructor initializer are compile time constants.
|
| * @param parameterElements the elements of parameters of constant constructor, they are
|
| @@ -9433,7 +9408,7 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| validateInitializerExpression(parameterElements, argument);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Validates that the expressions of the given initializers (of a constant constructor) are all
|
| * compile time constants.
|
| @@ -9490,14 +9465,13 @@ class ConstantVisitor_10 extends ConstantVisitor {
|
| return super.visitSimpleIdentifier(node);
|
| }
|
| }
|
| -
|
| /**
|
| * Instances of the class {@code ErrorVerifier} traverse an AST structure looking for additional
|
| * errors and warnings not covered by the parser and resolver.
|
| * @coverage dart.engine.resolver
|
| */
|
| class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| -
|
| +
|
| /**
|
| * Checks if the given expression is the reference to the type.
|
| * @param expr the expression to evaluate
|
| @@ -9510,66 +9484,72 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * The error reporter by which errors will be reported.
|
| */
|
| ErrorReporter _errorReporter;
|
| -
|
| +
|
| /**
|
| * The current library that is being analyzed.
|
| */
|
| LibraryElement _currentLibrary;
|
| -
|
| +
|
| /**
|
| * The type representing the type 'dynamic'.
|
| */
|
| Type2 _dynamicType;
|
| -
|
| +
|
| /**
|
| * The object providing access to the types defined by the language.
|
| */
|
| TypeProvider _typeProvider;
|
| -
|
| +
|
| /**
|
| * The manager for the inheritance mappings.
|
| */
|
| InheritanceManager _inheritanceManager;
|
| -
|
| +
|
| + /**
|
| + * A flag indicating whether we are running in strict mode. In strict mode, error reporting is
|
| + * based exclusively on the static type information.
|
| + */
|
| + bool _strictMode = false;
|
| +
|
| /**
|
| * This is set to {@code true} iff the visitor is currently visiting children nodes of a{@link ConstructorDeclaration} and the constructor is 'const'.
|
| * @see #visitConstructorDeclaration(ConstructorDeclaration)
|
| */
|
| bool _isEnclosingConstructorConst = false;
|
| -
|
| +
|
| /**
|
| * This is set to {@code true} iff the visitor is currently visiting children nodes of a{@link CatchClause}.
|
| * @see #visitCatchClause(CatchClause)
|
| */
|
| bool _isInCatchClause = false;
|
| -
|
| +
|
| /**
|
| * This is set to {@code true} iff the visitor is currently visiting a{@link ConstructorInitializer}.
|
| */
|
| bool _isInConstructorInitializer = false;
|
| -
|
| +
|
| /**
|
| * This is set to {@code true} iff the visitor is currently visiting code in the SDK.
|
| */
|
| bool _isInSystemLibrary = false;
|
| -
|
| +
|
| /**
|
| * The class containing the AST nodes being visited, or {@code null} if we are not in the scope of
|
| * a class.
|
| */
|
| ClassElement _enclosingClass;
|
| -
|
| +
|
| /**
|
| * The method or function that we are currently visiting, or {@code null} if we are not inside a
|
| * method or function.
|
| */
|
| ExecutableElement _enclosingFunction;
|
| -
|
| +
|
| /**
|
| * This map is initialized when visiting the contents of a class declaration. If the visitor is
|
| * not in an enclosing class declaration, then the map is set to {@code null}.
|
| @@ -9582,27 +9562,27 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| * @see #checkForAllFinalInitializedErrorCodes(ConstructorDeclaration)
|
| */
|
| Map<FieldElement, INIT_STATE> _initialFieldElementsMap;
|
| -
|
| +
|
| /**
|
| * A table mapping name of the library to the export directive which export this library.
|
| */
|
| Map<String, LibraryElement> _nameToExportElement = new Map<String, LibraryElement>();
|
| -
|
| +
|
| /**
|
| * A table mapping name of the library to the import directive which import this library.
|
| */
|
| Map<String, LibraryElement> _nameToImportElement = new Map<String, LibraryElement>();
|
| -
|
| +
|
| /**
|
| * A table mapping names to the export elements exported them.
|
| */
|
| Map<String, ExportElement> _exportedNames = new Map<String, ExportElement>();
|
| -
|
| +
|
| /**
|
| * A set of the names of the variable initializers we are visiting now.
|
| */
|
| Set<String> _namesForReferenceToDeclaredVariableInInitializer = new Set<String>();
|
| -
|
| +
|
| /**
|
| * A list of types used by the {@link CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS} and{@link CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS} error codes.
|
| */
|
| @@ -9613,6 +9593,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| this._isInSystemLibrary = currentLibrary.source.isInSystemLibrary();
|
| this._typeProvider = typeProvider;
|
| this._inheritanceManager = inheritanceManager;
|
| + _strictMode = currentLibrary.context.analysisOptions.strictMode;
|
| _isEnclosingConstructorConst = false;
|
| _isInCatchClause = false;
|
| _dynamicType = typeProvider.dynamicType;
|
| @@ -9990,7 +9971,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| checkForNonBoolCondition(node.condition);
|
| return super.visitWhileStatement(node);
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed constructor declaration does not violate any of the error codes
|
| * relating to the initialization of fields in the enclosing class.
|
| @@ -10058,7 +10039,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks the passed method declaration against override-error codes.
|
| * @param node the {@link MethodDeclaration} to evaluate
|
| @@ -10205,7 +10186,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that all classes of the passed 'with' clause are valid.
|
| * @param node the 'with' clause to evaluate
|
| @@ -10231,7 +10212,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return problemReported;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that the return statement of the form <i>return e;</i> is not in a generative
|
| * constructor.
|
| @@ -10277,7 +10258,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| bool isStaticAssignable = staticReturnType.isAssignableTo(expectedReturnType);
|
| Type2 propagatedReturnType = getPropagatedType(returnExpression);
|
| - if (propagatedReturnType == null) {
|
| + if (_strictMode || propagatedReturnType == null) {
|
| if (isStaticAssignable) {
|
| return false;
|
| }
|
| @@ -10292,7 +10273,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| return true;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the export namespace of the passed export directive does not export any name
|
| * already exported by other export directive.
|
| @@ -10322,7 +10303,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed argument definition test identifier is a parameter.
|
| * @param node the {@link ArgumentDefinitionTest} to evaluate
|
| @@ -10338,7 +10319,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed arguments can be assigned to their corresponding parameters.
|
| * @param node the arguments to evaluate
|
| @@ -10355,7 +10336,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return problemReported;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed argument can be assigned to their corresponding parameters.
|
| * @param node the argument to evaluate
|
| @@ -10381,6 +10362,10 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| if (staticType.isAssignableTo(parameterType)) {
|
| return false;
|
| }
|
| + if (_strictMode) {
|
| + _errorReporter.reportError2(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, argument, [staticType.displayName, parameterType.displayName]);
|
| + return true;
|
| + }
|
| Type2 propagatedType = getPropagatedType(argument);
|
| if (propagatedType != null && propagatedType.isAssignableTo(parameterType)) {
|
| return false;
|
| @@ -10388,7 +10373,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, argument, [(propagatedType == null ? staticType : propagatedType).displayName, parameterType.displayName]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that left hand side of the passed assignment expression is not final.
|
| * @param node the assignment expression to evaluate
|
| @@ -10399,7 +10384,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| Expression leftExpression = node.leftHandSide;
|
| return checkForAssignmentToFinal2(leftExpression);
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed expression is not final.
|
| * @param node the expression to evaluate
|
| @@ -10432,7 +10417,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed identifier is not a keyword, and generates the passed error code
|
| * on the identifier if it is a keyword.
|
| @@ -10452,7 +10437,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed variable declaration list does not have a built-in identifier.
|
| * @param node the variable declaration list to check
|
| @@ -10476,7 +10461,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the given switch case is terminated with 'break', 'continue', 'return' or
|
| * 'throw'.
|
| @@ -10511,7 +10496,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError4(StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, node.keyword, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the switch cases in the given switch statement is terminated with 'break',
|
| * 'continue', 'return' or 'throw'.
|
| @@ -10531,7 +10516,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed switch statement does not have a case expression with the
|
| * operator '==' overridden.
|
| @@ -10555,7 +10540,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed method declaration is abstract only if the enclosing class is
|
| * also abstract.
|
| @@ -10571,7 +10556,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies all possible conflicts of the constructor name with other constructors and
|
| * members of the same class.
|
| @@ -10619,7 +10604,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the superclass of the enclosing class does not declare accessible static
|
| * member with the same name as the passed instance getter/setter method declaration.
|
| @@ -10664,7 +10649,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the enclosing class does not have an instance member with the same name as
|
| * the passed static getter method declaration.
|
| @@ -10697,7 +10682,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER, nameNode, [setterType.displayName]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the enclosing class does not have an instance member with the same name as
|
| * the passed static getter method declaration.
|
| @@ -10737,7 +10722,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER, nameNode, [memberType.displayName]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed constructor declaration is 'const' then there are no non-final
|
| * instance variable.
|
| @@ -10757,7 +10742,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, node, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed throw expression is not enclosed in a 'const' constructor
|
| * declaration.
|
| @@ -10772,7 +10757,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed normal formal parameter is not 'const'.
|
| * @param node the normal formal parameter to evaluate
|
| @@ -10786,7 +10771,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed instance creation expression is not being invoked on an abstract
|
| * class.
|
| @@ -10811,7 +10796,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed 'const' instance creation expression is not being invoked on a
|
| * constructor that is not 'const'.
|
| @@ -10829,7 +10814,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed 'const' instance creation expression does not reference any type
|
| * parameters.
|
| @@ -10847,7 +10832,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| TypeName typeName = constructorName2.type;
|
| return checkForConstWithTypeParameters2(typeName);
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed type name does not reference any type parameters.
|
| * @param typeName the type name to evaluate
|
| @@ -10875,7 +10860,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that if the passed 'const' instance creation expression is being invoked on the
|
| * resolved constructor.
|
| @@ -10907,7 +10892,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that there are no default parameters in the passed function type alias.
|
| * @param node the function type alias to evaluate
|
| @@ -10929,7 +10914,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return result;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed import has unique name among other exported libraries.
|
| * @param node the export directive to evaluate
|
| @@ -10958,7 +10943,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Check that if the visiting library is not system, then any passed library should not be SDK
|
| * internal library.
|
| @@ -10987,7 +10972,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, node, [node.uri]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed extends clause does not extend classes such as num or String.
|
| * @param node the extends clause to test
|
| @@ -11000,7 +10985,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return checkForExtendsOrImplementsDisallowedClass(extendsClause.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS);
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed type name does not extend or implement classes such as 'num' or
|
| * 'String'.
|
| @@ -11034,7 +11019,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed constructor field initializer has compatible field and
|
| * initializer expression types.
|
| @@ -11060,6 +11045,13 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| if (staticType.isAssignableTo(fieldType)) {
|
| return false;
|
| + } else if (_strictMode) {
|
| + if (_isEnclosingConstructorConst) {
|
| + _errorReporter.reportError2(CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, expression2, [staticType.displayName, fieldType.displayName]);
|
| + } else {
|
| + _errorReporter.reportError2(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE, expression2, [staticType.displayName, fieldType.displayName]);
|
| + }
|
| + return true;
|
| }
|
| Type2 propagatedType = getPropagatedType(expression2);
|
| if (propagatedType != null && propagatedType.isAssignableTo(fieldType)) {
|
| @@ -11072,7 +11064,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed field formal parameter is in a constructor declaration.
|
| * @param node the field formal parameter to test
|
| @@ -11097,7 +11089,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that final fields that are declared, without any constructors in the enclosing
|
| * class, are initialized. Cases in which there is at least one constructor are handled at the end
|
| @@ -11122,7 +11114,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed variable declaration list has only initialized variables if the
|
| * list is final or const. This method is called by{@link #checkForFinalNotInitialized(ClassDeclaration)},{@link #visitTopLevelVariableDeclaration(TopLevelVariableDeclaration)} and{@link #visitVariableDeclarationStatement(VariableDeclarationStatement)}.
|
| @@ -11143,7 +11135,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed implements clause does not implement classes such as 'num' or
|
| * 'String'.
|
| @@ -11161,7 +11153,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that if the passed identifier is part of constructor initializer, then it does
|
| * not reference implicitly 'this' expression.
|
| @@ -11209,7 +11201,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER, node, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed import has unique name among other imported libraries.
|
| * @param node the import directive to evaluate
|
| @@ -11238,7 +11230,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Check that if the visiting library is not system, then any passed library should not be SDK
|
| * internal library.
|
| @@ -11267,7 +11259,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, node, [node.uri]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed switch statement case expressions all have the same type.
|
| * @param node the switch statement to evaluate
|
| @@ -11295,7 +11287,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * For each class declaration, this method is called which verifies that all inherited members are
|
| * inherited consistently.
|
| @@ -11313,7 +11305,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * Given an assignment using a compound assignment operator, this verifies that the given
|
| * assignment is valid.
|
| @@ -11342,7 +11334,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed left hand side and right hand side represent a valid assignment.
|
| * @param lhs the left hand side expression
|
| @@ -11359,7 +11351,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| Type2 staticRightType = getStaticType(rhs);
|
| bool isStaticAssignable = staticRightType.isAssignableTo(leftType);
|
| Type2 propagatedRightType = getPropagatedType(rhs);
|
| - if (propagatedRightType == null) {
|
| + if (_strictMode || propagatedRightType == null) {
|
| if (!isStaticAssignable) {
|
| _errorReporter.reportError2(StaticTypeWarningCode.INVALID_ASSIGNMENT, rhs, [staticRightType.displayName, leftType.displayName]);
|
| return true;
|
| @@ -11373,7 +11365,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the usage of the passed 'this' is valid.
|
| * @param node the 'this' expression to evaluate
|
| @@ -11387,7 +11379,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks to ensure that first type argument to a map literal must be the 'String' type.
|
| * @param arguments a non-{@code null}, non-empty {@link TypeName} node list from the respective{@link MapLiteral}
|
| @@ -11403,7 +11395,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks to ensure that the passed {@link ListLiteral} or {@link MapLiteral} does not have a type
|
| * parameter as a type argument.
|
| @@ -11421,7 +11413,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the {@link #enclosingClass} does not define members with the same name as
|
| * the enclosing class.
|
| @@ -11445,7 +11437,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return problemReported;
|
| }
|
| -
|
| +
|
| /**
|
| * Check to make sure that all similarly typed accessors are of the same type (including inherited
|
| * accessors).
|
| @@ -11476,7 +11468,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES, accessorDeclaration, [accessorTextName, setterType.displayName, getterType.displayName]);
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed mixin does not have an explicitly declared constructor.
|
| * @param mixinName the node to report problem on
|
| @@ -11493,7 +11485,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed mixin has the 'Object' superclass.
|
| * @param mixinName the node to report problem on
|
| @@ -11511,7 +11503,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed mixin does not reference 'super'.
|
| * @param mixinName the node to report problem on
|
| @@ -11525,7 +11517,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed constructor has at most one 'super' initializer.
|
| * @param node the constructor declaration to evaluate
|
| @@ -11544,7 +11536,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return numSuperInitializers > 0;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks to ensure that native function bodies can only in SDK code.
|
| * @param node the native function body to test
|
| @@ -11558,7 +11550,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed 'new' instance creation expression invokes existing constructor.
|
| * <p>
|
| @@ -11588,7 +11580,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that passed class declaration overrides all members required by its superclasses
|
| * and interfaces.
|
| @@ -11677,7 +11669,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * Checks to ensure that the expressions that need to be of type bool, are. Otherwise an error is
|
| * reported on the expression.
|
| @@ -11693,7 +11685,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the passed assert statement has either a 'bool' or '() -> bool' input.
|
| * @param node the assert statement to evaluate
|
| @@ -11717,7 +11709,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed map literal either:
|
| * <ul>
|
| @@ -11746,7 +11738,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT, node, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed method declaration of operator {@code \[\]=}, has {@code void} return
|
| * type.
|
| @@ -11768,7 +11760,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed setter has no return type or the {@code void} return type.
|
| * @param typeName the type name to evaluate
|
| @@ -11784,7 +11776,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed operator-method declaration, does not have an optional parameter.
|
| * <p>
|
| @@ -11809,7 +11801,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return foundError;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks for named optional parameters that begin with '_'.
|
| * @param node the default formal parameter to evaluate
|
| @@ -11828,7 +11820,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks if the passed constructor declaration is the redirecting generative constructor and
|
| * references itself directly or indirectly.
|
| @@ -11852,7 +11844,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks if the passed constructor declaration has redirected constructor and references
|
| * itself directly or indirectly.
|
| @@ -11872,7 +11864,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, redirectedConstructorNode, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks the class declaration is not a superinterface to itself.
|
| * @param classElt the class element to test
|
| @@ -11936,7 +11928,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| list.removeAt(list.length - 1);
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks the passed constructor declaration has a valid combination of redirected
|
| * constructor invocation(s), super constructor invocations and field initializers.
|
| @@ -11972,7 +11964,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return numProblems != 0;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks if the passed constructor declaration has redirected constructor with compatible
|
| * function type.
|
| @@ -12004,7 +11996,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks if the passed constructor declaration has redirected constructor and references
|
| * itself directly or indirectly. TODO(scheglov)
|
| @@ -12034,7 +12026,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR, redirectedConstructorNode, []);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks if the passed identifier is banned because it is part of the variable declaration
|
| * with the same name.
|
| @@ -12081,7 +12073,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER, node, [name2]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that the rethrow is inside of a catch clause.
|
| * @param node the rethrow expression to evaluate
|
| @@ -12095,7 +12087,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that if the given "target" is the type reference then the "name" is not the
|
| * reference to a instance member.
|
| @@ -12119,7 +12111,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER, name2, [name2.name]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that the type of the passed 'switch' expression is assignable to the type of the
|
| * 'case' members.
|
| @@ -12149,7 +12141,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies that the type arguments in the passed instance creation expression are all within
|
| * their bounds as specified by the class element where the constructor \[that is being invoked\] is
|
| @@ -12179,7 +12171,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This checks that if the passed generative constructor has no explicit super constructor
|
| * invocation, then super class has the default generative constructor.
|
| @@ -12216,7 +12208,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| _errorReporter.reportError2(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT, node.returnType, [superElement.name]);
|
| return true;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies the passed operator-method declaration, has correct number of parameters.
|
| * <p>
|
| @@ -12255,7 +12247,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * This verifies if the passed setter parameter list have only one parameter.
|
| * <p>
|
| @@ -12279,7 +12271,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated type of the given expression, or the static type if there is no
|
| * propagated type information.
|
| @@ -12293,7 +12285,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Returns the Type (return type) for a given getter.
|
| * @param propertyAccessorElement
|
| @@ -12307,14 +12299,14 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| return null;
|
| }
|
| }
|
| -
|
| +
|
| /**
|
| * Return the propagated type of the given expression that is to be used for type analysis.
|
| * @param expression the expression whose type is to be returned
|
| * @return the propagated type of the given expression
|
| */
|
| Type2 getPropagatedType(Expression expression) => expression.propagatedType;
|
| -
|
| +
|
| /**
|
| * Returns the Type (first and only parameter) for a given setter.
|
| * @param propertyAccessorElement
|
| @@ -12327,7 +12319,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return setterParameters[0].type;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the static type of the given expression that is to be used for type analysis.
|
| * @param expression the expression whose type is to be returned
|
| @@ -12340,7 +12332,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return type;
|
| }
|
| -
|
| +
|
| /**
|
| * Return the variable element represented by the given expression, or {@code null} if there is no
|
| * such element.
|
| @@ -12356,7 +12348,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return null;
|
| }
|
| -
|
| +
|
| /**
|
| * @return {@code true} if the given constructor redirects to itself, directly or indirectly
|
| */
|
| @@ -12375,7 +12367,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| return false;
|
| }
|
| -
|
| +
|
| /**
|
| * @param node the 'this' expression to analyze
|
| * @return {@code true} if the given 'this' expression is in the valid context
|
| @@ -12400,7 +12392,6 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| return false;
|
| }
|
| }
|
| -
|
| /**
|
| * This enum holds one of four states of a field initialization state through a constructor
|
| * signature, not initialized, initialized in the field declaration, initialized in the field
|
| @@ -12413,10 +12404,10 @@ class INIT_STATE implements Comparable<INIT_STATE> {
|
| static final INIT_STATE INIT_IN_DEFAULT_VALUE = new INIT_STATE('INIT_IN_DEFAULT_VALUE', 3);
|
| static final INIT_STATE INIT_IN_INITIALIZERS = new INIT_STATE('INIT_IN_INITIALIZERS', 4);
|
| static final List<INIT_STATE> values = [NOT_INIT, INIT_IN_DECLARATION, INIT_IN_FIELD_FORMAL, INIT_IN_DEFAULT_VALUE, INIT_IN_INITIALIZERS];
|
| -
|
| +
|
| /// The name of this enum constant, as declared in the enum declaration.
|
| final String name;
|
| -
|
| +
|
| /// The position in the enum declaration.
|
| final int ordinal;
|
| INIT_STATE(this.name, this.ordinal) {
|
| @@ -12424,7 +12415,128 @@ class INIT_STATE implements Comparable<INIT_STATE> {
|
| int compareTo(INIT_STATE other) => ordinal - other.ordinal;
|
| String toString() => name;
|
| }
|
| +/**
|
| + * Instances of the class {@code PubVerifier} traverse an AST structure looking for deviations from
|
| + * pub best practices.
|
| + */
|
| +class PubVerifier extends RecursiveASTVisitor<Object> {
|
| +
|
| + /**
|
| + * The error reporter by which errors will be reported.
|
| + */
|
| + ErrorReporter _errorReporter;
|
| + PubVerifier(ErrorReporter errorReporter) {
|
| + this._errorReporter = errorReporter;
|
| + }
|
| + Object visitImportDirective(ImportDirective directive) {
|
| +// StringLiteral uriLiteral = directive.uri;
|
| +// if (uriLiteral == null) {
|
| +// return null;
|
| +// }
|
| +// String uriContent = uriLiteral.stringValue;
|
| +// if (uriContent == null) {
|
| +// return null;
|
| +// }
|
| +// uriContent = uriContent.trim();
|
| +// int index = uriContent.indexOf(':');
|
| +// String scheme;
|
| +// String path;
|
| +// if (index > -1) {
|
| +// scheme = uriContent.substring(0, index);
|
| +// path = uriContent.substring(index + 1);
|
| +// } else {
|
| +// scheme = FileUriResolver.FILE_SCHEME;
|
| +// path = uriContent;
|
| +// }
|
| +// if (scheme == FileUriResolver.FILE_SCHEME) {
|
| +// if (checkForFileImportOutsideLibReferencesFileInside(directive, path)) {
|
| +// _errorReporter.reportError2(PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE, uriLiteral, []);
|
| +// } else if (checkForFileImportInsideLibReferencesFileOutside(directive, path)) {
|
| +// _errorReporter.reportError2(PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE, uriLiteral, []);
|
| +// }
|
| +// } else if (scheme == PackageUriResolver.PACKAGE_SCHEME) {
|
| +// if (checkForPackageImportContainsDotDot(path)) {
|
| +// _errorReporter.reportError2(PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT, uriLiteral, []);
|
| +// }
|
| +// }
|
| + return null;
|
| + }
|
| +
|
| + /**
|
| + * Determine if the file file path lies inside the "lib" directory hierarchy but references a file
|
| + * outside that directory hierarchy.
|
| + * @param directive the import directive (not {@code null})
|
| + * @param path the file path being verified (not {@code null})
|
| + * @return {@code true} if the file is inside but references a file outside
|
| + */
|
| + bool checkForFileImportInsideLibReferencesFileOutside(ImportDirective directive, String path) {
|
| + String fullName = getSourceFullName(directive);
|
| + if (fullName != null) {
|
| + int pathIndex = 0;
|
| + int fullNameIndex = fullName.length;
|
| + while (pathIndex < path.length && JavaString.startsWithBefore(path, "../", pathIndex)) {
|
| + fullNameIndex = fullName.lastIndexOf('/', fullNameIndex);
|
| + if (fullNameIndex < 4) {
|
| + return false;
|
| + }
|
| + if (JavaString.startsWithBefore(fullName, "/lib", fullNameIndex - 4)) {
|
| + return true;
|
| + }
|
| + pathIndex += 3;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| + * Determine if the given file path lies outside the "lib" directory hierarchy but references a
|
| + * file inside that directory hierarchy.
|
| + * @param directive the import directive (not {@code null})
|
| + * @param path the file path being verified (not {@code null})
|
| + * @return {@code true} if the file is outside but references a file inside
|
| + */
|
| + bool checkForFileImportOutsideLibReferencesFileInside(ImportDirective directive, String path) {
|
| + if (path.startsWith("lib/") || path.contains("/lib/")) {
|
| + String fullName = getSourceFullName(directive);
|
| + if (fullName != null) {
|
| + if (!fullName.contains("/lib/")) {
|
| + return true;
|
| + }
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| + * Determine if the given package import path contains ".."
|
| + * @param path the path to be validated (not {@code null})
|
| + * @return {@code true} if the import path contains ".."
|
| + */
|
| + bool checkForPackageImportContainsDotDot(String path) => path.contains("/../");
|
|
|
| + /**
|
| + * Answer the full name of the source associated with the compilation unit containing the given
|
| + * AST node. The returned value will have all {@link File#separatorChar} replace by '/'.
|
| + * @param node the node (not {@code null})
|
| + * @return the full name or {@code null} if it could not be determined
|
| + */
|
| + String getSourceFullName(ASTNode node) {
|
| +// CompilationUnit unit = node.getAncestor(CompilationUnit);
|
| +// if (unit != null) {
|
| +// CompilationUnitElement element2 = unit.element;
|
| +// if (element2 != null) {
|
| +// Source librarySource = element2.source;
|
| +// if (librarySource != null) {
|
| +// String fullName2 = librarySource.fullName;
|
| +// if (fullName2 != null) {
|
| +// return fullName2.replaceAll(JavaFile.separatorChar, '/');
|
| +// }
|
| +// }
|
| +// }
|
| +// }
|
| + return null;
|
| + }
|
| +}
|
| /**
|
| * The enumeration {@code ResolverErrorCode} defines the error codes used for errors detected by the
|
| * resolver. The convention for this class is for the name of the error code to indicate the problem
|
| @@ -12437,23 +12549,23 @@ class ResolverErrorCode implements Comparable<ResolverErrorCode>, ErrorCode {
|
| static final ResolverErrorCode CONTINUE_LABEL_ON_SWITCH = new ResolverErrorCode('CONTINUE_LABEL_ON_SWITCH', 1, ErrorType.COMPILE_TIME_ERROR, "A continue label resolves to switch, must be loop or switch member");
|
| static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new ResolverErrorCode('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TIME_ERROR, "Libraries that have parts must have a library directive");
|
| static final List<ResolverErrorCode> values = [BREAK_LABEL_ON_SWITCH_MEMBER, CONTINUE_LABEL_ON_SWITCH, MISSING_LIBRARY_DIRECTIVE_WITH_PART];
|
| -
|
| +
|
| /// The name of this enum constant, as declared in the enum declaration.
|
| final String name;
|
| -
|
| +
|
| /// The position in the enum declaration.
|
| final int ordinal;
|
| -
|
| +
|
| /**
|
| * The type of this error.
|
| */
|
| ErrorType _type;
|
| -
|
| +
|
| /**
|
| * The message template used to create the message to be displayed for this error.
|
| */
|
| String _message;
|
| -
|
| +
|
| /**
|
| * Initialize a newly created error code to have the given type and message.
|
| * @param type the type of this error
|
|
|