Fix subscript access on raw collection references (#1993)
This commit is contained in:
1 parent
c3d555d49c
commit
a7dc007cb4
3 files changed
+19
-1
No files matched your search
@@ -288,11 +288,20 @@ public final class VmReference extends VmValue {
|
||||
if (!(key instanceof Long)) {
|
||||
throw new VmReferenceAccessError(type, VmReferenceAccessErrorType.CANNOT_FIND_MEMBER);
|
||||
}
|
||||
normalizeTypes(ct.getTypeArguments()[0], clazz, clazz.getModuleClass(), result);
|
||||
var typeArgs = ct.getTypeArguments();
|
||||
if (typeArgs.length == 0) {
|
||||
result.add(UnknownType.INSTANCE);
|
||||
return;
|
||||
}
|
||||
normalizeTypes(typeArgs[0], clazz, clazz.getModuleClass(), result);
|
||||
return;
|
||||
}
|
||||
if (clazz.isMappingClass() || clazz.isMapClass()) {
|
||||
var typeArgs = ct.getTypeArguments();
|
||||
if (typeArgs.length == 0) {
|
||||
result.add(UnknownType.INSTANCE);
|
||||
return;
|
||||
}
|
||||
var keyTypes = normalizeTypes(typeArgs[0], clazz, clazz.getModuleClass());
|
||||
for (var kt : iterateTypes(keyTypes)) {
|
||||
if (kt == UnknownType.INSTANCE
|
||||
|
||||
@@ -150,6 +150,11 @@ mappingAnyKey = Ref<TypeHolder>(null).mappingAnyKey["foo"]
|
||||
// because VmListing/VmMapping don't track their type args
|
||||
mappingTypeArgKey = Ref<TypeHolder>(null).mappingTypeArgKey[new Listing<String> { "foo" }]
|
||||
|
||||
rawListingSubscript = Ref<Listing>(null)[0].foo
|
||||
rawListSubscript = Ref<List>(null)[1].foo
|
||||
rawMappingSubscript = Ref<Mapping>(null)["bar"].foo
|
||||
rawMapSubscript = Ref<Map>(null)[2].foo
|
||||
|
||||
output {
|
||||
renderer {
|
||||
converters {
|
||||
|
||||
@@ -66,3 +66,7 @@ bareFunctionType = "Expected value of type `pkl.ref#Reference<reference#D, Strin
|
||||
constraintInConstructor = "${null}"
|
||||
mappingAnyKey = "${null.mappingAnyKey[foo]}"
|
||||
mappingTypeArgKey = "${null.mappingTypeArgKey[new Listing { \"foo\" }]}"
|
||||
rawListingSubscript = "${null[0].foo}"
|
||||
rawListSubscript = "${null[1].foo}"
|
||||
rawMappingSubscript = "${null[bar].foo}"
|
||||
rawMapSubscript = "${null[2].foo}"
|
||||
Reference in new issue
Block a user