New Type Inference and Related Language Features
summary
Kotlin 1.3 exposes experimental features: an explicit contract DSL lets library functions declare effects (like “calls lambda exactly once” or “isNullOrEmpty() → receiver != null”) so the compiler applies smart casts; a rewritten new type inference engine (opt‑in) infers SAM lambdas from Java, improves builder/sequence inference (yield/buildSequence), analyzes whole call chains, and recognizes internal intersection type T!! = T & Any to treat checked-generic non‑nulls correctly. Migration checks and opt‑ins are provided.
AI-written summary · about
chapters (25)
- 0:00Intro
- 1:09Experimental features
- 1:52Example: Coroutines
- 2:26Automatic migration
- 2:53Experimental Language Features
- 5:21Using experimental API
- 6:05Experimental: Summary
- 7:04Changes in standard library
- 9:46Kotlin Contracts
- 12:08Contract: if the function returns false, the receiver is not null
- 16:08Why can't compiler just implicitly infer such information?
- 17:34Using contracts for your own functions
- 18:40Contracts: Summary
- 22:00Kotlin libraries
- 24:50SAM conversions for Kotlin functions
- 26:02Support for several SAM arguments
- 28:09Inference for sequence
- 28:59Inference for regular lambdas
- 29:45Inference for builder lambdas
- 30:17Builder inference
- 32:30Inference for call chains
- 34:06Better inference for intersection types
- 36:55Intersection type to denote not-nullable generic type
- 39:01Improving assertNotNull: return asserted value
- 40:43New type inference: summary








