Kotlin compiler: ExpressionCodegen and when conditions

 

fun main(args : Array<String>) {
  val x = #(1, 3)

  if (x is #(val a : Number, val b : Number)) {
  println(a)
  println(b)
  }
}


According to the documentation the code like this is not yet supported… I tried to look into the implementation code and found that JetBindingExpression for “val a: Number” has no condition… it looks like it should be type check? And Expression for upper lever should check for class Tuple2 ?

It probably should, but we decided to defer complex pattern matching until later, because it's too much work, and we would like to focus. Also, I suspect that we might do very well without any pattern matching at all (smart casts replace 90% of it), so it's not really worth the effort to implement it now.