Typen in Parameterlisten von Lambda Ausdrücken werden nicht mehr eingesetzt
This commit is contained in:
parent
b2e79b35f3
commit
c9477705cc
@ -259,7 +259,8 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL
|
|||||||
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||||
ResultSet resultSet) {
|
ResultSet resultSet) {
|
||||||
if(this.getOffset()<=0)return null;
|
if(this.getOffset()<=0)return null;
|
||||||
return new TypeInsertPoint(this, resultSet.getTypeEqualTo(tph), resultSet);
|
Type t = resultSet.getTypeEqualTo(tph);
|
||||||
|
return new TypeInsertPoint(this, t, resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,5 +273,10 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DeclId getDeclId() {
|
||||||
|
return this.declid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -67,7 +67,11 @@ public class LambdaExpression extends Expr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setParameterList(ParameterList params){
|
public void setParameterList(ParameterList params){
|
||||||
this.params = params;
|
ParameterList lambdaParameter = new ParameterList();
|
||||||
|
for(FormalParameter fp : params){
|
||||||
|
lambdaParameter.formalparameter.add(new LambdaParameter(fp));
|
||||||
|
}
|
||||||
|
this.params = lambdaParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
30
src/mycompiler/mystatement/LambdaParameter.java
Normal file
30
src/mycompiler/mystatement/LambdaParameter.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package mycompiler.mystatement;
|
||||||
|
|
||||||
|
import typinferenz.ResultSet;
|
||||||
|
import typinferenz.TypeInsertPoint;
|
||||||
|
import mycompiler.myclass.DeclId;
|
||||||
|
import mycompiler.myclass.FormalParameter;
|
||||||
|
import mycompiler.mytype.Type;
|
||||||
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der FormalParameter einer LambdaExpression hat gesonderte Eigenschaften.
|
||||||
|
* @author janulrich
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LambdaParameter extends FormalParameter {
|
||||||
|
|
||||||
|
public LambdaParameter(FormalParameter fp) {
|
||||||
|
super(fp.getDeclId());
|
||||||
|
this.setType(fp.getType());
|
||||||
|
this.parent = fp.getParent();
|
||||||
|
this.inferencelog = fp.inferencelog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
||||||
|
ResultSet resultSet) {
|
||||||
|
return null;//Ein LambdaParameter darf keine Typen einsetzen.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -139,7 +139,8 @@ public class TypeinferenceResultSet
|
|||||||
for(int i = 0; i<tips.size();i++){
|
for(int i = 0; i<tips.size();i++){
|
||||||
TypeInsertPoint tip = tips.elementAt(i);
|
TypeInsertPoint tip = tips.elementAt(i);
|
||||||
for(TypePlaceholder involvedTPH : toAdd.add(tip)){ //TIP anfügen...
|
for(TypePlaceholder involvedTPH : toAdd.add(tip)){ //TIP anfügen...
|
||||||
tips.addAll(involvedTPH.getTypeInsertPoints(unifiedConstraints)); //... und alle mit ihm in Verbindung stehenden TIPs in die anzufügende Liste anhängen.
|
//Benutzte Generische Variablen müssen nicht eingesetzt werden:
|
||||||
|
//tips.addAll(involvedTPH.getTypeInsertPoints(unifiedConstraints)); //... und alle mit ihm in Verbindung stehenden TIPs in die anzufügende Liste anhängen.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(!ret.contains(toAdd))ret.add(toAdd);
|
if(!ret.contains(toAdd))ret.add(toAdd);
|
||||||
|
@ -53,6 +53,8 @@ public class TypeInsertSet {
|
|||||||
int additionalOffset = 0;
|
int additionalOffset = 0;
|
||||||
String ret = fileContent;
|
String ret = fileContent;
|
||||||
Vector<GenericTypeInsertPoint> genericTIPs = new Vector<GenericTypeInsertPoint>();
|
Vector<GenericTypeInsertPoint> genericTIPs = new Vector<GenericTypeInsertPoint>();
|
||||||
|
|
||||||
|
//Alle gebrauchten Generischen Variablen ermitteln:
|
||||||
for(TypeInsertPoint p : points){
|
for(TypeInsertPoint p : points){
|
||||||
GenericTypeInsertPoint toAdd = new GenericTypeInsertPoint(p);
|
GenericTypeInsertPoint toAdd = new GenericTypeInsertPoint(p);
|
||||||
for(Pair genericPair : p.getResultSet().getConstraintsFor(p.getUnresolvedTPH())){
|
for(Pair genericPair : p.getResultSet().getConstraintsFor(p.getUnresolvedTPH())){
|
||||||
@ -60,15 +62,19 @@ public class TypeInsertSet {
|
|||||||
}
|
}
|
||||||
genericTIPs.add(toAdd);
|
genericTIPs.add(toAdd);
|
||||||
}
|
}
|
||||||
|
//... und dem TypeInsertSet anfügen:
|
||||||
for(GenericTypeInsertPoint p : genericTIPs){
|
for(GenericTypeInsertPoint p : genericTIPs){
|
||||||
for(GenericTypeInsertPoint p2 : genericTIPs){
|
for(GenericTypeInsertPoint p2 : genericTIPs){
|
||||||
//Doppelte Generische Variablen definitionen ausschließen:
|
//Doppelte Generische Variablen definitionen ausschließen:
|
||||||
for(TypeInsertPoint toAdd : p.merge(p2))this.add(toAdd);
|
for(TypeInsertPoint toAdd : p.merge(p2)){
|
||||||
|
this.add(toAdd);
|
||||||
|
//TODO: Alle Typen, welche die einzusetzenden Generischen Typen beinhalten, müssen ebenfalls eingesetzt werden.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//this.add(p);
|
//this.add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Anschließend sortieren:
|
||||||
Collections.sort(points);
|
Collections.sort(points);
|
||||||
|
|
||||||
for(TypeInsertPoint p : points){
|
for(TypeInsertPoint p : points){
|
||||||
|
Loading…
Reference in New Issue
Block a user