toString() of enum has changed or broken?

compilng for Android from swift3

we use Int enums…
we override toString() so in Java they serialise as Strings.

this used to work in previous versions.
but now with swift3 and Fire 2151 it’s not working.

the enums cover to “0”, 1", etc…

is this a bug or did something change that I’m not aware of?

public enum Blah
{
case ONE
case TWO
case THREE

public func toString() -> String
{
    switch (self)
    {
    case .ONE: return "ONE"
    case .TWO: return "TWO"
    case .THREE: return "FOUR"
        
    }
}

}

also…

Blah.ONE.toString();
does not compile in Android Studio

but I’m pretty sure it used to?

either way…
String s = “” + Blah.ONE;
leaves s = “0”

Thanks, logged as bugs://78359

thanks guys.
would love to get a beta update when this is fixed.
(we can work around it with structs,… but there are a lot of them to do)…

have a good weekend.

FWIW, the best way to get automatic and immediate beta access it to buy a license :stuck_out_tongue_winking_eye:

bugs://78359 got closed with status fixed.

Oke so what works now is explicitly calling “toString”. However when boxing it it still becomes an integer (thats how we store simple enums). The next version will also allow this:

import java.util

public protocol Serializable
{}

public enum Blah: Serializable
{
	case ONE
	case TWO
	case THREE

	public override func toString() -> String
	{
		switch (self)
		{
			case .ONE: return "ONE"
			case .TWO: return "TWO"
			case .THREE: return "FOUR"
		}
	}
}

writeLn(Blah.ONE().toString());

the protocol name doesn’t matter, but adding a protocol to an enum will emit a wrapper class that will probably work better for you.