Use information from stub for contracts presence

This commit is contained in:
Nikolay Krasko
2018-10-11 11:49:05 +03:00
parent d3ec145f13
commit ac2bc22f54
2 changed files with 10 additions and 10 deletions
@@ -293,11 +293,11 @@ inline fun <reified T : KtElement, R> flatMapDescendantsOfTypeVisitor(
// ----------- Contracts -------------------------------------------------------------------------------------------------------------------
fun KtElement.isContractPresentPsiCheck(): Boolean {
val contractAllowedHere = this is KtNamedFunction &&
isTopLevel &&
hasBlockBody() &&
!hasModifier(KtTokens.OPERATOR_KEYWORD)
fun KtNamedFunction.isContractPresentPsiCheck(): Boolean {
val contractAllowedHere =
isTopLevel &&
hasBlockBody() &&
!hasModifier(KtTokens.OPERATOR_KEYWORD)
if (!contractAllowedHere) return false
val firstExpression = ((this as? KtFunction)?.bodyExpression as? KtBlockExpression)?.statements?.firstOrNull() ?: return false