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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1423623008: Improve messages and static use for super/this-calls. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 years, 1 month 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
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 dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show 8 import '../common/names.dart' show
9 Selectors; 9 Selectors;
10 import '../compiler.dart' show 10 import '../compiler.dart' show
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 TypeResult visitTypeAnnotation(TypeAnnotation node) { 402 TypeResult visitTypeAnnotation(TypeAnnotation node) {
403 DartType type = resolveTypeAnnotation(node); 403 DartType type = resolveTypeAnnotation(node);
404 if (inCheckContext) { 404 if (inCheckContext) {
405 registry.registerTypeUse(new TypeUse.checkedModeCheck(type)); 405 registry.registerTypeUse(new TypeUse.checkedModeCheck(type));
406 } 406 }
407 return new TypeResult(type); 407 return new TypeResult(type);
408 } 408 }
409 409
410 bool isNamedConstructor(Send node) => node.receiver != null; 410 bool isNamedConstructor(Send node) => node.receiver != null;
411 411
412 Selector getRedirectingThisOrSuperConstructorSelector(Send node) { 412 Name getRedirectingThisOrSuperConstructorName(Send node) {
413 if (isNamedConstructor(node)) { 413 if (isNamedConstructor(node)) {
414 String constructorName = node.selector.asIdentifier().source; 414 String constructorName = node.selector.asIdentifier().source;
415 return new Selector.callConstructor( 415 return new Name(constructorName, enclosingElement.library);
416 new Name(constructorName, enclosingElement.library));
417 } else { 416 } else {
418 return new Selector.callDefaultConstructor(); 417 return const PublicName('');
419 } 418 }
420 } 419 }
421 420
422 FunctionElement resolveConstructorRedirection(FunctionElementX constructor) { 421 FunctionElement resolveConstructorRedirection(FunctionElementX constructor) {
423 FunctionExpression node = constructor.parseNode(resolution.parsing); 422 FunctionExpression node = constructor.parseNode(resolution.parsing);
424 423
425 // A synthetic constructor does not have a node. 424 // A synthetic constructor does not have a node.
426 if (node == null) return null; 425 if (node == null) return null;
427 if (node.initializers == null) return null; 426 if (node.initializers == null) return null;
428 Link<Node> initializers = node.initializers.nodes; 427 Link<Node> initializers = node.initializers.nodes;
429 if (!initializers.isEmpty && 428 if (!initializers.isEmpty &&
430 Initializers.isConstructorRedirect(initializers.head)) { 429 Initializers.isConstructorRedirect(initializers.head)) {
431 Selector selector = 430 Name name =
432 getRedirectingThisOrSuperConstructorSelector(initializers.head); 431 getRedirectingThisOrSuperConstructorName(initializers.head);
433 final ClassElement classElement = constructor.enclosingClass; 432 final ClassElement classElement = constructor.enclosingClass;
434 return classElement.lookupConstructor(selector.name); 433 return classElement.lookupConstructor(name.text);
435 } 434 }
436 return null; 435 return null;
437 } 436 }
438 437
439 void setupFunction(FunctionExpression node, FunctionElement function) { 438 void setupFunction(FunctionExpression node, FunctionElement function) {
440 Element enclosingElement = function.enclosingElement; 439 Element enclosingElement = function.enclosingElement;
441 if (node.modifiers.isStatic && 440 if (node.modifiers.isStatic &&
442 enclosingElement.kind != ElementKind.CLASS) { 441 enclosingElement.kind != ElementKind.CLASS) {
443 reporter.reportErrorMessage(node, MessageKind.ILLEGAL_STATIC); 442 reporter.reportErrorMessage(node, MessageKind.ILLEGAL_STATIC);
444 } 443 }
(...skipping 4318 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 } 4762 }
4764 return const NoneResult(); 4763 return const NoneResult();
4765 } 4764 }
4766 } 4765 }
4767 4766
4768 /// Looks up [name] in [scope] and unwraps the result. 4767 /// Looks up [name] in [scope] and unwraps the result.
4769 Element lookupInScope(DiagnosticReporter reporter, Node node, 4768 Element lookupInScope(DiagnosticReporter reporter, Node node,
4770 Scope scope, String name) { 4769 Scope scope, String name) {
4771 return Elements.unwrap(scope.lookup(name), reporter, node); 4770 return Elements.unwrap(scope.lookup(name), reporter, node);
4772 } 4771 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/constructors.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698