Browse Source

Checkcast may not work that well with primitives ^^'

kindlich 4 years ago
parent
commit
5cba6fc7b0
No known key found for this signature in database

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

932
 				javaWriter.invokeInterface(MAP_GET);
932
 				javaWriter.invokeInterface(MAP_GET);
933
 
933
 
934
 				AssocTypeID type = (AssocTypeID) expression.target.type.type;
934
 				AssocTypeID type = (AssocTypeID) expression.target.type.type;
935
-				javaWriter.checkCast(context.getInternalName(type.valueType));
935
+				type.valueType.type.accept(type.valueType, unboxingTypeVisitor);
936
 				break;
936
 				break;
937
 			}
937
 			}
938
 			case ASSOC_INDEXSET:
938
 			case ASSOC_INDEXSET:
2167
 	public Void visitGetField(GetFieldExpression expression) {
2167
 	public Void visitGetField(GetFieldExpression expression) {
2168
 		expression.target.accept(this);
2168
 		expression.target.accept(this);
2169
 		getField(expression.field);
2169
 		getField(expression.field);
2170
-		javaWriter.checkCast(context.getType(expression.field.getType()));
2170
+		if(!CompilerUtils.isPrimitive(expression.field.member.getType().type)) {
2171
+			javaWriter.checkCast(context.getType(expression.field.getType()));
2172
+		}
2171
 		return null;
2173
 		return null;
2172
 	}
2174
 	}
2173
 
2175
 
2217
 		if (builtin == null) {
2219
 		if (builtin == null) {
2218
 			if (context.hasJavaField(expression.getter)) {
2220
 			if (context.hasJavaField(expression.getter)) {
2219
 				javaWriter.getField(context.getJavaField(expression.getter));
2221
 				javaWriter.getField(context.getJavaField(expression.getter));
2220
-				javaWriter.checkCast(context.getType(expression.getter.getType()));
2222
+				if(!CompilerUtils.isPrimitive(expression.getter.member.getType().type)) {
2223
+					javaWriter.checkCast(context.getType(expression.getter.getType()));
2224
+				}
2221
 				return null;
2225
 				return null;
2222
 			}
2226
 			}
2223
 
2227
 
2234
 
2238
 
2235
 			if (!checkAndExecuteMethodInfo(expression.getter, expression.type, expression))
2239
 			if (!checkAndExecuteMethodInfo(expression.getter, expression.type, expression))
2236
 				throw new IllegalStateException("Call target has no method info!");
2240
 				throw new IllegalStateException("Call target has no method info!");
2237
-
2238
-			javaWriter.checkCast(context.getType(expression.getter.getType()));
2241
+			if(!CompilerUtils.isPrimitive(expression.getter.member.getType().type)) {
2242
+				javaWriter.checkCast(context.getType(expression.getter.getType()));
2243
+			}
2239
 			return null;
2244
 			return null;
2240
 		}
2245
 		}
2241
 
2246
 

Loading…
Cancel
Save