Skip to content
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

Some tests for instantiate-to-bound and super-bounded should be updated #984

Closed
scheglov opened this issue Jan 19, 2021 · 3 comments
Closed
Assignees

Comments

@scheglov
Copy link

I'm working on an update to checking regular-bounded and super-bounded types, motivated by this change. I see failures in co19 and co19_2 tests. See details in the test results.

/cc @eernstg

@sgrekhov
Copy link
Contributor

@scheglov how changes related with NNBD may affect co19_2 tests? These tests are pre-nnbd ones

@eernstg
Copy link
Member

eernstg commented Jan 20, 2021

I agree that dart-lang/language#1133 is intended to change the treatment of super-bounded types only for code with null safety.

Each of the helper predicates TOP, NULL, MORETOP, MOREBOTTOM mention types availably only with null safety; OBJECT implies null safety because OBJECT(dynamic) is false, and BOTTOM is followed by a sentence that implies null safety: 'BOTTOM(T) is true if and only if T is a subtype of Never' (BOTTOM(Null) is false, but in Dart before null safety we had Null <: T for all T).

So moving the helper predicates to the null safety spec should not imply that they now mean something different, and hence 'resources/type-system/upper-lower-bounds.md' should also not mean something different than it did before the change.

@eernstg
Copy link
Member

eernstg commented Jan 20, 2021

Note that we will now treat top types in positions that have no variance and in invariant positions the same as top types in covariant positions, but this is not the same thing as saying that every type variable which is unused/invariant is now considered covariant:

typedef F<X> = void Function(); // X is unused.
typedef G<Y> = Y Function(Y); // Y is invariant.

void main() {
  F<dynamic> x1; // Here, `dynamic` occurs in a position with no variance.
  F<void Function(dynamic)> x2; // `dynamic` position: no variance.
  G<dynamic> x3; // `dynamic` position: invariant.
  G<void Function(dynamic)> x4; // `dynamic` position: invariant.
  G<List<dynamic>> x5; // `dynamic` position: invariant.
  F<G<dynamic>> x5; // `dynamic` position: invariant.
  G<F<dynamic>> x6; // `dynamic` position: no variance.
}

For the purpose of checking a super-bounded type there is no need to make a distinction between a position that is invariant and a position that has no variance: Let 'unrelated' mean 'either invariant or without variance', then any subterm of a term whose position is unrelated will again be unrelated. In particular, the position does not switch to a different variance when we go from a function type F to to a parameter type of F, which is otherwise a situation where the variance changes (from covariant to contravariant, or from contravariant to covariant).

@iarkh iarkh closed this as completed in f35ddce Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants