Files
sdk/runtime/tests/vm/dart_2/tts_regression39716_test.dart
T
Anis Alibegić 40e18905f2 Fixed various typos in a lot of files
Closes https://github.com/dart-lang/sdk/pull/49478

TEST=Manual

GitOrigin-RevId: f4c9c6869dfe73639295e86574a021523b3d374d
Change-Id: I134a97caed4eec59d70e9cbca16b7e9a472cf2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251902
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-07-25 12:21:59 +00:00

53 lines
1.5 KiB
Dart

// Copyright (c) 2019, 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.
// @dart = 2.9
import 'package:expect/expect.dart';
main() {
// Ensure all classes are used.
final l = <dynamic>[Base(), A<int>(), B<int>(), I<int>()];
print(l);
// Call `add(T)` with `T = A<int/String>` (the VM will not generate an
// optimized TTS for `A<int>` because there's two classes implementing
// `A`, both have type argument vector at a different offset, so it wouldn't
// know where to load it from)
// Populate the SubtypeTestCache with successful `add(I<String>())`.
final x = <dynamic>[<A<String>>[]];
x.single.add(I<String>());
// Ensure type check fails if list type is now `A<int>`.
final y = <dynamic>[<A<int>>[]];
String exception = '';
try {
y.single.add(I<String>());
} catch (e) {
exception = e.toString();
}
print(exception);
Expect.isTrue(exception.contains('is not a subtype of'));
}
// Ensure depth-first preorder cid numbering will have the cid for [A] in the
// middle and ensure type argument vector will be second field.
class Base {
final int baseField = int.parse('1');
}
class A<T> extends Base {
T foo(T arg) => arg;
}
class B<T> extends A<T> {}
// Make another implementation of A<T> where type argument vector is first
// field.
class I<T> implements A<T> {
int get baseField => int.parse('2');
T foo(T arg) => arg;
}