| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.resolution.members; | 5 library dart2js.resolution.members; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Selectors; | 8 import '../common/names.dart' show Selectors; |
| 9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
| 10 import '../compile_time_constants.dart'; | 10 import '../compile_time_constants.dart'; |
| (...skipping 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 .subst(type.typeArguments, targetClass.typeVariables); | 3658 .subst(type.typeArguments, targetClass.typeVariables); |
| 3659 FunctionType constructorType = constructor.computeType(resolution); | 3659 FunctionType constructorType = constructor.computeType(resolution); |
| 3660 bool isSubtype = | 3660 bool isSubtype = |
| 3661 resolution.types.isSubtype(targetConstructorType, constructorType); | 3661 resolution.types.isSubtype(targetConstructorType, constructorType); |
| 3662 if (!isSubtype) { | 3662 if (!isSubtype) { |
| 3663 reporter.reportWarningMessage(node, MessageKind.NOT_ASSIGNABLE, | 3663 reporter.reportWarningMessage(node, MessageKind.NOT_ASSIGNABLE, |
| 3664 {'fromType': targetConstructorType, 'toType': constructorType}); | 3664 {'fromType': targetConstructorType, 'toType': constructorType}); |
| 3665 // TODO(johnniwinther): Handle this (potentially) erroneous case. | 3665 // TODO(johnniwinther): Handle this (potentially) erroneous case. |
| 3666 isValidAsConstant = false; | 3666 isValidAsConstant = false; |
| 3667 } | 3667 } |
| 3668 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { |
| 3669 registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); |
| 3670 } |
| 3668 | 3671 |
| 3669 redirectionTarget.computeType(resolution); | 3672 redirectionTarget.computeType(resolution); |
| 3670 FunctionSignature targetSignature = redirectionTarget.functionSignature; | 3673 FunctionSignature targetSignature = redirectionTarget.functionSignature; |
| 3671 constructor.computeType(resolution); | 3674 constructor.computeType(resolution); |
| 3672 FunctionSignature constructorSignature = constructor.functionSignature; | 3675 FunctionSignature constructorSignature = constructor.functionSignature; |
| 3673 if (!targetSignature.isCompatibleWith(constructorSignature)) { | 3676 if (!targetSignature.isCompatibleWith(constructorSignature)) { |
| 3674 assert(!isSubtype); | 3677 assert(!isSubtype); |
| 3675 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 3678 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
| 3676 isValidAsConstant = false; | 3679 isValidAsConstant = false; |
| 3677 } | 3680 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 } | 3883 } |
| 3881 | 3884 |
| 3882 if (!isInvalid) { | 3885 if (!isInvalid) { |
| 3883 // [constructor] might be the implementation element | 3886 // [constructor] might be the implementation element |
| 3884 // and only declaration elements may be registered. | 3887 // and only declaration elements may be registered. |
| 3885 registry.registerStaticUse(new StaticUse.constructorInvoke( | 3888 registry.registerStaticUse(new StaticUse.constructorInvoke( |
| 3886 constructor.declaration, callStructure)); | 3889 constructor.declaration, callStructure)); |
| 3887 // TODO(johniwinther): Avoid registration of `type` in face of redirecting | 3890 // TODO(johniwinther): Avoid registration of `type` in face of redirecting |
| 3888 // factory constructors. | 3891 // factory constructors. |
| 3889 registry.registerTypeUse(new TypeUse.instantiation(type)); | 3892 registry.registerTypeUse(new TypeUse.instantiation(type)); |
| 3893 InterfaceType interfaceType = type; |
| 3894 if (interfaceType.typeArguments.any((DartType type) => !type.isDynamic)) { |
| 3895 registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); |
| 3896 } |
| 3890 } | 3897 } |
| 3891 | 3898 |
| 3892 ResolutionResult resolutionResult = const NoneResult(); | 3899 ResolutionResult resolutionResult = const NoneResult(); |
| 3893 if (node.isConst) { | 3900 if (node.isConst) { |
| 3894 bool isValidAsConstant = !isInvalid && constructor.isConst; | 3901 bool isValidAsConstant = !isInvalid && constructor.isConst; |
| 3895 | 3902 |
| 3896 CommonElements commonElements = resolution.commonElements; | 3903 CommonElements commonElements = resolution.commonElements; |
| 3897 if (commonElements.isSymbolConstructor(constructor)) { | 3904 if (commonElements.isSymbolConstructor(constructor)) { |
| 3898 Node argumentNode = node.send.arguments.head; | 3905 Node argumentNode = node.send.arguments.head; |
| 3899 ConstantExpression constant = resolver.constantCompiler | 3906 ConstantExpression constant = resolver.constantCompiler |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4724 } | 4731 } |
| 4725 return const NoneResult(); | 4732 return const NoneResult(); |
| 4726 } | 4733 } |
| 4727 } | 4734 } |
| 4728 | 4735 |
| 4729 /// Looks up [name] in [scope] and unwraps the result. | 4736 /// Looks up [name] in [scope] and unwraps the result. |
| 4730 Element lookupInScope( | 4737 Element lookupInScope( |
| 4731 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4738 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
| 4732 return Elements.unwrap(scope.lookup(name), reporter, node); | 4739 return Elements.unwrap(scope.lookup(name), reporter, node); |
| 4733 } | 4740 } |
| OLD | NEW |