Bug 80063 - code assist allows overriding super class' private method
Summary: code assist allows overriding super class' private method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-02 17:09 EST by Rafael Chaves CLA
Modified: 2005-05-12 13:33 EDT (History)
0 users

See Also:


Attachments

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