Skip to content

Commit 88bb4d4

Browse files
Jennifer Messerlyvsmenon
Jennifer Messerly
authored andcommitted
fix #27336, ddc with recursive generic class type args
[email protected] Review URL: https://codereview.chromium.org/2516483002 .
1 parent e6f2035 commit 88bb4d4

File tree

8 files changed

+213
-151
lines changed

8 files changed

+213
-151
lines changed

pkg/dev_compiler/lib/js/amd/dart_sdk.js

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -797,43 +797,48 @@ define([], function() {
797797
}
798798
return flatten;
799799
};
800-
dart.generic = function(typeConstructor) {
801-
let length = typeConstructor.length;
802-
if (length < 1) {
803-
dart.throwInternalError('must have at least one generic type argument');
804-
}
805-
let resultMap = new Map();
806-
function makeGenericType(...args) {
807-
if (args.length != length && args.length != 0) {
808-
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
809-
}
810-
while (args.length < length)
811-
args.push(dart.dynamic);
812-
let value = resultMap;
813-
for (let i = 0; i < length; i++) {
814-
let arg = args[i];
815-
if (arg == null) {
816-
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
817-
}
818-
let map = value;
819-
value = map.get(arg);
820-
if (value === void 0) {
821-
if (i + 1 == length) {
822-
value = typeConstructor.apply(null, args);
823-
if (value) {
824-
value[dart._typeArguments] = args;
825-
value[dart._originalDeclaration] = makeGenericType;
800+
dart.generic = function(typeConstructor, setBaseClass) {
801+
if (setBaseClass === void 0) setBaseClass = null;
802+
return (() => {
803+
let length = typeConstructor.length;
804+
if (length < 1) {
805+
dart.throwInternalError('must have at least one generic type argument');
806+
}
807+
let resultMap = new Map();
808+
function makeGenericType(...args) {
809+
if (args.length != length && args.length != 0) {
810+
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
811+
}
812+
while (args.length < length)
813+
args.push(dart.dynamic);
814+
let value = resultMap;
815+
for (let i = 0; i < length; i++) {
816+
let arg = args[i];
817+
if (arg == null) {
818+
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
819+
}
820+
let map = value;
821+
value = map.get(arg);
822+
if (value === void 0) {
823+
if (i + 1 == length) {
824+
value = typeConstructor.apply(null, args);
825+
if (value) {
826+
value[dart._typeArguments] = args;
827+
value[dart._originalDeclaration] = makeGenericType;
828+
}
829+
map.set(arg, value);
830+
if (setBaseClass) setBaseClass(value);
831+
} else {
832+
value = new Map();
833+
map.set(arg, value);
826834
}
827-
} else {
828-
value = new Map();
829835
}
830-
map.set(arg, value);
831836
}
837+
return value;
832838
}
833-
return value;
834-
}
835-
makeGenericType[dart._genericTypeCtor] = typeConstructor;
836-
return makeGenericType;
839+
makeGenericType[dart._genericTypeCtor] = typeConstructor;
840+
return makeGenericType;
841+
})();
837842
};
838843
dart.getGenericClass = function(type) {
839844
return dart.safeGetOwnProperty(type, dart._originalDeclaration);
@@ -26743,7 +26748,6 @@ define([], function() {
2674326748
return this[_nextLink];
2674426749
}
2674526750
}
26746-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2674726751
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2674826752
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2674926753
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26757,6 +26761,8 @@ define([], function() {
2675726761
})
2675826762
});
2675926763
return _UserDoubleLinkedQueueEntry;
26764+
}, _UserDoubleLinkedQueueEntry => {
26765+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2676026766
});
2676126767
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2676226768
const _queue = Symbol('_queue');
@@ -26786,7 +26792,6 @@ define([], function() {
2678626792
return this[_previousLink][_asNonSentinelEntry]();
2678726793
}
2678826794
}
26789-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2679026795
dart.setSignature(_DoubleLinkedQueueEntry, {
2679126796
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2679226797
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26798,6 +26803,8 @@ define([], function() {
2679826803
})
2679926804
});
2680026805
return _DoubleLinkedQueueEntry;
26806+
}, _DoubleLinkedQueueEntry => {
26807+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2680126808
});
2680226809
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2680326810
const _elementCount = Symbol('_elementCount');

