Skip to content

Analyzer fails to recognize subtype relation in F-bounded type parameter. #34728

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
lrhn opened this issue Oct 9, 2018 · 1 comment
Closed
Labels
dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@lrhn
Copy link
Member

lrhn commented Oct 9, 2018

Example:

// Arbitrary generic class.                                                     
class A<X> {}

class B<X extends A<A<X>>> {}
class C<X extends A<X>> extends B<X> {}  // Analyzer error: 

// Example class.
class E extends A<E> {}

main() {
 A<A<E>> e1 = E();
 B<E>();
 C<E>();
}

The analyzer reports the following error:

Analyzing test.dart...                                                          
  error • 'X' doesn't extend 'A<A<X>>' at test.dart:5:35 • type_argument_not_matching_bounds

However, since X <: A<X>, by covariance of generics we also know that A<X> <: A<A<X>>, and by transitivity we know that X <: A<A<X>>, so the error is incorrect.

The code runs without issues on the CFE.

(Might be related to #34726).

@lrhn lrhn added legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 9, 2018
@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
@srawlins srawlins added the P3 A lower priority bug or feature request label Dec 20, 2021
@srawlins
Copy link
Member

srawlins commented May 5, 2023

No more error in analyzer 🎉

@srawlins srawlins closed this as completed May 5, 2023
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. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants