Bug 152961

Summary: [compiler] Private inner interface is "never used locally"
Product: [Eclipse Project] JDT Reporter: Ahmed Ashour <asashour>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.2   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Ahmed Ashour CLA 2006-08-07 07:52:26 EDT
In the following case, the 'Outer' interface is used, but it is marked as "never used locally", and code assist suggests to be removed.

Many thanks.
Ahmed Ashour

public class Test {

	private interface Outer {
		interface Inner {
			String variable = "my testing";
		}
	}
	
	public static void main( String[] args ) {
		System.out.println(Outer.Inner.variable);
	}
}
Comment 1 Frederic Fusier CLA 2006-08-07 08:11:32 EDT
Reproduce with 3.2 build. It sounds that we need to recurse through member type hierarchy in method ASTNode.isTypeUseDeprecated(TypeBinding, Scope).

Following test case with only one enclosing type level is correct:
public class Test {
	private interface Outer {
		String variable = "my testing";
	}
	public static void main(String[] args) {
		System.out.println(Outer.variable);
	}
}
Comment 2 Frederic Fusier CLA 2006-08-07 08:16:36 EDT
Rephrase my previous comment:
It seems we need to recurse through all enclosing types while setting ExtraCompilerModifiers.AccLocallyUsed bit...
Comment 3 Philipe Mulet CLA 2006-10-10 03:33:49 EDT
I think you are right.
Comment 4 Philipe Mulet CLA 2006-10-10 03:34:35 EDT
Frederic - pls prepare the change and show it to me before releasing.
Comment 5 Frederic Fusier CLA 2006-10-10 06:41:09 EDT
Created attachment 51670 [details]
Proposed patch
Comment 6 Frederic Fusier CLA 2006-10-10 06:41:39 EDT
Philippe, see TODO in the patch...
Comment 7 Frederic Fusier CLA 2006-10-11 12:21:23 EDT
Comment on attachment 51670 [details]
Proposed patch

Patch is not smart enough in some corner cases as:

public class Test { 
   private class A {
    class B {}
  }
  private class X extends A {
  }
  X.B d = null;
}
Comment 8 Philipe Mulet CLA 2007-01-09 13:12:09 EST
Other testcase:
public class X { 
   private class A {
    class B {}
  }
  private class Y<T> extends A {
  }
  Y<String>.B d = null;
}
Comment 9 Philipe Mulet CLA 2007-01-10 05:44:17 EST
Problem occurs in different places. 
Added support for Qualified type ref, Param qualified type ref.
Still need support for qualified name ref (as in original testcase).

Added regression tests:
   GenericTypeTest#test1098
   InnerEmulationTest#test135
Comment 10 Philipe Mulet CLA 2007-01-10 07:22:07 EST
Also added InnerEmulationTest#test136-139
Comment 11 Philipe Mulet CLA 2007-01-10 09:52:44 EST
Released for 3.3M5.
Fixed 
Comment 12 David Audel CLA 2007-02-06 06:25:03 EST
Verified for 3.3 M5 using build I20070206-0010