You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interface LoggingContext {
val log: Logger // This context provides a reference to a logger
}
context(LoggingContext)
fun startBusinessOperation() {
// You can access the log property since LoggingContext is an implicit receiver
log.info("Operation has started")
}
fun test(loggingContext: LoggingContext) {
with(loggingContext) {
// You need to have LoggingContext in a scope as an implicit receiver
// to call startBusinessOperation()
startBusinessOperation()
}
}
Additional information
Current version of ktlint: 0.45.1
The text was updated successfully, but these errors were encountered:
Expected Behavior
Ktlint should handle Kotlin files where context receivers are used.
Current Behavior
Scanning a file which includes a function using context receivers from Kotlin 1.6.20 currently fails with
Example declaration from Kotlin blog
Additional information
The text was updated successfully, but these errors were encountered: