From 8f7becd62d86902c4cc6ada43ce21c0ef0d48679 Mon Sep 17 00:00:00 2001 From: Andreas Stadelmeier Date: Mon, 3 Oct 2022 10:08:50 +0200 Subject: [PATCH] Fix for Bug 230 --- pom.xml | 6 +++--- .../typeinference/assumptions/FieldAssumption.java | 2 +- .../assumptions/TypeInferenceInformation.java | 2 +- src/test/java/typeinference/JavaTXCompilerTest.java | 4 ++++ src/test/resources/javFiles/FieldAccess.jav | 13 +++++++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/test/resources/javFiles/FieldAccess.jav diff --git a/pom.xml b/pom.xml index 95b20386..2f5df9a2 100644 --- a/pom.xml +++ b/pom.xml @@ -118,7 +118,7 @@ http://maven.apache.org/maven-v4_0_0.xsd"> - + @@ -129,8 +129,8 @@ http://maven.apache.org/maven-v4_0_0.xsd"> UTF-8 UTF-8 - 1.8 - 1.8 + 18 + 18 0.23.0 de.dhbwstuttgart.core.ConsoleInterface diff --git a/src/main/java/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java b/src/main/java/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java index 305fa55f..ee18ea7c 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java @@ -39,7 +39,7 @@ public class FieldAssumption extends Assumption{ for(GenericTypeVar gtv : receiverClass.getGenerics()){ //Hier wird ein GenericRefType gebildet, welcher einen für dieses Feld eindeutigen Namen hat GenericRefType genericRefType = - new GenericRefType(receiverClass.getClassName().toString() + " " + name + " " + gtv.getName() + new GenericRefType(gtv.getName() , new NullToken()); //Dieser wird dann korrekt aufgelöst vom Resolver: params.add(resolver.resolve(genericRefType)); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/assumptions/TypeInferenceInformation.java b/src/main/java/de/dhbwstuttgart/typeinference/assumptions/TypeInferenceInformation.java index cbb941f3..3a215bc3 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/assumptions/TypeInferenceInformation.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/assumptions/TypeInferenceInformation.java @@ -47,7 +47,7 @@ public class TypeInferenceInformation { for(Field m : cl.getFieldDecl()){ if(m.getName().equals(name)){ - ret.add(new FieldAssumption(name, cl, checkGTV(m.getType()), new TypeScopeContainer(cl, m))); + ret.add(new FieldAssumption(name, cl, m.getType(), new TypeScopeContainer(cl, m))); } } } diff --git a/src/test/java/typeinference/JavaTXCompilerTest.java b/src/test/java/typeinference/JavaTXCompilerTest.java index 3fa1562b..7a062779 100644 --- a/src/test/java/typeinference/JavaTXCompilerTest.java +++ b/src/test/java/typeinference/JavaTXCompilerTest.java @@ -33,6 +33,10 @@ public class JavaTXCompilerTest { execute(new File(rootDirectory+"Import.jav")); } @Test + public void fieldTest() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"FieldAccess.jav")); + } + @Test public void lambda() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda.jav")); } diff --git a/src/test/resources/javFiles/FieldAccess.jav b/src/test/resources/javFiles/FieldAccess.jav new file mode 100644 index 00000000..894bb6e1 --- /dev/null +++ b/src/test/resources/javFiles/FieldAccess.jav @@ -0,0 +1,13 @@ +class Box { +A f; +} +class B { + } + +class Box_Main extends B { + + m(b) { + b.f = new Box_Main(); + b.f = new B(); + } +} \ No newline at end of file