-
Notifications
You must be signed in to change notification settings - Fork 1.7k
NNBD_TOP_MERGE(int?, int*) does not produce int? #40524
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
Comments
@eernstg @sigmundch @fishythefish - do we have consensus on the right behavior here? |
For me: Yes, However, depending on the outcome of dart-lang/language#821 (actually, also independently of that issue), there would be a need to use a different technique than using |
The CFE correct computes The problem might be in the VM. |
The VM indeed prints
The VM will print:
which IMHO is correct too. But feel free to disagree :-) |
I wrote a bunch of tests about mixed inheritance ('tests/language/nnbd/mixed_inheritance/legacy_*'), and they are concerned with the type arguments of superinterfaces for the purposes of dynamic checks (like But they do not cover the run-time value of an expression in inherited code where a type variable is evaluated (like It may indeed be the most useful choice to let This means that instances of // Legacy 'testlib_out.dart'.
// @dart=2.6
Type typeOf<X>() => X;
class A<T> {
Type getType() => T;
bool test(Function f) => f.runtimeType == typeOf<void Function(T)>();
}
class out_int extends A<int> {}
// 'test.dart', with null-safety.
import "testlib_out.dart";
class B extends A<int?> {}
void bar(int i) {}
class C0 extends out_int {
bool get test2 => super.test(bar); // Optimized to `=> true`.
}
class C extends C0 implements B {} Class I think it's very likely that we never optimize a case like the one above (for instance, it's crucial that we call However, there could be other cases where implementations do perform similar optimizations that need to be invalidated if we "change our mind" about the value of a type variable in spite of the fact that it is already statically known (as in I think it's fair to say that this is still blocked on #841. PS: I created #841 exactly to clarify whether we should require inherited methods to reflect the mitigated implemented superinterfaces (e.g., that |
Since the consensus is that mitigation proposed in dart-lang/language#841 will not be implemented, this issue becomes invalid and there is nothing to fix in the VM. |
Dart VM version: 2.8.0-edge.aadcb4418b1a7ccbb74a7cc925ad55020ce4a924 (Thu Feb 6 02:00:49 2020 +0000) on "linux_x64"
According to NNBD Spec:
In the following code source:
testlib_out.dart:
test.dart:
direct super-interface type parameter of the class
C
should beint?
.However, this is not so and dart prints
false
here.The text was updated successfully, but these errors were encountered: