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

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 2814443005: Fix for summarization of generic function type aliases and support for resynthesizing. (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/analyzer/test/src/summary/resynthesize_common.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index a765d6c1cdbd735790d7de999276d61b1c28e15d..b76f8605963b904ca7a85a73d69107fbcd94f97e 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -6455,6 +6455,14 @@ class B extends A {}
linked.exportNames[0], absUri('/a.dart'), 'F', ReferenceKind.typedef);
}
+ test_export_typedef_genericFunction() {
+ addNamedSource('/a.dart', 'typedef F<S> = S Function<T>(T x);');
+ serializeLibraryText('export "a.dart";');
+ expect(linked.exportNames, hasLength(1));
+ checkExportName(linked.exportNames[0], absUri('/a.dart'), 'F',
+ ReferenceKind.genericFunctionTypedef);
+ }
+
test_export_uri() {
addNamedSource('/a.dart', 'library my.lib;');
String uriString = '"a.dart"';
@@ -10135,6 +10143,60 @@ typedef F();''';
checkDocumentationComment(typedef.documentationComment, text);
}
+ test_typedef_genericFunction_reference() {
+ EntityRef typeRef = serializeTypeText('F',
+ otherDeclarations: 'typedef F<S> = S Function<T>(T x);');
+ checkTypeRef(typeRef, null, 'F',
+ numTypeParameters: 1,
+ expectedKind: ReferenceKind.genericFunctionTypedef);
+ }
+
+ test_typedef_genericFunction_typeNames() {
+ UnlinkedTypedef typedef =
+ serializeTypedefText('typedef F<S> = S Function(int x, String y);');
+ expect(typedef.style, TypedefStyle.genericFunctionType);
+ expect(typedef.typeParameters, hasLength(1));
+ expect(typedef.typeParameters[0].name, 'S');
+ expect(typedef.parameters, isEmpty);
+
+ EntityRef genericFunction = typedef.returnType;
+ expect(genericFunction.entityKind, EntityRefKind.genericFunctionType);
+ expect(genericFunction.typeParameters, isEmpty);
+
+ List<UnlinkedParam> functionParameters = genericFunction.syntheticParams;
+ expect(functionParameters, hasLength(2));
+ expect(functionParameters[0].name, 'x');
+ expect(functionParameters[1].name, 'y');
+ checkLinkedTypeRef(functionParameters[0].type, 'dart:core', 'int');
+ checkLinkedTypeRef(functionParameters[1].type, 'dart:core', 'String');
+
+ checkParamTypeRef(genericFunction.syntheticReturnType, 1);
+ }
+
+ test_typedef_genericFunction_typeParameters() {
+ UnlinkedTypedef typedef =
+ serializeTypedefText('typedef F<S> = S Function<T1, T2>(T1 x, T2 y);');
+ expect(typedef.style, TypedefStyle.genericFunctionType);
+ expect(typedef.typeParameters, hasLength(1));
+ expect(typedef.typeParameters[0].name, 'S');
+ expect(typedef.parameters, isEmpty);
+
+ EntityRef genericFunction = typedef.returnType;
+ expect(genericFunction.entityKind, EntityRefKind.genericFunctionType);
+
+ expect(genericFunction.typeParameters, hasLength(2));
+ expect(genericFunction.typeParameters[0].name, 'T1');
+ expect(genericFunction.typeParameters[1].name, 'T2');
+
+ expect(genericFunction.syntheticParams, hasLength(2));
+ expect(genericFunction.syntheticParams[0].name, 'x');
+ expect(genericFunction.syntheticParams[1].name, 'y');
+ checkParamTypeRef(genericFunction.syntheticParams[0].type, 2);
+ checkParamTypeRef(genericFunction.syntheticParams[1].type, 1);
+
+ checkParamTypeRef(genericFunction.syntheticReturnType, 3);
+ }
+
test_typedef_name() {
String text = 'typedef F();';
UnlinkedTypedef type = serializeTypedefText(text);
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698