Skip to content

Dart fails with class A<X extends FutureOr<A<X>>> #34948

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 27, 2018 · 5 comments
Closed

Dart fails with class A<X extends FutureOr<A<X>>> #34948

iarkh opened this issue Oct 27, 2018 · 5 comments
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@iarkh
Copy link
Contributor

iarkh commented Oct 27, 2018

Dart SDK Version: 2.1.0-dev.8.0
OS: Windows 10 (64 bit)

This is a regression in dev.8.0, dart passes with the same code sample with dev.7.1.

Please note that there is an opened bug #34264 regarding dartanalyzer.

Here is a sample code example:

import "dart:async";
class A<X extends FutureOr<A<X>>> {}
main() {}

Still analyzer fails here because of #34264.

But in the recent dart version dart started to fail here too, sample output is:

test.dart:2:9: Error: Type argument '#lib1::A::X' violates the corresponding type variable bound of 'A'.
Try changing type arguments so that they conform to the bounds.
class A<X extends FutureOr<A>> {}
^
test.dart:2:9: Context: Bound of this variable is violated.
class A<X extends FutureOr<A>> {}
^
test.dart:1: Error: Type argument '#lib1::A::X' violates the corresponding type variable bound of 'A' in the return type.
Try changing type arguments so that they conform to the bounds.
test.dart:2:9: Context: Bound of this variable is violated.
class A<X extends FutureOr<A>> {}
^

@iarkh
Copy link
Contributor Author

iarkh commented Oct 27, 2018

Seems like the following code fails with dart because of the same reason:

import "dart:async";
class A<X extends A<X>> {}
class B<X extends A<A<X>>> {}
main() {}

Sample output is:

test.dart:3:9: Error: Type argument '#lib1::A<#lib1::B::X>' violates the corresponding type variable bound of 'A'.
Try changing type arguments so that they conform to the bounds.
class B<X extends A<A>> {}
^
test.dart:2:9: Context: Bound of this variable is violated.
class A<X extends A> {}
^
test.dart:3:9: Error: Type argument '#lib1::B::X' violates the corresponding type variable bound of 'A'.
Try changing type arguments so that they conform to the bounds.
class B<X extends A<A>> {}
^
test.dart:2:9: Context: Bound of this variable is violated.
class A<X extends A> {}
^

So please let me know if I should file a separate issue about this.

@vsmenon vsmenon added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Oct 29, 2018
@vsmenon
Copy link
Member

vsmenon commented Oct 29, 2018

Filing on language to clarify behavior and/or whether this is an intended breaking change.

@srawlins srawlins added the type-question A question about expected behavior or functionality label Oct 21, 2019
@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"

@scheglov
Copy link
Contributor

scheglov commented Oct 1, 2020

The fix landed as 499bae0.

It seems that this change should be in 2.11.0-176.0.dev. When I try with the bleeding edge build, it seems to work.

scheglov@scheglov-macbookpro2:~/Source/Dart/sdk.git/sdk (master)$ cat /Users/scheglov/dart/test/bin/test.dart
import "dart:async";

class B<X extends Future<A<X>>> {}
class A<X extends FutureOr<A<X>>> {}

A a = 0;
B b = 0;
scheglov@scheglov-macbookpro2:~/Source/Dart/sdk.git/sdk (master)$ dartanalyzer --version
dartanalyzer version 2.11.0-edge.919f68d8ac2da1f1498bceb3cda610b4b0ce9905
scheglov@scheglov-macbookpro2:~/Source/Dart/sdk.git/sdk (master)$ dartanalyzer /Users/scheglov/dart/test/bin/test.dart
Analyzing /Users/scheglov/dart/test/bin/test.dart...
  error • A value of type 'int' can't be assigned to a variable of type 'A<FutureOr<A<dynamic>>>'. • /Users/scheglov/dart/test/bin/test.dart:6:7 • invalid_assignment
  error • A value of type 'int' can't be assigned to a variable of type 'B<Future<A<dynamic>>>'. • /Users/scheglov/dart/test/bin/test.dart:7:7 • invalid_assignment
2 errors found.

@eernstg eernstg added legacy-area-analyzer Use area-devexp instead. legacy-area-front-end Legacy: Use area-dart-model instead. and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-question A question about expected behavior or functionality legacy-area-analyzer Use area-devexp instead. labels Oct 7, 2020
@eernstg
Copy link
Member

eernstg commented Oct 7, 2020

Closing: The example program is accepted by dart and dartanalyzer as of a49217b.

@eernstg eernstg closed this as completed Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

5 participants