Bug 216692

Summary: [1.5][compiler] Protected type not visible in subclass
Product: [Eclipse Project] JDT Reporter: Olivier Lefevre <lefevrol>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: elinsn, eric_jodet, jerome_lanneluc, Olivier_Thomann, xbranko
Version: 3.4   
Target Milestone: 3.4 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
The script to run
none
Proposed patch none

Description Olivier Lefevre CLA 2008-01-27 00:30:21 EST
Run the attached script. ecj will put:
-----------------------------------------------
1. ERROR in src\pkg2\SubFoo.java (at line 6)
        Field field = fields.get("test");
                      ^^^^^^^^^^^^^^^^^^
The type Foo<T>.Field is not visible
-----------------------------------------------
which does not make sense. First, it does not complain 
about the 'Field field = null' declaration, which should 
be equally problematic if the Field type was invisible.
Second, the Field type is protected in the super and 
thus _is_ visible anyhow.

One workaround is to make the Field type public. More
surprisingly, removing the type parameter of the Foo and
SubFoo classes also makes the problem disappear.
Comment 1 Olivier Lefevre CLA 2008-01-27 00:31:29 EST
Created attachment 87963 [details]
The script to run
Comment 2 Philipe Mulet CLA 2008-01-28 17:38:18 EST
Bug in visibility check, was not properly stepping through erased types (this explains why manually removing type parameters did seem to address the issue).

Comment 3 Philipe Mulet CLA 2008-01-28 17:41:06 EST
Created attachment 88069 [details]
Proposed patch
Comment 4 Philipe Mulet CLA 2008-01-28 17:42:10 EST
re: comment 2.
Most type visibility checks where actually behaving properly, but one code path did fail. Field/methods were fine already.
Comment 5 Philipe Mulet CLA 2008-01-29 05:16:55 EST
Released for 3.4M5.
Added GenericTypeTest#test1268
Fixed
Comment 6 Eric Jodet CLA 2008-02-04 06:40:16 EST
Verified for 3.4M5 using build I20080204-0010
Comment 7 Laurent Voisin CLA 2008-02-12 12:36:40 EST
Is there any chance that this fix is also applied to maintenance release 3.3.2 ?  Indeed, this bug was not there in release 3.3.1.1 and has been introduced in the maintenance branch for 3.3.2.
Comment 8 Philipe Mulet CLA 2008-02-28 07:38:14 EST
Released fix in 3.3.x maintenance branch (post 3.3.2).

Unfortunately, Laurent, 3.3.2 is out already.
If you are desperate, we could post a JDT/Core patch including this fix (based on 3.3.2 + this fix).
Comment 9 Philipe Mulet CLA 2008-05-07 05:11:43 EDT
*** Bug 230466 has been marked as a duplicate of this bug. ***
Comment 10 Philipe Mulet CLA 2008-05-15 05:56:42 EDT
*** Bug 232174 has been marked as a duplicate of this bug. ***
Comment 11 Philipe Mulet CLA 2008-05-15 05:58:36 EDT
Fix is available in 3.4 and in 3.3 maintenance branch post 3.3.2.
A patch is posted at: http://www.eclipse.org/jdt/core/r3.3/index.php#UPDATES
(use the 3.3.3 preview)