is<TYPE>() made static in KotlinBuiltIns

This commit is contained in:
Andrey Breslav
2014-12-02 16:00:15 +03:00
parent 7a41e37655
commit db635c0e44
30 changed files with 60 additions and 53 deletions
@@ -319,7 +319,7 @@ public class ReplInterpreter {
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassType));
JetType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType();
return LineResult.successful(rv, returnType != null && KotlinBuiltIns.getInstance().isUnit(returnType));
return LineResult.successful(rv, returnType != null && KotlinBuiltIns.isUnit(returnType));
}
catch (Throwable e) {
@SuppressWarnings("UseOfSystemOutOrSystemErr")
@@ -91,7 +91,7 @@ public abstract class ElementAlternativeSignatureData {
@Nullable JetTypeReference altReturnTypeReference,
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
if (altReturnTypeReference == null) {
if (KotlinBuiltIns.getInstance().isUnit(originalType)) {
if (KotlinBuiltIns.isUnit(originalType)) {
return originalType;
}
else {
@@ -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)
}
@@ -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);
}
@@ -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);
}
@@ -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));
}
@@ -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();
}
}
@@ -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));
}
@@ -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);
}
}
@@ -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;
@@ -130,7 +130,7 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
if (name in setOf("equals", "hashCode", "toString")) return
val returnType = callable.getReturnType()!!
if (!KotlinBuiltIns.getInstance().isUnit(returnType)) {
if (!KotlinBuiltIns.isUnit(returnType)) {
checkDescriptor(returnType.getConstructor().getDeclarationDescriptor()!!, callable)
}
@@ -145,7 +145,7 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
private fun checkSupertypes(classDescriptor: ClassDescriptor) {
classDescriptor.getDefaultType().getConstructor().getSupertypes().filter {
!KotlinBuiltIns.getInstance().isAnyOrNullableAny(it)
!KotlinBuiltIns.isAnyOrNullableAny(it)
}.map {
it.getConstructor().getDeclarationDescriptor()!!
}.forEach {
@@ -118,7 +118,7 @@ class LazyJavaClassDescriptor(
supertype ->
c.typeResolver.transformJavaType(supertype, TypeUsage.SUPERTYPE.toAttributes())
}
.filter { supertype -> !supertype.isError() && !KotlinBuiltIns.getInstance().isAnyOrNullableAny(supertype) }
.filter { supertype -> !supertype.isError() && !KotlinBuiltIns.isAnyOrNullableAny(supertype) }
.toList()
.ifEmpty {
listOf(KotlinBuiltIns.getInstance().getAnyType())
@@ -153,6 +153,8 @@ public class KotlinBuiltIns {
public final FqNameUnsafe nothing = fqName("Nothing");
public final FqNameUnsafe cloneable = fqName("Cloneable");
public final FqNameUnsafe suppress = fqName("suppress");
public final FqNameUnsafe unit = fqName("Unit");
public final FqNameUnsafe string = fqName("String");
public final Set<FqNameUnsafe> functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT);
public final Set<FqNameUnsafe> extensionFunctionClasses = computeIndexedFqNames("ExtensionFunction", FUNCTION_TRAIT_COUNT);
@@ -826,6 +828,15 @@ public class KotlinBuiltIns {
// Recognized & special
private static boolean isConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
return descriptor != null && fqName.equals(DescriptorUtils.getFqName(descriptor));
}
private static boolean isNotNullConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
return !type.isNullable() && isConstructedFromGivenClass(type, fqName);
}
public static boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) {
FqNameUnsafe fqName = DescriptorUtils.getFqName(descriptor);
return FQ_NAMES.any.equals(fqName) || FQ_NAMES.nothing.equals(fqName);
@@ -846,20 +857,19 @@ public class KotlinBuiltIns {
}
public static boolean isNothingOrNullableNothing(@NotNull JetType type) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
return descriptor != null && FQ_NAMES.nothing.equals(DescriptorUtils.getFqName(descriptor));
return isConstructedFromGivenClass(type, FQ_NAMES.nothing);
}
public boolean isAnyOrNullableAny(@NotNull JetType type) {
return type.getConstructor() == getAny().getTypeConstructor();
public static boolean isAnyOrNullableAny(@NotNull JetType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.any);
}
public boolean isUnit(@NotNull JetType type) {
return type.equals(getUnitType());
public static boolean isUnit(@NotNull JetType type) {
return isNotNullConstructedFromGivenClass(type, FQ_NAMES.unit);
}
public boolean isString(@Nullable JetType type) {
return getStringType().equals(type);
public static boolean isString(@Nullable JetType type) {
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string);
}
public static boolean isCloneable(@NotNull ClassDescriptor descriptor) {
@@ -879,8 +889,7 @@ public class KotlinBuiltIns {
}
public static boolean isSuppressAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) {
ClassifierDescriptor classifier = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor();
return classifier != null && FQ_NAMES.suppress.equals(DescriptorUtils.getFqName(classifier));
return isConstructedFromGivenClass(annotationDescriptor.getType(), FQ_NAMES.suppress);
}
static boolean containsAnnotation(DeclarationDescriptor descriptor, ClassDescriptor annotationClass) {
@@ -754,7 +754,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
renderReceiverAfterName(function, builder);
JetType returnType = function.getReturnType();
if (unitReturnType || (returnType == null || !KotlinBuiltIns.getInstance().isUnit(returnType))) {
if (unitReturnType || (returnType == null || !KotlinBuiltIns.isUnit(returnType))) {
builder.append(": ").append(returnType == null ? "[NULL]" : escape(renderType(returnType)));
}
@@ -964,7 +964,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
Collection<JetType> supertypes = klass.getTypeConstructor().getSupertypes();
if (supertypes.isEmpty() ||
supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAnyOrNullableAny(supertypes.iterator().next())) {
supertypes.size() == 1 && KotlinBuiltIns.isAnyOrNullableAny(supertypes.iterator().next())) {
}
else {
renderSpaceIfNeeded(builder);
@@ -35,8 +35,8 @@ fun JetType.makeNotNullable() = TypeUtils.makeNotNullable(this)
fun JetType.supertypes(): Set<JetType> = TypeUtils.getAllSupertypes(this)
fun JetType.isUnit(): Boolean = KotlinBuiltIns.getInstance().isUnit(this)
fun JetType.isAny(): Boolean = KotlinBuiltIns.getInstance().isAnyOrNullableAny(this)
fun JetType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this)
fun JetType.isAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this)
public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true): JetType {
if (jetType.isDynamic()) return jetType
@@ -43,7 +43,6 @@ import org.jetbrains.jet.plugin.JetBundle;
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil;
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import javax.swing.*;
import java.util.ArrayList;
@@ -98,7 +97,7 @@ public class JetAddFunctionToClassifierAction implements QuestionAction {
if (typeDescriptor.getKind() != ClassKind.TRAIT && functionDescriptor.getModality() != Modality.ABSTRACT) {
functionBody = "{}";
JetType returnType = functionDescriptor.getReturnType();
if (returnType == null || !KotlinBuiltIns.getInstance().isUnit(returnType)) {
if (returnType == null || !KotlinBuiltIns.isUnit(returnType)) {
functionBody = "{ throw UnsupportedOperationException() }";
}
}
@@ -43,7 +43,7 @@ public class ConvertToBlockBodyAction : PsiElementBaseIntentionAction() {
fun generateBody(returnsValue: Boolean): JetExpression {
val bodyType = expressionType(body)
val needReturn = returnsValue &&
(bodyType == null || (!KotlinBuiltIns.getInstance().isUnit(bodyType) && !KotlinBuiltIns.isNothing(bodyType)))
(bodyType == null || (!KotlinBuiltIns.isUnit(bodyType) && !KotlinBuiltIns.isNothing(bodyType)))
val oldBodyText = body.getText()!!
val newBodyText = if (needReturn) "return ${oldBodyText}" else oldBodyText
@@ -53,11 +53,11 @@ public class ConvertToBlockBodyAction : PsiElementBaseIntentionAction() {
val newBody = when (declaration) {
is JetNamedFunction -> {
val returnType = functionReturnType(declaration)!!
if (!declaration.hasDeclaredReturnType() && !KotlinBuiltIns.getInstance().isUnit(returnType)) {
if (!declaration.hasDeclaredReturnType() && !KotlinBuiltIns.isUnit(returnType)) {
specifyTypeExplicitly(declaration, returnType)
}
val newBody = generateBody(!KotlinBuiltIns.getInstance().isUnit(returnType) && !KotlinBuiltIns.isNothing(returnType))
val newBody = generateBody(!KotlinBuiltIns.isUnit(returnType) && !KotlinBuiltIns.isNothing(returnType))
declaration.getEqualsToken()!!.delete()
body.replace(newBody)
@@ -65,6 +65,6 @@ public class ConvertToConcatenatedStringIntention : JetSelfTargetingIntention<Je
val context = this.analyze()
val elementType = BindingContextUtils.getRecordedTypeInfo(this, context)?.getType()
return KotlinBuiltIns.getInstance().isString(elementType)
return KotlinBuiltIns.isString(elementType)
}
}
@@ -43,7 +43,7 @@ public class ConvertToExpressionBodyAction : PsiElementBaseIntentionAction() {
if (!declaration.hasDeclaredReturnType() && declaration is JetNamedFunction) {
val valueType = expressionType(value)
if (valueType == null || !KotlinBuiltIns.getInstance().isUnit(valueType)) {
if (valueType == null || !KotlinBuiltIns.isUnit(valueType)) {
specifyTypeExplicitly(declaration, "Unit")
}
}
@@ -93,7 +93,7 @@ public class ConvertToExpressionBodyAction : PsiElementBaseIntentionAction() {
val expressionType = expressionType(statement)
if (expressionType != null &&
(KotlinBuiltIns.getInstance().isUnit(expressionType) || KotlinBuiltIns.isNothing(expressionType)))
(KotlinBuiltIns.isUnit(expressionType) || KotlinBuiltIns.isNothing(expressionType)))
Data(declaration, statement)
else
null
@@ -41,7 +41,7 @@ public class ConvertToStringTemplateIntention : JetSelfTargetingIntention<JetBin
val context = element.analyze()
val elementType = BindingContextUtils.getRecordedTypeInfo(element, context)?.getType()
if (!(KotlinBuiltIns.getInstance().isString(elementType))) return false
if (!(KotlinBuiltIns.isString(elementType))) return false
val (left, right) = Pair(element.getLeft(), element.getRight())
if (left == null || right == null) return false
@@ -60,7 +60,7 @@ public class AddFunctionToSupertypeFix extends JetHintAction<JetNamedFunction> {
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
// TODO: filter out impossible supertypes (for example when argument's type isn't visible in a superclass).
for (ClassDescriptor supertypeDescriptor : getSupertypes(classDescriptor)) {
if (KotlinBuiltIns.getInstance().isAnyOrNullableAny(supertypeDescriptor.getDefaultType())) continue;
if (KotlinBuiltIns.isAnyOrNullableAny(supertypeDescriptor.getDefaultType())) continue;
functions.add(generateFunctionSignatureForType(functionDescriptor, supertypeDescriptor));
}
return functions;
@@ -79,7 +79,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
FqName fqName = element.getFqName();
if (fqName != null) functionName = fqName.asString();
if (KotlinBuiltIns.getInstance().isUnit(type) && element.hasBlockBody()) {
if (KotlinBuiltIns.isUnit(type) && element.hasBlockBody()) {
return functionName == null ?
JetBundle.message("remove.no.name.function.return.type") :
JetBundle.message("remove.function.return.type", functionName);
@@ -107,7 +107,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
changeFunctionLiteralReturnTypeFix.invoke(project, editor, file);
}
else {
if (!(KotlinBuiltIns.getInstance().isUnit(type) && element.hasBlockBody())) {
if (!(KotlinBuiltIns.isUnit(type) && element.hasBlockBody())) {
element.setTypeReference(JetPsiFactory(project).createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)));
}
else {
@@ -427,7 +427,7 @@ public class JetRefactoringUtil {
JetExpression expression = (JetExpression)element;
BindingContext bindingContext = ResolvePackage.analyze(expression);
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
if (expressionType == null || !KotlinBuiltIns.getInstance().isUnit(expressionType)) {
if (expressionType == null || !KotlinBuiltIns.isUnit(expressionType)) {
expressions.add(expression);
}
}
@@ -111,7 +111,7 @@ public class JetChangeInfo implements ChangeInfo {
buffer.append(getNewParametersSignature(inheritedFunction, isInherited, buffer.length()));
if (newReturnType != null && !KotlinBuiltIns.getInstance().isUnit(newReturnType) && !isConstructor())
if (newReturnType != null && !KotlinBuiltIns.isUnit(newReturnType) && !isConstructor())
buffer.append(": ").append(newReturnTypeText);
return buffer.toString();
@@ -67,7 +67,6 @@ import org.jetbrains.jet.plugin.refactoring.getContextForContainingDeclarationBo
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
import org.jetbrains.jet.plugin.caches.resolve.findModuleDescriptor
import org.jetbrains.jet.plugin.caches.resolve.analyze
import org.jetbrains.jet.lang.psi.psiUtil.getParentOfType
import org.jetbrains.jet.lang.psi.psiUtil.getStrictParentOfType
import org.jetbrains.jet.plugin.refactoring.comparePossiblyOverridingDescriptors
@@ -84,7 +83,7 @@ private fun JetType.renderForMessage(): String =
private fun JetDeclaration.renderForMessage(bindingContext: BindingContext): String? =
bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this]?.renderForMessage()
private fun JetType.isDefault(): Boolean = KotlinBuiltIns.getInstance().isUnit(this)
private fun JetType.isDefault(): Boolean = KotlinBuiltIns.isUnit(this)
private fun List<Instruction>.getModifiedVarDescriptors(bindingContext: BindingContext): Map<VariableDescriptor, List<JetExpression>> {
val result = HashMap<VariableDescriptor, MutableList<JetExpression>>()
@@ -159,7 +158,7 @@ private fun List<AbstractJumpInstruction>.checkEquivalence(checkPsi: Boolean): B
}
private fun JetType.isMeaningful(): Boolean {
return KotlinBuiltIns.getInstance().let { builtins -> !builtins.isUnit(this) && !KotlinBuiltIns.isNothing(this) }
return !KotlinBuiltIns.isUnit(this) && !KotlinBuiltIns.isNothing(this)
}
private fun ExtractionData.getLocalDeclarationsWithNonLocalUsages(
@@ -100,7 +100,7 @@ public final class FunctionBodyTranslator extends AbstractTranslator {
private boolean mustAddReturnToGeneratedFunctionBody() {
JetType functionReturnType = descriptor.getReturnType();
assert functionReturnType != null : "Function return typed type must be resolved.";
return (!declaration.hasBlockBody()) && (!KotlinBuiltIns.getInstance().isUnit(functionReturnType));
return (!declaration.hasBlockBody()) && (!KotlinBuiltIns.isUnit(functionReturnType));
}
@NotNull