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