| Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| index b9ee92552b1812f06ac4140d5a009f24df7d49d7..94afd380b162337cd19044853ea8bbae153444f1 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| @@ -3378,6 +3378,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| }
|
| FunctionElement functionElement = constructor;
|
| constructor = functionElement.redirectionTarget;
|
| +
|
| final bool isSymbolConstructor =
|
| functionElement == compiler.symbolConstructor;
|
|
|
| @@ -3390,6 +3391,23 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| message: 'Constructor Symbol.validated is missing'));
|
| }
|
|
|
| + bool isRedirected = functionElement.isRedirection;
|
| + DartType expectedType = type;
|
| + if (isRedirected) {
|
| + FunctionExpression functionNode = functionElement.parseNode(compiler);
|
| + if (functionNode.isRedirectingFactory) {
|
| + // Lookup the type used in the redirection.
|
| + Return redirectionNode = functionNode.body;
|
| + TreeElements treeElements =
|
| + compiler.enqueuer.resolution.getCachedElements(
|
| + functionElement.declaration);
|
| + ClassElement targetClass = functionElement.getEnclosingClass();
|
| + type = treeElements.getType(redirectionNode)
|
| + .subst(type.typeArguments, targetClass.typeVariables);
|
| + }
|
| + functionElement = functionElement.redirectionTarget;
|
| + }
|
| +
|
| var inputs = <HInstruction>[];
|
| // TODO(5347): Try to avoid the need for calling [implementation] before
|
| // calling [addStaticSendArgumentsToList].
|
| @@ -3434,6 +3452,15 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
| if (isListConstructor && backend.needsRti(compiler.listClass)) {
|
| handleListConstructor(type, send, newInstance);
|
| }
|
| +
|
| + // Finally, if we called a redirecting factory constructor, check the type.
|
| + if (isRedirected) {
|
| + HInstruction checked = potentiallyCheckType(newInstance, expectedType);
|
| + if (checked != newInstance) {
|
| + pop();
|
| + stack.add(checked);
|
| + }
|
| + }
|
| }
|
|
|
| visitStaticSend(Send node) {
|
|
|