Browse Source

[WIP, not sure] Added generic types checking if their bounds are met

Before it they would simply return false, even if a type would match the bounds
kindlich 5 years ago
parent
commit
49043637e1
No known key found for this signature in database

+ 11
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java View File

@@ -20,6 +20,7 @@ import org.openzen.zenscript.codemodel.expression.NullExpression;
20 20
 import org.openzen.zenscript.codemodel.expression.StorageCastExpression;
21 21
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
22 22
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
23
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
23 24
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
24 25
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25 26
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
@@ -430,8 +431,17 @@ public final class TypeMembers {
430 431
    
431 432
 		if( getImplicitCaster(toType) != null || extendsOrImplements(toType.type))
432 433
 		    return true;
433
-		
434
+
435
+		if(type.type.isGeneric() && type.type instanceof GenericTypeID) {
436
+			final GenericTypeID genericTypeID = (GenericTypeID) type.type;
437
+			if(genericTypeID.parameter.matches(cache, toType.type)) {
438
+				return true;
439
+			}
440
+		}
441
+
442
+
434 443
         final StoredType accept = type.type.accept(new TagRemovingTypeVisitor(cache));
444
+
435 445
         if(!this.type.type.equals(accept.type) && cache.get(accept).canCastImplicit(toType)){
436 446
             return true;
437 447
         }

Loading…
Cancel
Save