Apologies in advance for bundling all this into one issue, but just trying to document various issues trying to use Swift enums in Silver/Fire.
These are all in 9.1.100.2125, using a Cooper console project.
Baseline - this behaves as expected
public enum MyEnum { case hello case world } let h = MyEnum.hello printEnum(e: h) printEnum(e: MyEnum.world) func printEnum(e: MyEnum) { switch e { case .hello: print("hello") case .world: print("world") default: print("default") } }
Issue 1 - verify error
Change the parameter type of e to MyEnum! , and you get a runtime Verify error
!> Fatal exception of type java.lang.VerifyError on thread 0001 ()
!> Message: (class: consoleapplication334/__Global, method: printEnum__e signature: (Ljava/lang/Object;)V) Incompatible object argument for function call
Issue 2 - error E348: “mapped” is only allowed for methods on mapped types
Change MyEnum to be back by a string, and in the same file, and you get:
Issue 3 - Various String based enum type issues
Change MyEnum to be backed by a string, and move it to a separate file:
public enum MyEnum: String { case hello case world }
And you get:
Try and strongly type h to MyEnum and you get:
Try and force cast to MyEnum and you get:
Try and follow the errors through and type it all as String!, and then you can’t use a switch anymore:
This combination works and runs as expected, but is not at all nice that you have to erase the enum type to a string to do it:
Issue 4 - error E0: Internal error: Object reference not set to an instance of an object
With MyEnum in its own file, change the param type of e to MyEnum! (same with MyEnum?)
and you get