Chromium Code Reviews| Index: pkg/analyzer2dart/lib/src/tree_shaker.dart |
| diff --git a/pkg/analyzer2dart/lib/src/tree_shaker.dart b/pkg/analyzer2dart/lib/src/tree_shaker.dart |
| index 7e765ccf8cdfd7a3a73cd712b6f2f8f4f9cc637a..6b9eaa67a95bd3ca3f7220eed3c28eff85fbe011 100644 |
| --- a/pkg/analyzer2dart/lib/src/tree_shaker.dart |
| +++ b/pkg/analyzer2dart/lib/src/tree_shaker.dart |
| @@ -90,7 +90,16 @@ class LocalReachabilityComputer { |
| // constructor, in which case all we need to do is record the class as |
| // being instantiated by this method. TODO(paulberry): handle the |
| // mixin case. |
| - analysis.instantiates.add(method.enclosingElement); |
| + ClassElement instantiatedClass = method.enclosingElement; |
| + analysis.instantiates.add(instantiatedClass); |
| + if (instantiatedClass.supertype != null) { |
| + ClassElement superClass = instantiatedClass.supertype.element; |
| + ConstructorElement superConstructor = superClass.unnamedConstructor; |
| + if (superConstructor != null) { |
| + // TODO(johnniwinther): Register instantiated type and selector. |
| + analysis.calls.add(superConstructor); |
| + } |
| + } |
| } else { |
| // This is an executable element with no associated declaration in the |
| // AST, and it's not a constructor. TODO(paulberry): can this ever |
| @@ -369,7 +378,18 @@ class TreeShakingVisitor extends SemanticVisitor { |
| // we don't need to, because the redirected-to constructor will take care |
| // of that). |
| if (node.initializers.length != 1 || node.initializers[0] is! RedirectingConstructorInvocation) { |
|
sigurdm
2015/02/10 09:37:56
Long line (was there already)
Johnni Winther
2015/02/10 13:51:57
The analyzer is dog-fooding the formatter so toler
sigurdm
2015/02/10 13:55:31
Acknowledged.
|
| + ClassElement classElement = node.element.enclosingElement; |
| analysis.instantiates.add(node.element.enclosingElement); |
| + if (!node.initializers.any((i) => i is SuperConstructorInvocation)) { |
| + if (classElement.supertype != null) { |
| + ClassElement superClass = classElement.supertype.element; |
| + ConstructorElement superConstructor = superClass.unnamedConstructor; |
| + if (superConstructor != null) { |
| + // TODO(johnniwinther): Register instantiated type and selector. |
| + analysis.calls.add(superConstructor); |
| + } |
| + } |
| + } |
| } |
| } else if (node.redirectedConstructor != null) { |
| if (node.redirectedConstructor.staticElement == null) { |