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

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

Issue 1173403002: dart2js: Fix hints in code base. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Updated to latest revision Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 class InitializerResolver { 7 class InitializerResolver {
8 final ResolverVisitor visitor; 8 final ResolverVisitor visitor;
9 final Map<Element, Node> initialized; 9 final Map<Element, Node> initialized;
10 Link<Node> initializers; 10 Link<Node> initializers;
(...skipping 24 matching lines...) Expand all
35 init, 35 init,
36 MessageKind.DUPLICATE_INITIALIZER, {'fieldName': field.name}); 36 MessageKind.DUPLICATE_INITIALIZER, {'fieldName': field.name});
37 visitor.compiler.reportInfo( 37 visitor.compiler.reportInfo(
38 existing, 38 existing,
39 MessageKind.ALREADY_INITIALIZED, {'fieldName': field.name}); 39 MessageKind.ALREADY_INITIALIZED, {'fieldName': field.name});
40 } 40 }
41 41
42 void checkForDuplicateInitializers(FieldElementX field, Node init) { 42 void checkForDuplicateInitializers(FieldElementX field, Node init) {
43 // [field] can be null if it could not be resolved. 43 // [field] can be null if it could not be resolved.
44 if (field == null) return; 44 if (field == null) return;
45 String name = field.name;
46 if (initialized.containsKey(field)) { 45 if (initialized.containsKey(field)) {
47 reportDuplicateInitializerError(field, init, initialized[field]); 46 reportDuplicateInitializerError(field, init, initialized[field]);
48 } else if (field.isFinal) { 47 } else if (field.isFinal) {
49 field.parseNode(visitor.compiler); 48 field.parseNode(visitor.compiler);
50 Expression initializer = field.initializer; 49 Expression initializer = field.initializer;
51 if (initializer != null) { 50 if (initializer != null) {
52 reportDuplicateInitializerError(field, init, initializer); 51 reportDuplicateInitializerError(field, init, initializer);
53 } 52 }
54 } 53 }
55 initialized[field] = init; 54 initialized[field] = init;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return lookupTarget.supertype.element; 95 return lookupTarget.supertype.element;
97 } 96 }
98 } 97 }
99 return lookupTarget; 98 return lookupTarget;
100 } 99 }
101 100
102 Element resolveSuperOrThisForSend(FunctionElement constructor, 101 Element resolveSuperOrThisForSend(FunctionElement constructor,
103 FunctionExpression functionNode, 102 FunctionExpression functionNode,
104 Send call) { 103 Send call) {
105 // Resolve the selector and the arguments. 104 // Resolve the selector and the arguments.
106 ResolverTask resolver = visitor.compiler.resolver;
107 visitor.inStaticContext(() { 105 visitor.inStaticContext(() {
108 visitor.resolveSelector(call, null); 106 visitor.resolveSelector(call, null);
109 visitor.resolveArguments(call.argumentsNode); 107 visitor.resolveArguments(call.argumentsNode);
110 }); 108 });
111 Selector selector = registry.getSelector(call); 109 Selector selector = registry.getSelector(call);
112 bool isSuperCall = Initializers.isSuperConstructorCall(call); 110 bool isSuperCall = Initializers.isSuperConstructorCall(call);
113 111
114 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor, 112 ClassElement lookupTarget = getSuperOrThisLookupTarget(constructor,
115 isSuperCall, 113 isSuperCall,
116 call); 114 call);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (functionNode.hasBody() && !constructor.isConst) { 244 if (functionNode.hasBody() && !constructor.isConst) {
247 error(functionNode, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY); 245 error(functionNode, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY);
248 } 246 }
249 // Check that there are no other initializers. 247 // Check that there are no other initializers.
250 if (!initializers.tail.isEmpty) { 248 if (!initializers.tail.isEmpty) {
251 error(call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER); 249 error(call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER);
252 } else { 250 } else {
253 constructor.isRedirectingGenerative = true; 251 constructor.isRedirectingGenerative = true;
254 } 252 }
255 // Check that there are no field initializing parameters. 253 // Check that there are no field initializing parameters.
256 Compiler compiler = visitor.compiler;
257 FunctionSignature signature = constructor.functionSignature; 254 FunctionSignature signature = constructor.functionSignature;
258 signature.forEachParameter((ParameterElement parameter) { 255 signature.forEachParameter((ParameterElement parameter) {
259 if (parameter.isInitializingFormal) { 256 if (parameter.isInitializingFormal) {
260 Node node = parameter.node; 257 Node node = parameter.node;
261 error(node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED); 258 error(node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED);
262 } 259 }
263 }); 260 });
264 return resolveSuperOrThisForSend(constructor, functionNode, call); 261 return resolveSuperOrThisForSend(constructor, functionNode, call);
265 } else { 262 } else {
266 visitor.error(call, MessageKind.CONSTRUCTOR_CALL_EXPECTED); 263 visitor.error(call, MessageKind.CONSTRUCTOR_CALL_EXPECTED);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return element; 468 return element;
472 } 469 }
473 470
474 /// Assumed to be called by [resolveRedirectingFactory]. 471 /// Assumed to be called by [resolveRedirectingFactory].
475 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { 472 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) {
476 Node constructorReference = node.constructorReference; 473 Node constructorReference = node.constructorReference;
477 return finishConstructorReference(visit(constructorReference), 474 return finishConstructorReference(visit(constructorReference),
478 constructorReference, node); 475 constructorReference, node);
479 } 476 }
480 } 477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698