JS: add inspection for the case when something with dynamic type implicitly casted to kotlin another type
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>13</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to String</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>14</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Any</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>15</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Unit</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>22</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to String</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>36</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Any</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>40</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Unit</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>47</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Unit</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>43</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to String</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>43</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Any</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>43</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Unit</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>45</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Any</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>45</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Implicit (unsafe) cast from dynamic type</problem_class>
|
||||
<description>Implicit (unsafe) cast from dynamic to Unit</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnsafeCastFromDynamicInspection
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
class A {
|
||||
fun foo(i: Int) {}
|
||||
}
|
||||
|
||||
fun bar(d: dynamic, s: String, a: Any, u: Unit) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val d: dynamic = Any()
|
||||
var s: String = ""
|
||||
var a: Any = ""
|
||||
var u: Unit = Unit
|
||||
|
||||
s = d
|
||||
a = d
|
||||
u = d
|
||||
|
||||
s = d as String
|
||||
a = d as Any
|
||||
u = d as Unit
|
||||
|
||||
if (d is String) {
|
||||
s = d
|
||||
d.subSequence(1, 2)
|
||||
}
|
||||
|
||||
if (d is A) {
|
||||
d.foo(1)
|
||||
}
|
||||
|
||||
if (a is String) {
|
||||
s = a
|
||||
a.length
|
||||
}
|
||||
|
||||
if (d is Any) {
|
||||
a = d
|
||||
}
|
||||
|
||||
if (d is Unit) {
|
||||
u = d
|
||||
}
|
||||
|
||||
bar(d, d.boo, d, d)
|
||||
bar(d, d as String, d as Any, d as Unit)
|
||||
bar(d.aaa, d.bbb as String, d.ccc(), d.ddd {})
|
||||
|
||||
return d
|
||||
}
|
||||
Reference in New Issue
Block a user