Bug 320463 - [1.5][compiler] Inner class token incorrectly picks up outer type arguments
Summary: [1.5][compiler] Inner class token incorrectly picks up outer type arguments
Status: VERIFIED DUPLICATE of bug 312076
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-21 02:54 EDT by Matt McCutchen CLA
Modified: 2010-08-04 16:14 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.