pkg/dev_compiler/lib/js/common/dart_sdk.js

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -797,43 +797,48 @@
797797
}
798798
return flatten;
799799
};
800-
dart.generic = function(typeConstructor) {
801-
let length = typeConstructor.length;
802-
if (length < 1) {
803-
dart.throwInternalError('must have at least one generic type argument');
804-
}
805-
let resultMap = new Map();
806-
function makeGenericType(...args) {
807-
if (args.length != length && args.length != 0) {
808-
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
809-
}
810-
while (args.length < length)
811-
args.push(dart.dynamic);
812-
let value = resultMap;
813-
for (let i = 0; i < length; i++) {
814-
let arg = args[i];
815-
if (arg == null) {
816-
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
817-
}
818-
let map = value;
819-
value = map.get(arg);
820-
if (value === void 0) {
821-
if (i + 1 == length) {
822-
value = typeConstructor.apply(null, args);
823-
if (value) {
824-
value[dart._typeArguments] = args;
825-
value[dart._originalDeclaration] = makeGenericType;
800+
dart.generic = function(typeConstructor, setBaseClass) {
801+
if (setBaseClass === void 0) setBaseClass = null;
802+
return (() => {
803+
let length = typeConstructor.length;
804+
if (length < 1) {
805+
dart.throwInternalError('must have at least one generic type argument');
806+
}
807+
let resultMap = new Map();
808+
function makeGenericType(...args) {
809+
if (args.length != length && args.length != 0) {
810+
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
811+
}
812+
while (args.length < length)
813+
args.push(dart.dynamic);
814+
let value = resultMap;
815+
for (let i = 0; i < length; i++) {
816+
let arg = args[i];
817+
if (arg == null) {
818+
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
819+
}
820+
let map = value;
821+
value = map.get(arg);
822+
if (value === void 0) {
823+
if (i + 1 == length) {
824+
value = typeConstructor.apply(null, args);
825+
if (value) {
826+
value[dart._typeArguments] = args;
827+
value[dart._originalDeclaration] = makeGenericType;
828+
}
829+
map.set(arg, value);
830+
if (setBaseClass) setBaseClass(value);
831+
} else {
832+
value = new Map();
833+
map.set(arg, value);
826834
}
827-
} else {
828-
value = new Map();
829835
}
830-
map.set(arg, value);
831836
}
837+
return value;
832838
}
833-
return value;
834-
}
835-
makeGenericType[dart._genericTypeCtor] = typeConstructor;
836-
return makeGenericType;
839+
makeGenericType[dart._genericTypeCtor] = typeConstructor;
840+
return makeGenericType;
841+
})();
837842
};
838843
dart.getGenericClass = function(type) {
839844
return dart.safeGetOwnProperty(type, dart._originalDeclaration);
@@ -26743,7 +26748,6 @@
2674326748
return this[_nextLink];
2674426749
}
2674526750
}
26746-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2674726751
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2674826752
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2674926753
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26757,6 +26761,8 @@
2675726761
})
2675826762
});
2675926763
return _UserDoubleLinkedQueueEntry;
26764+
}, _UserDoubleLinkedQueueEntry => {
26765+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2676026766
});
2676126767
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2676226768
const _queue = Symbol('_queue');
@@ -26786,7 +26792,6 @@
2678626792
return this[_previousLink][_asNonSentinelEntry]();
2678726793
}
2678826794
}
26789-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2679026795
dart.setSignature(_DoubleLinkedQueueEntry, {
2679126796
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2679226797
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26798,6 +26803,8 @@
2679826803
})
2679926804
});
2680026805
return _DoubleLinkedQueueEntry;
26806+
}, _DoubleLinkedQueueEntry => {
26807+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2680126808
});
2680226809
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2680326810
const _elementCount = Symbol('_elementCount');

