Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Jul 23, 2024
1 parent 3f50938 commit d836946
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ClassDeclarationLocation extends AbstractSymbolLocation {

public final Type.ClassType toChange;

public ClassDeclarationLocation(Symbol target, Type.ClassType toChange) {
private ClassDeclarationLocation(Symbol target, Type.ClassType toChange) {
super(LocationKind.CLASS_DECLARATION, target);
this.toChange = toChange;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,7 @@ public static Set<Fix> computeFixesOnClassDeclarationForRawType(
if (index < 0) {
return Set.of();
}
ClassDeclarationLocation classDeclarationLocation =
new ClassDeclarationLocation(classType, inheritedType);
classDeclarationLocation.setTypeIndexSet(TypeIndex.setOf(index + 1, 0));
return Set.of(new Fix(classDeclarationLocation));
return Set.of();
} catch (Exception e) {
return Set.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,7 @@ public Fix buildFixForElement(Element element, FoundRequired pair) {
if (inheritedType == null) {
return null;
}
ClassDeclarationLocation classDeclarationLocation =
new ClassDeclarationLocation(classType, inheritedType);
if (classDeclarationLocation.path == null) {
// Class is not even declared in the project. Cannot do anything.
return null;
}
Set<AnnotatedTypeMirror.AnnotatedDeclaredType> supers =
AnnotatedTypes.getSuperTypes((AnnotatedTypeMirror.AnnotatedDeclaredType) pair.found);
supers.stream()
.filter(
annotatedDeclaredType -> {
if (annotatedDeclaredType.getUnderlyingType() instanceof Type.ClassType) {
Type.ClassType classType1 =
(Type.ClassType) annotatedDeclaredType.getUnderlyingType();
return classType1.tsym.equals(inheritedType.tsym);
}
return false;
})
.findFirst()
.ifPresent(
annotatedDeclaredType -> {
classDeclarationLocation.setTypeIndexSet(
untaintedTypeMatchVisitor.visit(annotatedDeclaredType, pair.required, null));
});
return classDeclarationLocation.getTypeIndexSet().isEmpty()
? null
: new Fix(classDeclarationLocation);
return null;
}
AnnotatedTypeMirror elementAnnotatedType = typeFactory.getAnnotatedType(element);
// remove redundant indices.
Expand Down
29 changes: 28 additions & 1 deletion tests/templatetest/foo/bar/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,31 @@
import java.lang.annotation.*;
import java.util.*;

public class Test {}
public class Test {


void test(){
Bar b = new Bar();
@RUntainted String s = b.getT();
}


}


class Foo<T> {

T getT(){
return null;
}
}

class Bar extends Foo<@RUntainted String>{}

class Zoo extends Bar{

String getT() {
return null;
}
}

0 comments on commit d836946

Please sign in to comment.