Community
Participate
Working Groups
N20081017-2000. With the changes made to fix bug 146768 it is now possible to inline invalid selections/methods. This is also surfaced by a broken test, see: http://download.eclipse.org/eclipse/downloads/drops/N20081017-2000/testresults/html/org.eclipse.jdt.ui.tests.refactoring_linux.gtk.x86_6.0.html
Can you please paste the test case in this bug?
Sure,it's: org.eclipse.jdt.ui.tests.refactoring.InlineMethodTests.testMultipleMethods
Sorry, I meant the source code that doesn't compile (I don't understand how the test works)
Here's a test case: package test; public class TestMultipleMethods { void bar() { toInline(""); } public void toInline(String d) { System.out.println(d); } public void toInline(String d) { System.out.println(""); } } Trying to inline 'toInline' inside bar() should fail but doesn't anymore. Also note that the first duplicate method doesn't get an error anymore which I think is wrong too.
FYI: I've disabled the test in HEAD.
Dani, the whole point of bug 146760 was to make duplicate fields & methos behave like other duplicate elements. We no longer complain against the first duplicate field/method, so it means less secondary errors because the first field/method is now available. I do not see this as a bug with 146760, but your test needs to be updated or just deleted.
Kent, it's not just the test: 1. when the user tries to inline code it now works on stuff that has errors and the result is not predictable. It should not allow the refactoring and for that we need to get an error reported (reconcile plus binding) 2. as a user it is just wrong that the first dup one isn't flagged with an error. What if I open a large file? I have to scroll down to notice that one of my methods is duplicated.
I agree for errors on each dup field/method. All needed for original bug was a way to avoid secondary issues when referring to a dup method/field (i.e. leaving a binding behind)
Dani, we released a new patch for bug 146760 which reports a duplicate error against each field/method. BUT we keep the first binding around so any valid references to it are compiled with an error. I think your test will still fail if you assume that this won't compile : void bar() { toInline(""); }
Sorry that should have said BUT we keep the first binding around so any valid references to it are compiled withOUT an error.
Kent, your fix does the trick because we check for errors on the methods. You can mark this bug FIXED. Thanks.
Fixed with the new patch for bug 146760
Verified for 3.5M3 using I20081026-2000 build.