forked from JavaTX/JavaCompilerCore
various
This commit is contained in:
parent
27acee3385
commit
6778160315
@ -4,7 +4,6 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public interface IRuleSet {
|
public interface IRuleSet {
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
import de.dhbwstuttgart.typeinference.unify.model.Unifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard unification algorithm (e.g. Robinson, Paterson-Wegman, Martelli-Montanari)
|
* Standard unification algorithm (e.g. Robinson, Paterson-Wegman, Martelli-Montanari)
|
||||||
|
@ -3,16 +3,30 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An extends wildcard type "? extends T".
|
||||||
|
*/
|
||||||
public final class ExtendsType extends Type {
|
public final class ExtendsType extends Type {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The extended type
|
||||||
|
*/
|
||||||
private Type extendedType;
|
private Type extendedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new extends wildcard type.
|
||||||
|
* @param extendedType The extended type e.g. Integer in "? extends Integer"
|
||||||
|
*/
|
||||||
public ExtendsType(Type extendedType) {
|
public ExtendsType(Type extendedType) {
|
||||||
super("? extends " + extendedType.getName(), extendedType.getTypeParams());
|
super("? extends " + extendedType.getName(), extendedType.getTypeParams());
|
||||||
this.extendedType = extendedType;
|
this.extendedType = extendedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type extended by this wildcard e.g. "Integer" for "? extends Integer"
|
||||||
|
* @return The extended type.
|
||||||
|
*/
|
||||||
public Type getExtendedType() {
|
public Type getExtendedType() {
|
||||||
return extendedType;
|
return extendedType;
|
||||||
}
|
}
|
||||||
@ -23,20 +37,20 @@ public final class ExtendsType extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
Set<Type> smArg(IFiniteClosure fc) {
|
||||||
return "? extends " + extendedType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Type> smArg(IFiniteClosure fc) {
|
|
||||||
return fc.smArg(this);
|
return fc.smArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> grArg(IFiniteClosure fc) {
|
Set<Type> grArg(IFiniteClosure fc) {
|
||||||
return fc.grArg(this);
|
return fc.grArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Type apply(Unifier unif) {
|
||||||
|
return new ExtendsType(extendedType.apply(unif));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return extendedType.hashCode() + 17;
|
return extendedType.hashCode() + 17;
|
||||||
@ -52,7 +66,7 @@ public final class ExtendsType extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type apply(Unifier unif) {
|
public String toString() {
|
||||||
return new ExtendsType(extendedType.apply(unif));
|
return "? extends " + extendedType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public final class PlaceholderType extends Type{
|
public final class PlaceholderType extends Type{
|
||||||
|
|
||||||
@ -12,12 +11,12 @@ public final class PlaceholderType extends Type{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> smArg(IFiniteClosure fc) {
|
Set<Type> smArg(IFiniteClosure fc) {
|
||||||
return fc.smArg(this);
|
return fc.smArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> grArg(IFiniteClosure fc) {
|
Set<Type> grArg(IFiniteClosure fc) {
|
||||||
return fc.grArg(this);
|
return fc.grArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +25,13 @@ public final class PlaceholderType extends Type{
|
|||||||
return typeName.hashCode();
|
return typeName.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Type apply(Unifier unif) {
|
||||||
|
if(unif.hasSubstitute(this))
|
||||||
|
return unif.getSubstitute(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(!(obj instanceof PlaceholderType))
|
if(!(obj instanceof PlaceholderType))
|
||||||
@ -33,11 +39,4 @@ public final class PlaceholderType extends Type{
|
|||||||
|
|
||||||
return ((PlaceholderType) obj).getName().equals(typeName);
|
return ((PlaceholderType) obj).getName().equals(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type apply(Unifier unif) {
|
|
||||||
if(unif.hasSubstitute(this))
|
|
||||||
return unif.getSubstitute(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public final class SimpleType extends Type {
|
public final class SimpleType extends Type {
|
||||||
public SimpleType(String name, Type... typeParams) {
|
public SimpleType(String name, Type... typeParams) {
|
||||||
@ -15,15 +14,20 @@ public final class SimpleType extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> smArg(IFiniteClosure fc) {
|
Set<Type> smArg(IFiniteClosure fc) {
|
||||||
return fc.smArg(this);
|
return fc.smArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> grArg(IFiniteClosure fc) {
|
Set<Type> grArg(IFiniteClosure fc) {
|
||||||
return fc.grArg(this);
|
return fc.grArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Type apply(Unifier unif) {
|
||||||
|
return new SimpleType(typeName, typeParams.apply(unif));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return typeName.hashCode();
|
return typeName.hashCode();
|
||||||
@ -41,9 +45,4 @@ public final class SimpleType extends Type {
|
|||||||
|
|
||||||
return other.getTypeParams().equals(typeParams);
|
return other.getTypeParams().equals(typeParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type apply(Unifier unif) {
|
|
||||||
return new SimpleType(typeName, typeParams.apply(unif));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public final class SuperType extends Type {
|
public final class SuperType extends Type {
|
||||||
|
|
||||||
@ -29,15 +28,20 @@ public final class SuperType extends Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> smArg(IFiniteClosure fc) {
|
Set<Type> smArg(IFiniteClosure fc) {
|
||||||
return fc.smArg(this);
|
return fc.smArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Type> grArg(IFiniteClosure fc) {
|
Set<Type> grArg(IFiniteClosure fc) {
|
||||||
return fc.grArg(this);
|
return fc.grArg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Type apply(Unifier unif) {
|
||||||
|
return new SuperType(superedType.apply(unif));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return superedType.hashCode() + 17;
|
return superedType.hashCode() + 17;
|
||||||
@ -51,9 +55,4 @@ public final class SuperType extends Type {
|
|||||||
SuperType other = (SuperType) obj;
|
SuperType other = (SuperType) obj;
|
||||||
return other.getSuperedType().equals(superedType);
|
return other.getSuperedType().equals(superedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type apply(Unifier unif) {
|
|
||||||
return new SuperType(superedType.apply(unif));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public abstract class Type {
|
public abstract class Type {
|
||||||
|
|
||||||
@ -28,11 +27,11 @@ public abstract class Type {
|
|||||||
return typeParams;
|
return typeParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Set<Type> smArg(IFiniteClosure fc);
|
abstract Set<Type> smArg(IFiniteClosure fc);
|
||||||
|
|
||||||
public abstract Set<Type> grArg(IFiniteClosure fc);
|
abstract Set<Type> grArg(IFiniteClosure fc);
|
||||||
|
|
||||||
public abstract Type apply(Unifier unif);
|
abstract Type apply(Unifier unif);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -3,8 +3,6 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unifynew.Unifier;
|
|
||||||
|
|
||||||
public final class TypeParams implements Iterable<Type>{
|
public final class TypeParams implements Iterable<Type>{
|
||||||
private final Type[] typeParams;
|
private final Type[] typeParams;
|
||||||
|
|
||||||
@ -42,6 +40,20 @@ public final class TypeParams implements Iterable<Type>{
|
|||||||
return new TypeParams(newParams);
|
return new TypeParams(newParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean occurs(PlaceholderType t) {
|
||||||
|
for(Type p : typeParams) {
|
||||||
|
if(p instanceof PlaceholderType) {
|
||||||
|
if(p.equals(t))
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if(p.getTypeParams().occurs(t))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(Type t) {
|
public boolean contains(Type t) {
|
||||||
for(Type t1 : typeParams)
|
for(Type t1 : typeParams)
|
||||||
if(t1.equals(t1))
|
if(t1.equals(t1))
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unifynew;
|
package de.dhbwstuttgart.typeinference.unify.model;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
|
||||||
|
|
||||||
public class Unifier implements Function<Type, Type> {
|
public class Unifier implements Function<Type, Type> {
|
||||||
private HashMap<PlaceholderType, Type> substitutions = new HashMap<>();
|
private HashMap<PlaceholderType, Type> substitutions = new HashMap<>();
|
||||||
|
|
@ -15,6 +15,7 @@ import de.dhbwstuttgart.typeinference.unify.model.MPair.PairOperator;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.Unifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Martelli-Montanari unification algorithm.
|
* Implementation of the Martelli-Montanari unification algorithm.
|
||||||
|
@ -20,6 +20,7 @@ import de.dhbwstuttgart.typeinference.unify.model.SimpleType;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.Unifier;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.MPair.PairOperator;
|
import de.dhbwstuttgart.typeinference.unify.model.MPair.PairOperator;
|
||||||
|
|
||||||
public class RuleSet implements IRuleSet{
|
public class RuleSet implements IRuleSet{
|
||||||
@ -534,35 +535,28 @@ public class RuleSet implements IRuleSet{
|
|||||||
typeMap.put(t2, typeMap.get(t2)+1);
|
typeMap.put(t2, typeMap.get(t2)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue<MPair> result = new LinkedList<MPair>(pairs);
|
ArrayList<MPair> result = new ArrayList<MPair>(pairs);
|
||||||
|
|
||||||
boolean applied = false;
|
boolean applied = false;
|
||||||
|
|
||||||
for(int i = 0; i < result.size(); i++) {
|
for(int i = 0; i < result.size(); i++) {
|
||||||
MPair pair = result.poll();
|
MPair pair = result.get(i);
|
||||||
Type lhsType;
|
PlaceholderType lhsType = null;
|
||||||
Type rhsType;
|
Type rhsType;
|
||||||
|
|
||||||
if(pair.getPairOp() == PairOperator.EQUALSDOT
|
if(pair.getPairOp() == PairOperator.EQUALSDOT
|
||||||
&& ((lhsType = pair.getLhsType()) instanceof PlaceholderType)
|
&& pair.getLhsType() instanceof PlaceholderType)
|
||||||
|
lhsType = (PlaceholderType) pair.getLhsType();
|
||||||
|
if(lhsType != null
|
||||||
&& !((rhsType = pair.getRhsType()) instanceof PlaceholderType)
|
&& !((rhsType = pair.getRhsType()) instanceof PlaceholderType)
|
||||||
&& typeMap.get(lhsType) > 1 // The type occurs in more pairs in the set than just the recent pair.
|
&& typeMap.get(lhsType) > 1 // The type occurs in more pairs in the set than just the recent pair.
|
||||||
&& !occurs(lhsType, rhsType)) {
|
&& !rhsType.getTypeParams().occurs(lhsType)) {
|
||||||
Unifier uni = new Unifier((PlaceholderType) lhsType, rhsType);
|
Unifier uni = new Unifier(lhsType, rhsType);
|
||||||
result = result.stream().map(uni::apply).collect(Collectors.toCollection(LinkedList::new));
|
result = result.stream().map(uni::apply).collect(Collectors.toCollection(ArrayList::new));
|
||||||
applied = true;
|
applied = true;
|
||||||
}
|
}
|
||||||
result.add(pair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return applied ? Optional.of(new HashSet<>(result)) : Optional.empty();
|
return applied ? Optional.of(new HashSet<>(result)) : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean occurs(Type t1, Type t2) {
|
|
||||||
TypeParams t2Params = t2.getTypeParams();
|
|
||||||
for(Type t2Param : t2Params)
|
|
||||||
if(t1.equals(t2Param) || occurs(t1, t2Param))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ public class Unify {
|
|||||||
|
|
||||||
// Sets that originate from pair pattern matching
|
// Sets that originate from pair pattern matching
|
||||||
// Sets of the "second level"
|
// Sets of the "second level"
|
||||||
sets.addAll(calculatePairSets(eq2s, fc));
|
|
||||||
|
|
||||||
|
sets.addAll(calculatePairSets(eq2s, fc));
|
||||||
|
|
||||||
/* Up to here, no cartesian products are calculated.
|
/* Up to here, no cartesian products are calculated.
|
||||||
* Around here, filters for pairs and sets can be applied */
|
* Around here, filters for pairs and sets can be applied */
|
||||||
@ -116,7 +116,7 @@ public class Unify {
|
|||||||
unchanged.addAll(this.unify(eqss, fc));
|
unchanged.addAll(this.unify(eqss, fc));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step 7: Filter result for solved pairs
|
* Step 7: Filter result for solved pairs TODO wie?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return unchanged;
|
return unchanged;
|
||||||
@ -228,13 +228,21 @@ public class Unify {
|
|||||||
IUnify unify = new MartelliMontanariUnify();
|
IUnify unify = new MartelliMontanariUnify();
|
||||||
|
|
||||||
Set<Type> possibleCs = fc.getAllTypes(rhsType.getName());
|
Set<Type> possibleCs = fc.getAllTypes(rhsType.getName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*IUnify unify = new MartelliMontanariUnify();
|
||||||
|
|
||||||
|
Set<Type> possibleCs = fc.getAllTypes(rhsType.getName());
|
||||||
Set<Type> possibleThetas = possibleCs.stream()
|
Set<Type> possibleThetas = possibleCs.stream()
|
||||||
.flatMap(x -> fc.smaller(x).stream())
|
.flatMap(x -> fc.smaller(x).stream())
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
Set<Type> possibleThetaPrimes = possibleThetas.stream()
|
Set<Type> possibleThetaPrimes = possibleThetas.stream()
|
||||||
.flatMap(x -> getAllInstantiations(x, fc).stream())
|
.flatMap(x -> getAllInstantiations(x, fc).stream())
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
*/
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
/*Set<Unifier> unifiers = possibleThetaPrimes.stream()
|
/*Set<Unifier> unifiers = possibleThetaPrimes.stream()
|
||||||
@ -263,7 +271,7 @@ public class Unify {
|
|||||||
|
|
||||||
// Case 2: (a <.? ? ext Theta')
|
// Case 2: (a <.? ? ext Theta')
|
||||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType){
|
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType){
|
||||||
// TODO
|
throw new NotImplementedException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Case 3: (a <.? ? sup Theta')
|
// Case 3: (a <.? ? sup Theta')
|
||||||
@ -299,7 +307,7 @@ public class Unify {
|
|||||||
|
|
||||||
// Case 7: (? sup Theta <.? a)
|
// Case 7: (? sup Theta <.? a)
|
||||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof SuperType && rhsType instanceof PlaceholderType) {
|
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof SuperType && rhsType instanceof PlaceholderType) {
|
||||||
// TODO
|
throw new NotImplementedException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Case 8: (Theta <.? a)
|
// Case 8: (Theta <.? a)
|
||||||
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.MPair.PairOperator;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
import de.dhbwstuttgart.typeinference.unify.model.Type;
|
||||||
|
|
||||||
public class FiniteClosureTest {
|
public class FiniteClosureTest {
|
||||||
@ -54,4 +55,10 @@ public class FiniteClosureTest {
|
|||||||
System.out.println("SmArg(? extends List<T>) = " + fc.smArg(tf.getExtendsType(tf.getSimpleType("List", "T"))));
|
System.out.println("SmArg(? extends List<T>) = " + fc.smArg(tf.getExtendsType(tf.getSimpleType("List", "T"))));
|
||||||
System.out.println("SmArg(? super List<T>) = " + fc.smArg(tf.getSuperType(tf.getSimpleType("List", "T"))));
|
System.out.println("SmArg(? super List<T>) = " + fc.smArg(tf.getSuperType(tf.getSimpleType("List", "T"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetGenericType() {
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,9 @@ public class UnifyTest extends Unify {
|
|||||||
// Double <. B
|
// Double <. B
|
||||||
// B <. Object
|
// B <. Object
|
||||||
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
|
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
|
||||||
|
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Number")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
|
||||||
//eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "C"), PairOperator.SMALLERDOT));
|
//eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "C"), PairOperator.SMALLERDOT));
|
||||||
eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("Integer"), PairOperator.SMALLERDOT));
|
//eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("Integer"), PairOperator.SMALLERDOT));
|
||||||
//eq.add(new MPair(tf.getSimpleType("Number"), tf.getPlaceholderType("A"), PairOperator.SMALLERDOT));
|
//eq.add(new MPair(tf.getSimpleType("Number"), tf.getPlaceholderType("A"), PairOperator.SMALLERDOT));
|
||||||
//eq.add(new MPair(tf.getPlaceholderType("A"), tf.getPlaceholderType("C"), PairOperator.SMALLERDOT));
|
//eq.add(new MPair(tf.getPlaceholderType("A"), tf.getPlaceholderType("C"), PairOperator.SMALLERDOT));
|
||||||
//eq.add(new MPair(tf.getSimpleType("Double"), tf.getPlaceholderType("B"), PairOperator.SMALLERDOT));
|
//eq.add(new MPair(tf.getSimpleType("Double"), tf.getPlaceholderType("B"), PairOperator.SMALLERDOT));
|
||||||
|
Loading…
Reference in New Issue
Block a user