Typen einsetzen um Wildcards erweitern

This commit is contained in:
JanUlrich 2017-06-26 18:19:56 +02:00
parent e6c58d44c2
commit 3173cccefa
3 changed files with 10 additions and 15 deletions

View File

@ -2,10 +2,7 @@ package de.dhbwstuttgart.typedeployment;
import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType; import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
@ -112,8 +109,12 @@ public class TypeInsertFactory {
if(typeParam instanceof TypePlaceholder){ if(typeParam instanceof TypePlaceholder){
insert += ((TypePlaceholder) typeParam).getName(); insert += ((TypePlaceholder) typeParam).getName();
additionalInserts.add((TypePlaceholder) typeParam); additionalInserts.add((TypePlaceholder) typeParam);
}else if(typeParam instanceof RefType){ }else if(typeParam instanceof RefType) {
insert += createInsertString((RefType) typeParam, additionalInserts); insert += createInsertString((RefType) typeParam, additionalInserts);
}else if(typeParam instanceof SuperWildcardType){
insert += "? super " + createInsertString(((SuperWildcardType) typeParam).getInnerType(), additionalInserts);
}else if(typeParam instanceof ExtendsWildcardType){
insert += "? extends " + createInsertString(((ExtendsWildcardType) typeParam).getInnerType(), additionalInserts);
}else throw new NotImplementedException(); }else throw new NotImplementedException();
if(iterator.hasNext())insert += ", "; if(iterator.hasNext())insert += ", ";
} }

View File

@ -4,15 +4,9 @@ mathStruc(A a) { ;}
A model(){ A a; return a; } A model(){ A a; return a; }
void methode(){ methode(){
auto innerOp = o -> ms -> auto innerOp = o -> ms ->
new mathStruc<A>(o.apply(this.model(),ms.model())); new mathStruc<A>(o.apply(this.model(),ms.model()));
return innerOp;
} }
}
interface Fun1<A,B>{
A apply(B b);
}
interface Fun2<A,B,C>{
A apply(B b, C c);
} }

View File

@ -26,8 +26,8 @@ public class JavaTXCompilerTest {
@Test @Test
public void test() throws IOException, ClassNotFoundException { public void test() throws IOException, ClassNotFoundException {
//filesToTest.add(new File(rootDirectory+"mathStruc.jav")); filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
filesToTest.add(new File(rootDirectory+"Lambda.jav")); //filesToTest.add(new File(rootDirectory+"Lambda.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda2.jav")); //filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda3.jav")); //filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
//filesToTest.add(new File(rootDirectory+"Vector.jav")); //filesToTest.add(new File(rootDirectory+"Vector.jav"));