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,7 +932,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
932 932
 				javaWriter.invokeInterface(MAP_GET);
933 933
 
934 934
 				AssocTypeID type = (AssocTypeID) expression.target.type.type;
935
-				javaWriter.checkCast(context.getInternalName(type.valueType));
935
+				type.valueType.type.accept(type.valueType, unboxingTypeVisitor);
936 936
 				break;
937 937
 			}
938 938
 			case ASSOC_INDEXSET:
@@ -2167,7 +2167,9 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
2167 2167
 	public Void visitGetField(GetFieldExpression expression) {
2168 2168
 		expression.target.accept(this);
2169 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 2173
 		return null;
2172 2174
 	}
2173 2175
 
@@ -2217,7 +2219,9 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
2217 2219
 		if (builtin == null) {
2218 2220
 			if (context.hasJavaField(expression.getter)) {
2219 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 2225
 				return null;
2222 2226
 			}
2223 2227
 
@@ -2234,8 +2238,9 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
2234 2238
 
2235 2239
 			if (!checkAndExecuteMethodInfo(expression.getter, expression.type, expression))
2236 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 2244
 			return null;
2240 2245
 		}
2241 2246
 

Loading…
Cancel
Save