| OLD | NEW |
| 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 library engine.resolver.error_verifier; | 5 library engine.resolver.error_verifier; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/static_type_analyzer.dart'; | 10 import 'package:analyzer/src/generated/static_type_analyzer.dart'; |
| (...skipping 5220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 /** | 5231 /** |
| 5232 * Check whether the given type [name] is a type parameter being used to | 5232 * Check whether the given type [name] is a type parameter being used to |
| 5233 * define a static member. | 5233 * define a static member. |
| 5234 * | 5234 * |
| 5235 * See [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]. | 5235 * See [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]. |
| 5236 */ | 5236 */ |
| 5237 bool _checkForTypeParameterReferencedByStatic(TypeName name) { | 5237 bool _checkForTypeParameterReferencedByStatic(TypeName name) { |
| 5238 if (_isInStaticMethod || _isInStaticVariableDeclaration) { | 5238 if (_isInStaticMethod || _isInStaticVariableDeclaration) { |
| 5239 DartType type = name.type; | 5239 DartType type = name.type; |
| 5240 if (type is TypeParameterType) { | 5240 if (type is TypeParameterType) { |
| 5241 _errorReporter.reportErrorForNode( | 5241 // The class's type parameters are not in scope for static methods. |
| 5242 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, name); | 5242 // However all other type parameters are legal (e.g. the static method's |
| 5243 return true; | 5243 // type parameters, or a local function's type parameters). |
| 5244 if (type.element.enclosingElement is ClassElement) { |
| 5245 _errorReporter.reportErrorForNode( |
| 5246 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, name); |
| 5247 return true; |
| 5248 } |
| 5244 } | 5249 } |
| 5245 } | 5250 } |
| 5246 return false; | 5251 return false; |
| 5247 } | 5252 } |
| 5248 | 5253 |
| 5249 /** | 5254 /** |
| 5250 * Check whether the given type [parameter] is a supertype of its bound. | 5255 * Check whether the given type [parameter] is a supertype of its bound. |
| 5251 * | 5256 * |
| 5252 * See [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND]. | 5257 * See [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND]. |
| 5253 */ | 5258 */ |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6105 toCheck.add(type.element); | 6110 toCheck.add(type.element); |
| 6106 // type arguments | 6111 // type arguments |
| 6107 if (type is InterfaceType) { | 6112 if (type is InterfaceType) { |
| 6108 InterfaceType interfaceType = type; | 6113 InterfaceType interfaceType = type; |
| 6109 for (DartType typeArgument in interfaceType.typeArguments) { | 6114 for (DartType typeArgument in interfaceType.typeArguments) { |
| 6110 _addTypeToCheck(typeArgument); | 6115 _addTypeToCheck(typeArgument); |
| 6111 } | 6116 } |
| 6112 } | 6117 } |
| 6113 } | 6118 } |
| 6114 } | 6119 } |
| OLD | NEW |