Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333243

Summary: [inline] inlining RHS of assignment which is not statement results in compile error
Product: [Eclipse Project] JDT Reporter: Vladislav Kuzkokov <vladislav.kuzkokov>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, deepakazad
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Vladislav Kuzkokov CLA 2010-12-27 09:37:52 EST
Build Identifier: M20100909-0800

Inlining of "complex" functions returning a value is allowed iff it's either initializer or a right-hand side of assignment. In the latter case it might be also needed to check if this assignment is a part of a more complex statement.

Reproducible: Always

Steps to Reproduce:
1. Input java source
public class Test {
	public static int doSth(String s) {
		int res = s.length();
		return res;
	}
	public static void main(String[] args) {
		String s;
		int t;
		System.out.printf(s = "%d", t = doSth(s));
	}
}
2. Use "Inline..." on method "doSth"
3. Get uncompilable code
Comment 1 Deepak Azad CLA 2010-12-27 14:01:18 EST
---------------------------------------------------
public class Test {
    public static int doSth(String s) {
        int res = s.length();
        return res;
    }
    public static void main(String[] args) {
        String s;
        System.out.printf(s = "%d", doSth(s));
    }
}
---------------------------------------------------

Inlining in the above snippet results in the following error - 
"Inlining is only possible on simple functions (consisting of a single return statement), or functions used in an assignment."
This is inconsistent behavior, if inline is allowed in snippet from comment 0, it should also be allowed in the above snippet.

One solution could be to allow inlining in case of assignment only when the assignment is the complete statement.

Another could be to fix Bug 99477 (though that would still leave the compile error issue)
Comment 2 Eclipse Genie CLA 2019-11-09 14:54:35 EST
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.