Community
Participate
Working Groups
If i extract values to fields, variables or constants: If the returning-interface is hidden in the package-scope the hidden returntype is used anyway! In example: This constalation create a Compiler Warning: You have 2 Interface and 2 Classes: Interface 1: package sumsum; public interface Show {} Interface 2: package sumsum; interface Hide extends Show{ String getText(); } Class 1: package sumsum; public class Case{ public static Hide getA(){return null;} } Class 2: package org.dontknow.jack; class Main{ public static void main(String[]args){ Case.getA(); // Ok, now i do a Extract to ... will produce: Hide a = Case.getA(); // Stop now! The compiler sais he dont know anything 'bout the class "Hide"! // Wouldnt it even better to have a result like: Show a = Case.getA(); // Well, even the method Hide.getText isnt accessible anymore. // I accept that eclipse wouldnt know what a interface you like to have, so // cant you guys show a modal Dropdown of Resulting Types? } } I hope i can reproduce what i am missing. Regards
Forward to UI for comment.
Test Case for easy pasting: package sumsum; public interface Show {} package sumsum; interface Hide extends Show{ String getText(); } package sumsum; public class Case{ public static Hide getA(){return null;} } package org.dontknow.jack; import sumsum.Case; class Main{ public static void main(String[]args){ Case.getA(); // <- extract this } }
Reproducible using Eclipse build id: I20130618-0800 During refactoring user is informed about the visibility issue of the type being extracted to. As suggested in the bug report, if refactoring encounter such a visibility issue, then it will be good to give user options of valid types to choose from, so that we can avoid the compiler error after the refactoring.
(In reply to comment #3) > Reproducible using Eclipse build id: I20130618-0800 > During refactoring user is informed about the visibility issue of the type > being extracted to. This is not what I see using R4.3 when invoking Extract Method on the snippet from comment 1. Also the Extract to ... Quick Fixes fail with an error - no dialog or warning is shown.
(In reply to comment #4) > This is not what I see using R4.3 when invoking Extract Method on the > snippet from comment 1. Refactor> Extract Local Variable... and Refactor> Extract Constant... informs user about the visibility issue. But i understand that user here is talking about the quick assist options available and yes currently we do not give any warning regarding the visibility issues in this case. > Also the Extract to ... Quick Fixes fail with an > error - no dialog or warning is shown. Though user ends up with a compiler error after the quick assist, I did not see the quick assist failing with an error. The improvement user is asking for (having a drop down to select from one of the possible types) can be taken up as an enhancement.