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

Side by Side Diff: pkg/analyzer/test/generated/declaration_resolver_test.dart

Issue 2814063003: Support for using generic function types in other AST structures. (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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/declaration_resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.declaration_resolver_test; 5 library engine.declaration_resolver_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 CompilationUnit unit = await resolveSource(code); 461 CompilationUnit unit = await resolveSource(code);
462 PropertyAccessorElement setterElement = 462 PropertyAccessorElement setterElement =
463 _findSimpleIdentifier(unit, code, 'zzz(_)').staticElement; 463 _findSimpleIdentifier(unit, code, 'zzz(_)').staticElement;
464 expect(setterElement.isSetter, isTrue); 464 expect(setterElement.isSetter, isTrue);
465 // re-resolve 465 // re-resolve
466 CompilationUnit unit2 = _cloneResolveUnit(unit); 466 CompilationUnit unit2 = _cloneResolveUnit(unit);
467 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz(_)'); 467 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz(_)');
468 expect(getterName.staticElement, same(setterElement)); 468 expect(getterName.staticElement, same(setterElement));
469 } 469 }
470 470
471 test_genericFunction_asFunctionReturnType() async {
472 String code = r'''
473 Function(int, String) f() => null;
474 ''';
475 CompilationUnit unit = await resolveSource(code);
476 // re-resolve
477 _cloneResolveUnit(unit);
478 // no other validations than built into DeclarationResolver
479 }
480
481 test_genericFunction_asGenericFunctionReturnType() async {
482 String code = r'''
483 typedef F<T> = int Function(T t, S s) Function<S>(int);
484 ''';
485 CompilationUnit unit = await resolveSource(code);
486 // re-resolve
487 _cloneResolveUnit(unit);
488 // no other validations than built into DeclarationResolver
489 }
490
491 test_genericFunction_asMethodReturnType() async {
492 String code = r'''
493 class C {
494 Function(int, String) m() => null;
495 }
496 ''';
497 CompilationUnit unit = await resolveSource(code);
498 // re-resolve
499 _cloneResolveUnit(unit);
500 // no other validations than built into DeclarationResolver
501 }
502
503 test_genericFunction_asParameterReturnType() async {
504 String code = r'''
505 f(Function(int, String) p) => null;
506 ''';
507 CompilationUnit unit = await resolveSource(code);
508 // re-resolve
509 _cloneResolveUnit(unit);
510 // no other validations than built into DeclarationResolver
511 }
512
513 test_genericFunction_asTopLevelVariableType() async {
514 String code = r'''
515 int Function(int, String) v;
516 ''';
517 CompilationUnit unit = await resolveSource(code);
518 // re-resolve
519 _cloneResolveUnit(unit);
520 // no other validations than built into DeclarationResolver
521 }
522
471 test_invalid_functionDeclaration_getter_inFunction() async { 523 test_invalid_functionDeclaration_getter_inFunction() async {
472 String code = r''' 524 String code = r'''
473 var v = (() { 525 var v = (() {
474 main() { 526 main() {
475 int get zzz => 42; 527 int get zzz => 42;
476 } 528 }
477 }); 529 });
478 '''; 530 ''';
479 CompilationUnit unit = await resolveSource(code); 531 CompilationUnit unit = await resolveSource(code);
480 FunctionElement getterElement = 532 FunctionElement getterElement =
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 expect(element.type.toString(), "<T>(T, T) → T"); 792 expect(element.type.toString(), "<T>(T, T) → T");
741 expect(t.element, same(tElement)); 793 expect(t.element, same(tElement));
742 794
743 // re-resolve 795 // re-resolve
744 CompilationUnit unit2 = _cloneResolveUnit(unit); 796 CompilationUnit unit2 = _cloneResolveUnit(unit);
745 node = _findSimpleIdentifier(unit2, code, 'max').parent; 797 node = _findSimpleIdentifier(unit2, code, 'max').parent;
746 t = node.typeParameters.typeParameters[0]; 798 t = node.typeParameters.typeParameters[0];
747 expect(t.element, same(tElement)); 799 expect(t.element, same(tElement));
748 } 800 }
749 } 801 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/declaration_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698