Bug 205235 - [1.5][compiler] Eclipse syntax highlighting flag correct syntax as a hierarchy cycle
Summary: [1.5][compiler] Eclipse syntax highlighting flag correct syntax as a hierarch...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 214191 214237 222933 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-02 16:05 EDT by John Day-Richter CLA
Modified: 2009-12-16 02:41 EST (History)
5 users (show)

See Also:


Attachments
Tarred & gzipped version of a project that exhibits the behavior (1.38 KB, application/octet-stream)
2007-10-02 16:05 EDT, John Day-Richter CLA
no flags Details
Proposed patch (2.52 KB, patch)
2007-10-10 13:07 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Day-Richter CLA 2007-10-02 16:05:41 EDT
Created attachment 79578 [details]
Tarred & gzipped version of a project that exhibits the behavior

Build ID: I20070621-1340

Steps To Reproduce:
1. Open attached project (note that there are no compiler errors)
2. Look at the syntax highlighting for class "C". Notice that it is flagged as a hierarchy error even though it is perfectly legal.


More information:
Under some circumstances, the Eclipse syntax highlighting flags perfectly legal class hierarchies with the "inconsistent class hierarchy", even though the compiler thinks that they're fine.

Check out the attached project to see the problem. Even though the project contains no compile errors, if you open interface "C", Eclipse has highlighted the interface name with an "inconsistent hierarchy" error.

I suspect that this is happening because the syntax highlighter is falsely detecting a cycle in the *hierarchy* (which really is illegal) because of a cycle in the *generics references* (which is perfectly legal, as far as I know).

The bug seems to be specific to a very particular structure of interfaces. For example, look at the InnerExample class. It contains a collection of static inner interfaces whose relationships are perfectly analogous to those specified in the public classes A,B,C, and D. Yet the syntax highlighter doesn't have a problem with these.

Another interesting wrinkle - If you change class B to this:

   public interface B extends A<C> {}

the problem disappears. This is odd, because if the problem is circular class references, this version is to be just as circular as the original version.
Comment 1 Kent Johnson CLA 2007-10-10 13:07:44 EDT
Created attachment 80075 [details]
Proposed patch

We have a order dependent problem with source types as seen in this example:

A.java
interface A<T extends C> {}
interface B extends A<D> {}
interface D extends C {}

C.java
interface C extends B {}


We should not report a cycle in this example and with this patch we no longer do.

We pass all tests with this patch.

Philippe - can you think of any case where we would need to ensure the hierarchy of D is resolved when we resolve the reference 'A<D>' ?
Comment 2 Philipe Mulet CLA 2007-10-11 06:24:45 EDT
Given all bound checks. supertype collision checks are being deferred already, I don't see  a problem for type compatibility rules per se.
Comment 3 Kent Johnson CLA 2007-10-12 13:30:02 EDT
Released into HEAD for 3.4M3

Added Java50Tests testHierarchyCycle()
Comment 4 Frederic Fusier CLA 2007-10-29 07:35:28 EDT
Verified for 3.4M3 using I20071029-0010 build.
Comment 5 Jerome Lanneluc CLA 2008-01-09 06:45:47 EST
*** Bug 214237 has been marked as a duplicate of this bug. ***
Comment 6 Jerome Lanneluc CLA 2008-01-09 06:47:02 EST
*** Bug 214191 has been marked as a duplicate of this bug. ***
Comment 7 Srikanth Sankaran CLA 2009-12-16 02:41:40 EST
*** Bug 222933 has been marked as a duplicate of this bug. ***