Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369295 - [extract method] Extract code in a method that returns generic type causes compilation error
Summary: [extract method] Extract code in a method that returns generic type causes co...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-20 16:11 EST by Milos Gligoric CLA
Modified: 2012-01-21 13:13 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milos Gligoric CLA 2012-01-20 16:11:39 EST
Build Identifier: Version: 3.7.1 Build id: I20110613-1736

Extract method refactoring introduces incorrect return type for the extracted method.

Reproducible: Always

Steps to Reproduce:
1. Mark "toExtract(list)" in the example below
2. Perform ExtractMethod refactoring
3. The resulting code is not compilable

class ExtractMethod {

    class C {
        void m() {
        }
    }

    <T extends Comparable<? super T>> void method(List<T> list) {
        toExtract(list).m();
    }

    static <T extends Comparable<? super T>> C toExtract(List<T> list) {
        return null;
    }
}
Comment 1 Mohsen Vakilian CLA 2012-01-21 07:54:14 EST
Refactorings have a few other bugs in handling generics (See Bug 94639, Bug 240353, and Bug 357998).
Comment 2 Deepak Azad CLA 2012-01-21 13:13:51 EST
We were not copying the type bounds, simple fix.

Fixed in master - e5035aaa0b268ce1b0110eaddb3424e954aa45eb