Replace with safe calls forbidden for comparisons #KT-13432 Fixed
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// "Replace with safe (?.) call" "false"
|
||||
// ERROR: Infix call corresponds to a dot-qualified call 'p1.compareTo(p2)' which is not allowed on a nullable receiver 'p1'. Use '?.'-qualified call instead
|
||||
// ACTION: Add non-null asserted (!!) call
|
||||
// ACTION: Flip '>'
|
||||
// ACTION: Replace overloaded operator with function call
|
||||
|
||||
class SafeType {
|
||||
operator fun compareTo(other : SafeType) = 0
|
||||
}
|
||||
fun safeA(p1: SafeType?, p2: SafeType) {
|
||||
val v8 = p1 <caret>> p2
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// ERROR: Infix call corresponds to a dot-qualified call 'value?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'value?.compareTo(1)'. Use '?.'-qualified call instead
|
||||
var foo: Int? = null
|
||||
set(value) {
|
||||
if((value <caret>< 1) ?: false) {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// ERROR: Infix call corresponds to a dot-qualified call 'value?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'value?.compareTo(1)'. Use '?.'-qualified call instead
|
||||
var foo: Int? = null
|
||||
set(value) {
|
||||
if((value?.compareTo(1) < 0) ?: false) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user