Register type arguments on generic super invocations.

Closes #34701

Change-Id: Ib0e575213c87be915cbfaff101e4421352030e87
Reviewed-on: https://dart-review.googlesource.com/c/78360
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/kernel/kernel_impact.dart b/pkg/compiler/lib/src/kernel/kernel_impact.dart
index b9ff323..fa881c1 100644
--- a/pkg/compiler/lib/src/kernel/kernel_impact.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_impact.dart
@@ -475,10 +475,10 @@
   void handleSuperInvocation(ir.Name name, ir.Node arguments) {
     FunctionEntity method =
         elementMap.getSuperMember(currentMember, name, setter: false);
-    _visitArguments(arguments);
+    List<DartType> typeArguments = _visitArguments(arguments);
     if (method != null) {
       impactBuilder.registerStaticUse(new StaticUse.superInvoke(
-          method, elementMap.getCallStructure(arguments)));
+          method, elementMap.getCallStructure(arguments), typeArguments));
     } else {
       impactBuilder.registerStaticUse(new StaticUse.superInvoke(
           elementMap.getSuperNoSuchMethod(currentMember.enclosingClass),
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index 3b2239c..5e7b719 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -295,13 +295,14 @@
 
   /// Invocation of a super method [element] with the given [callStructure].
   factory StaticUse.superInvoke(
-      FunctionEntity element, CallStructure callStructure) {
+      FunctionEntity element, CallStructure callStructure,
+      [List<DartType> typeArguments]) {
     assert(
         element.isInstanceMember,
         failedAt(element,
             "Super invoke element $element must be an instance method."));
-    return new StaticUse.internal(element, StaticUseKind.INVOKE,
-        callStructure: callStructure);
+    return new GenericStaticUse(
+        element, StaticUseKind.INVOKE, callStructure, typeArguments);
   }
 
   /// Read access of a super field or getter [element].
diff --git a/tests/compiler/dart2js_extra/34701_test.dart b/tests/compiler/dart2js_extra/34701_test.dart
new file mode 100644
index 0000000..5612791
--- /dev/null
+++ b/tests/compiler/dart2js_extra/34701_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2017, 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.
+
+// dart2jsOptions=--omit-implicit-checks
+
+/// Regression test for issue 34701.
+
+import 'dart:async';
+import 'package:expect/expect.dart';
+import 'package:meta/dart2js.dart';
+
+class A {
+  @noInline //# 01: ok
+  Future<T> _foo<T>(FutureOr<T> Function() f) async {
+    return await f();
+  }
+
+  @noInline //# 01: continued
+  Future<String> get m async => _foo(() => "a");
+}
+
+class M {}
+
+class B extends A with M {
+  @noInline //# 01: continued
+  Future<T> _foo<T>(FutureOr<T> Function() f) => super._foo(f);
+}
+
+main() async {
+  var b = new B();
+  print(b.m.runtimeType);
+  print((await b.m).runtimeType);
+  Expect.isTrue(b.m is Future<String>);
+  Expect.isTrue((await b.m) is String);
+}