Move static constants with builtin names to :core:descriptors.common module
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME
|
||||
import org.jetbrains.kotlin.builtins.functions.BuiltInFictitiousFunctionClassFactory
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
@@ -86,7 +87,7 @@ val DeclarationDescriptor.isBuiltinFunctionalClassDescriptor: Boolean
|
||||
}
|
||||
|
||||
fun isBuiltinFunctionClass(classId: ClassId): Boolean {
|
||||
if (!classId.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return false
|
||||
if (!classId.startsWith(KotlinBuiltInsNames.BUILT_INS_PACKAGE_NAME)) return false
|
||||
|
||||
val kind = classId.asSingleFqName().toUnsafe().getFunctionalClassKind()
|
||||
return kind == FunctionClassDescriptor.Kind.Function ||
|
||||
@@ -103,14 +104,14 @@ val KotlinType.isBuiltinExtensionFunctionalType: Boolean
|
||||
get() = isBuiltinFunctionalType && isTypeAnnotatedWithExtensionFunctionType
|
||||
|
||||
private val KotlinType.isTypeAnnotatedWithExtensionFunctionType: Boolean
|
||||
get() = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType) != null
|
||||
get() = annotations.findAnnotation(KotlinBuiltInsNames.FqNames.extensionFunctionType) != null
|
||||
|
||||
/**
|
||||
* @return true if this is an FQ name of a fictitious class representing the function type,
|
||||
* e.g. kotlin.Function1 (but NOT kotlin.reflect.KFunction1)
|
||||
*/
|
||||
fun isNumberedFunctionClassFqName(fqName: FqNameUnsafe): Boolean {
|
||||
return fqName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME) &&
|
||||
return fqName.startsWith(BUILT_INS_PACKAGE_NAME) &&
|
||||
fqName.getFunctionalClassKind() == FunctionClassDescriptor.Kind.Function
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ fun KotlinType.getPureArgumentsForFunctionalTypeOrSubtype(): List<KotlinType> {
|
||||
}
|
||||
|
||||
fun KotlinType.extractParameterNameFromFunctionTypeArgument(): Name? {
|
||||
val annotation = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.parameterName) ?: return null
|
||||
val annotation = annotations.findAnnotation(KotlinBuiltInsNames.FqNames.parameterName) ?: return null
|
||||
val name = (annotation.allValueArguments.values.singleOrNull() as? StringValue)
|
||||
?.value
|
||||
?.takeIf { Name.isValidIdentifier(it) }
|
||||
@@ -196,9 +197,9 @@ fun getFunctionTypeArgumentProjections(
|
||||
val name = parameterNames?.get(index)?.takeUnless { it.isSpecial }
|
||||
val typeToUse = if (name != null) {
|
||||
val parameterNameAnnotation = BuiltInAnnotationDescriptor(
|
||||
builtIns,
|
||||
KotlinBuiltIns.FQ_NAMES.parameterName,
|
||||
mapOf(Name.identifier("name") to StringValue(name.asString()))
|
||||
builtIns,
|
||||
KotlinBuiltInsNames.FqNames.parameterName,
|
||||
mapOf(Name.identifier("name") to StringValue(name.asString()))
|
||||
)
|
||||
type.replaceAnnotations(Annotations.create(type.annotations + parameterNameAnnotation))
|
||||
}
|
||||
@@ -233,16 +234,16 @@ fun createFunctionType(
|
||||
return KotlinTypeFactory.simpleNotNullType(typeAnnotations, classDescriptor, arguments)
|
||||
}
|
||||
|
||||
fun Annotations.hasExtensionFunctionAnnotation() = hasAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType)
|
||||
fun Annotations.hasExtensionFunctionAnnotation() = hasAnnotation(KotlinBuiltInsNames.FqNames.extensionFunctionType)
|
||||
|
||||
fun Annotations.withoutExtensionFunctionAnnotation() =
|
||||
FilteredAnnotations(this, true) { it != KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
|
||||
FilteredAnnotations(this, true) { it != KotlinBuiltInsNames.FqNames.extensionFunctionType }
|
||||
|
||||
fun Annotations.withExtensionFunctionAnnotation(builtIns: KotlinBuiltIns) =
|
||||
if (hasAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType)) {
|
||||
if (hasAnnotation(KotlinBuiltInsNames.FqNames.extensionFunctionType)) {
|
||||
this
|
||||
} else {
|
||||
Annotations.create(this + BuiltInAnnotationDescriptor(builtIns, KotlinBuiltIns.FQ_NAMES.extensionFunctionType, emptyMap()))
|
||||
Annotations.create(this + BuiltInAnnotationDescriptor(builtIns, KotlinBuiltInsNames.FqNames.extensionFunctionType, emptyMap()))
|
||||
}
|
||||
|
||||
fun getFunctionDescriptor(builtIns: KotlinBuiltIns, parameterCount: Int, isSuspendFunction: Boolean) =
|
||||
|
||||
+3
-3
@@ -5,8 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.builtins.functions
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
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.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractClassDescriptor
|
||||
@@ -14,7 +15,6 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
+4
-4
@@ -6,8 +6,9 @@
|
||||
package org.jetbrains.kotlin.builtins.functions
|
||||
|
||||
import org.jetbrains.kotlin.builtins.FunctionInterfacePackageFragment
|
||||
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
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.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.deserialization.ClassDescriptorFactory
|
||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
@@ -15,7 +16,6 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
@@ -78,7 +78,7 @@ fun functionInterfacePackageFragmentProvider(
|
||||
val classFactory = BuiltInFictitiousFunctionClassFactory(storageManager, module)
|
||||
val fragments = listOf(
|
||||
KOTLIN_REFLECT_FQ_NAME,
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
BUILT_INS_PACKAGE_FQ_NAME,
|
||||
COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
).map { fqName ->
|
||||
FunctionInterfacePackageFragmentImpl(classFactory, module, fqName)
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
@@ -15,7 +19,6 @@ import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
@@ -23,9 +26,9 @@ import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
private val FAKE_CONTINUATION_CLASS_DESCRIPTOR_EXPERIMENTAL =
|
||||
MutableClassDescriptor(
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL),
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL),
|
||||
ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false,
|
||||
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
).apply {
|
||||
modality = Modality.ABSTRACT
|
||||
visibility = Visibilities.PUBLIC
|
||||
@@ -39,9 +42,9 @@ private val FAKE_CONTINUATION_CLASS_DESCRIPTOR_EXPERIMENTAL =
|
||||
|
||||
private val FAKE_CONTINUATION_CLASS_DESCRIPTOR_RELEASE =
|
||||
MutableClassDescriptor(
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE),
|
||||
EmptyPackageFragmentDescriptor(ErrorUtils.getErrorModule(), COROUTINES_PACKAGE_FQ_NAME_RELEASE),
|
||||
ClassKind.INTERFACE, /* isInner = */ false, /* isExternal = */ false,
|
||||
DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
CONTINUATION_INTERFACE_FQ_NAME_RELEASE.shortName(), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
).apply {
|
||||
modality = Modality.ABSTRACT
|
||||
visibility = Visibilities.PUBLIC
|
||||
@@ -79,6 +82,6 @@ fun transformSuspendFunctionToRuntimeFunctionType(suspendFunType: KotlinType, is
|
||||
}
|
||||
|
||||
fun isContinuation(name: FqName?, isReleaseCoroutines: Boolean): Boolean {
|
||||
return if (isReleaseCoroutines) name == DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE
|
||||
else name == DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL
|
||||
return if (isReleaseCoroutines) name == CONTINUATION_INTERFACE_FQ_NAME_RELEASE
|
||||
else name == CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors.annotations
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
||||
@@ -31,9 +32,9 @@ fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
level: String = "WARNING"
|
||||
): AnnotationDescriptor {
|
||||
val replaceWithAnnotation = BuiltInAnnotationDescriptor(
|
||||
this,
|
||||
KotlinBuiltIns.FQ_NAMES.replaceWith,
|
||||
mapOf(
|
||||
this,
|
||||
KotlinBuiltInsNames.FqNames.replaceWith,
|
||||
mapOf(
|
||||
REPLACE_WITH_EXPRESSION_NAME to StringValue(replaceWith),
|
||||
REPLACE_WITH_IMPORTS_NAME to ArrayValue(emptyList()) { module ->
|
||||
module.builtIns.getArrayType(Variance.INVARIANT, stringType)
|
||||
@@ -42,14 +43,14 @@ fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
)
|
||||
|
||||
return BuiltInAnnotationDescriptor(
|
||||
this,
|
||||
KotlinBuiltIns.FQ_NAMES.deprecated,
|
||||
mapOf(
|
||||
this,
|
||||
KotlinBuiltInsNames.FqNames.deprecated,
|
||||
mapOf(
|
||||
DEPRECATED_MESSAGE_NAME to StringValue(message),
|
||||
DEPRECATED_REPLACE_WITH_NAME to AnnotationValue(replaceWithAnnotation),
|
||||
DEPRECATED_LEVEL_NAME to EnumValue(
|
||||
ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.deprecationLevel),
|
||||
Name.identifier(level)
|
||||
ClassId.topLevel(KotlinBuiltInsNames.FqNames.deprecationLevel),
|
||||
Name.identifier(level)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
@@ -28,9 +29,9 @@ fun ModuleDescriptor.resolveClassByFqName(fqName: FqName, lookupLocation: Lookup
|
||||
|
||||
fun ModuleDescriptor.findContinuationClassDescriptorOrNull(lookupLocation: LookupLocation, releaseCoroutines: Boolean) =
|
||||
if (releaseCoroutines)
|
||||
resolveClassByFqName(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE, lookupLocation)
|
||||
resolveClassByFqName(CONTINUATION_INTERFACE_FQ_NAME_RELEASE, lookupLocation)
|
||||
else
|
||||
resolveClassByFqName(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL, lookupLocation)
|
||||
resolveClassByFqName(CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL, lookupLocation)
|
||||
|
||||
fun ModuleDescriptor.findContinuationClassDescriptor(lookupLocation: LookupLocation, releaseCoroutines: Boolean) =
|
||||
findContinuationClassDescriptorOrNull(lookupLocation, releaseCoroutines).sure { "Continuation interface is not found" }
|
||||
@@ -52,4 +53,4 @@ fun DeclarationDescriptor.isTopLevelInPackage(name: String, packageName: String)
|
||||
val containingDeclaration = containingDeclaration as? PackageFragmentDescriptor ?: return false
|
||||
val packageFqName = containingDeclaration.fqName.asString()
|
||||
return packageName == packageFqName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ internal class DescriptorRendererImpl(
|
||||
|
||||
private val functionTypeAnnotationsRenderer: DescriptorRendererImpl by lazy {
|
||||
withOptions {
|
||||
excludedTypeAnnotationClasses += listOf(KotlinBuiltIns.FQ_NAMES.extensionFunctionType)
|
||||
excludedTypeAnnotationClasses += listOf(KotlinBuiltInsNames.FqNames.extensionFunctionType)
|
||||
annotationArgumentsRenderingPolicy = AnnotationArgumentsRenderingPolicy.ALWAYS_PARENTHESIZED
|
||||
} as DescriptorRendererImpl
|
||||
}
|
||||
@@ -424,7 +424,7 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
|
||||
private fun AnnotationDescriptor.isParameterName(): Boolean {
|
||||
return fqName == KotlinBuiltIns.FQ_NAMES.parameterName
|
||||
return fqName == KotlinBuiltInsNames.FqNames.parameterName
|
||||
}
|
||||
|
||||
override fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget?): String {
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.ENUM_VALUES;
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.ENUM_VALUE_OF;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getDefaultConstructorVisibility;
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
|
||||
|
||||
@@ -134,7 +136,7 @@ public class DescriptorFactory {
|
||||
@NotNull
|
||||
public static SimpleFunctionDescriptor createEnumValuesMethod(@NotNull ClassDescriptor enumClass) {
|
||||
SimpleFunctionDescriptorImpl values =
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.Companion.getEMPTY(), DescriptorUtils.ENUM_VALUES,
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.Companion.getEMPTY(), ENUM_VALUES,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, enumClass.getSource());
|
||||
return values.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
@@ -145,7 +147,7 @@ public class DescriptorFactory {
|
||||
@NotNull
|
||||
public static SimpleFunctionDescriptor createEnumValueOfMethod(@NotNull ClassDescriptor enumClass) {
|
||||
SimpleFunctionDescriptorImpl valueOf =
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.Companion.getEMPTY(), DescriptorUtils.ENUM_VALUE_OF,
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.Companion.getEMPTY(), ENUM_VALUE_OF,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, enumClass.getSource());
|
||||
ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
valueOf, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("value"), getBuiltIns(enumClass).getStringType(),
|
||||
@@ -161,11 +163,11 @@ public class DescriptorFactory {
|
||||
}
|
||||
|
||||
public static boolean isEnumValuesMethod(@NotNull FunctionDescriptor descriptor) {
|
||||
return descriptor.getName().equals(DescriptorUtils.ENUM_VALUES) && isEnumSpecialMethod(descriptor);
|
||||
return descriptor.getName().equals(ENUM_VALUES) && isEnumSpecialMethod(descriptor);
|
||||
}
|
||||
|
||||
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor descriptor) {
|
||||
return descriptor.getName().equals(DescriptorUtils.ENUM_VALUE_OF) && isEnumSpecialMethod(descriptor);
|
||||
return descriptor.getName().equals(ENUM_VALUE_OF) && isEnumSpecialMethod(descriptor);
|
||||
}
|
||||
|
||||
private static boolean isEnumSpecialMethod(@NotNull FunctionDescriptor descriptor) {
|
||||
|
||||
@@ -34,19 +34,6 @@ import static org.jetbrains.kotlin.descriptors.Modality.ABSTRACT;
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
|
||||
|
||||
public class DescriptorUtils {
|
||||
public static final Name ENUM_VALUES = Name.identifier("values");
|
||||
public static final Name ENUM_VALUE_OF = Name.identifier("valueOf");
|
||||
public static final FqName COROUTINES_PACKAGE_FQ_NAME_RELEASE = new FqName("kotlin.coroutines");
|
||||
public static final FqName COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL =
|
||||
COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("experimental"));
|
||||
public static final FqName COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL =
|
||||
COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("intrinsics"));
|
||||
public static final FqName CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL =
|
||||
COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("Continuation"));
|
||||
public static final FqName CONTINUATION_INTERFACE_FQ_NAME_RELEASE =
|
||||
COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("Continuation"));
|
||||
public static final FqName RESULT_FQ_NAME = new FqName("kotlin.Result");
|
||||
|
||||
// This JVM-specific class FQ name is declared here only because it's used in MainFunctionDetector which is in frontend
|
||||
public static final FqName JVM_NAME = new FqName("kotlin.jvm.JvmName");
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.jetbrains.kotlin.resolve.descriptorUtil
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames.ENUM_VALUE_OF
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
@@ -200,14 +202,14 @@ fun ValueParameterDescriptor.declaresOrInheritsDefaultValue(): Boolean {
|
||||
}
|
||||
|
||||
fun Annotated.isRepeatableAnnotation(): Boolean =
|
||||
annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.repeatable) != null
|
||||
annotations.findAnnotation(KotlinBuiltInsNames.FqNames.repeatable) != null
|
||||
|
||||
fun Annotated.isDocumentedAnnotation(): Boolean =
|
||||
annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.mustBeDocumented) != null
|
||||
annotations.findAnnotation(KotlinBuiltInsNames.FqNames.mustBeDocumented) != null
|
||||
|
||||
fun Annotated.getAnnotationRetention(): KotlinRetention? {
|
||||
val retentionArgumentValue =
|
||||
annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.retention)?.allValueArguments?.get(RETENTION_PARAMETER_NAME)
|
||||
annotations.findAnnotation(KotlinBuiltInsNames.FqNames.retention)?.allValueArguments?.get(RETENTION_PARAMETER_NAME)
|
||||
as? EnumValue ?: return null
|
||||
|
||||
val retentionArgumentValueName = retentionArgumentValue.enumEntryName.asString()
|
||||
@@ -344,7 +346,7 @@ private fun ClassDescriptor.getAllSuperClassesTypesIncludeItself(): List<KotlinT
|
||||
fun FunctionDescriptor.isEnumValueOfMethod(): Boolean {
|
||||
val methodTypeParameters = valueParameters
|
||||
val nullableString = builtIns.stringType.makeNullable()
|
||||
return DescriptorUtils.ENUM_VALUE_OF == name
|
||||
return ENUM_VALUE_OF == name
|
||||
&& methodTypeParameters.size == 1
|
||||
&& KotlinTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters[0].type, nullableString)
|
||||
}
|
||||
@@ -403,7 +405,7 @@ fun computeSealedSubclasses(sealedClass: ClassDescriptor): Collection<ClassDescr
|
||||
|
||||
fun DeclarationDescriptor.isPublishedApi(): Boolean {
|
||||
val descriptor = if (this is CallableMemberDescriptor) DescriptorUtils.getDirectMember(this) else this
|
||||
return descriptor.annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.publishedApi)
|
||||
return descriptor.annotations.hasAnnotation(KotlinBuiltInsNames.FqNames.publishedApi)
|
||||
}
|
||||
|
||||
fun DeclarationDescriptor.isAncestorOf(descriptor: DeclarationDescriptor, strict: Boolean): Boolean =
|
||||
|
||||
@@ -17,10 +17,14 @@
|
||||
package org.jetbrains.kotlin.resolve.constants
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
interface CompileTimeConstant<out T> {
|
||||
val isError: Boolean
|
||||
@@ -98,7 +102,7 @@ fun createIntegerValueTypeConstant(
|
||||
}
|
||||
|
||||
fun hasUnsignedTypesInModuleDependencies(module: ModuleDescriptor): Boolean {
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) != null
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uInt) != null
|
||||
}
|
||||
|
||||
class UnsignedErrorValueTypeConstant(
|
||||
|
||||
+5
-4
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.constants
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -65,10 +66,10 @@ class IntegerValueTypeConstructor(
|
||||
}
|
||||
|
||||
private fun addUnsignedSuperTypes() {
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltIns.FQ_NAMES.uInt))
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltIns.FQ_NAMES.uByte))
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltIns.FQ_NAMES.uShort))
|
||||
supertypes.add(module.unsignedType(KotlinBuiltIns.FQ_NAMES.uLong))
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltInsNames.FqNames.uInt))
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltInsNames.FqNames.uByte))
|
||||
checkBoundsAndAddSuperType(value, module.unsignedType(KotlinBuiltInsNames.FqNames.uShort))
|
||||
supertypes.add(module.unsignedType(KotlinBuiltInsNames.FqNames.uLong))
|
||||
}
|
||||
|
||||
private fun checkBoundsAndAddSuperType(value: Long, kotlinType: KotlinType) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.constants
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
@@ -41,16 +42,16 @@ internal fun KotlinType.maxValue(): Long {
|
||||
internal fun ModuleDescriptor.unsignedType(classId: ClassId): SimpleType = findClassAcrossModuleDependencies(classId)!!.defaultType
|
||||
|
||||
internal val ModuleDescriptor.uIntType: SimpleType
|
||||
get() = unsignedType(KotlinBuiltIns.FQ_NAMES.uInt)
|
||||
get() = unsignedType(KotlinBuiltInsNames.FqNames.uInt)
|
||||
|
||||
internal val ModuleDescriptor.uLongType: SimpleType
|
||||
get() = unsignedType(KotlinBuiltIns.FQ_NAMES.uLong)
|
||||
get() = unsignedType(KotlinBuiltInsNames.FqNames.uLong)
|
||||
|
||||
internal val ModuleDescriptor.uByteType: SimpleType
|
||||
get() = unsignedType(KotlinBuiltIns.FQ_NAMES.uByte)
|
||||
get() = unsignedType(KotlinBuiltInsNames.FqNames.uByte)
|
||||
|
||||
internal val ModuleDescriptor.uShortType: SimpleType
|
||||
get() = unsignedType(KotlinBuiltIns.FQ_NAMES.uShort)
|
||||
get() = unsignedType(KotlinBuiltInsNames.FqNames.uShort)
|
||||
|
||||
internal val ModuleDescriptor.allSignedLiteralTypes: Collection<KotlinType>
|
||||
get() = listOf(builtIns.intType, builtIns.longType, builtIns.byteType, builtIns.shortType)
|
||||
@@ -58,8 +59,8 @@ internal val ModuleDescriptor.allSignedLiteralTypes: Collection<KotlinType>
|
||||
internal val ModuleDescriptor.allUnsignedLiteralTypes: Collection<KotlinType>
|
||||
get() = if (hasUnsignedTypesInModuleDependencies(this)) {
|
||||
listOf(
|
||||
unsignedType(KotlinBuiltIns.FQ_NAMES.uInt), unsignedType(KotlinBuiltIns.FQ_NAMES.uLong),
|
||||
unsignedType(KotlinBuiltIns.FQ_NAMES.uByte), unsignedType(KotlinBuiltIns.FQ_NAMES.uShort)
|
||||
unsignedType(KotlinBuiltInsNames.FqNames.uInt), unsignedType(KotlinBuiltInsNames.FqNames.uLong),
|
||||
unsignedType(KotlinBuiltInsNames.FqNames.uByte), unsignedType(KotlinBuiltInsNames.FqNames.uShort)
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.constants
|
||||
|
||||
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.TypeParameterDescriptor
|
||||
@@ -218,7 +219,7 @@ class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(value) {
|
||||
// In JVM class file, we can't represent such literal properly, so we're writing java.lang.Object instead.
|
||||
// This has no effect on the compiler front-end or other back-ends, so we use kotlin.Any for simplicity here.
|
||||
// See LanguageFeature.ProhibitTypeParametersInClassLiteralsInAnnotationArguments
|
||||
KClassValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.any.toSafe()), 0)
|
||||
KClassValue(ClassId.topLevel(KotlinBuiltInsNames.FqNames.any.toSafe()), 0)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
@@ -258,7 +259,7 @@ class StringValue(value: String) : ConstantValue<String>(value) {
|
||||
|
||||
class UByteValue(byteValue: Byte) : UnsignedValueConstant<Byte>(byteValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uByte)?.defaultType
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uByte)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UByte not found")
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ class UByteValue(byteValue: Byte) : UnsignedValueConstant<Byte>(byteValue) {
|
||||
|
||||
class UShortValue(shortValue: Short) : UnsignedValueConstant<Short>(shortValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uShort)?.defaultType
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uShort)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UShort not found")
|
||||
}
|
||||
|
||||
@@ -284,7 +285,7 @@ class UShortValue(shortValue: Short) : UnsignedValueConstant<Short>(shortValue)
|
||||
|
||||
class UIntValue(intValue: Int) : UnsignedValueConstant<Int>(intValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt)?.defaultType
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uInt)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type UInt not found")
|
||||
}
|
||||
|
||||
@@ -297,7 +298,7 @@ class UIntValue(intValue: Int) : UnsignedValueConstant<Int>(intValue) {
|
||||
|
||||
class ULongValue(longValue: Long) : UnsignedValueConstant<Long>(longValue) {
|
||||
override fun getType(module: ModuleDescriptor): KotlinType {
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uLong)?.defaultType
|
||||
return module.findClassAcrossModuleDependencies(KotlinBuiltInsNames.FqNames.uLong)?.defaultType
|
||||
?: ErrorUtils.createErrorType("Unsigned type ULong not found")
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import kotlin.jvm.functions.Function1;
|
||||
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.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations;
|
||||
@@ -251,7 +252,7 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
|
||||
@Nullable TypeParameterDescriptor typeParameter,
|
||||
@NotNull TypeProjection originalProjection
|
||||
) {
|
||||
if (!originalType.getAnnotations().hasAnnotation(KotlinBuiltIns.FQ_NAMES.unsafeVariance)) return substituted;
|
||||
if (!originalType.getAnnotations().hasAnnotation(KotlinBuiltInsNames.FqNames.unsafeVariance)) return substituted;
|
||||
|
||||
TypeConstructor constructor = substituted.getType().getConstructor();
|
||||
if (!(constructor instanceof NewCapturedTypeConstructor)) return substituted;
|
||||
@@ -277,11 +278,11 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
|
||||
|
||||
@NotNull
|
||||
private static Annotations filterOutUnsafeVariance(@NotNull Annotations annotations) {
|
||||
if (!annotations.hasAnnotation(KotlinBuiltIns.FQ_NAMES.unsafeVariance)) return annotations;
|
||||
if (!annotations.hasAnnotation(KotlinBuiltInsNames.FqNames.unsafeVariance)) return annotations;
|
||||
return new FilteredAnnotations(annotations, new Function1<FqName, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(@NotNull FqName name) {
|
||||
return !name.equals(KotlinBuiltIns.FQ_NAMES.unsafeVariance);
|
||||
return !name.equals(KotlinBuiltInsNames.FqNames.unsafeVariance);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlin.jvm.functions.Function1;
|
||||
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.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
@@ -499,10 +500,10 @@ public class TypeUtils {
|
||||
return longType;
|
||||
}
|
||||
|
||||
KotlinType uIntType = findByFqName(supertypes, KotlinBuiltIns.FQ_NAMES.uIntFqName);
|
||||
KotlinType uIntType = findByFqName(supertypes, KotlinBuiltInsNames.FqNames.uIntFqName);
|
||||
if (uIntType != null) return uIntType;
|
||||
|
||||
KotlinType uLongType = findByFqName(supertypes, KotlinBuiltIns.FQ_NAMES.uLongFqName);
|
||||
KotlinType uLongType = findByFqName(supertypes, KotlinBuiltInsNames.FqNames.uLongFqName);
|
||||
if (uLongType != null) return uLongType;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.types.checker
|
||||
|
||||
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.PrimitiveType
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalTypeOrSubtype
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -248,12 +248,12 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
|
||||
override fun TypeConstructorMarker.isAnyConstructor(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FQ_NAMES.any)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FqNames.any)
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.isNothingConstructor(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FQ_NAMES.nothing)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FqNames.nothing)
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.asTypeArgument(): TypeArgumentMarker {
|
||||
@@ -263,7 +263,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
|
||||
override fun TypeConstructorMarker.isUnitTypeConstructor(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FQ_NAMES.unit)
|
||||
return KotlinBuiltIns.isTypeConstructorForGivenClass(this, FqNames.unit)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +441,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
require(constructor is TypeConstructor, constructor::errorMessage)
|
||||
|
||||
val annotations = if (isExtensionFunction) {
|
||||
Annotations.create(listOf(BuiltInAnnotationDescriptor(builtIns, FQ_NAMES.extensionFunctionType, emptyMap())))
|
||||
Annotations.create(listOf(BuiltInAnnotationDescriptor(builtIns, FqNames.extensionFunctionType, emptyMap())))
|
||||
} else Annotations.EMPTY
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -467,7 +467,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
|
||||
override fun SimpleTypeMarker.isExtensionFunction(): Boolean {
|
||||
require(this is SimpleType, this::errorMessage)
|
||||
return this.hasAnnotation(FQ_NAMES.extensionFunctionType)
|
||||
return this.hasAnnotation(FqNames.extensionFunctionType)
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.replaceArguments(newArguments: List<TypeArgumentMarker>): SimpleTypeMarker {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.metadata.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.metadata.deserialization.VersionRequirementTable
|
||||
@@ -83,7 +83,7 @@ class ClassDeserializer(private val components: DeserializationComponents) {
|
||||
* but the metadata is still serialized for kotlin-reflect 1.0 to work (see BuiltInsSerializer.kt).
|
||||
*/
|
||||
val BLACK_LIST = setOf(
|
||||
ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe())
|
||||
ClassId.topLevel(KotlinBuiltInsNames.FqNames.cloneable.toSafe())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.serialization.deserialization.builtins
|
||||
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsLoader
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.NotFoundClasses
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
@@ -35,7 +35,7 @@ class BuiltInsLoaderImpl : BuiltInsLoader {
|
||||
return createBuiltInPackageFragmentProvider(
|
||||
storageManager,
|
||||
builtInsModule,
|
||||
KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAMES,
|
||||
KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAMES,
|
||||
classDescriptorFactories,
|
||||
platformDependentDeclarationFilter,
|
||||
additionalClassPartsProvider,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package kotlin.reflect.jvm.internal
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltInsNames
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.builtins.jvm.CloneableClassScope
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
@@ -259,15 +259,15 @@ internal object RuntimeTypeMapper {
|
||||
fun mapJvmClassToKotlinClassId(klass: Class<*>): ClassId {
|
||||
if (klass.isArray) {
|
||||
klass.componentType.primitiveType?.let {
|
||||
return ClassId(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, it.arrayTypeName)
|
||||
return ClassId(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME, it.arrayTypeName)
|
||||
}
|
||||
return ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.array.toSafe())
|
||||
return ClassId.topLevel(KotlinBuiltInsNames.FqNames.array.toSafe())
|
||||
}
|
||||
|
||||
if (klass == Void.TYPE) return JAVA_LANG_VOID
|
||||
|
||||
klass.primitiveType?.let {
|
||||
return ClassId(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME, it.typeName)
|
||||
return ClassId(KotlinBuiltInsNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName)
|
||||
}
|
||||
|
||||
val classId = klass.classId
|
||||
|
||||
Reference in New Issue
Block a user