Dear rpau!
I want to analyze a "use interface where possible" case regarding generics.
I have some class "C" which implements interface "R".
They are used in the following case.
import java.util.List;
public interface Validator {
<T> List<ConstraintViolation<T>> validate(T t);
}
class ConstraintViolation<T> {}
class Usage {
public void f() {
Validator v = null;
C c = new C();
List<ConstraintViolation<C>> l = v.validate(c);
}
}
If I would replace all occurences of C with R that would work.
But I want to know how I can analyze the case if
"List<ConstraintViolation<C>> l" can be assigned from "v.validate(c)" if c would be changed to "R".
Obviously that analysis should result in "false" but I wonder how do I get there inside some visitor?
Do I have to fall back to "replace and compile" to let the java compiler do the semantic analysis
or is there some semantic analysis code in walkmod or the java compiler that can be used?
Thanks in advance,
Carsten