use of org.jetbrains.kotlin.resolve.scopes.TraceBasedLocalRedeclarationChecker in project kotlin by JetBrains.
the class ExpressionTypingServices method getBlockReturnedType.
@NotNull
public KotlinTypeInfo getBlockReturnedType(@NotNull KtBlockExpression expression, @NotNull CoercionStrategy coercionStrategyForLastExpression, @NotNull ExpressionTypingContext context) {
List<KtExpression> block = StatementFilterKt.filterStatements(statementFilter, expression);
DeclarationDescriptor containingDescriptor = context.scope.getOwnerDescriptor();
TraceBasedLocalRedeclarationChecker redeclarationChecker = new TraceBasedLocalRedeclarationChecker(context.trace, expressionTypingComponents.overloadChecker);
LexicalWritableScope scope = new LexicalWritableScope(context.scope, containingDescriptor, false, redeclarationChecker, LexicalScopeKind.CODE_BLOCK);
KotlinTypeInfo r;
if (block.isEmpty()) {
r = expressionTypingComponents.dataFlowAnalyzer.createCheckedTypeInfo(expressionTypingComponents.builtIns.getUnitType(), context, expression);
} else {
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context.replaceStatementFilter(statementFilter));
}
scope.freeze();
if (containingDescriptor instanceof ScriptDescriptor) {
context.trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope);
}
return r;
}
Aggregations