Skip to content

Having a mixin implement a private member of another mixin causes a name collision #4244

Open
@rrousselGit

Description

@rrousselGit

Consider the following:

// mixin.dart
mixin Mixin {
  int _method(int value);

  // Some more methods
}

mixin OtherMixin on Mixin {
  @override
  int _method(int value) => value;
}

Then:

import 'mixin.dart';

class Foo with Mixin, OtherMixin {}

This unexpectedly fails with:

The private name '_method', defined by 'OtherMixin', conflicts with the same name defined by 'Mixin'.
Try removing 'OtherMixin' from the 'with' clause.dart[private_collision_in_mixin_application](https://dart.dev/diagnostics/private_collision_in_mixin_application)

But there's no name conflict. Instead OtherMixin._method is from the same interface as Mixin._method

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions