Move static constants with builtin names to :core:descriptors.common module
This commit is contained in:
@@ -62,6 +62,8 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
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.CodegenUtilKt.isGenericToArray;
|
||||
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.Nullable;
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
|
||||
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
||||
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.
|
||||
// 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.
|
||||
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;
|
||||
} else {
|
||||
return ((DeserializedClassDescriptor) descriptor).getMetadataVersion().isAtLeast(1, 1, 16);
|
||||
|
||||
+4
-4
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.codegen.coroutines
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
||||
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
|
||||
@@ -312,7 +312,7 @@ private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isR
|
||||
|
||||
fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
|
||||
module.resolveTopLevelClass(
|
||||
DescriptorUtils.RESULT_FQ_NAME,
|
||||
KotlinBuiltInsNames.RESULT_FQ_NAME,
|
||||
NoLookupLocation.FROM_BACKEND
|
||||
)?.defaultType?.let {
|
||||
KotlinTypeFactory.simpleType(
|
||||
@@ -501,7 +501,7 @@ fun FunctionDescriptor.isSuspendLambdaOrLocalFunction() = this.isSuspend && when
|
||||
fun FunctionDescriptor.isLocalSuspendFunctionNotSuspendLambda() = isSuspendLambdaOrLocalFunction() && this !is AnonymousFunctionDescriptor
|
||||
|
||||
@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
|
||||
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.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.context.ClosureContext
|
||||
@@ -675,7 +675,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
if (callableDescriptor is FictitiousArrayConstructor) return true
|
||||
val name = callableDescriptor.name.asString()
|
||||
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.isBuiltInSuspendCoroutineUninterceptedOrReturn
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted
|
||||
@@ -54,7 +55,7 @@ internal fun generateInlineIntrinsic(
|
||||
|
||||
private fun isSpecialEnumMethod(descriptor: FunctionDescriptor): Boolean {
|
||||
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
|
||||
}
|
||||
if (descriptor.typeParameters.size != 1) {
|
||||
|
||||
+18
-18
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.codegen.AsmUtil;
|
||||
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.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.*;
|
||||
|
||||
public class IntrinsicMethods {
|
||||
@@ -70,15 +70,15 @@ public class IntrinsicMethods {
|
||||
|
||||
public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) {
|
||||
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, KotlinBuiltIns.FQ_NAMES.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.FQ_NAMES.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "java", -1, new KClassJavaProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltInsNames.FqNames.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
|
||||
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, "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());
|
||||
|
||||
@@ -87,7 +87,7 @@ public class IntrinsicMethods {
|
||||
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (Name method : primitiveCastMethods) {
|
||||
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) {
|
||||
declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST);
|
||||
}
|
||||
@@ -139,20 +139,20 @@ public class IntrinsicMethods {
|
||||
declareBinaryOp("or", IOR);
|
||||
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(FQ_NAMES.string, "get", 1, new StringGetChar());
|
||||
declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.string, "plus", 1, new Concat());
|
||||
declareIntrinsicFunction(KotlinBuiltInsNames.FqNames.string, "get", 1, new StringGetChar());
|
||||
|
||||
if (canReplaceStdlibRuntimeApiBehavior) {
|
||||
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.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, "trimMargin", 1, new TrimMargin());
|
||||
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, KotlinBuiltIns.FQ_NAMES.string, "plus", 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltInsNames.FqNames.any, "toString", 0, TO_STRING);
|
||||
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());
|
||||
|
||||
for (PrimitiveType type : PrimitiveType.values()) {
|
||||
@@ -197,7 +197,7 @@ public class IntrinsicMethods {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName());
|
||||
}
|
||||
declareArrayMethods(FQ_NAMES.array.toSafe());
|
||||
declareArrayMethods(FqNames.array.toSafe());
|
||||
}
|
||||
|
||||
private void declareArrayMethods(@NotNull FqName arrayTypeFqName) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
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.Callable
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.resolve.DescriptorUtils
|
||||
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.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import kotlin.text.Regex
|
||||
|
||||
object TypeIntrinsics {
|
||||
@JvmStatic
|
||||
@@ -134,20 +133,20 @@ object TypeIntrinsics {
|
||||
|
||||
|
||||
private val MUTABLE_COLLECTION_TYPE_FQ_NAMES = setOf(
|
||||
FQ_NAMES.mutableIterator,
|
||||
FQ_NAMES.mutableIterable,
|
||||
FQ_NAMES.mutableCollection,
|
||||
FQ_NAMES.mutableList,
|
||||
FQ_NAMES.mutableListIterator,
|
||||
FQ_NAMES.mutableMap,
|
||||
FQ_NAMES.mutableSet,
|
||||
FQ_NAMES.mutableMapEntry
|
||||
FqNames.mutableIterator,
|
||||
FqNames.mutableIterable,
|
||||
FqNames.mutableCollection,
|
||||
FqNames.mutableList,
|
||||
FqNames.mutableListIterator,
|
||||
FqNames.mutableMap,
|
||||
FqNames.mutableSet,
|
||||
FqNames.mutableMapEntry
|
||||
)
|
||||
|
||||
private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? {
|
||||
val fqName = getClassFqName(jetType)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -200,4 +199,4 @@ object TypeIntrinsics {
|
||||
|
||||
private val BEFORE_CHECKCAST_TO_FUNCTION_OF_ARITY_DESCRIPTOR =
|
||||
Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE, Type.INT_TYPE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.codegen.range
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -83,10 +84,10 @@ fun getRangeOrProgressionElementType(rangeType: KotlinType): KotlinType? {
|
||||
COMPARABLE_RANGE_FQN -> rangeType.arguments.singleOrNull()?.type
|
||||
|
||||
UINT_RANGE_FQN, UINT_PROGRESSION_FQN ->
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uIntFqName)
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltInsNames.FqNames.uIntFqName)
|
||||
|
||||
ULONG_RANGE_FQN, ULONG_PROGRESSION_FQN ->
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uLongFqName)
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltInsNames.FqNames.uLongFqName)
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.state
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
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.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.state
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
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.model.KotlinTypeMarker
|
||||
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
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@@ -81,9 +81,9 @@ val FqName?.isMethodWithDeclarationSiteWildcardsFqName: Boolean
|
||||
|
||||
private fun FqName.child(name: String): FqName = child(Name.identifier(name))
|
||||
private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf(
|
||||
BUILTIN_NAMES.mutableCollection.child("addAll"),
|
||||
BUILTIN_NAMES.mutableList.child("addAll"),
|
||||
BUILTIN_NAMES.mutableMap.child("putAll")
|
||||
FqNames.mutableCollection.child("addAll"),
|
||||
FqNames.mutableList.child("addAll"),
|
||||
FqNames.mutableMap.child("putAll")
|
||||
)
|
||||
|
||||
fun TypeMappingMode.updateArgumentModeFromAnnotations(
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.serialization.builtins
|
||||
|
||||
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.cli.common.CLIConfigurationKeys
|
||||
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).
|
||||
private fun createCloneable(module: ModuleDescriptor): ClassDescriptor {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -5,9 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
fun LanguageVersionSettings.coroutinesPackageFqName(): FqName {
|
||||
return coroutinesPackageFqName(isReleaseCoroutines())
|
||||
@@ -17,9 +17,9 @@ fun LanguageVersionSettings.isReleaseCoroutines() = supportsFeature(LanguageFeat
|
||||
|
||||
private fun coroutinesPackageFqName(isReleaseCoroutines: Boolean): FqName {
|
||||
return if (isReleaseCoroutines)
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
else
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
|
||||
KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
|
||||
}
|
||||
|
||||
fun LanguageVersionSettings.coroutinesIntrinsicsPackageFqName() =
|
||||
@@ -33,7 +33,7 @@ fun LanguageVersionSettings.restrictsSuspensionFqName() =
|
||||
|
||||
fun FqName.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) =
|
||||
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
|
||||
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
|
||||
this == DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
|
||||
this == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
|
||||
this == KotlinBuiltInsNames.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
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.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
@@ -210,7 +210,7 @@ private fun FirRegularClassBuilder.addSerializableIfNeeded(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
|
||||
superTypeRefs += buildResolvedTypeRef {
|
||||
type = ConeClassLikeTypeImpl(
|
||||
|
||||
+2
-3
@@ -5,9 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
|
||||
|
||||
val CONTINUATION_INTERFACE_CLASS_ID = ClassId.topLevel(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE)
|
||||
val CONTINUATION_INTERFACE_CLASS_ID = ClassId.topLevel(KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
@@ -395,7 +395,7 @@ fun CallableId.isInvoke() =
|
||||
isKFunctionInvoke()
|
||||
|| callableName.asString() == "invoke"
|
||||
&& className?.asString()?.startsWith("Function") == true
|
||||
&& packageName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
&& packageName == KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
|
||||
|
||||
fun CallableId.isKFunctionInvoke() =
|
||||
callableName.asString() == "invoke"
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
@@ -56,7 +56,7 @@ class FirBuiltinSymbolProvider(session: FirSession, val kotlinScopeProvider: Kot
|
||||
private fun loadBuiltIns(): List<BuiltInsPackageFragment> {
|
||||
val classLoader = this::class.java.classLoader
|
||||
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 ->
|
||||
val resourcePath = BuiltInSerializerProtocol.getBuiltInsFilePath(fqName)
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
class FirCloneableSymbolProvider(session: FirSession, scopeProvider: FirScopeProvider) : FirSymbolProvider(session) {
|
||||
companion object {
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
@@ -495,10 +495,10 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.getPrimitiveType() =
|
||||
getClassFqNameUnsafe()?.let(KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType::get)
|
||||
getClassFqNameUnsafe()?.let(KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType::get)
|
||||
|
||||
override fun TypeConstructorMarker.getPrimitiveArrayType() =
|
||||
getClassFqNameUnsafe()?.let(KotlinBuiltIns.FQ_NAMES.arrayClassFqNameToPrimitiveType::get)
|
||||
getClassFqNameUnsafe()?.let(KotlinBuiltInsNames.FqNames.arrayClassFqNameToPrimitiveType::get)
|
||||
|
||||
override fun TypeConstructorMarker.isUnderKotlinPackage() =
|
||||
getClassFqNameUnsafe()?.startsWith(Name.identifier("kotlin")) == true
|
||||
|
||||
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.SyntheticElement
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
|
||||
fun isSyntheticValuesOrValueOfMethod(method: PsiMethod): Boolean {
|
||||
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
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.JavaPropertyInitializerEvaluatorImpl
|
||||
@@ -68,7 +68,7 @@ class JavaActualAnnotationArgumentExtractor : ExpectedActualDeclarationChecker.A
|
||||
is JavaPrimitiveType -> {
|
||||
val primitiveType = type.type
|
||||
// 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) {
|
||||
KClassValue(ClassId.topLevel(primitiveType.arrayTypeFqName), arrayDimensions - 1)
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
@@ -238,7 +238,7 @@ class AnnotationChecker(
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -436,4 +436,4 @@ class AnnotationChecker(
|
||||
|
||||
interface AdditionalAnnotationChecker {
|
||||
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 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.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -76,7 +76,7 @@ class CollectionLiteralResolver(
|
||||
expression: KtCollectionLiteralExpression,
|
||||
callName: Name
|
||||
): 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))
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -975,7 +976,7 @@ class DeclarationsChecker(
|
||||
if (containingDeclaration !is ClassDescriptor) continue
|
||||
if (visitedClasses.contains(containingDeclaration)) continue
|
||||
|
||||
if (DescriptorUtils.getFqName(containingDeclaration) == KotlinBuiltIns.FQ_NAMES.any) {
|
||||
if (DescriptorUtils.getFqName(containingDeclaration) == KotlinBuiltInsNames.FqNames.any) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve
|
||||
|
||||
import com.google.common.collect.Lists
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -174,7 +175,7 @@ class DelegatedPropertyResolver(
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
@@ -19,10 +19,7 @@ package org.jetbrains.kotlin.resolve
|
||||
import com.intellij.openapi.util.ThrowableComputable
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.AstLoadingFilter
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.contracts.description.ContractProviderKey
|
||||
@@ -309,7 +306,7 @@ class FunctionDescriptorResolver(
|
||||
|
||||
private fun KotlinType.removeParameterNameAnnotation(): KotlinType {
|
||||
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 }))
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
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.impl.FunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl
|
||||
@@ -148,7 +148,7 @@ class VarianceCheckerCore(
|
||||
if (classifierDescriptor is TypeParameterDescriptor) {
|
||||
val declarationVariance = classifierDescriptor.varianceWithManual()
|
||||
if (!declarationVariance.allowsPosition(position)
|
||||
&& !type.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.unsafeVariance)
|
||||
&& !type.annotations.hasAnnotation(KotlinBuiltInsNames.FqNames.unsafeVariance)
|
||||
) {
|
||||
val varianceConflictDiagnosticData = VarianceConflictDiagnosticData(containingType, classifierDescriptor, position)
|
||||
val diagnostic =
|
||||
|
||||
+1
-2
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
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.descriptors.CallableDescriptor
|
||||
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.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
private val ALLOWED_MEMBER_NAMES = setOf(
|
||||
"equals", "hashCode", "toString", "invoke", "name"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
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.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
|
||||
+8
-5
@@ -6,16 +6,19 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
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.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isCallableReference
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
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
|
||||
|
||||
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 =
|
||||
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 =
|
||||
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) =
|
||||
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe?.isBuiltInCoroutineContext(languageVersionSettings) == true
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
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.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -31,8 +31,8 @@ class AnnotationClassTargetAndRetentionChecker : DeclarationChecker {
|
||||
val retention = descriptor.getAnnotationRetention() ?: KotlinRetention.RUNTIME
|
||||
|
||||
if (targets.contains(KotlinTarget.EXPRESSION) && retention != KotlinRetention.SOURCE) {
|
||||
val retentionAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.retention)
|
||||
val targetAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target)
|
||||
val retentionAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.retention)
|
||||
val targetAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.target)
|
||||
|
||||
val diagnostics =
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.RestrictRetentionForExpressionAnnotations))
|
||||
@@ -45,4 +45,4 @@ class AnnotationClassTargetAndRetentionChecker : DeclarationChecker {
|
||||
|
||||
private val AnnotationDescriptor.psi: PsiElement?
|
||||
get() = DescriptorToSourceUtils.getSourceFromAnnotation(this)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
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.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
@@ -25,14 +25,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object DeprecatedSinceKotlinAnnotationChecker : DeclarationChecker {
|
||||
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 deprecatedAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated)
|
||||
val deprecatedAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecated)
|
||||
|
||||
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(
|
||||
Errors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE.on(
|
||||
deprecatedSinceAnnotationName
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
@@ -70,7 +70,7 @@ class ExperimentalMarkerDeclarationAnnotationChecker(private val module: ModuleD
|
||||
val targetEntry =
|
||||
entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) }
|
||||
.entries
|
||||
.firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltIns.FQ_NAMES.target }
|
||||
.firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltInsNames.FqNames.target }
|
||||
?: return
|
||||
val (entry, descriptor) = targetEntry
|
||||
val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
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.DeclarationDescriptorWithVisibility
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
@@ -38,7 +38,7 @@ object PublishedApiUsageChecker {
|
||||
|
||||
for (entry in declaration.annotationEntries) {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -5,16 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class ResultClassInReturnTypeChecker : DeclarationChecker {
|
||||
@@ -60,6 +59,6 @@ internal fun KotlinType.isResultType(): Boolean {
|
||||
private fun DeclarationDescriptor.isResultClass(): Boolean {
|
||||
val container = containingDeclaration ?: return false
|
||||
return container is PackageFragmentDescriptor &&
|
||||
container.fqName == DescriptorUtils.RESULT_FQ_NAME.parent() &&
|
||||
name == DescriptorUtils.RESULT_FQ_NAME.shortName()
|
||||
container.fqName == KotlinBuiltInsNames.RESULT_FQ_NAME.parent() &&
|
||||
name == KotlinBuiltInsNames.RESULT_FQ_NAME.shortName()
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.util.TypeConversionUtil
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -1017,7 +1018,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
}
|
||||
|
||||
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)
|
||||
// Case `NotAccessibleButWasExperimental` will be checked later in `checkExperimentalityOfConstantLiteral`
|
||||
return accessibility is SinceKotlinAccessibility.Accessible
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.deprecation
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -200,11 +201,11 @@ class DeprecationResolver(
|
||||
}
|
||||
|
||||
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) {
|
||||
val deprecatedByAnnotation =
|
||||
DeprecatedByAnnotation.create(
|
||||
annotation, annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin),
|
||||
annotation, annotations.findAnnotation(KotlinBuiltInsNames.FqNames.deprecatedSinceKotlin),
|
||||
this, deprecationSettings.propagatedToOverrides(annotation),
|
||||
languageVersionSettings.apiVersion
|
||||
)
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.psi.PsiElement
|
||||
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.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
@@ -152,7 +152,7 @@ abstract class KotlinSuppressCache {
|
||||
}
|
||||
|
||||
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
|
||||
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.lower.LocalDeclarationsLowering
|
||||
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.SimpleFunctionDescriptor
|
||||
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.valueParameters.isEmpty() &&
|
||||
symbol.owner.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass ->
|
||||
receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltIns.FQ_NAMES.kProperty0
|
||||
receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltInsNames.FqNames.kProperty0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.backend.common.lower
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
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.declarations.IrFile
|
||||
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
|
||||
// is a member function of kotlin.String (with FqName kotlin.String.plus)
|
||||
private val PARENT_NAMES = setOf(
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltIns.FQ_NAMES.string.toSafe()
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltInsNames.FqNames.string.toSafe()
|
||||
)
|
||||
|
||||
/** @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
|
||||
&& 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] */
|
||||
|
||||
+25
-25
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
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.declarations.IrClass
|
||||
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)
|
||||
|
||||
private val specialMethodsWithDefaults = mapOf(
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.collection, "contains", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.collection, "contains", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableCollection, "remove", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.mutableCollection, "remove", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constFalse, 1, needsArgumentBoxing = true),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "containsKey", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "containsKey", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "containsValue", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "containsValue", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constFalse, 1),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableMap, "remove", 2) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.mutableMap, "remove", 2) to
|
||||
SpecialMethodWithDefaultInfo(::constFalse, 2),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.list, "indexOf", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.list, "indexOf", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constMinusOne, 1),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.list, "lastIndexOf", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.list, "lastIndexOf", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constMinusOne, 1),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "getOrDefault", 2) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "getOrDefault", 2) to
|
||||
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),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableMap, "remove", 1) to
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.mutableMap, "remove", 1) to
|
||||
SpecialMethodWithDefaultInfo(::constNull, 1, needsGenericSignature = true)
|
||||
)
|
||||
|
||||
private val specialProperties = mapOf(
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.collection, "size") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "size") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.charSequence.toSafe(), "length") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "keys") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "values") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.map, "entries") to BuiltInWithDifferentJvmName(needsGenericSignature = true)
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.collection, "size") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "size") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.charSequence.toSafe(), "length") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "keys") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "values") to BuiltInWithDifferentJvmName(needsGenericSignature = true),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.map, "entries") to BuiltInWithDifferentJvmName(needsGenericSignature = true)
|
||||
)
|
||||
|
||||
private val specialMethods = mapOf(
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toByte") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toShort") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toInt") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toLong") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toFloat") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.number.toSafe(), "toDouble") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.charSequence.toSafe(), "get", 1) to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltIns.FQ_NAMES.mutableList, "removeAt", 1) to BuiltInWithDifferentJvmName(needsGenericSignature = true)
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toByte") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toShort") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toInt") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toLong") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toFloat") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.number.toSafe(), "toDouble") to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.charSequence.toSafe(), "get", 1) to BuiltInWithDifferentJvmName(),
|
||||
makeDescription(KotlinBuiltInsNames.FqNames.mutableList, "removeAt", 1) to BuiltInWithDifferentJvmName(needsGenericSignature = true)
|
||||
)
|
||||
|
||||
val specialMethodNames = (specialMethodsWithDefaults + specialMethods).map { (description) -> description.name }.toHashSet()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
@@ -70,10 +70,10 @@ private inline fun IrType.isTypeFromKotlinPackage(namePredicate: (Name) -> Boole
|
||||
} 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 {
|
||||
(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 =
|
||||
|
||||
+3
-3
@@ -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.createParameterDeclarations
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.codegen.SamType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||
@@ -106,7 +106,7 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene
|
||||
descriptor.getParentJavaStaticClassScope()
|
||||
|
||||
private val annotationPackage =
|
||||
IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), KotlinBuiltIns.ANNOTATION_PACKAGE_FQ_NAME)
|
||||
IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), KotlinBuiltInsNames.ANNOTATION_PACKAGE_FQ_NAME)
|
||||
|
||||
private val flexibleNullabilityAnnotationClass = IrFactoryImpl.buildClass {
|
||||
kind = ClassKind.ANNOTATION_CLASS
|
||||
@@ -123,6 +123,6 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene
|
||||
|
||||
companion object {
|
||||
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.createImplicitParameterDeclarationWithWrappedDescriptor
|
||||
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.SUSPEND_CALL_RESULT_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.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -201,7 +200,7 @@ class JvmSymbols(
|
||||
get() = TODO("not implemented")
|
||||
|
||||
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 =
|
||||
createClass(FqName("java.lang.Class")) { klass ->
|
||||
@@ -226,12 +225,12 @@ class JvmSymbols(
|
||||
val assertionErrorConstructor = javaLangAssertionError.constructors.single()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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.addConstructor { isPrimary = true }.apply {
|
||||
addValueParameter("value", irBuiltIns.anyNType)
|
||||
|
||||
+3
-3
@@ -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.JvmGeneratorExtensions
|
||||
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.TypeAnnotationCollector
|
||||
import org.jetbrains.kotlin.codegen.TypePathInfo
|
||||
@@ -373,7 +373,7 @@ private val RETENTION_PARAMETER_NAME = Name.identifier("value")
|
||||
|
||||
private fun IrClass.getAnnotationRetention(): KotlinRetention? {
|
||||
val retentionArgument =
|
||||
getAnnotation(KotlinBuiltIns.FQ_NAMES.retention)?.getValueArgument(RETENTION_PARAMETER_NAME)
|
||||
getAnnotation(KotlinBuiltInsNames.FqNames.retention)?.getValueArgument(RETENTION_PARAMETER_NAME)
|
||||
as? IrGetEnumValue?: return null
|
||||
val retentionArgumentValue = retentionArgument.symbol.owner
|
||||
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 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)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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.propertyIfAccessor
|
||||
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.codegen.JvmCodegenUtil
|
||||
import org.jetbrains.kotlin.codegen.replaceValueParametersIn
|
||||
@@ -130,7 +130,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
||||
else null) ?: context.state.moduleName
|
||||
|
||||
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 {
|
||||
if (declaration !is IrFunction) {
|
||||
@@ -369,7 +369,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
// From BuiltinMethodsWithDifferentJvmName.isBuiltinFunctionWithDifferentNameInJvm, BuiltinMethodsWithDifferentJvmName.getJvmName
|
||||
@@ -424,4 +424,4 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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.JvmLoweredDeclarationOrigin
|
||||
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.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper
|
||||
@@ -105,7 +105,7 @@ fun JvmBackendContext.getSourceMapper(declaration: IrClass): SourceMapper {
|
||||
}
|
||||
|
||||
val IrType.isExtensionFunctionType: Boolean
|
||||
get() = isFunctionTypeOrSubtype() && hasAnnotation(FQ_NAMES.extensionFunctionType)
|
||||
get() = isFunctionTypeOrSubtype() && hasAnnotation(FqNames.extensionFunctionType)
|
||||
|
||||
|
||||
/* Borrowed with modifications from MemberCodegen.java */
|
||||
@@ -409,7 +409,7 @@ fun IrClass.isOptionalAnnotationClass(): Boolean =
|
||||
|
||||
val IrAnnotationContainer.deprecationFlags: Int
|
||||
get() {
|
||||
val annotation = annotations.findAnnotation(FQ_NAMES.deprecated)
|
||||
val annotation = annotations.findAnnotation(FqNames.deprecated)
|
||||
?: return if ((this as? IrDeclaration)?.origin?.let {
|
||||
it == JvmLoweredDeclarationOrigin.DEFAULT_IMPLS_BRIDGE_FOR_COMPATIBILITY
|
||||
} == true
|
||||
|
||||
+20
-17
@@ -17,9 +17,12 @@
|
||||
package org.jetbrains.kotlin.backend.jvm.intrinsics
|
||||
|
||||
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.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.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
@@ -43,11 +46,11 @@ class IrIntrinsicMethods(val irBuiltIns: IrBuiltIns, val symbols: JvmSymbols) {
|
||||
private val intrinsicsMap = (
|
||||
listOf(
|
||||
Key(kotlinJvm, FqName("T"), "<get-javaClass>", emptyList()) to JavaClassProperty,
|
||||
Key(kotlinJvm, KotlinBuiltIns.FQ_NAMES.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-javaObjectType>", emptyList()) to GetJavaObjectType,
|
||||
Key(kotlinJvm, KotlinBuiltInsNames.FqNames.kClass.toSafe(), "<get-javaPrimitiveType>", emptyList()) to GetJavaPrimitiveType,
|
||||
Key(
|
||||
kotlinJvm,
|
||||
KotlinBuiltIns.FQ_NAMES.kClass.toSafe(),
|
||||
KotlinBuiltInsNames.FqNames.kClass.toSafe(),
|
||||
"<get-java>",
|
||||
emptyList()
|
||||
) to KClassJavaProperty,
|
||||
@@ -55,49 +58,49 @@ class IrIntrinsicMethods(val irBuiltIns: IrBuiltIns, val symbols: JvmSymbols) {
|
||||
kotlinJvmInternalUnsafe,
|
||||
null,
|
||||
"access\$monitorEnter",
|
||||
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe())
|
||||
listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
|
||||
) to MonitorInstruction.MONITOR_ENTER,
|
||||
Key(
|
||||
kotlinJvmInternalUnsafe,
|
||||
null,
|
||||
"access\$monitorExit",
|
||||
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe())
|
||||
listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
|
||||
) to MonitorInstruction.MONITOR_EXIT,
|
||||
Key(
|
||||
kotlinJvm,
|
||||
KotlinBuiltIns.FQ_NAMES.array.toSafe(),
|
||||
KotlinBuiltInsNames.FqNames.array.toSafe(),
|
||||
"isArrayOf",
|
||||
emptyList()
|
||||
) to IsArrayOf,
|
||||
Key(
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
null,
|
||||
"arrayOfNulls",
|
||||
listOf(KotlinBuiltIns.FQ_NAMES._int.toSafe())
|
||||
listOf(KotlinBuiltInsNames.FqNames._int.toSafe())
|
||||
) to NewArray,
|
||||
Key(
|
||||
KotlinBuiltIns.FQ_NAMES.cloneable.toSafe(),
|
||||
KotlinBuiltInsNames.FqNames.cloneable.toSafe(),
|
||||
null,
|
||||
"clone",
|
||||
emptyList()
|
||||
) to Clone,
|
||||
Key(
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
null,
|
||||
"enumValues",
|
||||
listOf()
|
||||
) to EnumValues,
|
||||
Key(
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
null,
|
||||
"enumValueOf",
|
||||
listOf(KotlinBuiltIns.FQ_NAMES.string.toSafe())
|
||||
listOf(KotlinBuiltInsNames.FqNames.string.toSafe())
|
||||
) to EnumValueOf,
|
||||
Key(
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltIns.FQ_NAMES.string.toSafe(),
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
KotlinBuiltInsNames.FqNames.string.toSafe(),
|
||||
"plus",
|
||||
listOf(KotlinBuiltIns.FQ_NAMES.any.toSafe())
|
||||
listOf(KotlinBuiltInsNames.FqNames.any.toSafe())
|
||||
) to StringPlus,
|
||||
irBuiltIns.eqeqSymbol.toKey()!! to Equals(KtTokens.EQEQ),
|
||||
irBuiltIns.eqeqeqSymbol.toKey()!! to Equals(KtTokens.EQEQEQ),
|
||||
|
||||
+1
-3
@@ -17,12 +17,10 @@
|
||||
package org.jetbrains.kotlin.backend.jvm.intrinsics
|
||||
|
||||
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.fileClasses.internalNameWithoutInnerClasses
|
||||
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.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
|
||||
|
||||
+4
-4
@@ -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.phaser.makeIrFilePhase
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
@@ -127,7 +127,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
|
||||
}
|
||||
|
||||
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"))
|
||||
) return
|
||||
|
||||
@@ -228,7 +228,7 @@ private fun IrConstructorCall.getValueArgument(name: Name): IrExpression? {
|
||||
private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets")
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -238,4 +238,4 @@ private fun loadAnnotationTargets(targetEntry: IrConstructorCall): Set<KotlinTar
|
||||
return valueArgument.elements.filterIsInstance<IrGetEnumValue>().mapNotNull {
|
||||
KotlinTarget.valueOrNull(it.symbol.owner.name.asString())
|
||||
}.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.backend.common.lower.*
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
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.config.JVMAssertionsMode
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
@@ -129,7 +129,7 @@ private class AssertionLowering(private val context: JvmBackendContext) :
|
||||
}
|
||||
|
||||
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) =
|
||||
|
||||
+4
-4
@@ -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.ir.createJvmIrBuilder
|
||||
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.descriptors.Modality
|
||||
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
|
||||
return when {
|
||||
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") ->
|
||||
fqName == REFLECT_PACKAGE_FQ_NAME
|
||||
else -> false
|
||||
@@ -169,11 +169,11 @@ private class FunctionNVarargBridgeLowering(val context: JvmBackendContext) :
|
||||
}
|
||||
|
||||
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("functions"))
|
||||
|
||||
private val REFLECT_PACKAGE_FQ_NAME =
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
|
||||
.child(Name.identifier("reflect"))
|
||||
}
|
||||
|
||||
+2
-2
@@ -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.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.*
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
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.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
val jvmInlineClassPhase = makeIrFilePhase(
|
||||
@@ -398,7 +398,7 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
|
||||
?: return false
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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.irArray
|
||||
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.UnsignedType
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
@@ -106,7 +106,7 @@ private class VarargLowering(val context: JvmBackendContext) : FileLoweringPass,
|
||||
|
||||
private val IrFunctionSymbol.isEmptyArray: Boolean
|
||||
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 {
|
||||
private val PRIMITIVE_ARRAY_OF_NAMES: Set<String> =
|
||||
@@ -122,7 +122,7 @@ private class VarargLowering(val context: JvmBackendContext) : FileLoweringPass,
|
||||
is IrPackageFragment -> directParent
|
||||
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 } &&
|
||||
extensionReceiverParameter == null &&
|
||||
dispatchReceiverParameter == null &&
|
||||
|
||||
+2
-2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.backend.jvm.lower.inlineclasses
|
||||
|
||||
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.ir.declarations.*
|
||||
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.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
/**
|
||||
* Replace inline classes by their underlying types.
|
||||
@@ -114,7 +114,7 @@ object InlineClassAbi {
|
||||
internal val IrType.requiresMangling: Boolean
|
||||
get() {
|
||||
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>
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.psi2ir.transformations
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
|
||||
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),
|
||||
// we need one that takes Int.
|
||||
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)
|
||||
.find {
|
||||
val extensionReceiver = it.extensionReceiverParameter
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
@@ -202,10 +202,10 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
override fun SimpleTypeMarker.asArgumentList() = this as IrSimpleType
|
||||
|
||||
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 =
|
||||
this is IrClassSymbol && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.nothing)
|
||||
this is IrClassSymbol && isClassWithFqName(KotlinBuiltInsNames.FqNames.nothing)
|
||||
|
||||
override fun SimpleTypeMarker.isSingleClassifierType() = true
|
||||
|
||||
@@ -246,7 +246,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
|
||||
override fun SimpleTypeMarker.isExtensionFunction(): Boolean {
|
||||
require(this is IrSimpleType)
|
||||
return this.hasAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType)
|
||||
return this.hasAnnotation(KotlinBuiltInsNames.FqNames.extensionFunctionType)
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.typeDepth(): Int {
|
||||
@@ -364,7 +364,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
while (true) {
|
||||
val parent = declaration.parent
|
||||
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
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.symbols.FqNameEqualityChecker
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
@@ -47,7 +47,7 @@ fun IrType.isNullable(): 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 =
|
||||
if (isBoxedArray)
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
|
||||
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.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
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.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 =
|
||||
declaration.name == fqName.shortName() && fqName == declaration.fqNameWhenAvailable?.toUnsafe()
|
||||
|
||||
fun IrType.isAny(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.any)
|
||||
fun IrType.isNullableAny(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.any)
|
||||
fun IrType.isAny(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.any)
|
||||
fun IrType.isNullableAny(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.any)
|
||||
|
||||
fun IrType.isString(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.string)
|
||||
fun IrType.isNullableString(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.string)
|
||||
fun IrType.isStringClassType(): Boolean = isClassType(KotlinBuiltIns.FQ_NAMES.string)
|
||||
fun IrType.isArray(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.array)
|
||||
fun IrType.isNullableArray(): Boolean = isNullableClassType(KotlinBuiltIns.FQ_NAMES.array)
|
||||
fun IrType.isCollection(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.collection.toUnsafe())
|
||||
fun IrType.isNothing(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.nothing)
|
||||
fun IrType.isKClass(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.kClass)
|
||||
fun IrType.isString(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.string)
|
||||
fun IrType.isNullableString(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.string)
|
||||
fun IrType.isStringClassType(): Boolean = isClassType(KotlinBuiltInsNames.FqNames.string)
|
||||
fun IrType.isArray(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.array)
|
||||
fun IrType.isNullableArray(): Boolean = isNullableClassType(KotlinBuiltInsNames.FqNames.array)
|
||||
fun IrType.isCollection(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.collection.toUnsafe())
|
||||
fun IrType.isNothing(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.nothing)
|
||||
fun IrType.isKClass(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.kClass)
|
||||
|
||||
fun IrType.isPrimitiveType(): Boolean = KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType.keys.any { isNotNullClassType(it) }
|
||||
fun IrType.isNullablePrimitiveType(): Boolean = KotlinBuiltIns.FQ_NAMES.fqNameToPrimitiveType.keys.any { isNullableClassType(it) }
|
||||
fun IrType.isPrimitiveType(): Boolean = KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType.keys.any { isNotNullClassType(it) }
|
||||
fun IrType.isNullablePrimitiveType(): Boolean = KotlinBuiltInsNames.FqNames.fqNameToPrimitiveType.keys.any { isNullableClassType(it) }
|
||||
|
||||
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.isChar(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._char)
|
||||
fun IrType.isByte(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._byte)
|
||||
fun IrType.isShort(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._short)
|
||||
fun IrType.isInt(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._int)
|
||||
fun IrType.isLong(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._long)
|
||||
fun IrType.isUByte(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uByteFqName.toUnsafe())
|
||||
fun IrType.isUShort(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uShortFqName.toUnsafe())
|
||||
fun IrType.isUInt(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uIntFqName.toUnsafe())
|
||||
fun IrType.isULong(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.uLongFqName.toUnsafe())
|
||||
fun IrType.isFloat(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._float)
|
||||
fun IrType.isDouble(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES._double)
|
||||
fun IrType.isNumber(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.number)
|
||||
fun IrType.isBoolean(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._boolean)
|
||||
fun IrType.isChar(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._char)
|
||||
fun IrType.isByte(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._byte)
|
||||
fun IrType.isShort(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._short)
|
||||
fun IrType.isInt(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._int)
|
||||
fun IrType.isLong(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._long)
|
||||
fun IrType.isUByte(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uByteFqName.toUnsafe())
|
||||
fun IrType.isUShort(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uShortFqName.toUnsafe())
|
||||
fun IrType.isUInt(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uIntFqName.toUnsafe())
|
||||
fun IrType.isULong(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.uLongFqName.toUnsafe())
|
||||
fun IrType.isFloat(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._float)
|
||||
fun IrType.isDouble(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames._double)
|
||||
fun IrType.isNumber(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.number)
|
||||
|
||||
fun IrType.isComparable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.comparable.toUnsafe())
|
||||
fun IrType.isCharSequence(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.charSequence)
|
||||
fun IrType.isIterable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.iterable.toUnsafe())
|
||||
fun IrType.isComparable(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.comparable.toUnsafe())
|
||||
fun IrType.isCharSequence(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.charSequence)
|
||||
fun IrType.isIterable(): Boolean = isNotNullClassType(KotlinBuiltInsNames.FqNames.iterable.toUnsafe())
|
||||
fun IrType.isSequence(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.sequences.Sequence"))
|
||||
|
||||
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.isDoubleArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.DoubleArray"))
|
||||
|
||||
fun IrType.isKotlinResult(): Boolean = isNotNullClassType(DescriptorUtils.RESULT_FQ_NAME.toUnsafe())
|
||||
fun IrType.isNullableContinuation(): Boolean = isNullableClassType(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.toUnsafe())
|
||||
fun IrType.isKotlinResult(): Boolean = isNotNullClassType(KotlinBuiltInsNames.RESULT_FQ_NAME.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.psiType
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
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.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -316,7 +317,7 @@ internal fun KtModifierListOwner.isHiddenByDeprecation(support: KtUltraLightSupp
|
||||
annotation.looksLikeDeprecated()
|
||||
}
|
||||
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"
|
||||
} else {
|
||||
return false
|
||||
@@ -361,7 +362,7 @@ internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = nu
|
||||
val modifierList = this.modifierList ?: return false
|
||||
if (modifierList.annotationEntries.isEmpty()) return false
|
||||
|
||||
val deprecatedFqName = KotlinBuiltIns.FQ_NAMES.deprecated
|
||||
val deprecatedFqName = KotlinBuiltInsNames.FqNames.deprecated
|
||||
val deprecatedName = deprecatedFqName.shortName().asString()
|
||||
|
||||
for (annotationEntry in modifierList.annotationEntries) {
|
||||
@@ -374,7 +375,7 @@ internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = nu
|
||||
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? {
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiNameValuePair
|
||||
import org.jetbrains.kotlin.asJava.classes.KtUltraLightSimpleAnnotation
|
||||
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.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
@@ -64,7 +64,7 @@ private val targetMapping = hashMapOf(
|
||||
|
||||
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")
|
||||
?: extractAnnotationFqName("value")?.let { listOf(it) }
|
||||
@@ -101,7 +101,7 @@ internal fun createRetentionRuntimeAnnotation(support: KtUltraLightSupport, pare
|
||||
|
||||
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")
|
||||
?.let { retentionMapping[it] }
|
||||
@@ -118,7 +118,7 @@ internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport):
|
||||
|
||||
internal fun PsiAnnotation.tryConvertAsMustBeDocumented(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
|
||||
|
||||
if (FQ_NAMES.mustBeDocumented.asString() != qualifiedName) return null
|
||||
if (FqNames.mustBeDocumented.asString() != qualifiedName) return null
|
||||
|
||||
return KtUltraLightSimpleAnnotation(
|
||||
JAVA_LANG_ANNOTATION_DOCUMENTED,
|
||||
@@ -126,4 +126,4 @@ internal fun PsiAnnotation.tryConvertAsMustBeDocumented(support: KtUltraLightSup
|
||||
support,
|
||||
parent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.lexer.KtToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
@@ -178,7 +178,7 @@ public class KtPsiUtil {
|
||||
List<KtAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
||||
for (KtAnnotationEntry annotation : annotationEntries) {
|
||||
Name shortName = annotation.getShortName();
|
||||
if (KotlinBuiltIns.FQ_NAMES.deprecated.shortName().equals(shortName)) {
|
||||
if (KotlinBuiltInsNames.FqNames.deprecated.shortName().equals(shortName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
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.getValueParameterTypesFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
@@ -130,7 +130,7 @@ class PostponedArgumentsAnalyzer(
|
||||
|
||||
val convertedAnnotations = lambda.expectedType?.annotations?.let { 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(
|
||||
@@ -218,4 +218,4 @@ class PostponedArgumentsAnalyzer(
|
||||
private inline fun <T> UnwrappedType?.forFunctionalType(f: UnwrappedType.() -> T?): T? {
|
||||
return if (this?.isBuiltinFunctionalType == true) f(this) else null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.results
|
||||
import gnu.trove.THashSet
|
||||
import gnu.trove.TObjectHashingStrategy
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
||||
@@ -309,10 +310,10 @@ open class OverloadingConflictResolver<C : Any>(
|
||||
val isGeneralUnsigned = UnsignedTypes.isUnsignedType(general)
|
||||
return when {
|
||||
isSpecificUnsigned && isGeneralUnsigned -> {
|
||||
val uLong = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uLong)?.defaultType ?: return false
|
||||
val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt)?.defaultType ?: return false
|
||||
val uByte = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uByte)?.defaultType ?: return false
|
||||
val uShort = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uShort)?.defaultType ?: return false
|
||||
val uLong = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uLong)?.defaultType ?: return false
|
||||
val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uInt)?.defaultType ?: return false
|
||||
val uByte = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uByte)?.defaultType ?: return false
|
||||
val uShort = module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uShort)?.defaultType ?: return false
|
||||
|
||||
isNonSubtypeNotLessSpecific(specific, general, _double, _float, uLong, uInt, uByte, uShort)
|
||||
}
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@
|
||||
|
||||
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.descriptors.CallableDescriptor
|
||||
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.resolve.SINCE_KOTLIN_FQ_NAME
|
||||
|
||||
private val kotlin: FqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
private val kotlinText: FqName = KotlinBuiltIns.TEXT_PACKAGE_FQ_NAME
|
||||
private val kotlinCollections: FqName = KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME
|
||||
private val kotlin: FqName = KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
|
||||
private val kotlinText: FqName = KotlinBuiltInsNames.TEXT_PACKAGE_FQ_NAME
|
||||
private val kotlinCollections: FqName = KotlinBuiltInsNames.COLLECTIONS_PACKAGE_FQ_NAME
|
||||
private val kotlinStreams: FqName = kotlin.child(Name.identifier("streams"))
|
||||
|
||||
private val use: Name = Name.identifier("use")
|
||||
@@ -43,7 +43,7 @@ private val remove: Name = Name.identifier("remove")
|
||||
fun CallableDescriptor.isLowPriorityFromStdlibJre7Or8(): Boolean {
|
||||
val containingPackage = containingDeclaration as? PackageFragmentDescriptor ?: return false
|
||||
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 =
|
||||
packageFqName == kotlin && name == use ||
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
// Add the directive `// WITH_COROUTINES` to use these helpers in codegen tests (see TestFiles.java).
|
||||
fun createTextForCoroutineHelpers(isReleaseCoroutines: Boolean, checkStateMachine: Boolean, checkTailCallOptimization: Boolean): String {
|
||||
val coroutinesPackage =
|
||||
if (isReleaseCoroutines)
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString()
|
||||
KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.asString()
|
||||
else
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
|
||||
KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
|
||||
|
||||
val emptyContinuationBody =
|
||||
if (isReleaseCoroutines)
|
||||
@@ -197,4 +197,4 @@ fun createTextForCodegenTestHelpers(backend: TargetBackend) =
|
||||
|package helpers
|
||||
|
|
||||
|fun isIR() = ${backend.isIR}
|
||||
""".trimMargin()
|
||||
""".trimMargin()
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.TestsCompilerError
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector
|
||||
@@ -125,7 +126,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
|
||||
val languageVersionSettings =
|
||||
if (coroutinesPackage.isNotEmpty()) {
|
||||
val isExperimental = coroutinesPackage == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
|
||||
val isExperimental = coroutinesPackage == KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString()
|
||||
CompilerTestLanguageVersionSettings(
|
||||
DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
|
||||
if (isExperimental) ApiVersion.KOTLIN_1_2 else ApiVersion.KOTLIN_1_3,
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import java.io.File
|
||||
|
||||
@@ -16,6 +16,6 @@ abstract class AbstractDiagnosticsTestWithStdLib : AbstractDiagnosticsTest() {
|
||||
|
||||
override fun shouldValidateFirTestData(testDataFile: File): Boolean {
|
||||
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
-4
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
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.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.script.loadScriptingPlugin
|
||||
import org.jetbrains.kotlin.test.*
|
||||
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")) {
|
||||
result.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8())
|
||||
}
|
||||
if (DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage ||
|
||||
fileText.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())
|
||||
if (KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage ||
|
||||
fileText.contains(KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())
|
||||
) {
|
||||
result.add(ForTestCompileRuntime.coroutinesCompatForTests())
|
||||
}
|
||||
@@ -158,4 +158,4 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
|
||||
return file.name.endsWith(KotlinParserDefinition.STD_SCRIPT_EXT)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,10 +11,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.TestsRuntimeError;
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames;
|
||||
import org.jetbrains.kotlin.codegen.ir.AbstractFirBlackBoxCodegenTest;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||
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;
|
||||
|
||||
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")
|
||||
? "_1_2" :
|
||||
getBackend().isIR() ? "_ir" : "";
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.utils.addToStdlib.firstNotNullResult
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
@@ -21,7 +21,7 @@ abstract class AbstractBytecodeListingTest : CodegenTestCase() {
|
||||
|
||||
val prefixes = when {
|
||||
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("")
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.descriptors.*;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
@@ -346,7 +346,7 @@ public abstract class ExpectedResolveData {
|
||||
FqName fqName =
|
||||
nameOrFqName.contains(".")
|
||||
? 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);
|
||||
assertNotNull("Expected class not found: " + nameOrFqName, expectedClass);
|
||||
|
||||
|
||||
+5
-2
@@ -6,7 +6,10 @@
|
||||
package org.jetbrains.kotlin.serialization.builtins
|
||||
|
||||
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.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.renderer.AnnotationArgumentsRenderingPolicy
|
||||
@@ -53,7 +56,7 @@ abstract class AbstractBuiltInsWithJDKMembersTest : KotlinTestWithEnvironment()
|
||||
verbose = true
|
||||
annotationArgumentsRenderingPolicy = AnnotationArgumentsRenderingPolicy.UNLESS_EMPTY
|
||||
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.ImmutableMap
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings
|
||||
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.config.*
|
||||
import org.jetbrains.kotlin.config.JvmTarget.Companion.fromString
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import java.io.File
|
||||
import java.lang.reflect.Field
|
||||
@@ -239,12 +239,12 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
|
||||
}
|
||||
if (directives.contains("COMMON_COROUTINES_TEST")) {
|
||||
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
|
||||
includeCompatExperimentalCoroutines = true
|
||||
}
|
||||
}
|
||||
if (content.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())) {
|
||||
if (content.contains(KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())) {
|
||||
includeCompatExperimentalCoroutines = true
|
||||
}
|
||||
val fileLanguageVersionSettings: LanguageVersionSettings? = parseLanguageVersionSettings(directives)
|
||||
@@ -319,4 +319,4 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
|
||||
return TestJdkKind.MOCK_JDK
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import kotlin.Unit;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SubpackagesScope;
|
||||
@@ -75,7 +75,7 @@ public class RecursiveDescriptorComparator {
|
||||
|
||||
public static final Predicate<DeclarationDescriptor> SKIP_BUILT_INS_PACKAGES = descriptor -> {
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator;
|
||||
import java.io.File;
|
||||
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 {
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.container.ComponentProvider;
|
||||
import org.jetbrains.kotlin.container.DslKt;
|
||||
@@ -68,7 +68,7 @@ public class TypeUnifierTest extends KotlinTestWithEnvironment {
|
||||
module = DslKt.getService(container, ModuleDescriptor.class);
|
||||
|
||||
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);
|
||||
typeResolver = DslKt.getService(container, TypeResolver.class);
|
||||
x = createTypeVariable("X");
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
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.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
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.ClassifierDescriptorWithTypeParameters
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -25,7 +25,7 @@ class KlibMetadataStringTable : StringTableImpl() {
|
||||
superClassifiers[0].classId
|
||||
} else {
|
||||
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 {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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
|
||||
@@ -34,9 +23,9 @@ enum class PrimitiveType(typeName: String) {
|
||||
|
||||
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 {
|
||||
@JvmField
|
||||
+19
-19
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.builtins.jvm
|
||||
|
||||
import org.jetbrains.kotlin.builtins.CompanionObjectMapping
|
||||
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.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
|
||||
@@ -56,28 +56,28 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
}
|
||||
|
||||
val mutabilityMappings = listOf(
|
||||
mutabilityMapping<Iterable<*>>(ClassId.topLevel(FQ_NAMES.iterable), FQ_NAMES.mutableIterable),
|
||||
mutabilityMapping<Iterator<*>>(ClassId.topLevel(FQ_NAMES.iterator), FQ_NAMES.mutableIterator),
|
||||
mutabilityMapping<Collection<*>>(ClassId.topLevel(FQ_NAMES.collection), FQ_NAMES.mutableCollection),
|
||||
mutabilityMapping<List<*>>(ClassId.topLevel(FQ_NAMES.list), FQ_NAMES.mutableList),
|
||||
mutabilityMapping<Set<*>>(ClassId.topLevel(FQ_NAMES.set), FQ_NAMES.mutableSet),
|
||||
mutabilityMapping<ListIterator<*>>(ClassId.topLevel(FQ_NAMES.listIterator), FQ_NAMES.mutableListIterator),
|
||||
mutabilityMapping<Map<*, *>>(ClassId.topLevel(FQ_NAMES.map), FQ_NAMES.mutableMap),
|
||||
mutabilityMapping<Iterable<*>>(ClassId.topLevel(FqNames.iterable), FqNames.mutableIterable),
|
||||
mutabilityMapping<Iterator<*>>(ClassId.topLevel(FqNames.iterator), FqNames.mutableIterator),
|
||||
mutabilityMapping<Collection<*>>(ClassId.topLevel(FqNames.collection), FqNames.mutableCollection),
|
||||
mutabilityMapping<List<*>>(ClassId.topLevel(FqNames.list), FqNames.mutableList),
|
||||
mutabilityMapping<Set<*>>(ClassId.topLevel(FqNames.set), FqNames.mutableSet),
|
||||
mutabilityMapping<ListIterator<*>>(ClassId.topLevel(FqNames.listIterator), FqNames.mutableListIterator),
|
||||
mutabilityMapping<Map<*, *>>(ClassId.topLevel(FqNames.map), FqNames.mutableMap),
|
||||
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 {
|
||||
addTopLevel(Any::class.java, FQ_NAMES.any)
|
||||
addTopLevel(String::class.java, FQ_NAMES.string)
|
||||
addTopLevel(CharSequence::class.java, FQ_NAMES.charSequence)
|
||||
addTopLevel(Throwable::class.java, FQ_NAMES.throwable)
|
||||
addTopLevel(Cloneable::class.java, FQ_NAMES.cloneable)
|
||||
addTopLevel(Number::class.java, FQ_NAMES.number)
|
||||
addTopLevel(Comparable::class.java, FQ_NAMES.comparable)
|
||||
addTopLevel(Enum::class.java, FQ_NAMES._enum)
|
||||
addTopLevel(Annotation::class.java, FQ_NAMES.annotation)
|
||||
addTopLevel(Any::class.java, FqNames.any)
|
||||
addTopLevel(String::class.java, FqNames.string)
|
||||
addTopLevel(CharSequence::class.java, FqNames.charSequence)
|
||||
addTopLevel(Throwable::class.java, FqNames.throwable)
|
||||
addTopLevel(Cloneable::class.java, FqNames.cloneable)
|
||||
addTopLevel(Number::class.java, FqNames.number)
|
||||
addTopLevel(Comparable::class.java, FqNames.comparable)
|
||||
addTopLevel(Enum::class.java, FqNames._enum)
|
||||
addTopLevel(Annotation::class.java, FqNames.annotation)
|
||||
|
||||
for (platformCollection in mutabilityMappings) {
|
||||
addMapping(platformCollection)
|
||||
@@ -107,7 +107,7 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
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))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.builtins.jvm
|
||||
|
||||
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.deserialization.ClassDescriptorFactory
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
|
||||
@@ -49,8 +49,8 @@ class JvmBuiltInClassDescriptorFactory(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val KOTLIN_FQ_NAME = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
private val CLONEABLE_NAME = KotlinBuiltIns.FQ_NAMES.cloneable.shortName()
|
||||
val CLONEABLE_CLASS_ID = ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe())
|
||||
private val KOTLIN_FQ_NAME = KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME
|
||||
private val CLONEABLE_NAME = KotlinBuiltInsNames.FqNames.cloneable.shortName()
|
||||
val CLONEABLE_CLASS_ID = ClassId.topLevel(KotlinBuiltInsNames.FqNames.cloneable.toSafe())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.builtins.jvm
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.annotations.createDeprecatedAnnotation
|
||||
@@ -338,7 +339,7 @@ open class JvmBuiltInsSettings(
|
||||
}
|
||||
|
||||
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> =
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
|
||||
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
|
||||
|
||||
object FakePureImplementationsProvider {
|
||||
@@ -28,9 +28,9 @@ object FakePureImplementationsProvider {
|
||||
}
|
||||
|
||||
init {
|
||||
FQ_NAMES.mutableList implementedWith fqNameListOf("java.util.ArrayList", "java.util.LinkedList")
|
||||
FQ_NAMES.mutableSet implementedWith fqNameListOf("java.util.HashSet", "java.util.TreeSet", "java.util.LinkedHashSet")
|
||||
FQ_NAMES.mutableMap implementedWith fqNameListOf(
|
||||
FqNames.mutableList implementedWith fqNameListOf("java.util.ArrayList", "java.util.LinkedList")
|
||||
FqNames.mutableSet implementedWith fqNameListOf("java.util.HashSet", "java.util.TreeSet", "java.util.LinkedHashSet")
|
||||
FqNames.mutableMap implementedWith fqNameListOf(
|
||||
"java.util.HashMap", "java.util.TreeMap", "java.util.LinkedHashMap",
|
||||
"java.util.concurrent.ConcurrentHashMap", "java.util.concurrent.ConcurrentSkipListMap"
|
||||
)
|
||||
|
||||
+19
-19
@@ -16,7 +16,7 @@
|
||||
|
||||
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.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
@@ -57,8 +57,8 @@ object JavaAnnotationMapper {
|
||||
when (annotation.classId) {
|
||||
ClassId.topLevel(JAVA_TARGET_FQ_NAME) -> JavaTargetAnnotationDescriptor(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_DOCUMENTED_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.mustBeDocumented)
|
||||
ClassId.topLevel(JAVA_REPEATABLE_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.repeatable)
|
||||
ClassId.topLevel(JAVA_DOCUMENTED_FQ_NAME) -> JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.mustBeDocumented)
|
||||
ClassId.topLevel(JAVA_DEPRECATED_FQ_NAME) -> null
|
||||
else -> LazyJavaAnnotationDescriptor(c, annotation)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ object JavaAnnotationMapper {
|
||||
annotationOwner: JavaAnnotationOwner,
|
||||
c: LazyJavaResolverContext
|
||||
): AnnotationDescriptor? {
|
||||
if (kotlinName == KotlinBuiltIns.FQ_NAMES.deprecated) {
|
||||
if (kotlinName == KotlinBuiltInsNames.FqNames.deprecated) {
|
||||
val javaAnnotation = annotationOwner.findAnnotation(JAVA_DEPRECATED_FQ_NAME)
|
||||
if (javaAnnotation != null || annotationOwner.isDeprecatedInJavaDoc) {
|
||||
return JavaDeprecatedAnnotationDescriptor(javaAnnotation, c)
|
||||
@@ -84,19 +84,19 @@ object JavaAnnotationMapper {
|
||||
// kotlin.annotation.annotation is treated separately
|
||||
private val kotlinToJavaNameMap: Map<FqName, FqName> =
|
||||
mapOf(
|
||||
KotlinBuiltIns.FQ_NAMES.target to JAVA_TARGET_FQ_NAME,
|
||||
KotlinBuiltIns.FQ_NAMES.retention to JAVA_RETENTION_FQ_NAME,
|
||||
KotlinBuiltIns.FQ_NAMES.repeatable to JAVA_REPEATABLE_FQ_NAME,
|
||||
KotlinBuiltIns.FQ_NAMES.mustBeDocumented to JAVA_DOCUMENTED_FQ_NAME
|
||||
KotlinBuiltInsNames.FqNames.target to JAVA_TARGET_FQ_NAME,
|
||||
KotlinBuiltInsNames.FqNames.retention to JAVA_RETENTION_FQ_NAME,
|
||||
KotlinBuiltInsNames.FqNames.repeatable to JAVA_REPEATABLE_FQ_NAME,
|
||||
KotlinBuiltInsNames.FqNames.mustBeDocumented to JAVA_DOCUMENTED_FQ_NAME
|
||||
)
|
||||
|
||||
val javaToKotlinNameMap: Map<FqName, FqName> =
|
||||
mapOf(
|
||||
JAVA_TARGET_FQ_NAME to KotlinBuiltIns.FQ_NAMES.target,
|
||||
JAVA_RETENTION_FQ_NAME to KotlinBuiltIns.FQ_NAMES.retention,
|
||||
JAVA_DEPRECATED_FQ_NAME to KotlinBuiltIns.FQ_NAMES.deprecated,
|
||||
JAVA_REPEATABLE_FQ_NAME to KotlinBuiltIns.FQ_NAMES.repeatable,
|
||||
JAVA_DOCUMENTED_FQ_NAME to KotlinBuiltIns.FQ_NAMES.mustBeDocumented
|
||||
JAVA_TARGET_FQ_NAME to KotlinBuiltInsNames.FqNames.target,
|
||||
JAVA_RETENTION_FQ_NAME to KotlinBuiltInsNames.FqNames.retention,
|
||||
JAVA_DEPRECATED_FQ_NAME to KotlinBuiltInsNames.FqNames.deprecated,
|
||||
JAVA_REPEATABLE_FQ_NAME to KotlinBuiltInsNames.FqNames.repeatable,
|
||||
JAVA_DOCUMENTED_FQ_NAME to KotlinBuiltInsNames.FqNames.mustBeDocumented
|
||||
)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ open class JavaAnnotationDescriptor(
|
||||
class JavaDeprecatedAnnotationDescriptor(
|
||||
annotation: JavaAnnotation?,
|
||||
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 {
|
||||
mapOf(JavaAnnotationMapper.DEPRECATED_ANNOTATION_MESSAGE to StringValue("Deprecated in Java"))
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class JavaDeprecatedAnnotationDescriptor(
|
||||
class JavaTargetAnnotationDescriptor(
|
||||
annotation: JavaAnnotation,
|
||||
c: LazyJavaResolverContext
|
||||
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.target) {
|
||||
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.target) {
|
||||
override val allValueArguments by c.storageManager.createLazyValue {
|
||||
val targetArgument = when (firstArgument) {
|
||||
is JavaArrayAnnotationArgument -> JavaAnnotationTargetMapper.mapJavaTargetArguments(firstArgument.getElements())
|
||||
@@ -142,7 +142,7 @@ class JavaTargetAnnotationDescriptor(
|
||||
class JavaRetentionAnnotationDescriptor(
|
||||
annotation: JavaAnnotation,
|
||||
c: LazyJavaResolverContext
|
||||
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltIns.FQ_NAMES.retention) {
|
||||
) : JavaAnnotationDescriptor(c, annotation, KotlinBuiltInsNames.FqNames.retention) {
|
||||
override val allValueArguments by c.storageManager.createLazyValue {
|
||||
val retentionArgument = JavaAnnotationTargetMapper.mapJavaRetentionArgument(firstArgument)
|
||||
retentionArgument?.let { mapOf(JavaAnnotationMapper.RETENTION_ANNOTATION_VALUE to it) }.orEmpty()
|
||||
@@ -170,12 +170,12 @@ object JavaAnnotationTargetMapper {
|
||||
val kotlinTargets = arguments.filterIsInstance<JavaEnumValueAnnotationArgument>()
|
||||
.flatMap { mapJavaTargetArgumentByName(it.entryName?.asString()) }
|
||||
.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 ->
|
||||
val parameterDescriptor = DescriptorResolverUtils.getAnnotationParameterByName(
|
||||
JavaAnnotationMapper.TARGET_ANNOTATION_ALLOWED_TARGETS,
|
||||
module.builtIns.getBuiltInClassByFqName(KotlinBuiltIns.FQ_NAMES.target)
|
||||
module.builtIns.getBuiltInClassByFqName(KotlinBuiltInsNames.FqNames.target)
|
||||
)
|
||||
parameterDescriptor?.type ?: ErrorUtils.createErrorType("Error: AnnotationTarget[]")
|
||||
}
|
||||
@@ -191,7 +191,7 @@ object JavaAnnotationTargetMapper {
|
||||
// Map argument: java.lang.annotation.Retention -> kotlin.annotation.Retention
|
||||
return (element as? JavaEnumValueAnnotationArgument)?.let {
|
||||
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
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
|
||||
@@ -38,7 +38,7 @@ class LazyJavaAnnotations(
|
||||
override fun iterator() =
|
||||
(annotationOwner.annotations.asSequence().map(annotationDescriptors) +
|
||||
JavaAnnotationMapper.findMappedJavaAnnotation(
|
||||
KotlinBuiltIns.FQ_NAMES.deprecated,
|
||||
KotlinBuiltInsNames.FqNames.deprecated,
|
||||
annotationOwner,
|
||||
c
|
||||
)).filterNotNull().iterator()
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.jvm.createMappedTypeParametersSubstitution
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -225,7 +226,7 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
private fun getPurelyImplementedSupertype(): KotlinType? {
|
||||
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 =
|
||||
|
||||
+4
-4
@@ -16,6 +16,7 @@
|
||||
|
||||
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.ClassifierDescriptor
|
||||
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.resolve.DescriptorFactory.createEnumValueOfMethod
|
||||
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.MemberScope
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
@@ -46,7 +46,7 @@ class LazyJavaStaticClassScope(
|
||||
declaredMemberIndex().getMethodNames().toMutableSet().apply {
|
||||
addAll(ownerDescriptor.getParentJavaStaticClassScope()?.getFunctionNames().orEmpty())
|
||||
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) {
|
||||
when (name) {
|
||||
DescriptorUtils.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(ownerDescriptor))
|
||||
DescriptorUtils.ENUM_VALUES -> result.add(createEnumValuesMethod(ownerDescriptor))
|
||||
KotlinBuiltInsNames.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(ownerDescriptor))
|
||||
KotlinBuiltInsNames.ENUM_VALUES -> result.add(createEnumValuesMethod(ownerDescriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package org.jetbrains.kotlin.load.java
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.FqNames
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo
|
||||
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.jvm.JvmPrimitiveType
|
||||
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 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 {
|
||||
val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf(
|
||||
BUILTIN_NAMES._enum.childSafe("name") to Name.identifier("name"),
|
||||
BUILTIN_NAMES._enum.childSafe("ordinal") to Name.identifier("ordinal"),
|
||||
BUILTIN_NAMES.collection.child("size") to Name.identifier("size"),
|
||||
BUILTIN_NAMES.map.child("size") to Name.identifier("size"),
|
||||
BUILTIN_NAMES.charSequence.childSafe("length") to Name.identifier("length"),
|
||||
BUILTIN_NAMES.map.child("keys") to Name.identifier("keySet"),
|
||||
BUILTIN_NAMES.map.child("values") to Name.identifier("values"),
|
||||
BUILTIN_NAMES.map.child("entries") to Name.identifier("entrySet")
|
||||
FqNames._enum.childSafe("name") to Name.identifier("name"),
|
||||
FqNames._enum.childSafe("ordinal") to Name.identifier("ordinal"),
|
||||
FqNames.collection.child("size") to Name.identifier("size"),
|
||||
FqNames.map.child("size") to Name.identifier("size"),
|
||||
FqNames.charSequence.childSafe("length") to Name.identifier("length"),
|
||||
FqNames.map.child("keys") to Name.identifier("keySet"),
|
||||
FqNames.map.child("values") to Name.identifier("values"),
|
||||
FqNames.map.child("entries") to Name.identifier("entrySet")
|
||||
)
|
||||
|
||||
private val GETTER_JVM_NAME_TO_PROPERTIES_SHORT_NAME_MAP: Map<Name, List<Name>> =
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -58,7 +58,7 @@ fun forceSingleValueParameterBoxing(f: CallableDescriptor): Boolean {
|
||||
?: return false
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
@@ -47,7 +48,7 @@ private fun KotlinType.requiresFunctionNameManglingInParameterTypes() =
|
||||
isInlineClassThatRequiresMangling() || isTypeParameterWithUpperBoundThatRequiresMangling()
|
||||
|
||||
private fun isDontMangleClass(classDescriptor: ClassDescriptor) =
|
||||
classDescriptor.fqNameSafe == DescriptorUtils.RESULT_FQ_NAME
|
||||
classDescriptor.fqNameSafe == KotlinBuiltInsNames.RESULT_FQ_NAME
|
||||
|
||||
private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean {
|
||||
val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false
|
||||
|
||||
+5
-5
@@ -16,8 +16,11 @@
|
||||
|
||||
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.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.header.KotlinClassHeader
|
||||
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.Field
|
||||
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")
|
||||
private val TYPES_ELIGIBLE_FOR_SIMPLE_VISIT = setOf<Class<*>>(
|
||||
@@ -196,7 +196,7 @@ private object ReflectClassStructure {
|
||||
if (currentClass.isPrimitive) {
|
||||
if (currentClass == Void.TYPE) {
|
||||
// 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
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
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.kotlin.KotlinClassFinder
|
||||
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 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))
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.util.*
|
||||
object CompanionObjectMapping {
|
||||
private val classIds =
|
||||
(PrimitiveType.NUMBER_TYPES.map(KotlinBuiltIns::getPrimitiveFqName) +
|
||||
KotlinBuiltIns.FQ_NAMES.string.toSafe() +
|
||||
KotlinBuiltIns.FQ_NAMES._boolean.toSafe() +
|
||||
KotlinBuiltIns.FQ_NAMES._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel)
|
||||
KotlinBuiltInsNames.FqNames.string.toSafe() +
|
||||
KotlinBuiltInsNames.FqNames._boolean.toSafe() +
|
||||
KotlinBuiltInsNames.FqNames._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel)
|
||||
|
||||
fun allClassesWithIntrinsicCompanions(): Set<ClassId> =
|
||||
Collections.unmodifiableSet(classIds)
|
||||
|
||||
@@ -33,31 +33,11 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
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.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE;
|
||||
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 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 final NotNullLazyValue<Primitives> primitives;
|
||||
@@ -67,7 +47,6 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
private final StorageManager storageManager;
|
||||
|
||||
public static final FqNames FQ_NAMES = new FqNames();
|
||||
public static final Name BUILTINS_MODULE_NAME = Name.special("<built-ins module>");
|
||||
|
||||
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
|
||||
public ModuleDescriptorImpl getBuiltInsModule() {
|
||||
return builtInsModule;
|
||||
@@ -516,107 +366,107 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKClass() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kClass.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kClass.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKCallable() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kCallable.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kCallable.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKProperty() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kPropertyFqName.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kPropertyFqName.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKProperty0() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kProperty0.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kProperty0.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKProperty1() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kProperty1.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kProperty1.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKProperty2() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kProperty2.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kProperty2.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKMutableProperty0() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty0.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kMutableProperty0.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKMutableProperty1() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty1.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kMutableProperty1.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getKMutableProperty2() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.kMutableProperty2.toSafe());
|
||||
return getBuiltInClassByFqName(FqNames.kMutableProperty2.toSafe());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getIterator() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.iterator);
|
||||
return getBuiltInClassByFqName(FqNames.iterator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getIterable() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.iterable);
|
||||
return getBuiltInClassByFqName(FqNames.iterable);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableIterable() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableIterable);
|
||||
return getBuiltInClassByFqName(FqNames.mutableIterable);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableIterator() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableIterator);
|
||||
return getBuiltInClassByFqName(FqNames.mutableIterator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getCollection() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.collection);
|
||||
return getBuiltInClassByFqName(FqNames.collection);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableCollection() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableCollection);
|
||||
return getBuiltInClassByFqName(FqNames.mutableCollection);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getList() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.list);
|
||||
return getBuiltInClassByFqName(FqNames.list);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableList() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableList);
|
||||
return getBuiltInClassByFqName(FqNames.mutableList);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getSet() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.set);
|
||||
return getBuiltInClassByFqName(FqNames.set);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableSet() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableSet);
|
||||
return getBuiltInClassByFqName(FqNames.mutableSet);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMap() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.map);
|
||||
return getBuiltInClassByFqName(FqNames.map);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableMap() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableMap);
|
||||
return getBuiltInClassByFqName(FqNames.mutableMap);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -635,12 +485,12 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getListIterator() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.listIterator);
|
||||
return getBuiltInClassByFqName(FqNames.listIterator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getMutableListIterator() {
|
||||
return getBuiltInClassByFqName(FQ_NAMES.mutableListIterator);
|
||||
return getBuiltInClassByFqName(FqNames.mutableListIterator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -814,20 +664,20 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveArray(@NotNull FqNameUnsafe arrayFqName) {
|
||||
return FQ_NAMES.arrayClassFqNameToPrimitiveType.get(arrayFqName) != null;
|
||||
return FqNames.arrayClassFqNameToPrimitiveType.get(arrayFqName) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PrimitiveType getPrimitiveType(@NotNull DeclarationDescriptor descriptor) {
|
||||
return FQ_NAMES.primitiveTypeShortNames.contains(descriptor.getName())
|
||||
? FQ_NAMES.fqNameToPrimitiveType.get(getFqName(descriptor))
|
||||
return FqNames.primitiveTypeShortNames.contains(descriptor.getName())
|
||||
? FqNames.fqNameToPrimitiveType.get(getFqName(descriptor))
|
||||
: null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PrimitiveType getPrimitiveArrayType(@NotNull DeclarationDescriptor descriptor) {
|
||||
return FQ_NAMES.primitiveArrayTypeShortNames.contains(descriptor.getName())
|
||||
? FQ_NAMES.arrayClassFqNameToPrimitiveType.get(getFqName(descriptor))
|
||||
return FqNames.primitiveArrayTypeShortNames.contains(descriptor.getName())
|
||||
? FqNames.arrayClassFqNameToPrimitiveType.get(getFqName(descriptor))
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -850,11 +700,11 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return classFqNameEquals(descriptor, FQ_NAMES.array) || getPrimitiveArrayType(descriptor) != null;
|
||||
return classFqNameEquals(descriptor, FqNames.array) || getPrimitiveArrayType(descriptor) != null;
|
||||
}
|
||||
|
||||
public static boolean isArrayOrPrimitiveArray(@NotNull KotlinType type) {
|
||||
@@ -915,59 +765,59 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return classFqNameEquals(descriptor, FQ_NAMES.any);
|
||||
return classFqNameEquals(descriptor, FqNames.any);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._boolean);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._boolean);
|
||||
}
|
||||
|
||||
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) {
|
||||
return classFqNameEquals(classDescriptor, FQ_NAMES._boolean);
|
||||
return classFqNameEquals(classDescriptor, FqNames._boolean);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._char);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._char);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._int);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._int);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._long);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._long);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._short);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._short);
|
||||
}
|
||||
|
||||
public static boolean isFloat(@NotNull KotlinType type) {
|
||||
@@ -975,7 +825,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -983,23 +833,23 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uShortFqName.toUnsafe());
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames.uShortFqName.toUnsafe());
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.uLongFqName.toUnsafe());
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames.uLongFqName.toUnsafe());
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -1017,11 +867,11 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.any);
|
||||
return isConstructedFromGivenClass(type, FqNames.any);
|
||||
}
|
||||
|
||||
public static boolean isNullableAny(@NotNull KotlinType type) {
|
||||
@@ -1033,11 +883,11 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.unit);
|
||||
return isConstructedFromGivenClass(type, FqNames.unit);
|
||||
}
|
||||
|
||||
public boolean isBooleanOrSubtype(@NotNull KotlinType type) {
|
||||
@@ -1049,78 +899,78 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._enum);
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames._enum);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.comparable.toUnsafe());
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FqNames.comparable.toUnsafe());
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string);
|
||||
return type != null && isNotNullConstructedFromGivenClass(type, FqNames.string);
|
||||
}
|
||||
|
||||
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) {
|
||||
return type != null && isConstructedFromGivenClass(type, FQ_NAMES.string);
|
||||
return type != null && isConstructedFromGivenClass(type, FqNames.string);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.list);
|
||||
return isConstructedFromGivenClass(type, FqNames.list);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.map);
|
||||
return isConstructedFromGivenClass(type, FqNames.map);
|
||||
}
|
||||
|
||||
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) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.throwable);
|
||||
return isConstructedFromGivenClass(type, FqNames.throwable);
|
||||
}
|
||||
|
||||
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) {
|
||||
return classFqNameEquals(descriptor, FQ_NAMES.array);
|
||||
return classFqNameEquals(descriptor, FqNames.array);
|
||||
}
|
||||
|
||||
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
|
||||
// To check that a referenced descriptor is actually deprecated at call-site, use DeprecationResolver
|
||||
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) {
|
||||
boolean isVar = ((PropertyDescriptor) declarationDescriptor).isVar();
|
||||
@@ -1133,7 +983,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -5,27 +5,23 @@
|
||||
|
||||
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.annotations.Annotations
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
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.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
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) {
|
||||
private val kotlinReflectScope: MemberScope by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
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) }
|
||||
|
||||
fun hasKCallableTypeFqName(type: KotlinType): Boolean =
|
||||
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kCallable)
|
||||
hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kCallable)
|
||||
|
||||
fun hasKMutablePropertyTypeFqName(type: KotlinType): Boolean =
|
||||
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kMutablePropertyFqName)
|
||||
hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kMutablePropertyFqName)
|
||||
|
||||
fun isNumberedKMutablePropertyType(type: KotlinType): Boolean {
|
||||
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
|
||||
return hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty0) ||
|
||||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty1) ||
|
||||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty2)
|
||||
return hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty0) ||
|
||||
hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty1) ||
|
||||
hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kMutableProperty2)
|
||||
}
|
||||
|
||||
fun isNumberedTypeWithOneOrMoreNumber(type: KotlinType): Boolean {
|
||||
@@ -146,13 +142,13 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
}
|
||||
|
||||
fun hasKPropertyTypeFqName(type: KotlinType): Boolean =
|
||||
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kPropertyFqName)
|
||||
hasFqName(type.constructor, KotlinBuiltInsNames.FqNames.kPropertyFqName)
|
||||
|
||||
fun isNumberedKPropertyType(type: KotlinType): Boolean {
|
||||
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
|
||||
return hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty0) ||
|
||||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty1) ||
|
||||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kProperty2)
|
||||
return hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty0) ||
|
||||
hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty1) ||
|
||||
hasFqName(descriptor, KotlinBuiltInsNames.FqNames.kProperty2)
|
||||
}
|
||||
|
||||
fun isNumberedKFunctionOrKSuspendFunction(type: KotlinType): Boolean {
|
||||
@@ -184,7 +180,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
}
|
||||
|
||||
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,
|
||||
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single())))
|
||||
}
|
||||
@@ -207,7 +203,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
|| 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
|
||||
|| shortName.startsWith("SuspendFunction")
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ object UnsignedTypes {
|
||||
fun isUnsignedClass(descriptor: DeclarationDescriptor): Boolean {
|
||||
val container = descriptor.containingDeclaration
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user