Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iarkh opened this issue Oct 9, 2018 · 3 comments
Closed

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

iarkh opened this issue Oct 9, 2018 · 3 comments
Labels
dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@iarkh
Copy link
Contributor

iarkh commented Oct 9, 2018

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.

@eernstg eernstg added legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 9, 2018
@eernstg
Copy link
Member

eernstg commented Oct 9, 2018

Note that there may be some overlap with #34264 (which is focusing on FutureOr, but otherwise similar to this one).

@bwilkerson bwilkerson added this to the Dart2.2 milestone Oct 10, 2018
@stereotype441 stereotype441 modified the milestones: Dart 2.2, Future Apr 9, 2019
@aadilmaan aadilmaan modified the milestones: Future, D25 Release Jun 4, 2019
@srawlins srawlins added the dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 17, 2020
@iarkh
Copy link
Contributor Author

iarkh commented Oct 1, 2020

This bug is still reproducible with the recent dart version:
Dart SDK version: 2.11.0-176.0.dev (dev) (Mon Sep 28 19:05:52 2020 -0700) on "windows_x64"

@eernstg
Copy link
Member

eernstg commented Oct 6, 2020

Closing: Cf. #43687, we must get a compile-time error for the declaration of B, so the analyzer is behaving correctly. The common front end reports that error as well.

@eernstg eernstg closed this as completed Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants