https://kotlinlang.org logo
j

josephivie

07/26/2016, 12:02 AM
Where should I report the following bug?
Copy code
val scale:Int
if(condition){
	scale = whatever
}
Compiles in Android Studio, but when transformClassesWithDex runs in Gradle, it fails with a very vague error:
Copy code
Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information.
It took me a loooong time to catch this one. The automatic Java to Kotlin converter wrote the odd code, and that's how I found it. I think it's odd that this is apparently valid Kotlin code. No compiler errors or warnings. I thought anything declared as a
val
would have to be initialized immediately.