Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 257773008: New analyzer snapshot, based on r35422. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update pubspec.yaml Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.resolver; 8 library engine.resolver;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 CatchClause catchClause = catchClauses[i]; 3053 CatchClause catchClause = catchClauses[i];
3054 if (catchClause.onKeyword != null) { 3054 if (catchClause.onKeyword != null) {
3055 // on-catch clause found, verify that the exception type is not a subtyp e of a previous 3055 // on-catch clause found, verify that the exception type is not a subtyp e of a previous
3056 // on-catch exception type 3056 // on-catch exception type
3057 TypeName typeName = catchClause.exceptionType; 3057 TypeName typeName = catchClause.exceptionType;
3058 if (typeName != null && typeName.type != null) { 3058 if (typeName != null && typeName.type != null) {
3059 DartType currentType = typeName.type; 3059 DartType currentType = typeName.type;
3060 if (currentType.isObject) { 3060 if (currentType.isObject) {
3061 // Found catch clause clause that has Object as an exception type, t his is equivalent to 3061 // Found catch clause clause that has Object as an exception type, t his is equivalent to
3062 // having a catch clause that doesn't have an exception type, visit the block, but 3062 // having a catch clause that doesn't have an exception type, visit the block, but
3063 // generate an error on any following catch clauses (and don't visit them). 3063 // generate an error on any following catch clauses (and don't visi t them).
3064 _safelyVisit(catchClause); 3064 _safelyVisit(catchClause);
3065 if (i + 1 != numOfCatchClauses) { 3065 if (i + 1 != numOfCatchClauses) {
3066 // this catch clause is not the last in the try statement 3066 // this catch clause is not the last in the try statement
3067 CatchClause nextCatchClause = catchClauses[i + 1]; 3067 CatchClause nextCatchClause = catchClauses[i + 1];
3068 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1]; 3068 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
3069 int offset = nextCatchClause.offset; 3069 int offset = nextCatchClause.offset;
3070 int length = lastCatchClause.end - offset; 3070 int length = lastCatchClause.end - offset;
3071 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLO WING_CATCH, offset, length, []); 3071 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLO WING_CATCH, offset, length, []);
3072 return null; 3072 return null;
3073 } 3073 }
3074 } 3074 }
3075 for (DartType type in visitedTypes) { 3075 for (DartType type in visitedTypes) {
3076 if (currentType.isSubtypeOf(type)) { 3076 if (currentType.isSubtypeOf(type)) {
3077 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1]; 3077 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
3078 int offset = catchClause.offset; 3078 int offset = catchClause.offset;
3079 int length = lastCatchClause.end - offset; 3079 int length = lastCatchClause.end - offset;
3080 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_ON_CATCH_SU BTYPE, offset, length, [currentType.displayName, type.displayName]); 3080 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_ON_CATCH_SU BTYPE, offset, length, [currentType.displayName, type.displayName]);
3081 return null; 3081 return null;
3082 } 3082 }
3083 } 3083 }
3084 visitedTypes.add(currentType); 3084 visitedTypes.add(currentType);
3085 } 3085 }
3086 _safelyVisit(catchClause); 3086 _safelyVisit(catchClause);
3087 } else { 3087 } else {
3088 // Found catch clause clause that doesn't have an exception type, visit the block, but 3088 // Found catch clause clause that doesn't have an exception type, visit the block, but
3089 // generate an error on any following catch clauses (and don't visit the m). 3089 // generate an error on any following catch clauses (and don't visit the m).
3090 _safelyVisit(catchClause); 3090 _safelyVisit(catchClause);
3091 if (i + 1 != numOfCatchClauses) { 3091 if (i + 1 != numOfCatchClauses) {
3092 // this catch clause is not the last in the try statement 3092 // this catch clause is not the last in the try statement
3093 CatchClause nextCatchClause = catchClauses[i + 1]; 3093 CatchClause nextCatchClause = catchClauses[i + 1];
3094 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1]; 3094 CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
3095 int offset = nextCatchClause.offset; 3095 int offset = nextCatchClause.offset;
3096 int length = lastCatchClause.end - offset; 3096 int length = lastCatchClause.end - offset;
3097 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLOWING _CATCH, offset, length, []); 3097 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLOWING _CATCH, offset, length, []);
3098 return null; 3098 return null;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 ValidResult _getConstantBooleanValue(Expression expression) { 3133 ValidResult _getConstantBooleanValue(Expression expression) {
3134 if (expression is BooleanLiteral) { 3134 if (expression is BooleanLiteral) {
3135 if (expression.value) { 3135 if (expression.value) {
3136 return new ValidResult(new DartObjectImpl(null, BoolState.from(true))); 3136 return new ValidResult(new DartObjectImpl(null, BoolState.from(true)));
3137 } else { 3137 } else {
3138 return new ValidResult(new DartObjectImpl(null, BoolState.from(false))); 3138 return new ValidResult(new DartObjectImpl(null, BoolState.from(false)));
3139 } 3139 }
3140 } 3140 }
3141 // Don't consider situations where we could evaluate to a constant boolean e xpression with the 3141 // Don't consider situations where we could evaluate to a constant boolean e xpression with the
3142 // ConstantVisitor 3142 // ConstantVisitor
3143 // else { 3143 //
3144 // EvaluationResultImpl result = expression.accept(new ConstantVisitor( )); 3144 // else {
3145 // if (result == ValidResult.RESULT_TRUE) { 3145 //
3146 // return ValidResult.RESULT_TRUE; 3146 // EvaluationResultImpl result = expression.accept(new ConstantVisitor( ));
3147 // } else if (result == ValidResult.RESULT_FALSE) { 3147 //
3148 // return ValidResult.RESULT_FALSE; 3148 // if (result == ValidResult.RESULT_TRUE) {
3149 // } 3149 //
3150 // return null; 3150 // return ValidResult.RESULT_TRUE;
3151 // } 3151 //
3152 // } else if (result == ValidResult.RESULT_FALSE) {
3153 //
3154 // return ValidResult.RESULT_FALSE;
3155 //
3156 // }
3157 //
3158 // return null;
3159 //
3160 // }
3152 return null; 3161 return null;
3153 } 3162 }
3154 3163
3155 /** 3164 /**
3156 * Return `true` if and only if the passed expression is resolved to a constan t variable. 3165 * Return `true` if and only if the passed expression is resolved to a constan t variable.
3157 * 3166 *
3158 * @param expression some conditional expression 3167 * @param expression some conditional expression
3159 * @return `true` if and only if the passed expression is resolved to a consta nt variable 3168 * @return `true` if and only if the passed expression is resolved to a consta nt variable
3160 */ 3169 */
3161 bool _isDebugConstant(Expression expression) { 3170 bool _isDebugConstant(Expression expression) {
(...skipping 6751 matching lines...) Expand 10 before | Expand all | Expand 10 after
9913 if (prefix == null) { 9922 if (prefix == null) {
9914 prefix = new PrefixElementImpl(prefixNode); 9923 prefix = new PrefixElementImpl(prefixNode);
9915 nameToPrefixMap[prefixName] = prefix; 9924 nameToPrefixMap[prefixName] = prefix;
9916 } 9925 }
9917 importElement.prefix = prefix; 9926 importElement.prefix = prefix;
9918 prefixNode.staticElement = prefix; 9927 prefixNode.staticElement = prefix;
9919 } 9928 }
9920 directive.element = importElement; 9929 directive.element = importElement;
9921 imports.add(importElement); 9930 imports.add(importElement);
9922 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) { 9931 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
9923 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 9932 ErrorCode errorCode = (importElement.isDeferred ? StaticWarningC ode.IMPORT_OF_NON_LIBRARY : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
9933 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, errorCode, [uriLiteral.toSource()]));
9924 } 9934 }
9925 } 9935 }
9926 } 9936 }
9927 } else if (directive is ExportDirective) { 9937 } else if (directive is ExportDirective) {
9928 ExportDirective exportDirective = directive; 9938 ExportDirective exportDirective = directive;
9929 Source exportedSource = exportDirective.source; 9939 Source exportedSource = exportDirective.source;
9930 if (exportedSource != null) { 9940 if (exportedSource != null) {
9931 // The exported source will be null if the URI in the export directi ve was invalid. 9941 // The exported source will be null if the URI in the export directi ve was invalid.
9932 Library exportedLibrary = _libraryMap[exportedSource]; 9942 Library exportedLibrary = _libraryMap[exportedSource];
9933 if (exportedLibrary != null) { 9943 if (exportedLibrary != null) {
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
10490 if (prefix == null) { 10500 if (prefix == null) {
10491 prefix = new PrefixElementImpl(prefixNode); 10501 prefix = new PrefixElementImpl(prefixNode);
10492 nameToPrefixMap[prefixName] = prefix; 10502 nameToPrefixMap[prefixName] = prefix;
10493 } 10503 }
10494 importElement.prefix = prefix; 10504 importElement.prefix = prefix;
10495 prefixNode.staticElement = prefix; 10505 prefixNode.staticElement = prefix;
10496 } 10506 }
10497 directive.element = importElement; 10507 directive.element = importElement;
10498 imports.add(importElement); 10508 imports.add(importElement);
10499 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) { 10509 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
10500 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 10510 ErrorCode errorCode = (importElement.isDeferred ? StaticWarningC ode.IMPORT_OF_NON_LIBRARY : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
10511 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, errorCode, [uriLiteral.toSource()]));
10501 } 10512 }
10502 } 10513 }
10503 } 10514 }
10504 } else if (directive is ExportDirective) { 10515 } else if (directive is ExportDirective) {
10505 ExportDirective exportDirective = directive; 10516 ExportDirective exportDirective = directive;
10506 Source exportedSource = exportDirective.source; 10517 Source exportedSource = exportDirective.source;
10507 if (exportedSource != null && analysisContext.exists(exportedSource)) { 10518 if (exportedSource != null && analysisContext.exists(exportedSource)) {
10508 // The exported source will be null if the URI in the export directi ve was invalid. 10519 // The exported source will be null if the URI in the export directi ve was invalid.
10509 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource]; 10520 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource];
10510 if (exportedLibrary != null) { 10521 if (exportedLibrary != null) {
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
11256 } 11267 }
11257 11268
11258 @override 11269 @override
11259 Object visitBinaryExpression(BinaryExpression node) { 11270 Object visitBinaryExpression(BinaryExpression node) {
11260 sc.TokenType operatorType = node.operator.type; 11271 sc.TokenType operatorType = node.operator.type;
11261 Expression leftOperand = node.leftOperand; 11272 Expression leftOperand = node.leftOperand;
11262 Expression rightOperand = node.rightOperand; 11273 Expression rightOperand = node.rightOperand;
11263 if (operatorType == sc.TokenType.AMPERSAND_AMPERSAND) { 11274 if (operatorType == sc.TokenType.AMPERSAND_AMPERSAND) {
11264 safelyVisit(leftOperand); 11275 safelyVisit(leftOperand);
11265 if (rightOperand != null) { 11276 if (rightOperand != null) {
11277 _overrideManager.enterScope();
11266 try { 11278 try {
11267 _overrideManager.enterScope();
11268 _promoteManager.enterScope(); 11279 _promoteManager.enterScope();
11269 _propagateTrueState(leftOperand); 11280 try {
11270 // Type promotion. 11281 _propagateTrueState(leftOperand);
11271 _promoteTypes(leftOperand); 11282 // Type promotion.
11272 _clearTypePromotionsIfPotentiallyMutatedIn(leftOperand); 11283 _promoteTypes(leftOperand);
11273 _clearTypePromotionsIfPotentiallyMutatedIn(rightOperand); 11284 _clearTypePromotionsIfPotentiallyMutatedIn(leftOperand);
11274 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightOpe rand); 11285 _clearTypePromotionsIfPotentiallyMutatedIn(rightOperand);
11275 // Visit right operand. 11286 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightO perand);
11276 rightOperand.accept(this); 11287 // Visit right operand.
11288 rightOperand.accept(this);
11289 } finally {
11290 _promoteManager.exitScope();
11291 }
11277 } finally { 11292 } finally {
11278 _overrideManager.exitScope(); 11293 _overrideManager.exitScope();
11279 _promoteManager.exitScope();
11280 } 11294 }
11281 } 11295 }
11282 } else if (operatorType == sc.TokenType.BAR_BAR) { 11296 } else if (operatorType == sc.TokenType.BAR_BAR) {
11283 safelyVisit(leftOperand); 11297 safelyVisit(leftOperand);
11284 if (rightOperand != null) { 11298 if (rightOperand != null) {
11299 _overrideManager.enterScope();
11285 try { 11300 try {
11286 _overrideManager.enterScope();
11287 _propagateFalseState(leftOperand); 11301 _propagateFalseState(leftOperand);
11288 rightOperand.accept(this); 11302 rightOperand.accept(this);
11289 } finally { 11303 } finally {
11290 _overrideManager.exitScope(); 11304 _overrideManager.exitScope();
11291 } 11305 }
11292 } 11306 }
11293 } else { 11307 } else {
11294 safelyVisit(leftOperand); 11308 safelyVisit(leftOperand);
11295 safelyVisit(rightOperand); 11309 safelyVisit(rightOperand);
11296 } 11310 }
11297 node.accept(_elementResolver); 11311 node.accept(_elementResolver);
11298 node.accept(_typeAnalyzer); 11312 node.accept(_typeAnalyzer);
11299 return null; 11313 return null;
11300 } 11314 }
11301 11315
11302 @override 11316 @override
11303 Object visitBlockFunctionBody(BlockFunctionBody node) { 11317 Object visitBlockFunctionBody(BlockFunctionBody node) {
11304 safelyVisit(_commentBeforeFunction); 11318 safelyVisit(_commentBeforeFunction);
11319 _overrideManager.enterScope();
11305 try { 11320 try {
11306 _overrideManager.enterScope();
11307 super.visitBlockFunctionBody(node); 11321 super.visitBlockFunctionBody(node);
11308 } finally { 11322 } finally {
11309 _overrideManager.exitScope(); 11323 _overrideManager.exitScope();
11310 } 11324 }
11311 return null; 11325 return null;
11312 } 11326 }
11313 11327
11314 @override 11328 @override
11315 Object visitBreakStatement(BreakStatement node) { 11329 Object visitBreakStatement(BreakStatement node) {
11316 // 11330 //
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
11361 @override 11375 @override
11362 Object visitCompilationUnit(CompilationUnit node) { 11376 Object visitCompilationUnit(CompilationUnit node) {
11363 // 11377 //
11364 // TODO(brianwilkerson) The goal of the code below is to visit the declarati ons in such an 11378 // TODO(brianwilkerson) The goal of the code below is to visit the declarati ons in such an
11365 // order that we can infer type information for top-level variables before w e visit references 11379 // order that we can infer type information for top-level variables before w e visit references
11366 // to them. This is better than making no effort, but still doesn't complete ly satisfy that 11380 // to them. This is better than making no effort, but still doesn't complete ly satisfy that
11367 // goal (consider for example "final var a = b; final var b = 0;"; we'll inf er a type of 'int' 11381 // goal (consider for example "final var a = b; final var b = 0;"; we'll inf er a type of 'int'
11368 // for 'b', but not for 'a' because of the order of the visits). Ideally we would create a 11382 // for 'b', but not for 'a' because of the order of the visits). Ideally we would create a
11369 // dependency graph, but that would require references to be resolved, which they are not. 11383 // dependency graph, but that would require references to be resolved, which they are not.
11370 // 11384 //
11385 _overrideManager.enterScope();
11371 try { 11386 try {
11372 _overrideManager.enterScope();
11373 NodeList<Directive> directives = node.directives; 11387 NodeList<Directive> directives = node.directives;
11374 int directiveCount = directives.length; 11388 int directiveCount = directives.length;
11375 for (int i = 0; i < directiveCount; i++) { 11389 for (int i = 0; i < directiveCount; i++) {
11376 directives[i].accept(this); 11390 directives[i].accept(this);
11377 } 11391 }
11378 NodeList<CompilationUnitMember> declarations = node.declarations; 11392 NodeList<CompilationUnitMember> declarations = node.declarations;
11379 int declarationCount = declarations.length; 11393 int declarationCount = declarations.length;
11380 for (int i = 0; i < declarationCount; i++) { 11394 for (int i = 0; i < declarationCount; i++) {
11381 CompilationUnitMember declaration = declarations[i]; 11395 CompilationUnitMember declaration = declarations[i];
11382 if (declaration is! ClassDeclaration) { 11396 if (declaration is! ClassDeclaration) {
(...skipping 13 matching lines...) Expand all
11396 node.accept(_typeAnalyzer); 11410 node.accept(_typeAnalyzer);
11397 return null; 11411 return null;
11398 } 11412 }
11399 11413
11400 @override 11414 @override
11401 Object visitConditionalExpression(ConditionalExpression node) { 11415 Object visitConditionalExpression(ConditionalExpression node) {
11402 Expression condition = node.condition; 11416 Expression condition = node.condition;
11403 safelyVisit(condition); 11417 safelyVisit(condition);
11404 Expression thenExpression = node.thenExpression; 11418 Expression thenExpression = node.thenExpression;
11405 if (thenExpression != null) { 11419 if (thenExpression != null) {
11420 _overrideManager.enterScope();
11406 try { 11421 try {
11407 _overrideManager.enterScope();
11408 _promoteManager.enterScope(); 11422 _promoteManager.enterScope();
11409 _propagateTrueState(condition); 11423 try {
11410 // Type promotion. 11424 _propagateTrueState(condition);
11411 _promoteTypes(condition); 11425 // Type promotion.
11412 _clearTypePromotionsIfPotentiallyMutatedIn(thenExpression); 11426 _promoteTypes(condition);
11413 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpres sion); 11427 _clearTypePromotionsIfPotentiallyMutatedIn(thenExpression);
11414 // Visit "then" expression. 11428 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpr ession);
11415 thenExpression.accept(this); 11429 // Visit "then" expression.
11430 thenExpression.accept(this);
11431 } finally {
11432 _promoteManager.exitScope();
11433 }
11416 } finally { 11434 } finally {
11417 _overrideManager.exitScope(); 11435 _overrideManager.exitScope();
11418 _promoteManager.exitScope();
11419 } 11436 }
11420 } 11437 }
11421 Expression elseExpression = node.elseExpression; 11438 Expression elseExpression = node.elseExpression;
11422 if (elseExpression != null) { 11439 if (elseExpression != null) {
11440 _overrideManager.enterScope();
11423 try { 11441 try {
11424 _overrideManager.enterScope();
11425 _propagateFalseState(condition); 11442 _propagateFalseState(condition);
11426 elseExpression.accept(this); 11443 elseExpression.accept(this);
11427 } finally { 11444 } finally {
11428 _overrideManager.exitScope(); 11445 _overrideManager.exitScope();
11429 } 11446 }
11430 } 11447 }
11431 node.accept(_elementResolver); 11448 node.accept(_elementResolver);
11432 node.accept(_typeAnalyzer); 11449 node.accept(_typeAnalyzer);
11433 bool thenIsAbrupt = _isAbruptTerminationExpression(thenExpression); 11450 bool thenIsAbrupt = _isAbruptTerminationExpression(thenExpression);
11434 bool elseIsAbrupt = _isAbruptTerminationExpression(elseExpression); 11451 bool elseIsAbrupt = _isAbruptTerminationExpression(elseExpression);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
11482 // 11499 //
11483 // We do not visit the label because it needs to be visited in the context o f the statement. 11500 // We do not visit the label because it needs to be visited in the context o f the statement.
11484 // 11501 //
11485 node.accept(_elementResolver); 11502 node.accept(_elementResolver);
11486 node.accept(_typeAnalyzer); 11503 node.accept(_typeAnalyzer);
11487 return null; 11504 return null;
11488 } 11505 }
11489 11506
11490 @override 11507 @override
11491 Object visitDoStatement(DoStatement node) { 11508 Object visitDoStatement(DoStatement node) {
11509 _overrideManager.enterScope();
11492 try { 11510 try {
11493 _overrideManager.enterScope();
11494 super.visitDoStatement(node); 11511 super.visitDoStatement(node);
11495 } finally { 11512 } finally {
11496 _overrideManager.exitScope(); 11513 _overrideManager.exitScope();
11497 } 11514 }
11498 // TODO(brianwilkerson) If the loop can only be exited because the condition is false, then 11515 // TODO(brianwilkerson) If the loop can only be exited because the condition is false, then
11499 // propagateFalseState(node.getCondition()); 11516 // propagateFalseState(node.getCondition());
11500 return null; 11517 return null;
11501 } 11518 }
11502 11519
11503 @override 11520 @override
11504 Object visitEmptyFunctionBody(EmptyFunctionBody node) { 11521 Object visitEmptyFunctionBody(EmptyFunctionBody node) {
11505 safelyVisit(_commentBeforeFunction); 11522 safelyVisit(_commentBeforeFunction);
11506 return super.visitEmptyFunctionBody(node); 11523 return super.visitEmptyFunctionBody(node);
11507 } 11524 }
11508 11525
11509 @override 11526 @override
11510 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { 11527 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
11511 safelyVisit(_commentBeforeFunction); 11528 safelyVisit(_commentBeforeFunction);
11529 _overrideManager.enterScope();
11512 try { 11530 try {
11513 _overrideManager.enterScope();
11514 super.visitExpressionFunctionBody(node); 11531 super.visitExpressionFunctionBody(node);
11515 } finally { 11532 } finally {
11516 _overrideManager.exitScope(); 11533 _overrideManager.exitScope();
11517 } 11534 }
11518 return null; 11535 return null;
11519 } 11536 }
11520 11537
11521 @override 11538 @override
11522 Object visitFieldDeclaration(FieldDeclaration node) { 11539 Object visitFieldDeclaration(FieldDeclaration node) {
11540 _overrideManager.enterScope();
11523 try { 11541 try {
11524 _overrideManager.enterScope();
11525 super.visitFieldDeclaration(node); 11542 super.visitFieldDeclaration(node);
11526 } finally { 11543 } finally {
11527 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node. fields); 11544 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node. fields);
11528 _overrideManager.exitScope(); 11545 _overrideManager.exitScope();
11529 _overrideManager.applyOverrides(overrides); 11546 _overrideManager.applyOverrides(overrides);
11530 } 11547 }
11531 return null; 11548 return null;
11532 } 11549 }
11533 11550
11534 @override 11551 @override
11535 Object visitForEachStatement(ForEachStatement node) { 11552 Object visitForEachStatement(ForEachStatement node) {
11553 _overrideManager.enterScope();
11536 try { 11554 try {
11537 _overrideManager.enterScope();
11538 super.visitForEachStatement(node); 11555 super.visitForEachStatement(node);
11539 } finally { 11556 } finally {
11540 _overrideManager.exitScope(); 11557 _overrideManager.exitScope();
11541 } 11558 }
11542 return null; 11559 return null;
11543 } 11560 }
11544 11561
11545 @override 11562 @override
11546 Object visitForStatement(ForStatement node) { 11563 Object visitForStatement(ForStatement node) {
11564 _overrideManager.enterScope();
11547 try { 11565 try {
11548 _overrideManager.enterScope();
11549 super.visitForStatement(node); 11566 super.visitForStatement(node);
11550 } finally { 11567 } finally {
11551 _overrideManager.exitScope(); 11568 _overrideManager.exitScope();
11552 } 11569 }
11553 return null; 11570 return null;
11554 } 11571 }
11555 11572
11556 @override 11573 @override
11557 Object visitFunctionDeclaration(FunctionDeclaration node) { 11574 Object visitFunctionDeclaration(FunctionDeclaration node) {
11558 ExecutableElement outerFunction = _enclosingFunction; 11575 ExecutableElement outerFunction = _enclosingFunction;
11559 try { 11576 try {
11560 SimpleIdentifier functionName = node.name; 11577 SimpleIdentifier functionName = node.name;
11561 _enclosingFunction = functionName.staticElement as ExecutableElement; 11578 _enclosingFunction = functionName.staticElement as ExecutableElement;
11562 super.visitFunctionDeclaration(node); 11579 super.visitFunctionDeclaration(node);
11563 } finally { 11580 } finally {
11564 _enclosingFunction = outerFunction; 11581 _enclosingFunction = outerFunction;
11565 } 11582 }
11566 return null; 11583 return null;
11567 } 11584 }
11568 11585
11569 @override 11586 @override
11570 Object visitFunctionExpression(FunctionExpression node) { 11587 Object visitFunctionExpression(FunctionExpression node) {
11571 ExecutableElement outerFunction = _enclosingFunction; 11588 ExecutableElement outerFunction = _enclosingFunction;
11572 try { 11589 try {
11573 _enclosingFunction = node.element; 11590 _enclosingFunction = node.element;
11574 _overrideManager.enterScope(); 11591 _overrideManager.enterScope();
11575 super.visitFunctionExpression(node); 11592 try {
11593 super.visitFunctionExpression(node);
11594 } finally {
11595 _overrideManager.exitScope();
11596 }
11576 } finally { 11597 } finally {
11577 _overrideManager.exitScope();
11578 _enclosingFunction = outerFunction; 11598 _enclosingFunction = outerFunction;
11579 } 11599 }
11580 return null; 11600 return null;
11581 } 11601 }
11582 11602
11583 @override 11603 @override
11584 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 11604 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
11585 safelyVisit(node.function); 11605 safelyVisit(node.function);
11586 node.accept(_elementResolver); 11606 node.accept(_elementResolver);
11587 _inferFunctionExpressionsParametersTypes(node.argumentList); 11607 _inferFunctionExpressionsParametersTypes(node.argumentList);
11588 safelyVisit(node.argumentList); 11608 safelyVisit(node.argumentList);
11589 node.accept(_typeAnalyzer); 11609 node.accept(_typeAnalyzer);
11590 return null; 11610 return null;
11591 } 11611 }
11592 11612
11593 @override 11613 @override
11594 Object visitHideCombinator(HideCombinator node) => null; 11614 Object visitHideCombinator(HideCombinator node) => null;
11595 11615
11596 @override 11616 @override
11597 Object visitIfStatement(IfStatement node) { 11617 Object visitIfStatement(IfStatement node) {
11598 Expression condition = node.condition; 11618 Expression condition = node.condition;
11599 safelyVisit(condition); 11619 safelyVisit(condition);
11600 Map<Element, DartType> thenOverrides = null; 11620 Map<Element, DartType> thenOverrides = null;
11601 Statement thenStatement = node.thenStatement; 11621 Statement thenStatement = node.thenStatement;
11602 if (thenStatement != null) { 11622 if (thenStatement != null) {
11623 _overrideManager.enterScope();
11603 try { 11624 try {
11604 _overrideManager.enterScope();
11605 _promoteManager.enterScope(); 11625 _promoteManager.enterScope();
11606 _propagateTrueState(condition); 11626 try {
11607 // Type promotion. 11627 _propagateTrueState(condition);
11608 _promoteTypes(condition); 11628 // Type promotion.
11609 _clearTypePromotionsIfPotentiallyMutatedIn(thenStatement); 11629 _promoteTypes(condition);
11610 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStatem ent); 11630 _clearTypePromotionsIfPotentiallyMutatedIn(thenStatement);
11611 // Visit "then". 11631 _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStat ement);
11612 visitStatementInScope(thenStatement); 11632 // Visit "then".
11633 visitStatementInScope(thenStatement);
11634 } finally {
11635 _promoteManager.exitScope();
11636 }
11613 } finally { 11637 } finally {
11614 thenOverrides = _overrideManager.captureLocalOverrides(); 11638 thenOverrides = _overrideManager.captureLocalOverrides();
11615 _overrideManager.exitScope(); 11639 _overrideManager.exitScope();
11616 _promoteManager.exitScope();
11617 } 11640 }
11618 } 11641 }
11619 Map<Element, DartType> elseOverrides = null; 11642 Map<Element, DartType> elseOverrides = null;
11620 Statement elseStatement = node.elseStatement; 11643 Statement elseStatement = node.elseStatement;
11621 if (elseStatement != null) { 11644 if (elseStatement != null) {
11645 _overrideManager.enterScope();
11622 try { 11646 try {
11623 _overrideManager.enterScope();
11624 _propagateFalseState(condition); 11647 _propagateFalseState(condition);
11625 visitStatementInScope(elseStatement); 11648 visitStatementInScope(elseStatement);
11626 } finally { 11649 } finally {
11627 elseOverrides = _overrideManager.captureLocalOverrides(); 11650 elseOverrides = _overrideManager.captureLocalOverrides();
11628 _overrideManager.exitScope(); 11651 _overrideManager.exitScope();
11629 } 11652 }
11630 } 11653 }
11631 node.accept(_elementResolver); 11654 node.accept(_elementResolver);
11632 node.accept(_typeAnalyzer); 11655 node.accept(_typeAnalyzer);
11633 bool thenIsAbrupt = _isAbruptTerminationStatement(thenStatement); 11656 bool thenIsAbrupt = _isAbruptTerminationStatement(thenStatement);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
11732 // visited in the context of the constructor invocation. 11755 // visited in the context of the constructor invocation.
11733 // 11756 //
11734 safelyVisit(node.argumentList); 11757 safelyVisit(node.argumentList);
11735 node.accept(_elementResolver); 11758 node.accept(_elementResolver);
11736 node.accept(_typeAnalyzer); 11759 node.accept(_typeAnalyzer);
11737 return null; 11760 return null;
11738 } 11761 }
11739 11762
11740 @override 11763 @override
11741 Object visitSwitchCase(SwitchCase node) { 11764 Object visitSwitchCase(SwitchCase node) {
11765 _overrideManager.enterScope();
11742 try { 11766 try {
11743 _overrideManager.enterScope();
11744 super.visitSwitchCase(node); 11767 super.visitSwitchCase(node);
11745 } finally { 11768 } finally {
11746 _overrideManager.exitScope(); 11769 _overrideManager.exitScope();
11747 } 11770 }
11748 return null; 11771 return null;
11749 } 11772 }
11750 11773
11751 @override 11774 @override
11752 Object visitSwitchDefault(SwitchDefault node) { 11775 Object visitSwitchDefault(SwitchDefault node) {
11776 _overrideManager.enterScope();
11753 try { 11777 try {
11754 _overrideManager.enterScope();
11755 super.visitSwitchDefault(node); 11778 super.visitSwitchDefault(node);
11756 } finally { 11779 } finally {
11757 _overrideManager.exitScope(); 11780 _overrideManager.exitScope();
11758 } 11781 }
11759 return null; 11782 return null;
11760 } 11783 }
11761 11784
11762 @override 11785 @override
11763 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 11786 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
11787 _overrideManager.enterScope();
11764 try { 11788 try {
11765 _overrideManager.enterScope();
11766 super.visitTopLevelVariableDeclaration(node); 11789 super.visitTopLevelVariableDeclaration(node);
11767 } finally { 11790 } finally {
11768 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node. variables); 11791 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node. variables);
11769 _overrideManager.exitScope(); 11792 _overrideManager.exitScope();
11770 _overrideManager.applyOverrides(overrides); 11793 _overrideManager.applyOverrides(overrides);
11771 } 11794 }
11772 return null; 11795 return null;
11773 } 11796 }
11774 11797
11775 @override 11798 @override
11776 Object visitTypeName(TypeName node) => null; 11799 Object visitTypeName(TypeName node) => null;
11777 11800
11778 @override 11801 @override
11779 Object visitWhileStatement(WhileStatement node) { 11802 Object visitWhileStatement(WhileStatement node) {
11780 Expression condition = node.condition; 11803 Expression condition = node.condition;
11781 safelyVisit(condition); 11804 safelyVisit(condition);
11782 Statement body = node.body; 11805 Statement body = node.body;
11783 if (body != null) { 11806 if (body != null) {
11807 _overrideManager.enterScope();
11784 try { 11808 try {
11785 _overrideManager.enterScope();
11786 _propagateTrueState(condition); 11809 _propagateTrueState(condition);
11787 visitStatementInScope(body); 11810 visitStatementInScope(body);
11788 } finally { 11811 } finally {
11789 _overrideManager.exitScope(); 11812 _overrideManager.exitScope();
11790 } 11813 }
11791 } 11814 }
11792 // TODO(brianwilkerson) If the loop can only be exited because the condition is false, then 11815 // TODO(brianwilkerson) If the loop can only be exited because the condition is false, then
11793 // propagateFalseState(condition); 11816 // propagateFalseState(condition);
11794 node.accept(_elementResolver); 11817 node.accept(_elementResolver);
11795 node.accept(_typeAnalyzer); 11818 node.accept(_typeAnalyzer);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
11936 // while visiting the iterator. 11959 // while visiting the iterator.
11937 // 11960 //
11938 Expression iterator = node.iterator; 11961 Expression iterator = node.iterator;
11939 safelyVisit(iterator); 11962 safelyVisit(iterator);
11940 DeclaredIdentifier loopVariable = node.loopVariable; 11963 DeclaredIdentifier loopVariable = node.loopVariable;
11941 SimpleIdentifier identifier = node.identifier; 11964 SimpleIdentifier identifier = node.identifier;
11942 safelyVisit(loopVariable); 11965 safelyVisit(loopVariable);
11943 safelyVisit(identifier); 11966 safelyVisit(identifier);
11944 Statement body = node.body; 11967 Statement body = node.body;
11945 if (body != null) { 11968 if (body != null) {
11969 _overrideManager.enterScope();
11946 try { 11970 try {
11947 _overrideManager.enterScope();
11948 if (loopVariable != null && iterator != null) { 11971 if (loopVariable != null && iterator != null) {
11949 LocalVariableElement loopElement = loopVariable.element; 11972 LocalVariableElement loopElement = loopVariable.element;
11950 if (loopElement != null) { 11973 if (loopElement != null) {
11951 DartType iteratorElementType = _getIteratorElementType(iterator); 11974 DartType iteratorElementType = _getIteratorElementType(iterator);
11952 overrideVariable(loopElement, iteratorElementType); 11975 overrideVariable(loopElement, iteratorElementType);
11953 _recordPropagatedType(loopVariable.identifier, iteratorElementType); 11976 _recordPropagatedType(loopVariable.identifier, iteratorElementType);
11954 } 11977 }
11955 } else if (identifier != null && iterator != null) { 11978 } else if (identifier != null && iterator != null) {
11956 Element identifierElement = identifier.staticElement; 11979 Element identifierElement = identifier.staticElement;
11957 if (identifierElement is VariableElement) { 11980 if (identifierElement is VariableElement) {
(...skipping 6549 matching lines...) Expand 10 before | Expand all | Expand 10 after
18507 WithClause withClause = node.withClause; 18530 WithClause withClause = node.withClause;
18508 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ IDENTIFIER_AS_TYPE_NAME); 18531 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ IDENTIFIER_AS_TYPE_NAME);
18509 _checkForMemberWithClassName(); 18532 _checkForMemberWithClassName();
18510 _checkForNoDefaultSuperConstructorImplicit(node); 18533 _checkForNoDefaultSuperConstructorImplicit(node);
18511 _checkForConflictingTypeVariableErrorCodes(node); 18534 _checkForConflictingTypeVariableErrorCodes(node);
18512 // Only do error checks on the clause nodes if there is a non-null clause 18535 // Only do error checks on the clause nodes if there is a non-null clause
18513 if (implementsClause != null || extendsClause != null || withClause != nul l) { 18536 if (implementsClause != null || extendsClause != null || withClause != nul l) {
18514 // Only check for all of the inheritance logic around clauses if there i sn't an error code 18537 // Only check for all of the inheritance logic around clauses if there i sn't an error code
18515 // such as "Cannot extend double" already on the class. 18538 // such as "Cannot extend double" already on the class.
18516 if (!_checkForImplementsDisallowedClass(implementsClause) && !_checkForE xtendsDisallowedClass(extendsClause) && !_checkForAllMixinErrorCodes(withClause) ) { 18539 if (!_checkForImplementsDisallowedClass(implementsClause) && !_checkForE xtendsDisallowedClass(extendsClause) && !_checkForAllMixinErrorCodes(withClause) ) {
18540 _checkForExtendsDeferredClass(extendsClause);
18541 _checkForImplementsDeferredClass(implementsClause);
18517 _checkForNonAbstractClassInheritsAbstractMember(node.name); 18542 _checkForNonAbstractClassInheritsAbstractMember(node.name);
18518 _checkForInconsistentMethodInheritance(); 18543 _checkForInconsistentMethodInheritance();
18519 _checkForRecursiveInterfaceInheritance(_enclosingClass); 18544 _checkForRecursiveInterfaceInheritance(_enclosingClass);
18520 _checkForConflictingGetterAndMethod(); 18545 _checkForConflictingGetterAndMethod();
18521 _checkForConflictingInstanceGetterAndSuperclassMember(); 18546 _checkForConflictingInstanceGetterAndSuperclassMember();
18522 _checkImplementsSuperClass(node); 18547 _checkImplementsSuperClass(node);
18523 _checkImplementsFunctionWithoutCall(node); 18548 _checkImplementsFunctionWithoutCall(node);
18524 } 18549 }
18525 } 18550 }
18526 // initialize initialFieldElementsMap 18551 // initialize initialFieldElementsMap
(...skipping 20 matching lines...) Expand all
18547 18572
18548 @override 18573 @override
18549 Object visitClassTypeAlias(ClassTypeAlias node) { 18574 Object visitClassTypeAlias(ClassTypeAlias node) {
18550 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID ENTIFIER_AS_TYPEDEF_NAME); 18575 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID ENTIFIER_AS_TYPEDEF_NAME);
18551 ClassElement outerClassElement = _enclosingClass; 18576 ClassElement outerClassElement = _enclosingClass;
18552 try { 18577 try {
18553 _enclosingClass = node.element; 18578 _enclosingClass = node.element;
18554 // Only check for all of the inheritance logic around clauses if there isn 't an error code 18579 // Only check for all of the inheritance logic around clauses if there isn 't an error code
18555 // such as "Cannot extend double" already on the class. 18580 // such as "Cannot extend double" already on the class.
18556 if (!_checkForExtendsDisallowedClassInTypeAlias(node) && !_checkForImpleme ntsDisallowedClass(node.implementsClause) && !_checkForAllMixinErrorCodes(node.w ithClause)) { 18581 if (!_checkForExtendsDisallowedClassInTypeAlias(node) && !_checkForImpleme ntsDisallowedClass(node.implementsClause) && !_checkForAllMixinErrorCodes(node.w ithClause)) {
18582 _checkForExtendsDeferredClassInTypeAlias(node);
18583 _checkForImplementsDeferredClass(node.implementsClause);
18557 _checkForRecursiveInterfaceInheritance(node.element); 18584 _checkForRecursiveInterfaceInheritance(node.element);
18558 _checkForTypeAliasCannotReferenceItself_mixin(node); 18585 _checkForTypeAliasCannotReferenceItself_mixin(node);
18559 _checkForNonAbstractClassInheritsAbstractMember(node.name); 18586 _checkForNonAbstractClassInheritsAbstractMember(node.name);
18560 } 18587 }
18561 } finally { 18588 } finally {
18562 _enclosingClass = outerClassElement; 18589 _enclosingClass = outerClassElement;
18563 } 18590 }
18564 return super.visitClassTypeAlias(node); 18591 return super.visitClassTypeAlias(node);
18565 } 18592 }
18566 18593
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
18686 _isInInstanceVariableDeclaration = false; 18713 _isInInstanceVariableDeclaration = false;
18687 } 18714 }
18688 } 18715 }
18689 18716
18690 @override 18717 @override
18691 Object visitFieldFormalParameter(FieldFormalParameter node) { 18718 Object visitFieldFormalParameter(FieldFormalParameter node) {
18692 _checkForValidField(node); 18719 _checkForValidField(node);
18693 _checkForConstFormalParameter(node); 18720 _checkForConstFormalParameter(node);
18694 _checkForPrivateOptionalParameter(node); 18721 _checkForPrivateOptionalParameter(node);
18695 _checkForFieldInitializingFormalRedirectingConstructor(node); 18722 _checkForFieldInitializingFormalRedirectingConstructor(node);
18723 _checkForTypeAnnotationDeferredClass(node.type);
18696 return super.visitFieldFormalParameter(node); 18724 return super.visitFieldFormalParameter(node);
18697 } 18725 }
18698 18726
18699 @override 18727 @override
18700 Object visitFunctionDeclaration(FunctionDeclaration node) { 18728 Object visitFunctionDeclaration(FunctionDeclaration node) {
18701 ExecutableElement outerFunction = _enclosingFunction; 18729 ExecutableElement outerFunction = _enclosingFunction;
18702 try { 18730 try {
18703 SimpleIdentifier identifier = node.name; 18731 SimpleIdentifier identifier = node.name;
18704 String methodName = ""; 18732 String methodName = "";
18705 if (identifier != null) { 18733 if (identifier != null) {
18706 methodName = identifier.name; 18734 methodName = identifier.name;
18707 } 18735 }
18708 _enclosingFunction = node.element; 18736 _enclosingFunction = node.element;
18709 if (node.isSetter || node.isGetter) { 18737 if (node.isSetter || node.isGetter) {
18710 _checkForMismatchedAccessorTypes(node, methodName); 18738 _checkForMismatchedAccessorTypes(node, methodName);
18711 if (node.isSetter) { 18739 if (node.isSetter) {
18712 FunctionExpression functionExpression = node.functionExpression; 18740 FunctionExpression functionExpression = node.functionExpression;
18713 if (functionExpression != null) { 18741 if (functionExpression != null) {
18714 _checkForWrongNumberOfParametersForSetter(node.name, functionExpress ion.parameters); 18742 _checkForWrongNumberOfParametersForSetter(node.name, functionExpress ion.parameters);
18715 } 18743 }
18716 TypeName returnType = node.returnType; 18744 TypeName returnType = node.returnType;
18717 _checkForNonVoidReturnTypeForSetter(returnType); 18745 _checkForNonVoidReturnTypeForSetter(returnType);
18718 } 18746 }
18719 } 18747 }
18748 _checkForTypeAnnotationDeferredClass(node.returnType);
18720 return super.visitFunctionDeclaration(node); 18749 return super.visitFunctionDeclaration(node);
18721 } finally { 18750 } finally {
18722 _enclosingFunction = outerFunction; 18751 _enclosingFunction = outerFunction;
18723 } 18752 }
18724 } 18753 }
18725 18754
18726 @override 18755 @override
18727 Object visitFunctionExpression(FunctionExpression node) { 18756 Object visitFunctionExpression(FunctionExpression node) {
18728 // If this function expression is wrapped in a function declaration, don't c hange the 18757 // If this function expression is wrapped in a function declaration, don't c hange the
18729 // enclosingFunction field. 18758 // enclosingFunction field.
(...skipping 26 matching lines...) Expand all
18756 _checkForDefaultValueInFunctionTypeAlias(node); 18785 _checkForDefaultValueInFunctionTypeAlias(node);
18757 _checkForTypeAliasCannotReferenceItself_function(node); 18786 _checkForTypeAliasCannotReferenceItself_function(node);
18758 return super.visitFunctionTypeAlias(node); 18787 return super.visitFunctionTypeAlias(node);
18759 } 18788 }
18760 18789
18761 @override 18790 @override
18762 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 18791 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
18763 bool old = _isInFunctionTypedFormalParameter; 18792 bool old = _isInFunctionTypedFormalParameter;
18764 _isInFunctionTypedFormalParameter = true; 18793 _isInFunctionTypedFormalParameter = true;
18765 try { 18794 try {
18795 _checkForTypeAnnotationDeferredClass(node.returnType);
18766 return super.visitFunctionTypedFormalParameter(node); 18796 return super.visitFunctionTypedFormalParameter(node);
18767 } finally { 18797 } finally {
18768 _isInFunctionTypedFormalParameter = old; 18798 _isInFunctionTypedFormalParameter = old;
18769 } 18799 }
18770 } 18800 }
18771 18801
18772 @override 18802 @override
18773 Object visitIfStatement(IfStatement node) { 18803 Object visitIfStatement(IfStatement node) {
18774 _checkForNonBoolCondition(node.condition); 18804 _checkForNonBoolCondition(node.condition);
18775 return super.visitIfStatement(node); 18805 return super.visitIfStatement(node);
(...skipping 25 matching lines...) Expand all
18801 ConstructorName constructorName = node.constructorName; 18831 ConstructorName constructorName = node.constructorName;
18802 TypeName typeName = constructorName.type; 18832 TypeName typeName = constructorName.type;
18803 DartType type = typeName.type; 18833 DartType type = typeName.type;
18804 if (type is InterfaceType) { 18834 if (type is InterfaceType) {
18805 InterfaceType interfaceType = type; 18835 InterfaceType interfaceType = type;
18806 _checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); 18836 _checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
18807 if (_isInConstInstanceCreation) { 18837 if (_isInConstInstanceCreation) {
18808 _checkForConstWithNonConst(node); 18838 _checkForConstWithNonConst(node);
18809 _checkForConstWithUndefinedConstructor(node); 18839 _checkForConstWithUndefinedConstructor(node);
18810 _checkForConstWithTypeParametersInCreation(node); 18840 _checkForConstWithTypeParametersInCreation(node);
18841 _checkForConstDeferredClass(node, constructorName, typeName);
18811 } else { 18842 } else {
18812 _checkForNewWithUndefinedConstructor(node); 18843 _checkForNewWithUndefinedConstructor(node);
18813 } 18844 }
18814 } 18845 }
18815 return super.visitInstanceCreationExpression(node); 18846 return super.visitInstanceCreationExpression(node);
18816 } finally { 18847 } finally {
18817 _isInConstInstanceCreation = false; 18848 _isInConstInstanceCreation = false;
18818 } 18849 }
18819 } 18850 }
18820 18851
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
18856 Object visitMethodDeclaration(MethodDeclaration node) { 18887 Object visitMethodDeclaration(MethodDeclaration node) {
18857 ExecutableElement previousFunction = _enclosingFunction; 18888 ExecutableElement previousFunction = _enclosingFunction;
18858 try { 18889 try {
18859 _isInStaticMethod = node.isStatic; 18890 _isInStaticMethod = node.isStatic;
18860 _enclosingFunction = node.element; 18891 _enclosingFunction = node.element;
18861 SimpleIdentifier identifier = node.name; 18892 SimpleIdentifier identifier = node.name;
18862 String methodName = ""; 18893 String methodName = "";
18863 if (identifier != null) { 18894 if (identifier != null) {
18864 methodName = identifier.name; 18895 methodName = identifier.name;
18865 } 18896 }
18897 TypeName returnTypeName = node.returnType;
18866 if (node.isSetter || node.isGetter) { 18898 if (node.isSetter || node.isGetter) {
18867 _checkForMismatchedAccessorTypes(node, methodName); 18899 _checkForMismatchedAccessorTypes(node, methodName);
18868 } 18900 }
18869 if (node.isGetter) { 18901 if (node.isGetter) {
18870 _checkForVoidReturnType(node); 18902 _checkForVoidReturnType(node);
18871 _checkForConflictingStaticGetterAndInstanceSetter(node); 18903 _checkForConflictingStaticGetterAndInstanceSetter(node);
18872 } else if (node.isSetter) { 18904 } else if (node.isSetter) {
18873 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters); 18905 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters);
18874 _checkForNonVoidReturnTypeForSetter(node.returnType); 18906 _checkForNonVoidReturnTypeForSetter(returnTypeName);
18875 _checkForConflictingStaticSetterAndInstanceMember(node); 18907 _checkForConflictingStaticSetterAndInstanceMember(node);
18876 } else if (node.isOperator) { 18908 } else if (node.isOperator) {
18877 _checkForOptionalParameterInOperator(node); 18909 _checkForOptionalParameterInOperator(node);
18878 _checkForWrongNumberOfParametersForOperator(node); 18910 _checkForWrongNumberOfParametersForOperator(node);
18879 _checkForNonVoidReturnTypeForOperator(node); 18911 _checkForNonVoidReturnTypeForOperator(node);
18880 } 18912 }
18881 _checkForConcreteClassWithAbstractMember(node); 18913 _checkForConcreteClassWithAbstractMember(node);
18882 _checkForAllInvalidOverrideErrorCodesForMethod(node); 18914 _checkForAllInvalidOverrideErrorCodesForMethod(node);
18915 _checkForTypeAnnotationDeferredClass(returnTypeName);
18883 return super.visitMethodDeclaration(node); 18916 return super.visitMethodDeclaration(node);
18884 } finally { 18917 } finally {
18885 _enclosingFunction = previousFunction; 18918 _enclosingFunction = previousFunction;
18886 _isInStaticMethod = false; 18919 _isInStaticMethod = false;
18887 } 18920 }
18888 } 18921 }
18889 18922
18890 @override 18923 @override
18891 Object visitMethodInvocation(MethodInvocation node) { 18924 Object visitMethodInvocation(MethodInvocation node) {
18892 Expression target = node.realTarget; 18925 Expression target = node.realTarget;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
18980 _returnsWith.add(node); 19013 _returnsWith.add(node);
18981 } 19014 }
18982 _checkForAllReturnStatementErrorCodes(node); 19015 _checkForAllReturnStatementErrorCodes(node);
18983 return super.visitReturnStatement(node); 19016 return super.visitReturnStatement(node);
18984 } 19017 }
18985 19018
18986 @override 19019 @override
18987 Object visitSimpleFormalParameter(SimpleFormalParameter node) { 19020 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
18988 _checkForConstFormalParameter(node); 19021 _checkForConstFormalParameter(node);
18989 _checkForPrivateOptionalParameter(node); 19022 _checkForPrivateOptionalParameter(node);
19023 _checkForTypeAnnotationDeferredClass(node.type);
18990 return super.visitSimpleFormalParameter(node); 19024 return super.visitSimpleFormalParameter(node);
18991 } 19025 }
18992 19026
18993 @override 19027 @override
18994 Object visitSimpleIdentifier(SimpleIdentifier node) { 19028 Object visitSimpleIdentifier(SimpleIdentifier node) {
18995 _checkForImplicitThisReferenceInInitializer(node); 19029 _checkForImplicitThisReferenceInInitializer(node);
18996 if (!_isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) { 19030 if (!_isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) {
18997 _checkForUnqualifiedReferenceToNonLocalStaticMember(node); 19031 _checkForUnqualifiedReferenceToNonLocalStaticMember(node);
18998 } 19032 }
18999 return super.visitSimpleIdentifier(node); 19033 return super.visitSimpleIdentifier(node);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
19039 Object visitTypeName(TypeName node) { 19073 Object visitTypeName(TypeName node) {
19040 _checkForTypeArgumentNotMatchingBounds(node); 19074 _checkForTypeArgumentNotMatchingBounds(node);
19041 _checkForTypeParameterReferencedByStatic(node); 19075 _checkForTypeParameterReferencedByStatic(node);
19042 return super.visitTypeName(node); 19076 return super.visitTypeName(node);
19043 } 19077 }
19044 19078
19045 @override 19079 @override
19046 Object visitTypeParameter(TypeParameter node) { 19080 Object visitTypeParameter(TypeParameter node) {
19047 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID ENTIFIER_AS_TYPE_PARAMETER_NAME); 19081 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID ENTIFIER_AS_TYPE_PARAMETER_NAME);
19048 _checkForTypeParameterSupertypeOfItsBound(node); 19082 _checkForTypeParameterSupertypeOfItsBound(node);
19083 _checkForTypeAnnotationDeferredClass(node.bound);
19049 return super.visitTypeParameter(node); 19084 return super.visitTypeParameter(node);
19050 } 19085 }
19051 19086
19052 @override 19087 @override
19053 Object visitVariableDeclaration(VariableDeclaration node) { 19088 Object visitVariableDeclaration(VariableDeclaration node) {
19054 SimpleIdentifier nameNode = node.name; 19089 SimpleIdentifier nameNode = node.name;
19055 Expression initializerNode = node.initializer; 19090 Expression initializerNode = node.initializer;
19056 // do checks 19091 // do checks
19057 _checkForInvalidAssignment(nameNode, initializerNode); 19092 _checkForInvalidAssignment(nameNode, initializerNode);
19058 // visit name 19093 // visit name
19059 nameNode.accept(this); 19094 nameNode.accept(this);
19060 // visit initializer 19095 // visit initializer
19061 String name = nameNode.name; 19096 String name = nameNode.name;
19062 _namesForReferenceToDeclaredVariableInInitializer.add(name); 19097 _namesForReferenceToDeclaredVariableInInitializer.add(name);
19063 _isInInstanceVariableInitializer = _isInInstanceVariableDeclaration; 19098 _isInInstanceVariableInitializer = _isInInstanceVariableDeclaration;
19064 try { 19099 try {
19065 if (initializerNode != null) { 19100 if (initializerNode != null) {
19066 initializerNode.accept(this); 19101 initializerNode.accept(this);
19067 } 19102 }
19068 } finally { 19103 } finally {
19069 _isInInstanceVariableInitializer = false; 19104 _isInInstanceVariableInitializer = false;
19070 _namesForReferenceToDeclaredVariableInInitializer.remove(name); 19105 _namesForReferenceToDeclaredVariableInInitializer.remove(name);
19071 } 19106 }
19072 // done 19107 // done
19073 return null; 19108 return null;
19074 } 19109 }
19075 19110
19076 @override 19111 @override
19077 Object visitVariableDeclarationList(VariableDeclarationList node) => super.vis itVariableDeclarationList(node); 19112 Object visitVariableDeclarationList(VariableDeclarationList node) {
19113 _checkForTypeAnnotationDeferredClass(node.type);
19114 return super.visitVariableDeclarationList(node);
19115 }
19078 19116
19079 @override 19117 @override
19080 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { 19118 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) {
19081 _checkForFinalNotInitialized(node.variables); 19119 _checkForFinalNotInitialized(node.variables);
19082 return super.visitVariableDeclarationStatement(node); 19120 return super.visitVariableDeclarationStatement(node);
19083 } 19121 }
19084 19122
19085 @override 19123 @override
19086 Object visitWhileStatement(WhileStatement node) { 19124 Object visitWhileStatement(WhileStatement node) {
19087 _checkForNonBoolCondition(node.condition); 19125 _checkForNonBoolCondition(node.condition);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
19585 bool problemReported = false; 19623 bool problemReported = false;
19586 for (TypeName mixinName in withClause.mixinTypes) { 19624 for (TypeName mixinName in withClause.mixinTypes) {
19587 DartType mixinType = mixinName.type; 19625 DartType mixinType = mixinName.type;
19588 if (mixinType is! InterfaceType) { 19626 if (mixinType is! InterfaceType) {
19589 continue; 19627 continue;
19590 } 19628 }
19591 if (_checkForExtendsOrImplementsDisallowedClass(mixinName, CompileTimeErro rCode.MIXIN_OF_DISALLOWED_CLASS)) { 19629 if (_checkForExtendsOrImplementsDisallowedClass(mixinName, CompileTimeErro rCode.MIXIN_OF_DISALLOWED_CLASS)) {
19592 problemReported = true; 19630 problemReported = true;
19593 } else { 19631 } else {
19594 ClassElement mixinElement = (mixinType as InterfaceType).element; 19632 ClassElement mixinElement = (mixinType as InterfaceType).element;
19633 problemReported = javaBooleanOr(problemReported, _checkForExtendsOrImple mentsDeferredClass(mixinName, CompileTimeErrorCode.MIXIN_DEFERRED_CLASS));
19595 problemReported = javaBooleanOr(problemReported, _checkForMixinDeclaresC onstructor(mixinName, mixinElement)); 19634 problemReported = javaBooleanOr(problemReported, _checkForMixinDeclaresC onstructor(mixinName, mixinElement));
19596 problemReported = javaBooleanOr(problemReported, _checkForMixinInheritsN otFromObject(mixinName, mixinElement)); 19635 problemReported = javaBooleanOr(problemReported, _checkForMixinInheritsN otFromObject(mixinName, mixinElement));
19597 problemReported = javaBooleanOr(problemReported, _checkForMixinReference sSuper(mixinName, mixinElement)); 19636 problemReported = javaBooleanOr(problemReported, _checkForMixinReference sSuper(mixinName, mixinElement));
19598 } 19637 }
19599 } 19638 }
19600 return problemReported; 19639 return problemReported;
19601 } 19640 }
19602 19641
19603 /** 19642 /**
19604 * This checks error related to the redirected constructors. 19643 * This checks error related to the redirected constructors.
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
20421 ClassElement classElement = constructorElement.enclosingElement; 20460 ClassElement classElement = constructorElement.enclosingElement;
20422 if (!classElement.hasNonFinalField) { 20461 if (!classElement.hasNonFinalField) {
20423 return false; 20462 return false;
20424 } 20463 }
20425 // report problem 20464 // report problem
20426 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_WIT H_NON_FINAL_FIELD, node, []); 20465 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_WIT H_NON_FINAL_FIELD, node, []);
20427 return true; 20466 return true;
20428 } 20467 }
20429 20468
20430 /** 20469 /**
20470 * This verifies that the passed 'const' instance creation expression is not c reating a deferred
20471 * type.
20472 *
20473 * @param node the instance creation expression to evaluate
20474 * @param constructorName the constructor name from the instance creation expr ession
20475 * @param typeName the type name off of the constructor name
20476 * @return `true` if and only if an error code is generated on the passed node
20477 * @see CompileTimeErrorCode#CONST_DEFERRED_CLASS
20478 */
20479 bool _checkForConstDeferredClass(InstanceCreationExpression node, ConstructorN ame constructorName, TypeName typeName) {
20480 if (typeName.isDeferred) {
20481 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_DEFERRED_CLAS S, constructorName, [typeName.name.name]);
20482 return true;
20483 }
20484 return false;
20485 }
20486
20487 /**
20431 * This verifies that the passed throw expression is not enclosed in a 'const' constructor 20488 * This verifies that the passed throw expression is not enclosed in a 'const' constructor
20432 * declaration. 20489 * declaration.
20433 * 20490 *
20434 * @param node the throw expression expression to evaluate 20491 * @param node the throw expression expression to evaluate
20435 * @return `true` if and only if an error code is generated on the passed node 20492 * @return `true` if and only if an error code is generated on the passed node
20436 * @see CompileTimeErrorCode#CONST_CONSTRUCTOR_THROWS_EXCEPTION 20493 * @see CompileTimeErrorCode#CONST_CONSTRUCTOR_THROWS_EXCEPTION
20437 */ 20494 */
20438 bool _checkForConstEvalThrowsException(ThrowExpression node) { 20495 bool _checkForConstEvalThrowsException(ThrowExpression node) {
20439 if (_isEnclosingConstructorConst) { 20496 if (_isEnclosingConstructorConst) {
20440 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_T HROWS_EXCEPTION, node, []); 20497 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_CONSTRUCTOR_T HROWS_EXCEPTION, node, []);
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
20839 } 20896 }
20840 if (!sdkLibrary.isInternal) { 20897 if (!sdkLibrary.isInternal) {
20841 return false; 20898 return false;
20842 } 20899 }
20843 // report problem 20900 // report problem
20844 _errorReporter.reportErrorForNode(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRA RY, node, [node.uri]); 20901 _errorReporter.reportErrorForNode(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRA RY, node, [node.uri]);
20845 return true; 20902 return true;
20846 } 20903 }
20847 20904
20848 /** 20905 /**
20906 * This verifies that the passed extends clause does not extend a deferred cla ss.
20907 *
20908 * @param node the extends clause to test
20909 * @return `true` if and only if an error code is generated on the passed node
20910 * @see CompileTimeErrorCode#EXTENDS_DEFERRED_CLASS
20911 */
20912 bool _checkForExtendsDeferredClass(ExtendsClause node) {
20913 if (node == null) {
20914 return false;
20915 }
20916 return _checkForExtendsOrImplementsDeferredClass(node.superclass, CompileTim eErrorCode.EXTENDS_DEFERRED_CLASS);
20917 }
20918
20919 /**
20920 * This verifies that the passed type alias does not extend a deferred class.
20921 *
20922 * @param node the extends clause to test
20923 * @return `true` if and only if an error code is generated on the passed node
20924 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS
20925 */
20926 bool _checkForExtendsDeferredClassInTypeAlias(ClassTypeAlias node) {
20927 if (node == null) {
20928 return false;
20929 }
20930 return _checkForExtendsOrImplementsDeferredClass(node.superclass, CompileTim eErrorCode.EXTENDS_DEFERRED_CLASS);
20931 }
20932
20933 /**
20849 * This verifies that the passed extends clause does not extend classes such a s num or String. 20934 * This verifies that the passed extends clause does not extend classes such a s num or String.
20850 * 20935 *
20851 * @param node the extends clause to test 20936 * @param node the extends clause to test
20852 * @return `true` if and only if an error code is generated on the passed node 20937 * @return `true` if and only if an error code is generated on the passed node
20853 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS 20938 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS
20854 */ 20939 */
20855 bool _checkForExtendsDisallowedClass(ExtendsClause node) { 20940 bool _checkForExtendsDisallowedClass(ExtendsClause node) {
20856 if (node == null) { 20941 if (node == null) {
20857 return false; 20942 return false;
20858 } 20943 }
20859 return _checkForExtendsOrImplementsDisallowedClass(node.superclass, CompileT imeErrorCode.EXTENDS_DISALLOWED_CLASS); 20944 return _checkForExtendsOrImplementsDisallowedClass(node.superclass, CompileT imeErrorCode.EXTENDS_DISALLOWED_CLASS);
20860 } 20945 }
20861 20946
20862 /** 20947 /**
20863 * This verifies that the passed type alias does not extend classes such as nu m or String. 20948 * This verifies that the passed type alias does not extend classes such as nu m or String.
20864 * 20949 *
20865 * @param node the extends clause to test 20950 * @param node the extends clause to test
20866 * @return `true` if and only if an error code is generated on the passed node 20951 * @return `true` if and only if an error code is generated on the passed node
20867 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS 20952 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS
20868 */ 20953 */
20869 bool _checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias node) { 20954 bool _checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias node) {
20870 if (node == null) { 20955 if (node == null) {
20871 return false; 20956 return false;
20872 } 20957 }
20873 return _checkForExtendsOrImplementsDisallowedClass(node.superclass, CompileT imeErrorCode.EXTENDS_DISALLOWED_CLASS); 20958 return _checkForExtendsOrImplementsDisallowedClass(node.superclass, CompileT imeErrorCode.EXTENDS_DISALLOWED_CLASS);
20874 } 20959 }
20875 20960
20876 /** 20961 /**
20877 * This verifies that the passed type name does not extend or implement classe s such as 'num' or 20962 * This verifies that the passed type name does not extend, implement or mixin classes that are
20878 * 'String'. 20963 * deferred.
20964 *
20965 * @param node the type name to test
20966 * @return `true` if and only if an error code is generated on the passed node
20967 * @see #checkForExtendsDeferredClass(ExtendsClause)
20968 * @see #checkForExtendsDeferredClassInTypeAlias(ClassTypeAlias)
20969 * @see #checkForImplementsDeferredClass(ImplementsClause)
20970 * @see #checkForAllMixinErrorCodes(WithClause)
20971 * @see CompileTimeErrorCode#EXTENDS_DEFERRED_CLASS
20972 * @see CompileTimeErrorCode#IMPLEMENTS_DEFERRED_CLASS
20973 * @see CompileTimeErrorCode#MIXIN_DEFERRED_CLASS
20974 */
20975 bool _checkForExtendsOrImplementsDeferredClass(TypeName typeName, ErrorCode er rorCode) {
20976 if (typeName.isSynthetic) {
20977 return false;
20978 }
20979 if (typeName.isDeferred) {
20980 _errorReporter.reportErrorForNode(errorCode, typeName, [typeName.name.name ]);
20981 return true;
20982 }
20983 return false;
20984 }
20985
20986 /**
20987 * This verifies that the passed type name does not extend, implement or mixin classes such as
20988 * 'num' or 'String'.
20879 * 20989 *
20880 * @param node the type name to test 20990 * @param node the type name to test
20881 * @return `true` if and only if an error code is generated on the passed node 20991 * @return `true` if and only if an error code is generated on the passed node
20882 * @see #checkForExtendsDisallowedClass(ExtendsClause) 20992 * @see #checkForExtendsDisallowedClass(ExtendsClause)
20993 * @see #checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias)
20883 * @see #checkForImplementsDisallowedClass(ImplementsClause) 20994 * @see #checkForImplementsDisallowedClass(ImplementsClause)
20995 * @see #checkForAllMixinErrorCodes(WithClause)
20884 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS 20996 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS
20885 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS 20997 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS
20998 * @see CompileTimeErrorCode#MIXIN_OF_DISALLOWED_CLASS
20886 */ 20999 */
20887 bool _checkForExtendsOrImplementsDisallowedClass(TypeName typeName, ErrorCode errorCode) { 21000 bool _checkForExtendsOrImplementsDisallowedClass(TypeName typeName, ErrorCode errorCode) {
20888 if (typeName.isSynthetic) { 21001 if (typeName.isSynthetic) {
20889 return false; 21002 return false;
20890 } 21003 }
20891 DartType superType = typeName.type; 21004 DartType superType = typeName.type;
20892 for (InterfaceType disallowedType in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMEN T) { 21005 for (InterfaceType disallowedType in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMEN T) {
20893 if (superType != null && superType == disallowedType) { 21006 if (superType != null && superType == disallowedType) {
20894 // if the violating type happens to be 'num', we need to rule out the ca se where the 21007 // if the violating type happens to be 'num', we need to rule out the ca se where the
20895 // enclosing class is 'int' or 'double' 21008 // enclosing class is 'int' or 'double'
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
21038 for (ClassMember classMember in classMembers) { 21151 for (ClassMember classMember in classMembers) {
21039 if (classMember is FieldDeclaration) { 21152 if (classMember is FieldDeclaration) {
21040 FieldDeclaration field = classMember; 21153 FieldDeclaration field = classMember;
21041 foundError = javaBooleanOr(foundError, _checkForFinalNotInitialized(fiel d.fields)); 21154 foundError = javaBooleanOr(foundError, _checkForFinalNotInitialized(fiel d.fields));
21042 } 21155 }
21043 } 21156 }
21044 return foundError; 21157 return foundError;
21045 } 21158 }
21046 21159
21047 /** 21160 /**
21161 * This verifies that the passed implements clause does not implement classes that are deferred.
21162 *
21163 * @param node the implements clause to test
21164 * @return `true` if and only if an error code is generated on the passed node
21165 * @see CompileTimeErrorCode#IMPLEMENTS_DEFERRED_CLASS
21166 */
21167 bool _checkForImplementsDeferredClass(ImplementsClause node) {
21168 if (node == null) {
21169 return false;
21170 }
21171 bool foundError = false;
21172 for (TypeName type in node.interfaces) {
21173 foundError = javaBooleanOr(foundError, _checkForExtendsOrImplementsDeferre dClass(type, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS));
21174 }
21175 return foundError;
21176 }
21177
21178 /**
21048 * This verifies that the passed implements clause does not implement classes such as 'num' or 21179 * This verifies that the passed implements clause does not implement classes such as 'num' or
21049 * 'String'. 21180 * 'String'.
21050 * 21181 *
21051 * @param node the implements clause to test 21182 * @param node the implements clause to test
21052 * @return `true` if and only if an error code is generated on the passed node 21183 * @return `true` if and only if an error code is generated on the passed node
21053 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS 21184 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS
21054 */ 21185 */
21055 bool _checkForImplementsDisallowedClass(ImplementsClause node) { 21186 bool _checkForImplementsDisallowedClass(ImplementsClause node) {
21056 if (node == null) { 21187 if (node == null) {
21057 return false; 21188 return false;
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
22463 bool _checkForTypeAliasCannotReferenceItself_mixin(ClassTypeAlias node) { 22594 bool _checkForTypeAliasCannotReferenceItself_mixin(ClassTypeAlias node) {
22464 ClassElement element = node.element; 22595 ClassElement element = node.element;
22465 if (!_hasTypedefSelfReference(element)) { 22596 if (!_hasTypedefSelfReference(element)) {
22466 return false; 22597 return false;
22467 } 22598 }
22468 _errorReporter.reportErrorForNode(CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REF ERENCE_ITSELF, node, []); 22599 _errorReporter.reportErrorForNode(CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REF ERENCE_ITSELF, node, []);
22469 return true; 22600 return true;
22470 } 22601 }
22471 22602
22472 /** 22603 /**
22604 * This verifies that the passed type name is not a deferred type.
22605 *
22606 * @param expression the expression to evaluate
22607 * @return `true` if and only if an error code is generated on the passed node
22608 * @see StaticWarningCode#TYPE_ANNOTATION_DEFERRED_CLASS
22609 */
22610 bool _checkForTypeAnnotationDeferredClass(TypeName node) {
22611 if (node != null && node.isDeferred) {
22612 _errorReporter.reportErrorForNode(StaticWarningCode.TYPE_ANNOTATION_DEFERR ED_CLASS, node, [node.name]);
22613 }
22614 return false;
22615 }
22616
22617 /**
22473 * This verifies that the type arguments in the passed type name are all withi n their bounds. 22618 * This verifies that the type arguments in the passed type name are all withi n their bounds.
22474 * 22619 *
22475 * @param node the [TypeName] to evaluate 22620 * @param node the [TypeName] to evaluate
22476 * @return `true` if and only if an error code is generated on the passed node 22621 * @return `true` if and only if an error code is generated on the passed node
22477 * @see StaticTypeWarningCode#TYPE_ARGUMENT_NOT_MATCHING_BOUNDS 22622 * @see StaticTypeWarningCode#TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
22478 */ 22623 */
22479 bool _checkForTypeArgumentNotMatchingBounds(TypeName node) { 22624 bool _checkForTypeArgumentNotMatchingBounds(TypeName node) {
22480 if (node.typeArguments == null) { 22625 if (node.typeArguments == null) {
22481 return false; 22626 return false;
22482 } 22627 }
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
23285 * 23430 *
23286 * @param type the type of this error 23431 * @param type the type of this error
23287 * @param message the template used to create the message to be displayed for the error 23432 * @param message the template used to create the message to be displayed for the error
23288 * @param correction the template used to create the correction to be displaye d for the error 23433 * @param correction the template used to create the correction to be displaye d for the error
23289 */ 23434 */
23290 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message , this.correction) : super(name, ordinal); 23435 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message , this.correction) : super(name, ordinal);
23291 23436
23292 @override 23437 @override
23293 ErrorSeverity get errorSeverity => type.severity; 23438 ErrorSeverity get errorSeverity => type.severity;
23294 } 23439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698