Skip to content

Commit da7ee6c

Browse files
committed
Suggestions from code review
1 parent ba8c480 commit da7ee6c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

proposals/context-parameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This document is not (yet) formally a KEEP, since it lacks some of the technical
5151
**§1.1** *(declaration)*: Function and property declarations get support for **context parameters**. Context parameters are declared with the `context` keyword followed by a list of parameters, each of the form `name: Type`.
5252

5353
* Constructors may **not** declare context parameters.
54+
* Context parameters are allowed in operators, except for those related to [property delegation](https://kotlinlang.org/spec/declarations.html#delegated-property-declaration).
5455
* Within the body of the declaration, the value of the context parameter is accessible using its name, similar to value parameters.
5556
* It is allowed to use `_` as a name; in that case, the value is not accessible through any name (but still participates in context resolution).
5657

@@ -172,6 +173,7 @@ fun <A, B, C, R> context(a: A, b: B, c: C, block: context(A, B, C) () -> R): R =
172173
**§2.2** *(`implicit` function)*: We also provide a generic way to obtain a value by type from the context. It allows access to context parameters even when declared using `_`, or within the body of a lambda.
173174

174175
* Implementations are encouraged, but not required, to mark this function as `inline`.
176+
* If possible, type inference for type variable `A` should be restricted (for example, using `@NoInfer`). Developers are expected to use the function with explicit type arguments.
175177

176178
```kotlin
177179
context(ctx: A) fun <A> implicit(): A = ctx

0 commit comments

Comments
 (0)