Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2468)

Unified Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2867253004: Fix annotation of generic method invocations in Fasta inference tests. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
index 34abf39f1448a759231453a3097c419af93e819f..9013322fc8352437c39ff1a5fe4cfb35cb5f0244 100644
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
@@ -273,6 +273,16 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
}
}
+ visitMethodInvocation(MethodInvocation node) {
+ super.visitMethodInvocation(node);
+ var inferredTypeArguments = _getInferredFunctionTypeArguments(
+ node.function.staticType, node.staticInvokeType, node.typeArguments)
+ .toList();
+ if (inferredTypeArguments.isNotEmpty) {
+ _recordTypeArguments(node.methodName.offset, inferredTypeArguments);
+ }
+ }
+
visitSimpleIdentifier(SimpleIdentifier node) {
super.visitSimpleIdentifier(node);
Element element = node.staticElement;
@@ -311,6 +321,19 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
}
}
+ /// Based on DDC code generator's `_emitFunctionTypeArguments`
+ Iterable<DartType> _getInferredFunctionTypeArguments(
+ DartType g, DartType f, TypeArgumentList typeArgs) {
+ if (g is FunctionType &&
+ g.typeFormals.isNotEmpty &&
+ f is FunctionType &&
+ f.typeFormals.isEmpty) {
+ return _recoverTypeArguments(g, f);
+ } else {
+ return const [];
+ }
+ }
+
void _recordTopType(int offset, DartType type) {
_instrumentation.record(
uri, offset, 'topType', new _InstrumentationValueForType(type));
@@ -325,4 +348,13 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
_instrumentation.record(uri, offset, 'typeArgs',
new _InstrumentationValueForTypeArgs(typeArguments));
}
+
+ /// Based on DDC code generator's `_recoverTypeArguments`
+ Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
+ assert(identical(g.element, f.element));
+ assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
+ assert(g.typeFormals.length + g.typeArguments.length ==
+ f.typeArguments.length);
+ return f.typeArguments.skip(g.typeArguments.length);
+ }
}
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698