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

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

Issue 2941033002: Finish strong mode cleaning of dart2js. (Closed)
Patch Set: Created 3 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 library dart2js.resolution.constructors; 5 library dart2js.resolution.constructors;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution; 8 import '../common/resolution.dart' show Resolution;
9 import '../constants/constructors.dart' 9 import '../constants/constructors.dart'
10 show 10 show
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // that we can ensure that fields are initialized only once. 306 // that we can ensure that fields are initialized only once.
307 FunctionSignature functionParameters = constructor.functionSignature; 307 FunctionSignature functionParameters = constructor.functionSignature;
308 Scope oldScope = visitor.scope; 308 Scope oldScope = visitor.scope;
309 // In order to get the correct detection of name clashes between all 309 // In order to get the correct detection of name clashes between all
310 // parameters (regular ones and initializing formals) we must extend 310 // parameters (regular ones and initializing formals) we must extend
311 // the parameter scope rather than adding a new nested scope. 311 // the parameter scope rather than adding a new nested scope.
312 visitor.scope = new ExtensionScope(visitor.scope); 312 visitor.scope = new ExtensionScope(visitor.scope);
313 Link<Node> parameterNodes = (functionNode.parameters == null) 313 Link<Node> parameterNodes = (functionNode.parameters == null)
314 ? const Link<Node>() 314 ? const Link<Node>()
315 : functionNode.parameters.nodes; 315 : functionNode.parameters.nodes;
316 functionParameters.forEachParameter((ParameterElementX element) { 316 functionParameters.forEachParameter((FormalElement _element) {
317 ParameterElementX element = _element;
317 List<Element> optionals = functionParameters.optionalParameters; 318 List<Element> optionals = functionParameters.optionalParameters;
318 if (!optionals.isEmpty && element == optionals.first) { 319 if (!optionals.isEmpty && element == optionals.first) {
319 NodeList nodes = parameterNodes.head; 320 NodeList nodes = parameterNodes.head;
320 parameterNodes = nodes.nodes; 321 parameterNodes = nodes.nodes;
321 } 322 }
322 if (isConst) { 323 if (isConst) {
323 if (element.isOptional) { 324 if (element.isOptional) {
324 if (element.constantCache == null) { 325 if (element.constantCache == null) {
325 // TODO(johnniwinther): Remove this when all constant expressions 326 // TODO(johnniwinther): Remove this when all constant expressions
326 // can be computed during resolution. 327 // can be computed during resolution.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 408 }
408 // Check that there are no other initializers. 409 // Check that there are no other initializers.
409 if (!initializers.tail.isEmpty) { 410 if (!initializers.tail.isEmpty) {
410 reporter.reportErrorMessage( 411 reporter.reportErrorMessage(
411 call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER); 412 call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER);
412 } else { 413 } else {
413 constructor.isRedirectingGenerativeInternal = true; 414 constructor.isRedirectingGenerativeInternal = true;
414 } 415 }
415 // Check that there are no field initializing parameters. 416 // Check that there are no field initializing parameters.
416 FunctionSignature signature = constructor.functionSignature; 417 FunctionSignature signature = constructor.functionSignature;
417 signature.forEachParameter((ParameterElement parameter) { 418 signature.forEachParameter((FormalElement parameter) {
418 if (parameter.isInitializingFormal) { 419 if (parameter.isInitializingFormal) {
419 Node node = parameter.node; 420 Node node = parameter.node;
420 reporter.reportErrorMessage( 421 reporter.reportErrorMessage(
421 node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED); 422 node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED);
422 isValidAsConstant = false; 423 isValidAsConstant = false;
423 } 424 }
424 }); 425 });
425 ResolutionResult result = resolveSuperOrThisForSend(call); 426 ResolutionResult result = resolveSuperOrThisForSend(call);
426 if (isConst) { 427 if (isConst) {
427 if (result.isConstant) { 428 if (result.isConstant) {
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 // constructors. 887 // constructors.
887 return null; 888 return null;
888 } 889 }
889 // TODO(johnniwinther): Use [Name] for lookup. 890 // TODO(johnniwinther): Use [Name] for lookup.
890 ConstructorElement constructor = cls.lookupConstructor(constructorName); 891 ConstructorElement constructor = cls.lookupConstructor(constructorName);
891 if (constructor != null) { 892 if (constructor != null) {
892 constructor = constructor.declaration; 893 constructor = constructor.declaration;
893 } 894 }
894 return constructor; 895 return constructor;
895 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698