Skip to content

Commit 83bd1bc

Browse files
committed
Fix wildcard generic types in params not being checked
1 parent b98baf0 commit 83bd1bc

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

lib/preprocess/parameterproperty/ParameterPropertyHandlerRange.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ export class ParameterPropertyHandlerRange implements IParameterPropertyHandler
381381
genericsContext,
382382
undefined,
383383
[],
384-
)) {
384+
) && !this.hasParamValueValidType(value, type, genericTypeInstance, genericsContext)) {
385385
// If the generic type instance is just a type, check it against the value in the inner context.
386-
// If it does not match, return false.
386+
// If it does not match (either is not of that type, or the param type does not match), return false.
387387
return false;
388388
}
389389
}

test/unit/preprocess/parameterproperty/ParameterPropertyHandlerRange-test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,52 @@ describe('ParameterPropertyHandlerRange', () => {
18041804
}));
18051805
});
18061806

1807+
it(`should handle a generic component with value a sub-type with fixed generic with wildcard param generic`, () => {
1808+
genericsContext = new GenericsContext(objectLoader, []);
1809+
1810+
const value = handler.captureType(
1811+
objectLoader.createCompactedResource({
1812+
'@type': {
1813+
'@id': 'ex:SomeType1',
1814+
extends: {
1815+
'@type': 'GenericComponentExtension',
1816+
component: {
1817+
'@id': 'ex:SomeType2',
1818+
genericTypeParameters: [
1819+
'ex:SomeType2__generic_T',
1820+
],
1821+
},
1822+
genericTypeInstances: [
1823+
'xsd:integer',
1824+
],
1825+
},
1826+
},
1827+
}),
1828+
objectLoader.createCompactedResource({
1829+
range: {
1830+
'@type': 'ParameterRangeGenericComponent',
1831+
component: 'ex:SomeType2',
1832+
genericTypeInstances: [
1833+
{
1834+
'@type': 'ParameterRangeWildcard',
1835+
},
1836+
],
1837+
},
1838+
}),
1839+
genericsContext,
1840+
);
1841+
expect(value).toBeTruthy();
1842+
expectOutputProperties(value, objectLoader.createCompactedResource({
1843+
'@type': [ 'ex:SomeType1' ],
1844+
genericTypeInstancesComponentScope: 'ex:SomeType2',
1845+
genericTypeInstances: [
1846+
{
1847+
'@type': 'ParameterRangeWildcard',
1848+
},
1849+
],
1850+
}));
1851+
});
1852+
18071853
it(`should throw on a generic component with value a sub-type with fixed generic with incompatible fixed param generic`, () => {
18081854
genericsContext = new GenericsContext(objectLoader, []);
18091855

0 commit comments

Comments
 (0)