Minor refactoring: removed unnecessary parameter,
inlined method
This commit is contained in:
+7
-5
@@ -164,7 +164,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
ExpressionTypingContext newContext = context.replaceDataFlowInfo(presentInfo).replaceExpectedType(NO_EXPECTED_TYPE)
|
||||
.replaceContextDependency(INDEPENDENT);
|
||||
JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||
presentScope, Collections.singletonList(presentBranch), CoercionStrategy.NO_COERCION, newContext, context.trace);
|
||||
presentScope, Collections.singletonList(presentBranch), CoercionStrategy.NO_COERCION, newContext);
|
||||
JetType type = typeInfo.getType();
|
||||
DataFlowInfo dataFlowInfo;
|
||||
if (type != null && KotlinBuiltIns.isNothing(type)) {
|
||||
@@ -195,7 +195,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
DataFlowInfo conditionInfo = DataFlowUtils.extractDataFlowInfoFromCondition(condition, true, context).and(dataFlowInfo);
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||
scopeToExtend, Collections.singletonList(body),
|
||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(conditionInfo), context.trace);
|
||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(conditionInfo));
|
||||
}
|
||||
|
||||
if (!containsJumpOutOfLoop(expression, context)) {
|
||||
@@ -260,7 +260,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (!functionLiteral.hasParameterSpecification()) {
|
||||
WritableScope writableScope = newWritableScopeImpl(context, "do..while body scope");
|
||||
conditionScope = writableScope;
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(writableScope, functionLiteral.getBodyExpression().getStatements(), CoercionStrategy.NO_COERCION, context, context.trace);
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||
writableScope, functionLiteral.getBodyExpression().getStatements(), CoercionStrategy.NO_COERCION, context);
|
||||
context.trace.record(BindingContext.BLOCK, function);
|
||||
}
|
||||
else {
|
||||
@@ -277,7 +278,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
block = Collections.<JetElement>singletonList(body);
|
||||
}
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(writableScope, block, CoercionStrategy.NO_COERCION, context, context.trace);
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||
writableScope, block, CoercionStrategy.NO_COERCION, context);
|
||||
}
|
||||
JetExpression condition = expression.getCondition();
|
||||
DataFlowInfo conditionDataFlowInfo = checkCondition(conditionScope, condition, context);
|
||||
@@ -333,7 +335,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetExpression body = expression.getBody();
|
||||
if (body != null) {
|
||||
components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(loopScope, Collections.singletonList(body),
|
||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(dataFlowInfo), context.trace);
|
||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(dataFlowInfo));
|
||||
}
|
||||
|
||||
return DataFlowUtils.checkType(components.builtIns.getUnitType(), expression, contextWithExpectedType, dataFlowInfo);
|
||||
|
||||
+3
-10
@@ -235,7 +235,7 @@ public class ExpressionTypingServices {
|
||||
r = DataFlowUtils.checkType(builtIns.getUnitType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
else {
|
||||
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, context.trace);
|
||||
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context);
|
||||
}
|
||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
|
||||
@@ -276,15 +276,14 @@ public class ExpressionTypingServices {
|
||||
@NotNull WritableScope scope,
|
||||
@NotNull List<? extends JetElement> block,
|
||||
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull BindingTrace trace
|
||||
@NotNull ExpressionTypingContext context
|
||||
) {
|
||||
if (block.isEmpty()) {
|
||||
return JetTypeInfo.create(builtIns.getUnitType(), context.dataFlowInfo);
|
||||
}
|
||||
|
||||
ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(expressionTypingComponents, scope);
|
||||
ExpressionTypingContext newContext = createContext(context, trace, scope, context.dataFlowInfo, NO_EXPECTED_TYPE);
|
||||
ExpressionTypingContext newContext = context.replaceScope(scope).replaceExpectedType(NO_EXPECTED_TYPE);
|
||||
|
||||
JetTypeInfo result = JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) {
|
||||
@@ -352,12 +351,6 @@ public class ExpressionTypingServices {
|
||||
return result;
|
||||
}
|
||||
|
||||
private ExpressionTypingContext createContext(ExpressionTypingContext oldContext, BindingTrace trace, WritableScope scope, DataFlowInfo dataFlowInfo, JetType expectedType) {
|
||||
return ExpressionTypingContext.newContext(
|
||||
trace, scope, dataFlowInfo, expectedType, oldContext.contextDependency, oldContext.resolutionResultsCache,
|
||||
oldContext.callChecker, oldContext.isAnnotationContext);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetExpression deparenthesizeWithTypeResolution(
|
||||
@Nullable JetExpression expression,
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
.replaceScope(scopeToExtend).replaceDataFlowInfo(infosForCondition.thenInfo).replaceContextDependency(INDEPENDENT);
|
||||
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
||||
JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||
scopeToExtend, Collections.singletonList(bodyExpression), coercionStrategy, newContext, context.trace);
|
||||
scopeToExtend, Collections.singletonList(bodyExpression), coercionStrategy, newContext);
|
||||
JetType type = typeInfo.getType();
|
||||
if (type != null) {
|
||||
expressionTypes.add(type);
|
||||
|
||||
Reference in New Issue
Block a user