The following Code makes the Compiler emit an E0-Error:
" Internal error: Object not set to an instance of an object."
public typealias MySequenElement = (String,Int)
class CountDownIterator:java.util.Iterator<MySequenElement>{
private var count:Int
init(count:Int){
self.count = count
}
func hasNext() -> Bool {
return count>0
}
func next() -> (String,Int) {
let ret = ("\(count)",count)
count -= 1
return ret
}
func remove() {
// count -= 1
}
}
class mysequence:ISequence<MySequenElement>{
init(){
}
func iterator() -> java.util.Iterator<MySequenElement>! {
return CountDownIterator(count:10)
}
}
class testSilverFeatures{
public func testsucc(){
assert(true)
}
public func testsequence(){
let seq = mysequence()
var c = 0
for (name,elt) in seq {
c += 1
println(name + "\(elt)")
}
assert(c == 10)
}
}
The error occurrs in the loop in the function testsequence.
But if i manually substitude each occurrence of MySequenElement by its definition:(String,Int), like below, it compiles!
class CountDownIterator:java.util.Iterator<(String,Int)>{
private var count:Int
init(count:Int){
self.count = count
}
func hasNext() -> Bool {
return count>0
}
func next() -> (String,Int) {
let ret = ("\(count)",count)
count -= 1
return ret
}
func remove() {
// count -= 1
}
}
class mysequence:ISequence<(String,Int)>{
init(){
}
func iterator() -> java.util.Iterator<(String,Int)>! {
return CountDownIterator(count:10)
}
}
class testSilverFeatures{
public func testsucc(){
assert(true)
}
public func testsequence(){
let seq = mysequence()
var c = 0
for (name,elt) in seq {
c += 1
println(name + "\(elt)")
}
assert(c == 10)
}
}
That was quite some headscratcher for me…
Version Info:
Microsoft Visual Studio 2015 Shell (Integrated)
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081
Installed Version: IDE Standard
RemObjects Elements 9.0.97.2071
RemObjects Elements (Oxygene, C# and Silver) for .NET, Cocoa and Java.
Copyright 2003-2016 RemObjects Software, LLC. All rights reserved.
http://www.remobjects.com/elements
RemObjects Elements leverages the LLVM compiler backend:
Copyright © 2003-2016 University of Illinois at Urbana-Champaign. All rights reserved.
http://llvm.org
RemObjects Everwood 4.7.79.695
RemObjects Everwood
Copyright RemObjects Software, LLC 2002-2016. All Rights Reserved.
http://www.remobjects.com/everwood