mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
62f84880ef
Closes #40520 Closes #40948 Closes #40425 Change-Id: I0aa3cfa51b410c90dd0bea963846eeb6b2e73efb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140540 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
34 lines
1 KiB
Dart
34 lines
1 KiB
Dart
// Copyright (c) 2014, 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 the dart2js implementation of runtime types.
|
|
|
|
library test.type_mirror_for_type;
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
import 'dart:mirrors';
|
|
|
|
class C<T> {}
|
|
|
|
class X {
|
|
Type foo() => Object;
|
|
}
|
|
|
|
main() {
|
|
// Make sure that we need a type test against the runtime representation of
|
|
// [Type].
|
|
var a = (new DateTime.now().millisecondsSinceEpoch != 42)
|
|
? new C<Type>()
|
|
: new C<int>();
|
|
print(a is C<Type>);
|
|
|
|
var typeMirror = reflectType(X) as ClassMirror;
|
|
var declarationMirror = typeMirror.declarations[#foo] as MethodMirror;
|
|
// Test that the runtime type implementation does not confuse the runtime type
|
|
// representation of [Type] with an actual value of type [Type] when analyzing
|
|
// the return type of [foo].
|
|
Expect.equals(reflectType(Type), declarationMirror.returnType);
|
|
}
|