OLD | NEW |
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 import '../compiler.dart' show | 6 import '../compiler.dart' show |
7 Compiler, | 7 Compiler; |
8 isPrivateName; | |
9 import '../constants/constructors.dart' show | 8 import '../constants/constructors.dart' show |
10 GenerativeConstantConstructor, | 9 GenerativeConstantConstructor, |
11 RedirectingGenerativeConstantConstructor; | 10 RedirectingGenerativeConstantConstructor; |
12 import '../constants/expressions.dart'; | 11 import '../constants/expressions.dart'; |
13 import '../dart_types.dart'; | 12 import '../dart_types.dart'; |
14 import '../diagnostics/invariant.dart' show | 13 import '../diagnostics/invariant.dart' show |
15 invariant; | 14 invariant; |
16 import '../diagnostics/messages.dart' show | 15 import '../diagnostics/messages.dart' show |
17 MessageKind; | 16 MessageKind; |
18 import '../diagnostics/spannable.dart' show | 17 import '../diagnostics/spannable.dart' show |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 return new ErroneousConstructorElementX( | 451 return new ErroneousConstructorElementX( |
453 kind, arguments, name, enclosing); | 452 kind, arguments, name, enclosing); |
454 } | 453 } |
455 | 454 |
456 FunctionElement resolveConstructor(ClassElement cls, | 455 FunctionElement resolveConstructor(ClassElement cls, |
457 Node diagnosticNode, | 456 Node diagnosticNode, |
458 String constructorName) { | 457 String constructorName) { |
459 cls.ensureResolved(compiler); | 458 cls.ensureResolved(compiler); |
460 Element result = cls.lookupConstructor(constructorName); | 459 Element result = cls.lookupConstructor(constructorName); |
461 // TODO(johnniwinther): Use [Name] for lookup. | 460 // TODO(johnniwinther): Use [Name] for lookup. |
462 if (isPrivateName(constructorName) && | 461 if (Name.isPrivateName(constructorName) && |
463 resolver.enclosingElement.library != cls.library) { | 462 resolver.enclosingElement.library != cls.library) { |
464 result = null; | 463 result = null; |
465 } | 464 } |
466 if (result == null) { | 465 if (result == null) { |
467 String fullConstructorName = Elements.constructorNameForDiagnostics( | 466 String fullConstructorName = Elements.constructorNameForDiagnostics( |
468 cls.name, | 467 cls.name, |
469 constructorName); | 468 constructorName); |
470 return failOrReturnErroneousConstructorElement( | 469 return failOrReturnErroneousConstructorElement( |
471 diagnosticNode, | 470 diagnosticNode, |
472 cls, constructorName, | 471 cls, constructorName, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 return element; | 609 return element; |
611 } | 610 } |
612 | 611 |
613 /// Assumed to be called by [resolveRedirectingFactory]. | 612 /// Assumed to be called by [resolveRedirectingFactory]. |
614 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { | 613 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
615 Node constructorReference = node.constructorReference; | 614 Node constructorReference = node.constructorReference; |
616 return finishConstructorReference(visit(constructorReference), | 615 return finishConstructorReference(visit(constructorReference), |
617 constructorReference, node); | 616 constructorReference, node); |
618 } | 617 } |
619 } | 618 } |
OLD | NEW |