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

This commit is contained in:
Dmitriy Novozhilov
2020-08-16 22:57:12 +03:00
parent 2e92fe9be9
commit 7a7fe77b8e
180 changed files with 1085 additions and 1025 deletions
@@ -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) {
@@ -1,71 +0,0 @@
/*
* 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.
*/
package org.jetbrains.kotlin.builtins
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
enum class PrimitiveType(typeName: String) {
BOOLEAN("Boolean"),
CHAR("Char"),
BYTE("Byte"),
SHORT("Short"),
INT("Int"),
FLOAT("Float"),
LONG("Long"),
DOUBLE("Double"),
;
val typeName: Name = Name.identifier(typeName)
val arrayTypeName: Name = Name.identifier("${typeName}Array")
val typeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(this.typeName) }
val arrayTypeFqName: FqName by lazy(LazyThreadSafetyMode.PUBLICATION) { KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(arrayTypeName) }
companion object {
@JvmField
val NUMBER_TYPES = setOf(CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE)
@JvmStatic
fun getByShortName(name: String): PrimitiveType? = when (name) {
"Boolean" -> BOOLEAN
"Char" -> CHAR
"Byte" -> BYTE
"Short" -> SHORT
"Int" -> INT
"Float" -> FLOAT
"Long" -> LONG
"Double" -> DOUBLE
else -> null
}
@JvmStatic
fun getByShortArrayName(name: String): PrimitiveType? = when (name) {
"BooleanArray" -> BOOLEAN
"CharArray" -> CHAR
"ByteArray" -> BYTE
"ShortArray" -> SHORT
"IntArray" -> INT
"FloatArray" -> FLOAT
"LongArray" -> LONG
"DoubleArray" -> DOUBLE
else -> null
}
}
}
@@ -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) =
@@ -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.*
@@ -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(
@@ -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 {