New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abstract of enum - implicit cast not working in Map literals #4100

andywhite37 opened this Issue Mar 29, 2015 · 0 comments


None yet
1 participant

andywhite37 commented Mar 29, 2015

Hi, I'm not sure if this issue already exists, or if there are any workarounds. If I create an abstract wrapper for an enum, and the abstract has implicit cast function (@:from), the compiler doesn't recognize the implicit cast inside Map literals.

enum ValueEnum {
  VString(v : String);
  VInt(v : Int);

abstract ValueAbs(ValueEnum) {
  public inline function new(v : ValueEnum) {
    this = v;

  public static function fromString(v : String) : ValueAbs {
    return new ValueAbs(VString(v));

  public static function fromInt(v : Int) {
    return new ValueAbs(VInt(v));

class Test {
  static function main() {
    // compiles and works
    var myMap = new Map<String, ValueAbs>();
    myMap.set("one", "some string");

    // Doesn't compile
    var myMap2 : Map<String, ValueAbs> = [
      "one" => "some other string"


@Simn Simn closed this in 094db4e Mar 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment