Make "reflection not found" a warning, provide a quick fix
Reporting the warning on each "::", as ReflectionNotFoundInspection did, is not correct anymore, because for example name/get/set on properties works perfectly without kotlin-reflect.jar in the classpath. So instead we report the warning on calls to functions from reflection interfaces. This is not perfect either because it's wrong in projects with custom implementations of reflection interfaces, but this case is so rare that the users can suppress the warning there anyway #KT-7176 Fixed
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package test
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun bar(f: () -> Unit) = f()
|
||||
|
||||
// Inspection should be reported here because '::foo' may be used as a reflection object
|
||||
val p1 = ::foo // the type is KFunction0 by default
|
||||
val p2: KFunction0<Unit> = ::foo // the expected type is KFunction0
|
||||
|
||||
// But shouldn't be reported here
|
||||
val p3 = bar(::foo) // the expected type is Function0, '::foo' is used as an ordinary function
|
||||
val p4: Any = ::foo // the expected type is Any
|
||||
val p5: UnresolvedClass = ::foo // an error, another warning would be useless
|
||||
@@ -1,26 +0,0 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>functionReference.kt</file>
|
||||
<line>12</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/functionReference.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reflection not found</problem_class>
|
||||
<description>Reflection not found in the classpath</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>functionReference.kt</file>
|
||||
<line>13</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/functionReference.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reflection not found</problem_class>
|
||||
<description>Reflection not found in the classpath</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>withinAnnotationEntry.kt</file>
|
||||
<line>13</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/withinAnnotationEntry.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reflection not found</problem_class>
|
||||
<description>Reflection not found in the classpath</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -1 +0,0 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.ReflectionNotFoundInspection
|
||||
@@ -1,15 +0,0 @@
|
||||
package test
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class A(val arg: KClass<*>, val args: Array<KClass<*>>, vararg val other: KClass<*>)
|
||||
|
||||
A(Int::class, array(String::class), Double::class, Char::class)
|
||||
class MyClass {
|
||||
throws(Exception::class)
|
||||
fun foo() {
|
||||
Exception::class
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user