jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

enum and private variables.

Open arenevier opened this issue 3 years ago • 1 comments

Hi, the ts generated by the following code fails to compile:

public enum Bar {
  LOW {
    @Override
    public long value() {
      return ratio * 1L;
    }
  },
  MEDIUM {
    @Override
    public long value() {
      return ratio * 2L;
    }
  },
  HIGH {
    @Override
    public long value() {
      return ratio * 3L;
    }
  };

  private static final long ratio = 1L;

  public abstract long value();
}

with error Property 'ratio' does not exist on type 'typeof Bar'

Here is the problematic part of the generated ts:

export enum Bar {
    LOW, MEDIUM, HIGH
}

/** @ignore */
export abstract class Bar_$WRAPPER {
   
    ...

    static ratio = 1;

     ...
}

...


export namespace Bar {
    
    /** @ignore */
    export class Bar$0_$WRAPPER extends Bar_$WRAPPER {

        ...
        
        /**
         * 
         * @return {number}
         */
        public value(): number {
            return Bar.ratio * 1;
        }
    }
   .... 
}

arenevier avatar Jan 14 '21 21:01 arenevier

Thanks for reporting

lgrignon avatar Jan 15 '21 08:01 lgrignon