Skip to content

Commit 70c5ac1

Browse files
shadrinaelizarov
authored andcommitted
Fix samples
1 parent cb4a895 commit 70c5ac1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

proposals/context-receivers.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Take a look at the following example.
215215

216216
```kotlin
217217
context(Comparator<T>)
218-
inline infix operator fun <T> T.compareTo(other: T) = compare(this, other)
218+
infix operator fun <T> T.compareTo(other: T) = compare(this, other)
219219

220220
context(Comparator<T>)
221221
val <T> Pair<T, T>.max get() = if (first > second) first else second
@@ -296,7 +296,7 @@ For every receiver in the scope, the compiler generates the label from the name
296296

297297
```kotlin
298298
context(Logger, Storage<User>)
299-
fun userInfo(name: String): Storage.Info<User> {
299+
fun userInfo(name: String): Storage<User>.Info {
300300
this@Logger.info("Retrieving info about $name")
301301
return this@Storage.info(name)
302302
}
@@ -309,7 +309,7 @@ In cases where the label cannot be generated or referenced, a workaround is to u
309309
typealias IterableClass<C, T> = (C) -> Iterator<T>
310310

311311
context(IterableClass<C, T>)
312-
inline operator fun <C, T> C.iterator(): Iterator<T> = this@IterableClass.invoke(this)
312+
operator fun <C, T> C.iterator(): Iterator<T> = this@IterableClass.invoke(this)
313313
```
314314

315315
Using labeled `this` may come in handy even without context receivers. If multiple receivers in a nested scope can be

0 commit comments

Comments
 (0)