Menu

#106 [Generics] No implicit generics cast inserted

Self_Reported
open
nobody
5
2012-11-27
2006-11-16
No

In the below class, implicit generics casts should be inserted since the type Collection differ's from T's type erasure. However, these casts are missing as can be seen by looking at the generated bytecode.

Actually, MultiJava does have a mechanism to insert generics casts but it seems as if those casts are only inserted when performing generic type substitution.

However, the below examples are a bit trickier since the type to which the variable t needs to be cast depends on the context where t is used, i.e. it e.g. matters to which type t is being assigned.

===================================================
import java.util.Collection;

public class Bug13<T extends Number & Collection> {
public void foo(T t) {
Collection c = t; // No cast to Collection is inserted!
bar(t); // No cast to Collection is inserted!
}

public void bar(Collection c) { }
}
===================================================

Discussion


Log in to post a comment.