@@ -549,6 +549,7 @@ abstract class SummaryTest {
549
549
List <_PrefixExpectation > prefixExpectations,
550
550
int numTypeArguments: 0 ,
551
551
ReferenceKind expectedKind: ReferenceKind .classOrEnum,
552
+ EntityRefKind entityKind: null ,
552
553
int expectedTargetUnit: 0 ,
553
554
LinkedUnit linkedSourceUnit,
554
555
UnlinkedUnit unlinkedSourceUnit,
@@ -559,6 +560,12 @@ abstract class SummaryTest {
559
560
expect (typeRef.paramReference, 0 );
560
561
int index = typeRef.reference;
561
562
expect (typeRef.typeArguments, hasLength (numTypeArguments));
563
+
564
+ if (entityKind == EntityRefKind .genericFunctionType) {
565
+ // [GenericFunctionType]s don't have references to check.
566
+ return ;
567
+ }
568
+
562
569
UnlinkedReference reference = checkReferenceIndex (
563
570
index, absoluteUri, expectedName,
564
571
expectedKind: expectedKind,
@@ -2663,7 +2670,6 @@ const int v = p.a.length;
2663
2670
]);
2664
2671
}
2665
2672
2666
- @failingTest
2667
2673
test_constExpr_makeTypedList_functionType_withTypeParameters () {
2668
2674
UnlinkedVariable variable = serializeVariableText (
2669
2675
'final v = <void Function<T>(Function<Q>(T, Q))>[];' );
@@ -2682,13 +2688,13 @@ const int v = p.a.length;
2682
2688
expect (param.type.entityKind, EntityRefKind .genericFunctionType);
2683
2689
expect (param.type.syntheticParams, hasLength (2 ));
2684
2690
{
2685
- final subparam = reference .syntheticParams[0 ];
2691
+ final subparam = param.type .syntheticParams[0 ];
2686
2692
expect (subparam.name, '' ); // no name for generic type parameters
2687
2693
expect (subparam.type, new isInstanceOf <EntityRef >());
2688
2694
expect (subparam.type.paramReference, 2 );
2689
2695
}
2690
2696
{
2691
- final subparam = reference .syntheticParams[1 ];
2697
+ final subparam = param.type .syntheticParams[1 ];
2692
2698
expect (subparam.name, '' ); // no name for generic type parameters
2693
2699
expect (subparam.type, new isInstanceOf <EntityRef >());
2694
2700
expect (subparam.type.paramReference, 1 );
@@ -7989,10 +7995,6 @@ import "${'a'}.dart";
7989
7995
if (! strongMode || skipFullyLinkedData) {
7990
7996
return ;
7991
7997
}
7992
- // The type that is inferred for C.f's parameter g is "() -> void".
7993
- // Since the associated element for that function type is B.f's parameter g,
7994
- // and B has a type parameter, the inferred type will record a type
7995
- // parameter.
7996
7998
UnlinkedClass c = serializeClassText ('''
7997
7999
abstract class B<T> {
7998
8000
void f(void g());
@@ -8007,9 +8009,14 @@ class C<T> extends B<T> {
8007
8009
UnlinkedParam g = f.parameters[0 ];
8008
8010
expect (g.name, 'g' );
8009
8011
EntityRef typeRef = getTypeRefForSlot (g.inferredTypeSlot);
8010
- checkLinkedTypeRef (typeRef, null , 'f' ,
8011
- expectedKind: ReferenceKind .method, numTypeArguments: 1 );
8012
- checkParamTypeRef (typeRef.typeArguments[0 ], 1 );
8012
+
8013
+ // The type that is inferred for C.f's parameter g is "() -> void".
8014
+ // Therefore it has no type arguments. However, the associated element for
8015
+ // that function type is B.f's parameter g, and B has a type parameter, so
8016
+ // the inferred type *may* safely record that T as a type parameter, in
8017
+ // which case this assertion can be altered accordingly.
8018
+ checkTypeRef (typeRef, null , 'f' ,
8019
+ numTypeArguments: 0 , entityKind: EntityRefKind .genericFunctionType);
8013
8020
}
8014
8021
8015
8022
test_inferred_type_keeps_leading_dynamic () {
@@ -8071,7 +8078,7 @@ var v = h((y) {});
8071
8078
expect (y.name, 'y' );
8072
8079
EntityRef typeRef = getTypeRefForSlot (y.inferredTypeSlot);
8073
8080
checkLinkedTypeRef (typeRef, null , 'F' , expectedKind: ReferenceKind .typedef );
8074
- expect (typeRef.implicitFunctionTypeIndices, [ 0 ] );
8081
+ expect (typeRef.implicitFunctionTypeIndices, isEmpty );
8075
8082
}
8076
8083
8077
8084
test_inferred_type_refers_to_function_typed_parameter_type_generic_class () {
@@ -8086,24 +8093,15 @@ var v = h((y) {});
8086
8093
getTypeRefForSlot (cls.executables[0 ].parameters[1 ].inferredTypeSlot);
8087
8094
// Check that parameter g's inferred type is the type implied by D.f's 1st
8088
8095
// (zero-based) parameter.
8089
- expect (type.implicitFunctionTypeIndices, [ 1 ] );
8096
+ expect (type.implicitFunctionTypeIndices, isEmpty );
8090
8097
expect (type.paramReference, 0 );
8091
- expect (type.typeArguments, hasLength (2 ));
8092
- checkParamTypeRef (type.typeArguments[0 ], 1 );
8093
- checkTypeRef (type.typeArguments[1 ], 'dart:core' , 'int' );
8094
- expect (type.reference,
8095
- greaterThanOrEqualTo (unlinkedUnits[0 ].references.length));
8096
- LinkedReference linkedReference =
8097
- linked.units[0 ].references[type.reference];
8098
- expect (linkedReference.dependency, 0 );
8099
- expect (linkedReference.kind, ReferenceKind .method);
8100
- expect (linkedReference.name, 'f' );
8101
- expect (linkedReference.numTypeParameters, 0 );
8102
- expect (linkedReference.unit, 0 );
8103
- expect (linkedReference.containingReference, isNot (0 ));
8104
- expect (linkedReference.containingReference, lessThan (type.reference));
8105
- checkReferenceIndex (linkedReference.containingReference, null , 'D' ,
8106
- numTypeParameters: 2 );
8098
+ // Note: this *may* legally have two type arguments (V, W), but for the
8099
+ // moment does not in practice, so we assert isEmpty.
8100
+ expect (type.typeArguments, isEmpty);
8101
+ expect (type.entityKind, EntityRefKind .syntheticFunction);
8102
+ expect (type.syntheticParams, hasLength (1 ));
8103
+ checkParamTypeRef (type.syntheticParams[0 ].type, 1 );
8104
+ checkLinkedTypeRef (type.syntheticReturnType, 'dart:core' , 'int' );
8107
8105
}
8108
8106
8109
8107
test_inferred_type_refers_to_function_typed_parameter_type_other_lib () {
@@ -8117,24 +8115,15 @@ var v = h((y) {});
8117
8115
'import "a.dart"; class C extends D { void f(int x, g) {} }' );
8118
8116
EntityRef type =
8119
8117
getTypeRefForSlot (cls.executables[0 ].parameters[1 ].inferredTypeSlot);
8120
- // Check that parameter g's inferred type is the type implied by D.f's 1st
8121
- // (zero-based) parameter.
8122
- expect (type.implicitFunctionTypeIndices, [1 ]);
8118
+ expect (type.implicitFunctionTypeIndices, isEmpty);
8123
8119
expect (type.paramReference, 0 );
8120
+ // Note: this *may* legally have two type arguments (V, W), but for the
8121
+ // moment does not in practice, so we assert isEmpty.
8124
8122
expect (type.typeArguments, isEmpty);
8125
- expect (type.reference,
8126
- greaterThanOrEqualTo (unlinkedUnits[0 ].references.length));
8127
- LinkedReference linkedReference =
8128
- linked.units[0 ].references[type.reference];
8129
- expect (linkedReference.dependency, 0 );
8130
- expect (linkedReference.kind, ReferenceKind .method);
8131
- expect (linkedReference.name, 'f' );
8132
- expect (linkedReference.numTypeParameters, 0 );
8133
- expect (linkedReference.unit, 0 );
8134
- expect (linkedReference.containingReference, isNot (0 ));
8135
- expect (linkedReference.containingReference, lessThan (type.reference));
8136
- checkReferenceIndex (
8137
- linkedReference.containingReference, absUri ('/b.dart' ), 'E' );
8123
+ expect (type.entityKind, EntityRefKind .syntheticFunction);
8124
+ expect (type.syntheticParams, hasLength (1 ));
8125
+ checkLinkedTypeRef (type.syntheticReturnType, 'dart:core' , 'int' );
8126
+ checkLinkedTypeRef (type.syntheticParams[0 ].type, 'dart:core' , 'String' );
8138
8127
}
8139
8128
8140
8129
test_inferred_type_refers_to_method_function_typed_parameter_type () {
@@ -8147,23 +8136,16 @@ var v = h((y) {});
8147
8136
className: 'C' );
8148
8137
EntityRef type =
8149
8138
getTypeRefForSlot (cls.executables[0 ].parameters[1 ].inferredTypeSlot);
8150
- // Check that parameter g's inferred type is the type implied by D.f's 1st
8151
- // (zero-based) parameter.
8152
- expect (type.implicitFunctionTypeIndices, [1 ]);
8139
+
8140
+ expect (type.implicitFunctionTypeIndices, isEmpty);
8153
8141
expect (type.paramReference, 0 );
8142
+ // Note: this *may* legally have two type arguments (V, W), but for the
8143
+ // moment does not in practice, so we assert isEmpty.
8154
8144
expect (type.typeArguments, isEmpty);
8155
- expect (type.reference,
8156
- greaterThanOrEqualTo (unlinkedUnits[0 ].references.length));
8157
- LinkedReference linkedReference =
8158
- linked.units[0 ].references[type.reference];
8159
- expect (linkedReference.dependency, 0 );
8160
- expect (linkedReference.kind, ReferenceKind .method);
8161
- expect (linkedReference.name, 'f' );
8162
- expect (linkedReference.numTypeParameters, 0 );
8163
- expect (linkedReference.unit, 0 );
8164
- expect (linkedReference.containingReference, isNot (0 ));
8165
- expect (linkedReference.containingReference, lessThan (type.reference));
8166
- checkReferenceIndex (linkedReference.containingReference, null , 'D' );
8145
+ expect (type.entityKind, EntityRefKind .syntheticFunction);
8146
+ expect (type.syntheticParams, hasLength (1 ));
8147
+ checkLinkedTypeRef (type.syntheticReturnType, 'dart:core' , 'int' );
8148
+ checkLinkedTypeRef (type.syntheticParams[0 ].type, 'dart:core' , 'String' );
8167
8149
}
8168
8150
8169
8151
test_inferred_type_refers_to_nested_function_typed_param () {
0 commit comments