Accessing to synthetic properties on smart casted Android components crashed compiler

I have some problems after Kotlin 1.1.2-5 for my Android project. The gradle log has following output:

e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Invalid Android class type: UNKNOWN
Cause: Invalid Android class type: UNKNOWN

(... some code snippets)

The root cause was thrown at: AndroidExpressionCodegenExtension.kt:210
	at org.jetbrains.kotlin.codegen.ExpressionCodegen.genQualified(
	at org.jetbrains.kotlin.codegen.ExpressionCodegen.genQualified(
	at org.jetbrains.kotlin.codegen.ExpressionCodegen.gen(
  	at org.jetbrains.kotlin.codegen.CallGenerator$DefaultCallGenerator.genValueAndPut(CallGenerator.kt:61)
    at org.jetbrains.kotlin.codegen.CallBasedArgumentGenerator.generateExpression(

After some research, I found this is related to smart cast and synthetic properties.

Here’s code that crashes compiler:

val bad = DialogInterface.OnShowListener { di ->
    di as Dialog
    di.any_view_id // Imported synthetic properties

di in third line is smart casted to Dialog, however, seems compiler doesn’t aware that.

Here’s an workaround:

val good = DialogInterface.OnShowListener { di ->
    val dialog = di as Dialog
    dialog.any_view_id // Imported synthetic properties

I hope Kotlin team could make compiler aware of smart casts to prevent this error.

Could you please file a YouTrack issue for this problem? Thanks!

This is my first time submitting YouTrack issue:

Hope there’s no problem in this report!