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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 if (semantics == null) { | 1562 if (semantics == null) { |
1563 semantics = computeSuperAccessSemanticsForSelector(node, selector, | 1563 semantics = computeSuperAccessSemanticsForSelector(node, selector, |
1564 alternateName: name.setter); | 1564 alternateName: name.setter); |
1565 } | 1565 } |
1566 if (node.isCall) { | 1566 if (node.isCall) { |
1567 bool isIncompatibleInvoke = false; | 1567 bool isIncompatibleInvoke = false; |
1568 switch (semantics.kind) { | 1568 switch (semantics.kind) { |
1569 case AccessKind.SUPER_METHOD: | 1569 case AccessKind.SUPER_METHOD: |
1570 MethodElement superMethod = semantics.element; | 1570 MethodElement superMethod = semantics.element; |
1571 superMethod.computeType(resolution); | 1571 superMethod.computeType(resolution); |
1572 if (!callStructure.signatureApplies(superMethod.type)) { | 1572 if (!callStructure.signatureApplies(superMethod.parameterStructure)) { |
1573 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 1573 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
1574 registry.registerDynamicUse(new DynamicUse(selector, null)); | 1574 registry.registerDynamicUse(new DynamicUse(selector, null)); |
1575 registry.registerFeature(Feature.SUPER_NO_SUCH_METHOD); | 1575 registry.registerFeature(Feature.SUPER_NO_SUCH_METHOD); |
1576 isIncompatibleInvoke = true; | 1576 isIncompatibleInvoke = true; |
1577 } else { | 1577 } else { |
1578 registry.registerStaticUse( | 1578 registry.registerStaticUse( |
1579 new StaticUse.superInvoke(superMethod, callStructure)); | 1579 new StaticUse.superInvoke(superMethod, callStructure)); |
1580 } | 1580 } |
1581 break; | 1581 break; |
1582 case AccessKind.SUPER_FIELD: | 1582 case AccessKind.SUPER_FIELD: |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 Selector selector; | 2496 Selector selector; |
2497 if (node.isCall) { | 2497 if (node.isCall) { |
2498 CallStructure callStructure = | 2498 CallStructure callStructure = |
2499 resolveArguments(node.argumentsNode).callStructure; | 2499 resolveArguments(node.argumentsNode).callStructure; |
2500 selector = new Selector.call(name, callStructure); | 2500 selector = new Selector.call(name, callStructure); |
2501 bool isIncompatibleInvoke = false; | 2501 bool isIncompatibleInvoke = false; |
2502 switch (semantics.kind) { | 2502 switch (semantics.kind) { |
2503 case AccessKind.LOCAL_FUNCTION: | 2503 case AccessKind.LOCAL_FUNCTION: |
2504 LocalFunctionElementX function = semantics.element; | 2504 LocalFunctionElementX function = semantics.element; |
2505 function.computeType(resolution); | 2505 function.computeType(resolution); |
2506 if (!callStructure.signatureApplies(function.type)) { | 2506 if (!callStructure.signatureApplies(function.parameterStructure)) { |
2507 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 2507 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
2508 registry.registerDynamicUse(new DynamicUse(selector, null)); | 2508 registry.registerDynamicUse(new DynamicUse(selector, null)); |
2509 isIncompatibleInvoke = true; | 2509 isIncompatibleInvoke = true; |
2510 } | 2510 } |
2511 break; | 2511 break; |
2512 case AccessKind.PARAMETER: | 2512 case AccessKind.PARAMETER: |
2513 case AccessKind.FINAL_PARAMETER: | 2513 case AccessKind.FINAL_PARAMETER: |
2514 case AccessKind.LOCAL_VARIABLE: | 2514 case AccessKind.LOCAL_VARIABLE: |
2515 case AccessKind.FINAL_LOCAL_VARIABLE: | 2515 case AccessKind.FINAL_LOCAL_VARIABLE: |
2516 selector = callStructure.callSelector; | 2516 selector = callStructure.callSelector; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2665 ArgumentsResult argumentsResult = resolveArguments(node.argumentsNode); | 2665 ArgumentsResult argumentsResult = resolveArguments(node.argumentsNode); |
2666 CallStructure callStructure = argumentsResult.callStructure; | 2666 CallStructure callStructure = argumentsResult.callStructure; |
2667 selector = new Selector.call(name, callStructure); | 2667 selector = new Selector.call(name, callStructure); |
2668 | 2668 |
2669 bool isIncompatibleInvoke = false; | 2669 bool isIncompatibleInvoke = false; |
2670 switch (semantics.kind) { | 2670 switch (semantics.kind) { |
2671 case AccessKind.STATIC_METHOD: | 2671 case AccessKind.STATIC_METHOD: |
2672 case AccessKind.TOPLEVEL_METHOD: | 2672 case AccessKind.TOPLEVEL_METHOD: |
2673 MethodElement method = semantics.element; | 2673 MethodElement method = semantics.element; |
2674 method.computeType(resolution); | 2674 method.computeType(resolution); |
2675 if (!callStructure.signatureApplies(method.type)) { | 2675 if (!callStructure.signatureApplies(method.parameterStructure)) { |
2676 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 2676 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
2677 registry.registerDynamicUse(new DynamicUse(selector, null)); | 2677 registry.registerDynamicUse(new DynamicUse(selector, null)); |
2678 isIncompatibleInvoke = true; | 2678 isIncompatibleInvoke = true; |
2679 } else { | 2679 } else { |
2680 registry.registerStaticUse( | 2680 registry.registerStaticUse( |
2681 new StaticUse.staticInvoke(method, callStructure)); | 2681 new StaticUse.staticInvoke(method, callStructure)); |
2682 handleForeignCall(node, semantics.element, callStructure); | 2682 handleForeignCall(node, semantics.element, callStructure); |
2683 if (method == resolution.commonElements.identicalFunction && | 2683 if (method == resolution.commonElements.identicalFunction && |
2684 argumentsResult.isValidAsConstant) { | 2684 argumentsResult.isValidAsConstant) { |
2685 result = new ConstantResult( | 2685 result = new ConstantResult( |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 CallStructure callStructure = selector.callStructure; | 3852 CallStructure callStructure = selector.callStructure; |
3853 registry.useElement(node.send, constructor); | 3853 registry.useElement(node.send, constructor); |
3854 | 3854 |
3855 ResolutionDartType type = result.type; | 3855 ResolutionDartType type = result.type; |
3856 ConstructorAccessKind kind; | 3856 ConstructorAccessKind kind; |
3857 bool isInvalid = false; | 3857 bool isInvalid = false; |
3858 switch (result.kind) { | 3858 switch (result.kind) { |
3859 case ConstructorResultKind.GENERATIVE: | 3859 case ConstructorResultKind.GENERATIVE: |
3860 // Ensure that the signature of [constructor] has been computed. | 3860 // Ensure that the signature of [constructor] has been computed. |
3861 constructor.computeType(resolution); | 3861 constructor.computeType(resolution); |
3862 if (!callStructure.signatureApplies(constructor.type)) { | 3862 if (!callStructure.signatureApplies(constructor.parameterStructure)) { |
3863 isInvalid = true; | 3863 isInvalid = true; |
3864 kind = ConstructorAccessKind.INCOMPATIBLE; | 3864 kind = ConstructorAccessKind.INCOMPATIBLE; |
3865 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 3865 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
3866 } else { | 3866 } else { |
3867 kind = ConstructorAccessKind.GENERATIVE; | 3867 kind = ConstructorAccessKind.GENERATIVE; |
3868 } | 3868 } |
3869 break; | 3869 break; |
3870 case ConstructorResultKind.FACTORY: | 3870 case ConstructorResultKind.FACTORY: |
3871 // Ensure that the signature of [constructor] has been computed. | 3871 // Ensure that the signature of [constructor] has been computed. |
3872 constructor.computeType(resolution); | 3872 constructor.computeType(resolution); |
3873 if (!callStructure.signatureApplies(constructor.type)) { | 3873 if (!callStructure.signatureApplies(constructor.parameterStructure)) { |
3874 // The effective target might still be valid(!) so the is not an | 3874 // The effective target might still be valid(!) so the is not an |
3875 // invalid case in itself. For instance | 3875 // invalid case in itself. For instance |
3876 // | 3876 // |
3877 // class A { | 3877 // class A { |
3878 // factory A() = A.a; | 3878 // factory A() = A.a; |
3879 // A.a(a); | 3879 // A.a(a); |
3880 // } | 3880 // } |
3881 // m() => new A(0); // This creates a warning but works at runtime. | 3881 // m() => new A(0); // This creates a warning but works at runtime. |
3882 // | 3882 // |
3883 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 3883 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4797 } | 4797 } |
4798 return const NoneResult(); | 4798 return const NoneResult(); |
4799 } | 4799 } |
4800 } | 4800 } |
4801 | 4801 |
4802 /// Looks up [name] in [scope] and unwraps the result. | 4802 /// Looks up [name] in [scope] and unwraps the result. |
4803 Element lookupInScope( | 4803 Element lookupInScope( |
4804 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4804 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
4805 return Elements.unwrap(scope.lookup(name), reporter, node); | 4805 return Elements.unwrap(scope.lookup(name), reporter, node); |
4806 } | 4806 } |
OLD | NEW |