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

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

Issue 2621433003: fixes #28236, generic methods should not cause warnings in Dart 1 (Closed)
Patch Set: test type annotation fix Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.generated.resolver_test_case; 5 library analyzer.test.generated.resolver_test_case;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 class StaticTypeAnalyzer2TestShared extends ResolverTestCase { 745 class StaticTypeAnalyzer2TestShared extends ResolverTestCase {
746 String testCode; 746 String testCode;
747 Source testSource; 747 Source testSource;
748 CompilationUnit testUnit; 748 CompilationUnit testUnit;
749 749
750 /** 750 /**
751 * Looks up the identifier with [name] and validates that its type type 751 * Looks up the identifier with [name] and validates that its type type
752 * stringifies to [type] and that its generics match the given stringified 752 * stringifies to [type] and that its generics match the given stringified
753 * output. 753 * output.
754 */ 754 */
755 expectFunctionType(String name, String type, 755 FunctionTypeImpl expectFunctionType(String name, String type,
756 {String elementTypeParams: '[]', 756 {String elementTypeParams: '[]',
757 String typeParams: '[]', 757 String typeParams: '[]',
758 String typeArgs: '[]', 758 String typeArgs: '[]',
759 String typeFormals: '[]'}) { 759 String typeFormals: '[]',
760 String identifierType}) {
761 identifierType ??= type;
762
760 typeParameters(Element element) { 763 typeParameters(Element element) {
761 if (element is ExecutableElement) { 764 if (element is ExecutableElement) {
762 return element.typeParameters; 765 return element.typeParameters;
763 } else if (element is ParameterElement) { 766 } else if (element is ParameterElement) {
764 return element.typeParameters; 767 return element.typeParameters;
765 } 768 }
766 fail('Wrong element type: ${element.runtimeType}'); 769 fail('Wrong element type: ${element.runtimeType}');
767 } 770 }
768 771
769 SimpleIdentifier identifier = findIdentifier(name); 772 SimpleIdentifier identifier = findIdentifier(name);
770 // Element is either ExecutableElement or ParameterElement. 773 // Element is either ExecutableElement or ParameterElement.
771 Element element = identifier.staticElement; 774 var element = identifier.staticElement;
772 FunctionTypeImpl functionType = identifier.staticType; 775 FunctionTypeImpl functionType = (element as dynamic).type;
773 expect(functionType.toString(), type); 776 expect(functionType.toString(), type);
777 expect(identifier.staticType.toString(), identifierType);
774 expect(typeParameters(element).toString(), elementTypeParams); 778 expect(typeParameters(element).toString(), elementTypeParams);
775 expect(functionType.typeParameters.toString(), typeParams); 779 expect(functionType.typeParameters.toString(), typeParams);
776 expect(functionType.typeArguments.toString(), typeArgs); 780 expect(functionType.typeArguments.toString(), typeArgs);
777 expect(functionType.typeFormals.toString(), typeFormals); 781 expect(functionType.typeFormals.toString(), typeFormals);
782 return functionType;
778 } 783 }
779 784
780 /** 785 /**
781 * Looks up the identifier with [name] and validates its static [type]. 786 * Looks up the identifier with [name] and validates its static [type].
782 * 787 *
783 * If [type] is a string, validates that the identifier's static type 788 * If [type] is a string, validates that the identifier's static type
784 * stringifies to that text. Otherwise, [type] is used directly a [Matcher] 789 * stringifies to that text. Otherwise, [type] is used directly a [Matcher]
785 * to match the type. 790 * to match the type.
786 * 791 *
787 * If [propagatedType] is given, also validate's the identifier's propagated 792 * If [propagatedType] is given, also validate's the identifier's propagated
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. 844 * text. Otherwise, [expected] is used directly a [Matcher] to match the type.
840 */ 845 */
841 _expectType(DartType type, expected) { 846 _expectType(DartType type, expected) {
842 if (expected is String) { 847 if (expected is String) {
843 expect(type.toString(), expected); 848 expect(type.toString(), expected);
844 } else { 849 } else {
845 expect(type, expected); 850 expect(type, expected);
846 } 851 }
847 } 852 }
848 } 853 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/test/generated/static_type_analyzer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698