|
20 | 20 | import org.openzen.zenscript.codemodel.type.*; |
21 | 21 | import org.openzen.zenscript.codemodel.type.member.*; |
22 | 22 | import org.openzen.zenscript.javashared.*; |
| 23 | +import org.openzen.zenscript.javashared.types.JavaFunctionalInterfaceTypeID; |
23 | 24 | import org.openzen.zenscript.lexer.*; |
24 | 25 | import org.openzen.zenscript.parser.*; |
25 | 26 | import org.openzen.zenscript.parser.expression.*; |
@@ -889,20 +890,14 @@ private FunctionHeader getHeader( |
889 | 890 | Expression defaultValue = getDefaultValue(parameter, type); |
890 | 891 | parameters[i] = new FunctionParameter(type, parameter.getName(), defaultValue, parameter.isVarArgs()); |
891 | 892 | } |
892 | | - |
893 | | - TypeParameter[] typeParameters = new TypeParameter[javaTypeParameters.length]; |
894 | | - for (int i = 0; i < javaTypeParameters.length; i++) { |
895 | | - TypeVariable<Method> javaTypeParameter = javaTypeParameters[i]; |
896 | | - typeParameters[i] = new TypeParameter(CodePosition.UNKNOWN, javaTypeParameter.getName()); |
897 | | - context.put(javaTypeParameter, typeParameters[i]); |
898 | | - |
899 | | - for (AnnotatedType bound : javaTypeParameter.getAnnotatedBounds()) |
900 | | - typeParameters[i].addBound(new ParameterTypeBound(CodePosition.NATIVE, loadType(context, bound))); |
| 893 | + if (classParameters > 0 && classParameters == typeParameters.length) { |
| 894 | + parameters = Arrays.copyOfRange(parameters, classParameters, parameters.length); |
901 | 895 | } |
902 | | - |
| 896 | + |
903 | 897 | if (exceptionTypes.length > 1) |
904 | 898 | throw new IllegalArgumentException("A method can only throw a single exception type!"); |
905 | 899 |
|
| 900 | + TypeID returnType = javaReturnType == null ? BasicTypeID.VOID : loadStoredType(context, javaReturnType); |
906 | 901 | TypeID thrownType = exceptionTypes.length == 0 ? null : loadStoredType(context, exceptionTypes[0]); |
907 | 902 | return new FunctionHeader(typeParameters, returnType, thrownType, parameters); |
908 | 903 | } |
@@ -931,7 +926,7 @@ else if (annotatedType.isAnnotationPresent(ZenCodeType.NullableUSize.class)) |
931 | 926 | return loadType(context, annotatedType, nullable, unsigned); |
932 | 927 | } |
933 | 928 |
|
934 | | - private TypeID loadType(TypeVariableContext context, Type type, boolean nullable, boolean unsigned) { |
| 929 | + private TypeID loadType(TypeVariableContext context, AnnotatedElement type, boolean nullable, boolean unsigned) { |
935 | 930 | TypeID result = loadType(context, type, unsigned); |
936 | 931 | if (nullable) |
937 | 932 | result = registry.getOptional(result); |
@@ -1045,7 +1040,7 @@ private TypeID loadFunctionalInterface(TypeVariableContext loadContext, Class<?> |
1045 | 1040 | getMethodDescriptor(functionalInterfaceMethod), |
1046 | 1041 | JavaModifiers.PUBLIC | JavaModifiers.ABSTRACT, |
1047 | 1042 | header.getReturnType().isGeneric()); |
1048 | | - return registry.getFunction(header); |
| 1043 | + return new JavaFunctionalInterfaceTypeID(registry, header, functionalInterfaceMethod, method); |
1049 | 1044 | } |
1050 | 1045 |
|
1051 | 1046 | private <T> TypeVariableContext convertTypeParameters(Class<T> cls) { |
|
0 commit comments