| Summary: | [15] refactor patterninstanceof for extracting a method gives wrong code | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Manoj N Palat <manoj.palat> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, jjohnstn, kalyan_prasad, manoj.palat |
| Version: | 4.17 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
This no longer occurs. The Extract Method menu item is not offered for the Pattern instanceof. |
Given: class X { private void foo(Object o) { if (o instanceof X x) { // select the entire o instanceof X x System.out.println(x.toString()); x.foo(null); } } } select the entire o instanceof X x and Refactor->Extract Method gives: class X { private void foo(Object o) { if (extracted(o)) { // select the entire o instanceof X x System.out.println(x.toString()); x.foo(null); } } private boolean extracted(Object o) { return o instanceof X x; } } clearly an error at the method call extracted(o) Y build Version: 2020-09 (4.17) Build id: Y20200909-1200