Skip to content

Commit 37029a2

Browse files
author
Jennifer Messerly
committed
fix #27336, ddc with recursive generic class type args
[email protected] Review URL: https://codereview.chromium.org/2516483002 .
1 parent f670a46 commit 37029a2

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

+42-35
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);
@@ -26760,7 +26765,6 @@ define([], function() {
2676026765
return this[_nextLink];
2676126766
}
2676226767
}
26763-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2676426768
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2676526769
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2676626770
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26774,6 +26778,8 @@ define([], function() {
2677426778
})
2677526779
});
2677626780
return _UserDoubleLinkedQueueEntry;
26781+
}, _UserDoubleLinkedQueueEntry => {
26782+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2677726783
});
2677826784
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2677926785
const _queue = Symbol('_queue');
@@ -26803,7 +26809,6 @@ define([], function() {
2680326809
return this[_previousLink][_asNonSentinelEntry]();
2680426810
}
2680526811
}
26806-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2680726812
dart.setSignature(_DoubleLinkedQueueEntry, {
2680826813
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2680926814
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26815,6 +26820,8 @@ define([], function() {
2681526820
})
2681626821
});
2681726822
return _DoubleLinkedQueueEntry;
26823+
}, _DoubleLinkedQueueEntry => {
26824+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2681826825
});
2681926826
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2682026827
const _elementCount = Symbol('_elementCount');

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

+42-35
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);
@@ -26760,7 +26765,6 @@
2676026765
return this[_nextLink];
2676126766
}
2676226767
}
26763-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2676426768
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2676526769
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2676626770
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26774,6 +26778,8 @@
2677426778
})
2677526779
});
2677626780
return _UserDoubleLinkedQueueEntry;
26781+
}, _UserDoubleLinkedQueueEntry => {
26782+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2677726783
});
2677826784
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2677926785
const _queue = Symbol('_queue');
@@ -26803,7 +26809,6 @@
2680326809
return this[_previousLink][_asNonSentinelEntry]();
2680426810
}
2680526811
}
26806-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2680726812
dart.setSignature(_DoubleLinkedQueueEntry, {
2680826813
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2680926814
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26815,6 +26820,8 @@
2681526820
})
2681626821
});
2681726822
return _DoubleLinkedQueueEntry;
26823+
}, _DoubleLinkedQueueEntry => {
26824+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2681826825
});
2681926826
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2682026827
const _elementCount = Symbol('_elementCount');

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

+42-35
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);
@@ -26758,7 +26763,6 @@ collection._UserDoubleLinkedQueueEntry$ = dart.generic(E => {
2675826763
return this[_nextLink];
2675926764
}
2676026765
}
26761-
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2676226766
_UserDoubleLinkedQueueEntry[dart.implements] = () => [DoubleLinkedQueueEntryOfE()];
2676326767
dart.setSignature(_UserDoubleLinkedQueueEntry, {
2676426768
constructors: () => ({new: dart.definiteFunctionType(collection._UserDoubleLinkedQueueEntry$(E), [E])}),
@@ -26772,6 +26776,8 @@ collection._UserDoubleLinkedQueueEntry$ = dart.generic(E => {
2677226776
})
2677326777
});
2677426778
return _UserDoubleLinkedQueueEntry;
26779+
}, _UserDoubleLinkedQueueEntry => {
26780+
dart.setBaseClass(_UserDoubleLinkedQueueEntry, collection._DoubleLink$(_UserDoubleLinkedQueueEntry));
2677526781
});
2677626782
collection._UserDoubleLinkedQueueEntry = _UserDoubleLinkedQueueEntry();
2677726783
const _queue = Symbol('_queue');
@@ -26801,7 +26807,6 @@ collection._DoubleLinkedQueueEntry$ = dart.generic(E => {
2680126807
return this[_previousLink][_asNonSentinelEntry]();
2680226808
}
2680326809
}
26804-
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2680526810
dart.setSignature(_DoubleLinkedQueueEntry, {
2680626811
constructors: () => ({new: dart.definiteFunctionType(collection._DoubleLinkedQueueEntry$(E), [DoubleLinkedQueueOfE()])}),
2680726812
fields: () => ({[_queue]: DoubleLinkedQueueOfE()}),
@@ -26813,6 +26818,8 @@ collection._DoubleLinkedQueueEntry$ = dart.generic(E => {
2681326818
})
2681426819
});
2681526820
return _DoubleLinkedQueueEntry;
26821+
}, _DoubleLinkedQueueEntry => {
26822+
dart.setBaseClass(_DoubleLinkedQueueEntry, collection._DoubleLink$(_DoubleLinkedQueueEntry));
2681626823
});
2681726824
collection._DoubleLinkedQueueEntry = _DoubleLinkedQueueEntry();
2681826825
const _elementCount = Symbol('_elementCount');

0 commit comments

Comments
 (0)