Duplicating parameters removed

This commit is contained in:
Andrey Breslav
2013-08-20 16:02:10 +04:00
parent 2c1375f948
commit 3ead1cea37
4 changed files with 12 additions and 15 deletions
@@ -75,7 +75,7 @@ public class ScriptBodyResolver {
DataFlowInfo.EMPTY,
NO_EXPECTED_TYPE,
ExpressionPosition.FREE);
JetType returnType = expressionTypingServices.getBlockReturnedType(scope, declaration.getBlockExpression(), CoercionStrategy.NO_COERCION, context, trace).getType();
JetType returnType = expressionTypingServices.getBlockReturnedType(declaration.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType();
if (returnType == null) {
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
}
@@ -567,9 +567,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
}
public static JetTypeInfo visitBlockExpression(JetBlockExpression expression, ExpressionTypingContext context, boolean isStatement) {
return context.expressionTypingServices.getBlockReturnedType(context.scope, expression, isStatement
? CoercionStrategy.COERCION_TO_UNIT
: CoercionStrategy.NO_COERCION, context, context.trace);
return context.expressionTypingServices.getBlockReturnedType(expression, isStatement
? CoercionStrategy.COERCION_TO_UNIT
: CoercionStrategy.NO_COERCION, context);
}
@Override
@@ -288,8 +288,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
return returnType;
}
ExpressionTypingContext newContext = context.replaceExpectedType(expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE)
.replaceBindingTrace(temporaryTrace);
return context.expressionTypingServices.getBlockReturnedType(functionInnerScope, bodyExpression, CoercionStrategy.COERCION_TO_UNIT,
newContext, temporaryTrace).getType();
.replaceBindingTrace(temporaryTrace).replaceScope(functionInnerScope);
return context.expressionTypingServices.getBlockReturnedType(bodyExpression, CoercionStrategy.COERCION_TO_UNIT, newContext).getType();
}
}
@@ -171,7 +171,7 @@ public class ExpressionTypingServices {
JetFunctionLiteral functionLiteral = (JetFunctionLiteral) function;
JetBlockExpression blockExpression = functionLiteral.getBodyExpression();
assert blockExpression != null;
getBlockReturnedType(newContext.scope, blockExpression, CoercionStrategy.COERCION_TO_UNIT, context, trace);
getBlockReturnedType(blockExpression, CoercionStrategy.COERCION_TO_UNIT, context);
}
else {
expressionTypingFacade.getTypeInfo(bodyExpression, newContext, !blockBody);
@@ -180,15 +180,13 @@ public class ExpressionTypingServices {
@NotNull
public JetTypeInfo getBlockReturnedType(
@NotNull JetScope outerScope,
@NotNull JetBlockExpression expression,
@NotNull CoercionStrategy coercionStrategyForLastExpression,
@NotNull ExpressionTypingContext context,
@NotNull BindingTrace trace
@NotNull ExpressionTypingContext context
) {
List<JetElement> block = expression.getStatements();
DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration();
DeclarationDescriptor containingDescriptor = context.scope.getContainingDeclaration();
if (containingDescriptor instanceof ScriptDescriptor) {
if (!(expression.getParent() instanceof JetScript)) {
// top level script declarations should have ScriptDescriptor parent
@@ -197,7 +195,7 @@ public class ExpressionTypingServices {
}
}
WritableScope scope = new WritableScopeImpl(
outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
context.scope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
JetTypeInfo r;
@@ -205,12 +203,12 @@ public class ExpressionTypingServices {
r = DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, context, context.dataFlowInfo);
}
else {
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, trace);
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, context.trace);
}
scope.changeLockLevel(WritableScope.LockLevel.READING);
if (containingDescriptor instanceof ScriptDescriptor) {
trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope);
context.trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope);
}
return r;