Skip to content

incorrect override error generated by front-end for mixin #32183

@mraleph

Description

@mraleph
class X {}

abstract class A<Result, Input> {
  Result f(Input v);
}

abstract class A0<Result, Input> extends A<Result, Input> {
}

abstract class M extends A<X, num> implements X {
  @override
  M f(num v) => null;
}

class _C extends A0<X, num> with M {
}

void main() {
}

results in

file:///tmp/xxx.dart:17:7: Error: The return type of the method '_C::f' is #lib1::X, which does not match the return type of the overridden method (#lib1::M).
Change to a subtype of #lib1::M.
class _C extends A0<X, num> with M {
      ^
file:///tmp/xxx.dart:14:5: Error: This is the overriden method ('f').
  M f(num v) => null;
    ^

This is most likely caused by the forwarding stub generated in _C

  abstract class _A0&M^#U0&#U1^<#U0 extends core::Object, #U1 extends core::Ob
ject> extends xxx::A0<xxx::_A0&M^#U0&#U1^::#U0, xxx::_A0&M^#U0&#U1^::#U1> impl
ements xxx::M {
    synthetic constructor •() → void
      : super xxx::A0::•()
      ;
    method f(generic-covariant-impl generic-covariant-interface core::num v) → xxx::M
      return null;
  }

  class _C extends xxx::_A0&M^#U0&#U1^<xxx::X, core::num> {
    synthetic constructor •() → void
      : super xxx::A0::•()
      ;
    abstract forwarding-stub method f(generic-covariant-impl core::num v) → xxx::X;
  }

This example is extracted from package:file used by Flutter.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions