Files
sdk/pkg/front_end/testcases/late_lowering/later.dart
T
Jens Johansen a8c7757589 [CFE] Don't hard-code uncertain version numbers in messages or tests
Instead don't mention them (until they are certain), and make them
certain in tests, by setting a specific version (2.9999 in this case).

Change-Id: I1a375b4908c9d06f0241a6cda0746172d6b46c15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138285
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-04 14:35:05 +00:00

60 lines
1.2 KiB
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.
// @dart=2.9999
// This test checks for compile-time errors and their absence for some use cases
// of late fields and variables.
class A {
int a = 42;
late int b = (this.a * 2) >> 1; // Not an error.
foo(late int x) {} // Error.
}
bar(late int x) {} // Error.
baz() {
try {
throw "baz";
} on dynamic catch (late e, late t) {} // Error.
for (late int i = 0; i < 10; ++i) { // Error.
print("baz");
}
for (late String s in ["baz"]) { // Error.
print(s);
}
[for (late int i = 0; i < 10; ++i) i]; // Error.
}
hest() async {
await for (late String s in new Stream.fromIterable(["hest"])) { // Error.
print(s);
}
return "hest";
}
fisk() async {
late String s1 = await hest(); // Error.
late String s2 = '${fisk}${await hest()}${fisk}'; // Error.
late Function f = () async => await hest(); // Not an error.
}
class B {
late final int x = 42;
const B(); // Error: B has late final fields.
}
class C {
late final int x;
initVars() {
x = 42; // Ok: [x] doesn't have an initializer.
}
}
main() {}