Browse Source

CheckCast after MapGet if not primitive

Required for Type assertion, else a 'Object is not assignable to X' will follow
kindlich 4 years ago
parent
commit
fb280d54ed
No known key found for this signature in database

+ 3
- 0
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java View File

934
 				javaWriter.invokeInterface(MAP_GET);
934
 				javaWriter.invokeInterface(MAP_GET);
935
 
935
 
936
 				type.valueType.type.accept(type.valueType, unboxingTypeVisitor);
936
 				type.valueType.type.accept(type.valueType, unboxingTypeVisitor);
937
+				if(!CompilerUtils.isPrimitive(type.valueType.type)) {
938
+					javaWriter.checkCast(context.getType(type.valueType));
939
+				}
937
 				break;
940
 				break;
938
 			}
941
 			}
939
 			case ASSOC_INDEXSET:
942
 			case ASSOC_INDEXSET:

Loading…
Cancel
Save