pkg/dev_compiler/lib/js/es6/dart_sdk.js

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -795,43 +795,48 @@ dart.flattenFutures = function(builder) {
795795
}
796796
return flatten;
797797
};
798-
dart.generic = function(typeConstructor) {
799-
let length = typeConstructor.length;
800-
if (length < 1) {
801-
dart.throwInternalError('must have at least one generic type argument');
802-
}
803-
let resultMap = new Map();
804-
function makeGenericType(...args) {
805-
if (args.length != length && args.length != 0) {
806-
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
807-
}
808-
while (args.length < length)
809-
args.push(dart.dynamic);
810-
let value = resultMap;
811-
for (let i = 0; i < length; i++) {
812-
let arg = args[i];
813-
if (arg == null) {
814-
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
815-
}
816-
let map = value;
817-
value = map.get(arg);
818-
if (value === void 0) {
819-
if (i + 1 == length) {
820-
value = typeConstructor.apply(null, args);
821-
if (value) {
822-
value[dart._typeArguments] = args;
823-
value[dart._originalDeclaration] = makeGenericType;
798+
dart.generic = function(typeConstructor, setBaseClass) {
799+
if (setBaseClass === void 0) setBaseClass = null;
800+
return (() => {
801+
let length = typeConstructor.length;
802+
if (length < 1) {
803+
dart.throwInternalError('must have at least one generic type argument');
804+
}
805+
let resultMap = new Map();
806+
function makeGenericType(...args) {
807+
if (args.length != length && args.length != 0) {
808+
dart.throwInternalError('requires ' + length + ' or 0 type arguments');
809+
}
810+
while (args.length < length)
811+
args.push(dart.dynamic);
812+
let value = resultMap;
813+
for (let i = 0; i < length; i++) {
814+
let arg = args[i];
815+
if (arg == null) {
816+
dart.throwInternalError('type arguments should not be null: ' + typeConstructor);
817+
}
818+
let map = value;
819+
value = map.get(arg);
820+
if (value === void 0) {
821+
if (i + 1 == length) {
822+
value = typeConstructor.apply(null, args);
823+
if (value) {
824+
value[dart._typeArguments] = args;
825+
value[dart._originalDeclaration] = makeGenericType;
826+
}
827+
map.set(arg, value);
828+
if (setBaseClass) setBaseClass(value);
829+
} else {
830+
value = new Map();
831+
map.set(arg, value);
824832
}
825-
} else {
826-
value = new Map();
827833
}
828-
map.set(arg, value);
829834
}
835+
return value;
830836
}
831-
return value;
832-
}
833-
makeGenericType[dart._genericTypeCtor] = typeConstructor;
834-
return makeGenericType;
837+
makeGenericType[dart._genericTypeCtor] = typeConstructor;
838+
return makeGenericType;
839+
})();
835840
};
836841
dart.getGenericClass = function(type) {
837842
return dart.safeGetOwnProperty(type, dart._originalDeclaration);
@@ -26741,7 +26746,6 @@ collection._UserDoubleLinkedQueueEntry$ = dart.generic(E => {
2674126746
return this[_nextLink];
2674226747
}
2674326748
}
26744-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2674526749
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2674626750
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2674726751
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26755,6 +26759,8 @@ collection._UserDoubleLinkedQueueEntry$ = dart.generic(E => {
2675526759
})
2675626760
});
2675726761
return _UserDoubleLinkedQueueEntry;
26762+
}, _UserDoubleLinkedQueueEntry => {
26763+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2675826764
});
2675926765
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2676026766
const _queue = Symbol('_queue');
@@ -26784,7 +26790,6 @@ collection._DoubleLinkedQueueEntry$ = dart.generic(E => {
2678426790
return this[_previousLink][_asNonSentinelEntry]();
2678526791
}
2678626792
}
26787-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2678826793
dart.setSignature(_DoubleLinkedQueueEntry, {
2678926794
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2679026795
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26796,6 +26801,8 @@ collection._DoubleLinkedQueueEntry$ = dart.generic(E => {
2679626801
})
2679726802
});
2679826803
return _DoubleLinkedQueueEntry;
26804+
}, _DoubleLinkedQueueEntry => {
26805+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2679926806
});
2680026807
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2680126808
const _elementCount = Symbol('_elementCount');

0 commit comments

Comments
 (0)