dart-sdk/tests/language_2/cyclic_type_test.dart
Samir Jindel e23acaaf90 [vm/aot] Fix obfuscation.
Test Plan:

Make vm-kernel-precomp-obfuscate-linux-release-x64-try green, ensuring status file changes
reflect design gaps and not bugs.

Tested locally that obfuscated Flutter Gallery runs.

Change-Id: Ifcdc334de58f43c310e15b58dbcf6fe1597206f2
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-obfuscate-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/81009
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-26 13:00:33 +00:00

81 lines
3.5 KiB
Dart

// Copyright (c) 2013, 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.
// Tests self referencing types.
import "package:expect/expect.dart";
@pragma("vm:entry-point") // Prevent obfuscation
class Base<T> {
get t => T;
}
// Derived<T> is contractive.
@pragma("vm:entry-point") // Prevent obfuscation
class Derived<T> extends Base<Derived<T>> {} // //# 00: ok
// Derived<T> is contractive.
@pragma("vm:entry-point") // Prevent obfuscation
class Derived<T> extends Base<Derived<Derived<int>>> {} // //# 01: ok
// Derived<T> is non-contractive.
@pragma("vm:entry-point") // Prevent obfuscation
class Derived<T> extends Base<Derived<Derived<T>>> {} // //# 02: ok
// Derived1<U> and Derived2<V> are contractive.
@pragma("vm:entry-point") // Prevent obfuscation
class Derived1<U> extends Base<Derived2<U>> {} // //# 03: ok
@pragma("vm:entry-point") // Prevent obfuscation
class Derived2<V> extends Base<Derived1<V>> {} // //# 03: ok
// Derived1<U> and Derived2<V> are non-contractive.
@pragma("vm:entry-point") // Prevent obfuscation
class Derived1<U> extends Base<Derived2<U>> {} // //# 04: ok
@pragma("vm:entry-point") // Prevent obfuscation
class Derived2<V> extends Base<Derived1<Derived2<V>>> {} // //# 04: ok
main() {
// In the tests below we test that we get "int" and "bool" when calling
// toString() on the int and bool type respectively. This is not required
// behavior. However, we want to keep the original names for the most common
// core types so we make sure to handle these specifically in the compiler.
var d;
d = new Derived(); // //# 00: continued
Expect.equals("Derived<dynamic>", d.t.toString()); // //# 00: continued
d = new Derived<bool>(); // //# 00: continued
Expect.equals("Derived<bool>", d.t.toString()); // //# 00: continued
d = new Derived<Derived>(); // //# 00: continued
Expect.equals("Derived<Derived<dynamic>>", d.t.toString()); // //# 00: continued
d = new Derived(); // //# 01: continued
Expect.equals("Derived<Derived<int>>", d.t.toString()); // //# 01: continued
d = new Derived<bool>(); // //# 01: continued
Expect.equals("Derived<Derived<int>>", d.t.toString()); // //# 01: continued
d = new Derived<Derived>(); // //# 01: continued
Expect.equals("Derived<Derived<int>>", d.t.toString()); // //# 01: continued
d = new Derived(); // //# 02: continued
Expect.equals("Derived<Derived<dynamic>>", d.t.toString()); // //# 02: continued
d = new Derived<bool>(); // //# 02: continued
Expect.equals("Derived<Derived<bool>>", d.t.toString()); // //# 02: continued
d = new Derived<Derived>(); // //# 02: continued
Expect.equals("Derived<Derived<Derived<dynamic>>>", d.t.toString()); // //# 02: continued
d = new Derived1(); // //# 03: continued
Expect.equals("Derived2<dynamic>", d.t.toString()); // //# 03: continued
d = new Derived2(); // //# 03: continued
Expect.equals("Derived1<dynamic>", d.t.toString()); // //# 03: continued
d = new Derived2<Derived1<int>>(); // //# 03: continued
Expect.equals("Derived1<Derived1<int>>", d.t.toString()); // //# 03: continued
d = new Derived1(); // //# 04: continued
Expect.equals("Derived2<dynamic>", d.t.toString()); // //# 04: continued
d = new Derived2(); // //# 04: continued
Expect.equals("Derived1<Derived2<dynamic>>", d.t.toString()); // //# 04: continued
d = new Derived2<Derived1<int>>(); // //# 04: continued
Expect.equals("Derived1<Derived2<Derived1<int>>>", d.t.toString()); // //# 04: continued
}