// 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 // 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; } class B3 implements AAA { final dynamic __foo; B3(this.__foo); dynamic get _foo => __foo; dynamic get foo => _foo; } @pragma('dart2js:noInline') test1(AAA a, String expected) { // call-through getter 'foo' with one type argument. Expect.equals(expected, a.foo()); } @pragma('dart2js:noInline') test2(AAA a, String expected) { // call-through getter 'foo' with two type arguments. Expect.equals(expected, a.foo()); } main() { test1(B1(

() => '$P'), 'int'); test1(B2(() => '$Q'), 'num'); test1(B3(() => '$R'), 'double'); test2(B1(() => '$A $B'), 'int num'); test2(B2(() => '$X $Y'), 'num int'); test2(B3(() => '$C $D'), 'double String'); }