Resolve bounds for type parameters of generic type alias.

R=brianwilkerson@google.com

Change-Id: Iff270adcd55d0a8c3a0bfaeed2c0741ccb1a1c77
Reviewed-on: https://dart-review.googlesource.com/76440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 0a1ff71..069f66e 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -8285,6 +8285,11 @@
             unitMember.typeParameters,
             () => new FunctionTypeScope(
                 libraryScope, unitMember.declaredElement));
+      } else if (unitMember is GenericTypeAlias) {
+        _resolveTypeParameters(
+            unitMember.typeParameters,
+            () => new FunctionTypeScope(
+                libraryScope, unitMember.declaredElement));
       }
     }
   }
diff --git a/pkg/analyzer/test/src/dart/resolution/find_element.dart b/pkg/analyzer/test/src/dart/resolution/find_element.dart
index 1cd1173..dff0500 100644
--- a/pkg/analyzer/test/src/dart/resolution/find_element.dart
+++ b/pkg/analyzer/test/src/dart/resolution/find_element.dart
@@ -99,6 +99,15 @@
     fail('Not found top-level function: $name');
   }
 
+  GenericTypeAliasElement genericTypeAlias(String name) {
+    for (var element in unitElement.functionTypeAliases) {
+      if (element is GenericTypeAliasElement && element.name == name) {
+        return element;
+      }
+    }
+    fail('Not found generic type alias: $name');
+  }
+
   PropertyAccessorElement getter(String name, {String className}) {
     for (var class_ in unitElement.types) {
       if (className != null && class_.name != className) {
diff --git a/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
new file mode 100644
index 0000000..7f24421
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'driver_resolution.dart';
+import 'resolution.dart';
+import 'task_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(GenericTypeAliasDriverResolutionTest);
+    defineReflectiveTests(GenericTypeAliasTaskResolutionTest);
+  });
+}
+
+@reflectiveTest
+class GenericTypeAliasDriverResolutionTest extends DriverResolutionTest
+    with GenericTypeAliasResolutionMixin {}
+
+abstract class GenericTypeAliasResolutionMixin implements ResolutionTest {
+  test_typeParameters() async {
+    addTestFile(r'''
+class A {}
+
+class B {}
+
+typedef F<T extends A> = B<T> Function<U extends B>(T a, U b);
+''');
+    await resolveTestFile();
+
+    var f = findElement.genericTypeAlias('F');
+    expect(f.typeParameters, hasLength(1));
+
+    var t = f.typeParameters[0];
+    expect(t.name, 'T');
+    assertElementTypeString(t.bound, 'A');
+
+    var ff = f.function;
+    expect(ff.typeParameters, hasLength(1));
+
+    var u = ff.typeParameters[0];
+    expect(u.name, 'U');
+    assertElementTypeString(u.bound, 'B');
+  }
+}
+
+@reflectiveTest
+class GenericTypeAliasTaskResolutionTest extends TaskResolutionTest
+    with GenericTypeAliasResolutionMixin {}
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index 5c385a3..744c8d9 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -8,6 +8,7 @@
 import 'class_test.dart' as class_test;
 import 'enum_test.dart' as enum_test;
 import 'for_in_test.dart' as for_in_test;
+import 'generic_type_alias_test.dart' as generic_type_alias_test;
 import 'import_prefix_test.dart' as import_prefix_test;
 import 'instance_creation_test.dart' as instance_creation_test;
 import 'instance_member_inference_class_test.dart'
@@ -23,6 +24,7 @@
     class_test.main();
     enum_test.main();
     for_in_test.main();
+    generic_type_alias_test.main();
     import_prefix_test.main();
     instance_creation_test.main();
     instance_member_inference_class_test.main();