Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 10913081: Fix resolution of type parameters in static context, and the use of type parameters in closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/closure.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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('elements'); 5 #library('elements');
6 6
7 #import('dart:uri'); 7 #import('dart:uri');
8 8
9 #import('../tree/tree.dart'); 9 #import('../tree/tree.dart');
10 #import('../scanner/scannerlib.dart'); 10 #import('../scanner/scannerlib.dart');
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 641 }
642 listener.cancel('internal error: could not find $name', node: variables); 642 listener.cancel('internal error: could not find $name', node: variables);
643 } 643 }
644 644
645 DartType computeType(Compiler compiler) { 645 DartType computeType(Compiler compiler) {
646 return variables.computeType(compiler); 646 return variables.computeType(compiler);
647 } 647 }
648 648
649 DartType get type => variables.type; 649 DartType get type => variables.type;
650 650
651 bool isInstanceMember() { 651 bool isInstanceMember() => variables.isInstanceMember();
652 return isMember() && !modifiers.isStatic();
653 }
654 652
655 // Note: cachedNode.getBeginToken() will not be correct in all 653 // Note: cachedNode.getBeginToken() will not be correct in all
656 // cases, for example, for function typed parameters. 654 // cases, for example, for function typed parameters.
657 Token position() => findMyName(variables.position()); 655 Token position() => findMyName(variables.position());
658 656
659 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { 657 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) {
660 VariableListElement clonedVariables = 658 VariableListElement clonedVariables =
661 variables.cloneTo(enclosing, listener); 659 variables.cloneTo(enclosing, listener);
662 VariableElement result = new VariableElement( 660 VariableElement result = new VariableElement(
663 name, clonedVariables, kind, enclosing, cachedNode); 661 name, clonedVariables, kind, enclosing, cachedNode);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 750
753 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { 751 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) {
754 VariableListElement result; 752 VariableListElement result;
755 if (cachedNode !== null) { 753 if (cachedNode !== null) {
756 result = new VariableListElement.node(cachedNode, kind, enclosing); 754 result = new VariableListElement.node(cachedNode, kind, enclosing);
757 } else { 755 } else {
758 result = new VariableListElement(kind, modifiers, enclosing); 756 result = new VariableListElement(kind, modifiers, enclosing);
759 } 757 }
760 return result; 758 return result;
761 } 759 }
760
761 bool isInstanceMember() {
762 return isMember() && !modifiers.isStatic();
763 }
764
765 Scope buildScope() {
766 Scope result = new VariableScope(enclosingElement.buildScope(), this);
767 if (enclosingElement.isClass()) {
768 ClassScope clsScope = result.parent;
769 clsScope.inStaticContext = !isInstanceMember();
770 }
771 return result;
772 }
762 } 773 }
763 774
764 class ForeignElement extends Element { 775 class ForeignElement extends Element {
765 ForeignElement(SourceString name, ContainerElement enclosingElement) 776 ForeignElement(SourceString name, ContainerElement enclosingElement)
766 : super(name, ElementKind.FOREIGN, enclosingElement); 777 : super(name, ElementKind.FOREIGN, enclosingElement);
767 778
768 DartType computeType(Compiler compiler) { 779 DartType computeType(Compiler compiler) {
769 return compiler.types.dynamicType; 780 return compiler.types.dynamicType;
770 } 781 }
771 782
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 989
979 FunctionElement asFunctionElement() => this; 990 FunctionElement asFunctionElement() => this;
980 991
981 FunctionElement cloneTo(Element enclosing, DiagnosticListener listener) { 992 FunctionElement cloneTo(Element enclosing, DiagnosticListener listener) {
982 FunctionElement result = new FunctionElement.tooMuchOverloading( 993 FunctionElement result = new FunctionElement.tooMuchOverloading(
983 name, cachedNode, kind, modifiers, enclosing, functionSignature); 994 name, cachedNode, kind, modifiers, enclosing, functionSignature);
984 result.defaultImplementation = defaultImplementation; 995 result.defaultImplementation = defaultImplementation;
985 result.type = type; 996 result.type = type;
986 return result; 997 return result;
987 } 998 }
999
1000 Scope buildScope() {
1001 Scope result = new MethodScope(enclosingElement.buildScope(), this);
1002 if (enclosingElement.isClass()) {
1003 ClassScope clsScope = result.parent;
1004 clsScope.inStaticContext = !isInstanceMember() && !isConstructor();
1005 }
1006 return result;
1007 }
988 } 1008 }
989 1009
990 1010
991 class ConstructorBodyElement extends FunctionElement { 1011 class ConstructorBodyElement extends FunctionElement {
992 FunctionElement constructor; 1012 FunctionElement constructor;
993 1013
994 ConstructorBodyElement(FunctionElement constructor) 1014 ConstructorBodyElement(FunctionElement constructor)
995 : this.constructor = constructor, 1015 : this.constructor = constructor,
996 super(constructor.name, 1016 super(constructor.name,
997 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 1017 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1672
1653 MetadataAnnotation ensureResolved(Compiler compiler) { 1673 MetadataAnnotation ensureResolved(Compiler compiler) {
1654 if (resolutionState == STATE_NOT_STARTED) { 1674 if (resolutionState == STATE_NOT_STARTED) {
1655 compiler.resolver.resolveMetadataAnnotation(this); 1675 compiler.resolver.resolveMetadataAnnotation(this);
1656 } 1676 }
1657 return this; 1677 return this;
1658 } 1678 }
1659 1679
1660 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1680 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1661 } 1681 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/closure.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698