This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 434
KT-25019 - Forward references at top level cause NPE with confusing stack trace #928
Labels
Comments
Hmm.. I don't know if that is obvious 🤔
And I is maybe the same issue here. Because of that I wouldn't say that this is an "issue". It is just an Kotlin syntax error... |
@StefMa getting a compiler error is my expectation due to an unresolved reference, but the failure now happens at runtime with a Similar to your example in "pure Kotlin": fun hello() {
val m: Map<String, Map<String, String>> = emptyMap()
val f by k
val k by m
} Fails to compile (which is what I would expect). I have a feeling this is a bug or difference in Kotlin script compilation. |
@ligee You want to take a look at this one? |
Thanks for reporting, I'll have a look. |
eskatos
changed the title
Forward references at top level cause NPE with confusing stack trace
KT-25019 - Forward references at top level cause NPE with confusing stack trace
Jun 21, 2018
In a similar fashion, with Gradle 4.10 the following block compiles fine in a val help: Task by tasks.getting
val help: TaskProvider<Task> by tasks.existing
val help: Help by tasks.getting(Help::class) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
https://youtrack.jetbrains.com/issue/KT-25019
Expected Behavior
I'm not sure if this is a Kotlin scripting specific issue that should fail compilation, but I ran into this when working to debug a colleague's build script. My expectation would be failed compilation as it doesn't seem like you should be able to forward reference variables like the example shown below.
Current Behavior
A
NullPointerException
is thrown with a line number that is out of the bounds of the file size.Context
Converting a Groovy build to Kotlin that was passing lots of things around at the top-level of the script. I was editing a 350 line build script that did not have any red in IDEA and compiled successfully, but failed at runtime here. I noticed the forward reference to the variable and noticed that switching the order of declaration made it safe at runtime.
Steps to Reproduce (for bugs)
Setup up Gradle 4.8 project with
build.gradle.kts
:Run
./gradlew -s
and see stacktrace:Your Environment
The text was updated successfully, but these errors were encountered: