Don't run contract-specific checks in propery scopes
^KT-45118 Fixed
This commit is contained in:
+4
-7
@@ -41,14 +41,13 @@ class ContractParsingServices(val languageVersionSettings: LanguageVersionSettin
|
||||
*
|
||||
* Otherwise, it may lead to inconsistent resolve state and failed assertions
|
||||
*/
|
||||
fun checkContractAndRecordIfPresent(expression: KtExpression, trace: BindingTrace, scope: LexicalScope) {
|
||||
fun checkContractAndRecordIfPresent(expression: KtExpression, trace: BindingTrace, ownerDescriptor: FunctionDescriptor) {
|
||||
// Fastpath. Note that it doesn't violates invariant described in KDoc, because 'isContractDescriptionCallPsiCheck'
|
||||
// is a *necessary* (but not sufficient, actually) condition for presence of 'LazyContractProvider'
|
||||
if (!expression.isContractDescriptionCallPsiCheck()) return
|
||||
|
||||
val callContext = ContractCallContext(expression, scope, trace, languageVersionSettings)
|
||||
val contractProviderIfAny =
|
||||
(scope.ownerDescriptor as? FunctionDescriptor)?.getUserData(ContractProviderKey) as? LazyContractProvider?
|
||||
val callContext = ContractCallContext(expression, ownerDescriptor, trace, languageVersionSettings)
|
||||
val contractProviderIfAny = ownerDescriptor.getUserData(ContractProviderKey) as? LazyContractProvider?
|
||||
var resultingContractDescription: ContractDescription? = null
|
||||
|
||||
try {
|
||||
@@ -103,11 +102,9 @@ class ContractParsingServices(val languageVersionSettings: LanguageVersionSettin
|
||||
|
||||
class ContractCallContext(
|
||||
val contractCallExpression: KtExpression,
|
||||
val scope: LexicalScope,
|
||||
val functionDescriptor: FunctionDescriptor,
|
||||
val trace: BindingTrace,
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
val ownerDescriptor: DeclarationDescriptor = scope.ownerDescriptor
|
||||
val functionDescriptor: FunctionDescriptor = ownerDescriptor as FunctionDescriptor
|
||||
val bindingContext: BindingContext = trace.bindingContext
|
||||
}
|
||||
+6
-2
@@ -353,8 +353,12 @@ public class ExpressionTypingServices {
|
||||
}
|
||||
blockLevelVisitor = new ExpressionTypingVisitorDispatcher.ForBlock(expressionTypingComponents, annotationChecker, scope);
|
||||
|
||||
if (isFirstStatement) {
|
||||
expressionTypingComponents.contractParsingServices.checkContractAndRecordIfPresent(statementExpression, context.trace, scope);
|
||||
DeclarationDescriptor ownerDescriptor = scope.getOwnerDescriptor();
|
||||
|
||||
if (isFirstStatement && ownerDescriptor instanceof FunctionDescriptor) {
|
||||
expressionTypingComponents.contractParsingServices.checkContractAndRecordIfPresent(
|
||||
statementExpression, context.trace, (FunctionDescriptor) ownerDescriptor
|
||||
);
|
||||
isFirstStatement = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user