Skip to content

Commit d6bfc7b

Browse files
authored
dataconnect: relax variance of the NullableReference type parameter to covariant (was invariant) (#6511)
1 parent 3d6e8b2 commit d6bfc7b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/util/NullableReference.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
*/
1616
package com.google.firebase.dataconnect.util
1717

18-
internal class NullableReference<T>(val ref: T? = null) {
18+
/**
19+
* A class that simply wraps a reference to another object, possibly a null reference. Instances of
20+
* this class can be useful for the case where the meaning of `null` is overloaded, such as
21+
* [kotlinx.coroutines.flow.MutableStateFlow.compareAndSet].
22+
*/
23+
internal class NullableReference<out T>(val ref: T? = null) {
1924
override fun equals(other: Any?) = (other is NullableReference<*>) && other.ref == ref
2025
override fun hashCode() = ref?.hashCode() ?: 0
2126
override fun toString() = ref?.toString() ?: "null"

0 commit comments

Comments
 (0)