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

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

Issue 10854216: Fix for class members cannot have the same name as the class in dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « no previous file | lib/compiler/implementation/warnings.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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 TreeElements resolveMethodElement(FunctionElement element) { 112 TreeElements resolveMethodElement(FunctionElement element) {
113 return compiler.withCurrentElement(element, () { 113 return compiler.withCurrentElement(element, () {
114 bool isConstructor = element.kind === ElementKind.GENERATIVE_CONSTRUCTOR; 114 bool isConstructor = element.kind === ElementKind.GENERATIVE_CONSTRUCTOR;
115 if (constructorElements.containsKey(element)) { 115 if (constructorElements.containsKey(element)) {
116 assert(isConstructor); 116 assert(isConstructor);
117 TreeElements elements = constructorElements[element]; 117 TreeElements elements = constructorElements[element];
118 if (elements !== null) return elements; 118 if (elements !== null) return elements;
119 } 119 }
120 FunctionExpression tree = element.parseNode(compiler); 120 FunctionExpression tree = element.parseNode(compiler);
121 if (isConstructor) { 121 if (isConstructor) {
122 if (tree.returnType !== null) {
123 error(tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE);
124 }
122 resolveConstructorImplementation(element, tree); 125 resolveConstructorImplementation(element, tree);
123 } 126 }
124 ResolverVisitor visitor = new ResolverVisitor(compiler, element); 127 ResolverVisitor visitor = new ResolverVisitor(compiler, element);
125 visitor.useElement(tree, element); 128 visitor.useElement(tree, element);
126 visitor.setupFunction(tree, element); 129 visitor.setupFunction(tree, element);
127 130
128 if (isConstructor) { 131 if (isConstructor) {
129 // Even if there is no initializer list we still have to do the 132 // Even if there is no initializer list we still have to do the
130 // resolution in case there is an implicit super constructor call. 133 // resolution in case there is an implicit super constructor call.
131 InitializerResolver resolver = new InitializerResolver(visitor); 134 InitializerResolver resolver = new InitializerResolver(visitor);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 ClassResolverVisitor visitor = 277 ClassResolverVisitor visitor =
275 new ClassResolverVisitor(compiler, element); 278 new ClassResolverVisitor(compiler, element);
276 visitor.visit(tree); 279 visitor.visit(tree);
277 element.resolutionState = ClassElement.STATE_DONE; 280 element.resolutionState = ClassElement.STATE_DONE;
278 })); 281 }));
279 } 282 }
280 283
281 void checkMembers(ClassElement cls) { 284 void checkMembers(ClassElement cls) {
282 if (cls === compiler.objectClass) return; 285 if (cls === compiler.objectClass) return;
283 cls.forEachMember((holder, member) { 286 cls.forEachMember((holder, member) {
287
288 // Check modifiers.
289 if (member.isFunction() && member.modifiers.isFinal()) {
290 compiler.reportMessage(
291 compiler.spanFromElement(member),
292 MessageKind.ILLEGAL_FINAL_METHOD_MODIFIER.error(),
293 api.Diagnostic.ERROR);
294 }
295 if (member.isConstructor()) {
296 final mismatchedFlagsBits =
297 member.modifiers.flags &
298 (Modifiers.FLAG_STATIC | Modifiers.FLAG_ABSTRACT);
299 if (mismatchedFlagsBits != 0) {
300 final mismatchedFlags =
301 new Modifiers.withFlags(null, mismatchedFlagsBits);
302 compiler.reportMessage(
303 compiler.spanFromElement(member),
304 MessageKind.ILLEGAL_CONSTRUCTOR_MODIFIERS.error([mismatchedFlags]),
305 api.Diagnostic.ERROR);
306 }
307 }
284 checkAbstractField(member); 308 checkAbstractField(member);
285 checkValidOverride(member, cls.lookupSuperMember(member.name)); 309 checkValidOverride(member, cls.lookupSuperMember(member.name));
286 }); 310 });
287 } 311 }
288 312
289 void checkAbstractField(Element member) { 313 void checkAbstractField(Element member) {
290 if (member is !AbstractFieldElement) return; 314 if (member is !AbstractFieldElement) return;
291 if (member.getter === null) return; 315 if (member.getter === null) return;
292 if (member.setter === null) return; 316 if (member.setter === null) return;
293 int getterFlags = member.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT; 317 int getterFlags = member.getter.modifiers.flags | Modifiers.FLAG_ABSTRACT;
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 TopScope(LibraryElement library) : super(null, library); 2463 TopScope(LibraryElement library) : super(null, library);
2440 Element lookup(SourceString name) { 2464 Element lookup(SourceString name) {
2441 return library.find(name); 2465 return library.find(name);
2442 } 2466 }
2443 2467
2444 Element add(Element newElement) { 2468 Element add(Element newElement) {
2445 throw "Cannot add an element in the top scope"; 2469 throw "Cannot add an element in the top scope";
2446 } 2470 }
2447 String toString() => '$element'; 2471 String toString() => '$element';
2448 } 2472 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698