Skip to content

Analyzer rejects B<X extends A<A<X>>> whereas Dart passes with this. #34726

Closed
@iarkh

Description

@iarkh

Dart SDK Version: 2.1.0-dev.6.0
OS: Windows 10

The following example declares four classes and print their types:

class A<X extends A<X>> {}
class A1<X extends A1<A1<X>>> {}
class B<X extends A<X>> {}
class B1<X extends A<A<X>>> {}

main() {
  print(A);
  print(A1);
  print(B);
  print(B1);
}

Dart passes with this and prints actual types of A, A1, B, B1:

A<A>
A1<A1<A1>>
B<A>
B1<A<A>>
Seems like this is a correct result which corresponds instantiate-to-bound Spec.

However, dartanalyzer throws compile error for class B1<X extends A<A<X>>> here:

error - 'A' doesn't extend 'A<A>' at test.dart:4:22 - type_argument_not_matching_bounds
error - 'X' doesn't extend 'A' at test.dart:4:24 - type_argument_not_matching_bounds
2 errors found.
It should pass here kike dart does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions