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

Unified Diff: pkg/compiler/lib/src/serialization/element_serialization.dart

Issue 1891193003: Fix serialization of forwarding constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f4a9b45e63f2c25cb02fd309ee0cf359f7ece451..97c34d24de7b63563c964c6c7b9bee9dc0ce0d16 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -23,6 +23,7 @@ enum SerializedElementKind {
NAMED_MIXIN_APPLICATION,
GENERATIVE_CONSTRUCTOR,
FACTORY_CONSTRUCTOR,
+ FORWARDING_CONSTRUCTOR,
TOPLEVEL_FIELD,
STATIC_FIELD,
INSTANCE_FIELD,
@@ -339,7 +340,11 @@ class ConstructorSerializer implements ElementSerializer {
SerializedElementKind getSerializedKind(Element element) {
if (element.isGenerativeConstructor) {
- return SerializedElementKind.GENERATIVE_CONSTRUCTOR;
+ if (element.enclosingClass.isNamedMixinApplication) {
+ return SerializedElementKind.FORWARDING_CONSTRUCTOR;
+ } else {
+ return SerializedElementKind.GENERATIVE_CONSTRUCTOR;
+ }
} else if (element.isFactoryConstructor) {
return SerializedElementKind.FACTORY_CONSTRUCTOR;
}
@@ -349,18 +354,22 @@ class ConstructorSerializer implements ElementSerializer {
void serialize(ConstructorElement element, ObjectEncoder encoder,
SerializedElementKind kind) {
SerializerUtil.serializeParentRelation(element, encoder);
- encoder.setType(Key.TYPE, element.type);
- encoder.setString(Key.NAME, element.name);
- SerializerUtil.serializePosition(element, encoder);
- 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 (kind == SerializedElementKind.FORWARDING_CONSTRUCTOR) {
+ encoder.setElement(Key.ELEMENT, element.definingConstructor);
+ } else {
+ encoder.setType(Key.TYPE, element.type);
+ encoder.setString(Key.NAME, element.name);
+ SerializerUtil.serializePosition(element, encoder);
+ 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);
+ }
}
}
}
@@ -649,6 +658,9 @@ class ElementDeserializer {
return new GenerativeConstructorElementZ(decoder);
case SerializedElementKind.FACTORY_CONSTRUCTOR:
return new FactoryConstructorElementZ(decoder);
+ case SerializedElementKind.FORWARDING_CONSTRUCTOR:
+ return new ForwardingConstructorElementZ(
+ decoder.getElement(Key.CLASS), decoder.getElement(Key.ELEMENT));
case SerializedElementKind.TOPLEVEL_FUNCTION:
return new TopLevelFunctionElementZ(decoder);
case SerializedElementKind.STATIC_FUNCTION:
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698