Brian Hartvigsen
02/21/2025, 6:53 PMMissingUseCall rule detects the following as not using use?
val code = """
fun <T> MyCloseable.useMe(block: (object) -> T) = use { block(this) }
fun MyCloseable.useMe() = use {}
fun test() {
MyCloseable(0).use {}
MyCloseable(1).useMe()
MyCloseable(2).useMe { it.doStuff() }
}
${myClosable(clazz)}
""".trimIndent()
These are obviously contrived, we have a pattern that would look more like:
MyCloseable(0).use { it.subPropertyClosable.use { sub -> sub.doStuff() } }
I was trying to shorthand that to something like the useMe block except it's more like fun <T> MyCloseable.useMe(block: () -> T ) = use { subPropertyCloseable.use { block() } }, but I get an error that MyCloseable is doesn't call use to access the Closeable.Atul Gupta
08/12/2025, 4:53 AM