Introduce inspection for nullable extension receiver of inline function

So #KT-22303 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-01-19 11:32:12 +03:00
parent 08d3f20e09
commit c90056f8c4
9 changed files with 174 additions and 1 deletions
@@ -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>
@@ -0,0 +1,9 @@
public class JavaClass {
public static String getNull() {
return null;
}
public static My getMy() {
return null;
}
}
@@ -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() {}
}