is<TYPE>() made static in KotlinBuiltIns
This commit is contained in:
@@ -105,7 +105,7 @@ public class JetControlFlowProcessor {
|
||||
|
||||
JetType returnType = subroutineDescriptor.getReturnType();
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
if (returnType != null && builtIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
||||
if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
||||
|
||||
PseudoValue returnValue = builder.getBoundValue(bodyExpression);
|
||||
if (returnValue == null) return;
|
||||
|
||||
@@ -245,7 +245,7 @@ public class JetFlowInformationProvider {
|
||||
if (!(element instanceof JetExpression || element instanceof JetWhenCondition)) return;
|
||||
|
||||
if (blockBody && !noExpectedType(expectedReturnType)
|
||||
&& !KotlinBuiltIns.getInstance().isUnit(expectedReturnType)
|
||||
&& !KotlinBuiltIns.isUnit(expectedReturnType)
|
||||
&& !unreachableCode.getElements().contains(element)) {
|
||||
noReturnError[0] = true;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ public class JetFlowInformationProvider {
|
||||
if (operationReference != null) {
|
||||
DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference);
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(((FunctionDescriptor) descriptor).getReturnType())) {
|
||||
if (KotlinBuiltIns.isUnit(((FunctionDescriptor) descriptor).getReturnType())) {
|
||||
hasReassignMethodReturningUnit = true;
|
||||
}
|
||||
}
|
||||
@@ -444,7 +444,7 @@ public class JetFlowInformationProvider {
|
||||
trace.get(BindingContext.AMBIGUOUS_REFERENCE_TARGET, operationReference);
|
||||
if (descriptors != null) {
|
||||
for (DeclarationDescriptor referenceDescriptor : descriptors) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(((FunctionDescriptor) referenceDescriptor).getReturnType())) {
|
||||
if (KotlinBuiltIns.isUnit(((FunctionDescriptor) referenceDescriptor).getReturnType())) {
|
||||
hasReassignMethodReturningUnit = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class WhenChecker {
|
||||
|
||||
public static boolean mustHaveElse(@NotNull JetWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
JetType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
boolean isUnit = expectedType != null && KotlinBuiltIns.getInstance().isUnit(expectedType);
|
||||
boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType);
|
||||
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
||||
boolean isStatement = BindingContextUtilPackage.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
|
||||
|
||||
fun JetType.getSubtypesPredicate(): TypePredicate {
|
||||
return when {
|
||||
KotlinBuiltIns.getInstance().isAnyOrNullableAny(this) && isNullable() -> AllTypes
|
||||
KotlinBuiltIns.isAnyOrNullableAny(this) && isNullable() -> AllTypes
|
||||
TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
||||
else -> SingleType(this)
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class ArgumentTypeResolver {
|
||||
@NotNull JetType expectedType
|
||||
) {
|
||||
if (actualType == PLACEHOLDER_FUNCTION_TYPE) {
|
||||
return isFunctionOrErrorType(expectedType) || KotlinBuiltIns.getInstance().isAnyOrNullableAny(expectedType); //todo function type extends
|
||||
return isFunctionOrErrorType(expectedType) || KotlinBuiltIns.isAnyOrNullableAny(expectedType); //todo function type extends
|
||||
}
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType);
|
||||
}
|
||||
|
||||
+1
-1
@@ -302,7 +302,7 @@ public class CallExpressionResolver {
|
||||
|
||||
//TODO move further
|
||||
if (expression.getOperationSign() == JetTokens.SAFE_ACCESS) {
|
||||
if (selectorReturnType != null && !KotlinBuiltIns.getInstance().isUnit(selectorReturnType)) {
|
||||
if (selectorReturnType != null && !KotlinBuiltIns.isUnit(selectorReturnType)) {
|
||||
if (TypeUtils.isNullableType(receiverType)) {
|
||||
selectorReturnType = TypeUtils.makeNullable(selectorReturnType);
|
||||
}
|
||||
|
||||
+1
-1
@@ -744,7 +744,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType result;
|
||||
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
|
||||
assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor();
|
||||
if (KotlinBuiltIns.getInstance().isUnit(returnType)) {
|
||||
if (KotlinBuiltIns.isUnit(returnType)) {
|
||||
result = ErrorUtils.createErrorType(KotlinBuiltIns.getInstance().getUnit().getName().asString());
|
||||
context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign));
|
||||
}
|
||||
|
||||
+1
-1
@@ -265,7 +265,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType returnType = computeUnsafeReturnType(expression, context, functionDescriptor, expectedReturnType);
|
||||
|
||||
if (!expression.getFunctionLiteral().hasDeclaredReturnType() && functionTypeExpected) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(expectedReturnType)) {
|
||||
if (KotlinBuiltIns.isUnit(expectedReturnType)) {
|
||||
return KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -495,7 +495,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
.replaceContextDependency(INDEPENDENT));
|
||||
}
|
||||
else {
|
||||
if (expectedType != null && !noExpectedType(expectedType) && !KotlinBuiltIns.getInstance().isUnit(expectedType)) {
|
||||
if (expectedType != null && !noExpectedType(expectedType) && !KotlinBuiltIns.isUnit(expectedType)) {
|
||||
context.trace.report(RETURN_TYPE_MISMATCH.on(expression, expectedType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class DataFlowUtils {
|
||||
|
||||
@Nullable
|
||||
public static JetType checkStatementType(@NotNull JetExpression expression, @NotNull ResolutionContext context) {
|
||||
if (!noExpectedType(context.expectedType) && !KotlinBuiltIns.getInstance().isUnit(context.expectedType) && !context.expectedType.isError()) {
|
||||
if (!noExpectedType(context.expectedType) && !KotlinBuiltIns.isUnit(context.expectedType) && !context.expectedType.isError()) {
|
||||
context.trace.report(EXPECTED_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||
return null;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public class DataFlowUtils {
|
||||
@Nullable
|
||||
public static JetType checkImplicitCast(@Nullable JetType expressionType, @NotNull JetExpression expression, @NotNull ExpressionTypingContext context, boolean isStatement) {
|
||||
if (expressionType != null && context.expectedType == NO_EXPECTED_TYPE && context.contextDependency == INDEPENDENT && !isStatement
|
||||
&& (KotlinBuiltIns.getInstance().isUnit(expressionType) || KotlinBuiltIns.getInstance().isAnyOrNullableAny(expressionType))
|
||||
&& (KotlinBuiltIns.isUnit(expressionType) || KotlinBuiltIns.isAnyOrNullableAny(expressionType))
|
||||
&& !TypesPackage.isDynamic(expressionType)) {
|
||||
context.trace.report(IMPLICIT_CAST_TO_UNIT_OR_ANY.on(expression, expressionType));
|
||||
}
|
||||
|
||||
+2
-2
@@ -328,7 +328,7 @@ public class ExpressionTypingServices {
|
||||
if (!noExpectedType(context.expectedType) || context.expectedType == UNIT_EXPECTED_TYPE) {
|
||||
JetType expectedType;
|
||||
if (context.expectedType == UNIT_EXPECTED_TYPE ||//the first check is necessary to avoid invocation 'isUnit(UNIT_EXPECTED_TYPE)'
|
||||
(coercionStrategyForLastExpression == COERCION_TO_UNIT && KotlinBuiltIns.getInstance().isUnit(context.expectedType))) {
|
||||
(coercionStrategyForLastExpression == COERCION_TO_UNIT && KotlinBuiltIns.isUnit(context.expectedType))) {
|
||||
expectedType = UNIT_EXPECTED_TYPE;
|
||||
}
|
||||
else {
|
||||
@@ -353,7 +353,7 @@ public class ExpressionTypingServices {
|
||||
}
|
||||
if (mightBeUnit) {
|
||||
// ExpressionTypingVisitorForStatements should return only null or Unit for declarations and assignments
|
||||
assert result.getType() == null || KotlinBuiltIns.getInstance().isUnit(result.getType());
|
||||
assert result.getType() == null || KotlinBuiltIns.isUnit(result.getType());
|
||||
result = JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), context.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
@NotNull JetBinaryExpression expression,
|
||||
@NotNull ExpressionTypingContext context
|
||||
) {
|
||||
if (assignmentType != null && !KotlinBuiltIns.getInstance().isUnit(assignmentType) && !noExpectedType(context.expectedType) &&
|
||||
if (assignmentType != null && !KotlinBuiltIns.isUnit(assignmentType) && !noExpectedType(context.expectedType) &&
|
||||
TypeUtils.equalTypes(context.expectedType, assignmentType)) {
|
||||
context.trace.report(Errors.ASSIGNMENT_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user