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

Side by Side Diff: pkg/compiler/lib/src/serialization/modelz.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 unified diff | Download patch
OLDNEW
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 /// Implementation of the element model used for deserialiation. 5 /// Implementation of the element model used for deserialiation.
6 /// 6 ///
7 /// These classes are created by [ElementDeserializer] triggered by the 7 /// These classes are created by [ElementDeserializer] triggered by the
8 /// [Deserializer]. 8 /// [Deserializer].
9 9
10 library dart2js.serialization.modelz; 10 library dart2js.serialization.modelz;
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 @override 891 @override
892 FunctionType get callType { 892 FunctionType get callType {
893 _ensureSuperHierarchy(); 893 _ensureSuperHierarchy();
894 return _callType; 894 return _callType;
895 } 895 }
896 } 896 }
897 897
898 abstract class MixinApplicationElementMixin 898 abstract class MixinApplicationElementMixin
899 implements ElementZ, MixinApplicationElement { 899 implements ElementZ, MixinApplicationElement {
900 Link<ConstructorElement> _constructors;
901
902 @override 900 @override
903 bool get isMixinApplication => false; 901 bool get isMixinApplication => true;
904 902
905 @override 903 @override
906 ClassElement get mixin => mixinType.element; 904 ClassElement get mixin => mixinType.element;
907
908 Link<ConstructorElement> get constructors {
909 if (_constructors == null) {
910 LinkBuilder<ConstructorElement> builder =
911 new LinkBuilder<ConstructorElement>();
912 for (ConstructorElement definingConstructor in superclass.constructors) {
913 if (definingConstructor.isGenerativeConstructor &&
914 definingConstructor.memberName.isAccessibleFrom(library)) {
915 builder.addLast(
916 new ForwardingConstructorElementZ(this, definingConstructor));
917 }
918 }
919 _constructors = builder.toLink();
920 }
921 return _constructors;
922 }
923 } 905 }
924 906
925 class NamedMixinApplicationElementZ extends ClassElementZ 907 class NamedMixinApplicationElementZ extends ClassElementZ
926 with MixinApplicationElementCommon, MixinApplicationElementMixin { 908 with MixinApplicationElementMixin {
909 Link<Element> _constructors;
927 InterfaceType _mixinType; 910 InterfaceType _mixinType;
928 911
929 NamedMixinApplicationElementZ(ObjectDecoder decoder) : super(decoder); 912 NamedMixinApplicationElementZ(ObjectDecoder decoder) : super(decoder);
930 913
931 @override 914 @override
932 InterfaceType get mixinType => _mixinType ??= _decoder.getType(Key.MIXIN); 915 InterfaceType get mixinType => _mixinType ??= _decoder.getType(Key.MIXIN);
933 } 916 }
934 917
935 class UnnamedMixinApplicationElementZ extends ElementZ 918 class UnnamedMixinApplicationElementZ extends ElementZ
936 with 919 with
937 ClassElementCommon, 920 ClassElementCommon,
938 ClassElementMixin, 921 ClassElementMixin,
939 class_members.ClassMemberMixin, 922 class_members.ClassMemberMixin,
940 TypeDeclarationMixin<InterfaceType>, 923 TypeDeclarationMixin<InterfaceType>,
941 AnalyzableElementMixin, 924 AnalyzableElementMixin,
942 AstElementMixin, 925 AstElementMixin,
943 MixinApplicationElementCommon, 926 MixinApplicationElementCommon,
944 MixinApplicationElementMixin { 927 MixinApplicationElementMixin {
945 final String name; 928 final String name;
946 final ClassElement _subclass; 929 final ClassElement _subclass;
947 final InterfaceType supertype; 930 final InterfaceType supertype;
948 final Link<DartType> interfaces; 931 final Link<DartType> interfaces;
949 OrderedTypeSet _allSupertypesAndSelf; 932 OrderedTypeSet _allSupertypesAndSelf;
933 Link<ConstructorElement> _constructors;
950 934
951 UnnamedMixinApplicationElementZ( 935 UnnamedMixinApplicationElementZ(
952 ClassElement subclass, InterfaceType supertype, InterfaceType mixin) 936 ClassElement subclass, InterfaceType supertype, InterfaceType mixin)
953 : this._subclass = subclass, 937 : this._subclass = subclass,
954 this.supertype = supertype, 938 this.supertype = supertype,
955 this.interfaces = const Link<DartType>().prepend(mixin), 939 this.interfaces = const Link<DartType>().prepend(mixin),
956 this.name = "${supertype.name}+${mixin.name}"; 940 this.name = "${supertype.name}+${mixin.name}";
957 941
958 @override 942 @override
959 CompilationUnitElement get compilationUnit => _subclass.compilationUnit; 943 CompilationUnitElement get compilationUnit => _subclass.compilationUnit;
960 944
961 @override 945 @override
962 bool get isUnnamedMixinApplication => true; 946 bool get isUnnamedMixinApplication => true;
963 947
948 Link<ConstructorElement> get constructors {
949 if (_constructors == null) {
950 LinkBuilder<ConstructorElement> builder =
951 new LinkBuilder<ConstructorElement>();
952 for (ConstructorElement definingConstructor in superclass.constructors) {
953 if (definingConstructor.isGenerativeConstructor &&
954 definingConstructor.memberName.isAccessibleFrom(library)) {
955 builder.addLast(
956 new ForwardingConstructorElementZ(this, definingConstructor));
957 }
958 }
959 _constructors = builder.toLink();
960 }
961 return _constructors;
962 }
963
964 @override 964 @override
965 List<DartType> _getTypeVariables() { 965 List<DartType> _getTypeVariables() {
966 // Create synthetic type variables for the mixin application. 966 // Create synthetic type variables for the mixin application.
967 List<DartType> typeVariables = <DartType>[]; 967 List<DartType> typeVariables = <DartType>[];
968 int index = 0; 968 int index = 0;
969 for (TypeVariableType type in _subclass.typeVariables) { 969 for (TypeVariableType type in _subclass.typeVariables) {
970 SyntheticTypeVariableElementZ typeVariableElement = 970 SyntheticTypeVariableElementZ typeVariableElement =
971 new SyntheticTypeVariableElementZ(this, index, type.name); 971 new SyntheticTypeVariableElementZ(this, index, type.name);
972 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); 972 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
973 typeVariables.add(typeVariable); 973 typeVariables.add(typeVariable);
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 } 1966 }
1967 1967
1968 @override 1968 @override
1969 ElementKind get kind => ElementKind.PREFIX; 1969 ElementKind get kind => ElementKind.PREFIX;
1970 1970
1971 @override 1971 @override
1972 Element lookupLocalMember(String memberName) { 1972 Element lookupLocalMember(String memberName) {
1973 return _unsupported('lookupLocalMember'); 1973 return _unsupported('lookupLocalMember');
1974 } 1974 }
1975 } 1975 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/element_serialization.dart ('k') | tests/compiler/dart2js/serialization_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698