Skip to content

kernel: Do not abstract and share mixin applications #31118

Closed
@rakudrama

Description

@rakudrama

dart2js is blocked on this issue.

Consider:

class One<R> {}

class AnInterface<X> implements One<int> {}

class ADifferentInterface<Y> extends AnInterface<Y>{}

class TheMixin<Q> implements AnInterface<Q>  {}

class Two<T> extends One<int> with TheMixin<T> implements AnInterface<T> {}

class Three<T> extends One<int> with TheMixin<T> implements ADifferentInterface<T> {}

main() {
  new Two<double>();
}

What we see is that One<int> with TheMixin<T> is abstracted like so

class OneWithTheMixin<U, V> = One<U> with TheMixin<V>;
class Two<T> extends OneWithTheMixin<int, T> ...

This breaks on dart2js. dart2js has a constraint that a class cannot implement a type with different parameterizations. (The constraint allows the relationship between Two and One to be expressed as a function, the existence of this function is fundamental to the whole type representation.)

However, the introduced type OneWithTheMixin implements One<U> and One<int>. In particular, the raw type OneWithTheMixin implements One<dynamic> and One<int>.

The simplest for dart2js would be to create a fresh class for each with. This is what the old pipeline does - so it would be an advantage to do the same (we can compare outputs), and then reconsider a version of this abstraction later when we are done with the transition to Kernel.

This issue is blocking our next step, compiling angular apps with dart2js-with-kernel, so it is our highest priority issue with kernel.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions