Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2575. Remove null-aware warnings for CFE #2578

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading