Bug 80063

Summary: code assist allows overriding super class' private method
Product: [Eclipse Project] JDT Reporter: Rafael Chaves <eclipse>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Rafael Chaves CLA 2004-12-02 17:09:46 EST
i20041201

Code assist allows overriding super class private method. Superclass' private
members should be omitted instead. Example:

class A {
  private void m1() {}
}

class B extends A {
}

Triggering code assist inside B's body will offer to "override" A's m1() method,
which is private and cannot be overriden, resulting in:

class A {
  private void m1() {}
}

class B extends A {
  private void m1() {}
}

Where B's m1 method is completely unrelated to A's m1 method. The resulting code
is valid but it is not what the developer intended (which was to override a
super class' method).
Comment 1 Dirk Baeumer CLA 2004-12-03 10:01:34 EST
The proposals are generated by JDT/Core.
Comment 2 David Audel CLA 2005-04-18 10:08:12 EDT
private methods are only proposed if the option "Preferences>Java>Editor>Sorting
and filtering>Show only proposals visible in the invocation context" is unchecked.
Comment 3 Rafael Chaves CLA 2005-04-18 10:20:32 EDT
Yeah, I have it unchecked. 

I can see the usefulness of proposing private methods to callers, because an
error marker will be added and the user can then use quick fix to easily change
the member visibility. I have used this feature myself.

But when overriding methods, I think it is misleading (besides being plain useless).
Comment 4 David Audel CLA 2005-04-27 04:30:00 EDT
Fixed and test added
  CompletionTests#testCompletionMethodDeclaration11()
Comment 5 Olivier Thomann CLA 2005-05-12 13:33:56 EDT
Verified in I20050510-0010 + JDT/Core v_556