From 8c6dd95e3fb9aee036a4877a83463a79720044f2 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 20 May 2016 18:06:37 +0300 Subject: [PATCH] Introduce SimpleType. --- .../resolve/functionTypeResolveUtils.kt | 3 ++- .../lazy/descriptors/LazyClassDescriptor.java | 7 ++--- .../kotlin/builtins/KotlinBuiltIns.java | 20 +++++++------- .../kotlin/descriptors/ClassDescriptor.java | 6 ++--- .../descriptors/ClassifierDescriptor.java | 6 ++--- .../impl/AbstractClassDescriptor.java | 14 +++++----- .../impl/AbstractTypeAliasDescriptor.kt | 4 +-- .../impl/AbstractTypeParameterDescriptor.java | 10 +++---- .../impl/LazySubstitutingClassDescriptor.java | 4 +-- .../types/AbstractClassTypeConstructor.java | 4 +-- .../kotlin/types/AbstractKotlinType.java | 4 +-- .../kotlin/types/AbstractLazyType.kt | 2 +- .../kotlin/types/DelegatingType.java | 2 +- .../jetbrains/kotlin/types/ErrorUtils.java | 10 +++---- .../org/jetbrains/kotlin/types/KotlinType.kt | 6 +++++ .../jetbrains/kotlin/types/KotlinTypeImpl.kt | 2 +- .../org/jetbrains/kotlin/types/TypeUtils.java | 27 ++++++++++++++----- .../evaluate/GenerateOperationsMap.kt | 4 +-- 18 files changed, 78 insertions(+), 57 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/functionTypeResolveUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/functionTypeResolveUtils.kt index 4b1b0f6d3fc..c4c23aca888 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/functionTypeResolveUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/functionTypeResolveUtils.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinTypeImpl +import org.jetbrains.kotlin.types.SimpleType import org.jetbrains.kotlin.types.TypeProjection internal fun createValueParametersForInvokeInFunctionType( @@ -54,7 +55,7 @@ fun createFunctionType( receiverType: KotlinType?, parameterTypes: List, returnType: KotlinType -): KotlinType { +): SimpleType { val arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType) val size = parameterTypes.size val classDescriptor = builtIns.getFunction(if (receiverType == null) size else size + 1) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 24f8337e4f6..55ba381622f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -54,10 +54,7 @@ import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull; import org.jetbrains.kotlin.storage.NotNullLazyValue; import org.jetbrains.kotlin.storage.NullableLazyValue; import org.jetbrains.kotlin.storage.StorageManager; -import org.jetbrains.kotlin.types.AbstractClassTypeConstructor; -import org.jetbrains.kotlin.types.KotlinType; -import org.jetbrains.kotlin.types.TypeConstructor; -import org.jetbrains.kotlin.types.TypeUtils; +import org.jetbrains.kotlin.types.*; import java.util.ArrayList; import java.util.Collection; @@ -693,7 +690,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject(); if (classOrObject == null) { - return Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType()); + return Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType()); } List allSupertypes = diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index f0dc11cdd15..081f291cf27 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -606,22 +606,22 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getNothingType() { + public SimpleType getNothingType() { return getNothing().getDefaultType(); } @NotNull - public KotlinType getNullableNothingType() { + public SimpleType getNullableNothingType() { return TypeUtils.makeNullable(getNothingType()); } @NotNull - public KotlinType getAnyType() { + public SimpleType getAnyType() { return getAny().getDefaultType(); } @NotNull - public KotlinType getNullableAnyType() { + public SimpleType getNullableAnyType() { return TypeUtils.makeNullable(getAnyType()); } @@ -631,7 +631,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getPrimitiveKotlinType(@NotNull PrimitiveType type) { + public SimpleType getPrimitiveKotlinType(@NotNull PrimitiveType type) { return getPrimitiveClassDescriptor(type).getDefaultType(); } @@ -676,7 +676,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getUnitType() { + public SimpleType getUnitType() { return getUnit().getDefaultType(); } @@ -728,7 +728,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) { + public SimpleType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) { List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), @@ -739,7 +739,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getEnumType(@NotNull KotlinType argument) { + public SimpleType getEnumType(@NotNull SimpleType argument) { Variance projectionType = Variance.INVARIANT; List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); return KotlinTypeImpl.create( @@ -751,7 +751,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KotlinType getAnnotationType() { + public SimpleType getAnnotationType() { return getAnnotation().getDefaultType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java index 101af1b3661..5c19000f665 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.resolve.scopes.MemberScope; -import org.jetbrains.kotlin.types.KotlinType; +import org.jetbrains.kotlin.types.SimpleType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeSubstitution; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -57,7 +57,7 @@ public interface ClassDescriptor extends ClassifierDescriptorWithTypeParameters, */ @NotNull @Override - KotlinType getDefaultType(); + SimpleType getDefaultType(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java index 088dc00609a..f8dbfd7451c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KotlinType; +import org.jetbrains.kotlin.types.SimpleType; import org.jetbrains.kotlin.types.TypeConstructor; public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot { @@ -25,5 +25,5 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot { TypeConstructor getTypeConstructor(); @NotNull - KotlinType getDefaultType(); + SimpleType getDefaultType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java index 1826bcbcf55..59d62742da0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package org.jetbrains.kotlin.descriptors.impl; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.descriptors.*; +import org.jetbrains.kotlin.descriptors.ClassDescriptor; +import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor; +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper; import org.jetbrains.kotlin.resolve.scopes.MemberScope; @@ -31,15 +33,15 @@ import java.util.List; public abstract class AbstractClassDescriptor implements ClassDescriptor { private final Name name; - protected final NotNullLazyValue defaultType; + protected final NotNullLazyValue defaultType; private final NotNullLazyValue unsubstitutedInnerClassesScope; private final NotNullLazyValue thisAsReceiverParameter; public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name) { this.name = name; - this.defaultType = storageManager.createLazyValue(new Function0() { + this.defaultType = storageManager.createLazyValue(new Function0() { @Override - public KotlinType invoke() { + public SimpleType invoke() { return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getUnsubstitutedMemberScope()); } }); @@ -113,7 +115,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { @NotNull @Override - public KotlinType getDefaultType() { + public SimpleType getDefaultType() { return defaultType.invoke(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeAliasDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeAliasDescriptor.kt index 98153c39dee..f6c170ad346 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeAliasDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeAliasDescriptor.kt @@ -22,8 +22,8 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.SimpleType import org.jetbrains.kotlin.types.TypeConstructor -import org.jetbrains.kotlin.types.TypeSubstitutor abstract class AbstractTypeAliasDescriptor( containingDeclaration: DeclarationDescriptor, @@ -57,7 +57,7 @@ abstract class AbstractTypeAliasDescriptor( override fun getVisibility() = visibilityImpl - override fun getDefaultType(): KotlinType = + override fun getDefaultType(): SimpleType = TODO("typealias getDefaultType") override fun getTypeConstructor(): TypeConstructor = diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java index d5a1221db98..f44ab370d0d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip private final int index; private final NotNullLazyValue typeConstructor; - private final NotNullLazyValue defaultType; + private final NotNullLazyValue defaultType; protected AbstractTypeParameterDescriptor( @NotNull final StorageManager storageManager, @@ -65,9 +65,9 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip return new TypeParameterTypeConstructor(storageManager, supertypeLoopChecker); } }); - this.defaultType = storageManager.createLazyValue(new Function0() { + this.defaultType = storageManager.createLazyValue(new Function0() { @Override - public KotlinType invoke() { + public SimpleType invoke() { return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.emptyList(), @@ -124,7 +124,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip @NotNull @Override - public KotlinType getDefaultType() { + public SimpleType getDefaultType() { return defaultType.invoke(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index dd09ba71399..d36147516f4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public KotlinType getDefaultType() { + public SimpleType getDefaultType() { List typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters()); return KotlinTypeImpl.create( getAnnotations(), diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java index e67b65e247f..3fb1052487c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct // class B : A.C {} DeclarationDescriptor containingDeclaration = getDeclarationDescriptor().getContainingDeclaration(); if (containingDeclaration instanceof ClassDescriptor) { - return Collections.singleton(((ClassDescriptor) containingDeclaration).getDefaultType()); + return Collections.singleton(((ClassDescriptor) containingDeclaration).getDefaultType()); } return Collections.emptyList(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java index 788a50e4c5a..8b44ec9d0a0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.Iterator; import java.util.List; -public abstract class AbstractKotlinType implements KotlinType { +public abstract class AbstractKotlinType implements KotlinType, SimpleType { // TODO temporary upper bound @Nullable @Override public T getCapability(@NotNull Class capabilityClass) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt index 770ca094541..845a39923ca 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.getValue -abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType { +abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), SimpleType, LazyType { private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() } override val constructor by typeConstructor diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java b/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java index bba8a3fcb63..ee61878675f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.List; -public abstract class DelegatingType implements KotlinType { +public abstract class DelegatingType implements KotlinType, SimpleType { // TODO temporary upper bound protected abstract KotlinType getDelegate(); @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 9975166935e..0c8e18ced95 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -374,22 +374,22 @@ public class ErrorUtils { } @NotNull - public static KotlinType createErrorType(@NotNull String debugMessage) { + public static SimpleType createErrorType(@NotNull String debugMessage) { return createErrorTypeWithArguments(debugMessage, Collections.emptyList()); } @NotNull - public static KotlinType createErrorTypeWithCustomDebugName(@NotNull String debugName) { + public static SimpleType createErrorTypeWithCustomDebugName(@NotNull String debugName) { return createErrorTypeWithCustomConstructor(debugName, createErrorTypeConstructorWithCustomDebugName(debugName)); } @NotNull - public static KotlinType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) { + public static SimpleType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) { return new ErrorTypeImpl(typeConstructor, createErrorScope(debugName)); } @NotNull - public static KotlinType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List arguments) { + public static SimpleType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List arguments) { return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments); } @@ -484,7 +484,7 @@ public class ErrorUtils { ); } - private static class ErrorTypeImpl implements KotlinType { + private static class ErrorTypeImpl implements SimpleType { private final TypeConstructor constructor; private final MemberScope memberScope; private final List arguments; diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt index c03e57d2631..d77ae2efa40 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt @@ -39,4 +39,10 @@ interface KotlinType : Annotated { fun getCapability(capabilityClass: Class): T? val capabilities: TypeCapabilities + } + +@Deprecated("Temporary marker method for refactoring") +fun KotlinType.asSimpleType(): SimpleType = this as SimpleType + +interface SimpleType : KotlinType \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt index 83e638e7322..62fe30fd9b1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt @@ -27,7 +27,7 @@ private constructor( override val isMarkedNullable: Boolean, override val arguments: List, final override val memberScope: MemberScope -) : AbstractKotlinType() { +) : AbstractKotlinType(), SimpleType { companion object { @JvmStatic fun create(annotations: Annotations, diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index 4360ec3c626..9eee0a3f2c9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -33,10 +33,10 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.*; public class TypeUtils { - public static final KotlinType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE"); - public static final KotlinType CANT_INFER_FUNCTION_PARAM_TYPE = ErrorUtils.createErrorType("Cannot be inferred"); + public static final SimpleType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE"); + public static final SimpleType CANT_INFER_FUNCTION_PARAM_TYPE = ErrorUtils.createErrorType("Cannot be inferred"); - public static class SpecialType implements KotlinType { + public static class SpecialType implements SimpleType { private final String name; public SpecialType(String name) { @@ -96,9 +96,9 @@ public class TypeUtils { } @NotNull - public static final KotlinType NO_EXPECTED_TYPE = new SpecialType("NO_EXPECTED_TYPE"); + public static final SimpleType NO_EXPECTED_TYPE = new SpecialType("NO_EXPECTED_TYPE"); - public static final KotlinType UNIT_EXPECTED_TYPE = new SpecialType("UNIT_EXPECTED_TYPE"); + public static final SimpleType UNIT_EXPECTED_TYPE = new SpecialType("UNIT_EXPECTED_TYPE"); public static boolean noExpectedType(@NotNull KotlinType type) { return type == NO_EXPECTED_TYPE || type == UNIT_EXPECTED_TYPE; @@ -118,6 +118,21 @@ public class TypeUtils { return makeNullableAsSpecified(type, false); } + @NotNull + public static SimpleType makeNullable(@NotNull SimpleType type) { + return KotlinTypeKt.asSimpleType(makeNullableAsSpecified(type, true)); + } + + @NotNull + public static SimpleType makeNotNullable(@NotNull SimpleType type) { + return KotlinTypeKt.asSimpleType(makeNullableAsSpecified(type, false)); + } + + @NotNull + public static SimpleType makeNullableAsSpecified(@NotNull SimpleType type, boolean nullable) { + return KotlinTypeKt.asSimpleType(makeNullableAsSpecified((KotlinType) type, nullable)); + } + @NotNull public static KotlinType makeNullableAsSpecified(@NotNull KotlinType type, boolean nullable) { Flexibility flexibility = type.getCapability(Flexibility.class); @@ -229,7 +244,7 @@ public class TypeUtils { } @NotNull - public static KotlinType makeUnsubstitutedType(ClassifierDescriptor classifierDescriptor, MemberScope unsubstitutedMemberScope) { + public static SimpleType makeUnsubstitutedType(ClassifierDescriptor classifierDescriptor, MemberScope unsubstitutedMemberScope) { if (ErrorUtils.isError(classifierDescriptor)) { return ErrorUtils.createErrorType("Unsubstituted type for " + classifierDescriptor); } diff --git a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt index 2780ab0bc0b..b96b0d34280 100644 --- a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt +++ b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,7 +161,7 @@ private fun KotlinType.isIntegerType(): Boolean { private fun CallableDescriptor.getParametersTypes(): List { - val list = arrayListOf((containingDeclaration as ClassDescriptor).defaultType) + val list = arrayListOf((containingDeclaration as ClassDescriptor).defaultType) valueParameters.map { it.type }.forEach { list.add(TypeUtils.makeNotNullable(it)) }