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

Unified Diff: pkg/analyzer/test/dart/element/builder_test.dart

Issue 2809423003: Build GenericFunctionTypeElementImpl in both ApiElementBuilder and LocalElementBuilder. (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/lib/src/dart/element/builder.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/dart/element/builder_test.dart
diff --git a/pkg/analyzer/test/dart/element/builder_test.dart b/pkg/analyzer/test/dart/element/builder_test.dart
index 31883ccdf83616d606f89f3bc8f0c9aad37bedcd..0e7a9033c4b76e6c337178bfdf644ff043281f22 100644
--- a/pkg/analyzer/test/dart/element/builder_test.dart
+++ b/pkg/analyzer/test/dart/element/builder_test.dart
@@ -1114,6 +1114,19 @@ main() {
expect(variableElement.initializer, isNotNull);
}
+ void test_genericFunction_isExpression() {
+ buildElementsForText('main(p) { p is Function(int a, String); }');
+ var main = compilationUnit.declarations[0] as FunctionDeclaration;
+ var body = main.functionExpression.body as BlockFunctionBody;
+ var statement = body.block.statements[0] as ExpressionStatement;
+ var expression = statement.expression as IsExpression;
+ var typeNode = expression.type as GenericFunctionType;
+ var typeElement = typeNode.type.element as GenericFunctionTypeElementImpl;
+ expect(typeElement.parameters, hasLength(2));
+ expect(typeElement.parameters[0].name, 'a');
+ expect(typeElement.parameters[1].name, '');
+ }
+
void test_visitDefaultFormalParameter_local() {
CompilationUnit unit = parseCompilationUnit('''
main() {
@@ -1221,6 +1234,16 @@ abstract class _ApiElementBuilderTestMixin {
*/
void checkMetadata(Element element);
+ void test_genericFunction_asTopLevelVariableType() {
+ buildElementsForText('int Function(int a, String) v;');
+ var v = compilationUnit.declarations[0] as TopLevelVariableDeclaration;
+ var typeNode = v.variables.type as GenericFunctionType;
+ var typeElement = typeNode.type.element as GenericFunctionTypeElementImpl;
+ expect(typeElement.parameters, hasLength(2));
+ expect(typeElement.parameters[0].name, 'a');
+ expect(typeElement.parameters[1].name, '');
+ }
+
void test_metadata_fieldDeclaration() {
List<FieldElement> fields =
buildElementsForText('class C { @a int x, y; }').types[0].fields;
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698