However, if we have a generic class C that has an f-bounded formal type variable:
class C<X extends C<X>> ....
And we instantiate this type with wildcards, C<? extends C<?>>, it does type check. This is surprising since the type variables in the declaration are the same and yet the wildcards in the wildcard type are 'different', but here they are regarded as the same wildcard! There is no unsoundness as we can not create a type that violates the constraints of the formal parameters, but it is surprising that the type checker can apply this knowledge to the wildcard type.
Time to upgrade our model...
No comments:
Post a Comment