OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Regression test for http://dartbug.com/28749. |
| 6 // |
| 7 // This would crash at compile time because inner typedefs remain after calling |
| 8 // [type.unalias]. Expanding the typedef causes the inputs to be used multiple |
| 9 // types, breaking the invariant of HTypeInfoExpression that the type variable |
| 10 // occurrences correspond to inputs. |
| 11 |
| 12 import 'package:expect/expect.dart'; |
| 13 |
| 14 typedef void F<T>(T value); |
| 15 typedef F<U> Converter<U>(F<U> function); |
| 16 typedef Converter<V> ConvertFactory<V>(int input); |
| 17 |
| 18 class B<W> { |
| 19 final field = new Wrap<ConvertFactory<W>>(); |
| 20 @NoInline() |
| 21 B(); |
| 22 } |
| 23 |
| 24 class Wrap<X> { |
| 25 @NoInline() |
| 26 Wrap(); |
| 27 } |
| 28 |
| 29 foo<Y>(int x) { |
| 30 if (x == 0) |
| 31 return new Wrap<ConvertFactory<Y>>().runtimeType; |
| 32 else |
| 33 return new B<Y>().field.runtimeType; |
| 34 } |
| 35 |
| 36 void main() { |
| 37 var name = '${Wrap}'; |
| 38 if (name.length < 4) return; // minified. |
| 39 |
| 40 Expect.equals( |
| 41 'Wrap<(int) => ((int) => void) => (int) => void>', |
| 42 '${new B<int>().field.runtimeType}', |
| 43 ); |
| 44 Expect.equals( |
| 45 'Wrap<(int) => ((bool) => void) => (bool) => void>', |
| 46 '${new B<bool>().field.runtimeType}', |
| 47 ); |
| 48 |
| 49 Expect.equals( |
| 50 'Wrap<(int) => ((dynamic) => void) => (dynamic) => void>', |
| 51 '${foo<int>(0)}', |
| 52 ); |
| 53 Expect.equals( |
| 54 'Wrap<(int) => ((dynamic) => void) => (dynamic) => void>', |
| 55 '${foo<String>(1)}', |
| 56 ); |
| 57 } |
OLD | NEW |