Skip to content

Commit cdcee48

Browse files
authored
Use non-nullable parameters for operator == (#264)
The null value will never be passed to the equals operator implementation. Widening the type causes any other class which implements this interface to also widen the type.
1 parent 1c72944 commit cdcee48

14 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.3
2+
3+
- `operator ==` overrides no longer take nullable arguments. This is only
4+
visible for classes that implement the interfaces defined in this package
5+
which no longer need to also widen the argument type.
6+
17
## 2.1.2
28

39
- Fix to `Quad.copy` ([#221](https://github.com/google/vector_math.dart/issues/221))

lib/src/vector_math/matrix2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class Matrix2 {
145145

146146
/// Check if two matrices are the same.
147147
@override
148-
bool operator ==(Object? other) =>
148+
bool operator ==(Object other) =>
149149
(other is Matrix2) &&
150150
(_m2storage[0] == other._m2storage[0]) &&
151151
(_m2storage[1] == other._m2storage[1]) &&

lib/src/vector_math/matrix3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Matrix3 {
236236

237237
/// Check if two matrices are the same.
238238
@override
239-
bool operator ==(Object? other) =>
239+
bool operator ==(Object other) =>
240240
(other is Matrix3) &&
241241
(_m3storage[0] == other._m3storage[0]) &&
242242
(_m3storage[1] == other._m3storage[1]) &&

lib/src/vector_math/matrix4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class Matrix4 {
521521

522522
/// Check if two matrices are the same.
523523
@override
524-
bool operator ==(Object? other) =>
524+
bool operator ==(Object other) =>
525525
(other is Matrix4) &&
526526
(_m4storage[0] == other._m4storage[0]) &&
527527
(_m4storage[1] == other._m4storage[1]) &&

lib/src/vector_math/vector2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Vector2 implements Vector {
9696

9797
/// Check if two vectors are the same.
9898
@override
99-
bool operator ==(Object? other) =>
99+
bool operator ==(Object other) =>
100100
(other is Vector2) &&
101101
(_v2storage[0] == other._v2storage[0]) &&
102102
(_v2storage[1] == other._v2storage[1]);

lib/src/vector_math/vector3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Vector3 implements Vector {
104104

105105
/// Check if two vectors are the same.
106106
@override
107-
bool operator ==(Object? other) =>
107+
bool operator ==(Object other) =>
108108
(other is Vector3) &&
109109
(_v3storage[0] == other._v3storage[0]) &&
110110
(_v3storage[1] == other._v3storage[1]) &&

lib/src/vector_math/vector4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Vector4 implements Vector {
124124

125125
/// Check if two vectors are the same.
126126
@override
127-
bool operator ==(Object? other) =>
127+
bool operator ==(Object other) =>
128128
(other is Vector4) &&
129129
(_v4storage[0] == other._v4storage[0]) &&
130130
(_v4storage[1] == other._v4storage[1]) &&

lib/src/vector_math_64/matrix2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class Matrix2 {
145145

146146
/// Check if two matrices are the same.
147147
@override
148-
bool operator ==(Object? other) =>
148+
bool operator ==(Object other) =>
149149
(other is Matrix2) &&
150150
(_m2storage[0] == other._m2storage[0]) &&
151151
(_m2storage[1] == other._m2storage[1]) &&

lib/src/vector_math_64/matrix3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Matrix3 {
236236

237237
/// Check if two matrices are the same.
238238
@override
239-
bool operator ==(Object? other) =>
239+
bool operator ==(Object other) =>
240240
(other is Matrix3) &&
241241
(_m3storage[0] == other._m3storage[0]) &&
242242
(_m3storage[1] == other._m3storage[1]) &&

lib/src/vector_math_64/matrix4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class Matrix4 {
521521

522522
/// Check if two matrices are the same.
523523
@override
524-
bool operator ==(Object? other) =>
524+
bool operator ==(Object other) =>
525525
(other is Matrix4) &&
526526
(_m4storage[0] == other._m4storage[0]) &&
527527
(_m4storage[1] == other._m4storage[1]) &&

lib/src/vector_math_64/vector2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Vector2 implements Vector {
9696

9797
/// Check if two vectors are the same.
9898
@override
99-
bool operator ==(Object? other) =>
99+
bool operator ==(Object other) =>
100100
(other is Vector2) &&
101101
(_v2storage[0] == other._v2storage[0]) &&
102102
(_v2storage[1] == other._v2storage[1]);

lib/src/vector_math_64/vector3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Vector3 implements Vector {
104104

105105
/// Check if two vectors are the same.
106106
@override
107-
bool operator ==(Object? other) =>
107+
bool operator ==(Object other) =>
108108
(other is Vector3) &&
109109
(_v3storage[0] == other._v3storage[0]) &&
110110
(_v3storage[1] == other._v3storage[1]) &&

lib/src/vector_math_64/vector4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Vector4 implements Vector {
124124

125125
/// Check if two vectors are the same.
126126
@override
127-
bool operator ==(Object? other) =>
127+
bool operator ==(Object other) =>
128128
(other is Vector4) &&
129129
(_v4storage[0] == other._v4storage[0]) &&
130130
(_v4storage[1] == other._v4storage[1]) &&

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: vector_math
2-
version: 2.1.2
2+
version: 2.1.3
33
description: A Vector Math library for 2D and 3D applications.
44
repository: https://github.com/google/vector_math.dart
55

0 commit comments

Comments
 (0)