forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java
modified: src/test/java/targetast/TestComplete.java
This commit is contained in:
parent
f68afc88a6
commit
42821f3215
@ -13,6 +13,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.DebugException;
|
import de.dhbwstuttgart.exceptions.DebugException;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IRuleSet;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IRuleSet;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
|
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
|
||||||
@ -390,26 +391,51 @@ public class RuleSet implements IRuleSet{
|
|||||||
if((pair.getPairOp() != PairOperator.SMALLERDOT) && (pair.getPairOp() != PairOperator.SMALLERNEQDOT))
|
if((pair.getPairOp() != PairOperator.SMALLERDOT) && (pair.getPairOp() != PairOperator.SMALLERNEQDOT))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pair.getPairOp() == PairOperator.SMALLERNEQDOT) {
|
UnifyType lhsType = pair.getLhsType();
|
||||||
UnifyType lhs = pair.getLhsType();
|
UnifyType rhsType = pair.getRhsType();
|
||||||
UnifyType rhs = pair.getRhsType();
|
|
||||||
if (lhs instanceof WildcardType) {
|
/*
|
||||||
lhs = ((WildcardType)lhs).getWildcardedType();
|
* ty <. ? extends ty' is wrong
|
||||||
}
|
*/
|
||||||
if (rhs instanceof WildcardType) {
|
if (rhsType instanceof ExtendsType) {
|
||||||
rhs = ((WildcardType)rhs).getWildcardedType();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lhs.equals(rhs)){
|
/*
|
||||||
return false;
|
* ? super ty <. ty' is wrong
|
||||||
}
|
* except Ty' = Object or ty' = ? super Object
|
||||||
|
*/
|
||||||
|
if ((lhsType instanceof SuperType) &&
|
||||||
|
(!(rhsType.equals(new ReferenceType("java.lang.Object", false)))) &&
|
||||||
|
!(rhsType.equals(new SuperType (new ReferenceType("java.lang.Object", false))))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ? extends ty <. ty' is equivalent to ty < ty'
|
||||||
|
*/
|
||||||
|
if (lhsType instanceof ExtendsType) {
|
||||||
|
lhsType = ((WildcardType)lhsType).getWildcardedType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ty <. ? super ty' ist equivalent to ty <. ty'
|
||||||
|
*/
|
||||||
|
if (rhsType instanceof SuperType) {
|
||||||
|
rhsType = ((WildcardType)rhsType).getWildcardedType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SMALLERNEQDOT => type must not be equal
|
||||||
|
*/
|
||||||
|
if (pair.getPairOp() == PairOperator.SMALLERNEQDOT && lhsType.equals(rhsType)){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnifyType lhsType = pair.getLhsType();
|
|
||||||
if(!(lhsType instanceof ReferenceType) && !(lhsType instanceof PlaceholderType))
|
if(!(lhsType instanceof ReferenceType) && !(lhsType instanceof PlaceholderType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
UnifyType rhsType = pair.getRhsType();
|
|
||||||
if(!(rhsType instanceof ReferenceType) && !(rhsType instanceof PlaceholderType))
|
if(!(rhsType instanceof ReferenceType) && !(rhsType instanceof PlaceholderType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -279,6 +279,12 @@ public class TestComplete {
|
|||||||
assertEquals(result, instanceOfClass_m3);
|
assertEquals(result, instanceOfClass_m3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void scalarTest() throws Exception {
|
||||||
|
var classFiles = generateClassFiles("Scalar.jav", new ByteArrayClassLoader());
|
||||||
|
var scalar = classFiles.get("Scalar");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mergeTest() throws Exception {
|
public void mergeTest() throws Exception {
|
||||||
var classFiles = generateClassFiles("Merge.jav", new ByteArrayClassLoader());
|
var classFiles = generateClassFiles("Merge.jav", new ByteArrayClassLoader());
|
||||||
|
Loading…
Reference in New Issue
Block a user