Skip to content

Commit

Permalink
Fixes #2575. Remove null-aware warnings for CFE (#2578)
Browse files Browse the repository at this point in the history
The CFE no longer reports warnings, so tests shouldn't expect them.
  • Loading branch information
sgrekhov committed Mar 26, 2024
1 parent a111ff0 commit 3c24d05
Show file tree
Hide file tree
Showing 139 changed files with 80 additions and 1,140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ main() {
c!;
// ^
// [analyzer] STATIC_WARNING.UNNECESSARY_NON_NULL_ASSERTION
//^
// [cfe] Operand of null-aware operation '!' has type 'C' which excludes null.
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@ main() {
Expect.equals(1, a?.x);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'A' which excludes null.
Expect.equals(20, a?.y);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'A' which excludes null.
Expect.isNull(b?.x);
Expect.isNull(b?.y);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v *= e2 is
/// equivalent to the expression C.v *= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v *= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(2);
var res3 = (C?.v *= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(4, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v /= e2 is
/// equivalent to the expression C.v /= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v /= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(6);
var res3 = (C?.v /= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(3, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v ~/= e2 is
/// equivalent to the expression C.v ~/= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v ~/= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(5);
var res3 = (C?.v ~/= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(2, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v %= e2 is
/// equivalent to the expression C.v %= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v %= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(5);
var res3 = (C?.v %= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(1, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v += e2 is
/// equivalent to the expression C.v += e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v += 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(5);
var res3 = (C?.v += 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(7, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v -= e2 is
/// equivalent to the expression C.v -= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v -= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(5);
var res3 = (C?.v -= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(3, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v <<= e2 is
/// equivalent to the expression C.v <<= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v <<= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(5);
var res3 = (C?.v <<= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(20, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v >>= e2 is
/// equivalent to the expression C.v >>= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v >>= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(20);
var res3 = (C?.v >>= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(5, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v &= e2 is
/// equivalent to the expression C.v &= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v &= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(14);
var res3 = (C?.v &= 7);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(6, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v ^= e2 is
/// equivalent to the expression C.v ^= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v ^= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(14);
var res3 = (C?.v ^= 7);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(9, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v |= e2 is
/// equivalent to the expression C.v |= e2.
/// @author sgrekhov@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v |= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(14);
var res3 = (C?.v |= 7);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expect.equals(15, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A compound assignment of the form C?.v op= e2 is equivalent to
/// the expression C.v op= e2.
///
/// @description Checks that an expression of the of the form C?.v >>>= e2 is
/// equivalent to the expression C.v >>>= e2.
/// @author iarkh@unipro.ru
Expand Down Expand Up @@ -41,17 +42,13 @@ main() {
Expect.throws(() {C?.v >>>= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
Expect.equals(1, C.getterInvocation);
Expect.equals(0, C.setterInvocation);

C.init(20);
var res3 = (C?.v >>>= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] The class 'C' cannot be null.
var expected = 20 >>> 2;
Expect.equals(1, C.getterInvocation);
Expect.equals(1, C.setterInvocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
/// @assertion Evaluation of a compound assignment of the form e1?.v op = e2 is
/// equivalent to ((x) => x?.v = x.v op e2)(e1) where x is a variable that is not
/// used in e2.
///
/// @description Checks that an expression of the form e1?.v *= e2 is equivalent
/// to ((x) => x?.v = x.v * e2)(e1) where x is a variable that is not used in e2.
/// @author sgrekhov@unipro.ru

import '../../../../Utils/expect.dart';

class C {
Expand Down Expand Up @@ -42,15 +42,11 @@ main() {
Expect.throws(() {c2?.v *= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'C' which excludes null.

C c3 = new C(3);
var res3 = (c3?.v *= 3);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'C' which excludes null.
Expect.equals(1, c3.getterInvocation);
Expect.equals(1, c3.setterInvocation);
Expect.equals(9, res3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
/// @assertion Evaluation of a compound assignment of the form e1?.v op = e2 is
/// equivalent to ((x) => x?.v = x.v op e2)(e1) where x is a variable that is not
/// used in e2.
///
/// @description Checks that an expression of the form e1?.v /= e2 is equivalent
/// to ((x) => x?.v = x.v / e2)(e1) where x is a variable that is not used in e2.
/// @author sgrekhov@unipro.ru

import '../../../../Utils/expect.dart';

class C {
Expand Down Expand Up @@ -42,15 +42,11 @@ main() {
Expect.throws(() {c2?.v /= 2;});
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'C' which excludes null.

C c3 = new C(4);
var res3 = (c3?.v /= 2);
// ^^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
// ^
// [cfe] Operand of null-aware operation '?.' has type 'C' which excludes null.
Expect.equals(1, c3.getterInvocation);
Expect.equals(1, c3.setterInvocation);
Expect.equals(2, res3);
Expand Down
Loading

0 comments on commit 3c24d05

Please sign in to comment.