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 part of resolution; | 5 part of resolution; |
6 | 6 |
7 abstract class TreeElements { | 7 abstract class TreeElements { |
8 Element operator[](Node node); | 8 Element operator[](Node node); |
9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
10 Selector getGetterSelectorInComplexSendSet(SendSet node); | 10 Selector getGetterSelectorInComplexSendSet(SendSet node); |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 // When the element is a field, we are actually resolving its | 1630 // When the element is a field, we are actually resolving its |
1631 // initial value, which should not have access to instance | 1631 // initial value, which should not have access to instance |
1632 // fields. | 1632 // fields. |
1633 inInstanceContext = (element.isInstanceMember() && !element.isField()) | 1633 inInstanceContext = (element.isInstanceMember() && !element.isField()) |
1634 || element.isGenerativeConstructor(), | 1634 || element.isGenerativeConstructor(), |
1635 this.currentClass = element.isMember() ? element.getEnclosingClass() | 1635 this.currentClass = element.isMember() ? element.getEnclosingClass() |
1636 : null, | 1636 : null, |
1637 this.statementScope = new StatementScope(), | 1637 this.statementScope = new StatementScope(), |
1638 typeResolver = new TypeResolver(compiler), | 1638 typeResolver = new TypeResolver(compiler), |
1639 scope = element.buildScope(), | 1639 scope = element.buildScope(), |
1640 inCheckContext = compiler.enableTypeAssertions, | 1640 inCheckContext = compiler.enableTypeAssertions, |
ngeoffray
2013/02/28 20:08:42
If you did inCheckContext = compiler.enableTypeAss
karlklose
2013/03/01 08:23:38
That works, too, using the enclosingElement.
I th
| |
1641 inCatchBlock = false, | 1641 inCatchBlock = false, |
1642 super(compiler); | 1642 super(compiler); |
1643 | 1643 |
1644 ResolutionEnqueuer get world => compiler.enqueuer.resolution; | 1644 ResolutionEnqueuer get world => compiler.enqueuer.resolution; |
1645 | 1645 |
1646 Element lookup(Node node, SourceString name) { | 1646 Element lookup(Node node, SourceString name) { |
1647 Element result = scope.lookup(name); | 1647 Element result = scope.lookup(name); |
1648 if (!Elements.isUnresolved(result)) { | 1648 if (!Elements.isUnresolved(result)) { |
1649 if (!inInstanceContext && result.isInstanceMember()) { | 1649 if (!inInstanceContext && result.isInstanceMember()) { |
1650 compiler.reportErrorCode( | 1650 compiler.reportErrorCode( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1740 classElement.ensureResolved(compiler); | 1740 classElement.ensureResolved(compiler); |
1741 } | 1741 } |
1742 return useElement(node, element); | 1742 return useElement(node, element); |
1743 } | 1743 } |
1744 } | 1744 } |
1745 | 1745 |
1746 Element visitTypeAnnotation(TypeAnnotation node) { | 1746 Element visitTypeAnnotation(TypeAnnotation node) { |
1747 DartType type = resolveTypeAnnotation(node); | 1747 DartType type = resolveTypeAnnotation(node); |
1748 if (type != null) { | 1748 if (type != null) { |
1749 if (inCheckContext) { | 1749 if (inCheckContext) { |
1750 compiler.enqueuer.resolution.registerIsCheck(type); | 1750 if (!Types.isTypeVariableOfTypedef(type)) { |
1751 compiler.enqueuer.resolution.registerIsCheck(type); | |
1752 » } | |
1751 } | 1753 } |
1752 return type.element; | 1754 return type.element; |
1753 } | 1755 } |
1754 return null; | 1756 return null; |
1755 } | 1757 } |
1756 | 1758 |
1757 Element defineElement(Node node, Element element, | 1759 Element defineElement(Node node, Element element, |
1758 {bool doAddToScope: true}) { | 1760 {bool doAddToScope: true}) { |
1759 compiler.ensure(element != null); | 1761 compiler.ensure(element != null); |
1760 mapping[node] = element; | 1762 mapping[node] = element; |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2561 } | 2563 } |
2562 } | 2564 } |
2563 | 2565 |
2564 DartType resolveTypeAnnotation(TypeAnnotation node) { | 2566 DartType resolveTypeAnnotation(TypeAnnotation node) { |
2565 Function report = typeRequired ? error : warning; | 2567 Function report = typeRequired ? error : warning; |
2566 DartType type = typeResolver.resolveTypeAnnotation( | 2568 DartType type = typeResolver.resolveTypeAnnotation( |
2567 node, scope, enclosingElement, | 2569 node, scope, enclosingElement, |
2568 onFailure: report, whenResolved: useType); | 2570 onFailure: report, whenResolved: useType); |
2569 if (type == null) return null; | 2571 if (type == null) return null; |
2570 if (inCheckContext) { | 2572 if (inCheckContext) { |
2571 compiler.enqueuer.resolution.registerIsCheck(type); | 2573 if (!Types.isTypeVariableOfTypedef(type)) { |
2574 compiler.enqueuer.resolution.registerIsCheck(type); | |
2575 } | |
2572 } | 2576 } |
2573 if (typeRequired || inCheckContext) { | 2577 if (typeRequired || inCheckContext) { |
2574 if (type is InterfaceType) { | 2578 if (type is InterfaceType) { |
2575 InterfaceType itf = type; | 2579 InterfaceType itf = type; |
2576 itf.typeArguments.forEach((DartType argument) { | 2580 itf.typeArguments.forEach((DartType argument) { |
2577 analyzeTypeArgument(type, argument); | 2581 analyzeTypeArgument(type, argument); |
2578 }); | 2582 }); |
2579 } | 2583 } |
2580 // TODO(ngeoffray): Also handle T a (in checked mode). | 2584 // TODO(ngeoffray): Also handle T a (in checked mode). |
2581 } | 2585 } |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3801 return e; | 3805 return e; |
3802 } | 3806 } |
3803 | 3807 |
3804 /// Assumed to be called by [resolveRedirectingFactory]. | 3808 /// Assumed to be called by [resolveRedirectingFactory]. |
3805 Element visitReturn(Return node) { | 3809 Element visitReturn(Return node) { |
3806 Node expression = node.expression; | 3810 Node expression = node.expression; |
3807 return finishConstructorReference(visit(expression), | 3811 return finishConstructorReference(visit(expression), |
3808 expression, expression); | 3812 expression, expression); |
3809 } | 3813 } |
3810 } | 3814 } |
OLD | NEW |