有没有办法在枚举之间继承?

Is there any way to have inheritance between Enums?

我想在我定义的一些枚举之间继承。

假设我有以下代码:


/**
 * @enum {!number}
 */
var MyBaseEnum = {
    IS_VALID         : 0b00000001,
    UNDER_VALIDATION : 0b00000010,
    SUBMITTING       : 0b00000100
};

/**
 * @enum {!number}
 * @extends {MyBaseEnum}
 */
var MyChildEnum = {
    AN_ODDBALL_STATE      : 0b00001000,
    ANOTHER_ODDBALL_STATE : 0b00010000
};

goog.inherits(MyChildEnum, MyBaseEnum);

/**
 * @param  {!MyBaseEnum} myEnum
 * @return {!string}
 */
function iExpectBaseEnum (myEnum) {
    switch (myEnum) {
        case MyBaseEnum.IS_VALID:
            return "It's valid, man!";
        case MyBaseEnum.UNDER_VALIDATION:
            return "Chill, I'm working on it.";
        case MyBaseEnum.SUBMITTING:
            return "Under submission, bro.";
        default:
            return 'WAT';
    }
};

/**
 * @param  {!MyChildEnum} myEnum
 * @return {!string}
 */
function iExpectChildEnum (myEnum) {
    switch (myEnum) {
        case MyChildEnum.AN_ODDBALL_STATE:
            return 'Dunno.';
        case MyChildEnum.ANOTHER_ODDBALL_STATE:
            return 'Dunno, bro.';
        // Accessing parent's IS_VALID would be nice through MyChildEnum.
        case MyChildEnum.IS_VALID:
            return "It's valid, man!";
        // But also would be nice to have it work with paren'ts value.
        case MyBaseEnum.UNDER_VALIDATION:
            return "Chill, I'm working on it.";
        case MyBaseEnum.SUBMITTING:
            return "Under submission, bro.";
        default:
            return 'WAT';
    }
};

目前我只是找不到在我的枚举之间继承的方法 AND 仍然让它们表现得像枚举(我可以做一个非常丑陋的恶作剧来实现我自己的带有泛型的枚举系统,但是......糟糕...... + 我会从编译器中失去很多果汁。

有没有什么方法可以在我的枚举之间继承或以某种方式解决枚举特异性和扩展的概念问题?

我假设,使用 Google Closure Compiler 我们不能在枚举之间继承。

我假设的基础是,Java 不允许一个枚举继承另一个枚举(尽管使用接口有一些肮脏的空间),并且 Google Closure Compiler 似乎受到了很大的启发通过 Java.