Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
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

Description

@vsmenon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions