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

Bug 351086

Summary: Inline trivial boolean method into call argument produces broken code
Product: [Eclipse Project] JDT Reporter: Andreas Kohn <andreas.kohn>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: amj87.iitr, daniel_megert, stephan202
Version: 3.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Andreas Kohn CLA 2011-07-04 09:12:41 EDT
Build Identifier: I20110613-1736

Assume the following code:

public class FooBar {
	protected boolean isFoo() {
		return getBar() > 0;
	}
	
	protected int getBar() {
		return 1;
	}
	
	protected void assertTrue(boolean x) {
		// Nothing
	}
	
	protected void dummy() {
		assertTrue(isFoo());
	}
}

When inlining #isFoo() I'd expect dummy() to look like this:
protected void dummy() {
	assertTrue(getBar() > 0);
}

But one gets:
protected void dummy() {
	assertTrue(getBar() > 0;
}
(note the missing ')', which leads to obvious compile errors).


Reproducible: Always

Steps to Reproduce:
See summary
1. Inline a boolean method that is directly called to produce a parameter value for another method
2. Missing ')' in the inlined places.
Comment 1 Ayushman Jain CLA 2011-07-04 09:31:16 EDT
Moving to JDT/UI for investigation.
Comment 2 Dani Megert CLA 2011-07-19 07:15:47 EDT
1. download 3.7 SDK from:
http://download.eclipse.org/eclipse/downloads/drops/R-3.7-201106131736/index.php
2. start new workspace
3. paste the code from comment 0 into Package Explorer
4. inline isFoo()

==> works fine - no compile errors.
Comment 3 Andreas Kohn CLA 2011-07-19 08:38:51 EDT
I now retried this following the description from comment 2, and can also no longer reproduce it.

As soon as I see it again, what would be information I should immediately provide about the state? And, should I reopen this bug, or file a new one and link them together?
Comment 4 Dani Megert CLA 2011-07-19 08:47:07 EDT
(In reply to comment #3)
> I now retried this following the description from comment 2, and can also no
> longer reproduce it.
> 
> As soon as I see it again, what would be information I should immediately
> provide about the state? 
Check the .log for errors. Also, provide the JRE and the project compliance you're using. If possible attach the whole project.

> And, should I reopen this bug, or file a new one and
> link them together?
Just reopen this one.