Bug 320463

Summary: [1.5][compiler] Inner class token incorrectly picks up outer type arguments
Product: [Eclipse Project] JDT Reporter: Matt McCutchen <hashproduct+eclipse>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7 M1   
Hardware: All   
OS: All   
Whiteboard:

Description Matt McCutchen CLA 2010-07-21 02:54:15 EDT
Build Identifier: I20100608-0911

The following code is accepted without an unchecked warning, but it throws ClassCastException at a synthetic cast:

class Outer<T> {

	class Cell {
		final T value;
		Cell(T value) {
			this.value = value;
		}
	}

	// Expected a type mismatch here: Cell.class has type Class<Outer<?>.Cell>
	Class<Outer<T>.Cell> cellClass = Cell.class;

	public static void main(String[] args) {
		Outer<Integer>.Cell intCell = new Outer<Integer>().new Cell(314);
		Outer<String>.Cell strCell = new Outer<String>().cellClass.cast(intCell);
		String val = strCell.value; // ClassCastException
		System.out.println(val);
	}
}

Reproducible: Always

Steps to Reproduce:
1. Compile and run the given code.
Comment 1 Srikanth Sankaran CLA 2010-07-21 04:21:24 EDT
I'll investigate. cf. bug# 312076
Comment 2 Srikanth Sankaran CLA 2010-07-22 00:43:12 EDT
This is a duplicate of bug# 312076 - I have a fix for the latter
which also addresses this one. Will close this as duplicate and
include the test case from comment# 0 in the regression test for
bug# 312076. Targetting 3.7 M1 for the fix to be released.

*** This bug has been marked as a duplicate of bug 312076 ***
Comment 3 Olivier Thomann CLA 2010-08-04 16:14:11 EDT
Verified for 3.7M1.