Suppose I have the following classes:
public abstract class AbstractClass {
...
}
public class ConcreteClass extends AbstractClass {
...
}
a builder:
public class Builder{
static public ConcreteClass build(){
...
}
}
and a generic function in some other class:
public <T extends AbstractClass> T myFunction(){
T a = Builder.build();
return a;
}
It was my understanding that the compiler should have enough information to allow such assignment, however, it throws an error:
Type mismatch: cannot convert from ConcreteClass to T
Why is that and what are the potential dangers of such assignment?