modified: src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
Operatoren neue getypte Returnargument bei FUNN nach hinten verschoben modified: src/de/dhbwstuttgart/typeinference/unify/RuleSet.java Returnargument bei FUNN nach hinten verschoben Wildcards in Argumenten von als Undefined Pairs (funktioniert noch nicht) Methode wrongWildcard eingefuegt modified: src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java Methode doubleWildcard ind wrongWildcard umbenannt modified: src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java Methode doubleWildcard ind wrongWildcard umbenannt modified: src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java Methode doubleWildcard ind wrongWildcard umbenannt
This commit is contained in:
parent
da4c59f2cf
commit
e4243b612c
@ -57,8 +57,8 @@ public class TYPEStmt implements StatementVisitor{
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
TypePlaceholder tphRetType = TypePlaceholder.fresh(new NullToken());
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> lambdaParams = lambdaExpression.params.getFormalparalist().stream().map((formalParameter -> formalParameter.getType())).collect(Collectors.toList());
|
||||
//lambdaParams.add(tphRetType);
|
||||
lambdaParams.add(0,tphRetType);
|
||||
lambdaParams.add(tphRetType);
|
||||
//lambdaParams.add(0,tphRetType);
|
||||
constraintsSet.addUndConstraint(
|
||||
new Pair(lambdaExpression.getType(),
|
||||
new FunN(lambdaParams),PairOperator.EQUALSDOT));
|
||||
|
@ -767,8 +767,8 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
||||
|
||||
result.add(new UnifyPair(funNLhsType.getTypeParams().get(0), funNRhsType.getTypeParams().get(0), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 1; i < funNLhsType.getTypeParams().size(); i++)
|
||||
result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), funNRhsType.getTypeParams().get(funNRhsType.getTypeParams().size()-1), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 0; i < funNLhsType.getTypeParams().size()-1; i++)
|
||||
result.add(new UnifyPair(funNRhsType.getTypeParams().get(i), funNLhsType.getTypeParams().get(i), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
|
||||
return Optional.of(result);
|
||||
@ -793,8 +793,8 @@ public class RuleSet implements IRuleSet{
|
||||
for(int i = 0; i < freshPlaceholders.length; i++)
|
||||
freshPlaceholders[i] = PlaceholderType.freshPlaceholder();
|
||||
|
||||
result.add(new UnifyPair(funNLhsType.getTypeParams().get(0), freshPlaceholders[0], PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 1; i < funNLhsType.getTypeParams().size(); i++)
|
||||
result.add(new UnifyPair(funNLhsType.getTypeParams().get(funNLhsType.getTypeParams().size()-1), freshPlaceholders[funNLhsType.getTypeParams().size()-1], PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 0; i < funNLhsType.getTypeParams().size()-1; i++)
|
||||
result.add(new UnifyPair(freshPlaceholders[i], funNLhsType.getTypeParams().get(i), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
result.add(new UnifyPair(rhsType, funNLhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
|
||||
@ -820,8 +820,8 @@ public class RuleSet implements IRuleSet{
|
||||
for(int i = 0; i < freshPlaceholders.length; i++)
|
||||
freshPlaceholders[i] = PlaceholderType.freshPlaceholder();
|
||||
|
||||
result.add(new UnifyPair(freshPlaceholders[0], funNRhsType.getTypeParams().get(0), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 1; i < funNRhsType.getTypeParams().size(); i++)
|
||||
result.add(new UnifyPair(freshPlaceholders[funNRhsType.getTypeParams().size()-1], funNRhsType.getTypeParams().get(funNRhsType.getTypeParams().size()-1), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
for(int i = 0; i < funNRhsType.getTypeParams().size()-1; i++)
|
||||
result.add(new UnifyPair(funNRhsType.getTypeParams().get(i), freshPlaceholders[i], PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
result.add(new UnifyPair(lhsType, funNRhsType.setTypeParams(new TypeParams(freshPlaceholders)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
/*
|
||||
* ? extends ? extends Theta rausfiltern
|
||||
*/
|
||||
Set<UnifyPair> doubleExt = eq.stream().filter(x -> (x.doubleExtended())).map(x -> { x.setUndefinedPair(); return x;})
|
||||
Set<UnifyPair> doubleExt = eq.stream().filter(x -> (x.wrongWildcard())).map(x -> { x.setUndefinedPair(); return x;})
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
if (doubleExt.size() > 0) {
|
||||
Set<Set<UnifyPair>> ret = new HashSet<>();
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
@ -73,11 +75,18 @@ public class FunNType extends UnifyType {
|
||||
return new FunNType(newParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean wrongWildcard() {
|
||||
return !(new ArrayList<UnifyType>(Arrays.asList(getTypeParams()
|
||||
.get())).stream().filter(x -> (x instanceof WildcardType)).findFirst().isPresent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 181 + typeParams.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof FunNType))
|
||||
|
@ -134,8 +134,8 @@ public class UnifyPair {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean doubleExtended() {
|
||||
return lhs.doubleExtended() || rhs.doubleExtended();
|
||||
public Boolean wrongWildcard() {
|
||||
return lhs.wrongWildcard() || rhs.wrongWildcard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +103,7 @@ public abstract class UnifyType {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean doubleExtended() {//default
|
||||
public Boolean wrongWildcard() {//default
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public abstract class WildcardType extends UnifyType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean doubleExtended () {//This is an error
|
||||
public Boolean wrongWildcard () {//This is an error
|
||||
return (wildcardedType instanceof WildcardType);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user