Skip to content

fix: add explicit lambda parameter types for Kotlin 2.x compatibility#3

Merged
BjornvdLaan merged 3 commits intomainfrom
claude/fix-gradle-plugin-errors-591sH
Apr 23, 2026
Merged

fix: add explicit lambda parameter types for Kotlin 2.x compatibility#3
BjornvdLaan merged 3 commits intomainfrom
claude/fix-gradle-plugin-errors-591sH

Conversation

@BjornvdLaan
Copy link
Copy Markdown
Contributor

Gradle 8.14 bundles Kotlin 2.x which enforces stricter type inference.
Without explicit annotations, the tasks.register lambda parameter and
project.exec lambda parameter can't be inferred, causing "Variable
expected" and "Closure was expected" compile errors respectively.

https://claude.ai/code/session_01AJYvT4hqhYe9HZfGnbX5Eg

claude added 3 commits April 22, 2026 18:34
Gradle 8.14 bundles Kotlin 2.x which enforces stricter type inference.
Without explicit annotations, the `tasks.register` lambda parameter and
`project.exec` lambda parameter can't be inferred, causing "Variable
expected" and "Closure was expected" compile errors respectively.

https://claude.ai/code/session_01AJYvT4hqhYe9HZfGnbX5Eg
Gradle 8.14 ships Kotlin 2.x which has stricter type inference and
uses receiver lambdas (T.() -> Unit) everywhere in the DSL instead
of explicit-parameter lambdas.

Three changes required:
- ObserverPlugin: rename local `extension` to `ext` to avoid the
  name clash with ObserverTask.extension inside the receiver lambda,
  and use the trailing-lambda receiver form for tasks.register so
  Kotlin resolves the Action overload cleanly.
- ObserverPlugin: switch task.reportFile assignment to .set() because
  abstract val properties cannot be directly reassigned.
- ObserverTask: replace deprecated project.exec (whose Groovy Closure
  overload wins overload resolution in Kotlin 2.x) with an injected
  ExecOperations service, which exposes only the Action/receiver-lambda
  overload of exec.

https://claude.ai/code/session_01AJYvT4hqhYe9HZfGnbX5Eg
@BjornvdLaan BjornvdLaan merged commit 0fd15d4 into main Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants