Browse Source

Fixed compilation with generic arguments

kindlich 4 years ago
parent
commit
45029d5e80
No known key found for this signature in database

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

@@ -49,15 +49,16 @@ public class CompilerUtils {
49 49
 	}
50 50
 
51 51
     public static void tagMethodParameters(JavaBytecodeContext context, JavaCompiledModule module, FunctionHeader header, boolean isStatic) {
52
-		int index = header.getNumberOfTypeParameters();
52
+		int index = isStatic ? 0 : 1;
53 53
 		for (int i = 0; i < header.typeParameters.length; i++) {
54 54
 			TypeParameter parameter = header.typeParameters[i];
55
-			module.setTypeParameterInfo(parameter, new JavaTypeParameterInfo(index++));
55
+			module.setTypeParameterInfo(parameter, new JavaTypeParameterInfo(index));
56
+			index++;
56 57
 		}
57 58
         for (int i = 0; i < header.parameters.length; i++) {
58 59
             FunctionParameter parameter = header.parameters[i];
59 60
             String parameterType = context.getDescriptor(parameter.type);
60
-            module.setParameterInfo(parameter, new JavaParameterInfo(isStatic ? index : index + 1, parameterType));
61
+            module.setParameterInfo(parameter, new JavaParameterInfo(index, parameterType));
61 62
 			index++;
62 63
         }
63 64
     }

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

@@ -67,14 +67,15 @@ public class JavaWriter {
67 67
 		this.method = method;
68 68
 		this.forDefinition = forDefinition;
69 69
 		this.position = position;
70
-		
71
-		final MethodVisitor methodVisitor = visitor.visitMethod(isExtension ? method.modifiers | Opcodes.ACC_STATIC : method.modifiers, method.name, descriptor, signature, exceptions);
70
+
71
+		final int access = isExtension ? method.modifiers | ACC_STATIC : method.modifiers;
72
+		final MethodVisitor methodVisitor = visitor.visitMethod(access, method.name, descriptor, signature, exceptions);
72 73
 		
73 74
 		for (String annotation : annotations) {
74 75
 			methodVisitor.visitAnnotation(annotation, true).visitEnd();
75 76
 		}
76 77
 		
77
-		this.visitor = new LocalVariablesSorter(isExtension ? method.modifiers | Opcodes.ACC_STATIC : method.modifiers, descriptor, methodVisitor);
78
+		this.visitor = new LocalVariablesSorter(access, descriptor, methodVisitor);
78 79
 		this.nameVariables = nameVariables;
79 80
 	}
80 81
 	

Loading…
Cancel
Save