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

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

Open
lrhn opened this Issue Oct 9, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@lrhn
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).

@bwilkerson bwilkerson added this to the Dart2.2 milestone Oct 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment