Skip to content

Analyzer issues incorrect warning on inconsistent interfaces in mixin inference #34404

@leafpetersen

Description

@leafpetersen

The analyzer issues the following warnings on the code below:

  error • Type parameters could not be inferred for the mixin 'M1' because the base class implements the mixin's supertype constraint 'I<T>' in multiple conflicting ways at /Users/leafp/tmp/ddctest.dart:10:33 • mixin_inference_inconsistent_matching_classes
  error • A value of type 'int' can't be assigned to a variable of type 'String' at /Users/leafp/tmp/ddctest.dart:13:14 • invalid_assignment

Note that the second (expected) error does imply that the mixin inference is succeeding and inferring int as the type argument, but nonetheless the first (unexpected) error is emitted as if inference had failed.

class I<X> {}

class M0<T> extends I<T> {}

class M1<T> extends I<T> {
  T foo() => null;
}

// M1 is inferred as M1<int>
class A extends I<int> with M0, M1 {}

void main () {
  String s = new A().foo();
}

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failureslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions