You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a couple of problems with these typedefs:
Func1 and Func3 declare generic type aliases to non-generic function types. For example, declaration of Func1 in the new syntax is equivalent to
typedefFunc1<T> =List<T> Function(int i, T t);
As a result, is Func1 instantiates type parameter of generic Func1 with default dynamic, and the type check is actually testing is List<dynamic> Function(int i, dynamic t). Constructor tear-off is a generic function, and it doesn't pass type test against non-generic function type.
Instead, Func1 should be declared as a non-generic alias to a generic function type:
typedefFunc1=List<T> Function<T>(int i, T t);
Func3 and Func4 are used to test types of ListList.filled and ListList<int>.filled, where
However, they do not properly substitute type parameter E of List to List<T> or List<int> for the 2nd argument (E fill) of List.filled. They use T or int which is not correct.
These type aliases can be corrected in the following way:
typedefFunc3=List<List<T>> Function<T>(int i, List<T> t);
typedefList<List<int>> Func4(int i1, List<int> i2);
The text was updated successfully, but these errors were encountered:
…neric classes
When copying types of parameters from a constructor to a signature of
its tear-off, types should be instantiated to substitute class type
parameters with function type parameters.
For example,
class A<T> {
A(T x);
}
A.new // Should be 'A<S> Function<S>(S x)'
Without instantiation the parameter type would still reference class
type parameter:
A<S> Function<S>(T x)
As a result, Closure::GetInstantiatedSignature would replace
class type parameters with dynamic (as tear-off doesn't have
instantiated type arguments) which is not correct:
A<S> Function<S>(dynamic x)
TEST=co19/LanguageFeatures/Constructor-tear-offs/summary_A01_t01
(after dart-lang/co19#1141 is fixed)
Issue #46231
Change-Id: I0517c400271e2a59ab0496a8cc39be51022768b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209851
Commit-Queue: Alexander Markov <[email protected]>
Reviewed-by: Tess Strickland <[email protected]>
The test verifies that constructor tear-offs have the certain function types:
co19/LanguageFeatures/Constructor-tear-offs/summary_A01_t01.dart
Lines 26 to 29 in ef018b9
co19/LanguageFeatures/Constructor-tear-offs/summary_A01_t01.dart
Lines 32 to 39 in ef018b9
There are a couple of problems with these typedefs:
Func1
andFunc3
declare generic type aliases to non-generic function types. For example, declaration ofFunc1
in the new syntax is equivalent toAs a result,
is Func1
instantiates type parameter of genericFunc1
with defaultdynamic
, and the type check is actually testingis List<dynamic> Function(int i, dynamic t)
. Constructor tear-off is a generic function, and it doesn't pass type test against non-generic function type.Instead,
Func1
should be declared as a non-generic alias to a generic function type:Func3
andFunc4
are used to test types ofListList.filled
andListList<int>.filled
, whereco19/LanguageFeatures/Constructor-tear-offs/summary_A01_t01.dart
Line 24 in ef018b9
However, they do not properly substitute type parameter
E
of List toList<T>
orList<int>
for the 2nd argument (E fill
) of List.filled. They useT
orint
which is not correct.These type aliases can be corrected in the following way:
The text was updated successfully, but these errors were encountered: