Skip to content

Kernel's VM specific mixin transformation generates classes with incompatible overrides #30674

Open
@mraleph

Description

@mraleph

When I compile the following Dart code below:

abstract class I<T> {
  void map(void f(T e));
}


class A<T> {
  void map(void f(T e)) {

  }
}

abstract class B implements I<int> {
}

class Good extends A<int> with B implements I<int> {
}

In Kernel I get:

  abstract class _A&B^#U0^<#U0 extends core::Object> extends y::A<y::_A&B^#U0^::#U0> implements y::B {
    constructor •() → void
      : super y::A::•()
      ;
  }
  class Good extends y::_A&B^#U0^<core::int> implements y::I<core::int> {
    default constructor •() → void
      : super y::_A&B^#U0^::•()
      ;
  }

The artificial class introduced by mixin transformation actually introduces incompatible override: A<#U0> provides A<#U0>.map of type ((#U0) -> void) -> void, but implements y::B requires map of type ((int) -> void) -> void. These types are incompatible.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions