The following code throws ClassCastException at runtime, should instead be a compiler error
class HelloFantom{
Void main(){
HelloFantom h := false?HelloFantom():"test"
}
}
brianTue 14 Jun 2011
Although not ideal, that is technically the correct behavior from an expression point of view.
The expression false?HelloFantom():"test" has an inferred typed of Obj since that is the common base type between HelloFantom and Str. Then the entire expression is coerced from Obj to HelloFantom using Fantom's normal rules.
kaushik Tue 14 Jun 2011
The following code throws ClassCastException at runtime, should instead be a compiler error
brian Tue 14 Jun 2011
Although not ideal, that is technically the correct behavior from an expression point of view.
The expression
false?HelloFantom():"test"
has an inferred typed ofObj
since that is the common base type betweenHelloFantom
andStr
. Then the entire expression is coerced fromObj
toHelloFantom
using Fantom's normal rules.