Browse Source

Maybe fixed type arguments, added more logger info

Jared 5 years ago
parent
commit
1d02904fea
No account linked to committer's email address

+ 9
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import org.openzen.zenscript.codemodel.GenericName;
9
-import java.util.Arrays;
10
-import java.util.HashMap;
11
-import java.util.List;
12
-import java.util.Map;
13
-import java.util.Objects;
14
-import java.util.Set;
15
 import org.openzen.zenscript.codemodel.GenericMapper;
8
 import org.openzen.zenscript.codemodel.GenericMapper;
9
+import org.openzen.zenscript.codemodel.GenericName;
16
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
17
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
11
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
18
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
12
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
21
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
15
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
22
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
23
 
17
 
18
+import java.util.Arrays;
19
+import java.util.HashMap;
20
+import java.util.List;
21
+import java.util.Map;
22
+import java.util.Objects;
23
+import java.util.Set;
24
+
24
 /**
25
 /**
25
  *
26
  *
26
  * @author Hoofdgebruiker
27
  * @author Hoofdgebruiker
42
 		if (typeArguments == null)
43
 		if (typeArguments == null)
43
 			throw new NullPointerException("typeParameters cannot be null");
44
 			throw new NullPointerException("typeParameters cannot be null");
44
 		if (typeArguments.length != definition.getNumberOfGenericParameters())
45
 		if (typeArguments.length != definition.getNumberOfGenericParameters())
45
-			throw new IllegalArgumentException("Wrong number of type parameters!");
46
+			throw new IllegalArgumentException("Wrong number of type parameters! " + definition.name + " expected: " + definition.getNumberOfGenericParameters() + " got: " + typeArguments.length);
46
 		if (definition.isInnerDefinition() && !definition.isStatic() && outer == null)
47
 		if (definition.isInnerDefinition() && !definition.isStatic() && outer == null)
47
 			throw new IllegalArgumentException("Inner definition requires outer instance");
48
 			throw new IllegalArgumentException("Inner definition requires outer instance");
48
 		if ((!definition.isInnerDefinition() || definition.isStatic()) && outer != null)
49
 		if ((!definition.isInnerDefinition() || definition.isStatic()) && outer != null)

+ 4
- 4
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

300
 
300
 
301
 		TypeVariableContext context = new TypeVariableContext();
301
 		TypeVariableContext context = new TypeVariableContext();
302
 		TypeVariable<Class<T>>[] javaTypeParameters = cls.getTypeParameters();
302
 		TypeVariable<Class<T>>[] javaTypeParameters = cls.getTypeParameters();
303
-		TypeParameter[] typeParameters = new TypeParameter[cls.getTypeParameters().length];
303
+        definition.typeParameters = new TypeParameter[cls.getTypeParameters().length];
304
 		for (int i = 0; i < javaTypeParameters.length; i++) {
304
 		for (int i = 0; i < javaTypeParameters.length; i++) {
305
 			TypeVariable<Class<T>> typeVariable = javaTypeParameters[i];
305
 			TypeVariable<Class<T>> typeVariable = javaTypeParameters[i];
306
 			TypeParameter parameter = new TypeParameter(CodePosition.NATIVE, typeVariable.getName());
306
 			TypeParameter parameter = new TypeParameter(CodePosition.NATIVE, typeVariable.getName());
308
 				TypeID type = loadType(context, bound).type;
308
 				TypeID type = loadType(context, bound).type;
309
 				parameter.addBound(new ParameterTypeBound(CodePosition.NATIVE, type));
309
 				parameter.addBound(new ParameterTypeBound(CodePosition.NATIVE, type));
310
 			}
310
 			}
311
-			typeParameters[i] = parameter;
311
+            definition.typeParameters[i] = parameter;
312
 			context.put(typeVariable, parameter);
312
 			context.put(typeVariable, parameter);
313
 		}
313
 		}
314
-
314
+  
315
 		if (definition instanceof ClassDefinition && cls.getAnnotatedSuperclass() != null && shouldLoadType(cls.getAnnotatedSuperclass().getType())) {
315
 		if (definition instanceof ClassDefinition && cls.getAnnotatedSuperclass() != null && shouldLoadType(cls.getAnnotatedSuperclass().getType())) {
316
 			definition.setSuperType(loadType(context, cls.getAnnotatedSuperclass()).type);
316
 			definition.setSuperType(loadType(context, cls.getAnnotatedSuperclass()).type);
317
 		}
317
 		}
329
 			}
329
 			}
330
 		}
330
 		}
331
 		
331
 		
332
-		definition.typeParameters = typeParameters;
332
+		
333
 		compiled.setClassInfo(definition, javaClass);
333
 		compiled.setClassInfo(definition, javaClass);
334
 		
334
 		
335
 		StoredType thisType = new StoredType(registry.getForMyDefinition(definition), AutoStorageTag.INSTANCE);
335
 		StoredType thisType = new StoredType(registry.getForMyDefinition(definition), AutoStorageTag.INSTANCE);

Loading…
Cancel
Save