Browse Source

Match vararg types implicitly

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

+ 13
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

252
 			return false;
252
 			return false;
253
 		
253
 		
254
 		FunctionHeader header = fillGenericArguments(position, scope, arguments.typeArguments);
254
 		FunctionHeader header = fillGenericArguments(position, scope, arguments.typeArguments);
255
+		if(isVariadic()) {
256
+		    boolean matches = true;
257
+            for (int i = 0; i < arguments.arguments.length; i++) {
258
+                if (!scope.getTypeMembers(arguments.arguments[i].type).canCastImplicit(header.getParameterType(true, i))) {
259
+                    matches = false;
260
+                    break;
261
+                }
262
+            }
263
+            if(matches) {
264
+                return true;
265
+            }
266
+        }
267
+		
255
 		for (int i = 0; i < arguments.arguments.length; i++) {
268
 		for (int i = 0; i < arguments.arguments.length; i++) {
256
 			if (!scope.getTypeMembers(arguments.arguments[i].type).canCastImplicit(header.parameters[i].type))
269
 			if (!scope.getTypeMembers(arguments.arguments[i].type).canCastImplicit(header.parameters[i].type))
257
 				return false;
270
 				return false;

Loading…
Cancel
Save