Bug 436227 - [1.8][quick fix] Convert I.m to a default method
Summary: [1.8][quick fix] Convert I.m to a default method
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 417821 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-30 04:45 EDT by Dani Megert CLA
Modified: 2014-06-02 06:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2014-05-30 04:45:44 EDT
When adding a method to an interface one gets compile errors in the implementation classes:

The type X must implement the inherited abstract method I.m.

We should offer a quick fix to convert I.m to a default method.
Comment 1 Noopur Gupta CLA 2014-05-30 05:38:34 EDT
*** Bug 417821 has been marked as a duplicate of this bug. ***
Comment 2 Noopur Gupta CLA 2014-05-30 09:51:31 EDT
When a class or enum has the compile error IProblem.AbstractMethodMustBeImplemented, there could be one or more abstract methods from the implemented interface(s) and/or the extended abstract class. 

Should the quick fix offer to convert (all possible) unimplemented methods to default methods (similar to the existing "Add unimplemented methods")?

Or, multiple quick fixes should be shown, each offering to convert a single (possible) abstract method to default?

From the list of unimplemented methods at a type, it should not convert a method to default if its parent interface is at a level < 1.8, if its parent is an abstract class or if the parent cannot be modified (is binary etc).
Comment 3 Dani Megert CLA 2014-06-02 06:04:25 EDT
(In reply to Noopur Gupta from comment #2)

The ideal scenario where I would need the quick fix is when I add a new method to an existing interface. Unfortunately, the error is not reported on the interface but on a subclass(es).

> Should the quick fix offer to convert (all possible) unimplemented methods
> to default methods (similar to the existing "Add unimplemented methods")?

I think so.

Maybe we don't show the new quick fix if all methods from an interface are missing, e.g. when a class adds another interface to its declaration. I think it would be bad coding habit to use an existing "normal" interface and then later make all methods default.