// 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.

class C {
  C e() => this;
  C operator -() => this;
  C operator ~() => this;
}

void main() {
  final C? c = new C();
  /**/ -c?.e();
  //    ^^^^^^
  // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
  //   ^
  // [cfe] Operator 'unary-' cannot be called on 'C?' because it is potentially null.

  /**/ ~c?.e();
  //    ^^^^^^
  // [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
  //   ^
  // [cfe] Operator '~' cannot be called on 'C?' because it is potentially null.
}

Test error for -e and ~e when e is potentially nullable
Test error for -e and ~e when e is potentially nullable

This verifies that the operators `unary-` and `~` do not participate
in null-shorting. Cf. https://github.com/dart-lang/language/issues/1081.

Change-Id: Iba446724f00c1c4aaedb4be4425e69fb52cdb5c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166627
Reviewed-by: Lasse R.H. Nielsen <80295e4ef244a07779f93eaa95d582bad8e316a5@google.com>
Commit-Queue: Erik Ernst <251bb01623bfda2cd9151e339a6e783ca432874c@google.com>
