Move static constants with builtin names to :core:descriptors.common module

This commit is contained in:
Dmitriy Novozhilov
2020-08-16 22:57:12 +03:00
parent 2e92fe9be9
commit 7a7fe77b8e
180 changed files with 1085 additions and 1025 deletions
@@ -62,6 +62,8 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.*; import java.util.*;
import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.ENUM_VALUES;
import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.ENUM_VALUE_OF;
import static org.jetbrains.kotlin.codegen.AsmUtil.*; import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isGenericToArray; import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isGenericToArray;
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isNonGenericToArray; import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isNonGenericToArray;
@@ -12,6 +12,7 @@ import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor; import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure; import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.context.CodegenContext; import org.jetbrains.kotlin.codegen.context.CodegenContext;
@@ -404,7 +405,7 @@ public class JvmCodegenUtil {
// The Result class is the only inline class in the standard library without special rules for equality. // The Result class is the only inline class in the standard library without special rules for equality.
// We only call Result.equals-impl0 if we are compiling for Kotlin 1.4 or later. Otherwise, the code // We only call Result.equals-impl0 if we are compiling for Kotlin 1.4 or later. Otherwise, the code
// might well be running against an older version of the standard library. // might well be running against an older version of the standard library.
if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(DescriptorUtils.RESULT_FQ_NAME)) { if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(KotlinBuiltInsNames.RESULT_FQ_NAME)) {
return state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_4) >= 0; return state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_4) >= 0;
} else { } else {
return ((DeserializedClassDescriptor) descriptor).getMetadataVersion().isAtLeast(1, 1, 16); return ((DeserializedClassDescriptor) descriptor).getMetadataVersion().isAtLeast(1, 1, 16);
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.codegen.coroutines
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalClassDescriptor import org.jetbrains.kotlin.builtins.isBuiltinFunctionalClassDescriptor
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.binding.CodegenBinding import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
@@ -312,7 +312,7 @@ private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isR
fun ModuleDescriptor.getResult(kotlinType: KotlinType) = fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
module.resolveTopLevelClass( module.resolveTopLevelClass(
DescriptorUtils.RESULT_FQ_NAME, KotlinBuiltInsNames.RESULT_FQ_NAME,
NoLookupLocation.FROM_BACKEND NoLookupLocation.FROM_BACKEND
)?.defaultType?.let { )?.defaultType?.let {
KotlinTypeFactory.simpleType( KotlinTypeFactory.simpleType(
@@ -501,7 +501,7 @@ fun FunctionDescriptor.isSuspendLambdaOrLocalFunction() = this.isSuspend && when
fun FunctionDescriptor.isLocalSuspendFunctionNotSuspendLambda() = isSuspendLambdaOrLocalFunction() && this !is AnonymousFunctionDescriptor fun FunctionDescriptor.isLocalSuspendFunctionNotSuspendLambda() = isSuspendLambdaOrLocalFunction() && this !is AnonymousFunctionDescriptor
@JvmField @JvmField
val EXPERIMENTAL_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType() val EXPERIMENTAL_CONTINUATION_ASM_TYPE = KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType()
@JvmField @JvmField
val RELEASE_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType() val RELEASE_CONTINUATION_ASM_TYPE = KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType()
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.codegen.inline
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.util.ArrayUtil import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
import org.jetbrains.kotlin.codegen.context.ClosureContext import org.jetbrains.kotlin.codegen.context.ClosureContext
@@ -675,7 +675,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
if (callableDescriptor is FictitiousArrayConstructor) return true if (callableDescriptor is FictitiousArrayConstructor) return true
val name = callableDescriptor.name.asString() val name = callableDescriptor.name.asString()
return (name == "arrayOf" || name == "emptyArray") && callableDescriptor.containingDeclaration.let { container -> return (name == "arrayOf" || name == "emptyArray") && callableDescriptor.containingDeclaration.let { container ->
container is PackageFragmentDescriptor && container.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME container is PackageFragmentDescriptor && container.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
} }
} }
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted
@@ -54,7 +55,7 @@ internal fun generateInlineIntrinsic(
private fun isSpecialEnumMethod(descriptor: FunctionDescriptor): Boolean { private fun isSpecialEnumMethod(descriptor: FunctionDescriptor): Boolean {
val containingDeclaration = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false val containingDeclaration = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false
if (containingDeclaration.fqName != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) { if (containingDeclaration.fqName != KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME) {
return false return false
} }
if (descriptor.typeParameters.size != 1) { if (descriptor.typeParameters.size != 1) {
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
import kotlin.text.StringsKt; import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.builtins.PrimitiveType; import org.jetbrains.kotlin.builtins.PrimitiveType;
import org.jetbrains.kotlin.codegen.AsmUtil; import org.jetbrains.kotlin.codegen.AsmUtil;
import org.jetbrains.kotlin.config.JvmTarget; import org.jetbrains.kotlin.config.JvmTarget;
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions; import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.*; import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.*;
import static org.jetbrains.org.objectweb.asm.Opcodes.*; import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class IntrinsicMethods { public class IntrinsicMethods {
@@ -70,15 +70,15 @@ public class IntrinsicMethods {
public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) { public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) {
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, RECEIVER_PARAMETER_FQ_NAME, "javaClass", -1, JavaClassProperty.INSTANCE); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, RECEIVER_PARAMETER_FQ_NAME, "javaClass", -1, JavaClassProperty.INSTANCE);
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "java", -1, new KClassJavaProperty()); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "java", -1, new KClassJavaProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty()); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty()); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.FQ_NAMES.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty()); intrinsicsMap.registerIntrinsic(KotlinBuiltInsNames.FqNames.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorEnter", 1, MonitorInstruction.MONITOR_ENTER); intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorEnter", 1, MonitorInstruction.MONITOR_ENTER);
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorExit", 1, MonitorInstruction.MONITOR_EXIT); intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorExit", 1, MonitorInstruction.MONITOR_EXIT);
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.array, "isArrayOf", 0, new IsArrayOf()); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.array, "isArrayOf", 0, new IsArrayOf());
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOf", 1, new ArrayOf()); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOf", 1, new ArrayOf());
@@ -87,7 +87,7 @@ public class IntrinsicMethods {
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList(); ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
for (Name method : primitiveCastMethods) { for (Name method : primitiveCastMethods) {
String methodName = method.asString(); String methodName = method.asString();
declareIntrinsicFunction(FQ_NAMES.number, methodName, 0, NUMBER_CAST); declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.number, methodName, 0, NUMBER_CAST);
for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) {
declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST); declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST);
} }
@@ -139,20 +139,20 @@ public class IntrinsicMethods {
declareBinaryOp("or", IOR); declareBinaryOp("or", IOR);
declareBinaryOp("xor", IXOR); declareBinaryOp("xor", IXOR);
declareIntrinsicFunction(FQ_NAMES._boolean, "not", 0, new Not()); declareIntrinsicFunction(KotlinBuiltInsNames.FqNames._boolean, "not", 0, new Not());
declareIntrinsicFunction(FQ_NAMES.string, "plus", 1, new Concat()); declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.string, "plus", 1, new Concat());
declareIntrinsicFunction(FQ_NAMES.string, "get", 1, new StringGetChar()); declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.string, "get", 1, new StringGetChar());
if (canReplaceStdlibRuntimeApiBehavior) { if (canReplaceStdlibRuntimeApiBehavior) {
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimMargin", 1, new TrimMargin()); intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.string, "trimMargin", 1, new TrimMargin());
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimIndent", 0, new TrimIndent()); intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.string, "trimIndent", 0, new TrimIndent());
} }
declareIntrinsicFunction(FQ_NAMES.cloneable, "clone", 0, CLONE); declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.cloneable, "clone", 0, CLONE);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "toString", 0, TO_STRING); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.any, "toString", 0, TO_STRING);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.string, "plus", 1, STRING_PLUS); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.string, "plus", 1, STRING_PLUS);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray()); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray());
for (PrimitiveType type : PrimitiveType.values()) { for (PrimitiveType type : PrimitiveType.values()) {
@@ -197,7 +197,7 @@ public class IntrinsicMethods {
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) { for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName()); declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName());
} }
declareArrayMethods(FQ_NAMES.array.toSafe()); declareArrayMethods(FqNames.array.toSafe());
} }
private void declareArrayMethods(@NotNull FqName arrayTypeFqName) { private void declareArrayMethods(@NotNull FqName arrayTypeFqName) {
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.codegen.intrinsics package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COLLECTIONS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.kotlin.codegen.CallableMethod
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.codegen.intrinsics package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.jvm.AsmTypes
@@ -16,7 +16,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.* import org.jetbrains.org.objectweb.asm.tree.*
import kotlin.text.Regex
object TypeIntrinsics { object TypeIntrinsics {
@JvmStatic @JvmStatic
@@ -134,20 +133,20 @@ object TypeIntrinsics {
private val MUTABLE_COLLECTION_TYPE_FQ_NAMES = setOf( private val MUTABLE_COLLECTION_TYPE_FQ_NAMES = setOf(
FQ_NAMES.mutableIterator, FqNames.mutableIterator,
FQ_NAMES.mutableIterable, FqNames.mutableIterable,
FQ_NAMES.mutableCollection, FqNames.mutableCollection,
FQ_NAMES.mutableList, FqNames.mutableList,
FQ_NAMES.mutableListIterator, FqNames.mutableListIterator,
FQ_NAMES.mutableMap, FqNames.mutableMap,
FQ_NAMES.mutableSet, FqNames.mutableSet,
FQ_NAMES.mutableMapEntry FqNames.mutableMapEntry
) )
private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? { private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? {
val fqName = getClassFqName(jetType) val fqName = getClassFqName(jetType)
if (fqName == null || fqName !in MUTABLE_COLLECTION_TYPE_FQ_NAMES) return null if (fqName == null || fqName !in MUTABLE_COLLECTION_TYPE_FQ_NAMES) return null
val baseName = if (fqName == FQ_NAMES.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString() val baseName = if (fqName == FqNames.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
return prefix + baseName return prefix + baseName
} }
@@ -200,4 +199,4 @@ object TypeIntrinsics {
private val BEFORE_CHECKCAST_TO_FUNCTION_OF_ARITY_DESCRIPTOR = private val BEFORE_CHECKCAST_TO_FUNCTION_OF_ARITY_DESCRIPTOR =
Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE, Type.INT_TYPE) Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE, Type.INT_TYPE)
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.codegen.range package org.jetbrains.kotlin.codegen.range
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
@@ -83,10 +84,10 @@ fun getRangeOrProgressionElementType(rangeType: KotlinType): KotlinType? {
COMPARABLE_RANGE_FQN -> rangeType.arguments.singleOrNull()?.type COMPARABLE_RANGE_FQN -> rangeType.arguments.singleOrNull()?.type
UINT_RANGE_FQN, UINT_PROGRESSION_FQN -> UINT_RANGE_FQN, UINT_PROGRESSION_FQN ->
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uIntFqName) rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltInsNames.FqNames.uIntFqName)
ULONG_RANGE_FQN, ULONG_PROGRESSION_FQN -> ULONG_RANGE_FQN, ULONG_PROGRESSION_FQN ->
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uLongFqName) rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltInsNames.FqNames.uLongFqName)
else -> null else -> null
} }
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.state
import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.RESULT_FQ_NAME
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
@@ -18,6 +18,7 @@
package org.jetbrains.kotlin.codegen.state package org.jetbrains.kotlin.codegen.state
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
@@ -37,7 +38,6 @@ import org.jetbrains.kotlin.types.checker.convertVariance
import org.jetbrains.kotlin.types.getEffectiveVariance import org.jetbrains.kotlin.types.getEffectiveVariance
import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.model.KotlinTypeMarker
import org.jetbrains.kotlin.types.model.TypeParameterMarker import org.jetbrains.kotlin.types.model.TypeParameterMarker
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES
// TODO: probably class upper bound should be used // TODO: probably class upper bound should be used
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
@@ -81,9 +81,9 @@ val FqName?.isMethodWithDeclarationSiteWildcardsFqName: Boolean
private fun FqName.child(name: String): FqName = child(Name.identifier(name)) private fun FqName.child(name: String): FqName = child(Name.identifier(name))
private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf( private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf(
BUILTIN_NAMES.mutableCollection.child("addAll"), FqNames.mutableCollection.child("addAll"),
BUILTIN_NAMES.mutableList.child("addAll"), FqNames.mutableList.child("addAll"),
BUILTIN_NAMES.mutableMap.child("putAll") FqNames.mutableMap.child("putAll")
) )
fun TypeMappingMode.updateArgumentModeFromAnnotations( fun TypeMappingMode.updateArgumentModeFromAnnotations(
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.serialization.builtins package org.jetbrains.kotlin.serialization.builtins
import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInClassDescriptorFactory import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInClassDescriptorFactory
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
@@ -100,9 +100,9 @@ class BuiltInsSerializer(dependOnOldBuiltIns: Boolean) : MetadataSerializer(Buil
// Since Kotlin 1.1, we always discard this class during deserialization (see ClassDeserializer.kt). // Since Kotlin 1.1, we always discard this class during deserialization (see ClassDeserializer.kt).
private fun createCloneable(module: ModuleDescriptor): ClassDescriptor { private fun createCloneable(module: ModuleDescriptor): ClassDescriptor {
val factory = JvmBuiltInClassDescriptorFactory(LockBasedStorageManager.NO_LOCKS, module) { val factory = JvmBuiltInClassDescriptorFactory(LockBasedStorageManager.NO_LOCKS, module) {
EmptyPackageFragmentDescriptor(module, KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) EmptyPackageFragmentDescriptor(module, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME)
} }
return factory.createClass(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe())) return factory.createClass(ClassId.topLevel(KotlinBuiltInsNames.FqNames.cloneable.toSafe()))
?: error("Could not create kotlin.Cloneable in $module") ?: error("Could not create kotlin.Cloneable in $module")
} }
} }
@@ -5,9 +5,9 @@
package org.jetbrains.kotlin.config package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
fun LanguageVersionSettings.coroutinesPackageFqName(): FqName { fun LanguageVersionSettings.coroutinesPackageFqName(): FqName {
return coroutinesPackageFqName(isReleaseCoroutines()) return coroutinesPackageFqName(isReleaseCoroutines())
@@ -17,9 +17,9 @@ fun LanguageVersionSettings.isReleaseCoroutines() = supportsFeature(LanguageFeat
private fun coroutinesPackageFqName(isReleaseCoroutines: Boolean): FqName { private fun coroutinesPackageFqName(isReleaseCoroutines: Boolean): FqName {
return if (isReleaseCoroutines) return if (isReleaseCoroutines)
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
else else
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
} }
fun LanguageVersionSettings.coroutinesIntrinsicsPackageFqName() = fun LanguageVersionSettings.coroutinesIntrinsicsPackageFqName() =
@@ -33,7 +33,7 @@ fun LanguageVersionSettings.restrictsSuspensionFqName() =
fun FqName.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) = fun FqName.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) =
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)) if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines))
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext")) this == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
else else
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) || this == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
this == DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) this == KotlinBuiltInsNames.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.fir.backend package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAMES
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceElement
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.deserialization package org.jetbrains.kotlin.fir.deserialization
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsSettings import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsSettings
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
@@ -210,7 +210,7 @@ private fun FirRegularClassBuilder.addSerializableIfNeeded(classId: ClassId) {
} }
private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId) { private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId) {
if (classId.packageFqName != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) return if (classId.packageFqName != KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME) return
if (classId.shortClassName !in ARRAY_CLASSES) return if (classId.shortClassName !in ARRAY_CLASSES) return
superTypeRefs += buildResolvedTypeRef { superTypeRefs += buildResolvedTypeRef {
type = ConeClassLikeTypeImpl( type = ConeClassLikeTypeImpl(
@@ -5,9 +5,8 @@
package org.jetbrains.kotlin.fir.deserialization package org.jetbrains.kotlin.fir.deserialization
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.resolve.DescriptorUtils
val CONTINUATION_INTERFACE_CLASS_ID = ClassId.topLevel(KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE)
val CONTINUATION_INTERFACE_CLASS_ID = ClassId.topLevel(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE)
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.resolve package org.jetbrains.kotlin.fir.resolve
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.*
@@ -395,7 +395,7 @@ fun CallableId.isInvoke() =
isKFunctionInvoke() isKFunctionInvoke()
|| callableName.asString() == "invoke" || callableName.asString() == "invoke"
&& className?.asString()?.startsWith("Function") == true && className?.asString()?.startsWith("Function") == true
&& packageName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME && packageName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
fun CallableId.isKFunctionInvoke() = fun CallableId.isKFunctionInvoke() =
callableName.asString() == "invoke" callableName.asString() == "invoke"
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.resolve.providers.impl package org.jetbrains.kotlin.fir.resolve.providers.impl
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
@@ -56,7 +56,7 @@ class FirBuiltinSymbolProvider(session: FirSession, val kotlinScopeProvider: Kot
private fun loadBuiltIns(): List<BuiltInsPackageFragment> { private fun loadBuiltIns(): List<BuiltInsPackageFragment> {
val classLoader = this::class.java.classLoader val classLoader = this::class.java.classLoader
val streamProvider = { path: String -> classLoader?.getResourceAsStream(path) ?: ClassLoader.getSystemResourceAsStream(path) } val streamProvider = { path: String -> classLoader?.getResourceAsStream(path) ?: ClassLoader.getSystemResourceAsStream(path) }
val packageFqNames = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAMES val packageFqNames = KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAMES
return packageFqNames.map { fqName -> return packageFqNames.map { fqName ->
val resourcePath = BuiltInSerializerProtocol.getBuiltInsFilePath(fqName) val resourcePath = BuiltInSerializerProtocol.getBuiltInsFilePath(fqName)
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.resolve.providers.impl package org.jetbrains.kotlin.fir.resolve.providers.impl
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name
class FirCloneableSymbolProvider(session: FirSession, scopeProvider: FirScopeProvider) : FirSymbolProvider(session) { class FirCloneableSymbolProvider(session: FirSession, scopeProvider: FirScopeProvider) : FirSymbolProvider(session) {
companion object { companion object {
val CLONEABLE: Name = Name.identifier("Cloneable") val CLONEABLE: Name = Name.identifier("Cloneable")
val CLONEABLE_CLASS_ID: ClassId = ClassId(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, CLONEABLE) val CLONEABLE_CLASS_ID: ClassId = ClassId(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME, CLONEABLE)
val CLONE: Name = Name.identifier("clone") val CLONE: Name = Name.identifier("clone")
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.fir.types package org.jetbrains.kotlin.fir.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
@@ -495,10 +495,10 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
} }
override fun TypeConstructorMarker.getPrimitiveType() = override fun TypeConstructorMarker.getPrimitiveType() =
getClassFqNameUnsafe()?.let(KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType::get) getClassFqNameUnsafe()?.let(KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType::get)
override fun TypeConstructorMarker.getPrimitiveArrayType() = override fun TypeConstructorMarker.getPrimitiveArrayType() =
getClassFqNameUnsafe()?.let(KotlinBuiltIns.FQ_NAMES.arrayClassFqNameToPrimitiveType::get) getClassFqNameUnsafe()?.let(KotlinBuiltInsNames.FqNames.arrayClassFqNameToPrimitiveType::get)
override fun TypeConstructorMarker.isUnderKotlinPackage() = override fun TypeConstructorMarker.isUnderKotlinPackage() =
getClassFqNameUnsafe()?.startsWith(Name.identifier("kotlin")) == true getClassFqNameUnsafe()?.startsWith(Name.identifier("kotlin")) == true
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.PsiMethod import com.intellij.psi.PsiMethod
import com.intellij.psi.SyntheticElement import com.intellij.psi.SyntheticElement
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
fun isSyntheticValuesOrValueOfMethod(method: PsiMethod): Boolean { fun isSyntheticValuesOrValueOfMethod(method: PsiMethod): Boolean {
if (method !is SyntheticElement) return false if (method !is SyntheticElement) return false
return DescriptorUtils.ENUM_VALUE_OF.asString() == method.name || DescriptorUtils.ENUM_VALUES.asString() == method.name return KotlinBuiltInsNames.ENUM_VALUE_OF.asString() == method.name || KotlinBuiltInsNames.ENUM_VALUES.asString() == method.name
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.resolve.jvm.multiplatform package org.jetbrains.kotlin.resolve.jvm.multiplatform
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.components.JavaPropertyInitializerEvaluatorImpl import org.jetbrains.kotlin.load.java.components.JavaPropertyInitializerEvaluatorImpl
@@ -68,7 +68,7 @@ class JavaActualAnnotationArgumentExtractor : ExpectedActualDeclarationChecker.A
is JavaPrimitiveType -> { is JavaPrimitiveType -> {
val primitiveType = type.type val primitiveType = type.type
// void.class is not representable in Kotlin, we approximate it by Unit::class // void.class is not representable in Kotlin, we approximate it by Unit::class
?: return KClassValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.unit.toSafe()), 0) ?: return KClassValue(ClassId.topLevel(KotlinBuiltInsNames.FqNames.unit.toSafe()), 0)
if (arrayDimensions > 0) { if (arrayDimensions > 0) {
KClassValue(ClassId.topLevel(primitiveType.arrayTypeFqName), arrayDimensions - 1) KClassValue(ClassId.topLevel(primitiveType.arrayTypeFqName), arrayDimensions - 1)
} else { } else {
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.resolve package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
@@ -238,7 +238,7 @@ class AnnotationChecker(
} }
fun applicableTargetSet(classDescriptor: ClassDescriptor): Set<KotlinTarget>? { fun applicableTargetSet(classDescriptor: ClassDescriptor): Set<KotlinTarget>? {
val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target) ?: return null val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.target) ?: return null
return loadAnnotationTargets(targetEntryDescriptor) return loadAnnotationTargets(targetEntryDescriptor)
} }
@@ -436,4 +436,4 @@ class AnnotationChecker(
interface AdditionalAnnotationChecker { interface AdditionalAnnotationChecker {
fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace)
} }
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.resolve
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
@@ -76,7 +76,7 @@ class CollectionLiteralResolver(
expression: KtCollectionLiteralExpression, expression: KtCollectionLiteralExpression,
callName: Name callName: Name
): Collection<SimpleFunctionDescriptor> { ): Collection<SimpleFunctionDescriptor> {
val memberScopeOfKotlinPackage = module.getPackage(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME).memberScope val memberScopeOfKotlinPackage = module.getPackage(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME).memberScope
return memberScopeOfKotlinPackage.getContributedFunctions(callName, KotlinLookupLocation(expression)) return memberScopeOfKotlinPackage.getContributedFunctions(callName, KotlinLookupLocation(expression))
} }
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve
import com.google.common.collect.ImmutableSet import com.google.common.collect.ImmutableSet
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
@@ -975,7 +976,7 @@ class DeclarationsChecker(
if (containingDeclaration !is ClassDescriptor) continue if (containingDeclaration !is ClassDescriptor) continue
if (visitedClasses.contains(containingDeclaration)) continue if (visitedClasses.contains(containingDeclaration)) continue
if (DescriptorUtils.getFqName(containingDeclaration) == KotlinBuiltIns.FQ_NAMES.any) { if (DescriptorUtils.getFqName(containingDeclaration) == KotlinBuiltInsNames.FqNames.any) {
return true return true
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve
import com.google.common.collect.Lists import com.google.common.collect.Lists
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor
@@ -174,7 +175,7 @@ class DelegatedPropertyResolver(
} }
private fun KtPsiFactory.createExpressionForProperty(): KtExpression { private fun KtPsiFactory.createExpressionForProperty(): KtExpression {
return createExpression("null as ${KotlinBuiltIns.FQ_NAMES.kPropertyFqName.asString()}<*>") return createExpression("null as ${KotlinBuiltInsNames.FqNames.kPropertyFqName.asString()}<*>")
} }
/* Resolve getValue() or setValue() methods from delegate */ /* Resolve getValue() or setValue() methods from delegate */
@@ -19,10 +19,7 @@ package org.jetbrains.kotlin.resolve
import com.intellij.openapi.util.ThrowableComputable import com.intellij.openapi.util.ThrowableComputable
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.util.AstLoadingFilter import com.intellij.util.AstLoadingFilter
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.*
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.contracts.description.ContractProviderKey import org.jetbrains.kotlin.contracts.description.ContractProviderKey
@@ -309,7 +306,7 @@ class FunctionDescriptorResolver(
private fun KotlinType.removeParameterNameAnnotation(): KotlinType { private fun KotlinType.removeParameterNameAnnotation(): KotlinType {
if (this is TypeUtils.SpecialType) return this if (this is TypeUtils.SpecialType) return this
val parameterNameAnnotation = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.parameterName) ?: return this val parameterNameAnnotation = annotations.findAnnotation(KotlinBuiltInsNames.FqNames.parameterName) ?: return this
return replaceAnnotations(Annotations.create(annotations.filter { it != parameterNameAnnotation })) return replaceAnnotations(Annotations.create(annotations.filter { it != parameterNameAnnotation }))
} }
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.resolve package org.jetbrains.kotlin.resolve
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl
@@ -148,7 +148,7 @@ class VarianceCheckerCore(
if (classifierDescriptor is TypeParameterDescriptor) { if (classifierDescriptor is TypeParameterDescriptor) {
val declarationVariance = classifierDescriptor.varianceWithManual() val declarationVariance = classifierDescriptor.varianceWithManual()
if (!declarationVariance.allowsPosition(position) if (!declarationVariance.allowsPosition(position)
&& !type.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.unsafeVariance) && !type.annotations.hasAnnotation(KotlinBuiltInsNames.FqNames.unsafeVariance)
) { ) {
val varianceConflictDiagnosticData = VarianceConflictDiagnosticData(containingType, classifierDescriptor, position) val varianceConflictDiagnosticData = VarianceConflictDiagnosticData(containingType, classifierDescriptor, position)
val diagnostic = val diagnostic =
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.resolve.calls.checkers package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.builtins.ReflectionTypes import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue import org.jetbrains.kotlin.storage.getValue
import org.jetbrains.kotlin.util.OperatorNameConventions
private val ALLOWED_MEMBER_NAMES = setOf( private val ALLOWED_MEMBER_NAMES = setOf(
"equals", "hashCode", "toString", "invoke", "name" "equals", "hashCode", "toString", "invoke", "name"
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.resolve.calls.checkers package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
@@ -6,16 +6,19 @@
package org.jetbrains.kotlin.resolve.calls.checkers package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.KtCodeFragment
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.callUtil.isCallableReference import org.jetbrains.kotlin.resolve.calls.callUtil.isCallableReference
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -33,13 +36,13 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
val COROUTINE_CONTEXT_1_2_20_FQ_NAME = val COROUTINE_CONTEXT_1_2_20_FQ_NAME =
DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) KotlinBuiltInsNames.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
val COROUTINE_CONTEXT_1_2_30_FQ_NAME = val COROUTINE_CONTEXT_1_2_30_FQ_NAME =
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
val COROUTINE_CONTEXT_1_3_FQ_NAME = val COROUTINE_CONTEXT_1_3_FQ_NAME =
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext")) KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
fun FunctionDescriptor.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) = fun FunctionDescriptor.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) =
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe?.isBuiltInCoroutineContext(languageVersionSettings) == true (this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe?.isBuiltInCoroutineContext(languageVersionSettings) == true
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.resolve.checkers package org.jetbrains.kotlin.resolve.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
@@ -31,8 +31,8 @@ class AnnotationClassTargetAndRetentionChecker : DeclarationChecker {
val retention = descriptor.getAnnotationRetention() ?: KotlinRetention.RUNTIME val retention = descriptor.getAnnotationRetention() ?: KotlinRetention.RUNTIME
if (targets.contains(KotlinTarget.EXPRESSION) && retention != KotlinRetention.SOURCE) { if (targets.contains(KotlinTarget.EXPRESSION) && retention != KotlinRetention.SOURCE) {
val retentionAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.retention) val retentionAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.retention)
val targetAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target) val targetAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.target)
val diagnostics = val diagnostics =
if (context.languageVersionSettings.supportsFeature(LanguageFeature.RestrictRetentionForExpressionAnnotations)) if (context.languageVersionSettings.supportsFeature(LanguageFeature.RestrictRetentionForExpressionAnnotations))
@@ -45,4 +45,4 @@ class AnnotationClassTargetAndRetentionChecker : DeclarationChecker {
private val AnnotationDescriptor.psi: PsiElement? private val AnnotationDescriptor.psi: PsiElement?
get() = DescriptorToSourceUtils.getSourceFromAnnotation(this) get() = DescriptorToSourceUtils.getSourceFromAnnotation(this)
} }
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.resolve.checkers package org.jetbrains.kotlin.resolve.checkers
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
@@ -25,14 +25,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
object DeprecatedSinceKotlinAnnotationChecker : DeclarationChecker { object DeprecatedSinceKotlinAnnotationChecker : DeclarationChecker {
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
val deprecatedSinceAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin) ?: return val deprecatedSinceAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecatedSinceKotlin) ?: return
val deprecatedSinceAnnotationPsi = deprecatedSinceAnnotation.source.getPsi() as? KtAnnotationEntry ?: return val deprecatedSinceAnnotationPsi = deprecatedSinceAnnotation.source.getPsi() as? KtAnnotationEntry ?: return
val deprecatedAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) val deprecatedAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecated)
val deprecatedSinceAnnotationName = deprecatedSinceAnnotationPsi.typeReference ?: return val deprecatedSinceAnnotationName = deprecatedSinceAnnotationPsi.typeReference ?: return
if (descriptor.fqNameOrNull()?.isSubpackageOf(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) == false) { if (descriptor.fqNameOrNull()?.isSubpackageOf(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME) == false) {
context.trace.report( context.trace.report(
Errors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE.on( Errors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE.on(
deprecatedSinceAnnotationName deprecatedSinceAnnotationName
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.resolve.checkers package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
@@ -70,7 +70,7 @@ class ExperimentalMarkerDeclarationAnnotationChecker(private val module: ModuleD
val targetEntry = val targetEntry =
entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) } entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) }
.entries .entries
.firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltIns.FQ_NAMES.target } .firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltInsNames.FqNames.target }
?: return ?: return
val (entry, descriptor) = targetEntry val (entry, descriptor) = targetEntry
val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.resolve.checkers package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
@@ -38,7 +38,7 @@ object PublishedApiUsageChecker {
for (entry in declaration.annotationEntries) { for (entry in declaration.annotationEntries) {
val annotationDescriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue val annotationDescriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
if (annotationDescriptor.fqName == KotlinBuiltIns.FQ_NAMES.publishedApi) { if (annotationDescriptor.fqName == KotlinBuiltInsNames.FqNames.publishedApi) {
trace.report(Errors.NON_INTERNAL_PUBLISHED_API.on(entry)) trace.report(Errors.NON_INTERNAL_PUBLISHED_API.on(entry))
} }
} }
@@ -5,16 +5,15 @@
package org.jetbrains.kotlin.resolve.checkers package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.AnalysisFlags import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
class ResultClassInReturnTypeChecker : DeclarationChecker { class ResultClassInReturnTypeChecker : DeclarationChecker {
@@ -60,6 +59,6 @@ internal fun KotlinType.isResultType(): Boolean {
private fun DeclarationDescriptor.isResultClass(): Boolean { private fun DeclarationDescriptor.isResultClass(): Boolean {
val container = containingDeclaration ?: return false val container = containingDeclaration ?: return false
return container is PackageFragmentDescriptor && return container is PackageFragmentDescriptor &&
container.fqName == DescriptorUtils.RESULT_FQ_NAME.parent() && container.fqName == KotlinBuiltInsNames.RESULT_FQ_NAME.parent() &&
name == DescriptorUtils.RESULT_FQ_NAME.shortName() name == KotlinBuiltInsNames.RESULT_FQ_NAME.shortName()
} }
@@ -11,6 +11,7 @@ import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.TypeConversionUtil import com.intellij.psi.util.TypeConversionUtil
import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
@@ -1017,7 +1018,7 @@ private class ConstantExpressionEvaluatorVisitor(
} }
private fun checkAccessibilityOfUnsignedTypes(): Boolean { private fun checkAccessibilityOfUnsignedTypes(): Boolean {
val uInt = constantExpressionEvaluator.module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) ?: return false val uInt = constantExpressionEvaluator.module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uInt) ?: return false
val accessibility = uInt.checkSinceKotlinVersionAccessibility(languageVersionSettings) val accessibility = uInt.checkSinceKotlinVersionAccessibility(languageVersionSettings)
// Case `NotAccessibleButWasExperimental` will be checked later in `checkExperimentalityOfConstantLiteral` // Case `NotAccessibleButWasExperimental` will be checked later in `checkExperimentalityOfConstantLiteral`
return accessibility is SinceKotlinAccessibility.Accessible return accessibility is SinceKotlinAccessibility.Accessible
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.resolve.deprecation package org.jetbrains.kotlin.resolve.deprecation
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
@@ -200,11 +201,11 @@ class DeprecationResolver(
} }
private fun DeclarationDescriptor.addDeprecationIfPresent(result: MutableList<Deprecation>) { private fun DeclarationDescriptor.addDeprecationIfPresent(result: MutableList<Deprecation>) {
val annotation = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED) val annotation = annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecated) ?: annotations.findAnnotation(JAVA_DEPRECATED)
if (annotation != null) { if (annotation != null) {
val deprecatedByAnnotation = val deprecatedByAnnotation =
DeprecatedByAnnotation.create( DeprecatedByAnnotation.create(
annotation, annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin), annotation, annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecatedSinceKotlin),
this, deprecationSettings.propagatedToOverrides(annotation), this, deprecationSettings.propagatedToOverrides(annotation),
languageVersionSettings.apiVersion languageVersionSettings.apiVersion
) )
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet
import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.diagnostics.Severity
@@ -152,7 +152,7 @@ abstract class KotlinSuppressCache {
} }
private fun processAnnotation(builder: ImmutableSet.Builder<String>, annotationDescriptor: AnnotationDescriptor) { private fun processAnnotation(builder: ImmutableSet.Builder<String>, annotationDescriptor: AnnotationDescriptor) {
if (annotationDescriptor.fqName != KotlinBuiltIns.FQ_NAMES.suppress) return if (annotationDescriptor.fqName != KotlinBuiltInsNames.FqNames.suppress) return
// We only add strings and skip other values to facilitate recovery in presence of erroneous code // We only add strings and skip other values to facilitate recovery in presence of erroneous code
for (arrayValue in annotationDescriptor.allValueArguments.values) { for (arrayValue in annotationDescriptor.allValueArguments.values) {
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.common.ir
import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.lower.LocalDeclarationsLowering import org.jetbrains.kotlin.backend.common.lower.LocalDeclarationsLowering
import org.jetbrains.kotlin.builtins.* import org.jetbrains.kotlin.builtins.*
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
@@ -317,7 +318,7 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, irBuiltIns:
function.getPackageFragment()!!.fqName.asString() == "kotlin" && function.getPackageFragment()!!.fqName.asString() == "kotlin" &&
function.valueParameters.isEmpty() && function.valueParameters.isEmpty() &&
symbol.owner.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass -> symbol.owner.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass ->
receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltIns.FQ_NAMES.kProperty0 receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltInsNames.FqNames.kProperty0
} }
} }
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
@@ -72,8 +72,8 @@ class FlattenStringConcatenationLowering(val context: CommonBackendContext) : Fi
// The version for nullable strings has FqName kotlin.plus, the version for non-nullable strings // The version for nullable strings has FqName kotlin.plus, the version for non-nullable strings
// is a member function of kotlin.String (with FqName kotlin.String.plus) // is a member function of kotlin.String (with FqName kotlin.String.plus)
private val PARENT_NAMES = setOf( private val PARENT_NAMES = setOf(
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
KotlinBuiltIns.FQ_NAMES.string.toSafe() KotlinBuiltInsNames.FqNames.string.toSafe()
) )
/** @return true if the given expression is a call to [String.plus] */ /** @return true if the given expression is a call to [String.plus] */
@@ -108,7 +108,7 @@ class FlattenStringConcatenationLowering(val context: CommonBackendContext) : Fi
return dispatchReceiverParameter == null return dispatchReceiverParameter == null
&& extensionReceiverParameter?.type?.isNullableAny() == true && extensionReceiverParameter?.type?.isNullableAny() == true
&& fqNameWhenAvailable?.parent() == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME && fqNameWhenAvailable?.parent() == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
} }
/** @return true if the given expression is a call to [toString] */ /** @return true if the given expression is a call to [toString] */
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.ir.allOverridden import org.jetbrains.kotlin.backend.common.ir.allOverridden
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
@@ -63,46 +63,46 @@ class SpecialBridgeMethods(val context: CommonBackendContext) {
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, bridge.valueParameters[1].symbol) IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, bridge.valueParameters[1].symbol)
private val specialMethodsWithDefaults = mapOf( private val specialMethodsWithDefaults = mapOf(
makeDescription(KotlinBuiltIns.FQ_NAMES.collection, "contains", 1) to makeDescription(KotlinBuiltInsNames.FqNames.collection, "contains", 1) to
SpecialMethodWithDefaultInfo(::constFalse, 1), SpecialMethodWithDefaultInfo(::constFalse, 1),
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableCollection, "remove", 1) to makeDescription(KotlinBuiltInsNames.FqNames.mutableCollection, "remove", 1) to
SpecialMethodWithDefaultInfo(::constFalse, 1, needsArgumentBoxing = true), SpecialMethodWithDefaultInfo(::constFalse, 1, needsArgumentBoxing = true),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "containsKey", 1) to makeDescription(KotlinBuiltInsNames.FqNames.map, "containsKey", 1) to
SpecialMethodWithDefaultInfo(::constFalse, 1), SpecialMethodWithDefaultInfo(::constFalse, 1),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "containsValue", 1) to makeDescription(KotlinBuiltInsNames.FqNames.map, "containsValue", 1) to
SpecialMethodWithDefaultInfo(::constFalse, 1), SpecialMethodWithDefaultInfo(::constFalse, 1),
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableMap, "remove", 2) to makeDescription(KotlinBuiltInsNames.FqNames.mutableMap, "remove", 2) to
SpecialMethodWithDefaultInfo(::constFalse, 2), SpecialMethodWithDefaultInfo(::constFalse, 2),
makeDescription(KotlinBuiltIns.FQ_NAMES.list, "indexOf", 1) to makeDescription(KotlinBuiltInsNames.FqNames.list, "indexOf", 1) to
SpecialMethodWithDefaultInfo(::constMinusOne, 1), SpecialMethodWithDefaultInfo(::constMinusOne, 1),
makeDescription(KotlinBuiltIns.FQ_NAMES.list, "lastIndexOf", 1) to makeDescription(KotlinBuiltInsNames.FqNames.list, "lastIndexOf", 1) to
SpecialMethodWithDefaultInfo(::constMinusOne, 1), SpecialMethodWithDefaultInfo(::constMinusOne, 1),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "getOrDefault", 2) to makeDescription(KotlinBuiltInsNames.FqNames.map, "getOrDefault", 2) to
SpecialMethodWithDefaultInfo(::getSecondArg, 1, needsGenericSignature = true), SpecialMethodWithDefaultInfo(::getSecondArg, 1, needsGenericSignature = true),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "get", 1) to makeDescription(KotlinBuiltInsNames.FqNames.map, "get", 1) to
SpecialMethodWithDefaultInfo(::constNull, 1, needsGenericSignature = true), SpecialMethodWithDefaultInfo(::constNull, 1, needsGenericSignature = true),
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableMap, "remove", 1) to makeDescription(KotlinBuiltInsNames.FqNames.mutableMap, "remove", 1) to
SpecialMethodWithDefaultInfo(::constNull, 1, needsGenericSignature = true) SpecialMethodWithDefaultInfo(::constNull, 1, needsGenericSignature = true)
) )
private val specialProperties = mapOf( private val specialProperties = mapOf(
makeDescription(KotlinBuiltIns.FQ_NAMES.collection, "size") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.collection, "size") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "size") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.map, "size") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.charSequence.toSafe(), "length") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.charSequence.toSafe(), "length") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "keys") to BuiltInWithDifferentJvmName(needsGenericSignature = true), makeDescription(KotlinBuiltInsNames.FqNames.map, "keys") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "values") to BuiltInWithDifferentJvmName(needsGenericSignature = true), makeDescription(KotlinBuiltInsNames.FqNames.map, "values") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "entries") to BuiltInWithDifferentJvmName(needsGenericSignature = true) makeDescription(KotlinBuiltInsNames.FqNames.map, "entries") to BuiltInWithDifferentJvmName(needsGenericSignature = true)
) )
private val specialMethods = mapOf( private val specialMethods = mapOf(
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toByte") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toByte") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toShort") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toShort") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toInt") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toInt") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toLong") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toLong") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toFloat") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toFloat") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toDouble") to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toDouble") to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.charSequence.toSafe(), "get", 1) to BuiltInWithDifferentJvmName(), makeDescription(KotlinBuiltInsNames.FqNames.charSequence.toSafe(), "get", 1) to BuiltInWithDifferentJvmName(),
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableList, "removeAt", 1) to BuiltInWithDifferentJvmName(needsGenericSignature = true) makeDescription(KotlinBuiltInsNames.FqNames.mutableList, "removeAt", 1) to BuiltInWithDifferentJvmName(needsGenericSignature = true)
) )
val specialMethodNames = (specialMethodsWithDefaults + specialMethods).map { (description) -> description.name }.toHashSet() val specialMethodNames = (specialMethodsWithDefaults + specialMethods).map { (description) -> description.name }.toHashSet()
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.ir.util package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrClass
@@ -70,10 +70,10 @@ private inline fun IrType.isTypeFromKotlinPackage(namePredicate: (Name) -> Boole
} else return false } else return false
} }
fun IrType.isPrimitiveArray() = isTypeFromKotlinPackage { it in FQ_NAMES.primitiveArrayTypeShortNames } fun IrType.isPrimitiveArray() = isTypeFromKotlinPackage { it in FqNames.primitiveArrayTypeShortNames }
fun IrType.getPrimitiveArrayElementType() = (this as? IrSimpleType)?.let { fun IrType.getPrimitiveArrayElementType() = (this as? IrSimpleType)?.let {
(it.classifier.owner as? IrClass)?.fqNameWhenAvailable?.toUnsafe()?.let { fqn -> FQ_NAMES.arrayClassFqNameToPrimitiveType[fqn] } (it.classifier.owner as? IrClass)?.fqNameWhenAvailable?.toUnsafe()?.let { fqn -> FqNames.arrayClassFqNameToPrimitiveType[fqn] }
} }
fun IrType.substitute(params: List<IrTypeParameter>, arguments: List<IrType>): IrType = fun IrType.substitute(params: List<IrTypeParameter>, arguments: List<IrType>): IrType =
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.backend.jvm
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.SamType import org.jetbrains.kotlin.codegen.SamType
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
@@ -106,7 +106,7 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene
descriptor.getParentJavaStaticClassScope() descriptor.getParentJavaStaticClassScope()
private val annotationPackage = private val annotationPackage =
IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), KotlinBuiltIns.ANNOTATION_PACKAGE_FQ_NAME) IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), KotlinBuiltInsNames.ANNOTATION_PACKAGE_FQ_NAME)
private val flexibleNullabilityAnnotationClass = IrFactoryImpl.buildClass { private val flexibleNullabilityAnnotationClass = IrFactoryImpl.buildClass {
kind = ClassKind.ANNOTATION_CLASS kind = ClassKind.ANNOTATION_CLASS
@@ -123,6 +123,6 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene
companion object { companion object {
val FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME = val FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME =
KotlinBuiltIns.ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier("FlexibleNullability")) KotlinBuiltInsNames.ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier("FlexibleNullability"))
} }
} }
@@ -10,7 +10,7 @@ package org.jetbrains.kotlin.backend.jvm
import org.jetbrains.kotlin.backend.common.ir.Symbols import org.jetbrains.kotlin.backend.common.ir.Symbols
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.coroutines.INVOKE_SUSPEND_METHOD_NAME import org.jetbrains.kotlin.codegen.coroutines.INVOKE_SUSPEND_METHOD_NAME
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_CALL_RESULT_NAME import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_CALL_RESULT_NAME
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
@@ -201,7 +200,7 @@ class JvmSymbols(
get() = TODO("not implemented") get() = TODO("not implemented")
private val kDeclarationContainer: IrClassSymbol = private val kDeclarationContainer: IrClassSymbol =
createClass(KotlinBuiltIns.FQ_NAMES.kDeclarationContainer.toSafe(), ClassKind.INTERFACE, Modality.ABSTRACT) createClass(KotlinBuiltInsNames.FqNames.kDeclarationContainer.toSafe(), ClassKind.INTERFACE, Modality.ABSTRACT)
val javaLangClass: IrClassSymbol = val javaLangClass: IrClassSymbol =
createClass(FqName("java.lang.Class")) { klass -> createClass(FqName("java.lang.Class")) { klass ->
@@ -226,12 +225,12 @@ class JvmSymbols(
val assertionErrorConstructor = javaLangAssertionError.constructors.single() val assertionErrorConstructor = javaLangAssertionError.constructors.single()
val continuationClass: IrClassSymbol = val continuationClass: IrClassSymbol =
createClass(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE, ClassKind.INTERFACE) { klass -> createClass(KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE, ClassKind.INTERFACE) { klass ->
klass.addTypeParameter("T", irBuiltIns.anyNType, Variance.IN_VARIANCE) klass.addTypeParameter("T", irBuiltIns.anyNType, Variance.IN_VARIANCE)
} }
private val resultClassStub: IrClassSymbol = private val resultClassStub: IrClassSymbol =
createClass(DescriptorUtils.RESULT_FQ_NAME, classIsInline = true) { klass -> createClass(KotlinBuiltInsNames.RESULT_FQ_NAME, classIsInline = true) { klass ->
klass.addTypeParameter("T", irBuiltIns.anyNType, Variance.OUT_VARIANCE) klass.addTypeParameter("T", irBuiltIns.anyNType, Variance.OUT_VARIANCE)
klass.addConstructor { isPrimary = true }.apply { klass.addConstructor { isPrimary = true }.apply {
addValueParameter("value", irBuiltIns.anyNType) addValueParameter("value", irBuiltIns.anyNType)
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.backend.common.ir.ir2string
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensions import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensions
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.TypeAnnotationCollector import org.jetbrains.kotlin.codegen.TypeAnnotationCollector
import org.jetbrains.kotlin.codegen.TypePathInfo import org.jetbrains.kotlin.codegen.TypePathInfo
@@ -373,7 +373,7 @@ private val RETENTION_PARAMETER_NAME = Name.identifier("value")
private fun IrClass.getAnnotationRetention(): KotlinRetention? { private fun IrClass.getAnnotationRetention(): KotlinRetention? {
val retentionArgument = val retentionArgument =
getAnnotation(KotlinBuiltIns.FQ_NAMES.retention)?.getValueArgument(RETENTION_PARAMETER_NAME) getAnnotation(KotlinBuiltInsNames.FqNames.retention)?.getValueArgument(RETENTION_PARAMETER_NAME)
as? IrGetEnumValue?: return null as? IrGetEnumValue?: return null
val retentionArgumentValue = retentionArgument.symbol.owner val retentionArgumentValue = retentionArgument.symbol.owner
return KotlinRetention.valueOf(retentionArgumentValue.name.asString()) return KotlinRetention.valueOf(retentionArgumentValue.name.asString())
@@ -393,7 +393,7 @@ private fun IrConstructorCall.getValueArgument(name: Name): IrExpression? {
private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets") private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets")
private fun IrClass.applicableTargetSet(): Set<KotlinTarget>? { private fun IrClass.applicableTargetSet(): Set<KotlinTarget>? {
val targetEntry = getAnnotation(KotlinBuiltIns.FQ_NAMES.target) ?: return null val targetEntry = getAnnotation(KotlinBuiltInsNames.FqNames.target) ?: return null
return loadAnnotationTargets(targetEntry) return loadAnnotationTargets(targetEntry)
} }
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault
import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement
import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor
import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.codegen.JvmCodegenUtil import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.codegen.replaceValueParametersIn import org.jetbrains.kotlin.codegen.replaceValueParametersIn
@@ -130,7 +130,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
else null) ?: context.state.moduleName else null) ?: context.state.moduleName
private fun IrFunction.isPublishedApi(): Boolean = private fun IrFunction.isPublishedApi(): Boolean =
propertyIfAccessor.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.publishedApi) propertyIfAccessor.annotations.hasAnnotation(KotlinBuiltInsNames.FqNames.publishedApi)
fun mapReturnType(declaration: IrDeclaration, sw: JvmSignatureWriter? = null): Type { fun mapReturnType(declaration: IrDeclaration, sw: JvmSignatureWriter? = null): Type {
if (declaration !is IrFunction) { if (declaration !is IrFunction) {
@@ -369,7 +369,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
} }
private val IrSimpleFunction.isBuiltIn: Boolean private val IrSimpleFunction.isBuiltIn: Boolean
get() = getPackageFragment()?.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME || get() = getPackageFragment()?.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME ||
parent.safeAs<IrClass>()?.fqNameWhenAvailable?.toUnsafe()?.let(JavaToKotlinClassMap::mapKotlinToJava) != null parent.safeAs<IrClass>()?.fqNameWhenAvailable?.toUnsafe()?.let(JavaToKotlinClassMap::mapKotlinToJava) != null
// From BuiltinMethodsWithDifferentJvmName.isBuiltinFunctionWithDifferentNameInJvm, BuiltinMethodsWithDifferentJvmName.getJvmName // From BuiltinMethodsWithDifferentJvmName.isBuiltinFunctionWithDifferentNameInJvm, BuiltinMethodsWithDifferentJvmName.getJvmName
@@ -424,4 +424,4 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
} }
return null return null
} }
} }
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.backend.common.ir.ir2string
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.inline.SourceMapper import org.jetbrains.kotlin.codegen.inline.SourceMapper
@@ -105,7 +105,7 @@ fun JvmBackendContext.getSourceMapper(declaration: IrClass): SourceMapper {
} }
val IrType.isExtensionFunctionType: Boolean val IrType.isExtensionFunctionType: Boolean
get() = isFunctionTypeOrSubtype() && hasAnnotation(FQ_NAMES.extensionFunctionType) get() = isFunctionTypeOrSubtype() && hasAnnotation(FqNames.extensionFunctionType)
/* Borrowed with modifications from MemberCodegen.java */ /* Borrowed with modifications from MemberCodegen.java */
@@ -409,7 +409,7 @@ fun IrClass.isOptionalAnnotationClass(): Boolean =
val IrAnnotationContainer.deprecationFlags: Int val IrAnnotationContainer.deprecationFlags: Int
get() { get() {
val annotation = annotations.findAnnotation(FQ_NAMES.deprecated) val annotation = annotations.findAnnotation(FqNames.deprecated)
?: return if ((this as? IrDeclaration)?.origin?.let { ?: return if ((this as? IrDeclaration)?.origin?.let {
it == JvmLoweredDeclarationOrigin.DEFAULT_IMPLS_BRIDGE_FOR_COMPATIBILITY it == JvmLoweredDeclarationOrigin.DEFAULT_IMPLS_BRIDGE_FOR_COMPATIBILITY
} == true } == true
@@ -17,9 +17,12 @@
package org.jetbrains.kotlin.backend.jvm.intrinsics package org.jetbrains.kotlin.backend.jvm.intrinsics
import org.jetbrains.kotlin.backend.jvm.JvmSymbols import org.jetbrains.kotlin.backend.jvm.JvmSymbols
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
@@ -43,11 +46,11 @@ class IrIntrinsicMethods(val irBuiltIns: IrBuiltIns, val symbols: JvmSymbols) {
private val intrinsicsMap = ( private val intrinsicsMap = (
listOf( listOf(
Key(kotlinJvm, FqName("T"), "<get-javaClass>", emptyList()) to JavaClassProperty, Key(kotlinJvm, FqName("T"), "<get-javaClass>", emptyList()) to JavaClassProperty,
Key(kotlinJvm, KotlinBuiltIns.FQ_NAMES.kClass.toSafe(), "<get-javaObjectType>", emptyList()) to GetJavaObjectType, Key(kotlinJvm, KotlinBuiltInsNames.FqNames.kClass.toSafe(), "<get-javaObjectType>", emptyList()) to GetJavaObjectType,
Key(kotlinJvm, KotlinBuiltIns.FQ_NAMES.kClass.toSafe(), "<get-javaPrimitiveType>", emptyList()) to GetJavaPrimitiveType, Key(kotlinJvm, KotlinBuiltInsNames.FqNames.kClass.toSafe(), "<get-javaPrimitiveType>", emptyList()) to GetJavaPrimitiveType,
Key( Key(
kotlinJvm, kotlinJvm,
KotlinBuiltIns.FQ_NAMES.kClass.toSafe(), KotlinBuiltInsNames.FqNames.kClass.toSafe(),
"<get-java>", "<get-java>",
emptyList() emptyList()
) to KClassJavaProperty, ) to KClassJavaProperty,
@@ -55,49 +58,49 @@ class IrIntrinsicMethods(val irBuiltIns: IrBuiltIns, val symbols: JvmSymbols) {
kotlinJvmInternalUnsafe, kotlinJvmInternalUnsafe,
null, null,
"access\$monitorEnter", "access\$monitorEnter",
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe()) listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
) to MonitorInstruction.MONITOR_ENTER, ) to MonitorInstruction.MONITOR_ENTER,
Key( Key(
kotlinJvmInternalUnsafe, kotlinJvmInternalUnsafe,
null, null,
"access\$monitorExit", "access\$monitorExit",
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe()) listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
) to MonitorInstruction.MONITOR_EXIT, ) to MonitorInstruction.MONITOR_EXIT,
Key( Key(
kotlinJvm, kotlinJvm,
KotlinBuiltIns.FQ_NAMES.array.toSafe(), KotlinBuiltInsNames.FqNames.array.toSafe(),
"isArrayOf", "isArrayOf",
emptyList() emptyList()
) to IsArrayOf, ) to IsArrayOf,
Key( Key(
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
null, null,
"arrayOfNulls", "arrayOfNulls",
listOf(KotlinBuiltIns.FQ_NAMES._int.toSafe()) listOf(KotlinBuiltInsNames.FqNames._int.toSafe())
) to NewArray, ) to NewArray,
Key( Key(
KotlinBuiltIns.FQ_NAMES.cloneable.toSafe(), KotlinBuiltInsNames.FqNames.cloneable.toSafe(),
null, null,
"clone", "clone",
emptyList() emptyList()
) to Clone, ) to Clone,
Key( Key(
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
null, null,
"enumValues", "enumValues",
listOf() listOf()
) to EnumValues, ) to EnumValues,
Key( Key(
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
null, null,
"enumValueOf", "enumValueOf",
listOf(KotlinBuiltIns.FQ_NAMES.string.toSafe()) listOf(KotlinBuiltInsNames.FqNames.string.toSafe())
) to EnumValueOf, ) to EnumValueOf,
Key( Key(
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
KotlinBuiltIns.FQ_NAMES.string.toSafe(), KotlinBuiltInsNames.FqNames.string.toSafe(),
"plus", "plus",
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe()) listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
) to StringPlus, ) to StringPlus,
irBuiltIns.eqeqSymbol.toKey()!! to Equals(KtTokens.EQEQ), irBuiltIns.eqeqSymbol.toKey()!! to Equals(KtTokens.EQEQ),
irBuiltIns.eqeqeqSymbol.toKey()!! to Equals(KtTokens.EQEQEQ), irBuiltIns.eqeqeqSymbol.toKey()!! to Equals(KtTokens.EQEQEQ),
@@ -17,12 +17,10 @@
package org.jetbrains.kotlin.backend.jvm.intrinsics package org.jetbrains.kotlin.backend.jvm.intrinsics
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COLLECTIONS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.ir.types.isPrimitiveType
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.backend.common.ir.addChild import org.jetbrains.kotlin.backend.common.ir.addChild
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
@@ -127,7 +127,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
} }
private fun generateDocumentedAnnotation(irClass: IrClass) { private fun generateDocumentedAnnotation(irClass: IrClass) {
if (!irClass.hasAnnotation(KotlinBuiltIns.FQ_NAMES.mustBeDocumented) || if (!irClass.hasAnnotation(KotlinBuiltInsNames.FqNames.mustBeDocumented) ||
irClass.hasAnnotation(FqName("java.lang.annotation.Documented")) irClass.hasAnnotation(FqName("java.lang.annotation.Documented"))
) return ) return
@@ -228,7 +228,7 @@ private fun IrConstructorCall.getValueArgument(name: Name): IrExpression? {
private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets") private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets")
private fun IrClass.applicableTargetSet(): Set<KotlinTarget>? { private fun IrClass.applicableTargetSet(): Set<KotlinTarget>? {
val targetEntry = getAnnotation(KotlinBuiltIns.FQ_NAMES.target) ?: return null val targetEntry = getAnnotation(KotlinBuiltInsNames.FqNames.target) ?: return null
return loadAnnotationTargets(targetEntry) return loadAnnotationTargets(targetEntry)
} }
@@ -238,4 +238,4 @@ private fun loadAnnotationTargets(targetEntry: IrConstructorCall): Set<KotlinTar
return valueArgument.elements.filterIsInstance<IrGetEnumValue>().mapNotNull { return valueArgument.elements.filterIsInstance<IrGetEnumValue>().mapNotNull {
KotlinTarget.valueOrNull(it.symbol.owner.name.asString()) KotlinTarget.valueOrNull(it.symbol.owner.name.asString())
}.toSet() }.toSet()
} }
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.backend.common.lower.*
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.ASSERTIONS_DISABLED_FIELD_NAME import org.jetbrains.kotlin.codegen.ASSERTIONS_DISABLED_FIELD_NAME
import org.jetbrains.kotlin.config.JVMAssertionsMode import org.jetbrains.kotlin.config.JVMAssertionsMode
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
@@ -129,7 +129,7 @@ private class AssertionLowering(private val context: JvmBackendContext) :
} }
private val IrFunction.isAssert: Boolean private val IrFunction.isAssert: Boolean
get() = name.asString() == "assert" && getPackageFragment()?.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME get() = name.asString() == "assert" && getPackageFragment()?.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
} }
private fun IrBuilderWithScope.getJavaClass(backendContext: JvmBackendContext, irClass: IrClass) = private fun IrBuilderWithScope.getJavaClass(backendContext: JvmBackendContext, irClass: IrClass) =
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder
import org.jetbrains.kotlin.backend.jvm.ir.irArray import org.jetbrains.kotlin.backend.jvm.ir.irArray
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibilities
@@ -150,7 +150,7 @@ private class FunctionNVarargBridgeLowering(val context: JvmBackendContext) :
val fqName = clazz.parent.safeAs<IrPackageFragment>()?.fqName ?: return false val fqName = clazz.parent.safeAs<IrPackageFragment>()?.fqName ?: return false
return when { return when {
name.startsWith("Function") -> name.startsWith("Function") ->
fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME || fqName == FUNCTIONS_PACKAGE_FQ_NAME fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME || fqName == FUNCTIONS_PACKAGE_FQ_NAME
name.startsWith("KFunction") -> name.startsWith("KFunction") ->
fqName == REFLECT_PACKAGE_FQ_NAME fqName == REFLECT_PACKAGE_FQ_NAME
else -> false else -> false
@@ -169,11 +169,11 @@ private class FunctionNVarargBridgeLowering(val context: JvmBackendContext) :
} }
private val FUNCTIONS_PACKAGE_FQ_NAME = private val FUNCTIONS_PACKAGE_FQ_NAME =
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
.child(Name.identifier("jvm")) .child(Name.identifier("jvm"))
.child(Name.identifier("functions")) .child(Name.identifier("functions"))
private val REFLECT_PACKAGE_FQ_NAME = private val REFLECT_PACKAGE_FQ_NAME =
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
.child(Name.identifier("reflect")) .child(Name.identifier("reflect"))
} }
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.* import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.*
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.IrStatement
@@ -40,7 +41,6 @@ import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
val jvmInlineClassPhase = makeIrFilePhase( val jvmInlineClassPhase = makeIrFilePhase(
@@ -398,7 +398,7 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
?: return false ?: return false
// Before version 1.4, we cannot rely on the Result.equals-impl0 method // Before version 1.4, we cannot rely on the Result.equals-impl0 method
return (leftClass.fqNameWhenAvailable != DescriptorUtils.RESULT_FQ_NAME) || return (leftClass.fqNameWhenAvailable != KotlinBuiltInsNames.RESULT_FQ_NAME) ||
context.state.languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 context.state.languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4
} }
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.backend.jvm.ir.IrArrayBuilder
import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder
import org.jetbrains.kotlin.backend.jvm.ir.irArray import org.jetbrains.kotlin.backend.jvm.ir.irArray
import org.jetbrains.kotlin.backend.jvm.ir.irArrayOf import org.jetbrains.kotlin.backend.jvm.ir.irArrayOf
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.builtins.UnsignedType import org.jetbrains.kotlin.builtins.UnsignedType
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
@@ -106,7 +106,7 @@ private class VarargLowering(val context: JvmBackendContext) : FileLoweringPass,
private val IrFunctionSymbol.isEmptyArray: Boolean private val IrFunctionSymbol.isEmptyArray: Boolean
get() = owner.name.asString() == "emptyArray" && get() = owner.name.asString() == "emptyArray" &&
(owner.parent as? IrPackageFragment)?.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME (owner.parent as? IrPackageFragment)?.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
companion object { companion object {
private val PRIMITIVE_ARRAY_OF_NAMES: Set<String> = private val PRIMITIVE_ARRAY_OF_NAMES: Set<String> =
@@ -122,7 +122,7 @@ private class VarargLowering(val context: JvmBackendContext) : FileLoweringPass,
is IrPackageFragment -> directParent is IrPackageFragment -> directParent
else -> return false else -> return false
} }
return parent.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME && return parent.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME &&
name.asString().let { it in PRIMITIVE_ARRAY_OF_NAMES || it == ARRAY_OF_NAME } && name.asString().let { it in PRIMITIVE_ARRAY_OF_NAMES || it == ARRAY_OF_NAME } &&
extensionReceiverParameter == null && extensionReceiverParameter == null &&
dispatchReceiverParameter == null && dispatchReceiverParameter == null &&
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.backend.jvm.lower.inlineclasses package org.jetbrains.kotlin.backend.jvm.lower.inlineclasses
import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.codegen.state.md5base64 import org.jetbrains.kotlin.codegen.state.md5base64
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrStatementOriginImpl import org.jetbrains.kotlin.ir.expressions.IrStatementOriginImpl
@@ -13,7 +14,6 @@ import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
/** /**
* Replace inline classes by their underlying types. * Replace inline classes by their underlying types.
@@ -114,7 +114,7 @@ object InlineClassAbi {
internal val IrType.requiresMangling: Boolean internal val IrType.requiresMangling: Boolean
get() { get() {
val irClass = erasedUpperBound val irClass = erasedUpperBound
return irClass.isInline && irClass.fqNameWhenAvailable != DescriptorUtils.RESULT_FQ_NAME return irClass.isInline && irClass.fqNameWhenAvailable != KotlinBuiltInsNames.RESULT_FQ_NAME
} }
internal val IrFunction.fullValueParameterList: List<IrValueParameter> internal val IrFunction.fullValueParameterList: List<IrValueParameter>
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.psi2ir.transformations package org.jetbrains.kotlin.psi2ir.transformations
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.isFunctionType import org.jetbrains.kotlin.builtins.isFunctionType
import org.jetbrains.kotlin.builtins.isSuspendFunctionType import org.jetbrains.kotlin.builtins.isSuspendFunctionType
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
@@ -451,7 +452,7 @@ internal class InsertImplicitCasts(
// There are several such functions (one for each built-in integer type: Byte, Short, Int, Long), // There are several such functions (one for each built-in integer type: Byte, Short, Int, Long),
// we need one that takes Int. // we need one that takes Int.
val coercionFunction = targetType.constructor.declarationDescriptor!!.module val coercionFunction = targetType.constructor.declarationDescriptor!!.module
.getPackage(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) .getPackage(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME)
.memberScope.getContributedFunctions(Name.identifier(coercionFunName), NoLookupLocation.FROM_BACKEND) .memberScope.getContributedFunctions(Name.identifier(coercionFunName), NoLookupLocation.FROM_BACKEND)
.find { .find {
val extensionReceiver = it.extensionReceiverParameter val extensionReceiver = it.extensionReceiverParameter
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.ir.descriptors package org.jetbrains.kotlin.ir.descriptors
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.ir.types package org.jetbrains.kotlin.ir.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
@@ -202,10 +202,10 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
override fun SimpleTypeMarker.asArgumentList() = this as IrSimpleType override fun SimpleTypeMarker.asArgumentList() = this as IrSimpleType
override fun TypeConstructorMarker.isAnyConstructor(): Boolean = override fun TypeConstructorMarker.isAnyConstructor(): Boolean =
this is IrClassSymbol && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.any) this is IrClassSymbol && isClassWithFqName(KotlinBuiltInsNames.FqNames.any)
override fun TypeConstructorMarker.isNothingConstructor(): Boolean = override fun TypeConstructorMarker.isNothingConstructor(): Boolean =
this is IrClassSymbol && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.nothing) this is IrClassSymbol && isClassWithFqName(KotlinBuiltInsNames.FqNames.nothing)
override fun SimpleTypeMarker.isSingleClassifierType() = true override fun SimpleTypeMarker.isSingleClassifierType() = true
@@ -246,7 +246,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
override fun SimpleTypeMarker.isExtensionFunction(): Boolean { override fun SimpleTypeMarker.isExtensionFunction(): Boolean {
require(this is IrSimpleType) require(this is IrSimpleType)
return this.hasAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType) return this.hasAnnotation(KotlinBuiltInsNames.FqNames.extensionFunctionType)
} }
override fun SimpleTypeMarker.typeDepth(): Int { override fun SimpleTypeMarker.typeDepth(): Int {
@@ -364,7 +364,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
while (true) { while (true) {
val parent = declaration.parent val parent = declaration.parent
if (parent is IrPackageFragment) { if (parent is IrPackageFragment) {
return parent.fqName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME) return parent.fqName.startsWith(KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME)
} }
declaration = parent as? IrDeclaration ?: return false declaration = parent as? IrDeclaration ?: return false
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.ir.types package org.jetbrains.kotlin.ir.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.symbols.FqNameEqualityChecker import org.jetbrains.kotlin.ir.symbols.FqNameEqualityChecker
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
@@ -47,7 +47,7 @@ fun IrType.isNullable(): Boolean =
} }
val IrType.isBoxedArray: Boolean val IrType.isBoxedArray: Boolean
get() = classOrNull?.owner?.fqNameWhenAvailable == KotlinBuiltIns.FQ_NAMES.array.toSafe() get() = classOrNull?.owner?.fqNameWhenAvailable == KotlinBuiltInsNames.FqNames.array.toSafe()
fun IrType.getArrayElementType(irBuiltIns: IrBuiltIns): IrType = fun IrType.getArrayElementType(irBuiltIns: IrBuiltIns): IrType =
if (isBoxedArray) if (isBoxedArray)
@@ -5,13 +5,12 @@
package org.jetbrains.kotlin.ir.types package org.jetbrains.kotlin.ir.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.resolve.DescriptorUtils
private fun IrType.isNotNullClassType(fqName: FqNameUnsafe) = isClassType(fqName, hasQuestionMark = false) private fun IrType.isNotNullClassType(fqName: FqNameUnsafe) = isClassType(fqName, hasQuestionMark = false)
private fun IrType.isNullableClassType(fqName: FqNameUnsafe) = isClassType(fqName, hasQuestionMark = true) private fun IrType.isNullableClassType(fqName: FqNameUnsafe) = isClassType(fqName, hasQuestionMark = true)
@@ -33,42 +32,42 @@ private fun classFqNameEquals(symbol: IrClassSymbol, fqName: FqNameUnsafe): Bool
private fun classFqNameEquals(declaration: IrClass, fqName: FqNameUnsafe): Boolean = private fun classFqNameEquals(declaration: IrClass, fqName: FqNameUnsafe): Boolean =
declaration.name == fqName.shortName() && fqName == declaration.fqNameWhenAvailable?.toUnsafe() declaration.name == fqName.shortName() && fqName == declaration.fqNameWhenAvailable?.toUnsafe()
fun IrType.isAny(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.any) fun IrType.isAny(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.any)
fun IrType.isNullableAny(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.any) fun IrType.isNullableAny(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.any)
fun IrType.isString(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.string) fun IrType.isString(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.string)
fun IrType.isNullableString(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.string) fun IrType.isNullableString(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.string)
fun IrType.isStringClassType(): Boolean = isClassType(KotlinBuiltIns.FQ_NAMES.string) fun IrType.isStringClassType(): Boolean = isClassType(KotlinBuiltInsNames.FqNames.string)
fun IrType.isArray(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.array) fun IrType.isArray(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.array)
fun IrType.isNullableArray(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.array) fun IrType.isNullableArray(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.array)
fun IrType.isCollection(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.collection.toUnsafe()) fun IrType.isCollection(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.collection.toUnsafe())
fun IrType.isNothing(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.nothing) fun IrType.isNothing(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.nothing)
fun IrType.isKClass(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.kClass) fun IrType.isKClass(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.kClass)
fun IrType.isPrimitiveType(): Boolean = KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType.keys.any { isNotNullClassType(it) } fun IrType.isPrimitiveType(): Boolean = KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType.keys.any { isNotNullClassType(it) }
fun IrType.isNullablePrimitiveType(): Boolean = KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType.keys.any { isNullableClassType(it) } fun IrType.isNullablePrimitiveType(): Boolean = KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType.keys.any { isNullableClassType(it) }
fun IrType.isMarkedNullable() = (this as? IrSimpleType)?.hasQuestionMark ?: false fun IrType.isMarkedNullable() = (this as? IrSimpleType)?.hasQuestionMark ?: false
fun IrType.isUnit() = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.unit) fun IrType.isUnit() = isNotNullClassType(KotlinBuiltInsNames.FqNames.unit)
fun IrType.isBoolean(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._boolean) fun IrType.isBoolean(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._boolean)
fun IrType.isChar(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._char) fun IrType.isChar(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._char)
fun IrType.isByte(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._byte) fun IrType.isByte(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._byte)
fun IrType.isShort(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._short) fun IrType.isShort(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._short)
fun IrType.isInt(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._int) fun IrType.isInt(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._int)
fun IrType.isLong(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._long) fun IrType.isLong(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._long)
fun IrType.isUByte(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uByteFqName.toUnsafe()) fun IrType.isUByte(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uByteFqName.toUnsafe())
fun IrType.isUShort(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uShortFqName.toUnsafe()) fun IrType.isUShort(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uShortFqName.toUnsafe())
fun IrType.isUInt(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uIntFqName.toUnsafe()) fun IrType.isUInt(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uIntFqName.toUnsafe())
fun IrType.isULong(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uLongFqName.toUnsafe()) fun IrType.isULong(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uLongFqName.toUnsafe())
fun IrType.isFloat(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._float) fun IrType.isFloat(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._float)
fun IrType.isDouble(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._double) fun IrType.isDouble(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._double)
fun IrType.isNumber(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.number) fun IrType.isNumber(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.number)
fun IrType.isComparable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.comparable.toUnsafe()) fun IrType.isComparable(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.comparable.toUnsafe())
fun IrType.isCharSequence(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.charSequence) fun IrType.isCharSequence(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.charSequence)
fun IrType.isIterable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.iterable.toUnsafe()) fun IrType.isIterable(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.iterable.toUnsafe())
fun IrType.isSequence(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.sequences.Sequence")) fun IrType.isSequence(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.sequences.Sequence"))
fun IrType.isBooleanArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.BooleanArray")) fun IrType.isBooleanArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.BooleanArray"))
@@ -80,5 +79,5 @@ fun IrType.isLongArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.Long
fun IrType.isFloatArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.FloatArray")) fun IrType.isFloatArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.FloatArray"))
fun IrType.isDoubleArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.DoubleArray")) fun IrType.isDoubleArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.DoubleArray"))
fun IrType.isKotlinResult(): Boolean = isNotNullClassType(DescriptorUtils.RESULT_FQ_NAME.toUnsafe()) fun IrType.isKotlinResult(): Boolean = isNotNullClassType(KotlinBuiltInsNames.RESULT_FQ_NAME.toUnsafe())
fun IrType.isNullableContinuation(): Boolean = isNullableClassType(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.toUnsafe()) fun IrType.isNullableContinuation(): Boolean = isNullableClassType(KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.toUnsafe())
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.asJava.elements.KotlinLightTypeParameterListBuilder
import org.jetbrains.kotlin.asJava.elements.KtLightMethod import org.jetbrains.kotlin.asJava.elements.KtLightMethod
import org.jetbrains.kotlin.asJava.elements.psiType import org.jetbrains.kotlin.asJava.elements.psiType
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.JvmCodegenUtil import org.jetbrains.kotlin.codegen.JvmCodegenUtil
@@ -35,8 +36,8 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
@@ -316,7 +317,7 @@ internal fun KtModifierListOwner.isHiddenByDeprecation(support: KtUltraLightSupp
annotation.looksLikeDeprecated() annotation.looksLikeDeprecated()
} }
if (annotations.isNotEmpty()) { // some candidates found if (annotations.isNotEmpty()) { // some candidates found
val deprecated = support.findAnnotation(this, KotlinBuiltIns.FQ_NAMES.deprecated)?.second val deprecated = support.findAnnotation(this, KotlinBuiltInsNames.FqNames.deprecated)?.second
return (deprecated?.argumentValue("level") as? EnumValue)?.enumEntryName?.asString() == "HIDDEN" return (deprecated?.argumentValue("level") as? EnumValue)?.enumEntryName?.asString() == "HIDDEN"
} else { } else {
return false return false
@@ -361,7 +362,7 @@ internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = nu
val modifierList = this.modifierList ?: return false val modifierList = this.modifierList ?: return false
if (modifierList.annotationEntries.isEmpty()) return false if (modifierList.annotationEntries.isEmpty()) return false
val deprecatedFqName = KotlinBuiltIns.FQ_NAMES.deprecated val deprecatedFqName = KotlinBuiltInsNames.FqNames.deprecated
val deprecatedName = deprecatedFqName.shortName().asString() val deprecatedName = deprecatedFqName.shortName().asString()
for (annotationEntry in modifierList.annotationEntries) { for (annotationEntry in modifierList.annotationEntries) {
@@ -374,7 +375,7 @@ internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = nu
if (fqName.asString() == deprecatedName) return true if (fqName.asString() == deprecatedName) return true
} }
return support?.findAnnotation(this, KotlinBuiltIns.FQ_NAMES.deprecated) !== null return support?.findAnnotation(this, KotlinBuiltInsNames.FqNames.deprecated) !== null
} }
private fun toQualifiedName(userType: KtUserType): FqName? { private fun toQualifiedName(userType: KtUserType): FqName? {
@@ -13,7 +13,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNameValuePair import com.intellij.psi.PsiNameValuePair
import org.jetbrains.kotlin.asJava.classes.KtUltraLightSimpleAnnotation import org.jetbrains.kotlin.asJava.classes.KtUltraLightSimpleAnnotation
import org.jetbrains.kotlin.asJava.classes.KtUltraLightSupport import org.jetbrains.kotlin.asJava.classes.KtUltraLightSupport
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.ArrayValue
@@ -64,7 +64,7 @@ private val targetMapping = hashMapOf(
internal fun PsiAnnotation.tryConvertAsTarget(support: KtUltraLightSupport): KtLightAbstractAnnotation? { internal fun PsiAnnotation.tryConvertAsTarget(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
if (FQ_NAMES.target.asString() != qualifiedName) return null if (FqNames.target.asString() != qualifiedName) return null
val attributeValues = extractArrayAnnotationFqNames("allowedTargets") val attributeValues = extractArrayAnnotationFqNames("allowedTargets")
?: extractAnnotationFqName("value")?.let { listOf(it) } ?: extractAnnotationFqName("value")?.let { listOf(it) }
@@ -101,7 +101,7 @@ internal fun createRetentionRuntimeAnnotation(support: KtUltraLightSupport, pare
internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport): KtLightAbstractAnnotation? { internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
if (FQ_NAMES.retention.asString() != qualifiedName) return null if (FqNames.retention.asString() != qualifiedName) return null
val convertedValue = extractAnnotationFqName("value") val convertedValue = extractAnnotationFqName("value")
?.let { retentionMapping[it] } ?.let { retentionMapping[it] }
@@ -118,7 +118,7 @@ internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport):
internal fun PsiAnnotation.tryConvertAsMustBeDocumented(support: KtUltraLightSupport): KtLightAbstractAnnotation? { internal fun PsiAnnotation.tryConvertAsMustBeDocumented(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
if (FQ_NAMES.mustBeDocumented.asString() != qualifiedName) return null if (FqNames.mustBeDocumented.asString() != qualifiedName) return null
return KtUltraLightSimpleAnnotation( return KtUltraLightSimpleAnnotation(
JAVA_LANG_ANNOTATION_DOCUMENTED, JAVA_LANG_ANNOTATION_DOCUMENTED,
@@ -126,4 +126,4 @@ internal fun PsiAnnotation.tryConvertAsMustBeDocumented(support: KtUltraLightSup
support, support,
parent parent
) )
} }
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.KtNodeTypes; import org.jetbrains.kotlin.KtNodeTypes;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.kdoc.psi.api.KDocElement; import org.jetbrains.kotlin.kdoc.psi.api.KDocElement;
import org.jetbrains.kotlin.lexer.KtToken; import org.jetbrains.kotlin.lexer.KtToken;
import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.lexer.KtTokens;
@@ -178,7 +178,7 @@ public class KtPsiUtil {
List<KtAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries(); List<KtAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
for (KtAnnotationEntry annotation : annotationEntries) { for (KtAnnotationEntry annotation : annotationEntries) {
Name shortName = annotation.getShortName(); Name shortName = annotation.getShortName();
if (KotlinBuiltIns.FQ_NAMES.deprecated.shortName().equals(shortName)) { if (KotlinBuiltInsNames.FqNames.deprecated.shortName().equals(shortName)) {
return true; return true;
} }
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.resolve.calls.components package org.jetbrains.kotlin.resolve.calls.components
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
@@ -130,7 +130,7 @@ class PostponedArgumentsAnalyzer(
val convertedAnnotations = lambda.expectedType?.annotations?.let { annotations -> val convertedAnnotations = lambda.expectedType?.annotations?.let { annotations ->
if (receiver != null || expectedReceiver == null) annotations if (receiver != null || expectedReceiver == null) annotations
else FilteredAnnotations(annotations, true) { it != KotlinBuiltIns.FQ_NAMES.extensionFunctionType } else FilteredAnnotations(annotations, true) { it != KotlinBuiltInsNames.FqNames.extensionFunctionType }
} }
val returnArgumentsAnalysisResult = resolutionCallbacks.analyzeAndGetLambdaReturnArguments( val returnArgumentsAnalysisResult = resolutionCallbacks.analyzeAndGetLambdaReturnArguments(
@@ -218,4 +218,4 @@ class PostponedArgumentsAnalyzer(
private inline fun <T> UnwrappedType?.forFunctionalType(f: UnwrappedType.() -> T?): T? { private inline fun <T> UnwrappedType?.forFunctionalType(f: UnwrappedType.() -> T?): T? {
return if (this?.isBuiltinFunctionalType == true) f(this) else null return if (this?.isBuiltinFunctionalType == true) f(this) else null
} }
} }
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.results
import gnu.trove.THashSet import gnu.trove.THashSet
import gnu.trove.TObjectHashingStrategy import gnu.trove.TObjectHashingStrategy
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
@@ -309,10 +310,10 @@ open class OverloadingConflictResolver<C : Any>(
val isGeneralUnsigned = UnsignedTypes.isUnsignedType(general) val isGeneralUnsigned = UnsignedTypes.isUnsignedType(general)
return when { return when {
isSpecificUnsigned && isGeneralUnsigned -> { isSpecificUnsigned && isGeneralUnsigned -> {
val uLong = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uLong)?.defaultType ?: return false val uLong = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uLong)?.defaultType ?: return false
val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt)?.defaultType ?: return false val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uInt)?.defaultType ?: return false
val uByte = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uByte)?.defaultType ?: return false val uByte = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uByte)?.defaultType ?: return false
val uShort = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uShort)?.defaultType ?: return false val uShort = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uShort)?.defaultType ?: return false
isNonSubtypeNotLessSpecific(specific, general, _double, _float, uLong, uInt, uByte, uShort) isNonSubtypeNotLessSpecific(specific, general, _double, _float, uLong, uInt, uByte, uShort)
} }
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.resolve.calls.util package org.jetbrains.kotlin.resolve.calls.util
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.SINCE_KOTLIN_FQ_NAME import org.jetbrains.kotlin.resolve.SINCE_KOTLIN_FQ_NAME
private val kotlin: FqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME private val kotlin: FqName = KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
private val kotlinText: FqName = KotlinBuiltIns.TEXT_PACKAGE_FQ_NAME private val kotlinText: FqName = KotlinBuiltInsNames.TEXT_PACKAGE_FQ_NAME
private val kotlinCollections: FqName = KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME private val kotlinCollections: FqName = KotlinBuiltInsNames.COLLECTIONS_PACKAGE_FQ_NAME
private val kotlinStreams: FqName = kotlin.child(Name.identifier("streams")) private val kotlinStreams: FqName = kotlin.child(Name.identifier("streams"))
private val use: Name = Name.identifier("use") private val use: Name = Name.identifier("use")
@@ -43,7 +43,7 @@ private val remove: Name = Name.identifier("remove")
fun CallableDescriptor.isLowPriorityFromStdlibJre7Or8(): Boolean { fun CallableDescriptor.isLowPriorityFromStdlibJre7Or8(): Boolean {
val containingPackage = containingDeclaration as? PackageFragmentDescriptor ?: return false val containingPackage = containingDeclaration as? PackageFragmentDescriptor ?: return false
val packageFqName = containingPackage.fqName val packageFqName = containingPackage.fqName
if (!packageFqName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return false if (!packageFqName.startsWith(KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME)) return false
val isFromStdlibJre7Or8 = val isFromStdlibJre7Or8 =
packageFqName == kotlin && name == use || packageFqName == kotlin && name == use ||
@@ -5,16 +5,16 @@
package org.jetbrains.kotlin package org.jetbrains.kotlin
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
// Add the directive `// WITH_COROUTINES` to use these helpers in codegen tests (see TestFiles.java). // Add the directive `// WITH_COROUTINES` to use these helpers in codegen tests (see TestFiles.java).
fun createTextForCoroutineHelpers(isReleaseCoroutines: Boolean, checkStateMachine: Boolean, checkTailCallOptimization: Boolean): String { fun createTextForCoroutineHelpers(isReleaseCoroutines: Boolean, checkStateMachine: Boolean, checkTailCallOptimization: Boolean): String {
val coroutinesPackage = val coroutinesPackage =
if (isReleaseCoroutines) if (isReleaseCoroutines)
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString() KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString()
else else
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
val emptyContinuationBody = val emptyContinuationBody =
if (isReleaseCoroutines) if (isReleaseCoroutines)
@@ -197,4 +197,4 @@ fun createTextForCodegenTestHelpers(backend: TargetBackend) =
|package helpers |package helpers
| |
|fun isIR() = ${backend.isIR} |fun isIR() = ${backend.isIR}
""".trimMargin() """.trimMargin()
@@ -15,6 +15,7 @@ import junit.framework.TestCase
import org.jetbrains.kotlin.TestsCompilerError import org.jetbrains.kotlin.TestsCompilerError
import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector
@@ -125,7 +126,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
val languageVersionSettings = val languageVersionSettings =
if (coroutinesPackage.isNotEmpty()) { if (coroutinesPackage.isNotEmpty()) {
val isExperimental = coroutinesPackage == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() val isExperimental = coroutinesPackage == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
CompilerTestLanguageVersionSettings( CompilerTestLanguageVersionSettings(
DEFAULT_DIAGNOSTIC_TESTS_FEATURES, DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
if (isExperimental) ApiVersion.KOTLIN_1_2 else ApiVersion.KOTLIN_1_3, if (isExperimental) ApiVersion.KOTLIN_1_2 else ApiVersion.KOTLIN_1_3,
@@ -4,7 +4,7 @@
*/ */
package org.jetbrains.kotlin.checkers package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.ConfigurationKind
import java.io.File import java.io.File
@@ -16,6 +16,6 @@ abstract class AbstractDiagnosticsTestWithStdLib : AbstractDiagnosticsTest() {
override fun shouldValidateFirTestData(testDataFile: File): Boolean { override fun shouldValidateFirTestData(testDataFile: File): Boolean {
val path = testDataFile.absolutePath val path = testDataFile.absolutePath
return !path.endsWith(".kts") && coroutinesPackage != DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() return !path.endsWith(".kts") && coroutinesPackage != KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
} }
} }
@@ -4,6 +4,7 @@
*/ */
package org.jetbrains.kotlin.checkers package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -11,7 +12,6 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.Companion.cre
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.parsing.KotlinParserDefinition import org.jetbrains.kotlin.parsing.KotlinParserDefinition
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.script.loadScriptingPlugin import org.jetbrains.kotlin.script.loadScriptingPlugin
import org.jetbrains.kotlin.test.* import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.TestFiles.TestFileFactory import org.jetbrains.kotlin.test.TestFiles.TestFileFactory
@@ -86,8 +86,8 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
if (InTextDirectivesUtils.isDirectiveDefined(fileText, "STDLIB_JDK8")) { if (InTextDirectivesUtils.isDirectiveDefined(fileText, "STDLIB_JDK8")) {
result.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8()) result.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8())
} }
if (DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage || if (KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage ||
fileText.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()) fileText.contains(KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())
) { ) {
result.add(ForTestCompileRuntime.coroutinesCompatForTests()) result.add(ForTestCompileRuntime.coroutinesCompatForTests())
} }
@@ -158,4 +158,4 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
return file.name.endsWith(KotlinParserDefinition.STD_SCRIPT_EXT) return file.name.endsWith(KotlinParserDefinition.STD_SCRIPT_EXT)
} }
} }
} }
@@ -11,10 +11,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.TestsRuntimeError; import org.jetbrains.kotlin.TestsRuntimeError;
import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.codegen.ir.AbstractFirBlackBoxCodegenTest; import org.jetbrains.kotlin.codegen.ir.AbstractFirBlackBoxCodegenTest;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil; import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.InTextDirectivesUtils;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
@@ -69,7 +69,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
if (!InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "CHECK_BYTECODE_LISTING")) return; if (!InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "CHECK_BYTECODE_LISTING")) return;
String suffix = String suffix =
(coroutinesPackage.equals(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()) || coroutinesPackage.isEmpty()) (coroutinesPackage.equals(KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()) || coroutinesPackage.isEmpty())
&& InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "COMMON_COROUTINES_TEST") && InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "COMMON_COROUTINES_TEST")
? "_1_2" : ? "_1_2" :
getBackend().isIR() ? "_ir" : ""; getBackend().isIR() ? "_ir" : "";
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.codegen package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import org.jetbrains.kotlin.utils.sure import org.jetbrains.kotlin.utils.sure
@@ -21,7 +21,7 @@ abstract class AbstractBytecodeListingTest : CodegenTestCase() {
val prefixes = when { val prefixes = when {
backend.isIR -> listOf("_ir", "_1_3", "") backend.isIR -> listOf("_ir", "_1_3", "")
coroutinesPackage == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString() -> listOf("_1_3", "") coroutinesPackage == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString() -> listOf("_1_3", "")
else -> listOf("") else -> listOf("")
} }
@@ -22,7 +22,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.analyzer.AnalysisResult; import org.jetbrains.kotlin.analyzer.AnalysisResult;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.diagnostics.Diagnostic;
@@ -346,7 +346,7 @@ public abstract class ExpectedResolveData {
FqName fqName = FqName fqName =
nameOrFqName.contains(".") nameOrFqName.contains(".")
? new FqName(nameOrFqName) ? new FqName(nameOrFqName)
: KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(nameOrFqName)); : KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(nameOrFqName));
ClassDescriptor expectedClass = DescriptorUtilKt.resolveClassByFqName(module, fqName, NoLookupLocation.FROM_TEST); ClassDescriptor expectedClass = DescriptorUtilKt.resolveClassByFqName(module, fqName, NoLookupLocation.FROM_TEST);
assertNotNull("Expected class not found: " + nameOrFqName, expectedClass); assertNotNull("Expected class not found: " + nameOrFqName, expectedClass);
@@ -6,7 +6,10 @@
package org.jetbrains.kotlin.serialization.builtins package org.jetbrains.kotlin.serialization.builtins
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.* import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COLLECTIONS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.RANGES_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.renderer.AnnotationArgumentsRenderingPolicy import org.jetbrains.kotlin.renderer.AnnotationArgumentsRenderingPolicy
@@ -53,7 +56,7 @@ abstract class AbstractBuiltInsWithJDKMembersTest : KotlinTestWithEnvironment()
verbose = true verbose = true
annotationArgumentsRenderingPolicy = AnnotationArgumentsRenderingPolicy.UNLESS_EMPTY annotationArgumentsRenderingPolicy = AnnotationArgumentsRenderingPolicy.UNLESS_EMPTY
modifiers = DescriptorRendererModifier.ALL modifiers = DescriptorRendererModifier.ALL
excludedTypeAnnotationClasses = setOf(FQ_NAMES.unsafeVariance) excludedTypeAnnotationClasses = setOf(KotlinBuiltInsNames.FqNames.unsafeVariance)
} }
) )
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test
import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableMap
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings
import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
@@ -15,7 +16,6 @@ import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.JvmTarget.Companion.fromString import org.jetbrains.kotlin.config.JvmTarget.Companion.fromString
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import java.io.File import java.io.File
import java.lang.reflect.Field import java.lang.reflect.Field
@@ -239,12 +239,12 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
} }
if (directives.contains("COMMON_COROUTINES_TEST")) { if (directives.contains("COMMON_COROUTINES_TEST")) {
assert(!directives.contains("COROUTINES_PACKAGE")) { "Must replace COROUTINES_PACKAGE prior to tests compilation" } assert(!directives.contains("COROUTINES_PACKAGE")) { "Must replace COROUTINES_PACKAGE prior to tests compilation" }
if (DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage) { if (KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage) {
disableReleaseCoroutines = true disableReleaseCoroutines = true
includeCompatExperimentalCoroutines = true includeCompatExperimentalCoroutines = true
} }
} }
if (content.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())) { if (content.contains(KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())) {
includeCompatExperimentalCoroutines = true includeCompatExperimentalCoroutines = true
} }
val fileLanguageVersionSettings: LanguageVersionSettings? = parseLanguageVersionSettings(directives) val fileLanguageVersionSettings: LanguageVersionSettings? = parseLanguageVersionSettings(directives)
@@ -319,4 +319,4 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
return TestJdkKind.MOCK_JDK return TestJdkKind.MOCK_JDK
} }
} }
} }
@@ -22,7 +22,7 @@ import kotlin.Unit;
import kotlin.text.StringsKt; import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.contracts.description.*; import org.jetbrains.kotlin.contracts.description.*;
import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.SubpackagesScope; import org.jetbrains.kotlin.descriptors.impl.SubpackagesScope;
@@ -75,7 +75,7 @@ public class RecursiveDescriptorComparator {
public static final Predicate<DeclarationDescriptor> SKIP_BUILT_INS_PACKAGES = descriptor -> { public static final Predicate<DeclarationDescriptor> SKIP_BUILT_INS_PACKAGES = descriptor -> {
if (descriptor instanceof PackageViewDescriptor) { if (descriptor instanceof PackageViewDescriptor) {
return !KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(((PackageViewDescriptor) descriptor).getFqName()); return !KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME.equals(((PackageViewDescriptor) descriptor).getFqName());
} }
return true; return true;
}; };
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator;
import java.io.File; import java.io.File;
import java.util.Collections; import java.util.Collections;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAMES; import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAMES;
public class LoadBuiltinsTest extends KotlinTestWithEnvironment { public class LoadBuiltinsTest extends KotlinTestWithEnvironment {
@Override @Override
@@ -21,7 +21,7 @@ import kotlin.Unit;
import kotlin.collections.CollectionsKt; import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.container.ComponentProvider; import org.jetbrains.kotlin.container.ComponentProvider;
import org.jetbrains.kotlin.container.DslKt; import org.jetbrains.kotlin.container.DslKt;
@@ -68,7 +68,7 @@ public class TypeUnifierTest extends KotlinTestWithEnvironment {
module = DslKt.getService(container, ModuleDescriptor.class); module = DslKt.getService(container, ModuleDescriptor.class);
builtinsImportingScope = ScopeUtilsKt.chainImportingScopes( builtinsImportingScope = ScopeUtilsKt.chainImportingScopes(
CollectionsKt.map(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAMES, CollectionsKt.map(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAMES,
fqName -> ScopeUtilsKt.memberScopeAsImportingScope(module.getPackage(fqName).getMemberScope())), null); fqName -> ScopeUtilsKt.memberScopeAsImportingScope(module.getPackage(fqName).getMemberScope())), null);
typeResolver = DslKt.getService(container, TypeResolver.class); typeResolver = DslKt.getService(container, TypeResolver.class);
x = createTypeVariable("X"); x = createTypeVariable("X");
@@ -16,12 +16,12 @@
package org.jetbrains.kotlin.types package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
fun ModuleDescriptor.builtInPackageAsLexicalScope(): LexicalScope.Base { fun ModuleDescriptor.builtInPackageAsLexicalScope(): LexicalScope.Base {
val packageView = getPackage(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) val packageView = getPackage(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME)
return LexicalScope.Base(packageView.memberScope.memberScopeAsImportingScope(), this) return LexicalScope.Base(packageView.memberScope.memberScopeAsImportingScope(), this)
} }
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.backend.common.serialization.metadata package org.jetbrains.kotlin.backend.common.serialization.metadata
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
@@ -25,7 +25,7 @@ class KlibMetadataStringTable : StringTableImpl() {
superClassifiers[0].classId superClassifiers[0].classId
} else { } else {
val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) } val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) }
superClass?.classId ?: ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.any.toSafe()) superClass?.classId ?: ClassId.topLevel(KotlinBuiltInsNames.FqNames.any.toSafe())
} }
} else { } else {
super.getLocalClassIdReplacement(descriptor) super.getLocalClassIdReplacement(descriptor)
@@ -0,0 +1,208 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.builtins
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.newHashMapWithExpectedSize
import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize
@Suppress("Reformat")
object KotlinBuiltInsNames {
// --------------------------- From DescriptorUtils ---------------------------
@JvmField val ENUM_VALUES = Name.identifier("values")
@JvmField val ENUM_VALUE_OF = Name.identifier("valueOf")
@JvmField val COROUTINES_PACKAGE_FQ_NAME_RELEASE = FqName("kotlin.coroutines")
@JvmField val COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL = COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("experimental"))
@JvmField val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL = COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("intrinsics"))
@JvmField val CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL = COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("Continuation"))
@JvmField val CONTINUATION_INTERFACE_FQ_NAME_RELEASE = COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("Continuation"))
@JvmField val RESULT_FQ_NAME = FqName("kotlin.Result")
// --------------------------- From ReflectionTypes ---------------------------
@JvmField val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect")
const val K_PROPERTY_PREFIX = "KProperty"
const val K_MUTABLE_PROPERTY_PREFIX = "KMutableProperty"
const val K_FUNCTION_PREFIX = "KFunction"
const val K_SUSPEND_FUNCTION_PREFIX = "KSuspendFunction"
@JvmField val PREFIXES = listOf(K_PROPERTY_PREFIX, K_MUTABLE_PROPERTY_PREFIX, K_FUNCTION_PREFIX, K_SUSPEND_FUNCTION_PREFIX)
// --------------------------- From KotlinBuiltIns ---------------------------
@JvmField
val BUILT_INS_PACKAGE_NAME = Name.identifier("kotlin")
@JvmField
val BUILT_INS_PACKAGE_FQ_NAME = FqName.topLevel(BUILT_INS_PACKAGE_NAME)
@JvmField
val ANNOTATION_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("annotation"))
@JvmField
val COLLECTIONS_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("collections"))
@JvmField
val RANGES_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("ranges"))
@JvmField
val TEXT_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("text"))
@JvmField
val BUILT_INS_PACKAGE_FQ_NAMES = setOf(
BUILT_INS_PACKAGE_FQ_NAME,
COLLECTIONS_PACKAGE_FQ_NAME,
RANGES_PACKAGE_FQ_NAME,
ANNOTATION_PACKAGE_FQ_NAME,
KOTLIN_REFLECT_FQ_NAME,
BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("internal")),
COROUTINES_PACKAGE_FQ_NAME_RELEASE
)
object FqNames {
@JvmField val any: FqNameUnsafe = fqNameUnsafe("Any")
@JvmField val nothing: FqNameUnsafe = fqNameUnsafe("Nothing")
@JvmField val cloneable: FqNameUnsafe = fqNameUnsafe("Cloneable")
@JvmField val suppress: FqName = fqName("Suppress")
@JvmField val unit: FqNameUnsafe = fqNameUnsafe("Unit")
@JvmField val charSequence: FqNameUnsafe = fqNameUnsafe("CharSequence")
@JvmField val string: FqNameUnsafe = fqNameUnsafe("String")
@JvmField val array: FqNameUnsafe = fqNameUnsafe("Array")
@JvmField val _boolean: FqNameUnsafe = fqNameUnsafe("Boolean")
@JvmField val _char: FqNameUnsafe = fqNameUnsafe("Char")
@JvmField val _byte: FqNameUnsafe = fqNameUnsafe("Byte")
@JvmField val _short: FqNameUnsafe = fqNameUnsafe("Short")
@JvmField val _int: FqNameUnsafe = fqNameUnsafe("Int")
@JvmField val _long: FqNameUnsafe = fqNameUnsafe("Long")
@JvmField val _float: FqNameUnsafe = fqNameUnsafe("Float")
@JvmField val _double: FqNameUnsafe = fqNameUnsafe("Double")
@JvmField val number: FqNameUnsafe = fqNameUnsafe("Number")
@JvmField val _enum: FqNameUnsafe = fqNameUnsafe("Enum")
@JvmField val functionSupertype: FqNameUnsafe = fqNameUnsafe("Function")
@JvmField val throwable: FqName = fqName("Throwable")
@JvmField val comparable: FqName = fqName("Comparable")
@JvmField val intRange: FqNameUnsafe = rangesFqName("IntRange")
@JvmField val longRange: FqNameUnsafe = rangesFqName("LongRange")
@JvmField val deprecated: FqName = fqName("Deprecated")
@JvmField val deprecatedSinceKotlin: FqName = fqName("DeprecatedSinceKotlin")
@JvmField val deprecationLevel: FqName = fqName("DeprecationLevel")
@JvmField val replaceWith: FqName = fqName("ReplaceWith")
@JvmField val extensionFunctionType: FqName = fqName("ExtensionFunctionType")
@JvmField val parameterName: FqName = fqName("ParameterName")
@JvmField val annotation: FqName = fqName("Annotation")
@JvmField val target: FqName = annotationName("Target")
@JvmField val annotationTarget: FqName = annotationName("AnnotationTarget")
@JvmField val annotationRetention: FqName = annotationName("AnnotationRetention")
@JvmField val retention: FqName = annotationName("Retention")
@JvmField val repeatable: FqName = annotationName("Repeatable")
@JvmField val mustBeDocumented: FqName = annotationName("MustBeDocumented")
@JvmField val unsafeVariance: FqName = fqName("UnsafeVariance")
@JvmField val publishedApi: FqName = fqName("PublishedApi")
@JvmField val iterator: FqName = collectionsFqName("Iterator")
@JvmField val iterable: FqName = collectionsFqName("Iterable")
@JvmField val collection: FqName = collectionsFqName("Collection")
@JvmField val list: FqName = collectionsFqName("List")
@JvmField val listIterator: FqName = collectionsFqName("ListIterator")
@JvmField val set: FqName = collectionsFqName("Set")
@JvmField val map: FqName = collectionsFqName("Map")
@JvmField val mapEntry: FqName = map.child(Name.identifier("Entry"))
@JvmField val mutableIterator: FqName = collectionsFqName("MutableIterator")
@JvmField val mutableIterable: FqName = collectionsFqName("MutableIterable")
@JvmField val mutableCollection: FqName = collectionsFqName("MutableCollection")
@JvmField val mutableList: FqName = collectionsFqName("MutableList")
@JvmField val mutableListIterator: FqName = collectionsFqName("MutableListIterator")
@JvmField val mutableSet: FqName = collectionsFqName("MutableSet")
@JvmField val mutableMap: FqName = collectionsFqName("MutableMap")
@JvmField val mutableMapEntry: FqName = mutableMap.child(Name.identifier("MutableEntry"))
@JvmField val kClass: FqNameUnsafe = reflect("KClass")
@JvmField val kCallable: FqNameUnsafe = reflect("KCallable")
@JvmField val kProperty0: FqNameUnsafe = reflect("KProperty0")
@JvmField val kProperty1: FqNameUnsafe = reflect("KProperty1")
@JvmField val kProperty2: FqNameUnsafe = reflect("KProperty2")
@JvmField val kMutableProperty0: FqNameUnsafe = reflect("KMutableProperty0")
@JvmField val kMutableProperty1: FqNameUnsafe = reflect("KMutableProperty1")
@JvmField val kMutableProperty2: FqNameUnsafe = reflect("KMutableProperty2")
@JvmField val kPropertyFqName: FqNameUnsafe = reflect("KProperty")
@JvmField val kMutablePropertyFqName: FqNameUnsafe = reflect("KMutableProperty")
@JvmField val kProperty: ClassId = ClassId.topLevel(kPropertyFqName.toSafe())
@JvmField val kDeclarationContainer: FqNameUnsafe = reflect("KDeclarationContainer")
@JvmField val uByteFqName: FqName = fqName("UByte")
@JvmField val uShortFqName: FqName = fqName("UShort")
@JvmField val uIntFqName: FqName = fqName("UInt")
@JvmField val uLongFqName: FqName = fqName("ULong")
@JvmField val uByte: ClassId = ClassId.topLevel(uByteFqName)
@JvmField val uShort: ClassId = ClassId.topLevel(uShortFqName)
@JvmField val uInt: ClassId = ClassId.topLevel(uIntFqName)
@JvmField val uLong: ClassId = ClassId.topLevel(uLongFqName)
@JvmField val primitiveTypeShortNames: Set<Name> = newHashSetWithExpectedSize<Name>(PrimitiveType.values().size).apply {
PrimitiveType.values().mapTo(this) { it.typeName }
}
@JvmField val primitiveArrayTypeShortNames: Set<Name> = newHashSetWithExpectedSize<Name>(PrimitiveType.values().size).apply {
PrimitiveType.values().mapTo(this) { it.arrayTypeName }
}
@JvmField val fqNameToPrimitiveType: Map<FqNameUnsafe, PrimitiveType> =
newHashMapWithExpectedSize<FqNameUnsafe, PrimitiveType>(PrimitiveType.values().size).apply {
for (primitiveType in PrimitiveType.values()) {
this[fqNameUnsafe(primitiveType.typeName.asString())] = primitiveType
}
}
@JvmField val arrayClassFqNameToPrimitiveType: MutableMap<FqNameUnsafe, PrimitiveType> =
newHashMapWithExpectedSize<FqNameUnsafe, PrimitiveType>(PrimitiveType.values().size).apply {
for (primitiveType in PrimitiveType.values()) {
this[fqNameUnsafe(primitiveType.arrayTypeName.asString())] = primitiveType
}
}
private fun fqNameUnsafe(simpleName: String): FqNameUnsafe {
return fqName(simpleName).toUnsafe()
}
private fun fqName(simpleName: String): FqName {
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName))
}
private fun collectionsFqName(simpleName: String): FqName {
return COLLECTIONS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName))
}
private fun rangesFqName(simpleName: String): FqNameUnsafe {
return RANGES_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)).toUnsafe()
}
@JvmStatic
fun reflect(simpleName: String): FqNameUnsafe {
return KOTLIN_REFLECT_FQ_NAME.child(Name.identifier(simpleName)).toUnsafe()
}
private fun annotationName(simpleName: String): FqName {
return ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier(simpleName))
}
}
}
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.jetbrains.kotlin.builtins package org.jetbrains.kotlin.builtins
@@ -34,9 +23,9 @@ enum class PrimitiveType(typeName: String) {
val arrayTypeName: Name = Name.identifier("${typeName}Array") val arrayTypeName: Name = Name.identifier("${typeName}Array")
val typeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(this.typeName) } val typeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME.child(this.typeName) }
val arrayTypeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(arrayTypeName) } val arrayTypeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME.child(arrayTypeName) }
companion object { companion object {
@JvmField @JvmField
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.builtins.jvm
import org.jetbrains.kotlin.builtins.CompanionObjectMapping import org.jetbrains.kotlin.builtins.CompanionObjectMapping
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
@@ -56,28 +56,28 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
} }
val mutabilityMappings = listOf( val mutabilityMappings = listOf(
mutabilityMapping<Iterable<*>>(ClassId.topLevel(FQ_NAMES.iterable), FQ_NAMES.mutableIterable), mutabilityMapping<Iterable<*>>(ClassId.topLevel(FqNames.iterable), FqNames.mutableIterable),
mutabilityMapping<Iterator<*>>(ClassId.topLevel(FQ_NAMES.iterator), FQ_NAMES.mutableIterator), mutabilityMapping<Iterator<*>>(ClassId.topLevel(FqNames.iterator), FqNames.mutableIterator),
mutabilityMapping<Collection<*>>(ClassId.topLevel(FQ_NAMES.collection), FQ_NAMES.mutableCollection), mutabilityMapping<Collection<*>>(ClassId.topLevel(FqNames.collection), FqNames.mutableCollection),
mutabilityMapping<List<*>>(ClassId.topLevel(FQ_NAMES.list), FQ_NAMES.mutableList), mutabilityMapping<List<*>>(ClassId.topLevel(FqNames.list), FqNames.mutableList),
mutabilityMapping<Set<*>>(ClassId.topLevel(FQ_NAMES.set), FQ_NAMES.mutableSet), mutabilityMapping<Set<*>>(ClassId.topLevel(FqNames.set), FqNames.mutableSet),
mutabilityMapping<ListIterator<*>>(ClassId.topLevel(FQ_NAMES.listIterator), FQ_NAMES.mutableListIterator), mutabilityMapping<ListIterator<*>>(ClassId.topLevel(FqNames.listIterator), FqNames.mutableListIterator),
mutabilityMapping<Map<*, *>>(ClassId.topLevel(FQ_NAMES.map), FQ_NAMES.mutableMap), mutabilityMapping<Map<*, *>>(ClassId.topLevel(FqNames.map), FqNames.mutableMap),
mutabilityMapping<Map.Entry<*, *>>( mutabilityMapping<Map.Entry<*, *>>(
ClassId.topLevel(FQ_NAMES.map).createNestedClassId(FQ_NAMES.mapEntry.shortName()), FQ_NAMES.mutableMapEntry ClassId.topLevel(FqNames.map).createNestedClassId(FqNames.mapEntry.shortName()), FqNames.mutableMapEntry
) )
) )
init { init {
addTopLevel(Any::class.java, FQ_NAMES.any) addTopLevel(Any::class.java, FqNames.any)
addTopLevel(String::class.java, FQ_NAMES.string) addTopLevel(String::class.java, FqNames.string)
addTopLevel(CharSequence::class.java, FQ_NAMES.charSequence) addTopLevel(CharSequence::class.java, FqNames.charSequence)
addTopLevel(Throwable::class.java, FQ_NAMES.throwable) addTopLevel(Throwable::class.java, FqNames.throwable)
addTopLevel(Cloneable::class.java, FQ_NAMES.cloneable) addTopLevel(Cloneable::class.java, FqNames.cloneable)
addTopLevel(Number::class.java, FQ_NAMES.number) addTopLevel(Number::class.java, FqNames.number)
addTopLevel(Comparable::class.java, FQ_NAMES.comparable) addTopLevel(Comparable::class.java, FqNames.comparable)
addTopLevel(Enum::class.java, FQ_NAMES._enum) addTopLevel(Enum::class.java, FqNames._enum)
addTopLevel(Annotation::class.java, FQ_NAMES.annotation) addTopLevel(Annotation::class.java, FqNames.annotation)
for (platformCollection in mutabilityMappings) { for (platformCollection in mutabilityMappings) {
addMapping(platformCollection) addMapping(platformCollection)
@@ -107,7 +107,7 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
addKotlinToJava(FqName(kSuspendFun + i), K_FUNCTION_CLASS_ID) addKotlinToJava(FqName(kSuspendFun + i), K_FUNCTION_CLASS_ID)
} }
addKotlinToJava(FQ_NAMES.nothing.toSafe(), classId(Void::class.java)) addKotlinToJava(FqNames.nothing.toSafe(), classId(Void::class.java))
} }
/** /**
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.builtins.jvm package org.jetbrains.kotlin.builtins.jvm
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.deserialization.ClassDescriptorFactory import org.jetbrains.kotlin.descriptors.deserialization.ClassDescriptorFactory
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
@@ -49,8 +49,8 @@ class JvmBuiltInClassDescriptorFactory(
} }
companion object { companion object {
private val KOTLIN_FQ_NAME = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME private val KOTLIN_FQ_NAME = KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
private val CLONEABLE_NAME = KotlinBuiltIns.FQ_NAMES.cloneable.shortName() private val CLONEABLE_NAME = KotlinBuiltInsNames.FqNames.cloneable.shortName()
val CLONEABLE_CLASS_ID = ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe()) val CLONEABLE_CLASS_ID = ClassId.topLevel(KotlinBuiltInsNames.FqNames.cloneable.toSafe())
} }
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.builtins.jvm package org.jetbrains.kotlin.builtins.jvm
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.annotations.createDeprecatedAnnotation import org.jetbrains.kotlin.descriptors.annotations.createDeprecatedAnnotation
@@ -338,7 +339,7 @@ open class JvmBuiltInsSettings(
} }
private fun isArrayOrPrimitiveArray(fqName: FqNameUnsafe): Boolean { private fun isArrayOrPrimitiveArray(fqName: FqNameUnsafe): Boolean {
return fqName == KotlinBuiltIns.FQ_NAMES.array || KotlinBuiltIns.isPrimitiveArray(fqName) return fqName == KotlinBuiltInsNames.FqNames.array || KotlinBuiltIns.isPrimitiveArray(fqName)
} }
val DROP_LIST_METHOD_SIGNATURES: Set<String> = val DROP_LIST_METHOD_SIGNATURES: Set<String> =
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.load.java package org.jetbrains.kotlin.load.java
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
object FakePureImplementationsProvider { object FakePureImplementationsProvider {
@@ -28,9 +28,9 @@ object FakePureImplementationsProvider {
} }
init { init {
FQ_NAMES.mutableList implementedWith fqNameListOf("java.util.ArrayList", "java.util.LinkedList") FqNames.mutableList implementedWith fqNameListOf("java.util.ArrayList", "java.util.LinkedList")
FQ_NAMES.mutableSet implementedWith fqNameListOf("java.util.HashSet", "java.util.TreeSet", "java.util.LinkedHashSet") FqNames.mutableSet implementedWith fqNameListOf("java.util.HashSet", "java.util.TreeSet", "java.util.LinkedHashSet")
FQ_NAMES.mutableMap implementedWith fqNameListOf( FqNames.mutableMap implementedWith fqNameListOf(
"java.util.HashMap", "java.util.TreeMap", "java.util.LinkedHashMap", "java.util.HashMap", "java.util.TreeMap", "java.util.LinkedHashMap",
"java.util.concurrent.ConcurrentHashMap", "java.util.concurrent.ConcurrentSkipListMap" "java.util.concurrent.ConcurrentHashMap", "java.util.concurrent.ConcurrentSkipListMap"
) )
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.load.java.components package org.jetbrains.kotlin.load.java.components
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
@@ -57,8 +57,8 @@ object JavaAnnotationMapper {
when (annotation.classId) { when (annotation.classId) {
ClassId.topLevel(JAVA_TARGET_FQ_NAME) -> JavaTargetAnnotationDescriptor(annotation, c) ClassId.topLevel(JAVA_TARGET_FQ_NAME) -> JavaTargetAnnotationDescriptor(annotation, c)
ClassId.topLevel(JAVA_RETENTION_FQ_NAME) -> JavaRetentionAnnotationDescriptor(annotation, c) ClassId.topLevel(JAVA_RETENTION_FQ_NAME) -> JavaRetentionAnnotationDescriptor(annotation, c)
ClassId.topLevel(JAVA_REPEATABLE_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.repeatable) ClassId.topLevel(JAVA_REPEATABLE_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.repeatable)
ClassId.topLevel(JAVA_DOCUMENTED_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.mustBeDocumented) ClassId.topLevel(JAVA_DOCUMENTED_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.mustBeDocumented)
ClassId.topLevel(JAVA_DEPRECATED_FQ_NAME) -> null ClassId.topLevel(JAVA_DEPRECATED_FQ_NAME) -> null
else -> LazyJavaAnnotationDescriptor(c, annotation) else -> LazyJavaAnnotationDescriptor(c, annotation)
} }
@@ -68,7 +68,7 @@ object JavaAnnotationMapper {
annotationOwner: JavaAnnotationOwner, annotationOwner: JavaAnnotationOwner,
c: LazyJavaResolverContext c: LazyJavaResolverContext
): AnnotationDescriptor? { ): AnnotationDescriptor? {
if (kotlinName == KotlinBuiltIns.FQ_NAMES.deprecated) { if (kotlinName == KotlinBuiltInsNames.FqNames.deprecated) {
val javaAnnotation = annotationOwner.findAnnotation(JAVA_DEPRECATED_FQ_NAME) val javaAnnotation = annotationOwner.findAnnotation(JAVA_DEPRECATED_FQ_NAME)
if (javaAnnotation != null || annotationOwner.isDeprecatedInJavaDoc) { if (javaAnnotation != null || annotationOwner.isDeprecatedInJavaDoc) {
return JavaDeprecatedAnnotationDescriptor(javaAnnotation, c) return JavaDeprecatedAnnotationDescriptor(javaAnnotation, c)
@@ -84,19 +84,19 @@ object JavaAnnotationMapper {
// kotlin.annotation.annotation is treated separately // kotlin.annotation.annotation is treated separately
private val kotlinToJavaNameMap: Map<FqName, FqName> = private val kotlinToJavaNameMap: Map<FqName, FqName> =
mapOf( mapOf(
KotlinBuiltIns.FQ_NAMES.target to JAVA_TARGET_FQ_NAME, KotlinBuiltInsNames.FqNames.target to JAVA_TARGET_FQ_NAME,
KotlinBuiltIns.FQ_NAMES.retention to JAVA_RETENTION_FQ_NAME, KotlinBuiltInsNames.FqNames.retention to JAVA_RETENTION_FQ_NAME,
KotlinBuiltIns.FQ_NAMES.repeatable to JAVA_REPEATABLE_FQ_NAME, KotlinBuiltInsNames.FqNames.repeatable to JAVA_REPEATABLE_FQ_NAME,
KotlinBuiltIns.FQ_NAMES.mustBeDocumented to JAVA_DOCUMENTED_FQ_NAME KotlinBuiltInsNames.FqNames.mustBeDocumented to JAVA_DOCUMENTED_FQ_NAME
) )
val javaToKotlinNameMap: Map<FqName, FqName> = val javaToKotlinNameMap: Map<FqName, FqName> =
mapOf( mapOf(
JAVA_TARGET_FQ_NAME to KotlinBuiltIns.FQ_NAMES.target, JAVA_TARGET_FQ_NAME to KotlinBuiltInsNames.FqNames.target,
JAVA_RETENTION_FQ_NAME to KotlinBuiltIns.FQ_NAMES.retention, JAVA_RETENTION_FQ_NAME to KotlinBuiltInsNames.FqNames.retention,
JAVA_DEPRECATED_FQ_NAME to KotlinBuiltIns.FQ_NAMES.deprecated, JAVA_DEPRECATED_FQ_NAME to KotlinBuiltInsNames.FqNames.deprecated,
JAVA_REPEATABLE_FQ_NAME to KotlinBuiltIns.FQ_NAMES.repeatable, JAVA_REPEATABLE_FQ_NAME to KotlinBuiltInsNames.FqNames.repeatable,
JAVA_DOCUMENTED_FQ_NAME to KotlinBuiltIns.FQ_NAMES.mustBeDocumented JAVA_DOCUMENTED_FQ_NAME to KotlinBuiltInsNames.FqNames.mustBeDocumented
) )
} }
@@ -119,7 +119,7 @@ open class JavaAnnotationDescriptor(
class JavaDeprecatedAnnotationDescriptor( class JavaDeprecatedAnnotationDescriptor(
annotation: JavaAnnotation?, annotation: JavaAnnotation?,
c: LazyJavaResolverContext c: LazyJavaResolverContext
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.deprecated) { ) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.deprecated) {
override val allValueArguments: Map<Name, ConstantValue<*>> by c.storageManager.createLazyValue { override val allValueArguments: Map<Name, ConstantValue<*>> by c.storageManager.createLazyValue {
mapOf(JavaAnnotationMapper.DEPRECATED_ANNOTATION_MESSAGE to StringValue("Deprecated in Java")) mapOf(JavaAnnotationMapper.DEPRECATED_ANNOTATION_MESSAGE to StringValue("Deprecated in Java"))
} }
@@ -128,7 +128,7 @@ class JavaDeprecatedAnnotationDescriptor(
class JavaTargetAnnotationDescriptor( class JavaTargetAnnotationDescriptor(
annotation: JavaAnnotation, annotation: JavaAnnotation,
c: LazyJavaResolverContext c: LazyJavaResolverContext
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.target) { ) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.target) {
override val allValueArguments by c.storageManager.createLazyValue { override val allValueArguments by c.storageManager.createLazyValue {
val targetArgument = when (firstArgument) { val targetArgument = when (firstArgument) {
is JavaArrayAnnotationArgument -> JavaAnnotationTargetMapper.mapJavaTargetArguments(firstArgument.getElements()) is JavaArrayAnnotationArgument -> JavaAnnotationTargetMapper.mapJavaTargetArguments(firstArgument.getElements())
@@ -142,7 +142,7 @@ class JavaTargetAnnotationDescriptor(
class JavaRetentionAnnotationDescriptor( class JavaRetentionAnnotationDescriptor(
annotation: JavaAnnotation, annotation: JavaAnnotation,
c: LazyJavaResolverContext c: LazyJavaResolverContext
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.retention) { ) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.retention) {
override val allValueArguments by c.storageManager.createLazyValue { override val allValueArguments by c.storageManager.createLazyValue {
val retentionArgument = JavaAnnotationTargetMapper.mapJavaRetentionArgument(firstArgument) val retentionArgument = JavaAnnotationTargetMapper.mapJavaRetentionArgument(firstArgument)
retentionArgument?.let { mapOf(JavaAnnotationMapper.RETENTION_ANNOTATION_VALUE to it) }.orEmpty() retentionArgument?.let { mapOf(JavaAnnotationMapper.RETENTION_ANNOTATION_VALUE to it) }.orEmpty()
@@ -170,12 +170,12 @@ object JavaAnnotationTargetMapper {
val kotlinTargets = arguments.filterIsInstance<JavaEnumValueAnnotationArgument>() val kotlinTargets = arguments.filterIsInstance<JavaEnumValueAnnotationArgument>()
.flatMap { mapJavaTargetArgumentByName(it.entryName?.asString()) } .flatMap { mapJavaTargetArgumentByName(it.entryName?.asString()) }
.map { kotlinTarget -> .map { kotlinTarget ->
EnumValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.annotationTarget), Name.identifier(kotlinTarget.name)) EnumValue(ClassId.topLevel(KotlinBuiltInsNames.FqNames.annotationTarget), Name.identifier(kotlinTarget.name))
} }
return ArrayValue(kotlinTargets) { module -> return ArrayValue(kotlinTargets) { module ->
val parameterDescriptor = DescriptorResolverUtils.getAnnotationParameterByName( val parameterDescriptor = DescriptorResolverUtils.getAnnotationParameterByName(
JavaAnnotationMapper.TARGET_ANNOTATION_ALLOWED_TARGETS, JavaAnnotationMapper.TARGET_ANNOTATION_ALLOWED_TARGETS,
module.builtIns.getBuiltInClassByFqName(KotlinBuiltIns.FQ_NAMES.target) module.builtIns.getBuiltInClassByFqName(KotlinBuiltInsNames.FqNames.target)
) )
parameterDescriptor?.type ?: ErrorUtils.createErrorType("Error: AnnotationTarget[]") parameterDescriptor?.type ?: ErrorUtils.createErrorType("Error: AnnotationTarget[]")
} }
@@ -191,7 +191,7 @@ object JavaAnnotationTargetMapper {
// Map argument: java.lang.annotation.Retention -> kotlin.annotation.Retention // Map argument: java.lang.annotation.Retention -> kotlin.annotation.Retention
return (element as? JavaEnumValueAnnotationArgument)?.let { return (element as? JavaEnumValueAnnotationArgument)?.let {
retentionNameList[it.entryName?.asString()]?.let { retention -> retentionNameList[it.entryName?.asString()]?.let { retention ->
EnumValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.annotationRetention), Name.identifier(retention.name)) EnumValue(ClassId.topLevel(KotlinBuiltInsNames.FqNames.annotationRetention), Name.identifier(retention.name))
} }
} }
} }
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.load.java.lazy package org.jetbrains.kotlin.load.java.lazy
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
@@ -38,7 +38,7 @@ class LazyJavaAnnotations(
override fun iterator() = override fun iterator() =
(annotationOwner.annotations.asSequence().map(annotationDescriptors) + (annotationOwner.annotations.asSequence().map(annotationDescriptors) +
JavaAnnotationMapper.findMappedJavaAnnotation( JavaAnnotationMapper.findMappedJavaAnnotation(
KotlinBuiltIns.FQ_NAMES.deprecated, KotlinBuiltInsNames.FqNames.deprecated,
annotationOwner, annotationOwner,
c c
)).filterNotNull().iterator() )).filterNotNull().iterator()
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.load.java.lazy.descriptors package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.createMappedTypeParametersSubstitution import org.jetbrains.kotlin.builtins.jvm.createMappedTypeParametersSubstitution
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
@@ -225,7 +226,7 @@ class LazyJavaClassDescriptor(
private fun getPurelyImplementedSupertype(): KotlinType? { private fun getPurelyImplementedSupertype(): KotlinType? {
val annotatedPurelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()?.takeIf { fqName -> val annotatedPurelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()?.takeIf { fqName ->
!fqName.isRoot && fqName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME) !fqName.isRoot && fqName.startsWith(KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME)
} }
val purelyImplementedFqName = val purelyImplementedFqName =
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.load.java.lazy.descriptors package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor
@@ -29,7 +30,6 @@ import org.jetbrains.kotlin.load.java.structure.JavaClass
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.DFS
@@ -46,7 +46,7 @@ class LazyJavaStaticClassScope(
declaredMemberIndex().getMethodNames().toMutableSet().apply { declaredMemberIndex().getMethodNames().toMutableSet().apply {
addAll(ownerDescriptor.getParentJavaStaticClassScope()?.getFunctionNames().orEmpty()) addAll(ownerDescriptor.getParentJavaStaticClassScope()?.getFunctionNames().orEmpty())
if (jClass.isEnum) { if (jClass.isEnum) {
addAll(listOf(DescriptorUtils.ENUM_VALUE_OF, DescriptorUtils.ENUM_VALUES)) addAll(listOf(KotlinBuiltInsNames.ENUM_VALUE_OF, KotlinBuiltInsNames.ENUM_VALUES))
} }
} }
@@ -75,8 +75,8 @@ class LazyJavaStaticClassScope(
if (jClass.isEnum) { if (jClass.isEnum) {
when (name) { when (name) {
DescriptorUtils.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(ownerDescriptor)) KotlinBuiltInsNames.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(ownerDescriptor))
DescriptorUtils.ENUM_VALUES -> result.add(createEnumValuesMethod(ownerDescriptor)) KotlinBuiltInsNames.ENUM_VALUES -> result.add(createEnumValuesMethod(ownerDescriptor))
} }
} }
} }
@@ -19,6 +19,7 @@
package org.jetbrains.kotlin.load.java package org.jetbrains.kotlin.load.java
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters
@@ -37,7 +38,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor import org.jetbrains.kotlin.resolve.descriptorUtil.propertyIfAccessor
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES
private fun FqName.child(name: String): FqName = child(Name.identifier(name)) private fun FqName.child(name: String): FqName = child(Name.identifier(name))
private fun FqNameUnsafe.childSafe(name: String): FqName = child(Name.identifier(name)).toSafe() private fun FqNameUnsafe.childSafe(name: String): FqName = child(Name.identifier(name)).toSafe()
@@ -52,14 +52,14 @@ private fun String.method(name: String, parameters: String, returnType: String)
object BuiltinSpecialProperties { object BuiltinSpecialProperties {
val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf( val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf(
BUILTIN_NAMES._enum.childSafe("name") to Name.identifier("name"), FqNames._enum.childSafe("name") to Name.identifier("name"),
BUILTIN_NAMES._enum.childSafe("ordinal") to Name.identifier("ordinal"), FqNames._enum.childSafe("ordinal") to Name.identifier("ordinal"),
BUILTIN_NAMES.collection.child("size") to Name.identifier("size"), FqNames.collection.child("size") to Name.identifier("size"),
BUILTIN_NAMES.map.child("size") to Name.identifier("size"), FqNames.map.child("size") to Name.identifier("size"),
BUILTIN_NAMES.charSequence.childSafe("length") to Name.identifier("length"), FqNames.charSequence.childSafe("length") to Name.identifier("length"),
BUILTIN_NAMES.map.child("keys") to Name.identifier("keySet"), FqNames.map.child("keys") to Name.identifier("keySet"),
BUILTIN_NAMES.map.child("values") to Name.identifier("values"), FqNames.map.child("values") to Name.identifier("values"),
BUILTIN_NAMES.map.child("entries") to Name.identifier("entrySet") FqNames.map.child("entries") to Name.identifier("entrySet")
) )
private val GETTER_JVM_NAME_TO_PROPERTIES_SHORT_NAME_MAP: Map<Name, List<Name>> = private val GETTER_JVM_NAME_TO_PROPERTIES_SHORT_NAME_MAP: Map<Name, List<Name>> =
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.load.kotlin package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
@@ -58,7 +58,7 @@ fun forceSingleValueParameterBoxing(f: CallableDescriptor): Boolean {
?: return false ?: return false
val overriddenParameterType = overridden.original.valueParameters.single().type.mapToJvmType() val overriddenParameterType = overridden.original.valueParameters.single().type.mapToJvmType()
return overridden.containingDeclaration.fqNameUnsafe == KotlinBuiltIns.FQ_NAMES.mutableCollection.toUnsafe() return overridden.containingDeclaration.fqNameUnsafe == KotlinBuiltInsNames.FqNames.mutableCollection.toUnsafe()
&& overriddenParameterType is JvmType.Object && overriddenParameterType.internalName == "java/lang/Object" && overriddenParameterType is JvmType.Object && overriddenParameterType.internalName == "java/lang/Object"
} }
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.resolve.jvm package org.jetbrains.kotlin.resolve.jvm
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
@@ -47,7 +48,7 @@ private fun KotlinType.requiresFunctionNameManglingInParameterTypes() =
isInlineClassThatRequiresMangling() || isTypeParameterWithUpperBoundThatRequiresMangling() isInlineClassThatRequiresMangling() || isTypeParameterWithUpperBoundThatRequiresMangling()
private fun isDontMangleClass(classDescriptor: ClassDescriptor) = private fun isDontMangleClass(classDescriptor: ClassDescriptor) =
classDescriptor.fqNameSafe == DescriptorUtils.RESULT_FQ_NAME classDescriptor.fqNameSafe == KotlinBuiltInsNames.RESULT_FQ_NAME
private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean { private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean {
val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false
@@ -16,8 +16,11 @@
package org.jetbrains.kotlin.descriptors.runtime.components package org.jetbrains.kotlin.descriptors.runtime.components
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.descriptors.runtime.structure.classId
import org.jetbrains.kotlin.descriptors.runtime.structure.desc
import org.jetbrains.kotlin.descriptors.runtime.structure.isEnumClassOrSpecializedEnumEntryClass
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.load.kotlin.header.ReadKotlinClassHeaderAnnotationVisitor import org.jetbrains.kotlin.load.kotlin.header.ReadKotlinClassHeaderAnnotationVisitor
@@ -28,9 +31,6 @@ import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
import java.lang.reflect.Constructor import java.lang.reflect.Constructor
import java.lang.reflect.Field import java.lang.reflect.Field
import java.lang.reflect.Method import java.lang.reflect.Method
import org.jetbrains.kotlin.descriptors.runtime.structure.classId
import org.jetbrains.kotlin.descriptors.runtime.structure.desc
import org.jetbrains.kotlin.descriptors.runtime.structure.isEnumClassOrSpecializedEnumEntryClass
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
private val TYPES_ELIGIBLE_FOR_SIMPLE_VISIT = setOf<Class<*>>( private val TYPES_ELIGIBLE_FOR_SIMPLE_VISIT = setOf<Class<*>>(
@@ -196,7 +196,7 @@ private object ReflectClassStructure {
if (currentClass.isPrimitive) { if (currentClass.isPrimitive) {
if (currentClass == Void.TYPE) { if (currentClass == Void.TYPE) {
// void.class is not representable in Kotlin, we approximate it by Unit::class // void.class is not representable in Kotlin, we approximate it by Unit::class
return ClassLiteralValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.unit.toSafe()), dimensions) return ClassLiteralValue(ClassId.topLevel(KotlinBuiltInsNames.FqNames.unit.toSafe()), dimensions)
} }
val primitiveType = JvmPrimitiveType.get(currentClass.name).primitiveType val primitiveType = JvmPrimitiveType.get(currentClass.name).primitiveType
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.descriptors.runtime.components package org.jetbrains.kotlin.descriptors.runtime.components
import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.JavaClass
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass
@@ -47,7 +47,7 @@ class ReflectKotlinClassFinder(private val classLoader: ClassLoader) : KotlinCla
override fun hasMetadataPackage(fqName: FqName): Boolean = false override fun hasMetadataPackage(fqName: FqName): Boolean = false
override fun findBuiltInsData(packageFqName: FqName): InputStream? { override fun findBuiltInsData(packageFqName: FqName): InputStream? {
if (!packageFqName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return null if (!packageFqName.startsWith(KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME)) return null
return builtInsResourceLoader.loadResource(BuiltInSerializerProtocol.getBuiltInsFilePath(packageFqName)) return builtInsResourceLoader.loadResource(BuiltInSerializerProtocol.getBuiltInsFilePath(packageFqName))
} }
@@ -25,9 +25,9 @@ import java.util.*
object CompanionObjectMapping { object CompanionObjectMapping {
private val classIds = private val classIds =
(PrimitiveType.NUMBER_TYPES.map(KotlinBuiltIns::getPrimitiveFqName) + (PrimitiveType.NUMBER_TYPES.map(KotlinBuiltIns::getPrimitiveFqName) +
KotlinBuiltIns.FQ_NAMES.string.toSafe() + KotlinBuiltInsNames.FqNames.string.toSafe() +
KotlinBuiltIns.FQ_NAMES._boolean.toSafe() + KotlinBuiltInsNames.FqNames._boolean.toSafe() +
KotlinBuiltIns.FQ_NAMES._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel) KotlinBuiltInsNames.FqNames._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel)
fun allClassesWithIntrinsicCompanions(): Set<ClassId> = fun allClassesWithIntrinsicCompanions(): Set<ClassId> =
Collections.unmodifiableSet(classIds) Collections.unmodifiableSet(classIds)
@@ -33,31 +33,11 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import java.util.*; import java.util.*;
import static kotlin.collections.SetsKt.setOf; import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.*;
import static org.jetbrains.kotlin.builtins.PrimitiveType.*; import static org.jetbrains.kotlin.builtins.PrimitiveType.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName; import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.kotlin.utils.CollectionsKt.newHashMapWithExpectedSize;
import static org.jetbrains.kotlin.utils.CollectionsKt.newHashSetWithExpectedSize;
public abstract class KotlinBuiltIns { public abstract class KotlinBuiltIns {
public static final Name BUILT_INS_PACKAGE_NAME = Name.identifier("kotlin");
public static final FqName BUILT_INS_PACKAGE_FQ_NAME = FqName.topLevel(BUILT_INS_PACKAGE_NAME);
public static final FqName ANNOTATION_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("annotation"));
public static final FqName COLLECTIONS_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("collections"));
public static final FqName RANGES_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("ranges"));
public static final FqName TEXT_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("text"));
public static final Set<FqName> BUILT_INS_PACKAGE_FQ_NAMES = setOf(
BUILT_INS_PACKAGE_FQ_NAME,
COLLECTIONS_PACKAGE_FQ_NAME,
RANGES_PACKAGE_FQ_NAME,
ANNOTATION_PACKAGE_FQ_NAME,
ReflectionTypesKt.getKOTLIN_REFLECT_FQ_NAME(),
BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("internal")),
COROUTINES_PACKAGE_FQ_NAME_RELEASE
);
private ModuleDescriptorImpl builtInsModule; private ModuleDescriptorImpl builtInsModule;
private final NotNullLazyValue<Primitives> primitives; private final NotNullLazyValue<Primitives> primitives;
@@ -67,7 +47,6 @@ public abstract class KotlinBuiltIns {
private final StorageManager storageManager; private final StorageManager storageManager;
public static final FqNames FQ_NAMES = new FqNames();
public static final Name BUILTINS_MODULE_NAME = Name.special("<built-ins module>"); public static final Name BUILTINS_MODULE_NAME = Name.special("<built-ins module>");
protected KotlinBuiltIns(@NotNull StorageManager storageManager) { protected KotlinBuiltIns(@NotNull StorageManager storageManager) {
@@ -180,135 +159,6 @@ public abstract class KotlinBuiltIns {
} }
} }
public static class FqNames {
public final FqNameUnsafe any = fqNameUnsafe("Any");
public final FqNameUnsafe nothing = fqNameUnsafe("Nothing");
public final FqNameUnsafe cloneable = fqNameUnsafe("Cloneable");
public final FqName suppress = fqName("Suppress");
public final FqNameUnsafe unit = fqNameUnsafe("Unit");
public final FqNameUnsafe charSequence = fqNameUnsafe("CharSequence");
public final FqNameUnsafe string = fqNameUnsafe("String");
public final FqNameUnsafe array = fqNameUnsafe("Array");
public final FqNameUnsafe _boolean = fqNameUnsafe("Boolean");
public final FqNameUnsafe _char = fqNameUnsafe("Char");
public final FqNameUnsafe _byte = fqNameUnsafe("Byte");
public final FqNameUnsafe _short = fqNameUnsafe("Short");
public final FqNameUnsafe _int = fqNameUnsafe("Int");
public final FqNameUnsafe _long = fqNameUnsafe("Long");
public final FqNameUnsafe _float = fqNameUnsafe("Float");
public final FqNameUnsafe _double = fqNameUnsafe("Double");
public final FqNameUnsafe number = fqNameUnsafe("Number");
public final FqNameUnsafe _enum = fqNameUnsafe("Enum");
public final FqNameUnsafe functionSupertype = fqNameUnsafe("Function");
public final FqName throwable = fqName("Throwable");
public final FqName comparable = fqName("Comparable");
public final FqNameUnsafe intRange = rangesFqName("IntRange");
public final FqNameUnsafe longRange = rangesFqName("LongRange");
public final FqName deprecated = fqName("Deprecated");
public final FqName deprecatedSinceKotlin = fqName("DeprecatedSinceKotlin");
public final FqName deprecationLevel = fqName("DeprecationLevel");
public final FqName replaceWith = fqName("ReplaceWith");
public final FqName extensionFunctionType = fqName("ExtensionFunctionType");
public final FqName parameterName = fqName("ParameterName");
public final FqName annotation = fqName("Annotation");
public final FqName target = annotationName("Target");
public final FqName annotationTarget = annotationName("AnnotationTarget");
public final FqName annotationRetention = annotationName("AnnotationRetention");
public final FqName retention = annotationName("Retention");
public final FqName repeatable = annotationName("Repeatable");
public final FqName mustBeDocumented = annotationName("MustBeDocumented");
public final FqName unsafeVariance = fqName("UnsafeVariance");
public final FqName publishedApi = fqName("PublishedApi");
public final FqName iterator = collectionsFqName("Iterator");
public final FqName iterable = collectionsFqName("Iterable");
public final FqName collection = collectionsFqName("Collection");
public final FqName list = collectionsFqName("List");
public final FqName listIterator = collectionsFqName("ListIterator");
public final FqName set = collectionsFqName("Set");
public final FqName map = collectionsFqName("Map");
public final FqName mapEntry = map.child(Name.identifier("Entry"));
public final FqName mutableIterator = collectionsFqName("MutableIterator");
public final FqName mutableIterable = collectionsFqName("MutableIterable");
public final FqName mutableCollection = collectionsFqName("MutableCollection");
public final FqName mutableList = collectionsFqName("MutableList");
public final FqName mutableListIterator = collectionsFqName("MutableListIterator");
public final FqName mutableSet = collectionsFqName("MutableSet");
public final FqName mutableMap = collectionsFqName("MutableMap");
public final FqName mutableMapEntry = mutableMap.child(Name.identifier("MutableEntry"));
public final FqNameUnsafe kClass = reflect("KClass");
public final FqNameUnsafe kCallable = reflect("KCallable");
public final FqNameUnsafe kProperty0 = reflect("KProperty0");
public final FqNameUnsafe kProperty1 = reflect("KProperty1");
public final FqNameUnsafe kProperty2 = reflect("KProperty2");
public final FqNameUnsafe kMutableProperty0 = reflect("KMutableProperty0");
public final FqNameUnsafe kMutableProperty1 = reflect("KMutableProperty1");
public final FqNameUnsafe kMutableProperty2 = reflect("KMutableProperty2");
public final FqNameUnsafe kPropertyFqName = reflect("KProperty");
public final FqNameUnsafe kMutablePropertyFqName = reflect("KMutableProperty");
public final ClassId kProperty = ClassId.topLevel(kPropertyFqName.toSafe());
public final FqNameUnsafe kDeclarationContainer = reflect("KDeclarationContainer");
public final FqName uByteFqName = fqName("UByte");
public final FqName uShortFqName = fqName("UShort");
public final FqName uIntFqName = fqName("UInt");
public final FqName uLongFqName = fqName("ULong");
public final ClassId uByte = ClassId.topLevel(uByteFqName);
public final ClassId uShort = ClassId.topLevel(uShortFqName);
public final ClassId uInt = ClassId.topLevel(uIntFqName);
public final ClassId uLong = ClassId.topLevel(uLongFqName);
public final Set<Name> primitiveTypeShortNames = newHashSetWithExpectedSize(PrimitiveType.values().length);
public final Set<Name> primitiveArrayTypeShortNames = newHashSetWithExpectedSize(PrimitiveType.values().length);
public final Map<FqNameUnsafe, PrimitiveType> fqNameToPrimitiveType = newHashMapWithExpectedSize(PrimitiveType.values().length);
public final Map<FqNameUnsafe, PrimitiveType> arrayClassFqNameToPrimitiveType = newHashMapWithExpectedSize(PrimitiveType.values().length);
{
for (PrimitiveType primitiveType : PrimitiveType.values()) {
primitiveTypeShortNames.add(primitiveType.getTypeName());
primitiveArrayTypeShortNames.add(primitiveType.getArrayTypeName());
fqNameToPrimitiveType.put(fqNameUnsafe(primitiveType.getTypeName().asString()), primitiveType);
arrayClassFqNameToPrimitiveType.put(fqNameUnsafe(primitiveType.getArrayTypeName().asString()), primitiveType);
}
}
@NotNull
private static FqNameUnsafe fqNameUnsafe(@NotNull String simpleName) {
return fqName(simpleName).toUnsafe();
}
@NotNull
private static FqName fqName(@NotNull String simpleName) {
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName));
}
@NotNull
private static FqName collectionsFqName(@NotNull String simpleName) {
return COLLECTIONS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName));
}
@NotNull
private static FqNameUnsafe rangesFqName(@NotNull String simpleName) {
return RANGES_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)).toUnsafe();
}
@NotNull
private static FqNameUnsafe reflect(@NotNull String simpleName) {
return ReflectionTypesKt.getKOTLIN_REFLECT_FQ_NAME().child(Name.identifier(simpleName)).toUnsafe();
}
@NotNull
private static FqName annotationName(@NotNull String simpleName) {
return ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier(simpleName));
}
}
@NotNull @NotNull
public ModuleDescriptorImpl getBuiltInsModule() { public ModuleDescriptorImpl getBuiltInsModule() {
return builtInsModule; return builtInsModule;
@@ -516,107 +366,107 @@ public abstract class KotlinBuiltIns {
@NotNull @NotNull
public ClassDescriptor getKClass() { public ClassDescriptor getKClass() {
return getBuiltInClassByFqName(FQ_NAMES.kClass.toSafe()); return getBuiltInClassByFqName(FqNames.kClass.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKCallable() { public ClassDescriptor getKCallable() {
return getBuiltInClassByFqName(FQ_NAMES.kCallable.toSafe()); return getBuiltInClassByFqName(FqNames.kCallable.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKProperty() { public ClassDescriptor getKProperty() {
return getBuiltInClassByFqName(FQ_NAMES.kPropertyFqName.toSafe()); return getBuiltInClassByFqName(FqNames.kPropertyFqName.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKProperty0() { public ClassDescriptor getKProperty0() {
return getBuiltInClassByFqName(FQ_NAMES.kProperty0.toSafe()); return getBuiltInClassByFqName(FqNames.kProperty0.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKProperty1() { public ClassDescriptor getKProperty1() {
return getBuiltInClassByFqName(FQ_NAMES.kProperty1.toSafe()); return getBuiltInClassByFqName(FqNames.kProperty1.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKProperty2() { public ClassDescriptor getKProperty2() {
return getBuiltInClassByFqName(FQ_NAMES.kProperty2.toSafe()); return getBuiltInClassByFqName(FqNames.kProperty2.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKMutableProperty0() { public ClassDescriptor getKMutableProperty0() {
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty0.toSafe()); return getBuiltInClassByFqName(FqNames.kMutableProperty0.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKMutableProperty1() { public ClassDescriptor getKMutableProperty1() {
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty1.toSafe()); return getBuiltInClassByFqName(FqNames.kMutableProperty1.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getKMutableProperty2() { public ClassDescriptor getKMutableProperty2() {
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty2.toSafe()); return getBuiltInClassByFqName(FqNames.kMutableProperty2.toSafe());
} }
@NotNull @NotNull
public ClassDescriptor getIterator() { public ClassDescriptor getIterator() {
return getBuiltInClassByFqName(FQ_NAMES.iterator); return getBuiltInClassByFqName(FqNames.iterator);
} }
@NotNull @NotNull
public ClassDescriptor getIterable() { public ClassDescriptor getIterable() {
return getBuiltInClassByFqName(FQ_NAMES.iterable); return getBuiltInClassByFqName(FqNames.iterable);
} }
@NotNull @NotNull
public ClassDescriptor getMutableIterable() { public ClassDescriptor getMutableIterable() {
return getBuiltInClassByFqName(FQ_NAMES.mutableIterable); return getBuiltInClassByFqName(FqNames.mutableIterable);
} }
@NotNull @NotNull
public ClassDescriptor getMutableIterator() { public ClassDescriptor getMutableIterator() {
return getBuiltInClassByFqName(FQ_NAMES.mutableIterator); return getBuiltInClassByFqName(FqNames.mutableIterator);
} }
@NotNull @NotNull
public ClassDescriptor getCollection() { public ClassDescriptor getCollection() {
return getBuiltInClassByFqName(FQ_NAMES.collection); return getBuiltInClassByFqName(FqNames.collection);
} }
@NotNull @NotNull
public ClassDescriptor getMutableCollection() { public ClassDescriptor getMutableCollection() {
return getBuiltInClassByFqName(FQ_NAMES.mutableCollection); return getBuiltInClassByFqName(FqNames.mutableCollection);
} }
@NotNull @NotNull
public ClassDescriptor getList() { public ClassDescriptor getList() {
return getBuiltInClassByFqName(FQ_NAMES.list); return getBuiltInClassByFqName(FqNames.list);
} }
@NotNull @NotNull
public ClassDescriptor getMutableList() { public ClassDescriptor getMutableList() {
return getBuiltInClassByFqName(FQ_NAMES.mutableList); return getBuiltInClassByFqName(FqNames.mutableList);
} }
@NotNull @NotNull
public ClassDescriptor getSet() { public ClassDescriptor getSet() {
return getBuiltInClassByFqName(FQ_NAMES.set); return getBuiltInClassByFqName(FqNames.set);
} }
@NotNull @NotNull
public ClassDescriptor getMutableSet() { public ClassDescriptor getMutableSet() {
return getBuiltInClassByFqName(FQ_NAMES.mutableSet); return getBuiltInClassByFqName(FqNames.mutableSet);
} }
@NotNull @NotNull
public ClassDescriptor getMap() { public ClassDescriptor getMap() {
return getBuiltInClassByFqName(FQ_NAMES.map); return getBuiltInClassByFqName(FqNames.map);
} }
@NotNull @NotNull
public ClassDescriptor getMutableMap() { public ClassDescriptor getMutableMap() {
return getBuiltInClassByFqName(FQ_NAMES.mutableMap); return getBuiltInClassByFqName(FqNames.mutableMap);
} }
@NotNull @NotNull
@@ -635,12 +485,12 @@ public abstract class KotlinBuiltIns {
@NotNull @NotNull
public ClassDescriptor getListIterator() { public ClassDescriptor getListIterator() {
return getBuiltInClassByFqName(FQ_NAMES.listIterator); return getBuiltInClassByFqName(FqNames.listIterator);
} }
@NotNull @NotNull
public ClassDescriptor getMutableListIterator() { public ClassDescriptor getMutableListIterator() {
return getBuiltInClassByFqName(FQ_NAMES.mutableListIterator); return getBuiltInClassByFqName(FqNames.mutableListIterator);
} }
@NotNull @NotNull
@@ -814,20 +664,20 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isPrimitiveArray(@NotNull FqNameUnsafe arrayFqName) { public static boolean isPrimitiveArray(@NotNull FqNameUnsafe arrayFqName) {
return FQ_NAMES.arrayClassFqNameToPrimitiveType.get(arrayFqName) != null; return FqNames.arrayClassFqNameToPrimitiveType.get(arrayFqName) != null;
} }
@Nullable @Nullable
public static PrimitiveType getPrimitiveType(@NotNull DeclarationDescriptor descriptor) { public static PrimitiveType getPrimitiveType(@NotNull DeclarationDescriptor descriptor) {
return FQ_NAMES.primitiveTypeShortNames.contains(descriptor.getName()) return FqNames.primitiveTypeShortNames.contains(descriptor.getName())
? FQ_NAMES.fqNameToPrimitiveType.get(getFqName(descriptor)) ? FqNames.fqNameToPrimitiveType.get(getFqName(descriptor))
: null; : null;
} }
@Nullable @Nullable
public static PrimitiveType getPrimitiveArrayType(@NotNull DeclarationDescriptor descriptor) { public static PrimitiveType getPrimitiveArrayType(@NotNull DeclarationDescriptor descriptor) {
return FQ_NAMES.primitiveArrayTypeShortNames.contains(descriptor.getName()) return FqNames.primitiveArrayTypeShortNames.contains(descriptor.getName())
? FQ_NAMES.arrayClassFqNameToPrimitiveType.get(getFqName(descriptor)) ? FqNames.arrayClassFqNameToPrimitiveType.get(getFqName(descriptor))
: null; : null;
} }
@@ -850,11 +700,11 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isArray(@NotNull KotlinType type) { public static boolean isArray(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.array); return isConstructedFromGivenClass(type, FqNames.array);
} }
public static boolean isArrayOrPrimitiveArray(@NotNull ClassDescriptor descriptor) { public static boolean isArrayOrPrimitiveArray(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.array) || getPrimitiveArrayType(descriptor) != null; return classFqNameEquals(descriptor, FqNames.array) || getPrimitiveArrayType(descriptor) != null;
} }
public static boolean isArrayOrPrimitiveArray(@NotNull KotlinType type) { public static boolean isArrayOrPrimitiveArray(@NotNull KotlinType type) {
@@ -915,59 +765,59 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) { public static boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.any) || classFqNameEquals(descriptor, FQ_NAMES.nothing); return classFqNameEquals(descriptor, FqNames.any) || classFqNameEquals(descriptor, FqNames.nothing);
} }
public static boolean isAny(@NotNull ClassDescriptor descriptor) { public static boolean isAny(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.any); return classFqNameEquals(descriptor, FqNames.any);
} }
public static boolean isAny(@NotNull KotlinType type) { public static boolean isAny(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.any); return isConstructedFromGivenClassAndNotNullable(type, FqNames.any);
} }
public static boolean isBoolean(@NotNull KotlinType type) { public static boolean isBoolean(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._boolean); return isConstructedFromGivenClassAndNotNullable(type, FqNames._boolean);
} }
public static boolean isBooleanOrNullableBoolean(@NotNull KotlinType type) { public static boolean isBooleanOrNullableBoolean(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES._boolean); return isConstructedFromGivenClass(type, FqNames._boolean);
} }
public static boolean isBoolean(@NotNull ClassDescriptor classDescriptor) { public static boolean isBoolean(@NotNull ClassDescriptor classDescriptor) {
return classFqNameEquals(classDescriptor, FQ_NAMES._boolean); return classFqNameEquals(classDescriptor, FqNames._boolean);
} }
public static boolean isNumber(@NotNull KotlinType type) { public static boolean isNumber(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.number); return isConstructedFromGivenClassAndNotNullable(type, FqNames.number);
} }
public static boolean isChar(@NotNull KotlinType type) { public static boolean isChar(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._char); return isConstructedFromGivenClassAndNotNullable(type, FqNames._char);
} }
public static boolean isCharOrNullableChar(@NotNull KotlinType type) { public static boolean isCharOrNullableChar(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES._char); return isConstructedFromGivenClass(type, FqNames._char);
} }
public static boolean isInt(@NotNull KotlinType type) { public static boolean isInt(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._int); return isConstructedFromGivenClassAndNotNullable(type, FqNames._int);
} }
public static boolean isByte(@NotNull KotlinType type) { public static boolean isByte(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._byte); return isConstructedFromGivenClassAndNotNullable(type, FqNames._byte);
} }
public static boolean isLong(@NotNull KotlinType type) { public static boolean isLong(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._long); return isConstructedFromGivenClassAndNotNullable(type, FqNames._long);
} }
public static boolean isLongOrNullableLong(@NotNull KotlinType type) { public static boolean isLongOrNullableLong(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES._long); return isConstructedFromGivenClass(type, FqNames._long);
} }
public static boolean isShort(@NotNull KotlinType type) { public static boolean isShort(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._short); return isConstructedFromGivenClassAndNotNullable(type, FqNames._short);
} }
public static boolean isFloat(@NotNull KotlinType type) { public static boolean isFloat(@NotNull KotlinType type) {
@@ -975,7 +825,7 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isFloatOrNullableFloat(@NotNull KotlinType type) { public static boolean isFloatOrNullableFloat(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES._float); return isConstructedFromGivenClass(type, FqNames._float);
} }
public static boolean isDouble(@NotNull KotlinType type) { public static boolean isDouble(@NotNull KotlinType type) {
@@ -983,23 +833,23 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isUByte(@NotNull KotlinType type) { public static boolean isUByte(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uByteFqName.toUnsafe()); return isConstructedFromGivenClassAndNotNullable(type, FqNames.uByteFqName.toUnsafe());
} }
public static boolean isUShort(@NotNull KotlinType type) { public static boolean isUShort(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uShortFqName.toUnsafe()); return isConstructedFromGivenClassAndNotNullable(type, FqNames.uShortFqName.toUnsafe());
} }
public static boolean isUInt(@NotNull KotlinType type) { public static boolean isUInt(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uIntFqName.toUnsafe()); return isConstructedFromGivenClassAndNotNullable(type, FqNames.uIntFqName.toUnsafe());
} }
public static boolean isULong(@NotNull KotlinType type) { public static boolean isULong(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uLongFqName.toUnsafe()); return isConstructedFromGivenClassAndNotNullable(type, FqNames.uLongFqName.toUnsafe());
} }
public static boolean isDoubleOrNullableDouble(@NotNull KotlinType type) { public static boolean isDoubleOrNullableDouble(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES._double); return isConstructedFromGivenClass(type, FqNames._double);
} }
private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) { private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) {
@@ -1017,11 +867,11 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isNothingOrNullableNothing(@NotNull KotlinType type) { public static boolean isNothingOrNullableNothing(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.nothing); return isConstructedFromGivenClass(type, FqNames.nothing);
} }
public static boolean isAnyOrNullableAny(@NotNull KotlinType type) { public static boolean isAnyOrNullableAny(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.any); return isConstructedFromGivenClass(type, FqNames.any);
} }
public static boolean isNullableAny(@NotNull KotlinType type) { public static boolean isNullableAny(@NotNull KotlinType type) {
@@ -1033,11 +883,11 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isUnit(@NotNull KotlinType type) { public static boolean isUnit(@NotNull KotlinType type) {
return isNotNullConstructedFromGivenClass(type, FQ_NAMES.unit); return isNotNullConstructedFromGivenClass(type, FqNames.unit);
} }
public static boolean isUnitOrNullableUnit(@NotNull KotlinType type) { public static boolean isUnitOrNullableUnit(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.unit); return isConstructedFromGivenClass(type, FqNames.unit);
} }
public boolean isBooleanOrSubtype(@NotNull KotlinType type) { public boolean isBooleanOrSubtype(@NotNull KotlinType type) {
@@ -1049,78 +899,78 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isEnum(@NotNull ClassDescriptor descriptor) { public static boolean isEnum(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES._enum); return classFqNameEquals(descriptor, FqNames._enum);
} }
public static boolean isEnum(@NotNull KotlinType type) { public static boolean isEnum(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._enum); return isConstructedFromGivenClassAndNotNullable(type, FqNames._enum);
} }
public static boolean isComparable(@NotNull ClassDescriptor descriptor) { public static boolean isComparable(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.comparable.toUnsafe()); return classFqNameEquals(descriptor, FqNames.comparable.toUnsafe());
} }
public static boolean isComparable(@NotNull KotlinType type) { public static boolean isComparable(@NotNull KotlinType type) {
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.comparable.toUnsafe()); return isConstructedFromGivenClassAndNotNullable(type, FqNames.comparable.toUnsafe());
} }
public static boolean isCharSequence(@Nullable KotlinType type) { public static boolean isCharSequence(@Nullable KotlinType type) {
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.charSequence); return type != null && isNotNullConstructedFromGivenClass(type, FqNames.charSequence);
} }
public static boolean isString(@Nullable KotlinType type) { public static boolean isString(@Nullable KotlinType type) {
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string); return type != null && isNotNullConstructedFromGivenClass(type, FqNames.string);
} }
public static boolean isCharSequenceOrNullableCharSequence(@Nullable KotlinType type) { public static boolean isCharSequenceOrNullableCharSequence(@Nullable KotlinType type) {
return type != null && isConstructedFromGivenClass(type, FQ_NAMES.charSequence); return type != null && isConstructedFromGivenClass(type, FqNames.charSequence);
} }
public static boolean isStringOrNullableString(@Nullable KotlinType type) { public static boolean isStringOrNullableString(@Nullable KotlinType type) {
return type != null && isConstructedFromGivenClass(type, FQ_NAMES.string); return type != null && isConstructedFromGivenClass(type, FqNames.string);
} }
public static boolean isCollectionOrNullableCollection(@NotNull KotlinType type) { public static boolean isCollectionOrNullableCollection(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.collection); return isConstructedFromGivenClass(type, FqNames.collection);
} }
public static boolean isListOrNullableList(@NotNull KotlinType type) { public static boolean isListOrNullableList(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.list); return isConstructedFromGivenClass(type, FqNames.list);
} }
public static boolean isSetOrNullableSet(@NotNull KotlinType type) { public static boolean isSetOrNullableSet(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.set); return isConstructedFromGivenClass(type, FqNames.set);
} }
public static boolean isMapOrNullableMap(@NotNull KotlinType type) { public static boolean isMapOrNullableMap(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.map); return isConstructedFromGivenClass(type, FqNames.map);
} }
public static boolean isIterableOrNullableIterable(@NotNull KotlinType type) { public static boolean isIterableOrNullableIterable(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.iterable); return isConstructedFromGivenClass(type, FqNames.iterable);
} }
public static boolean isThrowableOrNullableThrowable(@NotNull KotlinType type) { public static boolean isThrowableOrNullableThrowable(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.throwable); return isConstructedFromGivenClass(type, FqNames.throwable);
} }
public static boolean isKClass(@NotNull ClassDescriptor descriptor) { public static boolean isKClass(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.kClass); return classFqNameEquals(descriptor, FqNames.kClass);
} }
public static boolean isNonPrimitiveArray(@NotNull ClassDescriptor descriptor) { public static boolean isNonPrimitiveArray(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.array); return classFqNameEquals(descriptor, FqNames.array);
} }
public static boolean isCloneable(@NotNull ClassDescriptor descriptor) { public static boolean isCloneable(@NotNull ClassDescriptor descriptor) {
return classFqNameEquals(descriptor, FQ_NAMES.cloneable); return classFqNameEquals(descriptor, FqNames.cloneable);
} }
// This function only checks presence of Deprecated annotation at declaration-site, it doesn't take into account @DeprecatedSinceKotlin // This function only checks presence of Deprecated annotation at declaration-site, it doesn't take into account @DeprecatedSinceKotlin
// To check that a referenced descriptor is actually deprecated at call-site, use DeprecationResolver // To check that a referenced descriptor is actually deprecated at call-site, use DeprecationResolver
public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) { public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
if (declarationDescriptor.getOriginal().getAnnotations().hasAnnotation(FQ_NAMES.deprecated)) return true; if (declarationDescriptor.getOriginal().getAnnotations().hasAnnotation(FqNames.deprecated)) return true;
if (declarationDescriptor instanceof PropertyDescriptor) { if (declarationDescriptor instanceof PropertyDescriptor) {
boolean isVar = ((PropertyDescriptor) declarationDescriptor).isVar(); boolean isVar = ((PropertyDescriptor) declarationDescriptor).isVar();
@@ -1133,7 +983,7 @@ public abstract class KotlinBuiltIns {
} }
public static boolean isNotNullOrNullableFunctionSupertype(@NotNull KotlinType type) { public static boolean isNotNullOrNullableFunctionSupertype(@NotNull KotlinType type) {
return isConstructedFromGivenClass(type, FQ_NAMES.functionSupertype); return isConstructedFromGivenClass(type, FqNames.functionSupertype);
} }
public static FqName getPrimitiveFqName(@NotNull PrimitiveType primitiveType) { public static FqName getPrimitiveFqName(@NotNull PrimitiveType primitiveType) {
@@ -5,27 +5,23 @@
package org.jetbrains.kotlin.builtins package org.jetbrains.kotlin.builtins
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.K_FUNCTION_PREFIX
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.K_SUSPEND_FUNCTION_PREFIX
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.PREFIXES
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.*
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect")
val K_PROPERTY_PREFIX = "KProperty"
val K_MUTABLE_PROPERTY_PREFIX = "KMutableProperty"
val K_FUNCTION_PREFIX = "KFunction"
val K_SUSPEND_FUNCTION_PREFIX = "KSuspendFunction"
val PREFIXES = listOf(K_PROPERTY_PREFIX, K_MUTABLE_PROPERTY_PREFIX, K_FUNCTION_PREFIX, K_SUSPEND_FUNCTION_PREFIX)
class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: NotFoundClasses) { class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: NotFoundClasses) {
private val kotlinReflectScope: MemberScope by lazy(LazyThreadSafetyMode.PUBLICATION) { private val kotlinReflectScope: MemberScope by lazy(LazyThreadSafetyMode.PUBLICATION) {
module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope
@@ -116,16 +112,16 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
hasKCallableTypeFqName(type) || type.constructor.supertypes.any { isKCallableType(it) } hasKCallableTypeFqName(type) || type.constructor.supertypes.any { isKCallableType(it) }
fun hasKCallableTypeFqName(type: KotlinType): Boolean = fun hasKCallableTypeFqName(type: KotlinType): Boolean =
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kCallable) hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kCallable)
fun hasKMutablePropertyTypeFqName(type: KotlinType): Boolean = fun hasKMutablePropertyTypeFqName(type: KotlinType): Boolean =
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kMutablePropertyFqName) hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kMutablePropertyFqName)
fun isNumberedKMutablePropertyType(type: KotlinType): Boolean { fun isNumberedKMutablePropertyType(type: KotlinType): Boolean {
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
return hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty0) || return hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty0) ||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty1) || hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty1) ||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty2) hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty2)
} }
fun isNumberedTypeWithOneOrMoreNumber(type: KotlinType): Boolean { fun isNumberedTypeWithOneOrMoreNumber(type: KotlinType): Boolean {
@@ -146,13 +142,13 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
} }
fun hasKPropertyTypeFqName(type: KotlinType): Boolean = fun hasKPropertyTypeFqName(type: KotlinType): Boolean =
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kPropertyFqName) hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kPropertyFqName)
fun isNumberedKPropertyType(type: KotlinType): Boolean { fun isNumberedKPropertyType(type: KotlinType): Boolean {
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
return hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty0) || return hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty0) ||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty1) || hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty1) ||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty2) hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty2)
} }
fun isNumberedKFunctionOrKSuspendFunction(type: KotlinType): Boolean { fun isNumberedKFunctionOrKSuspendFunction(type: KotlinType): Boolean {
@@ -184,7 +180,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
} }
fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? { fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? {
val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.kProperty) ?: return null
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kPropertyClass, return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kPropertyClass,
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single()))) listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single())))
} }
@@ -207,7 +203,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|| shortName == "KCallable" || shortName == "KAnnotatedElement" || shortName == "KCallable" || shortName == "KAnnotatedElement"
} }
if (packageName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME || packageName == COROUTINES_PACKAGE_FQ_NAME_RELEASE) { if (packageName == BUILT_INS_PACKAGE_FQ_NAME || packageName == COROUTINES_PACKAGE_FQ_NAME_RELEASE) {
return shortName.startsWith("Function") // FunctionN, Function return shortName.startsWith("Function") // FunctionN, Function
|| shortName.startsWith("SuspendFunction") || shortName.startsWith("SuspendFunction")
} }
@@ -63,7 +63,7 @@ object UnsignedTypes {
fun isUnsignedClass(descriptor: DeclarationDescriptor): Boolean { fun isUnsignedClass(descriptor: DeclarationDescriptor): Boolean {
val container = descriptor.containingDeclaration val container = descriptor.containingDeclaration
return container is PackageFragmentDescriptor && return container is PackageFragmentDescriptor &&
container.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME && container.fqName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME &&
descriptor.name in UnsignedTypes.unsignedTypeNames descriptor.name in UnsignedTypes.unsignedTypeNames
} }
} }

Some files were not shown because too many files have changed in this diff Show More