Fix of EA-105681 in KotlinRunLineMarkerContributor

This commit is contained in:
Mikhail Glukhikh
2017-08-11 14:00:48 +03:00
committed by Mikhail Glukhikh
parent 165707c46c
commit 830b543879
2 changed files with 7 additions and 6 deletions
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.types.Variance
class MainFunctionDetector {
private val getFunctionDescriptor: (KtNamedFunction) -> FunctionDescriptor
private val getFunctionDescriptor: (KtNamedFunction) -> FunctionDescriptor?
/** Assumes that the function declaration is already resolved and the descriptor can be found in the `bindingContext`. */
constructor(bindingContext: BindingContext) {
@@ -38,7 +38,7 @@ class MainFunctionDetector {
}
}
constructor(functionResolver: (KtNamedFunction) -> FunctionDescriptor) {
constructor(functionResolver: (KtNamedFunction) -> FunctionDescriptor?) {
this.getFunctionDescriptor = functionResolver
}
@@ -74,7 +74,8 @@ class MainFunctionDetector {
return false
}
return isMain(getFunctionDescriptor(function), checkJvmStaticAnnotation)
val functionDescriptor = getFunctionDescriptor(function) ?: return false
return isMain(functionDescriptor, checkJvmStaticAnnotation)
}
fun getMainFunction(module: ModuleDescriptor): FunctionDescriptor? = getMainFunction(module, module.getPackage(FqName.ROOT))
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.psi.KtNamedFunction
@@ -32,8 +32,8 @@ class KotlinRunLineMarkerContributor : RunLineMarkerContributor() {
if (function.nameIdentifier != element) return null
val detector = MainFunctionDetector { function ->
function.resolveToDescriptor() as FunctionDescriptor
val detector = MainFunctionDetector { someFunction ->
someFunction.resolveToDescriptorIfAny() as? FunctionDescriptor
}
if (detector.isMain(function)) {