Menu

#113 Bug in trinary expressions

Self_Reported
open
nobody
5
2012-11-27
2007-06-22
zuegerr
No

If the two reference types of a trinary expression are not in a subtype relationship, MultiJava complains by returning "File "CondTest.java", line 4, character 34 error: Incompatible types in trinary expression [JLS 15.24]"

In the code, it is enforced that either one has to be the supertype and the other the subtype

Example:

class CondTest {

void m() {
Object o = true ? "" : new Integer(5);
}
}

String "" and Integer 5 are in no subtype relationship. Correct was to take the greatest common supertype, i.e. Object.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB