Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

KT-22210 Use meaningful parameter names instead of p0 #464

Closed
sdeleuze opened this issue Aug 16, 2017 · 13 comments
Closed

KT-22210 Use meaningful parameter names instead of p0 #464

sdeleuze opened this issue Aug 16, 2017 · 13 comments

Comments

@sdeleuze
Copy link

In IntelliJ IDEA, when you enable the option that displays implicit parameter names, you get weird p0 parameters in id() and plugin(). Meaningful parameter names would be better.

screenshot from 2017-08-16 14-39-13

@JLLeitschuh
Copy link
Contributor

JLLeitschuh commented Aug 16, 2017

Is this because gradle is compiled without the -parameters compiler flag? This sounds like something that needs to be fixed in the core gradle repository.

https://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html

I can open a pull request if this seems like an appropriate fix.

@eskatos
Copy link
Member

eskatos commented Sep 27, 2017

#437 (comment)
Upon further inspection this seems to be caused by Kotlin interface delegation (... : Project by project { ...) not preserving the parameter names in the generated bytecode.

Parameter names show up correctly for non delegated members, for instance, notice the version parameter below:
screen shot 2017-07-21 at 10 32 31 am

@AlexCzar
Copy link

@eskatos I searched Kotlin's issue tracker but couldn't find this specific problem. Was it reported?

@eskatos
Copy link
Member

eskatos commented Jan 4, 2018

@AlexCzar not that I know of, feel free to report it upstream, I'll get back to it next week if you don't beat me to it.

It doesn't happen when no .kts file is involved.
I didn't try and reproduce outside of the Kotlin DSL yet.

@eskatos eskatos changed the title Use meaningful parameter names instead of p0 KT-22210 Use meaningful parameter names instead of p0 Jan 10, 2018
@eskatos
Copy link
Member

eskatos commented Jan 10, 2018

Reported upstream: https://youtrack.jetbrains.com/issue/KT-22210

@bamboo
Copy link
Member

bamboo commented May 22, 2018

Moved to backlog so we can decide if we should tackle it ourselves.

@eskatos
Copy link
Member

eskatos commented May 24, 2018

Two candidate solutions until Gradle is built with Java 8 and -parameters:

  • have a parameter names index in the Gradle distribution and enhance the Gradle API Jar before passing it to the Kotlin compiler in the Kotlin DSL build
  • building all Gradle modules with Java 8 and -parameters, publish them and use them instead of gradleApi() in the Kotlin DSL build

@bamboo
Copy link
Member

bamboo commented Jun 29, 2018

Tracked it down to https://youtrack.jetbrains.com/issue/KT-25193

@JLLeitschuh
Copy link
Contributor

Good find!

@eskatos
Copy link
Member

eskatos commented Jul 19, 2018

A workaround is mentioned in https://youtrack.jetbrains.com/issue/KT-25193#comment=27-2957572

As a temporary workaround, you can use the compiler argument -Xuse-old-class-files-reading.

Description of that argument is Use old class files reading implementation (may slow down the build and should be used in case of problems with the new implementation)

See https://github.com/JetBrains/kotlin/blob/094cb6be1d351022a1d6a8cdcd1c30f74a6c82e3/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt#L148-L153

@eskatos
Copy link
Member

eskatos commented Aug 1, 2018

Made an attempt with -java-parameters and -Xuse-old-class-files-reading in 28cc2ec without success, doesn't work from the cli nor in the ide.

@eskatos
Copy link
Member

eskatos commented Aug 1, 2018

Adding -Xuse-old-class-files-reading to the small reproducer build works: https://github.com/bamboo/kotlin-parameter-names

To make all this work we'd need the Gradle API jar bytecode to include parameter names.

@eskatos eskatos closed this as completed Aug 5, 2018
@JLLeitschuh
Copy link
Contributor

🎆 🎉 👍 🎉 🎆

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants