Bug 548665 - [inline] Inline Local Variable doesn't produce correct code when type witness would be needed
Summary: [inline] Inline Local Variable doesn't produce correct code when type witness...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-26 05:34 EDT by Lukas Eder CLA
Modified: 2023-06-09 07:06 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 Lukas Eder CLA 2019-06-26 05:34:51 EDT
The "Refactor > Inline" refactoring produces correct output for most cases, but in some cases, the output would need a type witness, which is not generated e.g. when inlining the stream variable:

// ----------------------------
import java.util.stream.Stream;

public class X {
    void m() {
        Stream<Integer> stream = Stream.of();
        System.out.println(stream.reduce(0, Math::addExact));
    }
}
// ----------------------------

Inlining the stream variable produces

// ----------------------------
import java.util.stream.Stream;

public class X {
    void m() {
        System.out.println(Stream.of().reduce(0, Math::addExact));
    }
}
// ----------------------------

Which does not compile in Java 11. The correct output would have been:

// ----------------------------
import java.util.stream.Stream;

public class X {
    void m() {
        System.out.println(Stream.<Integer>of().reduce(0, Math::addExact));
    }
}
// ----------------------------
Comment 1 Eclipse Genie CLA 2021-06-16 15:40:00 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Thomas Wolf CLA 2021-06-16 16:28:43 EDT
Still occurs on 2021-06.
Comment 3 Eclipse Genie CLA 2023-06-09 07:06:58 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.