Add "Round using roundToInt/roundToLong" quick fix
#KT-30389 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1455451601
commit
607325c6e5
+1
@@ -1,5 +1,6 @@
|
||||
// "Create function 'synchronized'" "false"
|
||||
// ACTION: Convert expression to 'Int'
|
||||
// ACTION: Round using roundToInt()
|
||||
// ERROR: Type mismatch: inferred type is Float but Int was expected
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Round using roundToInt()" "false"
|
||||
// DISABLE-ERRORS
|
||||
// ACTION: Change parameter 'x' type of function 'foo' to 'Double'
|
||||
// ACTION: Convert expression to 'Float'
|
||||
// ACTION: Create function 'foo'
|
||||
// WITH_RUNTIME
|
||||
fun test(d: Double) {
|
||||
foo(d<caret>)
|
||||
}
|
||||
|
||||
fun foo(x: Float) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Round using roundToInt()" "false"
|
||||
// DISABLE-ERRORS
|
||||
// ACTION: Change parameter 'x' type of function 'foo' to 'Long'
|
||||
// ACTION: Convert expression to 'Int'
|
||||
// ACTION: Create function 'foo'
|
||||
// WITH_RUNTIME
|
||||
fun test(l: Long) {
|
||||
foo(l<caret>)
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Round using roundToInt()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(d: Double) {
|
||||
foo(d<caret>)
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
// "Round using roundToInt()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(d: Double) {
|
||||
foo(d.roundToInt())
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Round using roundToLong()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(d: Double) {
|
||||
bar(d<caret>)
|
||||
}
|
||||
|
||||
fun bar(x: Long) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
// "Round using roundToLong()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(d: Double) {
|
||||
bar(d.roundToLong())
|
||||
}
|
||||
|
||||
fun bar(x: Long) {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Round using roundToInt()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(f: Float) {
|
||||
foo(f<caret>)
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
// "Round using roundToInt()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(f: Float) {
|
||||
foo(f.roundToInt())
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Round using roundToLong()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(f: Float) {
|
||||
bar(f<caret>)
|
||||
}
|
||||
|
||||
fun bar(x: Long) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
// "Round using roundToLong()" "true"
|
||||
// WITH_RUNTIME
|
||||
fun test(f: Float) {
|
||||
bar(f.roundToLong())
|
||||
}
|
||||
|
||||
fun bar(x: Long) {}
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
// ACTION: Change type of 'a' to 'Double'
|
||||
// ACTION: Convert expression to 'Int'
|
||||
// ACTION: Convert property initializer to getter
|
||||
// ACTION: Round using roundToInt()
|
||||
// ERROR: The floating-point literal does not conform to the expected type Int
|
||||
|
||||
val a : Int = 1.12<caret>
|
||||
@@ -4,6 +4,7 @@
|
||||
// ACTION: Convert expression to 'Long'
|
||||
// ACTION: Convert property initializer to getter
|
||||
// ACTION: Add underscores
|
||||
// ACTION: Round using roundToLong()
|
||||
// ERROR: The floating-point literal does not conform to the expected type Long
|
||||
|
||||
val a : Long = 10000000000000000000.0<caret>
|
||||
Reference in New Issue
Block a user