ended4월 2일· 1 sources

Kotlin's Self-Referential Generics: Enforcing Type Safety at System Boundaries

Kotlin의 자기참조 제네릭: UI/Domain 경계에서 타입 안전성 강제하기

Why it matters

At the UI/Domain boundary where compile-time types naturally blur, self-referential generics combined with sealed classes provide a standardized, type-safe way to communicate between layers. This pattern prevents type mismatches from reaching production by enforcing variance constraints at compile time while maintaining ergonomic API design. Understanding how covariance and contravariance work in this context is the difference between thoughtful architecture and cargo-culting generic patterns.

1
Sources
+0
24h
Growth
172d
Active
Self-referential genericsKotlin type systemVariance annotationsViewModel patternType erasure

Sources

Related Issues