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
 import org.openzen.zenscript.codemodel.expression.StorageCastExpression;
20
 import org.openzen.zenscript.codemodel.expression.StorageCastExpression;
21
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
21
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
22
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
22
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
23
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
23
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
24
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
24
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
26
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
430
    
431
    
431
 		if( getImplicitCaster(toType) != null || extendsOrImplements(toType.type))
432
 		if( getImplicitCaster(toType) != null || extendsOrImplements(toType.type))
432
 		    return true;
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
         final StoredType accept = type.type.accept(new TagRemovingTypeVisitor(cache));
443
         final StoredType accept = type.type.accept(new TagRemovingTypeVisitor(cache));
444
+
435
         if(!this.type.type.equals(accept.type) && cache.get(accept).canCastImplicit(toType)){
445
         if(!this.type.type.equals(accept.type) && cache.get(accept).canCastImplicit(toType)){
436
             return true;
446
             return true;
437
         }
447
         }

Loading…
Cancel
Save