Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

[SoM] trivial enums aren't showing constructors, methods and properties #140

Open
stephen-hawley opened this issue Apr 25, 2018 · 0 comments
Milestone

Comments

@stephen-hawley
Copy link
Contributor

public enum {
    case good, bad
    public init(isGood: Bool) {
        if isGood {
            self = .good
         }
        else {
            self = .bad
        }
    }
    public func convertToString() -> String {
        if self == .good {
            return "Good"
        }
        else {
            return "Bad"
       }
    }
}

This is tricky in that the distinction between trivial and non-trivial enums has to do with whether or not the have a case with a non-integral payload.
A non-trivial enum is represented by a class that implements ISwiftEnum.
A trivial enum is represented by an enum. We also create a set of extension methods on it.
There are two options here.
The easiest path is to redefine a non-trivial enum as having either a non-trivial enum or having methods. This is not palatable because it adds overhead to all marshaling for that type which should have 0 overhead.
The other path is to put every method into the extension methods. This is possible, but the problem is that every method has to be transformed into a static extension method, which puts them through a completely different code path than either structs or classes or non-trivial enums, which all share the same code paths.

@stephen-hawley stephen-hawley transferred this issue from another repository Oct 29, 2019
@chamons chamons added this to the Future milestone Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants