Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Generics and named constructors #158

Closed
vsmenon opened this issue Apr 24, 2015 · 4 comments
Closed

Generics and named constructors #158

vsmenon opened this issue Apr 24, 2015 · 4 comments

Comments

@vsmenon
Copy link
Contributor

vsmenon commented Apr 24, 2015

We appear to generate invalid code for named constructors with generic types:

class A<T> {
  A.named() {
    init();
  }

  init() {
    print('hello');
  }
}

main() {
  new A<int>.named();
}

results in this error when the named constructor is executed:
"Uncaught TypeError: this.init is not a function"

@vsmenon
Copy link
Contributor Author

vsmenon commented Apr 24, 2015

@jmesserly helped me track this down to precedence.

We're generating:

new A$(core.int).named();

We should be generating:

new (A$(core.int).named)();

@vsmenon
Copy link
Contributor Author

vsmenon commented May 4, 2015

This is somewhat related to / muddled by #162.
E.g., this surprisingly seems to work today:

  new core.Map$(core.String, core.String).from(oldmap);

but it is actually creating an empty Map via the default constructor and calling from as an instance method on it.

@jmesserly
Copy link
Contributor

yeah, that's the same bug

@jmesserly
Copy link
Contributor

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

No branches or pull requests

2 participants