Files
sdk/pkg/compiler/test/rti/emission/jsinterop_generic.dart
T
Mayank Patke bd672a90af [dart2js] Improve simplification of type tests.
Change-Id: I29fd8e32145df61816bf98dd9fdc2dac33cafc75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157662
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-18 09:14:10 +00:00

62 lines
1.4 KiB
Dart

// Copyright (c) 2018, 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.7
// dart2jsOptions=--strong
@JS()
library foo;
// TODO(johnniwinther): Avoid generating duplicate is/as function when multiple
// jsinterop classes implement the same interface.
/*class: global#JavaScriptObject:checks=[$isA,$isB,$isB],instance*/
import 'package:expect/expect.dart';
import 'package:js/js.dart';
/*class: A:checkedInstance,checks=[],instance,onlyForRti*/
@JS()
@anonymous
class A<T> {
external factory A();
}
/*class: B:checkedInstance*/
class B<T> {}
/*class: C:checks=[],instance,onlyForRti*/
@JS()
@anonymous
class C implements B<int> {
external factory C();
}
/*class: D:*/
class D<T> {}
/*class: E:checks=[],instance,onlyForRti*/
@JS()
@anonymous
class E implements B<String> {
external factory E();
}
main() {
test(new A<int>());
test(new A<String>());
test(new C());
test(new E());
}
test(o) {
Expect.isTrue(o is A<int>, "Expected $o to be A<int>");
Expect.isTrue(o is A<String>, "Expected $o to be A<String>");
Expect.isTrue(o is B<int>, "Expected $o to be B<int>");
Expect.isTrue(o is B<String>, "Expected $o to be B<String>");
Expect.isFalse(o is D<int>, "Expected $o not to be D<int>");
}