dart-sdk/tests/dart2js_2/41449b_test.dart
Stephen Adams 89c5b5c904 [dart2js] Call-through stubs must forward type arguments
There are several problems contributing to issue 41449.
This fixes the malformed call-through stubs.

Change-Id: I90f1584f221956ee3fe4111314cba2813a16837c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150283
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2020-06-08 18:40:53 +00:00

51 lines
1.3 KiB
Dart

// Copyright (c) 2020, 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.
// @dart = 2.7
// This test is the same as 41449a_test.dart without forcing `-O0`.
//
// Regression test for passing type parameters through call-through stub.
//
// We use an abstract class with two implementations to avoid the optimizer
// 'inlining' the call-through stub, so we are testing that the stub itself
// passes through the type parameters.
import 'package:expect/expect.dart';
abstract class AAA {
dynamic get foo;
}
class B1 implements AAA {
final dynamic foo;
B1(this.foo);
}
class B2 implements AAA {
final dynamic _arr;
B2(foo) : _arr = [foo];
dynamic get foo => _arr.first;
}
@pragma('dart2js:noInline')
test1<T>(AAA a, String expected) {
// call-through getter 'foo' with one type argument.
Expect.equals(expected, a.foo<T>());
}
@pragma('dart2js:noInline')
test2<U, V>(AAA a, String expected) {
// call-through getter 'foo' with two type arguments.
Expect.equals(expected, a.foo<U, V>());
}
main() {
test1<int>(B1(<P>() => '$P'), 'int');
test1<num>(B2(<Q>() => '$Q'), 'num');
test2<int, num>(B1(<A, B>() => '$A $B'), 'int num');
test2<num, int>(B2(<X, Y>() => '$X $Y'), 'num int');
}