The following code compiles and should be fine, but it throws a java InstantiationError, when the class needsStuff is instantiated.
import android.app
import android.content
import android.os
import android.util
import android.view
import android.widget
public protocol Stuff{
func somefunc(_ x: String)->String
}
class concretestuff: Stuff{
public func somefunc(_ x: String) -> String {
return x+x
}
init(){}
}
public protocol facp{
init()
func makestuff()->Stuff
}
class concretefac: facp{
required init(){}
public func makestuff() -> Stuff {
return concretestuff()
}
}
class needsStuff<F: facp>{
private var factory: F
init(){
factory = F()
}
}
public class MainActivity: Activity {
public override func onCreate(_ savedInstanceState: Bundle!) {
super.onCreate(savedInstanceState)
ContentView = R.layout.main
}
let t = needsStuff<concretefac>()
}
This can be circumvented by getting rid of the generic parameter in needsStuff (essentially making the generic parameter a constructor parameter)
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