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

In generic type definition, optimize self references. #556

Closed
vsmenon opened this issue May 6, 2016 · 0 comments
Closed

In generic type definition, optimize self references. #556

vsmenon opened this issue May 6, 2016 · 0 comments
Labels

Comments

@vsmenon
Copy link
Contributor

vsmenon commented May 6, 2016

This is an optimization that will happen to avoid one case of #253 that we're hitting.

Here's a simplification:

class Bar<T> {
}

class Foo<T> extends Bar<Foo<T>> {
}

void main() {
  print(new Foo<int>());
}

It hits an infinite loop today. Here's the generate JS:

  generic.Bar$ = dart.generic(T => {
    class Bar extends core.Object {}
    return Bar;
  });
  generic.Bar = generic.Bar$();
  generic.Foo$ = dart.generic(T => {
    class Foo extends generic.Bar {}
    dart.setBaseClass(Foo, generic.Bar$(generic.Foo$(T)));
    return Foo;
  });
  generic.Foo = generic.Foo$();

The recursive call to generic.Foo$(T) is causing the problem. We could safely replace it with Foo, which is already defined in scope here.

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

No branches or pull requests

2 participants