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
Description
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.