Skip to content

recursive_inheritance_test fails in strong mode #26970

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
jmesserly opened this issue Jul 27, 2016 · 4 comments
Closed

recursive_inheritance_test fails in strong mode #26970

jmesserly opened this issue Jul 27, 2016 · 4 comments
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on

Comments

@jmesserly
Copy link

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>);
}
@jmesserly jmesserly added legacy-area-analyzer Use area-devexp instead. analyzer-strong-mode P2 A bug or feature request we're likely to work on labels Jul 27, 2016
@jmesserly
Copy link
Author

jmesserly commented Aug 4, 2016

This may have been improved by a recent commit: 0fe54a6, or we may have another similar issue. There were a couple of things wrong with inference and recursive bounds.

@jmesserly
Copy link
Author

According to @vsmenon this is now fixed when he brings the latest Analyzer into DDC \o/

@zoechi
Copy link
Contributor

zoechi commented Aug 6, 2016

@jmesserly does this fix #25530 as well?

@jmesserly
Copy link
Author

yeah @zoechi, I wondered the same thing! Will have to try it. In general these patterns are kind of unsound, so it may still be valid to reject the code. But I hope it rejects the code with a valid error, not because it was going off the rails and computing crazy types. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

2 participants