Files
sdk/tests/language/implicit_downcast_during/compound_assignment_test.dart
Robert Nystrom 7134a451f3 Format tests/language/i*.
A lot of files in this one, but nothing interesting in any of the tests.

Change-Id: I69c705bfd2c2b2f9711b393e4ac78c357336e1a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407660
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-02-05 08:36:21 -08:00

31 lines
850 B
Dart

// Copyright (c) 2017, 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.
class A {}
class B extends A {
Object operator +(Object x) => x;
}
void main() {
B b = B();
b += 2;
//^
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'B'.
// ^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
++b;
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'B'.
b++;
// [error column 3, length 3]
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [error column 4]
// [cfe] A value of type 'Object' can't be assigned to a variable of type 'B'.
}