Front-end fix: result type corrected for increment / decrement expressions. Smart cast allowed on a postfix increment result. See KT-7561.
Now result type is receiver type for postfix increment, or increment result type for prefix increment. A set of relevant tests.
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
class MyClass
|
||||
|
||||
// Correct at compile time but wrong at run-time
|
||||
fun MyClass?.inc(): MyClass? { return null }
|
||||
|
||||
public fun box() : MyClass? {
|
||||
var i : MyClass?
|
||||
i = MyClass()
|
||||
var j = i++
|
||||
<!DEBUG_INFO_SMARTCAST!>j<!>.hashCode()
|
||||
return i
|
||||
}
|
||||
Reference in New Issue
Block a user