Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/compiler/dart2js_extra/28749_test.dart

Issue 2812393003: dart2js: Capture typedef arguments once (Closed)
Patch Set: comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/js_ast/lib/src/printer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « pkg/js_ast/lib/src/printer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698