Allow contracts on final non-override members since 1.4
This commit is contained in:
@@ -246,11 +246,15 @@ public class KtNamedFunction extends KtTypeParameterListOwnerStub<KotlinFunction
|
||||
}
|
||||
|
||||
public boolean mayHaveContract() {
|
||||
return mayHaveContract(true);
|
||||
}
|
||||
|
||||
public boolean mayHaveContract(boolean isAllowedOnMembers) {
|
||||
KotlinFunctionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.mayHaveContract();
|
||||
}
|
||||
|
||||
return KtPsiUtilKt.isContractPresentPsiCheck(this);
|
||||
return KtPsiUtilKt.isContractPresentPsiCheck(this, isAllowedOnMembers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,9 +296,9 @@ inline fun <reified T : KtElement, R> flatMapDescendantsOfTypeVisitor(
|
||||
|
||||
// ----------- Contracts -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
fun KtNamedFunction.isContractPresentPsiCheck(): Boolean {
|
||||
fun KtNamedFunction.isContractPresentPsiCheck(isAllowedOnMembers: Boolean): Boolean {
|
||||
val contractAllowedHere =
|
||||
isTopLevel &&
|
||||
(isAllowedOnMembers || isTopLevel) &&
|
||||
hasBlockBody() &&
|
||||
!hasModifier(KtTokens.OPERATOR_KEYWORD)
|
||||
if (!contractAllowedHere) return false
|
||||
|
||||
Reference in New Issue
Block a user