From a71e56ea9793f9ffb05d99b9b8a7c159e6053a2d Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 21 Mar 2018 11:15:59 +0100 Subject: [PATCH] Fix --- .../typeinference/assumptions/FieldAssumption.java | 5 +++-- .../typeinference/assumptions/MethodAssumption.java | 3 ++- src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java | 2 +- test/typeinference/JavaTXCompilerTest.java | 4 ++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java index 62867a264..e039dcbeb 100644 --- a/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java +++ b/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.typeinference.assumptions; +import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.TypeScope; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; @@ -25,7 +26,7 @@ public class FieldAssumption extends Assumption{ } public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(GenericsResolver resolver) { - - return null; + //TODO + throw new NotImplementedException(); } } diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java index 4656318c8..e17281e5f 100644 --- a/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java +++ b/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java @@ -37,7 +37,8 @@ public class MethodAssumption extends Assumption{ return receiver; } - public RefTypeOrTPHOrWildcardOrGeneric getReturnType() { + public RefTypeOrTPHOrWildcardOrGeneric getReturnType(GenericsResolver resolver) { + if(retType instanceof GenericRefType)return resolver.resolve(retType); return retType; } diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 0cadc0858..19f212bfe 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -393,7 +393,7 @@ public class TYPEStmt implements StatementVisitor{ for(Method m : cl.getMethods()){ if(m.getName().equals(name) && m.getParameterList().getFormalparalist().size() == numArgs){ - RefTypeOrTPHOrWildcardOrGeneric retType = info.checkGTV(m.getReturnType()); + RefTypeOrTPHOrWildcardOrGeneric retType = m.getReturnType();//info.checkGTV(m.getReturnType()); ret.add(new MethodAssumption(cl, retType, convertParams(m.getParameterList(),info), createTypeScope(cl, m))); diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index 87551476d..3ba22bc6a 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -49,6 +49,10 @@ public class JavaTXCompilerTest { execute(new File(rootDirectory+"Generics.jav")); } @Test + public void genericsMethodCall() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"MethodCallGenerics.jav")); + } + @Test public void faculty() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Faculty.jav")); }