@@ -95,7 +95,7 @@ abstract class RuntimeTypesNeed {
95
95
// TODO(redemption): Remove this when the old frontend is deleted.
96
96
bool localFunctionNeedsSignature (Local localFunction);
97
97
98
- bool classUsesTypeVariableExpression (ClassEntity cls);
98
+ bool classUsesTypeVariableLiteral (ClassEntity cls);
99
99
}
100
100
101
101
class TrivialRuntimeTypesNeed implements RuntimeTypesNeed {
@@ -105,7 +105,7 @@ class TrivialRuntimeTypesNeed implements RuntimeTypesNeed {
105
105
bool classNeedsTypeArguments (ClassEntity cls) => true ;
106
106
107
107
@override
108
- bool classUsesTypeVariableExpression (ClassEntity cls) => true ;
108
+ bool classUsesTypeVariableLiteral (ClassEntity cls) => true ;
109
109
110
110
@override
111
111
bool localFunctionNeedsSignature (Local localFunction) => true ;
@@ -125,8 +125,15 @@ class TrivialRuntimeTypesNeed implements RuntimeTypesNeed {
125
125
126
126
/// Interface for computing classes and methods that need runtime types.
127
127
abstract class RuntimeTypesNeedBuilder {
128
- /// Registers that [cls] contains a type variable literal.
129
- void registerClassUsingTypeVariableExpression (ClassEntity cls);
128
+ /// Registers that [cls] uses one of its type variables as a literal.
129
+ void registerClassUsingTypeVariableLiteral (ClassEntity cls);
130
+
131
+ /// Registers that [method] uses one of its type variables as a literal.
132
+ void registerMethodUsingTypeVariableLiteral (FunctionEntity method);
133
+
134
+ /// Registers that [localFunction] uses one of its type variables as a
135
+ /// literal.
136
+ void registerLocalFunctionUsingTypeVariableLiteral (Local localFunction);
130
137
131
138
/// Registers that if [element] needs type arguments at runtime then so does
132
139
/// [dependency] .
@@ -163,7 +170,13 @@ class TrivialRuntimeTypesNeedBuilder implements RuntimeTypesNeedBuilder {
163
170
const TrivialRuntimeTypesNeedBuilder ();
164
171
165
172
@override
166
- void registerClassUsingTypeVariableExpression (ClassEntity cls) {}
173
+ void registerClassUsingTypeVariableLiteral (ClassEntity cls) {}
174
+
175
+ @override
176
+ void registerMethodUsingTypeVariableLiteral (FunctionEntity method) {}
177
+
178
+ @override
179
+ void registerLocalFunctionUsingTypeVariableLiteral (Local localFunction) {}
167
180
168
181
@override
169
182
RuntimeTypesNeed computeRuntimeTypesNeed (
@@ -526,9 +539,8 @@ class RuntimeTypesNeedImpl implements RuntimeTypesNeed {
526
539
final Set <Local > localFunctionsNeedingSignature;
527
540
final Set <Local > localFunctionsNeedingTypeArguments;
528
541
529
- /// The set of classes that use one of their type variables as expressions
530
- /// to get the runtime type.
531
- final Set <ClassEntity > classesUsingTypeVariableExpression;
542
+ /// The set of classes that use one of their type variables as literals.
543
+ final Set <ClassEntity > classesUsingTypeVariableLiterals;
532
544
533
545
RuntimeTypesNeedImpl (
534
546
this ._elementEnvironment,
@@ -538,7 +550,7 @@ class RuntimeTypesNeedImpl implements RuntimeTypesNeed {
538
550
this .methodsNeedingTypeArguments,
539
551
this .localFunctionsNeedingSignature,
540
552
this .localFunctionsNeedingTypeArguments,
541
- this .classesUsingTypeVariableExpression );
553
+ this .classesUsingTypeVariableLiterals );
542
554
543
555
bool checkClass (covariant ClassEntity cls) => true ;
544
556
@@ -580,28 +592,28 @@ class RuntimeTypesNeedImpl implements RuntimeTypesNeed {
580
592
}
581
593
582
594
@override
583
- bool classUsesTypeVariableExpression (ClassEntity cls) {
584
- return classesUsingTypeVariableExpression .contains (cls);
595
+ bool classUsesTypeVariableLiteral (ClassEntity cls) {
596
+ return classesUsingTypeVariableLiterals .contains (cls);
585
597
}
586
598
}
587
599
588
600
class _ResolutionRuntimeTypesNeed extends RuntimeTypesNeedImpl {
589
601
_ResolutionRuntimeTypesNeed (
590
602
ElementEnvironment elementEnvironment,
591
603
BackendUsage backendUsage,
592
- Set <ClassEntity > classesNeedingRti ,
593
- Set <FunctionEntity > methodsNeedingRti ,
594
- Set <FunctionEntity > methodsNeedingGenericRti ,
595
- Set <Local > localFunctionsNeedingRti ,
604
+ Set <ClassEntity > classesNeedingTypeArguments ,
605
+ Set <FunctionEntity > methodsNeedingSignature ,
606
+ Set <FunctionEntity > methodsNeedingTypeArguments ,
607
+ Set <Local > localFunctionsNeedingSignature ,
596
608
Set <Local > localFunctionsNeedingTypeArguments,
597
609
Set <ClassEntity > classesUsingTypeVariableExpression)
598
610
: super (
599
611
elementEnvironment,
600
612
backendUsage,
601
- classesNeedingRti ,
602
- methodsNeedingRti ,
603
- methodsNeedingGenericRti ,
604
- localFunctionsNeedingRti ,
613
+ classesNeedingTypeArguments ,
614
+ methodsNeedingSignature ,
615
+ methodsNeedingTypeArguments ,
616
+ localFunctionsNeedingSignature ,
605
617
localFunctionsNeedingTypeArguments,
606
618
classesUsingTypeVariableExpression);
607
619
@@ -615,9 +627,14 @@ class RuntimeTypesNeedBuilderImpl extends _RuntimeTypesBase
615
627
final Map <Entity , Set <Entity >> typeArgumentDependencies =
616
628
< Entity , Set <Entity >> {};
617
629
618
- final Set <ClassEntity > classesUsingTypeVariableExpression =
630
+ final Set <ClassEntity > classesUsingTypeVariableLiterals =
619
631
new Set <ClassEntity >();
620
632
633
+ final Set <FunctionEntity > methodsUsingTypeVariableLiterals =
634
+ new Set <FunctionEntity >();
635
+
636
+ final Set <Local > localFunctionsUsingTypeVariableLiterals = new Set <Local >();
637
+
621
638
final Set <ClassEntity > classesUsingTypeVariableTests = new Set <ClassEntity >();
622
639
623
640
Set <DartType > isChecks;
@@ -630,8 +647,18 @@ class RuntimeTypesNeedBuilderImpl extends _RuntimeTypesBase
630
647
bool checkClass (covariant ClassEntity cls) => true ;
631
648
632
649
@override
633
- void registerClassUsingTypeVariableExpression (ClassEntity cls) {
634
- classesUsingTypeVariableExpression.add (cls);
650
+ void registerClassUsingTypeVariableLiteral (ClassEntity cls) {
651
+ classesUsingTypeVariableLiterals.add (cls);
652
+ }
653
+
654
+ @override
655
+ void registerMethodUsingTypeVariableLiteral (FunctionEntity method) {
656
+ methodsUsingTypeVariableLiterals.add (method);
657
+ }
658
+
659
+ @override
660
+ void registerLocalFunctionUsingTypeVariableLiteral (Local localFunction) {
661
+ localFunctionsUsingTypeVariableLiterals.add (localFunction);
635
662
}
636
663
637
664
@override
@@ -771,9 +798,12 @@ class RuntimeTypesNeedBuilderImpl extends _RuntimeTypesBase
771
798
checkClosures ();
772
799
}
773
800
774
- // Add the classes that need RTI because they use a type variable as
775
- // expression.
776
- classesUsingTypeVariableExpression.forEach (potentiallyNeedTypeArguments);
801
+ // Add the classes, methods and local functions that need type arguments
802
+ // because they use a type variable as a literal.
803
+ classesUsingTypeVariableLiterals.forEach (potentiallyNeedTypeArguments);
804
+ methodsUsingTypeVariableLiterals.forEach (potentiallyNeedTypeArguments);
805
+ localFunctionsUsingTypeVariableLiterals
806
+ .forEach (potentiallyNeedTypeArguments);
777
807
778
808
return _createRuntimeTypesNeed (
779
809
_elementEnvironment,
@@ -783,7 +813,7 @@ class RuntimeTypesNeedBuilderImpl extends _RuntimeTypesBase
783
813
methodsNeedingTypeArguments,
784
814
localFunctionsNeedingSignature,
785
815
localFunctionsNeedingTypeArguments,
786
- classesUsingTypeVariableExpression );
816
+ classesUsingTypeVariableLiterals );
787
817
}
788
818
789
819
RuntimeTypesNeed _createRuntimeTypesNeed (
0 commit comments