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:
+13
@@ -0,0 +1,13 @@
|
||||
class MyClass
|
||||
|
||||
// In principle it is not correct, MyClass? is not a subtype of MyClass
|
||||
fun MyClass.inc(): MyClass? { return null }
|
||||
|
||||
public fun box() {
|
||||
var i : MyClass?
|
||||
i = MyClass()
|
||||
// Type of j should be inferred as MyClass?
|
||||
var j = ++<!DEBUG_INFO_SMARTCAST!>i<!>
|
||||
// j is null so call is unsafe
|
||||
j<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
Reference in New Issue
Block a user