Introduce "redundant explicit type" inspection #KT-18517 Fixed

Reported cases: constants, constructors, object references
This commit is contained in:
Mikhail Glukhikh
2017-06-22 18:05:12 +03:00
committed by Mikhail Glukhikh
parent 0f4ae3b727
commit f80f41d254
29 changed files with 302 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.RedundantExplicitTypeInspection
@@ -0,0 +1,3 @@
fun foo() {
val t: <caret>Boolean = true
}
@@ -0,0 +1,3 @@
fun foo() {
val t = true
}
@@ -0,0 +1,3 @@
fun foo() {
val ch: <caret>Char = 'z'
}
@@ -0,0 +1,3 @@
fun foo() {
val ch = 'z'
}
@@ -0,0 +1,5 @@
class Point(val x: Int, val y: Int)
fun foo() {
val p: <caret>Point = Point(1, 2)
}
@@ -0,0 +1,5 @@
class Point(val x: Int, val y: Int)
fun foo() {
val p = Point(1, 2)
}
@@ -0,0 +1,3 @@
fun foo() {
val pi: <caret>Double = 3.14
}
@@ -0,0 +1,3 @@
fun foo() {
val pi = 3.14
}
@@ -0,0 +1,3 @@
fun foo() {
val pi: <caret>Float = 3.14f
}
@@ -0,0 +1,3 @@
fun foo() {
val pi = 3.14f
}
@@ -0,0 +1,3 @@
fun foo() {
val i: <caret>Int = 42
}
@@ -0,0 +1,3 @@
fun foo() {
val i = 42
}
@@ -0,0 +1,5 @@
// PROBLEM: none
fun foo() {
val i: <caret>Int = 2 * 2
}
@@ -0,0 +1,12 @@
// PROBLEM: none
interface Point {
val x: Int
val y: Int
}
class PointImpl(override val x: Int, override val y: Int) : Point
fun foo() {
val p: <caret>Point = PointImpl(1, 2)
}
@@ -0,0 +1,3 @@
fun foo() {
val l: <caret>Long = 1234567890123L
}
@@ -0,0 +1,3 @@
fun foo() {
val l = 1234567890123L
}
@@ -0,0 +1,5 @@
// PROBLEM: none
class My {
val x: <caret>Int = 1
}
@@ -0,0 +1,5 @@
// PROBLEM: none
fun foo() {
val s: <caret>String? = null
}
@@ -0,0 +1,5 @@
object Obj
fun foo() {
val o: <caret>Obj = Obj
}
@@ -0,0 +1,5 @@
object Obj
fun foo() {
val o = Obj
}
@@ -0,0 +1,5 @@
// PROBLEM: none
fun foo() {
val i: <caret>Short = 42
}
@@ -0,0 +1,3 @@
fun foo() {
val s: <caret>String = "Hello"
}
@@ -0,0 +1,3 @@
fun foo() {
val s = "Hello"
}
@@ -0,0 +1,3 @@
// PROBLEM: none
val ZERO: <caret>Int = 0