@@ -177,7 +177,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
177
177
/**
178
178
* True if this type is the result of instantiating type parameters (and thus
179
179
* any type parameters bound by the typedef should be considered part of
180
- * [typeParameters] rather than [boundTypeParameters ] ).
180
+ * [typeParameters] rather than [typeFormals ] ).
181
181
*/
182
182
final bool _isInstantiated;
183
183
@@ -243,8 +243,12 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
243
243
*/
244
244
DartType get baseReturnType => element.returnType;
245
245
246
+ @deprecated
246
247
@override
247
- List <TypeParameterElement > get boundTypeParameters {
248
+ List <TypeParameterElement > get boundTypeParameters => typeFormals;
249
+
250
+ @override
251
+ List <TypeParameterElement > get typeFormals {
248
252
if (_isInstantiated) {
249
253
return TypeParameterElement .EMPTY_LIST ;
250
254
} else {
@@ -349,26 +353,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
349
353
return code;
350
354
}
351
355
352
- /**
353
- * The type arguments that were used to instantiate this function type, if
354
- * any, otherwise this will return an empty list.
355
- *
356
- * Given a function type `f` :
357
- *
358
- * f == f.originalFunction.instantiate(f.instantiatedTypeArguments)
359
- *
360
- * Will always hold.
361
- */
362
- List <DartType > get instantiatedTypeArguments {
363
- int typeParameterCount = element.type.boundTypeParameters.length;
364
- if (typeParameterCount == 0 ) {
365
- return DartType .EMPTY_LIST ;
366
- }
367
- // The substituted types at the end should be our bound type parameters.
368
- int skipCount = typeArguments.length - typeParameterCount;
369
- return new List <DartType >.from (typeArguments.skip (skipCount));
370
- }
371
-
372
356
/**
373
357
* Return `true` if this type is the result of instantiating type parameters.
374
358
*/
@@ -471,20 +455,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
471
455
return types;
472
456
}
473
457
474
- /**
475
- * If this is an instantiation of a generic function type, this will get
476
- * the original function from which it was instantiated.
477
- *
478
- * Otherwise, this will return `this` .
479
- */
480
- FunctionTypeImpl get originalFunction {
481
- if (element.type.boundTypeParameters.isEmpty) {
482
- return this ;
483
- }
484
- return (element.type as FunctionTypeImpl ).substitute2 (typeArguments,
485
- TypeParameterTypeImpl .getTypes (typeParameters), prunedTypedefs);
486
- }
487
-
488
458
@override
489
459
List <ParameterElement > get parameters {
490
460
List <ParameterElement > baseParameters = this .baseParameters;
@@ -558,19 +528,19 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
558
528
return false ;
559
529
}
560
530
FunctionTypeImpl otherType = object as FunctionTypeImpl ;
561
- if (boundTypeParameters .length != otherType.boundTypeParameters .length) {
531
+ if (typeFormals .length != otherType.typeFormals .length) {
562
532
return false ;
563
533
}
564
534
// `<T>T -> T` should be equal to `<U>U -> U`
565
535
// To test this, we instantiate both types with the same (unique) type
566
536
// variables, and see if the result is equal.
567
- if (boundTypeParameters .isNotEmpty) {
537
+ if (typeFormals .isNotEmpty) {
568
538
List <DartType > instantiateTypeArgs = new List <DartType >();
569
539
List <DartType > variablesThis = new List <DartType >();
570
540
List <DartType > variablesOther = new List <DartType >();
571
- for (int i = 0 ; i < boundTypeParameters .length; i++ ) {
572
- TypeParameterElement pThis = boundTypeParameters [i];
573
- TypeParameterElement pOther = otherType.boundTypeParameters [i];
541
+ for (int i = 0 ; i < typeFormals .length; i++ ) {
542
+ TypeParameterElement pThis = typeFormals [i];
543
+ TypeParameterElement pOther = otherType.typeFormals [i];
574
544
TypeParameterTypeImpl pFresh = new TypeParameterTypeImpl (
575
545
new TypeParameterElementImpl (pThis.name, - 1 ));
576
546
instantiateTypeArgs.add (pFresh);
@@ -583,7 +553,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
583
553
return false ;
584
554
}
585
555
}
586
- // After instantiation, they will no longer have boundTypeParameters ,
556
+ // After instantiation, they will no longer have typeFormals ,
587
557
// so we will continue below.
588
558
return this .instantiate (instantiateTypeArgs) ==
589
559
otherType.instantiate (instantiateTypeArgs);
@@ -599,7 +569,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
599
569
600
570
@override
601
571
void appendTo (StringBuffer buffer) {
602
- if (boundTypeParameters .isNotEmpty) {
572
+ if (typeFormals .isNotEmpty) {
603
573
// To print a type with type variables, first make sure we have unique
604
574
// variable names to print.
605
575
Set <TypeParameterType > freeVariables = new HashSet <TypeParameterType >();
@@ -615,8 +585,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
615
585
List <DartType > instantiateTypeArgs = new List <DartType >();
616
586
List <DartType > variables = new List <DartType >();
617
587
buffer.write ("<" );
618
- for (TypeParameterElement e in boundTypeParameters ) {
619
- if (e != boundTypeParameters [0 ]) {
588
+ for (TypeParameterElement e in typeFormals ) {
589
+ if (e != typeFormals [0 ]) {
620
590
buffer.write ("," );
621
591
}
622
592
String name = e.name;
@@ -645,7 +615,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
645
615
buffer.write (">" );
646
616
647
617
// Instantiate it and print the resulting type. After instantiation, it
648
- // will no longer have boundTypeParameters , so we will continue below.
618
+ // will no longer have typeFormals , so we will continue below.
649
619
this .instantiate (instantiateTypeArgs).appendTo (buffer);
650
620
return ;
651
621
}
@@ -713,10 +683,10 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
713
683
714
684
@override
715
685
FunctionTypeImpl instantiate (List <DartType > argumentTypes) {
716
- if (argumentTypes.length != boundTypeParameters .length) {
686
+ if (argumentTypes.length != typeFormals .length) {
717
687
throw new IllegalArgumentException (
718
688
"argumentTypes.length (${argumentTypes .length }) != "
719
- "boundTypeParameters .length (${boundTypeParameters .length })" );
689
+ "typeFormals .length (${typeFormals .length })" );
720
690
}
721
691
if (argumentTypes.isEmpty) {
722
692
return this ;
@@ -725,7 +695,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
725
695
// Given:
726
696
// {U/T} <S> T -> S
727
697
// Where {U/T} represents the typeArguments (U) and typeParameters (T) list,
728
- // and <S> represents the boundTypeParameters .
698
+ // and <S> represents the typeFormals .
729
699
//
730
700
// Now instantiate([V]), and the result should be:
731
701
// {U/T, V/S} T -> S.
@@ -1024,8 +994,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
1024
994
FunctionType type, Set <TypeParameterType > free) {
1025
995
// Make some fresh variables to avoid capture.
1026
996
List <DartType > typeArgs = DartType .EMPTY_LIST ;
1027
- if (type.boundTypeParameters .isNotEmpty) {
1028
- typeArgs = new List <DartType >.from (type.boundTypeParameters .map ((e) =>
997
+ if (type.typeFormals .isNotEmpty) {
998
+ typeArgs = new List <DartType >.from (type.typeFormals .map ((e) =>
1029
999
new TypeParameterTypeImpl (new TypeParameterElementImpl (e.name, - 1 ))));
1030
1000
1031
1001
type = type.instantiate (typeArgs);
0 commit comments