Duplicating parameters removed
This commit is contained in:
@@ -75,7 +75,7 @@ public class ScriptBodyResolver {
|
|||||||
DataFlowInfo.EMPTY,
|
DataFlowInfo.EMPTY,
|
||||||
NO_EXPECTED_TYPE,
|
NO_EXPECTED_TYPE,
|
||||||
ExpressionPosition.FREE);
|
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) {
|
if (returnType == null) {
|
||||||
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -567,9 +567,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JetTypeInfo visitBlockExpression(JetBlockExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
public static JetTypeInfo visitBlockExpression(JetBlockExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
||||||
return context.expressionTypingServices.getBlockReturnedType(context.scope, expression, isStatement
|
return context.expressionTypingServices.getBlockReturnedType(expression, isStatement
|
||||||
? CoercionStrategy.COERCION_TO_UNIT
|
? CoercionStrategy.COERCION_TO_UNIT
|
||||||
: CoercionStrategy.NO_COERCION, context, context.trace);
|
: CoercionStrategy.NO_COERCION, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-3
@@ -288,8 +288,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return returnType;
|
return returnType;
|
||||||
}
|
}
|
||||||
ExpressionTypingContext newContext = context.replaceExpectedType(expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE)
|
ExpressionTypingContext newContext = context.replaceExpectedType(expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE)
|
||||||
.replaceBindingTrace(temporaryTrace);
|
.replaceBindingTrace(temporaryTrace).replaceScope(functionInnerScope);
|
||||||
return context.expressionTypingServices.getBlockReturnedType(functionInnerScope, bodyExpression, CoercionStrategy.COERCION_TO_UNIT,
|
return context.expressionTypingServices.getBlockReturnedType(bodyExpression, CoercionStrategy.COERCION_TO_UNIT, newContext).getType();
|
||||||
newContext, temporaryTrace).getType();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -171,7 +171,7 @@ public class ExpressionTypingServices {
|
|||||||
JetFunctionLiteral functionLiteral = (JetFunctionLiteral) function;
|
JetFunctionLiteral functionLiteral = (JetFunctionLiteral) function;
|
||||||
JetBlockExpression blockExpression = functionLiteral.getBodyExpression();
|
JetBlockExpression blockExpression = functionLiteral.getBodyExpression();
|
||||||
assert blockExpression != null;
|
assert blockExpression != null;
|
||||||
getBlockReturnedType(newContext.scope, blockExpression, CoercionStrategy.COERCION_TO_UNIT, context, trace);
|
getBlockReturnedType(blockExpression, CoercionStrategy.COERCION_TO_UNIT, context);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expressionTypingFacade.getTypeInfo(bodyExpression, newContext, !blockBody);
|
expressionTypingFacade.getTypeInfo(bodyExpression, newContext, !blockBody);
|
||||||
@@ -180,15 +180,13 @@ public class ExpressionTypingServices {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeInfo getBlockReturnedType(
|
public JetTypeInfo getBlockReturnedType(
|
||||||
@NotNull JetScope outerScope,
|
|
||||||
@NotNull JetBlockExpression expression,
|
@NotNull JetBlockExpression expression,
|
||||||
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
@NotNull CoercionStrategy coercionStrategyForLastExpression,
|
||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context
|
||||||
@NotNull BindingTrace trace
|
|
||||||
) {
|
) {
|
||||||
List<JetElement> block = expression.getStatements();
|
List<JetElement> block = expression.getStatements();
|
||||||
|
|
||||||
DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration();
|
DeclarationDescriptor containingDescriptor = context.scope.getContainingDeclaration();
|
||||||
if (containingDescriptor instanceof ScriptDescriptor) {
|
if (containingDescriptor instanceof ScriptDescriptor) {
|
||||||
if (!(expression.getParent() instanceof JetScript)) {
|
if (!(expression.getParent() instanceof JetScript)) {
|
||||||
// top level script declarations should have ScriptDescriptor parent
|
// top level script declarations should have ScriptDescriptor parent
|
||||||
@@ -197,7 +195,7 @@ public class ExpressionTypingServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WritableScope scope = new WritableScopeImpl(
|
WritableScope scope = new WritableScopeImpl(
|
||||||
outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
|
context.scope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
|
|
||||||
JetTypeInfo r;
|
JetTypeInfo r;
|
||||||
@@ -205,12 +203,12 @@ public class ExpressionTypingServices {
|
|||||||
r = DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, context, context.dataFlowInfo);
|
r = DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, context, context.dataFlowInfo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, trace);
|
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, context.trace);
|
||||||
}
|
}
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
|
|
||||||
if (containingDescriptor instanceof ScriptDescriptor) {
|
if (containingDescriptor instanceof ScriptDescriptor) {
|
||||||
trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope);
|
context.trace.record(BindingContext.SCRIPT_SCOPE, (ScriptDescriptor) containingDescriptor, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
Reference in New Issue
Block a user