704446d159
Change-Id: Ia0a3271c9137bc8c7fa4cdbd469cf93d9453b69c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103405 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Mike Fairhurst <mfairhurst@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
|
|
}
|