blob: 79ec58ad8025c6b7260ef0d087aa8c330863bae6 [file] [log] [blame]
// 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.
/// @assertion It is a compile time error to assign a value to a local variable
/// marked late and final when the variable is definitely assigned. This includes
/// all forms of assignments, including assignments via the composite assignment
/// operators as well as pre and post-fix operators.
///
/// @description Check that it is a compile time error to assign a value to a
/// local variable marked late and final when the variable is definitely assigned
/// @author sgrekhov@unipro.ru
// Requirements=nnbd-strong
class C {
C operator +(int val) {
return this;
}
C operator -(int val) {
return this;
}
C operator *(int val) {
return this;
}
C operator /(int val) {
return this;
}
C operator %(int val) {
return this;
}
C operator <<(int val) {
return this;
}
C operator >>(int val) {
return this;
}
C operator ~/(int val) {
return this;
}
C operator &(int val) {
return this;
}
C operator |(int val) {
return this;
}
C operator ^(int val) {
return this;
}
}
main() {
late final C x = new C();
x += 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x -= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x *= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x /= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x %= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x ~/= 1;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
x <<= 1;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
x >>= 1;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
x &= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x ^= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
x |= 1;
// ^^
// [analyzer] unspecified
// [cfe] unspecified
}