Youssef Shoaib [MOD]
07/25/2025, 6:13 PMcontext consistently, even for DSL builders that pass a single context, is superior for a nice experience. Maybe this annotation makes a receiver only appear as a context for users that have contexts enabled, thus preparing for when everyone has them enabled to then "flip the switch". It can then also warn users who refer to this explicitly for an annotated receiver and recommend changing to contextOf instead. Perhaps a similar thing can also be applied to methods that take in an extension receiver now but want to take a context in the future, but that feels less useful for DSLs you can simple @Deprecate the extension version and introduce the context version right away, but you can't do the same with block DSLsCLOVIS
07/27/2025, 6:11 PMval foo = "\$foo" // Warning: add interpolation prefix
println("""
foo: $foo
""".trimIndent())
Let's follow the warning. We get:
val foo = $$"$foo"
println("""
foo: $foo
""".trimIndent())
So far, so good. But now, the variable is pointless. Let's inline it, we get:
println("""
foo: $foo // doesn't compile
""".trimIndent())
Sometimes, it does actually inline it into:
println("""
foo: ${$$"$foo"}
""".trimIndent())
which was probably not the intent behind the KEEP. There is no inspection there to add an interpolation prefix.
There is also no inspection for:
println("""
foo: ${"\$foo"}
""".trimIndent())
Code highlighting frequently gets it wrong (e.g. see attached screenshot).
In the end, I'm pretty much did the entire migration manually.
Especially now that the team is proposing changing existing syntax in every other KEEP, I'm worried that tooling is being left off as an afterthought.Shaun Wild
08/10/2025, 11:49 AMMultipleChoices not qualify for context sensitive resolution here? It's a list of sealed class (from KOOG)Bernhard
08/11/2025, 2:33 PMRafael Costa
08/13/2025, 9:48 AMfun bar(
lambda: context(String) () -> Unit
) {
with("") {
lambda()
}
}
fun foo() {
bar {
this // error
}
}
Am I missing something? Is this not supposed to give me a string?
I am not able to get the context parameter of the lambda in any way. If I try bar { str -> then "str" here is also an error 🤔CLOVIS
08/13/2025, 1:46 PMCLOVIS
08/20/2025, 12:16 PMtailrec only a warning and not an error?Shaun Wild
08/22/2025, 3:36 PMShaun Wild
08/26/2025, 9:16 AMHunter
08/26/2025, 7:15 PMinternal to get the closest behavior but I really would want it to only be accessible in-file. If not, would be very nice to have.eygraber
08/29/2025, 4:23 AMYoussef Shoaib [MOD]
08/30/2025, 10:27 AM@Bridged KSP plugin yet that generates contextual bridge functions?Mohammad Fallah
09/01/2025, 12:43 PMfun rollDice(): 1 | 2 | 3 | 4 | 5 | 6 {...}
or
fun switch(switch : "on" | "off") { ... }phldavies
09/01/2025, 7:05 PMgetValue and setValue the semantics of context-parameters would be murky (is the context resolved on use or on declaration), but what is the reason not to support context-parameters on provideDelegate? Would the semantics not be quite clear that the context-parameter is used at declaration, i.e at the val x by y and non-contextual getValue /`setValue` used as any other delegate?Daniel Pitts
09/04/2025, 4:07 PMorg.jetbrains.kotlin.plugin.assignment becomes integrated with the core language at some point? It's a nifty feature that I'd love to use in my own DSLs.eygraber
09/04/2025, 4:17 PMStarr
09/06/2025, 5:25 PMWhen calling Java functions on the JVM, you can't use the named argument syntax because Java bytecode does not always preserve the names of function parameters.
However, nearly all java code these days is compiled with the metadata needed; and any changes (in either dependencies or combined-source java files) would be no more breaking than with kotlin. Given that stability, and by-name parameters mechanics being relevant only at compile-time, I'm not sure why the regular java metadata can't be used?
Arjan van Wieringen
09/07/2025, 6:19 AMimplicit function for context parameters? I am experimenting and I can find of no other way to access the context inside of an context inside a lambda.
EDIT: it appears to be https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/context-of.htmlCLOVIS
09/13/2025, 6:01 PMTom
09/15/2025, 1:42 PMArjan van Wieringen
09/17/2025, 6:46 PMfun doFoo(depA: DependencyA, depB: DependencyB, param: Param) { ... }
you can type doF in IntelliJ and see the possible options that are available in this scope.
However, when you have context parameters you have the above example as follows:
context(depA: DependencyA, depB: DependencyB)
fun doFoo(param: Param) { ... }
you will never get doFoo as suggestion if you do not have proper contextual scope. This makes perfect sense of course! However, it greatly reduces ways to discover API's via IntelliJ, without going fully into docs / source code. I can imagine that working with foreign API's which require context parameters it is hard to find the proper functions.
Are there any ideas around this? E.g, autocomplete/hinting with suggestions that will work if you add more context?CLOVIS
09/18/2025, 6:58 AMreified and interface methods is unfortunate.
Let's say I have:
interface Container<T> {
fun <O> map(…): Container<O>
}
But, I want to know the type of the contents of the container (because of KotlinX.Serialization, because type parameters are erased).
interface Container<T> {
val type: KType
fun <O> map(type: KType, …): Container<0>
}
That works, but specifying the type is not convenient, so I'd like to have a convenience overload:
interface Container<T> {
val type: KType
fun <O> map(type: KType, …): Container<O>
inline fun <reified O> map(…): Container<O> =
map(typeOf<O>(), …)
}
but inline can't be used within interfaces, so
interface Container<T> {
val type: KType
fun <O> map(type: KType, …): Container<O>
}
inline fun <T, reified O> Container<T>.map(…): Container<O> =
map(typeOf<O>(), …)
This actually decreases developer experience quite a bit because IntelliJ will always auto-complete the inconvenient overload much higher than the convenient one.
Also, I can't make the initial .map function protected , so I have to use opt-in annotations.
But let's say that I have an implementation
class Foo<T> {
override fun <O> map(…): Foo<O>
}
Notice how it returns an instance of itself to users.
Now that .map has become an extension function, it's not possible anymore to override it to change its output type.
Also, it's not possible to have a Container<Nothing> anymore because reified forbids Nothing .Youssef Shoaib [MOD]
09/18/2025, 10:50 PMinterface Functor<F<_>> { // Imaginary syntax, based on Scala's F[_]
fun <A, B> F<A>.map(f: (A) -> B): F<B>
}
object ListFunctor: Functor<List> {
override fun <A, B> List<A>.map(f: (A) -> B): List<B> = ...
}
It's good to note that Kotlin doesn't have raw types, unlike Java, and so seeing just List means the type constructor List, and not a raw type equivalent to List<*>Hunter
09/19/2025, 5:14 PMKFunctions in places where lambdas with context are expected. For example
class Server
data class Foo(val action: context(Server) (Int) -> Unit)
context(_: Server)
fun doSomething(int: Int) { ... }
// val foo = Foo(::doSomething) This currently doesn't work
val foo = Foo { doSomething(it) }
I would really like to be able to pass ::doSomething into Foo, but it doesn't work currently.
I know context parameters are experimental, is this something expected to be fixed/added in the future? There's a YouTrack issue for this, but I don't see any timeline for it or if it's even expected to change.Arjan van Wieringen
10/10/2025, 8:09 AMPHondogo
10/16/2025, 4:18 PMinternal modifier that it is module wide.
Why not to make sealed classes also module wide?
I have lot of cases in my code where declaration of base class is in somePackage and all inherited classes in somePackage.subPackage.
Now it is not possible to use sealed classes such way.phldavies
10/17/2025, 4:08 PM-Xnested-type-aliases by declaring an otherwise empty object containing only type aliases for the types you want to 'export'.PHondogo
10/18/2025, 11:14 AMKirill Grouchnikov
10/20/2025, 6:11 PMw: Language version 1.8 is deprecated and its support will be removed in a future version of Kotlin
Looks like this is already on the table. What's the plan for moving off of 1.8 as the minimum supported version?