CLOVIS
06/29/2026, 7:27 PMYoussef Shoaib [MOD]
06/29/2026, 8:02 PMinternal class NonExhaustive(val nothing: Nothing): MyEnum, so within your library, you can still get exhaustivity, but outside, users will be forced to use else. Even better, this prevents you from accidentally assuming exhaustivity in public inline methods because NonExhaustive is not @PublishedApiYoussef Shoaib [MOD]
06/29/2026, 8:13 PMRequiresOptIn with a non-public type... Users thus can't opt-in, unless they do it using the compiler argumentCLOVIS
06/30/2026, 7:10 AMAnother devious trick: you canThe result is the same as withwith a non-public type... Users thus can't opt-in, unless they do it using the compiler argumentRequiresOptIn
DeprecationLevel.ErrorYoussef Shoaib [MOD]
06/30/2026, 7:13 AMReplaceWith. It also means that you don't need to use error suppression