3455133d98
Change-Id: I0765a1e0fb19f38d7ad1c8655ba444f2f46fbf6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128301 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
20 lines
739 B
Dart
20 lines
739 B
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.
|
|
|
|
// SharedOptions=--enable-experiment=non-nullable
|
|
|
|
// Test that it is an error to do what was once allowed as an "implicit
|
|
// downcast."
|
|
main() {
|
|
num asNum = 1;
|
|
Object asObject = 1;
|
|
dynamic asDynamic = 1;
|
|
int asInt1 = asNum; //# 01: compile-time error
|
|
double asDouble1 = asNum; //# 02: compile-time error
|
|
int asInt2 = asObject; //# 03: compile-time error
|
|
double asDouble2 = asObject; //# 04: compile-time error
|
|
String asString1 = asObject; //# 05: compile-time error
|
|
int asInt3 = asDynamic; //# 06: ok
|
|
}
|