Skip to content

Commit 06da339

Browse files
authored
use explicit receivers to disambiguate possible accidental references to this (#81)
1 parent 7142c0b commit 06da339

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

protokt-runtime/src/main/kotlin/com/toasttab/protokt/rt/BytesSlice.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class BytesSlice(
3535
}
3636

3737
override fun equals(other: Any?) =
38-
equalsUsingSequence(other, { length }) { asSequence() }
38+
equalsUsingSequence(other, { it.length }) { it.asSequence() }
3939

4040
override fun hashCode() =
41-
hashCodeUsingSequence { asSequence() }
41+
hashCodeUsingSequence(asSequence())
4242

4343
override fun toString() =
4444
asSequence().joinToString(prefix = "[", postfix = "]")

protokt-runtime/src/main/kotlin/com/toasttab/protokt/rt/RuntimeUtils.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ fun <T> copyList(list: List<T>): List<T> =
4747

4848
internal inline fun <reified T> T.equalsUsingSequence(
4949
other: Any?,
50-
size: T.() -> Int,
51-
asSequence: T.() -> Sequence<*>
50+
size: (T) -> Int,
51+
asSequence: (T) -> Sequence<*>
5252
) =
5353
other is T &&
54-
size() == other.size() &&
55-
asSequence().zip(other.asSequence()).all { (l, r) -> l == r }
54+
size(this) == size(other) &&
55+
asSequence(this).zip(asSequence(other)).all { (l, r) -> l == r }
5656

57-
internal inline fun hashCodeUsingSequence(asSequence: () -> Sequence<*>) =
58-
asSequence().fold(1) { hash, elt -> 31 * hash + elt.hashCode() }
57+
internal fun hashCodeUsingSequence(asSequence: Sequence<*>) =
58+
asSequence.fold(1) { hash, elt -> 31 * hash + elt.hashCode() }

protokt-runtime/src/main/kotlin/com/toasttab/protokt/rt/UnknownFieldSet.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ private constructor(
9393
write(Tag((fieldNumber shl 3) or wireType))
9494

9595
override fun equals(other: Any?) =
96-
equalsUsingSequence(other, { size }) { asSequence() }
96+
equalsUsingSequence(other, { it.size }) { it.asSequence() }
9797

9898
override fun hashCode() =
99-
hashCodeUsingSequence { asSequence() }
99+
hashCodeUsingSequence(asSequence())
100100

101101
override fun toString(): String =
102102
"Field(" +

0 commit comments

Comments
 (0)