Index: pkg/compiler/lib/src/serialization/element_serialization.dart |
diff --git a/pkg/compiler/lib/src/serialization/element_serialization.dart b/pkg/compiler/lib/src/serialization/element_serialization.dart |
index 6f5dc4d83cd17ded8f670874a3d2e135d65114b3..5c8c0d68fc326fb5a79b9a41f29c6d81a8566d9e 100644 |
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart |
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart |
@@ -13,6 +13,7 @@ import 'constant_serialization.dart'; |
import 'keys.dart'; |
import 'modelz.dart'; |
import 'serialization.dart'; |
+import 'serialization_util.dart'; |
/// Enum kinds used for encoding [Element]s. |
enum SerializedElementKind { |
@@ -23,6 +24,7 @@ enum SerializedElementKind { |
NAMED_MIXIN_APPLICATION, |
GENERATIVE_CONSTRUCTOR, |
FACTORY_CONSTRUCTOR, |
+ REDIRECTING_FACTORY_CONSTRUCTOR, |
FORWARDING_CONSTRUCTOR, |
TOPLEVEL_FIELD, |
STATIC_FIELD, |
@@ -346,7 +348,12 @@ class ConstructorSerializer implements ElementSerializer { |
return SerializedElementKind.GENERATIVE_CONSTRUCTOR; |
} |
} else if (element.isFactoryConstructor) { |
- return SerializedElementKind.FACTORY_CONSTRUCTOR; |
+ ConstructorElement constructor = element; |
+ if (constructor.isRedirectingFactory) { |
+ return SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR; |
+ } else { |
+ return SerializedElementKind.FACTORY_CONSTRUCTOR; |
+ } |
} |
return null; |
} |
@@ -363,13 +370,37 @@ class ConstructorSerializer implements ElementSerializer { |
SerializerUtil.serializeParameters(element, encoder); |
encoder.setBool(Key.IS_CONST, element.isConst); |
encoder.setBool(Key.IS_EXTERNAL, element.isExternal); |
- if (element.isExternal) return; |
if (element.isConst && !element.isFromEnvironmentConstructor) { |
ConstantConstructor constantConstructor = element.constantConstructor; |
ObjectEncoder constantEncoder = encoder.createObject(Key.CONSTRUCTOR); |
const ConstantConstructorSerializer() |
.visit(constantConstructor, constantEncoder); |
} |
+ if (element.definingConstructor != null) { |
+ assert(invariant( |
+ element, |
+ element.definingConstructor.enclosingClass == |
+ element.enclosingClass.superclass, |
+ message: "Unexpected defining constructor: " |
+ "${element.definingConstructor}")); |
+ encoder.setString( |
+ Key.DEFINING_CONSTRUCTOR, element.definingConstructor.name); |
+ } |
+ if (kind == SerializedElementKind.GENERATIVE_CONSTRUCTOR) { |
+ encoder.setBool(Key.IS_REDIRECTING, element.isRedirectingGenerative); |
+ } |
+ encoder.setElement(Key.EFFECTIVE_TARGET, element.effectiveTarget); |
+ if (kind == SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR) { |
+ encoder.setType( |
+ Key.EFFECTIVE_TARGET_TYPE, |
+ element |
+ .computeEffectiveTargetType(element.enclosingClass.thisType)); |
+ encoder.setElement(Key.IMMEDIATE_REDIRECTION_TARGET, |
+ element.immediateRedirectionTarget); |
+ if (element.redirectionDeferredPrefix != null) { |
+ encoder.setElement(Key.PREFIX, element.redirectionDeferredPrefix); |
+ } |
+ } |
} |
} |
} |
@@ -660,6 +691,8 @@ class ElementDeserializer { |
return new GenerativeConstructorElementZ(decoder); |
case SerializedElementKind.FACTORY_CONSTRUCTOR: |
return new FactoryConstructorElementZ(decoder); |
+ case SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR: |
+ return new RedirectingFactoryConstructorElementZ(decoder); |
case SerializedElementKind.FORWARDING_CONSTRUCTOR: |
return new ForwardingConstructorElementZ( |
decoder.getElement(Key.CLASS), decoder.getElement(Key.ELEMENT)); |