blob: 3b0ee51079e8019f93910bd4a8e4c789ae3976ca [file] [log] [blame]
// 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.
// dart2jsOptions=-O4
// @dart = 2.7
// 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;
class B2 implements AAA {
final dynamic _arr;
B2(foo) : _arr = [foo];
dynamic get foo => _arr.first;
class B3 implements AAA {
final dynamic __foo;
dynamic get _foo => __foo;
dynamic get foo => _foo;
test1<T>(AAA a, String expected) {
// call-through getter 'foo' with one type argument.
test2<U, V>(AAA a, String expected) {
// call-through getter 'foo' with two type arguments.
Expect.equals(expected,<U, V>());
main() {
test1<int>(B1(<P>() => '$P'), 'int');
test1<num>(B2(<Q>() => '$Q'), 'num');
test1<double>(B3(<R>() => '$R'), 'double');
test2<int, num>(B1(<A, B>() => '$A $B'), 'int num');
test2<num, int>(B2(<X, Y>() => '$X $Y'), 'num int');
test2<double, String>(B3(<C, D>() => '$C $D'), 'double String');