dart-sdk/tests/language_2/regress/regress40066_test.dart
Alexander Markov 5357052714 [vm/compiler] Fix handling of function types in type tests for type parameters
Fixes https://github.com/dart-lang/sdk/issues/40066

Change-Id: I90f74c8162e5a369e656666e98e0e427bb179822
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131200
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-13 20:55:26 +00:00

30 lines
689 B
Dart

// Copyright (c) 2020, 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.
import "package:expect/expect.dart";
class A<T> {
foo(T x) {
print('T = $T');
print('x.runtimeType = ${x.runtimeType}');
print('x is T = ${x is T}');
}
}
typedef IntFunc = void Function(int);
typedef StringFunc = void Function(String);
void main() {
void inner<S>(S y) {}
IntFunc innerOfInt = inner;
A a = new A<IntFunc>();
a.foo(innerOfInt);
StringFunc innerOfString = inner;
Expect.throwsTypeError(() {
a.foo(innerOfString);
});
}