~/talk

Getting ready for Kotlin Context Receivers

Talkat droidcon New York 2023 · 2023-09-14..09-15· [kotlin]
links:none on file
slides:none on file

Experimental Kotlin context receivers require enabling -Xcontext-receivers and compile to functions that the JVM sees as extra parameters — bytecode adds context as parameters — so calls are rewritten at compile time. They work on functions, classes, interfaces and SAMs, handle generics, and ambiguous methods resolve via explicit at-qualifiers. Nested with/apply blocks remain a pain but custom helpers (author shows a with-multiple-receivers helper using generics and a suppression) solve it. Not production-recommended yet and no multiplatform support, but full language support is likely next year.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 1:03What are context receivers
  3. 3:53Basic usage and width statements
  4. 5:15Context receivers on classes and interfaces
  5. 7:48SAM types and context resolution
  6. 8:29Handling duplicate method names
  7. 9:56Context receivers with generics
  8. 11:02How context receivers work under the hood
  9. 13:09Avoiding nested with statements
  10. 14:14When to use context receivers
  11. 16:20Android examples with context receivers
  12. 19:55Business logic in view models
  13. 20:58Context receivers in Compose
  14. 24:35Compose slot APIs and extension functions
  15. 26:43Alternatives to with statements
  16. 28:08Custom width for multiple contexts
  17. 30:19Future of context receivers
  18. 32:26Dependency injection potential
  19. 33:08Cautions and multiplatform support
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.