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

Unified Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 2827463002: Issue 29360. Fix type name resolution for GenericTypeAliasElement. (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/generated/resolver.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/generated/non_error_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 8392f69dc190c39864802fbe43ac34c0a1a28cdb..25e7f50fc3615a4ad020d997827e724d897721b8 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -2184,6 +2184,42 @@ class B extends A implements Function {
verify([source]);
}
+ test_genericTypeAlias_castsAndTypeChecks_hasTypeParameters() async {
+ Source source = addSource('''
+typedef Foo<S> = S Function<T>(T x);
+
+main(Object p) {
+ (p as Foo)<int>(3);
+ if (p is Foo) {
+ p<int>(3);
+ }
+ (p as Foo<String>)<int>(3);
+ if (p is Foo<String>) {
+ p<int>(3);
+ }
+}
+''');
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ test_genericTypeAlias_castsAndTypeChecks_noTypeParameters() async {
+ Source source = addSource('''
+typedef Foo = T Function<T>(T x);
+
+main(Object p) {
+ (p as Foo)<int>(3);
+ if (p is Foo) {
+ p<int>(3);
+ }
+}
+''');
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
test_genericTypeAlias_fieldAndReturnType_noTypeParameters() async {
Source source = addSource(r'''
typedef Foo = int Function<T>(T x);
@@ -2247,6 +2283,19 @@ class A {
verify([source]);
}
+ test_genericTypeAlias_invalidGenericFunctionType() async {
+ Source source = addSource('''
+typedef F = int;
+main(p) {
+ p is F;
+}
+''');
+ await computeAnalysisResult(source);
+ // There is a parse error, but no crashes.
+ assertErrors(source, [ParserErrorCode.INVALID_GENERIC_FUNCTION_TYPE]);
+ verify([source]);
+ }
+
test_genericTypeAlias_noTypeParameters() async {
Source source = addSource(r'''
typedef Foo = int Function<T>(T x);
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698