Community
Participate
Working Groups
Build Identifier: I20110613-1736 The infix operator '+=' is not supported by Xtend. Using it causes Xtend to underline the operator as if it were an error, providing a tooltip that reads: "Couldn't resolve reference to JvmIdentifiableElement '+='". Example: [xtend] var i1 = 1 var i2 = 1 i1 += i2 [/xtend] Moreover, quick fixes (replacing the '+=' operator with a comparison operator) are not available for String objects. Reproducible: Always Steps to Reproduce: 1. Create a new .xtend class 2. Define a method and type the following in the method body: var i1 = 1 var i2 = 1 i1 += i2
The operator '+=' is mapped to functions with the name 'add' (operator overloading). Since int doesn't define such a function (and there is no such extension function defined as well) the operator is not available for int. It wouldn't behave like in C or Java though, because ints are immutable.
(In reply to comment #1) > The operator '+=' is mapped to functions with the name 'add' (operator > overloading). Since int doesn't define such a function (and there is no such > extension function defined as well) the operator is not available for int. It > wouldn't behave like in C or Java though, because ints are immutable. Okay. I expected it to work like in Java. Now I took a closer look at the documentation and noticed the difference between _operator_add() and _operator_plus() :) However, there is no quick fix available for Strings, though similar looking operators (<=) exist.
Closed as won't fix since similar looking is not really similar if 50% of the characters are different. It would actually involve less keystrokes to fix the operator manually instead of scrolling through a list of proposals like !=, ==, <=, >=, <, > where even the alphabetic order is not too meaningful for the user.
Closing all bugs that were set to RESOLVED before Neon.0