7dd4259d87
Change-Id: Ie7b6ff9e62b3b8c78f6c04359cb72f77b249440c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97240 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
33 lines
1009 B
Dart
33 lines
1009 B
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.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
/*element: main:[null]*/
|
|
main() {
|
|
trustParameters();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Test that we trust the explicit type of a parameter.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/*element: _trustParameters:[exact=JSUInt31]*/
|
|
_trustParameters(
|
|
int
|
|
/*strong.Union([exact=JSString], [exact=JSUInt31])*/
|
|
/*omit.[exact=JSUInt31]*/
|
|
/*strongConst.Union([exact=JSString], [exact=JSUInt31])*/
|
|
/*omitConst.[exact=JSUInt31]*/
|
|
i) {
|
|
return i;
|
|
}
|
|
|
|
/*element: trustParameters:[null]*/
|
|
trustParameters() {
|
|
dynamic f = _trustParameters;
|
|
Expect.equals(0, f(0));
|
|
Expect.throws(/*[null|subclass=Object]*/ () => f('foo'));
|
|
}
|