Implement inspection for declarations with implicit platform types #KT-12310 Fixed
(cherry picked from commit 00d8c26)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1cb72169f9
commit
d7bf03be46
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() = java.lang.String.valueOf(1)
|
||||
@@ -0,0 +1,26 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>function.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/function.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Function, property or variable has platform type.</problem_class>
|
||||
<description>Function has platform type. Make the type explicit to prevent subtle bugs.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>property1.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/property1.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Function, property or variable has platform type.</problem_class>
|
||||
<description>Property has platform type. Make the type explicit to prevent subtle bugs.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>property2.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/property2.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Function, property or variable has platform type.</problem_class>
|
||||
<description>Property has platform type. Make the type explicit to prevent subtle bugs.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.HasPlatformTypeInspection
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
val local = java.lang.String.valueOf(1)
|
||||
|
||||
fun bar() = java.lang.String.valueOf(2)
|
||||
|
||||
class Local {
|
||||
val local = java.lang.String.valueOf(3)
|
||||
|
||||
fun bar() = java.lang.String.valueOf(4)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val bar = java.lang.String.valueOf(1)
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val list = arrayOf(java.lang.String.valueOf(1))
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Wrapper<T>(val value: T)
|
||||
|
||||
fun star(): Wrapper<Wrapper<*>> = Wrapper(Wrapper(Any()))
|
||||
|
||||
fun star2(): List<*> = listOf(Any())
|
||||
Reference in New Issue
Block a user