Introduce inspection for nullable extension receiver of inline function
So #KT-22303 Fixed
This commit is contained in:
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class JavaClass {
|
||||
public static String getNull() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static My getMy() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
fun test() {
|
||||
JavaClass.getNull().toBoolean() // ISE in runtime
|
||||
JavaClass.getNull().toInt() // OK
|
||||
"123".toBoolean() // OK
|
||||
null.toBoolean() // Compilation error, no inspection message
|
||||
|
||||
JavaClass.getNull().contentNotInline() // OK
|
||||
JavaClass.getMy().contentNonExtensionInlineFun() // OK
|
||||
}
|
||||
|
||||
fun String.contentNotInline() {}
|
||||
|
||||
class My {
|
||||
inline fun contentNonExtensionInlineFun() {}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.kt</file>
|
||||
<line>2</line>
|
||||
<entry_point TYPE="file" FQNAME="Test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unsafe call of inline function with nullable extension receiver</problem_class>
|
||||
<description>Call of inline function with nullable extension receiver can provoke NPE in Kotlin 1.2+</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"inspectionClass": "org.jetbrains.kotlin.idea.inspections.PlatformExtensionReceiverOfInlineInspection",
|
||||
"withRuntime": "true",
|
||||
"isMultiModule": "false"
|
||||
}
|
||||
Reference in New Issue
Block a user