Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362937 - [Xbase 2.1] Negative XIntLiterals results in wrong Java code when converting PrimitiveToWrapper
Summary: [Xbase 2.1] Negative XIntLiterals results in wrong Java code when converting ...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-04 15:16 EDT by Ingo Meyer CLA
Modified: 2017-09-19 17:29 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ingo Meyer CLA 2011-11-04 15:16:21 EDT
Build Identifier: 20110609-2236

With negative values for a XIntLiteral the Xbase compiler produces illegal code through method the method TypeConvertingCompiler.convertPrimitiveToWrapper:
"( ((Integer) - 1) )".
This could be easily solved by put the primitive value into parentesis: ""( ((Integer) (- 1)) )".
In 2.0.1 the following was working but with 2.1 the context variable is missing:

	protected void convertPrimitiveToWrapper(
			final JvmTypeReference wrapper,
			final IAppendable appendable,
			final XExpression context,
			final Later expression )
	{
		appendable.append( "((" );
		serialize( wrapper, null, appendable );
		appendable.append( ")" );
		if (context instanceof XIntLiteral)
		{
			final XIntLiteral xInt = (XIntLiteral) context;
			if (xInt.getValue() < 0)
			{
				appendable.append( "(" );
				expression.exec();
				appendable.append( ")" );
			}
			else
				expression.exec();
		}
		else
			expression.exec();
		appendable.append( ")" );
	}




Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-11-07 07:33:16 EST
Pushed to master.
Comment 2 Karsten Thoms CLA 2017-09-19 17:18:03 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:29:23 EDT
Closing all bugs that were set to RESOLVED before Neon.0