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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/js_ast/lib/src/printer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_extra/28749_test.dart
diff --git a/tests/compiler/dart2js_extra/28749_test.dart b/tests/compiler/dart2js_extra/28749_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b75dd271a37e471e237c6b07889fc4ca23e75bcd
--- /dev/null
+++ b/tests/compiler/dart2js_extra/28749_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2017, 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.
+
+// Regression test for http://dartbug.com/28749.
+//
+// This would crash at compile time because inner typedefs remain after calling
+// [type.unalias]. Expanding the typedef causes the inputs to be used multiple
+// types, breaking the invariant of HTypeInfoExpression that the type variable
+// occurrences correspond to inputs.
+
+import 'package:expect/expect.dart';
+
+typedef void F<T>(T value);
+typedef F<U> Converter<U>(F<U> function);
+typedef Converter<V> ConvertFactory<V>(int input);
+
+class B<W> {
+ final field = new Wrap<ConvertFactory<W>>();
+ @NoInline()
+ B();
+}
+
+class Wrap<X> {
+ @NoInline()
+ Wrap();
+}
+
+foo<Y>(int x) {
+ if (x == 0)
+ return new Wrap<ConvertFactory<Y>>().runtimeType;
+ else
+ return new B<Y>().field.runtimeType;
+}
+
+void main() {
+ var name = '${Wrap}';
+ if (name.length < 4) return; // minified.
+
+ Expect.equals(
+ 'Wrap<(int) => ((int) => void) => (int) => void>',
+ '${new B<int>().field.runtimeType}',
+ );
+ Expect.equals(
+ 'Wrap<(int) => ((bool) => void) => (bool) => void>',
+ '${new B<bool>().field.runtimeType}',
+ );
+
+ Expect.equals(
+ 'Wrap<(int) => ((dynamic) => void) => (dynamic) => void>',
+ '${foo<int>(0)}',
+ );
+ Expect.equals(
+ 'Wrap<(int) => ((dynamic) => void) => (dynamic) => void>',
+ '${foo<String>(1)}',
+ );
+}
« 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