3c5767ccd3
If a type variable T is used in an `is` or `as` expression (e.g. `42 is T` or `42 as T`) or is part of a subtype check, then any types which may be substituted for T via instantiation must also be treated as participating in a type check. This CL ensures that the RTI need computation includes type arguments for those substituted types and that those types are included in the list of implicit checks. Additionally, in order for this to work, this CL fixes a bug in which the impact transformer was failing to register generic instantiations occurring in (partial) constants. Fixes: https://github.com/dart-lang/sdk/issues/45046 Change-Id: I98ae0eca0adcbbb26cdd664318da0da578b289b5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190460 Reviewed-by: Stephen Adams <sra@google.com> Commit-Queue: Mayank Patke <fishythefish@google.com>
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// @dart = 2.7
|
|
|
|
/*spec.member: f1:deps=[method],direct,explicit=[f1.T*],needsArgs,needsInst=[<method.X*>]*/
|
|
/*prod.member: f1:deps=[method]*/
|
|
int f1<T>(T a, T b, T c) => null;
|
|
|
|
/*spec.member: f2:deps=[method],direct,explicit=[f2.S*,f2.T*],needsArgs,needsInst=[<method.X*,method.Y*>]*/
|
|
/*prod.member: f2:deps=[method]*/
|
|
int f2<T, S>(T a, S b, S c) => null;
|
|
|
|
/*spec.member: f3:deps=[method],direct,explicit=[f3.S*,f3.T*,f3.U*],needsArgs,needsInst=[<method.X*,method.Y*,method.Z*>]*/
|
|
/*prod.member: f3:deps=[method]*/
|
|
int f3<T, S, U>(T a, S b, U c) => null;
|
|
|
|
typedef int F1<R>(R a, R b, R c);
|
|
typedef int F2<R, P>(R a, P b, P c);
|
|
typedef int F3<R, P, Q>(R a, P b, Q c);
|
|
|
|
/*spec.member: method:implicit=[method.X,method.Y,method.Z],indirect,needsArgs*/
|
|
method<X, Y, Z>() {
|
|
F1<X> c1;
|
|
F2<X, Y> c2;
|
|
F3<X, Y, Z> c3;
|
|
|
|
return () {
|
|
c1 = f1;
|
|
c2 = f2;
|
|
c3 = f3;
|
|
return c1 ?? c2 ?? c3;
|
|
};
|
|
}
|
|
|
|
main() {
|
|
method();
|
|
}
|