Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin DSL generated accessors for JVM types are typed Any, should be typed properly instead #22968

Closed
eskatos opened this issue Dec 4, 2022 · 0 comments · Fixed by #25815
Closed
Assignees
Labels
a:bug has:reproducer Indicates the issue has a confirmed reproducer in:kotlin-dsl
Milestone

Comments

@eskatos
Copy link
Member

eskatos commented Dec 4, 2022

Expected Behavior

Gradle Kotlin DSL generated accessors for JVM types, e.g. a Project extension whose type is declared in the JDK, should be propertly typed.

Current Behavior

They are considered inaccessible and thus typed Any.
Types from the Kotlin stdlib are currently working (e.g. List), so this is really about types from the JDK that aren't handled by the Kotlin stdlib.

See AccessorsClassPath.loadAccessibilityInfoFor(className: String): TypeAccessibilityInfo

Context

Steps to Reproduce

See the reproducer test introduced in b4e0464

@eskatos eskatos added a:bug in:kotlin-dsl has:reproducer Indicates the issue has a confirmed reproducer labels Dec 4, 2022
bot-gradle added a commit that referenced this issue Dec 5, 2022
…VM target to 8

Previously, the compilation of `.gradle.kts` scripts always used Java 8 as the Kotlin JVM target.
Starting with this PR, it now uses the version of the JVM running the build.

If your team is using e.g. Java 11 to run Gradle, this allows you to use Java 11 librairies and language features in your build scripts.

----

Implementation notes

* [x] IDE editor uses the Gradle build JVM in its context thus reflects the JVM target used to compile the scripts
* [x] Generated Gradle API Kotlin DSL extensions JAR is still compiled with target JVM 8
* [x] Selected JVM target is part of the cache key for script compilation
* [x] Accessors generation still uses JVM 8
    JVM types in accessors are not accessible anyway
    #22968
    Adding JVM selection would not provide any enhancement, would be convoluted to test and add complexity at this point

Related optimistic fixes

* [x] `plugins {}` block compilation for precompiled scripts now honors configured `jvmTarget`

----

* Fixes #21041

Co-authored-by: Paul Merlin <paul@gradle.com>
@eskatos eskatos added this to the 8.4 RC1 milestone Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug has:reproducer Indicates the issue has a confirmed reproducer in:kotlin-dsl
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants