Skip to content

Commit 99613a7

Browse files
authored
Changed how class types are registered (#14)
## Description Changed how class types are registered in the ClassLevelMaps to be coherent with how they are searched. ## Example A Class type would be added by the method VisitCtClass(...) in LatteClassFirstPass as "LinkedList", but would be searched for by the method visitCtInvocation(...) in LatteTypeChecker as "LinkedList<String>" (for example), leading to a miss. Was fixed by using .getTypeErasure() on visitCtInvocation(...), simplifying to "LinkedList" in every case ## Related Issue #6 ## Type of change - [x] Bug fix - [ ] New feature - [ ] Documentation update - [ ] Code refactoring ## How Has This Been Tested? App.java was run and the previously known bug was found. Adding other instances of the same class but with different Types did not affect the correctness of the output.
1 parent 45a115f commit 99613a7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

latte/src/main/java/typechecking/LatteClassFirstPass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public LatteClassFirstPass(SymbolicEnvironment se, PermissionEnvironment pe,
2424
public <T> void visitCtClass(CtClass<T> ctClass) {
2525
logInfo("Visiting class: " + ctClass.getSimpleName());
2626
// Add the class to the type reference and class map
27-
CtTypeReference<?> typeRef = ctClass.getReference();
28-
maps.addTypeClass(typeRef, ctClass);
27+
CtTypeReference<?> typeRef1 = ctClass.getReference();
28+
maps.addTypeClass(typeRef1, ctClass);
2929
super.visitCtClass(ctClass);
3030
}
3131

latte/src/main/java/typechecking/LatteTypeChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ public <T> void visitCtInvocation(CtInvocation<T> invocation) {
191191
if (invocation.getTarget() == null){
192192
logError("Invocation needs to have a target but found none -", invocation);
193193
}
194-
CtTypeReference<?> e = invocation.getTarget().getType();
194+
CtTypeReference<?> e = invocation.getTarget().getType().getTypeErasure();
195195

196196
// method(Γ(𝑥), 𝑓 ) = 𝛼 𝐶 𝑚(𝛼0 𝐶0 this, 𝛼1 𝐶1 𝑥1, · · · , 𝛼𝑛 𝐶𝑛 𝑥𝑛 )
197197
CtClass<?> klass = maps.getClassFrom(e);
198198
CtMethod<?> m = maps.getCtMethod(klass, metName,
199199
invocation.getArguments().size());
200200

201201
if (m == null){
202-
logInfo(String.format("Cannot find method {} for {} in the context", metName, invocation.getType()));
202+
logInfo("Cannot find method {" + metName + "} for {} in the context");
203203
return;
204204
}
205205
List<SymbolicValue> paramSymbValues = new ArrayList<>();

0 commit comments

Comments
 (0)