using [java]fanx.interop::Interop
using [java]java.util::ArrayList
class TestList : Test{
Void test(){
arrList := ArrayList()
arrList.add(ArrayList())
arrList.add(ArrayList())
arrList.add(ArrayList())
// case 1
ArrayList[] inlineMe := Interop.toFan(arrList.iterator)
row := inlineMe.map|tr|{tr.toString}
// case 2
row2 := Interop.toFan(arrList.iterator).map|ArrayList tr|{tr.toString}
// failed
verifyEq(row,row2)
}
}
Output:
TEST FAILED
sys::TestErr: Test failed: sys::Obj?[[], [], []] != sys::Obj?[null, null, null]
vkuzkokovSat 28 Aug 2010
It's not inlining. It's type inference. You explicitly say that inlineMe is ArrayList[], while toFan returns Obj?[]. If you will delete explicit ArrayList[] you'll get compilation error on the next line. It's because tr type will be resolved as Obj? and therefore won't have toString.
The idea of the above is that case 1 and case 2 are not supposed to do the same.
Here, case 1 gives us what is expected. [] is the value of toString for empty list in java. You can use non-empty list for clarification. when you write:
Akcelisto Sat 28 Aug 2010
Output:
vkuzkokov Sat 28 Aug 2010
It's not inlining. It's type inference. You explicitly say that
inlineMe
isArrayList[]
, whiletoFan
returnsObj?[]
. If you will delete explicitArrayList[]
you'll get compilation error on the next line. It's becausetr
type will be resolved asObj?
and therefore won't havetoString
.The idea of the above is that case 1 and case 2 are not supposed to do the same.
Here, case 1 gives us what is expected.
[]
is the value of toString for empty list in java. You can use non-empty list for clarification. when you write:it's understood as:
Note that it's different from
because latter returns
Void
. Thusrow2
is an array ofVoid
s which are interpreted as nulls (we can't haveVoid[]
indeed).Akcelisto Sat 28 Aug 2010
Thanks to vkuzkokov. I understood: case 1 and case 2 is not equivalent.
Now test passed.