Bug 78810

Summary: [1.5] [Generics] Erroneous problem detection with cast.
Product: [Eclipse Project] JDT Reporter: R Lenard <rlenard>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description R Lenard CLA 2004-11-16 23:46:55 EST
For this code.
% cat Test.java
public abstract class Test
{
    public abstract Object getProperty(final Object src, final String name);
    
    public <T> T getTheProperty(final Object src, final String name)
    {
        final T val = (T) getProperty(src, name); // this gives erroneous cast 
warning
        return val;
    }
}
<<<
The marked line gives.
Severity	Description	Resource	In Folder	Location
	Creation Time
1	Unnecessary cast from Object to T	Test.java		line 78
	November 17, 2004 3:26:30 PM


Now clearly the cast is required here - because the type is unknown.
Comment 1 Philipe Mulet CLA 2005-01-05 09:27:10 EST
Same issue as bug 78591, different symptoms.
Added GenericTypeTest#test444

*** This bug has been marked as a duplicate of 78591 ***
Comment 2 Philipe Mulet CLA 2005-01-05 09:32:50 EST
Note: If unchecked/unsafe type operation warnings are enabled, you will now get
a warning when casting to a type parameter:

Type safety: The cast from Object to T is actually checking against the erased
type Object
Comment 3 Philipe Mulet CLA 2005-01-06 06:38:21 EST
Test is actually: test445.