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 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 * [_checkForAllMixinErrorCodes], | 3192 * [_checkForAllMixinErrorCodes], |
3193 * [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS], | 3193 * [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS], |
3194 * [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS], and | 3194 * [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS], and |
3195 * [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]. | 3195 * [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]. |
3196 */ | 3196 */ |
3197 bool _checkForExtendsOrImplementsDisallowedClass( | 3197 bool _checkForExtendsOrImplementsDisallowedClass( |
3198 TypeName typeName, ErrorCode errorCode) { | 3198 TypeName typeName, ErrorCode errorCode) { |
3199 if (typeName.isSynthetic) { | 3199 if (typeName.isSynthetic) { |
3200 return false; | 3200 return false; |
3201 } | 3201 } |
| 3202 // The SDK implementation may implement disallowed types. For example, |
| 3203 // JSNumber in dart2js and _Smi in Dart VM both implement int. |
| 3204 if (_currentLibrary.source.isInSystemLibrary) { |
| 3205 return false; |
| 3206 } |
3202 DartType superType = typeName.type; | 3207 DartType superType = typeName.type; |
3203 for (InterfaceType disallowedType | 3208 for (InterfaceType disallowedType |
3204 in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT) { | 3209 in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT) { |
3205 if (superType != null && superType == disallowedType) { | 3210 if (superType != null && superType == disallowedType) { |
3206 // if the violating type happens to be 'num', we need to rule out the | 3211 // if the violating type happens to be 'num', we need to rule out the |
3207 // case where the enclosing class is 'int' or 'double' | 3212 // case where the enclosing class is 'int' or 'double' |
3208 if (superType == _typeProvider.numType) { | 3213 if (superType == _typeProvider.numType) { |
3209 AstNode grandParent = typeName.parent.parent; | 3214 AstNode grandParent = typeName.parent.parent; |
3210 // Note: this is a corner case that won't happen often, so adding a | 3215 // Note: this is a corner case that won't happen often, so adding a |
3211 // field currentClass (see currentFunction) to ErrorVerifier isn't | 3216 // field currentClass (see currentFunction) to ErrorVerifier isn't |
(...skipping 2859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 toCheck.add(type.element); | 6076 toCheck.add(type.element); |
6072 // type arguments | 6077 // type arguments |
6073 if (type is InterfaceType) { | 6078 if (type is InterfaceType) { |
6074 InterfaceType interfaceType = type; | 6079 InterfaceType interfaceType = type; |
6075 for (DartType typeArgument in interfaceType.typeArguments) { | 6080 for (DartType typeArgument in interfaceType.typeArguments) { |
6076 _addTypeToCheck(typeArgument); | 6081 _addTypeToCheck(typeArgument); |
6077 } | 6082 } |
6078 } | 6083 } |
6079 } | 6084 } |
6080 } | 6085 } |
OLD | NEW |