Skip to content

recursive_inheritance_test fails in strong mode #26970

Closed
@jmesserly

Description

@jmesserly

we do correctly reject the code (new MI() not being legal in strong mode), but it seems like we're going off the rails a bit here. I would expect the error at the new expressions. Instead we seem to infer non-sensical type arguments for new MI and new PMI.

import "package:expect/expect.dart";

// Regression test for recursive inheritance patterns
abstract class Comparable<T> {
  int compare(T a);
}
class MI<T extends MI<T>> {}

class PMI<T extends Comparable<T>> extends MI<PMI<T>> {}

void main() {
  var a = new MI();
  var b = new PMI();
  // [error] A value of type 'PMI<Comparable<Comparable<T>>>' cannot be assigned to a variable of type 'MI<MI<MI<T>>>'
  a = b;
  Expect.isTrue(a is MI);
  Expect.isTrue(b is PMI);
  Expect.isTrue(b is MI);
  Expect.isTrue(b is MI<PMI>);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions