I currently have three classes and trying to implement Generic Visitor pattern for putting it into a library shared among all our projects:
public interface Visitable<ReturnType> {
public ReturnType accept(Visitor<?, ?> v);
}
public interface Visitor<SomeVisitable extends Visitable<?>, ReturnType> {
public ReturnType visit(SomeVisitable v);
}
public class BaseObject implements Visitable<Void>{
public Void accept(Visitor<?, ?> v) {
v.visit(this); //1
// The method visit(capture#1-of ?) in the type
// Visitor<capture#1-of ?,capture#2-of ?> is not
// applicable for the arguments (BaseObject)
}
}
Why did I get the compile-time error at //1? Honestly I really don't know what I should redisign in that code to make it compile.
Aucun commentaire:
Enregistrer un commentaire