Skip to content

mixin member invalid override on non conflicting types error #57005

Open
@bar4488

Description

@bar4488

It seems that if 2 mixins declare the same member with different bounds, the type of the latter mixin member must conform to the type first mixin member, which can throw an error even in cases where the class using the mixin is able to satisfy both types.

mixin LongRangeWeapon {}

mixin ExplosionWeapon {}

class Shotgun with LongRangeWeapon, ExplosionWeapon {}

mixin Shooter {
  LongRangeWeapon get weapon;
}

mixin Bomber {
  ExplosionWeapon get weapon;
}

abstract class Combatant with Shooter, Bomber { // 'Bomber.weapon' ('ExplosionWeapon Function()') isn't a valid override of 'Shooter.weapon' ('LongRangeWeapon Function()')
  @override
  Shotgun get weapon;
}

expected behavior: There should not be any error as long as the class itself validly satisfies both mixin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).type-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions