diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt index 117b7c25f9f..8633fb82a3e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils -public object FakePureImplementationsProvider { - public fun getPurelyImplementedInterface(classFqName: FqName): FqName? = when(classFqName) { +object FakePureImplementationsProvider { + fun getPurelyImplementedInterface(classFqName: FqName): FqName? = when(classFqName) { in MUTABLE_LISTS_IMPLEMENTATIONS -> MUTABLE_LIST_FQ_NAME in MUTABLE_MAPS_IMPLEMENTATIONS -> MUTABLE_MAP_FQ_NAME in MUTABLE_SETS_IMPLEMENTATIONS -> MUTABLE_SET_FQ_NAME diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaAnnotationMapper.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaAnnotationMapper.kt index 8581ba52921..1ba8c4926a2 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaAnnotationMapper.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/JavaAnnotationMapper.kt @@ -36,7 +36,7 @@ import java.lang.annotation.Retention import java.lang.annotation.Target import java.util.EnumSet -public object JavaAnnotationMapper { +object JavaAnnotationMapper { private val JAVA_TARGET_FQ_NAME = FqName(Target::class.java.canonicalName) private val JAVA_RETENTION_FQ_NAME = FqName(Retention::class.java.canonicalName) @@ -45,7 +45,7 @@ public object JavaAnnotationMapper { // Java8-specific thing private val JAVA_REPEATABLE_FQ_NAME = FqName("java.lang.annotation.Repeatable") - public fun mapOrResolveJavaAnnotation(annotation: JavaAnnotation, c: LazyJavaResolverContext): AnnotationDescriptor? = + fun mapOrResolveJavaAnnotation(annotation: JavaAnnotation, c: LazyJavaResolverContext): AnnotationDescriptor? = when (annotation.classId) { ClassId.topLevel(JAVA_TARGET_FQ_NAME) -> JavaTargetAnnotationDescriptor(annotation, c) ClassId.topLevel(JAVA_RETENTION_FQ_NAME) -> JavaRetentionAnnotationDescriptor(annotation, c) @@ -55,7 +55,7 @@ public object JavaAnnotationMapper { else -> c.resolveAnnotation(annotation) } - public fun findMappedJavaAnnotation(kotlinName: FqName, + fun findMappedJavaAnnotation(kotlinName: FqName, annotationOwner: JavaAnnotationOwner, c: LazyJavaResolverContext ): AnnotationDescriptor? { @@ -79,7 +79,7 @@ public object JavaAnnotationMapper { KotlinBuiltIns.FQ_NAMES.repeatable to JAVA_REPEATABLE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.mustBeDocumented to JAVA_DOCUMENTED_FQ_NAME) - public val javaToKotlinNameMap: Map = + val javaToKotlinNameMap: Map = 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, @@ -154,7 +154,7 @@ class JavaRetentionAnnotationDescriptor( override fun getAllValueArguments() = valueArguments() } -public object JavaAnnotationTargetMapper { +object JavaAnnotationTargetMapper { private val targetNameLists = mapOf("PACKAGE" to EnumSet.noneOf(KotlinTarget::class.java), "TYPE" to EnumSet.of(KotlinTarget.CLASS, KotlinTarget.FILE), "ANNOTATION_TYPE" to EnumSet.of(KotlinTarget.ANNOTATION_CLASS), @@ -169,9 +169,9 @@ public object JavaAnnotationTargetMapper { "TYPE_USE" to EnumSet.of(KotlinTarget.TYPE) ) - public fun mapJavaTargetArgumentByName(argumentName: String?): Set = targetNameLists[argumentName] ?: emptySet() + fun mapJavaTargetArgumentByName(argumentName: String?): Set = targetNameLists[argumentName] ?: emptySet() - public fun mapJavaTargetArguments(arguments: List, builtIns: KotlinBuiltIns): ConstantValue<*>? { + fun mapJavaTargetArguments(arguments: List, builtIns: KotlinBuiltIns): ConstantValue<*>? { // Map arguments: java.lang.annotation.Target -> kotlin.annotation.Target val kotlinTargets = arguments.filterIsInstance() .flatMap { mapJavaTargetArgumentByName(it.resolve()?.name?.asString()) } @@ -188,7 +188,7 @@ public object JavaAnnotationTargetMapper { "SOURCE" to KotlinRetention.SOURCE ) - public fun mapJavaRetentionArgument(element: JavaAnnotationArgument, builtIns: KotlinBuiltIns): ConstantValue<*>? { + fun mapJavaRetentionArgument(element: JavaAnnotationArgument, builtIns: KotlinBuiltIns): ConstantValue<*>? { // Map argument: java.lang.annotation.Retention -> kotlin.annotation.annotation return (element as? JavaEnumValueAnnotationArgument)?.let { retentionNameList[it.resolve()?.name?.asString()]?.let { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt index 391c9795877..491094ff9be 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.types.KotlinType -public interface SamConversionResolver { - public companion object EMPTY : SamConversionResolver { +interface SamConversionResolver { + companion object EMPTY : SamConversionResolver { override fun resolveSamAdapter(original: D) = null override fun resolveSamConstructor(constructorOwner: DeclarationDescriptor, classifier: () -> ClassifierDescriptor?) = null override fun resolveFunctionTypeIfSamInterface( @@ -33,11 +33,11 @@ public interface SamConversionResolver { ): KotlinType? = null } - public fun resolveSamConstructor(constructorOwner: DeclarationDescriptor, classifier: () -> ClassifierDescriptor?): SamConstructorDescriptor? + fun resolveSamConstructor(constructorOwner: DeclarationDescriptor, classifier: () -> ClassifierDescriptor?): SamConstructorDescriptor? - public fun resolveSamAdapter(original: D): D? + fun resolveSamAdapter(original: D): D? - public fun resolveFunctionTypeIfSamInterface( + fun resolveFunctionTypeIfSamInterface( classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor ): KotlinType? diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt index c17e97e63e0..1fef0437b0f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt @@ -21,19 +21,19 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude -public class SamConstructorDescriptor( +class SamConstructorDescriptor( containingDeclaration: DeclarationDescriptor, samInterface: JavaClassDescriptor ) : SimpleFunctionDescriptorImpl( containingDeclaration, null, - samInterface.getAnnotations(), - samInterface.getName(), + samInterface.annotations, + samInterface.name, CallableMemberDescriptor.Kind.SYNTHESIZED, - samInterface.getSource() + samInterface.source ) -public object SamConstructorDescriptorKindExclude : DescriptorKindExclude() { +object SamConstructorDescriptorKindExclude : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor) = descriptor is SamConstructorDescriptor override val fullyExcludedDescriptorKinds: Int get() = 0 diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt index e1dab435b09..7ca65a2b8c3 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaPackageFragmentProvider.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.storage.MemoizedFunctionToNullable import org.jetbrains.kotlin.utils.emptyOrSingletonList -public class LazyJavaPackageFragmentProvider( +class LazyJavaPackageFragmentProvider( components: JavaResolverComponents, module: ModuleDescriptor, reflectionTypes: ReflectionTypes diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt index b0bdaee69ac..2d223404dda 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt @@ -23,11 +23,11 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import kotlin.properties.Delegates import javax.inject.Inject -public interface ModuleClassResolver { - public fun resolveClass(javaClass: JavaClass): ClassDescriptor? +interface ModuleClassResolver { + fun resolveClass(javaClass: JavaClass): ClassDescriptor? } -public class SingleModuleClassResolver() : ModuleClassResolver { +class SingleModuleClassResolver() : ModuleClassResolver { override fun resolveClass(javaClass: JavaClass): ClassDescriptor? { return resolver!!.resolveClass(javaClass) } @@ -37,6 +37,6 @@ public class SingleModuleClassResolver() : ModuleClassResolver { @Inject set } -public class ModuleClassResolverImpl(private val descriptorResolverByJavaClass: (JavaClass) -> JavaDescriptorResolver): ModuleClassResolver { +class ModuleClassResolverImpl(private val descriptorResolverByJavaClass: (JavaClass) -> JavaDescriptorResolver): ModuleClassResolver { override fun resolveClass(javaClass: JavaClass): ClassDescriptor? = descriptorResolverByJavaClass(javaClass).resolveClass(javaClass) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JavaDescriptorUtil.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JavaDescriptorUtil.kt index a41d2760e45..626c7f6f2ce 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JavaDescriptorUtil.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JavaDescriptorUtil.kt @@ -20,5 +20,5 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor // Currently getter is null iff it's loaded from Java field -public val PropertyDescriptor.isJavaField: Boolean +val PropertyDescriptor.isJavaField: Boolean get() = getter == null \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 23ace291778..2263fadf6c4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.utils.keysToMapExceptNulls fun LazyJavaResolverContext.resolveAnnotation(annotation: JavaAnnotation): LazyJavaAnnotationDescriptor? { - val classId = annotation.getClassId() + val classId = annotation.classId if (classId == null || isSpecialAnnotation(classId, false)) return null return LazyJavaAnnotationDescriptor(this, annotation) } @@ -74,12 +74,12 @@ class LazyJavaAnnotationDescriptor( override fun getSource() = source private fun computeValueArguments(): Map> { - val constructors = getAnnotationClass().getConstructors() + val constructors = getAnnotationClass().constructors if (constructors.isEmpty()) return mapOf() - val nameToArg = javaAnnotation.getArguments().toMapBy { it.name } + val nameToArg = javaAnnotation.arguments.toMapBy { it.name } - return constructors.first().getValueParameters().keysToMapExceptNulls { valueParameter -> + return constructors.first().valueParameters.keysToMapExceptNulls { valueParameter -> var javaAnnotationArgument = nameToArg[valueParameter.getName()] if (javaAnnotationArgument == null && valueParameter.getName() == DEFAULT_ANNOTATION_MEMBER_NAME) { javaAnnotationArgument = nameToArg[null] @@ -89,7 +89,7 @@ class LazyJavaAnnotationDescriptor( } } - private fun getAnnotationClass() = getType().getConstructor().getDeclarationDescriptor() as ClassDescriptor + private fun getAnnotationClass() = getType().getConstructor().declarationDescriptor as ClassDescriptor private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): ConstantValue<*>? { return when (argument) { @@ -116,18 +116,18 @@ class LazyJavaAnnotationDescriptor( val values = elements.map { argument -> resolveAnnotationArgument(argument) ?: factory.createNullValue() } - return factory.createArrayValue(values, valueParameter.getType()) + return factory.createArrayValue(values, valueParameter.type) } private fun resolveFromEnumValue(element: JavaField?): ConstantValue<*>? { - if (element == null || !element.isEnumEntry()) return null + if (element == null || !element.isEnumEntry) return null - val containingJavaClass = element.getContainingClass() + val containingJavaClass = element.containingClass //TODO: (module refactoring) moduleClassResolver should be used here val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) ?: return null - val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER) + val classifier = enumClass.unsubstitutedInnerClassesScope.getContributedClassifier(element.name, NoLookupLocation.FROM_JAVA_LOADER) if (classifier !is ClassDescriptor) return null return factory.createEnumValue(classifier) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 9e1399f3db8..5c780dfffcf 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -57,18 +57,18 @@ class LazyJavaClassDescriptor( } private val kind = when { - jClass.isAnnotationType() -> ClassKind.ANNOTATION_CLASS - jClass.isInterface() -> ClassKind.INTERFACE - jClass.isEnum() -> ClassKind.ENUM_CLASS + jClass.isAnnotationType -> ClassKind.ANNOTATION_CLASS + jClass.isInterface -> ClassKind.INTERFACE + jClass.isEnum -> ClassKind.ENUM_CLASS else -> ClassKind.CLASS } - private val modality = if (jClass.isAnnotationType()) + private val modality = if (jClass.isAnnotationType) Modality.FINAL - else Modality.convertFromFlags(jClass.isAbstract() || jClass.isInterface(), !jClass.isFinal()) + else Modality.convertFromFlags(jClass.isAbstract || jClass.isInterface, !jClass.isFinal) - private val visibility = jClass.getVisibility() - private val isInner = jClass.getOuterClass() != null && !jClass.isStatic() + private val visibility = jClass.visibility + private val isInner = jClass.outerClass != null && !jClass.isStatic override fun getKind() = kind override fun getModality() = modality diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 4cc310a949f..57e144f4f44 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -60,14 +60,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.check import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import java.util.* -public class LazyJavaClassMemberScope( +class LazyJavaClassMemberScope( c: LazyJavaResolverContext, override val ownerDescriptor: ClassDescriptor, private val jClass: JavaClass ) : LazyJavaScope(c) { override fun computeMemberIndex(): MemberIndex { - return object : ClassMemberIndex(jClass, { !it.isStatic() }) { + return object : ClassMemberIndex(jClass, { !it.isStatic }) { // For SAM-constructors override fun getMethodNames(nameFilter: (Name) -> Boolean): Collection = super.getMethodNames(nameFilter) + getClassNames(DescriptorKindFilter.CLASSIFIERS, nameFilter) @@ -341,7 +341,7 @@ public class LazyJavaClassMemberScope( } override fun computeNonDeclaredProperties(name: Name, result: MutableCollection) { - if (jClass.isAnnotationType()) { + if (jClass.isAnnotationType) { computeAnnotationProperties(name, result) } @@ -506,13 +506,13 @@ public class LazyJavaClassMemberScope( classDescriptor, c.resolveAnnotations(constructor), /* isPrimary = */ false, c.components.sourceElementFactory.source(constructor) ) - val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters()) + val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.valueParameters) constructorDescriptor.initialize(valueParameters.descriptors, constructor.visibility) constructorDescriptor.setHasStableParameterNames(false) constructorDescriptor.setHasSynthesizedParameterNames(valueParameters.hasSynthesizedNames) - constructorDescriptor.setReturnType(classDescriptor.getDefaultType()) + constructorDescriptor.returnType = classDescriptor.defaultType c.components.javaResolverCache.recordConstructor(constructor, constructorDescriptor) @@ -520,8 +520,8 @@ public class LazyJavaClassMemberScope( } private fun createDefaultConstructor(): ConstructorDescriptor? { - val isAnnotation: Boolean = jClass.isAnnotationType() - if (jClass.isInterface() && !isAnnotation) + val isAnnotation: Boolean = jClass.isAnnotationType + if (jClass.isInterface && !isAnnotation) return null val classDescriptor = ownerDescriptor @@ -534,13 +534,13 @@ public class LazyJavaClassMemberScope( constructorDescriptor.initialize(valueParameters, getConstructorVisibility(classDescriptor)) constructorDescriptor.setHasStableParameterNames(true) - constructorDescriptor.setReturnType(classDescriptor.getDefaultType()) + constructorDescriptor.returnType = classDescriptor.defaultType c.components.javaResolverCache.recordConstructor(jClass, constructorDescriptor); return constructorDescriptor } private fun getConstructorVisibility(classDescriptor: ClassDescriptor): Visibility { - val visibility = classDescriptor.getVisibility() + val visibility = classDescriptor.visibility if (visibility == JavaVisibilities.PROTECTED_STATIC_VISIBILITY) { return JavaVisibilities.PROTECTED_AND_PACKAGE } @@ -548,22 +548,22 @@ public class LazyJavaClassMemberScope( } private fun createAnnotationConstructorParameters(constructor: ConstructorDescriptorImpl): List { - val methods = jClass.getMethods() + val methods = jClass.methods val result = ArrayList(methods.size) val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false, isForAnnotationParameter = true) val (methodsNamedValue, otherMethods) = methods. - partition { it.getName() == JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME } + partition { it.name == JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME } assert(methodsNamedValue.size <= 1) { "There can't be more than one method named 'value' in annotation class: $jClass" } val methodNamedValue = methodsNamedValue.firstOrNull() if (methodNamedValue != null) { - val parameterNamedValueJavaType = methodNamedValue.getReturnType() + val parameterNamedValueJavaType = methodNamedValue.returnType val (parameterType, varargType) = if (parameterNamedValueJavaType is JavaArrayType) Pair(c.typeResolver.transformArrayType(parameterNamedValueJavaType, attr, isVararg = true), - c.typeResolver.transformJavaType(parameterNamedValueJavaType.getComponentType(), attr)) + c.typeResolver.transformJavaType(parameterNamedValueJavaType.componentType, attr)) else Pair(c.typeResolver.transformJavaType(parameterNamedValueJavaType, attr), null) @@ -572,7 +572,7 @@ public class LazyJavaClassMemberScope( val startIndex = if (methodNamedValue != null) 1 else 0 for ((index, method) in otherMethods.withIndex()) { - val parameterType = c.typeResolver.transformJavaType(method.getReturnType(), attr) + val parameterType = c.typeResolver.transformJavaType(method.returnType, attr) result.addAnnotationValueParameter(constructor, index + startIndex, method, parameterType, null) } @@ -591,7 +591,7 @@ public class LazyJavaClassMemberScope( null, index, Annotations.EMPTY, - method.getName(), + method.name, // Parameters of annotation constructors in Java are never nullable TypeUtils.makeNotNullable(returnType), method.hasAnnotationParameterDefaultValue(), @@ -654,5 +654,5 @@ public class LazyJavaClassMemberScope( } } - override fun toString() = "Lazy java member scope for " + jClass.getFqName() + override fun toString() = "Lazy java member scope for " + jClass.fqName } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt index baaa36b3c3d..5c25a414fe0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.storage.getValue -public class LazyJavaPackageScope( +class LazyJavaPackageScope( c: LazyJavaResolverContext, private val jPackage: JavaPackage, override val ownerDescriptor: LazyJavaPackageFragment @@ -58,7 +58,7 @@ public class LazyJavaPackageScope( result } - public fun getFacadeSimpleNameForPartSimpleName(partName: String): String? = + fun getFacadeSimpleNameForPartSimpleName(partName: String): String? = partToFacade()[partName] private val deserializedPackageScope by c.storageManager.createLazyValue { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 8e0736d7dcc..93fbdb52971 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* -public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberScopeImpl() { +abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberScopeImpl() { protected abstract val ownerDescriptor: DeclarationDescriptor // this lazy value is not used at all in LazyPackageFragmentScopeForJavaPackage because we do not use caching there @@ -118,8 +118,8 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : val c = c.child(functionDescriptorImpl, method) - val methodTypeParameters = method.getTypeParameters().map { p -> c.typeParameterResolver.resolveTypeParameter(p)!! } - val valueParameters = resolveValueParameters(c, functionDescriptorImpl, method.getValueParameters()) + val methodTypeParameters = method.typeParameters.map { p -> c.typeParameterResolver.resolveTypeParameter(p)!! } + val valueParameters = resolveValueParameters(c, functionDescriptorImpl, method.valueParameters) val returnType = computeMethodReturnType(method, annotations, c) @@ -131,8 +131,8 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : effectiveSignature.typeParameters, effectiveSignature.valueParameters, effectiveSignature.returnType, - Modality.convertFromFlags(method.isAbstract(), !method.isFinal()), - method.getVisibility() + Modality.convertFromFlags(method.isAbstract, !method.isFinal), + method.visibility ) functionDescriptorImpl.setParameterNamesStatus(effectiveSignature.hasStableParameterNames, valueParameters.hasSynthesizedNames) @@ -145,13 +145,13 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : } protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KotlinType { - val annotationMethod = method.getContainingClass().isAnnotationType() + val annotationMethod = method.containingClass.isAnnotationType val returnTypeAttrs = LazyJavaTypeAttributes( TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations, allowFlexible = !annotationMethod, isForAnnotationParameter = annotationMethod ) - return c.typeResolver.transformJavaType(method.getReturnType(), returnTypeAttrs).let { + return c.typeResolver.transformJavaType(method.returnType, returnTypeAttrs).let { // Annotation arguments are never null in Java if (annotationMethod) TypeUtils.makeNotNullable(it) else it } @@ -171,17 +171,17 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : val annotations = c.resolveAnnotations(javaParameter) val typeUsage = LazyJavaTypeAttributes(TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT, annotations) val (outType, varargElementType) = - if (javaParameter.isVararg()) { - val paramType = javaParameter.getType() as? JavaArrayType + if (javaParameter.isVararg) { + val paramType = javaParameter.type as? JavaArrayType ?: throw AssertionError("Vararg parameter should be an array: $javaParameter") val outType = c.typeResolver.transformArrayType(paramType, typeUsage, true) outType to c.module.builtIns.getArrayElementType(outType) } else { - c.typeResolver.transformJavaType(javaParameter.getType(), typeUsage) to null + c.typeResolver.transformJavaType(javaParameter.type, typeUsage) to null } - val name = if (function.getName().asString() == "equals" && + val name = if (function.name.asString() == "equals" && jValueParameters.size == 1 && c.module.builtIns.getNullableAnyType() == outType) { // This is a hack to prevent numerous warnings on Kotlin classes that inherit Java classes: if you override "equals" in such @@ -192,7 +192,7 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : } else { // TODO: parameter names may be drawn from attached sources, which is slow; it's better to make them lazy - val javaName = javaParameter.getName() + val javaName = javaParameter.name if (javaName == null) synthesizedNames = true javaName ?: Name.identifier("p$index") } @@ -264,10 +264,10 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : } private fun createPropertyDescriptor(field: JavaField): PropertyDescriptorImpl { - val isVar = !field.isFinal() - val visibility = field.getVisibility() + val isVar = !field.isFinal + val visibility = field.visibility val annotations = c.resolveAnnotations(field) - val propertyName = field.getName() + val propertyName = field.name return JavaPropertyDescriptor(ownerDescriptor, annotations, Modality.FINAL, visibility, isVar, propertyName, c.components.sourceElementFactory.source(field), /* original = */ null, /*isConst= */ field.isFinalStatic) @@ -347,7 +347,7 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : override fun toString() = "Lazy scope for ${ownerDescriptor}" override fun printScopeStructure(p: Printer) { - p.println(javaClass.getSimpleName(), " {") + p.println(javaClass.simpleName, " {") p.pushIndent() p.println("containingDeclaration: ${ownerDescriptor}") diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt index c84fa536d95..ad6944efc22 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt @@ -33,20 +33,20 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.types.KotlinType -public class LazyJavaStaticClassScope( +class LazyJavaStaticClassScope( c: LazyJavaResolverContext, private val jClass: JavaClass, override val ownerDescriptor: LazyJavaClassDescriptor ) : LazyJavaStaticScope(c) { override fun computeMemberIndex(): MemberIndex { - val delegate = ClassMemberIndex(jClass) { it.isStatic() } + val delegate = ClassMemberIndex(jClass) { it.isStatic } return object : MemberIndex by delegate { override fun getMethodNames(nameFilter: (Name) -> Boolean): Collection { // Should be a super call, but KT-2860 return delegate.getMethodNames(nameFilter) + // For SAM-constructors - jClass.getInnerClasses().map { it.getName() } + jClass.innerClasses.map { it.name } } } } @@ -78,7 +78,7 @@ public class LazyJavaStaticClassScope( val functionsFromSupertypes = getStaticFunctionsFromJavaSuperClasses(name, ownerDescriptor) result.addAll(DescriptorResolverUtils.resolveOverrides(name, functionsFromSupertypes, result, ownerDescriptor, c.components.errorReporter)) - if (jClass.isEnum()) { + if (jClass.isEnum) { when (name) { DescriptorUtils.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(ownerDescriptor)) DescriptorUtils.ENUM_VALUES -> result.add(createEnumValuesMethod(ownerDescriptor)) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt index 6b66b9bb31a..d34ab196ac8 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.KotlinType -public abstract class LazyJavaStaticScope(c: LazyJavaResolverContext) : LazyJavaScope(c) { +abstract class LazyJavaStaticScope(c: LazyJavaResolverContext) : LazyJavaScope(c) { override fun getDispatchReceiverParameter() = null diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt index 571cc9a0a29..cfb9603f058 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.types.Variance class LazyJavaTypeParameterDescriptor( private val c: LazyJavaResolverContext, - public val javaTypeParameter: JavaTypeParameter, + val javaTypeParameter: JavaTypeParameter, index: Int, containingDeclaration: DeclarationDescriptor ) : AbstractLazyTypeParameterDescriptor( diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt index db330d93ca6..2c8dac9490a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt @@ -81,12 +81,12 @@ private fun JavaClass.getAllMemberNames(filter: (M) -> Boolean, for (member in getMembers()) { if (filter(member)) { - result.add(member.getName()) + result.add(member.name) } } - for (supertype in getSupertypes()) { - val classifier = supertype.getClassifier() + for (supertype in supertypes) { + val classifier = supertype.classifier if (classifier is JavaClass) { result.addAll(classifier.getNonDeclaredMethodNames()) classifier.visit() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/resolvers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/resolvers.kt index fa163059227..ea43a55df2b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/resolvers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/resolvers.kt @@ -45,7 +45,7 @@ class LazyJavaTypeParameterResolver( private val containingDeclaration: DeclarationDescriptor, typeParameterOwner: JavaTypeParameterListOwner ) : TypeParameterResolver { - private val typeParameters: Map = typeParameterOwner.getTypeParameters().mapToIndex() + private val typeParameters: Map = typeParameterOwner.typeParameters.mapToIndex() private val resolve = c.storageManager.createMemoizedFunctionWithNullableValues { typeParameter: JavaTypeParameter -> diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index 65dc1d03bcd..6a2bccdfce0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -45,10 +45,10 @@ class LazyJavaTypeResolver( private val typeParameterResolver: TypeParameterResolver ) { - public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KotlinType { + fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KotlinType { return when (javaType) { is JavaPrimitiveType -> { - val primitiveType = javaType.getType() + val primitiveType = javaType.type if (primitiveType != null) c.module.builtIns.getPrimitiveKotlinType(primitiveType) else c.module.builtIns.getUnitType() } @@ -64,10 +64,10 @@ class LazyJavaTypeResolver( } } - public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KotlinType { + fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KotlinType { return run { - val javaComponentType = arrayType.getComponentType() - val primitiveType = (javaComponentType as? JavaPrimitiveType)?.getType() + val javaComponentType = arrayType.componentType + val primitiveType = (javaComponentType as? JavaPrimitiveType)?.type if (primitiveType != null) { val jetType = c.module.builtIns.getPrimitiveArrayKotlinType(primitiveType) return@run if (attr.allowFlexible) @@ -101,7 +101,7 @@ class LazyJavaTypeResolver( override fun computeTypeConstructor(): TypeConstructor { val classifier = classifier() if (classifier == null) { - return ErrorUtils.createErrorTypeConstructor("Unresolved java classifier: " + javaType.getPresentableText()) + return ErrorUtils.createErrorTypeConstructor("Unresolved java classifier: " + javaType.presentableText) } return when (classifier) { is JavaClass -> { @@ -109,16 +109,16 @@ class LazyJavaTypeResolver( val classData = mapKotlinClass(fqName) ?: c.components.moduleClassResolver.resolveClass(classifier) - classData?.getTypeConstructor() - ?: ErrorUtils.createErrorTypeConstructor("Unresolved java classifier: " + javaType.getPresentableText()) + classData?.typeConstructor + ?: ErrorUtils.createErrorTypeConstructor("Unresolved java classifier: " + javaType.presentableText) } is JavaTypeParameter -> { if (isConstructorTypeParameter()) { getConstructorTypeParameterSubstitute().getConstructor() } else { - typeParameterResolver.resolveTypeParameter(classifier)?.getTypeConstructor() - ?: ErrorUtils.createErrorTypeConstructor("Unresolved Java type parameter: " + javaType.getPresentableText()) + typeParameterResolver.resolveTypeParameter(classifier)?.typeConstructor + ?: ErrorUtils.createErrorTypeConstructor("Unresolved Java type parameter: " + javaType.presentableText) } } else -> throw IllegalStateException("Unknown classifier kind: $classifier") @@ -174,18 +174,18 @@ class LazyJavaTypeResolver( } private fun isRaw(): Boolean { - if (javaType.isRaw()) return true + if (javaType.isRaw) return true // This option is needed because sometimes we get weird versions of JDK classes in the class path, // such as collections with no generics, so the Java types are not raw, formally, but they don't match with // their Kotlin analogs, so we treat them as raw to avoid exceptions // No type arguments, but some are expected => raw - return javaType.getTypeArguments().isEmpty() && !getConstructor().getParameters().isEmpty() + return javaType.typeArguments.isEmpty() && !getConstructor().parameters.isEmpty() } override fun computeArguments(): List { val typeConstructor = getConstructor() - val typeParameters = typeConstructor.getParameters() + val typeParameters = typeConstructor.parameters if (isRaw()) { return typeParameters.map { parameter -> @@ -213,12 +213,12 @@ class LazyJavaTypeResolver( return getConstructorTypeParameterSubstitute().getArguments() } - if (typeParameters.size != javaType.getTypeArguments().size) { + if (typeParameters.size != javaType.typeArguments.size) { // Most of the time this means there is an error in the Java code - return typeParameters.map { p -> TypeProjectionImpl(ErrorUtils.createErrorType(p.getName().asString())) } + return typeParameters.map { p -> TypeProjectionImpl(ErrorUtils.createErrorType(p.name.asString())) } } var howTheProjectionIsUsed = if (attr.howThisTypeIsUsed == SUPERTYPE) SUPERTYPE_ARGUMENT else TYPE_ARGUMENT - return javaType.getTypeArguments().withIndex().map { + return javaType.typeArguments.withIndex().map { javaTypeParameter -> val (i, t) = javaTypeParameter val parameter = if (i >= typeParameters.size) @@ -235,7 +235,7 @@ class LazyJavaTypeResolver( ): TypeProjection { return when (javaType) { is JavaWildcardType -> { - val bound = javaType.getBound() + val bound = javaType.bound if (bound == null) makeStarProjection(typeParameter, attr) else { @@ -278,7 +278,7 @@ class LazyJavaTypeResolver( override fun getAnnotations() = annotations } - public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities { + object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities { @JvmStatic fun create(lowerBound: KotlinType, upperBound: KotlinType) = DelegatingFlexibleType.create(lowerBound, upperBound, this) @@ -380,8 +380,8 @@ class LazyJavaTypeAttributes( private fun hasAnnotation(fqName: FqName) = typeAnnotations.findAnnotation(fqName) != null } -public fun Annotations.isMarkedNotNull() = findAnnotation(JETBRAINS_NOT_NULL_ANNOTATION) != null -public fun Annotations.isMarkedNullable() = findAnnotation(JETBRAINS_NULLABLE_ANNOTATION) != null +fun Annotations.isMarkedNotNull() = findAnnotation(JETBRAINS_NOT_NULL_ANNOTATION) != null +fun Annotations.isMarkedNullable() = findAnnotation(JETBRAINS_NULLABLE_ANNOTATION) != null fun TypeUsage.toAttributes( allowFlexible: Boolean = true, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt index af1ab88ded0..0abbe261199 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.renderer.CustomFlexibleRendering import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.types.* -public object RawTypeTag : TypeCapability +object RawTypeTag : TypeCapability -public object RawTypeCapabilities : TypeCapabilities { +object RawTypeCapabilities : TypeCapabilities { private object RawSubstitutionCapability : CustomSubstitutionCapability { override val substitution: TypeSubstitution? get() = RawSubstitution @@ -89,7 +89,7 @@ internal object RawSubstitution : TypeSubstitution() { private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND) private val upperTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND) - public fun eraseType(type: KotlinType): KotlinType { + fun eraseType(type: KotlinType): KotlinType { val declaration = type.constructor.declarationDescriptor return when (declaration) { is TypeParameterDescriptor -> eraseType(declaration.getErasedUpperBound()) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/propertiesConventionUtil.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/propertiesConventionUtil.kt index 76c37f6aad6..11b90e70e39 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/propertiesConventionUtil.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/propertiesConventionUtil.kt @@ -32,8 +32,8 @@ fun propertyNamesBySetMethodName(methodName: Name) = listOf(propertyNameBySetMethodName(methodName, false), propertyNameBySetMethodName(methodName, true)).filterNotNull() private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String, removePrefix: Boolean = true, addPrefix: String? = null): Name? { - if (methodName.isSpecial()) return null - val identifier = methodName.getIdentifier() + if (methodName.isSpecial) return null + val identifier = methodName.identifier if (!identifier.startsWith(prefix)) return null if (identifier.length == prefix.length) return null if (identifier[prefix.length] in 'a'..'z') return null diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/sources/JavaSourceElementFactory.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/sources/JavaSourceElementFactory.kt index 62f9b694930..e36402d2a74 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/sources/JavaSourceElementFactory.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/sources/JavaSourceElementFactory.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.load.java.sources import org.jetbrains.kotlin.load.java.structure.JavaElement import org.jetbrains.kotlin.descriptors.SourceElement -public interface JavaSourceElementFactory { - public fun source(javaElement: JavaElement): JavaSourceElement +interface JavaSourceElementFactory { + fun source(javaElement: JavaElement): JavaSourceElement } -public interface JavaSourceElement: SourceElement { - public val javaElement: JavaElement +interface JavaSourceElement: SourceElement { + val javaElement: JavaElement } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt index a8a78426f12..cc0e10b7150 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt @@ -79,7 +79,7 @@ object BuiltinMethodsWithSpecialGenericSignature { FqName("kotlin.MutableCollection.retainAll") ) - public enum class DefaultValue(val value: Any?) { + enum class DefaultValue(val value: Any?) { NULL(null), INDEX(-1), FALSE(false) } @@ -258,7 +258,7 @@ private fun getOverriddenBuiltinThatAffectsJvmName( return null } -public fun ClassDescriptor.hasRealKotlinSuperClassWithOverrideOf( +fun ClassDescriptor.hasRealKotlinSuperClassWithOverrideOf( specialCallableDescriptor: CallableDescriptor ): Boolean { val builtinContainerDefaultType = (specialCallableDescriptor.containingDeclaration as ClassDescriptor).defaultType @@ -286,16 +286,16 @@ public fun ClassDescriptor.hasRealKotlinSuperClassWithOverrideOf( } // Util methods -public val CallableMemberDescriptor.isFromJava: Boolean +val CallableMemberDescriptor.isFromJava: Boolean get() = propertyIfAccessor is JavaCallableMemberDescriptor && propertyIfAccessor.containingDeclaration is JavaClassDescriptor -public fun CallableMemberDescriptor.isFromBuiltins(): Boolean { +fun CallableMemberDescriptor.isFromBuiltins(): Boolean { val fqName = propertyIfAccessor.fqNameOrNull() ?: return false return fqName.toUnsafe().startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME) && this.module == this.builtIns.builtInsModule } -public fun CallableMemberDescriptor.isFromJavaOrBuiltins() = isFromJava || isFromBuiltins() +fun CallableMemberDescriptor.isFromJavaOrBuiltins() = isFromJava || isFromBuiltins() private fun Map.getInversedShortNamesMap(): Map> = entries.groupBy { it.value }.mapValues { entry -> entry.value.map { it.key.shortName() } } \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt index 87f14f8c3b1..9d70ffd61cb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPackage.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.load.java.structure import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public interface JavaPackage : JavaElement { - public fun getClasses(nameFilter: (Name) -> Boolean): Collection +interface JavaPackage : JavaElement { + fun getClasses(nameFilter: (Name) -> Boolean): Collection - public fun getSubPackages(): Collection + fun getSubPackages(): Collection - public fun getFqName(): FqName + fun getFqName(): FqName } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt index 44f2be2af9d..f660f787587 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.load.java.structure import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.resolve.constants.ConstantValue -public interface JavaPropertyInitializerEvaluator { - public fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor): ConstantValue<*>? +interface JavaPropertyInitializerEvaluator { + fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor): ConstantValue<*>? - public fun isNotNullCompileTimeConstant(field: JavaField): Boolean + fun isNotNullCompileTimeConstant(field: JavaField): Boolean - public object DoNothing : JavaPropertyInitializerEvaluator { + object DoNothing : JavaPropertyInitializerEvaluator { override fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor) = null override fun isNotNullCompileTimeConstant(field: JavaField) = false diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/annotationArguments.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/annotationArguments.kt index 7db7bae7719..ac3ae7a4819 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/annotationArguments.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/annotationArguments.kt @@ -18,26 +18,26 @@ package org.jetbrains.kotlin.load.java.structure import org.jetbrains.kotlin.name.Name -public interface JavaAnnotationArgument { - public val name: Name? +interface JavaAnnotationArgument { + val name: Name? } -public interface JavaLiteralAnnotationArgument : JavaAnnotationArgument { - public val value: Any? +interface JavaLiteralAnnotationArgument : JavaAnnotationArgument { + val value: Any? } -public interface JavaArrayAnnotationArgument : JavaAnnotationArgument { - public fun getElements(): List +interface JavaArrayAnnotationArgument : JavaAnnotationArgument { + fun getElements(): List } -public interface JavaEnumValueAnnotationArgument : JavaAnnotationArgument { - public fun resolve(): JavaField? +interface JavaEnumValueAnnotationArgument : JavaAnnotationArgument { + fun resolve(): JavaField? } -public interface JavaClassObjectAnnotationArgument : JavaAnnotationArgument { - public fun getReferencedType(): JavaType +interface JavaClassObjectAnnotationArgument : JavaAnnotationArgument { + fun getReferencedType(): JavaType } -public interface JavaAnnotationAsAnnotationArgument : JavaAnnotationArgument { - public fun getAnnotation(): JavaAnnotation +interface JavaAnnotationAsAnnotationArgument : JavaAnnotationArgument { + fun getAnnotation(): JavaAnnotation } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt index 691f6c0c562..f884655aa8e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt @@ -20,27 +20,27 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.types.KotlinType -public fun enhanceSignatures(platformSignatures: Collection): Collection { +fun enhanceSignatures(platformSignatures: Collection): Collection { return platformSignatures.map { it.enhanceSignature() } } -public fun D.enhanceSignature(): D { +fun D.enhanceSignature(): D { // TODO type parameters // TODO use new type parameters while enhancing other types // TODO Propagation into generic type arguments val enhancedReceiverType = - if (getExtensionReceiverParameter() != null) - parts(isCovariant = false) { it.getExtensionReceiverParameter()!!.getType() }.enhance() + if (extensionReceiverParameter != null) + parts(isCovariant = false) { it.extensionReceiverParameter!!.type }.enhance() else null - val enhancedValueParametersTypes = getValueParameters().map { - p -> parts(isCovariant = false) { it.getValueParameters()[p.index].getType() }.enhance() + val enhancedValueParametersTypes = valueParameters.map { + p -> parts(isCovariant = false) { it.valueParameters[p.index].type }.enhance() } - val enhancedReturnType = parts(isCovariant = true) { it.getReturnType()!! }.enhance() + val enhancedReturnType = parts(isCovariant = true) { it.returnType!! }.enhance() if (this is JavaCallableMemberDescriptor) { @Suppress("UNCHECKED_CAST") @@ -64,7 +64,7 @@ private class SignatureParts( private fun D.parts(isCovariant: Boolean, collector: (D) -> KotlinType): SignatureParts { return SignatureParts( collector(this), - this.getOverriddenDescriptors().map { + this.overriddenDescriptors.map { @Suppress("UNCHECKED_CAST") collector(it as D) }, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index aac3a3ccc31..943979101c4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -71,7 +71,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers val shouldEnhance = position.shouldEnhance() if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1) - val originalClass = getConstructor().getDeclarationDescriptor() + val originalClass = getConstructor().declarationDescriptor ?: return Result(this, 1) val effectiveQualifiers = qualifiers(index) @@ -82,12 +82,12 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers var globalArgIndex = index + 1 val enhancedArguments = getArguments().mapIndexed { localArgIndex, arg -> - if (arg.isStarProjection()) { + if (arg.isStarProjection) { globalArgIndex++ - TypeUtils.makeStarProjection(enhancedClassifier.getTypeConstructor().getParameters()[localArgIndex]) + TypeUtils.makeStarProjection(enhancedClassifier.typeConstructor.parameters[localArgIndex]) } else { - val (enhancedType, subtreeSize) = arg.getType().enhancePossiblyFlexible(qualifiers, globalArgIndex) + val (enhancedType, subtreeSize) = arg.type.enhancePossiblyFlexible(qualifiers, globalArgIndex) globalArgIndex += subtreeSize createProjection(enhancedType, arg.projectionKind, typeParameterDescriptor = typeConstructor.parameters[localArgIndex]) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index 8a0924af555..96b3256c1f8 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -95,11 +95,11 @@ fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection( +abstract class AbstractBinaryClassAnnotationAndConstantLoader( storageManager: StorageManager, private val kotlinClassFinder: KotlinClassFinder, private val errorReporter: ErrorReporter @@ -322,7 +322,7 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader( - public val memberAnnotations: Map>, - public val propertyConstants: Map + val memberAnnotations: Map>, + val propertyConstants: Map ) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index 54d199a31e7..b5d445a4482 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.ErrorUtils import java.util.* -public class BinaryClassAnnotationAndConstantLoaderImpl( +class BinaryClassAnnotationAndConstantLoaderImpl( private val module: ModuleDescriptor, storageManager: StorageManager, kotlinClassFinder: KotlinClassFinder, @@ -131,7 +131,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( val parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass) if (parameter != null) { elements.trimToSize() - arguments[parameter] = factory.createArrayValue(elements, parameter.getType()) + arguments[parameter] = factory.createArrayValue(elements, parameter.type) } } } @@ -151,8 +151,8 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( // NOTE: see analogous code in AnnotationDeserializer private fun enumEntryValue(enumClassId: ClassId, name: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) - if (enumClass.getKind() == ClassKind.ENUM_CLASS) { - val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(name, NoLookupLocation.FROM_JAVA_LOADER) + if (enumClass.kind == ClassKind.ENUM_CLASS) { + val classifier = enumClass.unsubstitutedInnerClassesScope.getContributedClassifier(name, NoLookupLocation.FROM_JAVA_LOADER) if (classifier is ClassDescriptor) { return factory.createEnumValue(classifier) } @@ -161,7 +161,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( } override fun visitEnd() { - result.add(AnnotationDescriptorImpl(annotationClass.getDefaultType(), arguments, source)) + result.add(AnnotationDescriptorImpl(annotationClass.defaultType, arguments, source)) } private fun createConstant(name: Name?, value: Any?): ConstantValue<*> { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializationComponentsForJava.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializationComponentsForJava.kt index dee42e30bbe..4acaf5d1a87 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializationComponentsForJava.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializationComponentsForJava.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.storage.StorageManager // This class is needed only for easier injection: exact types of needed components are specified in the constructor here. // Otherwise injector generator is not smart enough to deduce, for example, which package fragment provider DeserializationComponents needs -public class DeserializationComponentsForJava( +class DeserializationComponentsForJava( storageManager: StorageManager, moduleDescriptor: ModuleDescriptor, classDataFinder: JavaClassDataFinder, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaClassDataFinder.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaClassDataFinder.kt index 0dd123e521d..bdd8462785d 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaClassDataFinder.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaClassDataFinder.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.serialization.ClassDataWithSource import org.jetbrains.kotlin.serialization.deserialization.ClassDataFinder import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil -public class JavaClassDataFinder( +class JavaClassDataFinder( private val kotlinClassFinder: KotlinClassFinder, private val deserializedDescriptorResolver: DeserializedDescriptorResolver ) : ClassDataFinder { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaTypeCapabilitiesLoader.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaTypeCapabilitiesLoader.kt index 9ab7906af02..1673a99f5e9 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaTypeCapabilitiesLoader.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JavaTypeCapabilitiesLoader.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.deserialization.TypeCapabilitiesLoader import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.types.TypeCapabilities -public object JavaTypeCapabilitiesLoader : TypeCapabilitiesLoader() { +object JavaTypeCapabilitiesLoader : TypeCapabilitiesLoader() { override fun loadCapabilities(type: ProtoBuf.Type): TypeCapabilities = if (type.hasExtension(JvmProtoBuf.isRaw)) RawTypeCapabilities else TypeCapabilities.NONE } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinClassFinder.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinClassFinder.kt index e333625e093..d0347b27e8e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinClassFinder.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinClassFinder.kt @@ -19,8 +19,8 @@ package org.jetbrains.kotlin.load.kotlin import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.name.ClassId -public interface KotlinClassFinder { - public fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? +interface KotlinClassFinder { + fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? - public fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? + fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt index dd434829731..ab92bb1c32f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinaryPackageSourceElement.kt @@ -37,11 +37,11 @@ class KotlinJvmBinaryPackageSourceElement( override fun toString(): String = "Binary package ${jPackage.getFqName()}: ${implClassNameToBinaryClass.keys}" override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE - public fun getRepresentativeBinaryClass(): KotlinJvmBinaryClass { + fun getRepresentativeBinaryClass(): KotlinJvmBinaryClass { return implClassNameToBinaryClass.values.first() } - public fun getContainingBinaryClass(descriptor: DeserializedCallableMemberDescriptor): KotlinJvmBinaryClass? { + fun getContainingBinaryClass(descriptor: DeserializedCallableMemberDescriptor): KotlinJvmBinaryClass? { val name = descriptor.getImplClassNameForDeserialized() ?: return null return implClassNameToBinaryClass[name.asString()] } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt index e8fdc9db233..11f7559d060 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.kotlin import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceFile -public class KotlinJvmBinarySourceElement(public val binaryClass: KotlinJvmBinaryClass) : SourceElement { +class KotlinJvmBinarySourceElement(val binaryClass: KotlinJvmBinaryClass) : SourceElement { override fun toString() = javaClass.name + ": " + binaryClass.toString() override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/ModuleMapping.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/ModuleMapping.kt index d2ed53eb9e1..29e584d85be 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/ModuleMapping.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/ModuleMapping.kt @@ -22,18 +22,16 @@ import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable import java.io.ByteArrayInputStream import java.io.DataInputStream -public class ModuleMapping private constructor(val packageFqName2Parts: Map) { +class ModuleMapping private constructor(val packageFqName2Parts: Map) { fun findPackageParts(packageFqName: String): PackageParts? { return packageFqName2Parts[packageFqName] } companion object { - @JvmField - public val MAPPING_FILE_EXT: String = "kotlin_module" + @JvmField val MAPPING_FILE_EXT: String = "kotlin_module" - @JvmField - public val EMPTY: ModuleMapping = ModuleMapping(emptyMap()) + @JvmField val EMPTY: ModuleMapping = ModuleMapping(emptyMap()) fun create(proto: ByteArray? = null): ModuleMapping { if (proto == null) { @@ -68,7 +66,7 @@ public class ModuleMapping private constructor(val packageFqName2Parts: Map() @@ -79,8 +77,7 @@ public class PackageParts(val packageFqName: String) { packageFqName.hashCode() * 31 + parts.hashCode() companion object { - @JvmStatic - public fun PackageParts.serialize(builder: JvmPackageTable.PackageTable.Builder) { + @JvmStatic fun PackageParts.serialize(builder: JvmPackageTable.PackageTable.Builder) { if (this.parts.isNotEmpty()) { val packageParts = JvmPackageTable.PackageParts.newBuilder() packageParts.setPackageFqName(this.packageFqName) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt index bedfe0cc564..4934cb8389b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt @@ -25,31 +25,27 @@ import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.utils.singletonOrEmptyList import java.io.ByteArrayInputStream -public object JvmProtoBufUtil { - public val EXTENSION_REGISTRY: ExtensionRegistryLite = run { +object JvmProtoBufUtil { + val EXTENSION_REGISTRY: ExtensionRegistryLite = run { val registry = ExtensionRegistryLite.newInstance() JvmProtoBuf.registerAllExtensions(registry) registry } - @JvmStatic - public fun readClassDataFrom(data: Array, strings: Array): ClassData = + @JvmStatic fun readClassDataFrom(data: Array, strings: Array): ClassData = readClassDataFrom(BitEncoding.decodeBytes(data), strings) - @JvmStatic - public fun readClassDataFrom(bytes: ByteArray, strings: Array): ClassData { + @JvmStatic fun readClassDataFrom(bytes: ByteArray, strings: Array): ClassData { val input = ByteArrayInputStream(bytes) val nameResolver = JvmNameResolver(JvmProtoBuf.StringTableTypes.parseDelimitedFrom(input, EXTENSION_REGISTRY), strings) val classProto = ProtoBuf.Class.parseFrom(input, EXTENSION_REGISTRY) return ClassData(nameResolver, classProto) } - @JvmStatic - public fun readPackageDataFrom(data: Array, strings: Array): PackageData = + @JvmStatic fun readPackageDataFrom(data: Array, strings: Array): PackageData = readPackageDataFrom(BitEncoding.decodeBytes(data), strings) - @JvmStatic - public fun readPackageDataFrom(bytes: ByteArray, strings: Array): PackageData { + @JvmStatic fun readPackageDataFrom(bytes: ByteArray, strings: Array): PackageData { val input = ByteArrayInputStream(bytes) val nameResolver = JvmNameResolver(JvmProtoBuf.StringTableTypes.parseDelimitedFrom(input, EXTENSION_REGISTRY), strings) val packageProto = ProtoBuf.Package.parseFrom(input, EXTENSION_REGISTRY) diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeErrorReporter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeErrorReporter.kt index b8eb8947685..5358369eac0 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeErrorReporter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeErrorReporter.kt @@ -23,10 +23,10 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter -public object RuntimeErrorReporter : ErrorReporter { +object RuntimeErrorReporter : ErrorReporter { // TODO: specialized exceptions override fun reportIncompleteHierarchy(descriptor: ClassDescriptor, unresolvedSuperClasses: MutableList) { - throw IllegalStateException("Incomplete hierarchy for class ${descriptor.getName()}, unresolved classes $unresolvedSuperClasses") + throw IllegalStateException("Incomplete hierarchy for class ${descriptor.name}, unresolved classes $unresolvedSuperClasses") } override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: BinaryVersion) { @@ -36,7 +36,7 @@ public object RuntimeErrorReporter : ErrorReporter { override fun reportCannotInferVisibility(descriptor: CallableMemberDescriptor) { // TODO: use DescriptorRenderer - throw IllegalStateException("Cannot infer visibility for class ${descriptor.getName()}") + throw IllegalStateException("Cannot infer visibility for class ${descriptor.name}") } override fun reportLoadingError(message: String, exception: Exception?) { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeSourceElementFactory.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeSourceElementFactory.kt index 33e21b8f80b..75c60758783 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeSourceElementFactory.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/components/RuntimeSourceElementFactory.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory import org.jetbrains.kotlin.load.java.structure.JavaElement import org.jetbrains.kotlin.load.java.structure.reflect.ReflectJavaElement -public object RuntimeSourceElementFactory : JavaSourceElementFactory { +object RuntimeSourceElementFactory : JavaSourceElementFactory { private class RuntimeSourceElement(override val javaElement: ReflectJavaElement) : JavaSourceElement { override fun toString() = javaClass.name + ": " + javaElement.toString() override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/reflect/ReflectJavaClassFinder.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/reflect/ReflectJavaClassFinder.kt index 0762ac4c29e..0e1e1a5e97a 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/reflect/ReflectJavaClassFinder.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/reflect/ReflectJavaClassFinder.kt @@ -24,12 +24,12 @@ import org.jetbrains.kotlin.load.java.structure.reflect.ReflectJavaClass import org.jetbrains.kotlin.load.java.structure.reflect.ReflectJavaPackage import org.jetbrains.kotlin.name.ClassId -public class ReflectJavaClassFinder(private val classLoader: ClassLoader) : JavaClassFinder { +class ReflectJavaClassFinder(private val classLoader: ClassLoader) : JavaClassFinder { override fun findClass(classId: ClassId): JavaClass? { - val packageFqName = classId.getPackageFqName() - val relativeClassName = classId.getRelativeClassName().asString().replace('.', '$') + val packageFqName = classId.packageFqName + val relativeClassName = classId.relativeClassName.asString().replace('.', '$') val name = - if (packageFqName.isRoot()) relativeClassName + if (packageFqName.isRoot) relativeClassName else packageFqName.asString() + "." + relativeClassName val klass = classLoader.tryLoadClass(name) diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt index bfb436e938e..1da90612ada 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotation.kt @@ -21,17 +21,17 @@ import org.jetbrains.kotlin.load.java.structure.JavaAnnotationArgument import org.jetbrains.kotlin.name.Name import java.lang.reflect.Method -public class ReflectJavaAnnotation(private val annotation: Annotation) : ReflectJavaElement(), JavaAnnotation { +class ReflectJavaAnnotation(private val annotation: Annotation) : ReflectJavaElement(), JavaAnnotation { override fun findArgument(name: Name): JavaAnnotationArgument? { return getArgumentValue(annotation.annotationClass.java.getDeclaredMethod(name.asString())) } override fun getArguments(): Collection { - return annotation.annotationClass.java.getDeclaredMethods().map { getArgumentValue(it) } + return annotation.annotationClass.java.declaredMethods.map { getArgumentValue(it) } } private fun getArgumentValue(argument: Method): ReflectJavaAnnotationArgument { - return argument.invoke(annotation).let { ReflectJavaAnnotationArgument.create(it, Name.identifier(argument.getName())) } + return argument.invoke(annotation).let { ReflectJavaAnnotationArgument.create(it, Name.identifier(argument.name)) } } override fun resolve() = ReflectJavaClass(annotation.annotationClass.java) @@ -42,5 +42,5 @@ public class ReflectJavaAnnotation(private val annotation: Annotation) : Reflect override fun hashCode() = annotation.hashCode() - override fun toString() = javaClass.getName() + ": " + annotation + override fun toString() = javaClass.name + ": " + annotation } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationArguments.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationArguments.kt index 6fb902c79ed..28eaf13626d 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationArguments.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationArguments.kt @@ -53,7 +53,7 @@ class ReflectJavaEnumValueAnnotationArgument( ) : ReflectJavaAnnotationArgument(name), JavaEnumValueAnnotationArgument { override fun resolve(): ReflectJavaField { val clazz = value.javaClass - val enumClass = if (clazz.isEnum()) clazz else clazz.getEnclosingClass() + val enumClass = if (clazz.isEnum) clazz else clazz.enclosingClass return ReflectJavaField(enumClass.getDeclaredField(value.name)) } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt index cbe506afeff..2dd04ec2dc8 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaAnnotationOwner.kt @@ -20,12 +20,12 @@ import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner import org.jetbrains.kotlin.name.FqName import java.lang.reflect.AnnotatedElement -public interface ReflectJavaAnnotationOwner : JavaAnnotationOwner { +interface ReflectJavaAnnotationOwner : JavaAnnotationOwner { val element: AnnotatedElement - override fun getAnnotations() = getAnnotations(element.getDeclaredAnnotations()) + override fun getAnnotations() = getAnnotations(element.declaredAnnotations) - override fun findAnnotation(fqName: FqName) = findAnnotation(element.getDeclaredAnnotations(), fqName) + override fun findAnnotation(fqName: FqName) = findAnnotation(element.declaredAnnotations, fqName) override fun isDeprecatedInJavaDoc() = false } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt index fb6f8621ec7..47bb86e1647 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaArrayType.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType import java.lang.reflect.GenericArrayType import java.lang.reflect.Type -public class ReflectJavaArrayType(override val type: Type) : ReflectJavaType(), JavaArrayType { +class ReflectJavaArrayType(override val type: Type) : ReflectJavaType(), JavaArrayType { private val componentType: ReflectJavaType = with (type) { when { - this is GenericArrayType -> ReflectJavaType.create(getGenericComponentType()) + this is GenericArrayType -> ReflectJavaType.create(genericComponentType) this is Class<*> && isArray() -> ReflectJavaType.create(getComponentType()) else -> throw IllegalArgumentException("Not an array type (${type.javaClass}): $type") } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt index 71b469877e6..df8db001d05 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt @@ -24,39 +24,39 @@ import org.jetbrains.kotlin.name.Name import java.lang.reflect.Method import java.util.Arrays -public class ReflectJavaClass( +class ReflectJavaClass( private val klass: Class<*> ) : ReflectJavaElement(), ReflectJavaAnnotationOwner, ReflectJavaModifierListOwner, JavaClass { override val element: Class<*> get() = klass - override val modifiers: Int get() = klass.getModifiers() + override val modifiers: Int get() = klass.modifiers - override fun getInnerClasses() = klass.getDeclaredClasses() + override fun getInnerClasses() = klass.declaredClasses .asSequence() .filterNot { // getDeclaredClasses() returns anonymous classes sometimes, for example enums with specialized entries (which are in fact // anonymous classes) or in case of a special anonymous class created for the synthetic accessor to a private nested class // constructor accessed from the outer class - it.getSimpleName().isEmpty() + it.simpleName.isEmpty() } .map(::ReflectJavaClass) .toList() override fun getFqName() = klass.classId.asSingleFqName() - override fun getOuterClass() = klass.getDeclaringClass()?.let(::ReflectJavaClass) + override fun getOuterClass() = klass.declaringClass?.let(::ReflectJavaClass) override fun getSupertypes(): Collection { if (klass == Any::class.java) return emptyList() return listOf(klass.genericSuperclass ?: Any::class.java, *klass.genericInterfaces).map(::ReflectJavaClassifierType) } - override fun getMethods() = klass.getDeclaredMethods() + override fun getMethods() = klass.declaredMethods .asSequence() .filter { method -> when { - method.isSynthetic() -> false - isEnum() -> !isEnumValuesOrValueOf(method) + method.isSynthetic -> false + isEnum -> !isEnumValuesOrValueOf(method) else -> true } } @@ -64,22 +64,22 @@ public class ReflectJavaClass( .toList() private fun isEnumValuesOrValueOf(method: Method): Boolean { - return when (method.getName()) { - "values" -> method.getParameterTypes().isEmpty() - "valueOf" -> Arrays.equals(method.getParameterTypes(), arrayOf(String::class.java)) + return when (method.name) { + "values" -> method.parameterTypes.isEmpty() + "valueOf" -> Arrays.equals(method.parameterTypes, arrayOf(String::class.java)) else -> false } } - override fun getFields() = klass.getDeclaredFields() + override fun getFields() = klass.declaredFields .asSequence() - .filter { field -> !field.isSynthetic() } + .filter { field -> !field.isSynthetic } .map(::ReflectJavaField) .toList() - override fun getConstructors() = klass.getDeclaredConstructors() + override fun getConstructors() = klass.declaredConstructors .asSequence() - .filter { constructor -> !constructor.isSynthetic() } + .filter { constructor -> !constructor.isSynthetic } .map(::ReflectJavaConstructor) .toList() @@ -90,17 +90,17 @@ public class ReflectJavaClass( override fun createImmediateType(substitutor: JavaTypeSubstitutor): JavaType = throw UnsupportedOperationException() - override fun getName(): Name = Name.identifier(klass.getSimpleName()) + override fun getName(): Name = Name.identifier(klass.simpleName) - override fun getTypeParameters() = klass.getTypeParameters().map { ReflectJavaTypeParameter(it) } + override fun getTypeParameters() = klass.typeParameters.map { ReflectJavaTypeParameter(it) } - override fun isInterface() = klass.isInterface() - override fun isAnnotationType() = klass.isAnnotation() - override fun isEnum() = klass.isEnum() + override fun isInterface() = klass.isInterface + override fun isAnnotationType() = klass.isAnnotation + override fun isEnum() = klass.isEnum override fun equals(other: Any?) = other is ReflectJavaClass && klass == other.klass override fun hashCode() = klass.hashCode() - override fun toString() = javaClass.getName() + ": " + klass + override fun toString() = javaClass.name + ": " + klass } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt index d46270525cf..93231e395d5 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt @@ -22,13 +22,13 @@ import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.lang.reflect.TypeVariable -public class ReflectJavaClassifierType(public override val type: Type) : ReflectJavaType(), JavaClassifierType { +class ReflectJavaClassifierType(public override val type: Type) : ReflectJavaType(), JavaClassifierType { private val classifier: JavaClassifier = run { val type = type val classifier: JavaClassifier = when (type) { is Class<*> -> ReflectJavaClass(type) is TypeVariable<*> -> ReflectJavaTypeParameter(type) - is ParameterizedType -> ReflectJavaClass(type.getRawType() as Class<*>) + is ParameterizedType -> ReflectJavaClass(type.rawType as Class<*>) else -> throw IllegalStateException("Not a classifier type (${type.javaClass}): $type") } classifier diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt index 1dfe04b2c5b..badd2d4e76f 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaConstructor.kt @@ -22,27 +22,27 @@ import org.jetbrains.kotlin.load.java.structure.JavaValueParameter import java.lang.reflect.Constructor import java.lang.reflect.Modifier -public class ReflectJavaConstructor(override val member: Constructor<*>) : ReflectJavaMember(), JavaConstructor { +class ReflectJavaConstructor(override val member: Constructor<*>) : ReflectJavaMember(), JavaConstructor { // TODO: test local/anonymous classes override fun getValueParameters(): List { - val types = member.getGenericParameterTypes() + val types = member.genericParameterTypes if (types.isEmpty()) return emptyList() - val klass = member.getDeclaringClass() + val klass = member.declaringClass val realTypes = when { - klass.getDeclaringClass() != null && !Modifier.isStatic(klass.getModifiers()) -> types.copyOfRange(1, types.size) + klass.declaringClass != null && !Modifier.isStatic(klass.modifiers) -> types.copyOfRange(1, types.size) else -> types } - val annotations = member.getParameterAnnotations() + val annotations = member.parameterAnnotations val realAnnotations = when { annotations.size < realTypes.size -> throw IllegalStateException("Illegal generic signature: $member") annotations.size > realTypes.size -> annotations.copyOfRange(annotations.size - realTypes.size, annotations.size) else -> annotations } - return getValueParameters(realTypes, realAnnotations, member.isVarArgs()) + return getValueParameters(realTypes, realAnnotations, member.isVarArgs) } override fun getTypeParameters(): List { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaElement.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaElement.kt index a76e78b9eb5..7db2f2a9a1c 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaElement.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaElement.kt @@ -18,4 +18,4 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaElement -public abstract class ReflectJavaElement : JavaElement +abstract class ReflectJavaElement : JavaElement diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt index 553e816279f..3eb3214861e 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaField.kt @@ -19,8 +19,8 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaField import java.lang.reflect.Field -public class ReflectJavaField(override val member: Field) : ReflectJavaMember(), JavaField { - override fun isEnumEntry() = member.isEnumConstant() +class ReflectJavaField(override val member: Field) : ReflectJavaMember(), JavaField { + override fun isEnumEntry() = member.isEnumConstant - override fun getType() = ReflectJavaType.create(member.getGenericType()) + override fun getType() = ReflectJavaType.create(member.genericType) } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt index 999c67de6f2..0d90aadeea4 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMember.kt @@ -26,16 +26,16 @@ import java.lang.reflect.Method import java.lang.reflect.Type import java.util.* -public abstract class ReflectJavaMember : ReflectJavaElement(), ReflectJavaAnnotationOwner, ReflectJavaModifierListOwner, JavaMember { - public abstract val member: Member +abstract class ReflectJavaMember : ReflectJavaElement(), ReflectJavaAnnotationOwner, ReflectJavaModifierListOwner, JavaMember { + abstract val member: Member override val element: AnnotatedElement get() = member as AnnotatedElement - override val modifiers: Int get() = member.getModifiers() + override val modifiers: Int get() = member.modifiers - override fun getName() = member.getName()?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED + override fun getName() = member.name?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED - override fun getContainingClass() = ReflectJavaClass(member.getDeclaringClass()) + override fun getContainingClass() = ReflectJavaClass(member.declaringClass) protected fun getValueParameters( parameterTypes: Array, @@ -57,7 +57,7 @@ public abstract class ReflectJavaMember : ReflectJavaElement(), ReflectJavaAnnot override fun hashCode() = member.hashCode() - override fun toString() = javaClass.getName() + ": " + member + override fun toString() = javaClass.name + ": " + member } private object Java8ParameterNamesLoader { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt index e45135ce817..df2c9973ad7 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaMethod.kt @@ -20,13 +20,13 @@ import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.load.java.structure.JavaValueParameter import java.lang.reflect.Method -public class ReflectJavaMethod(override val member: Method) : ReflectJavaMember(), JavaMethod { +class ReflectJavaMethod(override val member: Method) : ReflectJavaMember(), JavaMethod { override fun getValueParameters(): List = - getValueParameters(member.getGenericParameterTypes(), member.getParameterAnnotations(), member.isVarArgs()) + getValueParameters(member.genericParameterTypes, member.parameterAnnotations, member.isVarArgs) - override fun getReturnType() = ReflectJavaType.create(member.getGenericReturnType()) + override fun getReturnType() = ReflectJavaType.create(member.genericReturnType) - override fun hasAnnotationParameterDefaultValue() = member.getDefaultValue() != null + override fun hasAnnotationParameterDefaultValue() = member.defaultValue != null - override fun getTypeParameters() = member.getTypeParameters().map { ReflectJavaTypeParameter(it) } + override fun getTypeParameters() = member.typeParameters.map { ReflectJavaTypeParameter(it) } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt index 4974a43dc61..53bca09b14c 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaModifierListOwner.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.load.java.JavaVisibilities import org.jetbrains.kotlin.load.java.structure.JavaModifierListOwner import java.lang.reflect.Modifier -public interface ReflectJavaModifierListOwner : JavaModifierListOwner { +interface ReflectJavaModifierListOwner : JavaModifierListOwner { /* protected // KT-3029 */ val modifiers: Int override fun isAbstract() = Modifier.isAbstract(modifiers) diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt index 050b05a90c9..46e278dbab6 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPackage.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaPackage import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public class ReflectJavaPackage(private val fqName: FqName) : ReflectJavaElement(), JavaPackage { +class ReflectJavaPackage(private val fqName: FqName) : ReflectJavaElement(), JavaPackage { override fun getFqName() = fqName override fun getClasses(nameFilter: (Name) -> Boolean): Collection { @@ -38,5 +38,5 @@ public class ReflectJavaPackage(private val fqName: FqName) : ReflectJavaElement override fun hashCode() = fqName.hashCode() - override fun toString() = javaClass.getName() + ": " + fqName + override fun toString() = javaClass.name + ": " + fqName } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt index f52672f864a..b33c3f12449 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaPrimitiveType.kt @@ -19,8 +19,8 @@ package org.jetbrains.kotlin.load.java.structure.reflect import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType -public class ReflectJavaPrimitiveType(override val type: Class<*>) : ReflectJavaType(), JavaPrimitiveType { +class ReflectJavaPrimitiveType(override val type: Class<*>) : ReflectJavaType(), JavaPrimitiveType { override fun getType() = if (type == Void.TYPE) null - else JvmPrimitiveType.get(type.getName()).getPrimitiveType() + else JvmPrimitiveType.get(type.name).primitiveType } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt index 19e82de9edb..dc7292b6e43 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaType.kt @@ -22,7 +22,7 @@ import java.lang.reflect.GenericArrayType import java.lang.reflect.Type import java.lang.reflect.WildcardType -public abstract class ReflectJavaType : JavaType { +abstract class ReflectJavaType : JavaType { protected abstract val type: Type override fun createArrayType(): JavaArrayType = throw UnsupportedOperationException() @@ -30,8 +30,8 @@ public abstract class ReflectJavaType : JavaType { companion object Factory { fun create(type: Type): ReflectJavaType { return when { - type is Class<*> && type.isPrimitive() -> ReflectJavaPrimitiveType(type) - type is GenericArrayType || type is Class<*> && type.isArray() -> ReflectJavaArrayType(type) + type is Class<*> && type.isPrimitive -> ReflectJavaPrimitiveType(type) + type is GenericArrayType || type is Class<*> && type.isArray -> ReflectJavaArrayType(type) type is WildcardType -> ReflectJavaWildcardType(type) else -> ReflectJavaClassifierType(type) } @@ -42,5 +42,5 @@ public abstract class ReflectJavaType : JavaType { override fun hashCode() = type.hashCode() - override fun toString() = javaClass.getName() + ": " + type + override fun toString() = javaClass.name + ": " + type } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt index 94aa99737ff..df33739a257 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt @@ -25,17 +25,17 @@ import java.lang.reflect.Constructor import java.lang.reflect.Method import java.lang.reflect.TypeVariable -public class ReflectJavaTypeParameter( - public val typeVariable: TypeVariable<*> +class ReflectJavaTypeParameter( + val typeVariable: TypeVariable<*> ) : ReflectJavaElement(), JavaTypeParameter { override fun getUpperBounds(): List { - val bounds = typeVariable.getBounds().map { bound -> ReflectJavaClassifierType(bound) } + val bounds = typeVariable.bounds.map { bound -> ReflectJavaClassifierType(bound) } if (bounds.singleOrNull()?.type == Any::class.java) return emptyList() return bounds } override fun getOwner(): JavaTypeParameterListOwner? { - val owner = typeVariable.getGenericDeclaration() + val owner = typeVariable.genericDeclaration return when (owner) { is Class<*> -> ReflectJavaClass(owner) is Method -> ReflectJavaMethod(owner) @@ -48,11 +48,11 @@ public class ReflectJavaTypeParameter( override fun getTypeProvider(): JavaTypeProvider = throw UnsupportedOperationException() - override fun getName() = Name.identifier(typeVariable.getName()) + override fun getName() = Name.identifier(typeVariable.name) override fun equals(other: Any?) = other is ReflectJavaTypeParameter && typeVariable == other.typeVariable override fun hashCode() = typeVariable.hashCode() - override fun toString() = javaClass.getName() + ": " + typeVariable + override fun toString() = javaClass.name + ": " + typeVariable } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt index 0e82734392c..88ac46c2117 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaValueParameter.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name.guess -public class ReflectJavaValueParameter( +class ReflectJavaValueParameter( private val returnType: ReflectJavaType, private val annotations: Array, private val name: String?, @@ -37,5 +37,5 @@ public class ReflectJavaValueParameter( override fun getType() = returnType override fun isVararg() = isVararg - override fun toString() = javaClass.getName() + ": " + (if (isVararg) "vararg " else "") + getName() + ": " + returnType + override fun toString() = javaClass.name + ": " + (if (isVararg) "vararg " else "") + getName() + ": " + returnType } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt index f877f5d8e4e..e132d05f85b 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaWildcardType.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.load.java.structure.JavaTypeProvider import org.jetbrains.kotlin.load.java.structure.JavaWildcardType import java.lang.reflect.WildcardType -public class ReflectJavaWildcardType(override val type: WildcardType): ReflectJavaType(), JavaWildcardType { +class ReflectJavaWildcardType(override val type: WildcardType): ReflectJavaType(), JavaWildcardType { override fun getBound(): ReflectJavaType? { - val upperBounds = type.getUpperBounds() - val lowerBounds = type.getLowerBounds() + val upperBounds = type.upperBounds + val lowerBounds = type.lowerBounds if (upperBounds.size > 1 || lowerBounds.size > 1) { throw UnsupportedOperationException("Wildcard types with many bounds are not yet supported: $type") } @@ -34,7 +34,7 @@ public class ReflectJavaWildcardType(override val type: WildcardType): ReflectJa } } - override fun isExtends() = type.getUpperBounds().firstOrNull() != Any::class.java + override fun isExtends() = type.upperBounds.firstOrNull() != Any::class.java override fun getTypeProvider(): JavaTypeProvider = throw UnsupportedOperationException() } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt index e3f30c4c88d..1e682bec838 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt @@ -21,33 +21,33 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import java.lang.reflect.Array -public val Class<*>.safeClassLoader: ClassLoader +val Class<*>.safeClassLoader: ClassLoader get() = classLoader ?: ClassLoader.getSystemClassLoader() -public fun Class<*>.isEnumClassOrSpecializedEnumEntryClass(): Boolean = +fun Class<*>.isEnumClassOrSpecializedEnumEntryClass(): Boolean = Enum::class.java.isAssignableFrom(this) /** * NOTE: does not perform a Java -> Kotlin mapping. If this is not expected, consider using KClassImpl#classId instead */ -public val Class<*>.classId: ClassId +val Class<*>.classId: ClassId get() = when { - isPrimitive() -> throw IllegalArgumentException("Can't compute ClassId for primitive type: $this") - isArray() -> throw IllegalArgumentException("Can't compute ClassId for array type: $this") - getEnclosingMethod() != null || getEnclosingConstructor() != null || getSimpleName().isEmpty() -> { - val fqName = FqName(getName()) + isPrimitive -> throw IllegalArgumentException("Can't compute ClassId for primitive type: $this") + isArray -> throw IllegalArgumentException("Can't compute ClassId for array type: $this") + enclosingMethod != null || enclosingConstructor != null || simpleName.isEmpty() -> { + val fqName = FqName(name) ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), /* local = */ true) } - else -> getDeclaringClass()?.classId?.createNestedClassId(Name.identifier(getSimpleName())) ?: ClassId.topLevel(FqName(getName())) + else -> declaringClass?.classId?.createNestedClassId(Name.identifier(simpleName)) ?: ClassId.topLevel(FqName(name)) } -public val Class<*>.desc: String +val Class<*>.desc: String get() { if (this == Void.TYPE) return "V" // This is a clever exploitation of a format returned by Class.getName(): for arrays, it's almost an internal name, // but with '.' instead of '/' - return createArrayType().getName().substring(1).replace('.', '/') + return createArrayType().name.substring(1).replace('.', '/') } -public fun Class<*>.createArrayType(): Class<*> = +fun Class<*>.createArrayType(): Class<*> = Array.newInstance(this, 0).javaClass diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectAnnotationSource.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectAnnotationSource.kt index a4d2960bda0..dec76a0f1b4 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectAnnotationSource.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectAnnotationSource.kt @@ -19,6 +19,6 @@ package org.jetbrains.kotlin.load.kotlin.reflect import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceFile -public class ReflectAnnotationSource(public val annotation: Annotation) : SourceElement { +class ReflectAnnotationSource(val annotation: Annotation) : SourceElement { override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClass.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClass.kt index 3fb3e405eee..38455677731 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClass.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClass.kt @@ -39,21 +39,21 @@ private val TYPES_ELIGIBLE_FOR_SIMPLE_VISIT = setOf>( Class::class.java, String::class.java ) -public class ReflectKotlinClass private constructor( - public val klass: Class<*>, +class ReflectKotlinClass private constructor( + val klass: Class<*>, private val classHeader: KotlinClassHeader ) : KotlinJvmBinaryClass { companion object Factory { - public fun create(klass: Class<*>): ReflectKotlinClass? { + fun create(klass: Class<*>): ReflectKotlinClass? { val headerReader = ReadKotlinClassHeaderAnnotationVisitor() ReflectClassStructure.loadClassAnnotations(klass, headerReader) return ReflectKotlinClass(klass, headerReader.createHeader() ?: return null) } } - override fun getLocation() = klass.getName().replace('.', '/') + ".class" + override fun getLocation() = klass.name.replace('.', '/') + ".class" override fun getClassId() = klass.classId @@ -71,12 +71,12 @@ public class ReflectKotlinClass private constructor( override fun hashCode() = klass.hashCode() - override fun toString() = javaClass.getName() + ": " + klass + override fun toString() = javaClass.name + ": " + klass } private object ReflectClassStructure { fun loadClassAnnotations(klass: Class<*>, visitor: KotlinJvmBinaryClass.AnnotationVisitor) { - for (annotation in klass.getDeclaredAnnotations()) { + for (annotation in klass.declaredAnnotations) { processAnnotation(visitor, annotation) } visitor.visitEnd() @@ -89,14 +89,14 @@ private object ReflectClassStructure { } private fun loadMethodAnnotations(klass: Class<*>, memberVisitor: KotlinJvmBinaryClass.MemberVisitor) { - for (method in klass.getDeclaredMethods()) { - val visitor = memberVisitor.visitMethod(Name.identifier(method.getName()), SignatureSerializer.methodDesc(method)) ?: continue + for (method in klass.declaredMethods) { + val visitor = memberVisitor.visitMethod(Name.identifier(method.name), SignatureSerializer.methodDesc(method)) ?: continue - for (annotation in method.getDeclaredAnnotations()) { + for (annotation in method.declaredAnnotations) { processAnnotation(visitor, annotation) } - for ((parameterIndex, annotations) in method.getParameterAnnotations().withIndex()) { + for ((parameterIndex, annotations) in method.parameterAnnotations.withIndex()) { for (annotation in annotations) { val annotationType = annotation.annotationClass.java visitor.visitParameterAnnotation(parameterIndex, annotationType.classId, ReflectAnnotationSource(annotation))?.let { @@ -110,14 +110,14 @@ private object ReflectClassStructure { } private fun loadConstructorAnnotations(klass: Class<*>, memberVisitor: KotlinJvmBinaryClass.MemberVisitor) { - for (constructor in klass.getDeclaredConstructors()) { + for (constructor in klass.declaredConstructors) { val visitor = memberVisitor.visitMethod(Name.special(""), SignatureSerializer.constructorDesc(constructor)) ?: continue - for (annotation in constructor.getDeclaredAnnotations()) { + for (annotation in constructor.declaredAnnotations) { processAnnotation(visitor, annotation) } - val parameterAnnotations = constructor.getParameterAnnotations() + val parameterAnnotations = constructor.parameterAnnotations if (parameterAnnotations.isNotEmpty()) { // Constructors of some classes have additional synthetic parameters: // - inner classes have one parameter, instance of the outer class @@ -125,7 +125,7 @@ private object ReflectClassStructure { // - local/anonymous classes may have many parameters for captured values // At the moment this seems like a working heuristic for computing number of synthetic parameters for Kotlin classes, // although this is wrong and likely to change, see KT-6886 - val shift = constructor.getParameterTypes().size - parameterAnnotations.size + val shift = constructor.parameterTypes.size - parameterAnnotations.size for ((parameterIndex, annotations) in parameterAnnotations.withIndex()) { for (annotation in annotations) { @@ -144,10 +144,10 @@ private object ReflectClassStructure { } private fun loadFieldAnnotations(klass: Class<*>, memberVisitor: KotlinJvmBinaryClass.MemberVisitor) { - for (field in klass.getDeclaredFields()) { - val visitor = memberVisitor.visitField(Name.identifier(field.getName()), SignatureSerializer.fieldDesc(field), null) ?: continue + for (field in klass.declaredFields) { + val visitor = memberVisitor.visitField(Name.identifier(field.name), SignatureSerializer.fieldDesc(field), null) ?: continue - for (annotation in field.getDeclaredAnnotations()) { + for (annotation in field.declaredAnnotations) { processAnnotation(visitor, annotation) } @@ -167,8 +167,8 @@ private object ReflectClassStructure { annotation: Annotation, annotationType: Class<*> ) { - for (method in annotationType.getDeclaredMethods()) { - processAnnotationArgumentValue(visitor, Name.identifier(method.getName()), method(annotation)!!) + for (method in annotationType.declaredMethods) { + processAnnotationArgumentValue(visitor, Name.identifier(method.name), method(annotation)!!) } visitor.visitEnd() } @@ -181,18 +181,18 @@ private object ReflectClassStructure { } clazz.isEnumClassOrSpecializedEnumEntryClass() -> { // isEnum returns false for specialized enum constants (enum entries which are anonymous enum subclasses) - val classId = (if (clazz.isEnum()) clazz else clazz.getEnclosingClass()).classId + val classId = (if (clazz.isEnum) clazz else clazz.enclosingClass).classId visitor.visitEnum(name, classId, Name.identifier((value as Enum<*>).name)) } Annotation::class.java.isAssignableFrom(clazz) -> { - val annotationClass = clazz.getInterfaces().single() + val annotationClass = clazz.interfaces.single() val v = visitor.visitAnnotation(name, annotationClass.classId) ?: return processAnnotationArguments(v, value as Annotation, annotationClass) } - clazz.isArray() -> { + clazz.isArray -> { val v = visitor.visitArray(name) ?: return - val componentType = clazz.getComponentType() - if (componentType.isEnum()) { + val componentType = clazz.componentType + if (componentType.isEnum) { val enumClassId = componentType.classId for (element in value as Array<*>) { v.visitEnum(enumClassId, Name.identifier((element as Enum<*>).name)) @@ -216,18 +216,18 @@ private object SignatureSerializer { fun methodDesc(method: Method): String { val sb = StringBuilder() sb.append("(") - for (parameterType in method.getParameterTypes()) { + for (parameterType in method.parameterTypes) { sb.append(parameterType.desc) } sb.append(")") - sb.append(method.getReturnType().desc) + sb.append(method.returnType.desc) return sb.toString() } fun constructorDesc(constructor: Constructor<*>): String { val sb = StringBuilder() sb.append("(") - for (parameterType in constructor.getParameterTypes()) { + for (parameterType in constructor.parameterTypes) { sb.append(parameterType.desc) } sb.append(")V") @@ -235,6 +235,6 @@ private object SignatureSerializer { } fun fieldDesc(field: Field): String { - return field.getType().desc + return field.type.desc } } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClassFinder.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClassFinder.kt index ab2e3f813e8..011925a0a5f 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClassFinder.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/ReflectKotlinClassFinder.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass import org.jetbrains.kotlin.name.ClassId -public class ReflectKotlinClassFinder(private val classLoader: ClassLoader) : KotlinClassFinder { +class ReflectKotlinClassFinder(private val classLoader: ClassLoader) : KotlinClassFinder { private fun findKotlinClass(fqName: String): KotlinJvmBinaryClass? { return classLoader.tryLoadClass(fqName)?.let { ReflectKotlinClass.create(it) } } @@ -31,11 +31,11 @@ public class ReflectKotlinClassFinder(private val classLoader: ClassLoader) : Ko override fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? { // TODO: go through javaClass's class loader - return findKotlinClass(javaClass.getFqName()?.asString() ?: return null) + return findKotlinClass(javaClass.fqName?.asString() ?: return null) } } private fun ClassId.toRuntimeFqName(): String { - val className = getRelativeClassName().asString().replace('.', '$') - return if (getPackageFqName().isRoot()) className else "${getPackageFqName()}.$className" + val className = relativeClassName.asString().replace('.', '$') + return if (packageFqName.isRoot) className else "${packageFqName}.$className" } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt index 75c89d48d59..3fa5bf8934f 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt @@ -40,12 +40,12 @@ import org.jetbrains.kotlin.serialization.deserialization.DeserializationCompone import org.jetbrains.kotlin.serialization.deserialization.LocalClassResolver import org.jetbrains.kotlin.storage.LockBasedStorageManager -public class RuntimeModuleData private constructor(public val deserialization: DeserializationComponents, val packageFacadeProvider: RuntimePackagePartProvider) { - public val module: ModuleDescriptor get() = deserialization.moduleDescriptor - public val localClassResolver: LocalClassResolver get() = deserialization.localClassResolver +class RuntimeModuleData private constructor(val deserialization: DeserializationComponents, val packageFacadeProvider: RuntimePackagePartProvider) { + val module: ModuleDescriptor get() = deserialization.moduleDescriptor + val localClassResolver: LocalClassResolver get() = deserialization.localClassResolver companion object { - public fun create(classLoader: ClassLoader): RuntimeModuleData { + fun create(classLoader: ClassLoader): RuntimeModuleData { val builtIns = JvmBuiltIns.Instance val storageManager = LockBasedStorageManager() val module = ModuleDescriptorImpl(Name.special(""), storageManager, diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsInitializer.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsInitializer.kt index d5562c67889..ed277c48568 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsInitializer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsInitializer.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.builtins import org.jetbrains.kotlin.utils.sure -public class BuiltInsInitializer( +class BuiltInsInitializer( private val constructor: () -> T ) { @Volatile private var instance: T? = null diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt index cf68177e8ab..a9af714cd6d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.storage.StorageManager import java.io.DataInputStream import java.io.InputStream -public class BuiltinsPackageFragment( +class BuiltinsPackageFragment( fqName: FqName, storageManager: StorageManager, module: ModuleDescriptor, @@ -68,7 +68,7 @@ public class BuiltinsPackageFragment( ) } ?: super.computeMemberScope() - protected override fun loadClassNames(packageProto: ProtoBuf.Package): Collection { + override fun loadClassNames(packageProto: ProtoBuf.Package): Collection { return packageProto.getExtension(BuiltInsProtoBuf.className)?.map { id -> nameResolver.getName(id) } ?: listOf() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/CompanionObjectMapping.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/CompanionObjectMapping.kt index abf7f31c79b..4e8143cdc7b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/CompanionObjectMapping.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/CompanionObjectMapping.kt @@ -20,22 +20,22 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.resolve.DescriptorUtils import java.util.* -public class CompanionObjectMapping(private val builtIns: KotlinBuiltIns) { +class CompanionObjectMapping(private val builtIns: KotlinBuiltIns) { private val classes = linkedSetOf() init { for (type in PrimitiveType.NUMBER_TYPES) { classes.add(builtIns.getPrimitiveClassDescriptor(type)) } - classes.add(builtIns.getString()) - classes.add(builtIns.getEnum()) + classes.add(builtIns.string) + classes.add(builtIns.enum) } - public fun allClassesWithIntrinsicCompanions(): Set = + fun allClassesWithIntrinsicCompanions(): Set = Collections.unmodifiableSet(classes) - public fun hasMappingToObject(classDescriptor: ClassDescriptor): Boolean { + fun hasMappingToObject(classDescriptor: ClassDescriptor): Boolean { return DescriptorUtils.isCompanionObject(classDescriptor) && - classDescriptor.getContainingDeclaration() in classes + classDescriptor.containingDeclaration in classes } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 7ec3c9bc36b..847d78be625 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -32,7 +32,7 @@ import kotlin.reflect.KProperty val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect") -public class ReflectionTypes(private val module: ModuleDescriptor) { +class ReflectionTypes(private val module: ModuleDescriptor) { private val kotlinReflectScope: MemberScope by lazy { module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope } @@ -49,16 +49,16 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { } } - public fun getKFunction(n: Int): ClassDescriptor = find("KFunction$n") + fun getKFunction(n: Int): ClassDescriptor = find("KFunction$n") - public val kClass: ClassDescriptor by ClassLookup - public val kProperty0: ClassDescriptor by ClassLookup - public val kProperty1: ClassDescriptor by ClassLookup - public val kProperty2: ClassDescriptor by ClassLookup - public val kMutableProperty0: ClassDescriptor by ClassLookup - public val kMutableProperty1: ClassDescriptor by ClassLookup + val kClass: ClassDescriptor by ClassLookup + val kProperty0: ClassDescriptor by ClassLookup + val kProperty1: ClassDescriptor by ClassLookup + val kProperty2: ClassDescriptor by ClassLookup + val kMutableProperty0: ClassDescriptor by ClassLookup + val kMutableProperty1: ClassDescriptor by ClassLookup - public fun getKClassType(annotations: Annotations, type: KotlinType): KotlinType { + fun getKClassType(annotations: Annotations, type: KotlinType): KotlinType { val descriptor = kClass if (ErrorUtils.isError(descriptor)) { return descriptor.defaultType @@ -68,7 +68,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return KotlinTypeImpl.create(annotations, descriptor, false, arguments) } - public fun getKFunctionType( + fun getKFunctionType( annotations: Annotations, receiverType: KotlinType?, parameterTypes: List, @@ -85,7 +85,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments) } - public fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType { + fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType { val classDescriptor = when { receiverType != null -> when { @@ -111,12 +111,12 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { } companion object { - public fun isReflectionClass(descriptor: ClassDescriptor): Boolean { + fun isReflectionClass(descriptor: ClassDescriptor): Boolean { val containingPackage = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java) return containingPackage != null && containingPackage.fqName == KOTLIN_REFLECT_FQ_NAME } - public fun isCallableType(type: KotlinType): Boolean = + fun isCallableType(type: KotlinType): Boolean = KotlinBuiltIns.isFunctionOrExtensionFunctionType(type) || isKCallableType(type) private fun isKCallableType(type: KotlinType): Boolean = @@ -128,7 +128,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return descriptor is ClassDescriptor && DescriptorUtils.getFqName(descriptor) == KotlinBuiltIns.FQ_NAMES.kCallable } - public fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? { + fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? { val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null return KotlinTypeImpl.create( Annotations.EMPTY, kPropertyClass, false, diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/builtInsPackageFragmentProvider.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/builtInsPackageFragmentProvider.kt index 082b2e1dbd5..8a836f0a70e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/builtInsPackageFragmentProvider.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/builtInsPackageFragmentProvider.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.storage.StorageManager import java.io.InputStream -public fun createBuiltInPackageFragmentProvider( +fun createBuiltInPackageFragmentProvider( storageManager: StorageManager, module: ModuleDescriptor, packageFqNames: Set, diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt index 70fa3e63d89..abc1952f645 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.storage.StorageManager /** * Produces descriptors representing the fictitious classes for function types, such as kotlin.Function1 or kotlin.reflect.KFunction2. */ -public class BuiltInFictitiousFunctionClassFactory( +class BuiltInFictitiousFunctionClassFactory( private val storageManager: StorageManager, private val module: ModuleDescriptor ) : ClassDescriptorFactory { @@ -35,8 +35,7 @@ public class BuiltInFictitiousFunctionClassFactory( private data class KindWithArity(val kind: Kind, val arity: Int) companion object { - @JvmStatic - public fun parseClassName(className: String, packageFqName: FqName): KindWithArity? { + @JvmStatic fun parseClassName(className: String, packageFqName: FqName): KindWithArity? { val kind = FunctionClassDescriptor.Kind.byPackage(packageFqName) ?: return null val prefix = kind.classNamePrefix diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 6d6deaf4082..5bf015c3d44 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -40,14 +40,14 @@ import java.util.* * If the class represents kotlin.reflect.KFunction1, it has two supertypes: kotlin.Function1 and kotlin.reflect.KFunction. * This allows to use both 'invoke' and reflection API on function references obtained by '::'. */ -public class FunctionClassDescriptor( +class FunctionClassDescriptor( private val storageManager: StorageManager, private val containingDeclaration: PackageFragmentDescriptor, val functionKind: Kind, val arity: Int ) : AbstractClassDescriptor(storageManager, functionKind.numberedClassName(arity)) { - public enum class Kind(val packageFqName: FqName, val classNamePrefix: String) { + enum class Kind(val packageFqName: FqName, val classNamePrefix: String) { Function(BUILT_INS_PACKAGE_FQ_NAME, "Function"), KFunction(KOTLIN_REFLECT_FQ_NAME, "KFunction"); @@ -117,11 +117,11 @@ public class FunctionClassDescriptor( val descriptor = packageFragment.getMemberScope().getContributedClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor ?: error("Class $name not found in $packageFragment") - val typeConstructor = descriptor.getTypeConstructor() + val typeConstructor = descriptor.typeConstructor // Substitute all type parameters of the super class with our last type parameters - val arguments = getParameters().takeLast(typeConstructor.getParameters().size).map { - TypeProjectionImpl(it.getDefaultType()) + val arguments = getParameters().takeLast(typeConstructor.parameters.size).map { + TypeProjectionImpl(it.defaultType) } result.add(KotlinTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments)) @@ -132,7 +132,7 @@ public class FunctionClassDescriptor( // For KFunction{n}, add corresponding numbered Function{n} class, e.g. Function2 for KFunction2 if (functionKind == Kind.KFunction) { - val module = containingDeclaration.getContainingDeclaration() + val module = containingDeclaration.containingDeclaration val kotlinPackageFragment = module.getPackage(BUILT_INS_PACKAGE_FQ_NAME).fragments.single() add(kotlinPackageFragment, Kind.Function.numberedClassName(arity)) @@ -150,8 +150,8 @@ public class FunctionClassDescriptor( override fun isFinal() = false override fun getAnnotations() = Annotations.EMPTY - override fun toString() = getDeclarationDescriptor().toString() + override fun toString() = declarationDescriptor.toString() } - override fun toString() = getName().asString() + override fun toString() = name.asString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt index b8b994bdfb6..2a8f414f7f8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt @@ -47,24 +47,24 @@ class FunctionClassScope( } override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { - return allDescriptors().filterIsInstance().filter { it.getName() == name } + return allDescriptors().filterIsInstance().filter { it.name == name } } override fun getContributedVariables(name: Name, location: LookupLocation): Collection { - return allDescriptors().filterIsInstance().filter { it.getName() == name } + return allDescriptors().filterIsInstance().filter { it.name == name } } private fun createFakeOverrides(invoke: FunctionDescriptor?): List { val result = ArrayList(3) - val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes() - .flatMap { it.getMemberScope().getContributedDescriptors() } + val allSuperDescriptors = functionClass.typeConstructor.supertypes + .flatMap { it.memberScope.getContributedDescriptors() } .filterIsInstance() - for ((name, group) in allSuperDescriptors.groupBy { it.getName() }) { + for ((name, group) in allSuperDescriptors.groupBy { it.name }) { for ((isFunction, descriptors) in group.groupBy { it is FunctionDescriptor }) { OverridingUtil.generateOverridesInFunctionGroup( name, /* membersFromSupertypes = */ descriptors, - /* membersFromCurrent = */ if (isFunction && name == invoke?.getName()) listOf(invoke) else listOf(), + /* membersFromCurrent = */ if (isFunction && name == invoke?.name) listOf(invoke) else listOf(), functionClass, object : OverridingUtil.DescriptorSink { override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt index ed9fa85e3c2..558ab8708c8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance -public class FunctionInvokeDescriptor private constructor( +class FunctionInvokeDescriptor private constructor( private val container: DeclarationDescriptor, private val original: FunctionInvokeDescriptor?, private val callableKind: CallableMemberDescriptor.Kind @@ -63,12 +63,12 @@ public class FunctionInvokeDescriptor private constructor( val result = FunctionInvokeDescriptor(functionClass, null, CallableMemberDescriptor.Kind.DECLARATION) result.initialize( null, - functionClass.getThisAsReceiverParameter(), + functionClass.thisAsReceiverParameter, listOf(), - typeParameters.takeWhile { it.getVariance() == Variance.IN_VARIANCE } + typeParameters.takeWhile { it.variance == Variance.IN_VARIANCE } .withIndex() .map { createValueParameter(result, it.index, it.value) }, - typeParameters.last().getDefaultType(), + typeParameters.last().defaultType, Modality.ABSTRACT, Visibilities.PUBLIC ) @@ -81,7 +81,7 @@ public class FunctionInvokeDescriptor private constructor( index: Int, typeParameter: TypeParameterDescriptor ): ValueParameterDescriptor { - val typeParameterName = typeParameter.getName().asString() + val typeParameterName = typeParameter.name.asString() val name = when (typeParameterName) { "T" -> "instance" "E" -> "receiver" @@ -95,7 +95,7 @@ public class FunctionInvokeDescriptor private constructor( containingDeclaration, null, index, Annotations.EMPTY, Name.identifier(name), - typeParameter.getDefaultType(), + typeParameter.defaultType, /* declaresDefaultValue = */ false, /* isCrossinline = */ false, /* isNoinline = */ false, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt index 1f1b8ab1db1..d688c8cc24b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt @@ -22,8 +22,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.types.KotlinType object ConstUtil { - @JvmStatic - public fun canBeUsedForConstVal(type: KotlinType) = type.canBeUsedForConstVal() + @JvmStatic fun canBeUsedForConstVal(type: KotlinType) = type.canBeUsedForConstVal() } -public fun KotlinType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this) +fun KotlinType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this) diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt index 1baff1a9c03..53ceaa2e9ed 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt @@ -23,12 +23,12 @@ import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap import org.jetbrains.kotlin.resolve.ImportPath import org.jetbrains.kotlin.types.TypeSubstitutor -public interface ModuleDescriptor : DeclarationDescriptor, ModuleParameters { +interface ModuleDescriptor : DeclarationDescriptor, ModuleParameters { override fun getContainingDeclaration(): DeclarationDescriptor? = null - public val builtIns: KotlinBuiltIns + val builtIns: KotlinBuiltIns - public fun isFriend(other: ModuleDescriptor): Boolean + fun isFriend(other: ModuleDescriptor): Boolean override fun substitute(substitutor: TypeSubstitutor): ModuleDescriptor { return this @@ -38,9 +38,9 @@ public interface ModuleDescriptor : DeclarationDescriptor, ModuleParameters { return visitor.visitModuleDeclaration(this, data) } - public fun getPackage(fqName: FqName): PackageViewDescriptor + fun getPackage(fqName: FqName): PackageViewDescriptor - public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection + fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection fun getCapability(capability: Capability): T? @@ -48,8 +48,8 @@ public interface ModuleDescriptor : DeclarationDescriptor, ModuleParameters { } interface ModuleParameters { - public val defaultImports: List - public val platformToKotlinClassMap: PlatformToKotlinClassMap + val defaultImports: List + val platformToKotlinClassMap: PlatformToKotlinClassMap object Empty: ModuleParameters { override val defaultImports: List = emptyList() @@ -57,7 +57,7 @@ interface ModuleParameters { } } -public fun ModuleParameters(defaultImports: List, platformToKotlinClassMap: PlatformToKotlinClassMap): ModuleParameters = +fun ModuleParameters(defaultImports: List, platformToKotlinClassMap: PlatformToKotlinClassMap): ModuleParameters = object : ModuleParameters { override val defaultImports: List = defaultImports override val platformToKotlinClassMap: PlatformToKotlinClassMap = platformToKotlinClassMap diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentDescriptor.kt index e86b3754ab2..493c2ec7ce1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentDescriptor.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.scopes.MemberScope -public interface PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor { +interface PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor { override fun getContainingDeclaration(): ModuleDescriptor - public val fqName: FqName + val fqName: FqName - public fun getMemberScope(): MemberScope + fun getMemberScope(): MemberScope } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProvider.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProvider.kt index 224653dce92..216c723fbfe 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProvider.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProvider.kt @@ -19,13 +19,13 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public interface PackageFragmentProvider { - public fun getPackageFragments(fqName: FqName): List +interface PackageFragmentProvider { + fun getPackageFragments(fqName: FqName): List - public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection + fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection - public object Empty : PackageFragmentProvider { + object Empty : PackageFragmentProvider { override fun getPackageFragments(fqName: FqName) = emptyList() override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean) = emptySet() diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProviderImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProviderImpl.kt index 8e2677978f5..6e2960d86bb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProviderImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageFragmentProviderImpl.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public class PackageFragmentProviderImpl( +class PackageFragmentProviderImpl( private val packageFragments: Collection ) : PackageFragmentProvider { override fun getPackageFragments(fqName: FqName): List = @@ -28,6 +28,6 @@ public class PackageFragmentProviderImpl( override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection = packageFragments.asSequence() .map { it.fqName } - .filter { !it.isRoot() && it.parent() == fqName } + .filter { !it.isRoot && it.parent() == fqName } .toList() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageViewDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageViewDescriptor.kt index 18f0e4be64f..f8e1e33dfdb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageViewDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/PackageViewDescriptor.kt @@ -19,16 +19,16 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.scopes.MemberScope -public interface PackageViewDescriptor : DeclarationDescriptor { +interface PackageViewDescriptor : DeclarationDescriptor { override fun getContainingDeclaration(): PackageViewDescriptor? - public val fqName: FqName + val fqName: FqName - public val memberScope: MemberScope + val memberScope: MemberScope - public val module: ModuleDescriptor + val module: ModuleDescriptor - public val fragments: List + val fragments: List - public fun isEmpty(): Boolean = fragments.isEmpty() + fun isEmpty(): Boolean = fragments.isEmpty() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibility.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibility.kt index ea0d8908673..ab3ddd1367c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibility.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibility.kt @@ -18,11 +18,11 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -public abstract class Visibility protected constructor( - public val name: String, - public val isPublicAPI: Boolean +abstract class Visibility protected constructor( + val name: String, + val isPublicAPI: Boolean ) { - public abstract fun isVisible(receiver: ReceiverValue?, what: DeclarationDescriptorWithVisibility, from: DeclarationDescriptor): Boolean + abstract fun isVisible(receiver: ReceiverValue?, what: DeclarationDescriptorWithVisibility, from: DeclarationDescriptor): Boolean /** * True, if it makes sense to check this visibility in imports and not import inaccessible declarations with such visibility. @@ -34,7 +34,7 @@ public abstract class Visibility protected constructor( * it returns true for PRIVATE, because there's no point in importing privates: they are inaccessible unless their short name is * already available without an import */ - public abstract fun mustCheckInImports(): Boolean + abstract fun mustCheckInImports(): Boolean /** * @return null if the answer is unknown @@ -43,13 +43,13 @@ public abstract class Visibility protected constructor( return Visibilities.compareLocal(this, visibility) } - public open val displayName: String + open val displayName: String get() = name override final fun toString() = displayName - public open fun normalize(): Visibility = this + open fun normalize(): Visibility = this // Should be overloaded in Java visibilities - public open fun effectiveVisibility(descriptor: ClassDescriptor?) = effectiveVisibility(normalize(), descriptor) + open fun effectiveVisibility(descriptor: ClassDescriptor?) = effectiveVisibility(normalize(), descriptor) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationUseSiteTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationUseSiteTarget.kt index 9428a4b38e1..fd0fcb42230 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationUseSiteTarget.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationUseSiteTarget.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors.annotations import org.jetbrains.kotlin.descriptors.* -public enum class AnnotationUseSiteTarget(renderName: String? = null) { +enum class AnnotationUseSiteTarget(renderName: String? = null) { FIELD(), FILE(), PROPERTY(), @@ -28,10 +28,10 @@ public enum class AnnotationUseSiteTarget(renderName: String? = null) { CONSTRUCTOR_PARAMETER("param"), SETTER_PARAMETER("setparam"); - public val renderName: String = renderName ?: name.toLowerCase() + val renderName: String = renderName ?: name.toLowerCase() - public companion object { - public fun getAssociatedUseSiteTarget(descriptor: DeclarationDescriptor): AnnotationUseSiteTarget? = when (descriptor) { + companion object { + fun getAssociatedUseSiteTarget(descriptor: DeclarationDescriptor): AnnotationUseSiteTarget? = when (descriptor) { is PropertyDescriptor -> PROPERTY is ValueParameterDescriptor -> CONSTRUCTOR_PARAMETER is PropertyGetterDescriptor -> PROPERTY_GETTER diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationWithTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationWithTarget.kt index a1c4f398003..200cd834a02 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationWithTarget.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationWithTarget.kt @@ -16,4 +16,4 @@ package org.jetbrains.kotlin.descriptors.annotations -public data class AnnotationWithTarget(val annotation: AnnotationDescriptor, val target: AnnotationUseSiteTarget?) \ No newline at end of file +data class AnnotationWithTarget(val annotation: AnnotationDescriptor, val target: AnnotationUseSiteTarget?) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt index cdf5ad7813f..5760115fd33 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt @@ -20,23 +20,23 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils -public interface Annotations : Iterable { +interface Annotations : Iterable { - public fun isEmpty(): Boolean + fun isEmpty(): Boolean - public fun findAnnotation(fqName: FqName): AnnotationDescriptor? + fun findAnnotation(fqName: FqName): AnnotationDescriptor? - public fun hasAnnotation(fqName: FqName) = findAnnotation(fqName) != null + fun hasAnnotation(fqName: FqName) = findAnnotation(fqName) != null - public fun findExternalAnnotation(fqName: FqName): AnnotationDescriptor? + fun findExternalAnnotation(fqName: FqName): AnnotationDescriptor? - public fun getUseSiteTargetedAnnotations(): List + fun getUseSiteTargetedAnnotations(): List // Returns both targeted and annotations without target. Annotation order is preserved. - public fun getAllAnnotations(): List + fun getAllAnnotations(): List companion object { - public val EMPTY: Annotations = object : Annotations { + val EMPTY: Annotations = object : Annotations { override fun isEmpty() = true override fun findAnnotation(fqName: FqName) = null @@ -52,11 +52,11 @@ public interface Annotations : Iterable { override fun toString() = "EMPTY" } - public fun findAnyAnnotation(annotations: Annotations, fqName: FqName): AnnotationWithTarget? { + fun findAnyAnnotation(annotations: Annotations, fqName: FqName): AnnotationWithTarget? { return annotations.getAllAnnotations().firstOrNull { checkAnnotationName(it.annotation, fqName) } } - public fun findUseSiteTargetedAnnotation(annotations: Annotations, target: AnnotationUseSiteTarget, fqName: FqName): AnnotationDescriptor? { + fun findUseSiteTargetedAnnotation(annotations: Annotations, target: AnnotationUseSiteTarget, fqName: FqName): AnnotationDescriptor? { return getUseSiteTargetedAnnotations(annotations, target).firstOrNull { checkAnnotationName(it, fqName) } } @@ -104,9 +104,9 @@ class FilteredAnnotations( override fun iterator() = delegate.filter { shouldBeReturned(it) }.iterator() private fun shouldBeReturned(annotation: AnnotationDescriptor): Boolean { - val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor() + val descriptor = annotation.type.constructor.declarationDescriptor return descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName -> - fqName.isSafe() && fqNameFilter(fqName.toSafe()) + fqName.isSafe && fqNameFilter(fqName.toSafe()) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationsImpl.kt index 4629cb885f6..286f6dc8058 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationsImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils -public class AnnotationsImpl : Annotations { +class AnnotationsImpl : Annotations { private val annotations: List private val targetedAnnotations: List @@ -41,7 +41,7 @@ public class AnnotationsImpl : Annotations { override fun isEmpty() = annotations.isEmpty() override fun findAnnotation(fqName: FqName) = annotations.firstOrNull { - val descriptor = it.getType().getConstructor().getDeclarationDescriptor() + val descriptor = it.type.constructor.declarationDescriptor descriptor is ClassDescriptor && fqName.toUnsafe() == DescriptorUtils.getFqName(descriptor) } @@ -60,13 +60,11 @@ public class AnnotationsImpl : Annotations { override fun toString() = annotations.toString() companion object { - @JvmStatic - public fun create(annotationsWithTargets: List): AnnotationsImpl { + @JvmStatic fun create(annotationsWithTargets: List): AnnotationsImpl { return AnnotationsImpl(annotationsWithTargets, 0) } - @JvmStatic - public fun createWithNoTarget(vararg annotations: AnnotationDescriptor): AnnotationsImpl { + @JvmStatic fun createWithNoTarget(vararg annotations: AnnotationDescriptor): AnnotationsImpl { return create(annotations.map { AnnotationWithTarget(it, null) }) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinRetention.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinRetention.kt index ae52042f77f..2437c5c0ad6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinRetention.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinRetention.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.descriptors.annotations -public enum class KotlinRetention { +enum class KotlinRetention { RUNTIME, BINARY, SOURCE diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt index 08d3481dbe2..33736f18a18 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt @@ -23,7 +23,7 @@ import java.util.* // NOTE: this enum must have the same entries with kotlin.annotation.AnnotationTarget, // and may also have some additional entries -public enum class KotlinTarget(val description: String, val isDefault: Boolean = true) { +enum class KotlinTarget(val description: String, val isDefault: Boolean = true) { CLASS("class"), // includes CLASS_ONLY, OBJECT, COMPANION_OBJECT, OBJECT_LITERAL, INTERFACE, *_CLASS but not ENUM_ENTRY ANNOTATION_CLASS("annotation class"), TYPE_PARAMETER("type parameter", false), @@ -81,13 +81,13 @@ public enum class KotlinTarget(val description: String, val isDefault: Boolean = } } - public fun valueOrNull(name: String): KotlinTarget? = map[name] + fun valueOrNull(name: String): KotlinTarget? = map[name] - public val DEFAULT_TARGET_SET: Set = values().filter { it.isDefault }.toSet() + val DEFAULT_TARGET_SET: Set = values().filter { it.isDefault }.toSet() - public val ALL_TARGET_SET: Set = values().toSet() + val ALL_TARGET_SET: Set = values().toSet() - public fun classActualTargets(descriptor: ClassDescriptor): List = when (descriptor.kind) { + fun classActualTargets(descriptor: ClassDescriptor): List = when (descriptor.kind) { ClassKind.ANNOTATION_CLASS -> listOf(ANNOTATION_CLASS, CLASS) ClassKind.CLASS -> if (descriptor.isInner) { @@ -117,7 +117,7 @@ public enum class KotlinTarget(val description: String, val isDefault: Boolean = ClassKind.ENUM_ENTRY -> listOf(ENUM_ENTRY, PROPERTY, FIELD) } - public val USE_SITE_MAPPING: Map = mapOf( + val USE_SITE_MAPPING: Map = mapOf( AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER to VALUE_PARAMETER, AnnotationUseSiteTarget.FIELD to FIELD, AnnotationUseSiteTarget.PROPERTY to PROPERTY, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt index 0f9df4e727c..074800b4e31 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.constants.EnumValue import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.types.Variance -public fun KotlinBuiltIns.createDeprecatedAnnotation( +fun KotlinBuiltIns.createDeprecatedAnnotation( message: String, replaceWith: String, level: String = "WARNING" diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/CompositePackageFragmentProvider.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/CompositePackageFragmentProvider.kt index 045a41c8cfb..de3eab32b01 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/CompositePackageFragmentProvider.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/CompositePackageFragmentProvider.kt @@ -23,7 +23,7 @@ import java.util.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.toReadOnlyList -public class CompositePackageFragmentProvider(// can be modified from outside +class CompositePackageFragmentProvider(// can be modified from outside private val providers: List) : PackageFragmentProvider { override fun getPackageFragments(fqName: FqName): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyPackageViewDescriptorImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyPackageViewDescriptorImpl.kt index 9dfbccc043d..a2e5684d6e0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyPackageViewDescriptorImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyPackageViewDescriptorImpl.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.getValue import org.jetbrains.kotlin.types.TypeSubstitutor -public class LazyPackageViewDescriptorImpl( +class LazyPackageViewDescriptorImpl( override val module: ModuleDescriptorImpl, override val fqName: FqName, storageManager: StorageManager @@ -51,7 +51,7 @@ public class LazyPackageViewDescriptorImpl( }) override fun getContainingDeclaration(): PackageViewDescriptor? { - return if (fqName.isRoot()) null else module.getPackage(fqName.parent()) + return if (fqName.isRoot) null else module.getPackage(fqName.parent()) } override fun equals(other: Any?): Boolean { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt index 5d2d6fce05a..8576a466534 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.sure import java.util.* -public class ModuleDescriptorImpl @JvmOverloads constructor( +class ModuleDescriptorImpl @JvmOverloads constructor( moduleName: Name, private val storageManager: StorageManager, private val moduleParameters: ModuleParameters, @@ -36,7 +36,7 @@ public class ModuleDescriptorImpl @JvmOverloads constructor( private val capabilities: Map, Any?> = emptyMap() ) : DeclarationDescriptorImpl(Annotations.EMPTY, moduleName), ModuleDescriptor, ModuleParameters by moduleParameters { init { - if (!moduleName.isSpecial()) { + if (!moduleName.isSpecial) { throw IllegalArgumentException("Module name must be special: $moduleName") } } @@ -68,26 +68,26 @@ public class ModuleDescriptorImpl @JvmOverloads constructor( private val isInitialized: Boolean get() = packageFragmentProviderForModuleContent != null - public fun setDependencies(dependencies: ModuleDependencies) { + fun setDependencies(dependencies: ModuleDependencies) { assert(this.dependencies == null) { "Dependencies of $id were already set" } this.dependencies = dependencies } - public fun setDependencies(vararg descriptors: ModuleDescriptorImpl) { + fun setDependencies(vararg descriptors: ModuleDescriptorImpl) { setDependencies(descriptors.toList()) } - public fun setDependencies(descriptors: List) { + fun setDependencies(descriptors: List) { setDependencies(ModuleDependenciesImpl(descriptors)) } private val id: String - get() = getName().toString() + get() = name.toString() /* * Call initialize() to set module contents. Uninitialized module cannot be queried for its contents. */ - public fun initialize(providerForModuleContent: PackageFragmentProvider) { + fun initialize(providerForModuleContent: PackageFragmentProvider) { assert(!isInitialized) { "Attempt to initialize module $id twice" } this.packageFragmentProviderForModuleContent = providerForModuleContent } @@ -99,7 +99,7 @@ public class ModuleDescriptorImpl @JvmOverloads constructor( override fun isFriend(other: ModuleDescriptor) = other == this || other in friendModules - public fun addFriend(friend: ModuleDescriptorImpl): Unit { + fun addFriend(friend: ModuleDescriptorImpl): Unit { assert(friend != this) { "Attempt to make module $id a friend to itself" } friendModules.add(friend) } @@ -108,13 +108,13 @@ public class ModuleDescriptorImpl @JvmOverloads constructor( override fun getCapability(capability: ModuleDescriptor.Capability) = capabilities[capability] as? T } -public interface ModuleDependencies { - public val descriptors: List +interface ModuleDependencies { + val descriptors: List } -public class ModuleDependenciesImpl(override val descriptors: List) : ModuleDependencies +class ModuleDependenciesImpl(override val descriptors: List) : ModuleDependencies -public class LazyModuleDependencies( +class LazyModuleDependencies( storageManager: StorageManager, computeDependencies: () -> List ) : ModuleDependencies { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PackageFragmentDescriptorImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PackageFragmentDescriptorImpl.kt index 1b9e5936b18..31c697c23a7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PackageFragmentDescriptorImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PackageFragmentDescriptorImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.types.TypeSubstitutor -public abstract class PackageFragmentDescriptorImpl( +abstract class PackageFragmentDescriptorImpl( module: ModuleDescriptor, override val fqName: FqName ) : DeclarationDescriptorNonRootImpl(module, Annotations.EMPTY, fqName.shortNameOrSpecial(), SourceElement.NO_SOURCE), diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt index ff1e3dcea12..791037a23d2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt @@ -28,10 +28,10 @@ import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* -public open class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, private val fqName: FqName) : MemberScopeImpl() { +open class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, private val fqName: FqName) : MemberScopeImpl() { protected fun getPackage(name: Name): PackageViewDescriptor? { - if (name.isSpecial()) { + if (name.isSpecial) { return null } val packageViewDescriptor = moduleDescriptor.getPackage(fqName.child(name)) @@ -44,7 +44,7 @@ public open class SubpackagesScope(private val moduleDescriptor: ModuleDescripto override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { if (!kindFilter.acceptsKinds(DescriptorKindFilter.PACKAGES_MASK)) return listOf() - if (fqName.isRoot() && kindFilter.excludes.contains(DescriptorKindExclude.TopLevelPackages)) return listOf() + if (fqName.isRoot && kindFilter.excludes.contains(DescriptorKindExclude.TopLevelPackages)) return listOf() val subFqNames = moduleDescriptor.getSubPackagesOf(fqName, nameFilter) val result = ArrayList(subFqNames.size) @@ -58,7 +58,7 @@ public open class SubpackagesScope(private val moduleDescriptor: ModuleDescripto } override fun printScopeStructure(p: Printer) { - p.println(javaClass.getSimpleName(), " {") + p.println(javaClass.simpleName, " {") p.pushIndent() p.popIndent() diff --git a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt index 66dc9ee949a..0969c32bf01 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.components import java.io.Serializable -public interface LookupLocation { +interface LookupLocation { val location: LocationInfo? } @@ -35,7 +35,7 @@ data class Position(val line: Int, val column: Int) : Serializable { } } -public enum class NoLookupLocation : LookupLocation { +enum class NoLookupLocation : LookupLocation { FROM_IDE, FROM_BACKEND, FROM_TEST, diff --git a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupTracker.kt b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupTracker.kt index 09c11e5468f..873b0d09a98 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupTracker.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupTracker.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.components import java.io.Serializable -public interface LookupTracker { +interface LookupTracker { // used in tests for more accurate checks val requiresPosition: Boolean @@ -41,7 +41,7 @@ public interface LookupTracker { } } -public enum class ScopeKind { +enum class ScopeKind { PACKAGE, CLASSIFIER } diff --git a/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt b/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt index b047547fe07..fdec289002f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.incremental.components.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe -public fun LookupTracker.record(from: LookupLocation, scopeOwner: DeclarationDescriptor, name: Name) { +fun LookupTracker.record(from: LookupLocation, scopeOwner: DeclarationDescriptor, name: Name) { if (this == LookupTracker.DO_NOTHING || from is NoLookupLocation) return val location = from.location ?: return diff --git a/core/descriptors/src/org/jetbrains/kotlin/name/FqNamesUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/name/FqNamesUtil.kt index 601c559764b..89f724e1cea 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/name/FqNamesUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/name/FqNamesUtil.kt @@ -16,10 +16,10 @@ package org.jetbrains.kotlin.name -public fun FqName.isSubpackageOf(packageName: FqName): Boolean { +fun FqName.isSubpackageOf(packageName: FqName): Boolean { return when { this == packageName -> true - packageName.isRoot() -> true + packageName.isRoot -> true else -> isSubpackageOf(this.asString(), packageName.asString()) } } @@ -28,7 +28,7 @@ private fun isSubpackageOf(subpackageNameStr: String, packageNameStr: String): B return subpackageNameStr.startsWith(packageNameStr) && subpackageNameStr[packageNameStr.length] == '.' } -public fun FqName.isOneSegmentFQN(): Boolean = !isRoot() && parent().isRoot() +fun FqName.isOneSegmentFQN(): Boolean = !isRoot && parent().isRoot /** * Get the tail part of the FQ name by stripping a prefix. If FQ name does not begin with the given prefix, it will be returned as is. @@ -39,15 +39,15 @@ public fun FqName.isOneSegmentFQN(): Boolean = !isRoot() && parent().isRoot() * "org.jetbrains.kotlin".tail("org.jetbrains.kotlin") = "" * "org.jetbrains.kotlin".tail("org.jetbrains.gogland") = "org.jetbrains.kotlin" */ -public fun FqName.tail(prefix: FqName): FqName { +fun FqName.tail(prefix: FqName): FqName { return when { - !isSubpackageOf(prefix) || prefix.isRoot() -> this + !isSubpackageOf(prefix) || prefix.isRoot -> this this == prefix -> FqName.ROOT else -> FqName(asString().substring(prefix.asString().length + 1)) } } -public fun FqName.parentOrNull(): FqName? = if (this.isRoot) null else parent() +fun FqName.parentOrNull(): FqName? = if (this.isRoot) null else parent() private enum class State { BEGINNING, @@ -56,7 +56,7 @@ private enum class State { } // Check that it is javaName(\.javaName)* or an empty string -public fun isValidJavaFqName(qualifiedName: String?): Boolean { +fun isValidJavaFqName(qualifiedName: String?): Boolean { if (qualifiedName == null) return false var state = State.BEGINNING diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt index 035004ec483..a48b00d64a0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.types.Flexibility import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeCapability -public interface CustomFlexibleRendering : TypeCapability { - public fun renderInflexible(type: KotlinType, renderer: DescriptorRenderer): String? - public fun renderBounds(flexibility: Flexibility, renderer: DescriptorRenderer): Pair? +interface CustomFlexibleRendering : TypeCapability { + fun renderInflexible(type: KotlinType, renderer: DescriptorRenderer): String? + fun renderBounds(flexibility: Flexibility, renderer: DescriptorRenderer): Pair? } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index 43326362dcf..94f13f8af71 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -26,45 +26,45 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeProjection -public abstract class DescriptorRenderer : Renderer { - public fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer { +abstract class DescriptorRenderer : Renderer { + fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer { val options = (this as DescriptorRendererImpl).options.copy() options.changeOptions() options.lock() return DescriptorRendererImpl(options) } - public abstract fun renderType(type: KotlinType): String + abstract fun renderType(type: KotlinType): String - public abstract fun renderTypeArguments(typeArguments: List): String + abstract fun renderTypeArguments(typeArguments: List): String - public abstract fun renderTypeProjection(typeProjection: TypeProjection): String + abstract fun renderTypeProjection(typeProjection: TypeProjection): String - public abstract fun renderTypeConstructor(typeConstructor: TypeConstructor): String + abstract fun renderTypeConstructor(typeConstructor: TypeConstructor): String - public abstract fun renderClassifierName(klass: ClassifierDescriptor): String + abstract fun renderClassifierName(klass: ClassifierDescriptor): String - public abstract fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget? = null): String + abstract fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget? = null): String override abstract fun render(declarationDescriptor: DeclarationDescriptor): String - public abstract fun renderValueParameters(parameters: Collection, synthesizedParameterNames: Boolean): String + abstract fun renderValueParameters(parameters: Collection, synthesizedParameterNames: Boolean): String - public fun renderFunctionParameters(functionDescriptor: FunctionDescriptor): String + fun renderFunctionParameters(functionDescriptor: FunctionDescriptor): String = renderValueParameters(functionDescriptor.valueParameters, functionDescriptor.hasSynthesizedParameterNames()) - public abstract fun renderName(name: Name): String + abstract fun renderName(name: Name): String - public abstract fun renderFqName(fqName: FqNameUnsafe): String + abstract fun renderFqName(fqName: FqNameUnsafe): String - public interface ValueParametersHandler { - public fun appendBeforeValueParameters(parameterCount: Int, builder: StringBuilder) - public fun appendAfterValueParameters(parameterCount: Int, builder: StringBuilder) + interface ValueParametersHandler { + fun appendBeforeValueParameters(parameterCount: Int, builder: StringBuilder) + fun appendAfterValueParameters(parameterCount: Int, builder: StringBuilder) - public fun appendBeforeValueParameter(parameter: ValueParameterDescriptor, parameterIndex: Int, parameterCount: Int, builder: StringBuilder) - public fun appendAfterValueParameter(parameter: ValueParameterDescriptor, parameterIndex: Int, parameterCount: Int, builder: StringBuilder) + fun appendBeforeValueParameter(parameter: ValueParameterDescriptor, parameterIndex: Int, parameterCount: Int, builder: StringBuilder) + fun appendAfterValueParameter(parameter: ValueParameterDescriptor, parameterIndex: Int, parameterCount: Int, builder: StringBuilder) - public object DEFAULT : ValueParametersHandler { + object DEFAULT : ValueParametersHandler { override fun appendBeforeValueParameters(parameterCount: Int, builder: StringBuilder) { builder.append("(") } @@ -85,33 +85,29 @@ public abstract class DescriptorRenderer : Renderer { } companion object { - public fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer { + fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer { val options = DescriptorRendererOptionsImpl() options.changeOptions() options.lock() return DescriptorRendererImpl(options) } - @JvmField - public val COMPACT_WITH_MODIFIERS: DescriptorRenderer = withOptions { + @JvmField val COMPACT_WITH_MODIFIERS: DescriptorRenderer = withOptions { withDefinedIn = false } - @JvmField - public val COMPACT: DescriptorRenderer = withOptions { + @JvmField val COMPACT: DescriptorRenderer = withOptions { withDefinedIn = false modifiers = emptySet() } - @JvmField - public val COMPACT_WITH_SHORT_TYPES: DescriptorRenderer = withOptions { + @JvmField val COMPACT_WITH_SHORT_TYPES: DescriptorRenderer = withOptions { modifiers = emptySet() nameShortness = NameShortness.SHORT parameterNameRenderingPolicy = ParameterNameRenderingPolicy.ONLY_NON_SYNTHESIZED } - @JvmField - public val ONLY_NAMES_WITH_SHORT_TYPES: DescriptorRenderer = withOptions { + @JvmField val ONLY_NAMES_WITH_SHORT_TYPES: DescriptorRenderer = withOptions { withDefinedIn = false modifiers = emptySet() nameShortness = NameShortness.SHORT @@ -123,40 +119,35 @@ public abstract class DescriptorRenderer : Renderer { startFromName = true } - @JvmField - public val FQ_NAMES_IN_TYPES: DescriptorRenderer = withOptions { + @JvmField val FQ_NAMES_IN_TYPES: DescriptorRenderer = withOptions { modifiers = DescriptorRendererModifier.ALL } - @JvmField - public val SHORT_NAMES_IN_TYPES: DescriptorRenderer = withOptions { + @JvmField val SHORT_NAMES_IN_TYPES: DescriptorRenderer = withOptions { nameShortness = NameShortness.SHORT parameterNameRenderingPolicy = ParameterNameRenderingPolicy.ONLY_NON_SYNTHESIZED } - @JvmField - public val DEBUG_TEXT: DescriptorRenderer = withOptions { + @JvmField val DEBUG_TEXT: DescriptorRenderer = withOptions { debugMode = true nameShortness = NameShortness.FULLY_QUALIFIED modifiers = DescriptorRendererModifier.ALL } - @JvmField - public val FLEXIBLE_TYPES_FOR_CODE: DescriptorRenderer = withOptions { + @JvmField val FLEXIBLE_TYPES_FOR_CODE: DescriptorRenderer = withOptions { flexibleTypesForCode = true } - @JvmField - public val HTML: DescriptorRenderer = withOptions { + @JvmField val HTML: DescriptorRenderer = withOptions { textFormat = RenderingFormat.HTML modifiers = DescriptorRendererModifier.ALL } - public fun getClassKindPrefix(klass: ClassDescriptor): String { - if (klass.isCompanionObject()) { + fun getClassKindPrefix(klass: ClassDescriptor): String { + if (klass.isCompanionObject) { return "companion object" } - return when (klass.getKind()) { + return when (klass.kind) { ClassKind.CLASS -> "class" ClassKind.INTERFACE -> "interface" ClassKind.ENUM_CLASS -> "enum class" @@ -168,38 +159,38 @@ public abstract class DescriptorRenderer : Renderer { } } -public interface DescriptorRendererOptions { - public var nameShortness: NameShortness - public var withDefinedIn: Boolean - public var modifiers: Set - public var startFromName: Boolean - public var debugMode: Boolean - public var classWithPrimaryConstructor: Boolean - public var verbose: Boolean - public var unitReturnType: Boolean - public var withoutReturnType: Boolean - public var normalizedVisibilities: Boolean - public var showInternalKeyword: Boolean - public var prettyFunctionTypes: Boolean - public var uninferredTypeParameterAsName: Boolean - public var overrideRenderingPolicy: OverrideRenderingPolicy - public var valueParametersHandler: DescriptorRenderer.ValueParametersHandler - public var textFormat: RenderingFormat - public var excludedAnnotationClasses: Set - public var excludedTypeAnnotationClasses: Set - public var includePropertyConstant: Boolean - public var parameterNameRenderingPolicy: ParameterNameRenderingPolicy - public var withoutTypeParameters: Boolean - public var receiverAfterName: Boolean - public var renderCompanionObjectName: Boolean - public var withoutSuperTypes: Boolean - public var typeNormalizer: (KotlinType) -> KotlinType - public var renderDefaultValues: Boolean - public var flexibleTypesForCode: Boolean - public var secondaryConstructorsAsPrimary: Boolean - public var renderAccessors: Boolean - public var renderDefaultAnnotationArguments: Boolean - public var alwaysRenderModifiers: Boolean +interface DescriptorRendererOptions { + var nameShortness: NameShortness + var withDefinedIn: Boolean + var modifiers: Set + var startFromName: Boolean + var debugMode: Boolean + var classWithPrimaryConstructor: Boolean + var verbose: Boolean + var unitReturnType: Boolean + var withoutReturnType: Boolean + var normalizedVisibilities: Boolean + var showInternalKeyword: Boolean + var prettyFunctionTypes: Boolean + var uninferredTypeParameterAsName: Boolean + var overrideRenderingPolicy: OverrideRenderingPolicy + var valueParametersHandler: DescriptorRenderer.ValueParametersHandler + var textFormat: RenderingFormat + var excludedAnnotationClasses: Set + var excludedTypeAnnotationClasses: Set + var includePropertyConstant: Boolean + var parameterNameRenderingPolicy: ParameterNameRenderingPolicy + var withoutTypeParameters: Boolean + var receiverAfterName: Boolean + var renderCompanionObjectName: Boolean + var withoutSuperTypes: Boolean + var typeNormalizer: (KotlinType) -> KotlinType + var renderDefaultValues: Boolean + var flexibleTypesForCode: Boolean + var secondaryConstructorsAsPrimary: Boolean + var renderAccessors: Boolean + var renderDefaultAnnotationArguments: Boolean + var alwaysRenderModifiers: Boolean } object ExcludedTypeAnnotations { @@ -214,30 +205,30 @@ object ExcludedTypeAnnotations { FqName("kotlin.internal.Exact")) } -public enum class RenderingFormat { +enum class RenderingFormat { PLAIN, HTML } -public enum class NameShortness { +enum class NameShortness { SHORT, FULLY_QUALIFIED, SOURCE_CODE_QUALIFIED // for local declarations qualified up to function scope } -public enum class OverrideRenderingPolicy { +enum class OverrideRenderingPolicy { RENDER_OVERRIDE, RENDER_OPEN, RENDER_OPEN_OVERRIDE } -public enum class ParameterNameRenderingPolicy { +enum class ParameterNameRenderingPolicy { ALL, ONLY_NON_SYNTHESIZED, NONE } -public enum class DescriptorRendererModifier(val includeByDefault: Boolean) { +enum class DescriptorRendererModifier(val includeByDefault: Boolean) { VISIBILITY(true), MODALITY(true), OVERRIDE(true), diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 7a1ea89b11f..3f1a3d8eef1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -90,7 +90,7 @@ internal class DescriptorRendererImpl( } private fun renderName(descriptor: DeclarationDescriptor, builder: StringBuilder) { - builder.append(renderName(descriptor.getName())) + builder.append(renderName(descriptor.name)) } private fun renderCompanionObjectName(descriptor: DeclarationDescriptor, builder: StringBuilder) { @@ -99,15 +99,15 @@ internal class DescriptorRendererImpl( builder.append("companion object") } renderSpaceIfNeeded(builder) - val containingDeclaration = descriptor.getContainingDeclaration() + val containingDeclaration = descriptor.containingDeclaration if (containingDeclaration != null) { builder.append("of ") - builder.append(renderName(containingDeclaration.getName())) + builder.append(renderName(containingDeclaration.name)) } } if (verbose || descriptor.name != SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT) { if (!startFromName) renderSpaceIfNeeded(builder) - builder.append(renderName(descriptor.getName())) + builder.append(renderName(descriptor.name)) } } @@ -120,7 +120,7 @@ internal class DescriptorRendererImpl( return klass.fullFqName.asString() } if (ErrorUtils.isError(klass)) { - return klass.getTypeConstructor().toString() + return klass.typeConstructor.toString() } when (nameShortness) { NameShortness.SHORT -> { @@ -129,8 +129,8 @@ internal class DescriptorRendererImpl( // for nested classes qualified name should be used var current: DeclarationDescriptor? = klass do { - qualifiedNameElements.add(current!!.getName()) - current = current.getContainingDeclaration() + qualifiedNameElements.add(current!!.name) + current = current.containingDeclaration } while (current is ClassDescriptor) @@ -162,8 +162,8 @@ internal class DescriptorRendererImpl( return renderFlexibleTypeWithBothBounds(type.flexibility().lowerBound, type.flexibility().upperBound) } else if (flexibleTypesForCode) { - val prefix = if (nameShortness == NameShortness.SHORT) "" else Flexibility.FLEXIBLE_TYPE_CLASSIFIER.getPackageFqName().asString() + "." - return prefix + Flexibility.FLEXIBLE_TYPE_CLASSIFIER.getRelativeClassName() + lt() + renderNormalizedType(type.flexibility().lowerBound) + ", " + renderNormalizedType(type.flexibility().upperBound) + gt() + val prefix = if (nameShortness == NameShortness.SHORT) "" else Flexibility.FLEXIBLE_TYPE_CLASSIFIER.packageFqName.asString() + "." + return prefix + Flexibility.FLEXIBLE_TYPE_CLASSIFIER.relativeClassName + lt() + renderNormalizedType(type.flexibility().lowerBound) + ", " + renderNormalizedType(type.flexibility().upperBound) + gt() } else { return renderFlexibleType(type) @@ -189,11 +189,11 @@ internal class DescriptorRendererImpl( } if (ErrorUtils.isUninferredParameter(type)) { if (uninferredTypeParameterAsName) { - return renderError((type.getConstructor() as UninferredParameterTypeConstructor).getTypeParameterDescriptor().getName().toString()) + return renderError((type.constructor as UninferredParameterTypeConstructor).typeParameterDescriptor.name.toString()) } return "???" } - if (type.isError()) { + if (type.isError) { return renderDefaultType(type) } if (shouldRenderAsPrettyFunctionType(type)) { @@ -204,7 +204,7 @@ internal class DescriptorRendererImpl( private fun shouldRenderAsPrettyFunctionType(type: KotlinType): Boolean { return prettyFunctionTypes && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type) - && type.getArguments().none { it.isStarProjection() } + && type.arguments.none { it.isStarProjection } } private fun renderFlexibleType(type: KotlinType): String { @@ -251,15 +251,15 @@ internal class DescriptorRendererImpl( renderAnnotations(type, sb, /* needBrackets = */ true) - if (type.isError()) { - sb.append(type.getConstructor().toString()) // Debug name of an error type is more informative - sb.append(renderTypeArguments(type.getArguments())) + if (type.isError) { + sb.append(type.constructor.toString()) // Debug name of an error type is more informative + sb.append(renderTypeArguments(type.arguments)) } else { sb.append(renderTypeConstructorAndArguments(type)) } - if (type.isMarkedNullable()) { + if (type.isMarkedNullable) { sb.append("?") } return sb.toString() @@ -295,7 +295,7 @@ internal class DescriptorRendererImpl( override fun renderTypeConstructor(typeConstructor: TypeConstructor): String { - val cd = typeConstructor.getDeclarationDescriptor() + val cd = typeConstructor.declarationDescriptor return when (cd) { is TypeParameterDescriptor -> renderName(cd.getName()) is ClassDescriptor -> renderClassifierName(cd) @@ -310,24 +310,24 @@ internal class DescriptorRendererImpl( private fun appendTypeProjections(typeProjections: List, builder: StringBuilder) { typeProjections.map { - if (it.isStarProjection()) { + if (it.isStarProjection) { "*" } else { - val type = renderType(it.getType()) - if (it.getProjectionKind() == Variance.INVARIANT) type else "${it.getProjectionKind()} $type" + val type = renderType(it.type) + if (it.projectionKind == Variance.INVARIANT) type else "${it.projectionKind} $type" } }.joinTo(builder, ", ") } private fun renderFunctionType(type: KotlinType): String { return buildString { - val isNullable = type.isMarkedNullable() + val isNullable = type.isMarkedNullable if (isNullable) append("(") val receiverType = KotlinBuiltIns.getReceiverType(type) if (receiverType != null) { - val surroundReceiver = shouldRenderAsPrettyFunctionType(receiverType) && !receiverType.isMarkedNullable() + val surroundReceiver = shouldRenderAsPrettyFunctionType(receiverType) && !receiverType.isMarkedNullable if (surroundReceiver) { append("(") } @@ -375,9 +375,9 @@ internal class DescriptorRendererImpl( // See AnnotationResolver.resolveAndAppendAnnotationsFromModifiers for clarification // This hack can be removed when modifiers will be resolved without annotations - val sortedAnnotations = annotated.getAnnotations().getAllAnnotations() + val sortedAnnotations = annotated.annotations.getAllAnnotations() for ((annotation, target) in sortedAnnotations) { - val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as ClassDescriptor + val annotationClass = annotation.type.constructor.declarationDescriptor as ClassDescriptor if (!excluded.contains(DescriptorUtils.getFqNameSafe(annotationClass))) { append(renderAnnotation(annotation, target)).append(" ") @@ -394,7 +394,7 @@ internal class DescriptorRendererImpl( if (target != null) { append(target.renderName + ":") } - append(renderType(annotation.getType())) + append(renderType(annotation.type)) if (verbose) { renderAndSortAnnotationArguments(annotation).joinTo(this, ", ", "(", ")") } @@ -402,17 +402,17 @@ internal class DescriptorRendererImpl( } private fun renderAndSortAnnotationArguments(descriptor: AnnotationDescriptor): List { - val allValueArguments = descriptor.getAllValueArguments() - val classDescriptor = if (renderDefaultAnnotationArguments) TypeUtils.getClassDescriptor(descriptor.getType()) else null - val parameterDescriptorsWithDefaultValue = classDescriptor?.getUnsubstitutedPrimaryConstructor()?.getValueParameters()?.filter { + val allValueArguments = descriptor.allValueArguments + val classDescriptor = if (renderDefaultAnnotationArguments) TypeUtils.getClassDescriptor(descriptor.type) else null + val parameterDescriptorsWithDefaultValue = classDescriptor?.unsubstitutedPrimaryConstructor?.valueParameters?.filter { it.declaresDefaultValue() } ?: emptyList() val defaultList = parameterDescriptorsWithDefaultValue.filter { !allValueArguments.containsKey(it) }.map { - "${it.getName().asString()} = ..." + "${it.name.asString()} = ..." } val argumentList = allValueArguments.entries .map { entry -> - val name = entry.key.getName().asString() + val name = entry.key.name.asString() val value = if (!parameterDescriptorsWithDefaultValue.contains(entry.key)) renderConstant(entry.value) else "..." "$name = $value" } @@ -457,11 +457,11 @@ internal class DescriptorRendererImpl( } private fun renderModalityForCallable(callable: CallableMemberDescriptor, builder: StringBuilder) { - if (!DescriptorUtils.isTopLevelDeclaration(callable) || callable.getModality() != Modality.FINAL) { - if (overridesSomething(callable) && overrideRenderingPolicy == OverrideRenderingPolicy.RENDER_OVERRIDE && callable.getModality() == Modality.OPEN) { + if (!DescriptorUtils.isTopLevelDeclaration(callable) || callable.modality != Modality.FINAL) { + if (overridesSomething(callable) && overrideRenderingPolicy == OverrideRenderingPolicy.RENDER_OVERRIDE && callable.modality == Modality.OPEN) { return } - renderModality(callable.getModality(), builder) + renderModality(callable.modality, builder) } } @@ -471,7 +471,7 @@ internal class DescriptorRendererImpl( if (overrideRenderingPolicy != OverrideRenderingPolicy.RENDER_OPEN) { builder.append("override ") if (verbose) { - builder.append("/*").append(callableMember.getOverriddenDescriptors().size).append("*/ ") + builder.append("/*").append(callableMember.overriddenDescriptors.size).append("*/ ") } } } @@ -479,8 +479,8 @@ internal class DescriptorRendererImpl( private fun renderMemberKind(callableMember: CallableMemberDescriptor, builder: StringBuilder) { if (DescriptorRendererModifier.MEMBER_KIND !in modifiers) return - if (verbose && callableMember.getKind() != CallableMemberDescriptor.Kind.DECLARATION) { - builder.append("/*").append(callableMember.getKind().name.toLowerCase()).append("*/ ") + if (verbose && callableMember.kind != CallableMemberDescriptor.Kind.DECLARATION) { + builder.append("/*").append(callableMember.kind.name.toLowerCase()).append("*/ ") } } @@ -526,27 +526,27 @@ internal class DescriptorRendererImpl( } if (verbose) { - builder.append("/*").append(typeParameter.getIndex()).append("*/ ") + builder.append("/*").append(typeParameter.index).append("*/ ") } - if (typeParameter.isReified()) { + if (typeParameter.isReified) { builder.append(renderKeyword("reified")).append(" ") } - val variance = typeParameter.getVariance().label + val variance = typeParameter.variance.label if (!variance.isEmpty()) { builder.append(renderKeyword(variance)).append(" ") } renderName(typeParameter, builder) - val upperBoundsCount = typeParameter.getUpperBounds().size + val upperBoundsCount = typeParameter.upperBounds.size if ((upperBoundsCount > 1 && !topLevel) || upperBoundsCount == 1) { - val upperBound = typeParameter.getUpperBounds().iterator().next() + val upperBound = typeParameter.upperBounds.iterator().next() if (!KotlinBuiltIns.isDefaultBound(upperBound)) { builder.append(" : ").append(renderType(upperBound)) } } else if (topLevel) { var first = true - for (upperBound in typeParameter.getUpperBounds()) { + for (upperBound in typeParameter.upperBounds) { if (KotlinBuiltIns.isDefaultBound(upperBound)) { continue } @@ -597,7 +597,7 @@ internal class DescriptorRendererImpl( private fun renderFunction(function: FunctionDescriptor, builder: StringBuilder) { if (!startFromName) { renderAnnotations(function, builder) - renderVisibility(function.getVisibility(), builder) + renderVisibility(function.visibility, builder) renderModalityForCallable(function, builder) renderAdditionalModifiers(function, builder) renderOverride(function, builder) @@ -608,7 +608,7 @@ internal class DescriptorRendererImpl( } builder.append(renderKeyword("fun")).append(" ") - renderTypeParameters(function.getTypeParameters(), builder, true) + renderTypeParameters(function.typeParameters, builder, true) renderReceiver(function, builder) } @@ -618,27 +618,27 @@ internal class DescriptorRendererImpl( renderReceiverAfterName(function, builder) - val returnType = function.getReturnType() + val returnType = function.returnType if (!withoutReturnType && (unitReturnType || (returnType == null || !KotlinBuiltIns.isUnit(returnType)))) { builder.append(": ").append(if (returnType == null) "[NULL]" else escape(renderType(returnType))) } - renderWhereSuffix(function.getTypeParameters(), builder) + renderWhereSuffix(function.typeParameters, builder) } private fun renderReceiverAfterName(callableDescriptor: CallableDescriptor, builder: StringBuilder) { if (!receiverAfterName) return - val receiver = callableDescriptor.getExtensionReceiverParameter() + val receiver = callableDescriptor.extensionReceiverParameter if (receiver != null) { - builder.append(" on ").append(escape(renderType(receiver.getType()))) + builder.append(" on ").append(escape(renderType(receiver.type))) } } private fun renderReceiver(callableDescriptor: CallableDescriptor, builder: StringBuilder) { - val receiver = callableDescriptor.getExtensionReceiverParameter() + val receiver = callableDescriptor.extensionReceiverParameter if (receiver != null) { - val type = receiver.getType() + val type = receiver.type var result = escape(renderType(type)) if (shouldRenderAsPrettyFunctionType(type) && !TypeUtils.isNullableType(type)) { result = "($result)" @@ -649,12 +649,12 @@ internal class DescriptorRendererImpl( private fun renderConstructor(constructor: ConstructorDescriptor, builder: StringBuilder) { renderAnnotations(constructor, builder) - renderVisibility(constructor.getVisibility(), builder) + renderVisibility(constructor.visibility, builder) renderMemberKind(constructor, builder) builder.append(renderKeyword("constructor")) if (secondaryConstructorsAsPrimary) { - val classDescriptor = constructor.getContainingDeclaration() + val classDescriptor = constructor.containingDeclaration builder.append(" ") renderName(classDescriptor, builder) renderTypeParameters(classDescriptor.declaredTypeParameters, builder, false) @@ -663,7 +663,7 @@ internal class DescriptorRendererImpl( renderValueParameters(constructor.valueParameters, constructor.hasSynthesizedParameterNames(), builder) if (secondaryConstructorsAsPrimary) { - renderWhereSuffix(constructor.getTypeParameters(), builder) + renderWhereSuffix(constructor.typeParameters, builder) } } @@ -673,9 +673,9 @@ internal class DescriptorRendererImpl( val upperBoundStrings = ArrayList(0) for (typeParameter in typeParameters) { - typeParameter.getUpperBounds() + typeParameter.upperBounds .drop(1) // first parameter is rendered by renderTypeParameter - .mapTo(upperBoundStrings) { renderName(typeParameter.getName()) + " : " + escape(renderType(it)) } + .mapTo(upperBoundStrings) { renderName(typeParameter.name) + " : " + escape(renderType(it)) } } if (!upperBoundStrings.isEmpty()) { @@ -736,11 +736,11 @@ internal class DescriptorRendererImpl( } private fun renderValVarPrefix(variable: VariableDescriptor, builder: StringBuilder) { - builder.append(renderKeyword(if (variable.isVar()) "var" else "val")).append(" ") + builder.append(renderKeyword(if (variable.isVar) "var" else "val")).append(" ") } private fun renderVariable(variable: VariableDescriptor, includeName: Boolean, builder: StringBuilder, topLevel: Boolean) { - val realType = variable.getType() + val realType = variable.type val varargElementType = (variable as? ValueParameterDescriptor)?.varargElementType val typeToRender = varargElementType ?: realType @@ -769,7 +769,7 @@ internal class DescriptorRendererImpl( private fun renderProperty(property: PropertyDescriptor, builder: StringBuilder) { if (!startFromName) { renderAnnotations(property, builder) - renderVisibility(property.getVisibility(), builder) + renderVisibility(property.visibility, builder) if (property.isConst) { builder.append("const ") @@ -780,23 +780,23 @@ internal class DescriptorRendererImpl( renderLateInit(property, builder) renderMemberKind(property, builder) renderValVarPrefix(property, builder) - renderTypeParameters(property.getTypeParameters(), builder, true) + renderTypeParameters(property.typeParameters, builder, true) renderReceiver(property, builder) } renderName(property, builder) - builder.append(": ").append(escape(renderType(property.getType()))) + builder.append(": ").append(escape(renderType(property.type))) renderReceiverAfterName(property, builder) renderInitializer(property, builder) - renderWhereSuffix(property.getTypeParameters(), builder) + renderWhereSuffix(property.typeParameters, builder) } private fun renderInitializer(variable: VariableDescriptor, builder: StringBuilder) { if (includePropertyConstant) { - variable.getCompileTimeInitializer()?.let { constant -> + variable.compileTimeInitializer?.let { constant -> builder.append(" = ").append(escape(renderConstant(constant))) } } @@ -861,7 +861,7 @@ internal class DescriptorRendererImpl( if (KotlinBuiltIns.isNothing(klass.defaultType)) return - val supertypes = klass.getTypeConstructor().getSupertypes() + val supertypes = klass.typeConstructor.supertypes if (supertypes.isEmpty() || supertypes.size == 1 && KotlinBuiltIns.isAnyOrNullableAny(supertypes.iterator().next())) return renderSpaceIfNeeded(builder) @@ -890,7 +890,7 @@ internal class DescriptorRendererImpl( builder.append(renderFqName(fragment.fqName.toUnsafe())) if (debugMode) { builder.append(" in ") - renderName(fragment.getContainingDeclaration(), builder) + renderName(fragment.containingDeclaration, builder) } } @@ -918,7 +918,7 @@ internal class DescriptorRendererImpl( if (renderAccessors) { renderAccessorModifiers(descriptor, builder) builder.append("getter for ") - renderProperty(descriptor.getCorrespondingProperty(), builder) + renderProperty(descriptor.correspondingProperty, builder) } else { visitFunctionDescriptor(descriptor, builder) @@ -930,7 +930,7 @@ internal class DescriptorRendererImpl( if (renderAccessors) { renderAccessorModifiers(descriptor, builder) builder.append("setter for ") - renderProperty(descriptor.getCorrespondingProperty(), builder) + renderProperty(descriptor.correspondingProperty, builder) } else { visitFunctionDescriptor(descriptor, builder) @@ -999,5 +999,5 @@ internal class DescriptorRendererImpl( private fun differsOnlyInNullability(lower: String, upper: String) = lower == upper.replace("?", "") || upper.endsWith("?") && ("$lower?") == upper || "($lower)?" == upper - private fun overridesSomething(callable: CallableMemberDescriptor) = !callable.getOverriddenDescriptors().isEmpty() + private fun overridesSomething(callable: CallableMemberDescriptor) = !callable.overriddenDescriptors.isEmpty() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index c787d940717..b4e098aa076 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -25,15 +25,15 @@ import kotlin.properties.ObservableProperty import kotlin.properties.ReadWriteProperty internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { - public var isLocked: Boolean = false + var isLocked: Boolean = false private set - public fun lock() { + fun lock() { assert(!isLocked) isLocked = true } - public fun copy(): DescriptorRendererOptionsImpl { + fun copy(): DescriptorRendererOptionsImpl { val copy = DescriptorRendererOptionsImpl() //TODO: use Kotlin reflection diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/Renderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/Renderer.kt index 222bad1ef21..92f056bab3a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/Renderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/Renderer.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.renderer -public interface Renderer { +interface Renderer { fun render(obj: O): String } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/RenderingUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/RenderingUtils.kt index a86c32be6bd..4f4235e4174 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/RenderingUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/RenderingUtils.kt @@ -21,12 +21,12 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name -public fun qualifiedNameForSourceCode(descriptor: ClassifierDescriptor): String { - val nameString = descriptor.getName().render() +fun qualifiedNameForSourceCode(descriptor: ClassifierDescriptor): String { + val nameString = descriptor.name.render() if (descriptor is TypeParameterDescriptor) { return nameString } - val qualifier = qualifierName(descriptor.getContainingDeclaration()) + val qualifier = qualifierName(descriptor.containingDeclaration) return if (qualifier != null && qualifier != "") qualifier + "." + nameString else nameString } @@ -37,26 +37,26 @@ private fun qualifierName(descriptor: DeclarationDescriptor): String? = when (de } -public fun Name.render(): String { +fun Name.render(): String { return if (this.shouldBeEscaped()) '`' + asString() + '`' else asString() } private fun Name.shouldBeEscaped(): Boolean { - if (isSpecial()) return false + if (isSpecial) return false val string = asString() return string in KeywordStringsGenerated.KEYWORDS || string.any { !Character.isLetterOrDigit(it) && it != '_' } } -public fun FqNameUnsafe.render(): String { +fun FqNameUnsafe.render(): String { return renderFqName(pathSegments()) } -public fun FqName.render(): String { +fun FqName.render(): String { return renderFqName(pathSegments()) } -public fun renderFqName(pathSegments: List): String { +fun renderFqName(pathSegments: List): String { return buildString { for (element in pathSegments) { if (length > 0) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index 09e46f8ca0f..1a6e8b6e758 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -31,74 +31,74 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.addToStdlib.check -public fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = getCompanionObjectDescriptor() ?: this +fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = companionObjectDescriptor ?: this -public fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor { +fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor { return when { - this is ConstructorDescriptor -> getContainingDeclaration() - this is PropertyAccessorDescriptor -> getCorrespondingProperty() + this is ConstructorDescriptor -> containingDeclaration + this is PropertyAccessorDescriptor -> correspondingProperty else -> this } } -public val DeclarationDescriptor.fqNameUnsafe: FqNameUnsafe +val DeclarationDescriptor.fqNameUnsafe: FqNameUnsafe get() = DescriptorUtils.getFqName(this) -public val DeclarationDescriptor.fqNameSafe: FqName +val DeclarationDescriptor.fqNameSafe: FqName get() = DescriptorUtils.getFqNameSafe(this) -public val DeclarationDescriptor.isExtension: Boolean - get() = this is CallableDescriptor && getExtensionReceiverParameter() != null +val DeclarationDescriptor.isExtension: Boolean + get() = this is CallableDescriptor && extensionReceiverParameter != null -public val DeclarationDescriptor.module: ModuleDescriptor +val DeclarationDescriptor.module: ModuleDescriptor get() = DescriptorUtils.getContainingModule(this) -public fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? { - assert(!topLevelClassFqName.isRoot()) +fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? { + assert(!topLevelClassFqName.isRoot) return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor } -public val ClassDescriptor.classId: ClassId +val ClassDescriptor.classId: ClassId get() { - val owner = getContainingDeclaration() + val owner = containingDeclaration if (owner is PackageFragmentDescriptor) { - return ClassId(owner.fqName, getName()) + return ClassId(owner.fqName, name) } else if (owner is ClassDescriptor) { - return owner.classId.createNestedClassId(getName()) + return owner.classId.createNestedClassId(name) } throw IllegalStateException("Illegal container: $owner") } -public val ClassDescriptor.hasCompanionObject: Boolean get() = companionObjectDescriptor != null +val ClassDescriptor.hasCompanionObject: Boolean get() = companionObjectDescriptor != null -public val ClassDescriptor.hasClassValueDescriptor: Boolean get() = classValueDescriptor != null +val ClassDescriptor.hasClassValueDescriptor: Boolean get() = classValueDescriptor != null -public val ClassDescriptor.classValueDescriptor: ClassDescriptor? +val ClassDescriptor.classValueDescriptor: ClassDescriptor? get() = if (kind.isSingleton) this else companionObjectDescriptor -public val ClassDescriptor.classValueTypeDescriptor: ClassDescriptor? +val ClassDescriptor.classValueTypeDescriptor: ClassDescriptor? get() = when (kind) { OBJECT -> this ENUM_ENTRY -> { // enum entry has the type of enum class val container = this.containingDeclaration - assert(container is ClassDescriptor && container.getKind() == ENUM_CLASS) + assert(container is ClassDescriptor && container.kind == ENUM_CLASS) container as ClassDescriptor } else -> companionObjectDescriptor } /** If a literal of this class can be used as a value, returns the type of this value */ -public val ClassDescriptor.classValueType: KotlinType? - get() = classValueTypeDescriptor?.getDefaultType() +val ClassDescriptor.classValueType: KotlinType? + get() = classValueTypeDescriptor?.defaultType -public val DeclarationDescriptorWithVisibility.isEffectivelyPublicApi: Boolean +val DeclarationDescriptorWithVisibility.isEffectivelyPublicApi: Boolean get() { var parent: DeclarationDescriptorWithVisibility? = this while (parent != null) { - if (!parent.getVisibility().isPublicAPI) return false + if (!parent.visibility.isPublicAPI) return false parent = DescriptorUtils.getParentOfType(parent, DeclarationDescriptorWithVisibility::class.java) } @@ -106,7 +106,7 @@ public val DeclarationDescriptorWithVisibility.isEffectivelyPublicApi: Boolean return true } -public fun ClassDescriptor.getSuperClassNotAny(): ClassDescriptor? { +fun ClassDescriptor.getSuperClassNotAny(): ClassDescriptor? { for (supertype in defaultType.constructor.supertypes) { if (!KotlinBuiltIns.isAnyOrNullableAny(supertype)) { val superClassifier = supertype.constructor.declarationDescriptor @@ -118,12 +118,12 @@ public fun ClassDescriptor.getSuperClassNotAny(): ClassDescriptor? { return null } -public fun ClassDescriptor.getSuperClassOrAny(): ClassDescriptor = getSuperClassNotAny() ?: builtIns.getAny() +fun ClassDescriptor.getSuperClassOrAny(): ClassDescriptor = getSuperClassNotAny() ?: builtIns.any -public val ClassDescriptor.secondaryConstructors: List - get() = getConstructors().filterNot { it.isPrimary() } +val ClassDescriptor.secondaryConstructors: List + get() = constructors.filterNot { it.isPrimary } -public val DeclarationDescriptor.builtIns: KotlinBuiltIns +val DeclarationDescriptor.builtIns: KotlinBuiltIns get() = module.builtIns /** @@ -144,17 +144,17 @@ public val DeclarationDescriptor.builtIns: KotlinBuiltIns * for constructor of Outer.Inner -> returns Outer (dispatch receiver parameter is Outer, but it's containing declaration is Inner) * */ -public fun CallableDescriptor.getOwnerForEffectiveDispatchReceiverParameter(): DeclarationDescriptor? { - if (this is CallableMemberDescriptor && getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { +fun CallableDescriptor.getOwnerForEffectiveDispatchReceiverParameter(): DeclarationDescriptor? { + if (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { return getContainingDeclaration() } - return getDispatchReceiverParameter()?.getContainingDeclaration() + return dispatchReceiverParameter?.containingDeclaration } /** * @return `true` iff the parameter has a default value, i.e. declares it or inherits by overriding a parameter which has a default value. */ -public fun ValueParameterDescriptor.hasDefaultValue(): Boolean { +fun ValueParameterDescriptor.hasDefaultValue(): Boolean { val handler = object : DFS.AbstractNodeHandler() { var result = false @@ -177,13 +177,13 @@ public fun ValueParameterDescriptor.hasDefaultValue(): Boolean { return handler.result() } -public fun Annotated.isRepeatableAnnotation(): Boolean = +fun Annotated.isRepeatableAnnotation(): Boolean = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.repeatable) != null -public fun Annotated.isDocumentedAnnotation(): Boolean = +fun Annotated.isDocumentedAnnotation(): Boolean = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.mustBeDocumented) != null -public fun Annotated.getAnnotationRetention(): KotlinRetention? { +fun Annotated.getAnnotationRetention(): KotlinRetention? { val annotationEntryDescriptor = annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.retention) ?: return null val retentionArgumentValue = annotationEntryDescriptor.allValueArguments.entries.firstOrNull { it.key.name.asString() == "value" @@ -191,10 +191,10 @@ public fun Annotated.getAnnotationRetention(): KotlinRetention? { return KotlinRetention.valueOf(retentionArgumentValue.value.name.asString()) } -public val DeclarationDescriptor.parentsWithSelf: Sequence +val DeclarationDescriptor.parentsWithSelf: Sequence get() = sequence(this, { it.containingDeclaration }) -public val DeclarationDescriptor.parents: Sequence +val DeclarationDescriptor.parents: Sequence get() = parentsWithSelf.drop(1) val CallableMemberDescriptor.propertyIfAccessor: CallableMemberDescriptor @@ -202,7 +202,7 @@ val CallableMemberDescriptor.propertyIfAccessor: CallableMemberDescriptor fun CallableDescriptor.fqNameOrNull(): FqName? = fqNameUnsafe.check { it.isSafe }?.toSafe() -public fun CallableMemberDescriptor.firstOverridden( +fun CallableMemberDescriptor.firstOverridden( predicate: (CallableMemberDescriptor) -> Boolean ): CallableMemberDescriptor? { var result: CallableMemberDescriptor? = null diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt index 3235f579174..5f4a408ae73 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt @@ -27,24 +27,24 @@ import org.jetbrains.kotlin.types.KotlinType private val NO_INFER_ANNOTATION_FQ_NAME = FqName("kotlin.internal.NoInfer") private val EXACT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.Exact") -public fun KotlinType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) +fun KotlinType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) -public fun KotlinType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME) +fun KotlinType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME) -public fun Annotations.hasInternalAnnotationForResolve(): Boolean = +fun Annotations.hasInternalAnnotationForResolve(): Boolean = hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) || hasAnnotation(EXACT_ANNOTATION_FQ_NAME) -public fun FqName.isInternalAnnotationForResolve() = this == NO_INFER_ANNOTATION_FQ_NAME || this == EXACT_ANNOTATION_FQ_NAME +fun FqName.isInternalAnnotationForResolve() = this == NO_INFER_ANNOTATION_FQ_NAME || this == EXACT_ANNOTATION_FQ_NAME private val LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME = FqName("kotlin.internal.LowPriorityInOverloadResolution") -public fun CallableDescriptor.hasLowPriorityInOverloadResolution(): Boolean = annotations.hasAnnotation(LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME) +fun CallableDescriptor.hasLowPriorityInOverloadResolution(): Boolean = annotations.hasAnnotation(LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME) private val ONLY_INPUT_TYPES_FQ_NAME = FqName("kotlin.internal.OnlyInputTypes") -public fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME) +fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME) -public fun getExactInAnnotations(): Annotations = AnnotationsWithOnly(EXACT_ANNOTATION_FQ_NAME) +fun getExactInAnnotations(): Annotations = AnnotationsWithOnly(EXACT_ANNOTATION_FQ_NAME) private class AnnotationsWithOnly(val presentAnnotation: FqName): Annotations { override fun iterator(): Iterator = listOf().iterator() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt index d2e419ec1f6..844c7e283aa 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt @@ -24,11 +24,11 @@ import org.jetbrains.kotlin.types.Variance.IN_VARIANCE import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE import org.jetbrains.kotlin.types.typeUtil.builtIns -public class CapturedTypeConstructor( - public val typeProjection: TypeProjection +class CapturedTypeConstructor( + val typeProjection: TypeProjection ): TypeConstructor { init { - assert(typeProjection.getProjectionKind() != Variance.INVARIANT) { + assert(typeProjection.projectionKind != Variance.INVARIANT) { "Only nontrivial projections can be captured, not: $typeProjection" } } @@ -36,8 +36,8 @@ public class CapturedTypeConstructor( override fun getParameters(): List = listOf() override fun getSupertypes(): Collection { - val superType = if (typeProjection.getProjectionKind() == Variance.OUT_VARIANCE) - typeProjection.getType() + val superType = if (typeProjection.projectionKind == Variance.OUT_VARIANCE) + typeProjection.type else builtIns.nullableAnyType return listOf(superType) @@ -56,7 +56,7 @@ public class CapturedTypeConstructor( override fun getBuiltIns(): KotlinBuiltIns = typeProjection.type.constructor.builtIns } -public class CapturedType( +class CapturedType( private val typeProjection: TypeProjection ): DelegatingType(), SubtypingRepresentatives { @@ -86,18 +86,18 @@ public class CapturedType( get() = representative(IN_VARIANCE, builtIns.nothingType) private fun representative(variance: Variance, default: KotlinType) = - if (typeProjection.getProjectionKind() == variance) typeProjection.getType() else default + if (typeProjection.projectionKind == variance) typeProjection.type else default - override fun sameTypeConstructor(type: KotlinType) = delegateType.getConstructor() === type.getConstructor() + override fun sameTypeConstructor(type: KotlinType) = delegateType.constructor === type.constructor override fun toString() = "Captured($typeProjection)" } -public fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection) +fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection) -public fun KotlinType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor +fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor -public fun TypeSubstitution.wrapWithCapturingSubstitution(): TypeSubstitution = +fun TypeSubstitution.wrapWithCapturingSubstitution(): TypeSubstitution = if (this is IndexedParametersSubstitution) IndexedParametersSubstitution( this.parameters, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index ce572aa6c46..ac2f8655718 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -20,45 +20,45 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.types.* -public interface CompileTimeConstant { - public val isError: Boolean +interface CompileTimeConstant { + val isError: Boolean get() = false - public val parameters: CompileTimeConstant.Parameters + val parameters: CompileTimeConstant.Parameters - public fun toConstantValue(expectedType: KotlinType): ConstantValue + fun toConstantValue(expectedType: KotlinType): ConstantValue - public fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value + fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value - public val canBeUsedInAnnotations: Boolean get() = parameters.canBeUsedInAnnotation + val canBeUsedInAnnotations: Boolean get() = parameters.canBeUsedInAnnotation - public val usesVariableAsConstant: Boolean get() = parameters.usesVariableAsConstant + val usesVariableAsConstant: Boolean get() = parameters.usesVariableAsConstant - public val usesNonConstValAsConstant: Boolean get() = parameters.usesNonConstValAsConstant + val usesNonConstValAsConstant: Boolean get() = parameters.usesNonConstValAsConstant - public val isPure: Boolean get() = parameters.isPure + val isPure: Boolean get() = parameters.isPure - public class Parameters( - public val canBeUsedInAnnotation: Boolean, - public val isPure: Boolean, - public val usesVariableAsConstant: Boolean, - public val usesNonConstValAsConstant: Boolean + class Parameters( + val canBeUsedInAnnotation: Boolean, + val isPure: Boolean, + val usesVariableAsConstant: Boolean, + val usesNonConstValAsConstant: Boolean ) } -public class TypedCompileTimeConstant( - public val constantValue: ConstantValue, +class TypedCompileTimeConstant( + val constantValue: ConstantValue, override val parameters: CompileTimeConstant.Parameters ) : CompileTimeConstant { override val isError: Boolean get() = constantValue is ErrorValue - public val type: KotlinType = constantValue.type + val type: KotlinType = constantValue.type override fun toConstantValue(expectedType: KotlinType): ConstantValue = constantValue } -public class IntegerValueTypeConstant( +class IntegerValueTypeConstant( private val value: Number, private val builtIns: KotlinBuiltIns, override val parameters: CompileTimeConstant.Parameters @@ -89,7 +89,7 @@ public class IntegerValueTypeConstant( ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) ) - public fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) + fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) override fun toString() = typeConstructor.toString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt index 6d84c9f7d09..75e135f6070 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils -public class ConstantValueFactory( +class ConstantValueFactory( private val builtins: KotlinBuiltIns ) { fun createLongValue(value: Long) = LongValue(value, builtins) @@ -77,7 +77,7 @@ public class ConstantValueFactory( } } - public fun createIntegerConstantValue( + fun createIntegerConstantValue( value: Long, expectedType: KotlinType ): ConstantValue<*>? { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt index c40de35874d..61ed8e446eb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import java.util.* -public class IntegerValueTypeConstructor( +class IntegerValueTypeConstructor( private val value: Long, private val builtIns: KotlinBuiltIns ) : TypeConstructor { @@ -33,10 +33,10 @@ public class IntegerValueTypeConstructor( // order of types matters // 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type // for expected type 'Any' result type 'Int' should be returned - checkBoundsAndAddSuperType(value, Integer.MIN_VALUE.toLong(), Integer.MAX_VALUE.toLong(), builtIns.getIntType()) - checkBoundsAndAddSuperType(value, java.lang.Byte.MIN_VALUE.toLong(), java.lang.Byte.MAX_VALUE.toLong(), builtIns.getByteType()) - checkBoundsAndAddSuperType(value, java.lang.Short.MIN_VALUE.toLong(), java.lang.Short.MAX_VALUE.toLong(), builtIns.getShortType()) - supertypes.add(builtIns.getLongType()) + checkBoundsAndAddSuperType(value, Integer.MIN_VALUE.toLong(), Integer.MAX_VALUE.toLong(), builtIns.intType) + checkBoundsAndAddSuperType(value, java.lang.Byte.MIN_VALUE.toLong(), java.lang.Byte.MAX_VALUE.toLong(), builtIns.byteType) + checkBoundsAndAddSuperType(value, java.lang.Short.MIN_VALUE.toLong(), java.lang.Short.MAX_VALUE.toLong(), builtIns.shortType) + supertypes.add(builtIns.longType) } private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KotlinType) { @@ -57,7 +57,7 @@ public class IntegerValueTypeConstructor( override fun getAnnotations() = Annotations.EMPTY - public fun getValue(): Long = value + fun getValue(): Long = value override fun getBuiltIns(): KotlinBuiltIns { return builtIns diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt index 8965ece6b70..1f9ee124bf6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt @@ -25,26 +25,26 @@ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.sure -public abstract class ConstantValue(public open val value: T) { - public abstract val type: KotlinType +abstract class ConstantValue(open val value: T) { + abstract val type: KotlinType - public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R + abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R override fun toString() = value.toString() } -public abstract class IntegerValueConstant protected constructor(value: T) : ConstantValue(value) +abstract class IntegerValueConstant protected constructor(value: T) : ConstantValue(value) -public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue(value) { +class AnnotationValue(value: AnnotationDescriptor) : ConstantValue(value) { override val type: KotlinType - get() = value.getType() + get() = value.type override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitAnnotationValue(this, data) override fun toString() = value.toString() } -public class ArrayValue( +class ArrayValue( value: List>, override val type: KotlinType, private val builtIns: KotlinBuiltIns @@ -56,7 +56,7 @@ public class ArrayValue( override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitArrayValue(this, data) - public val elementType: KotlinType + val elementType: KotlinType get() = builtIns.getArrayElementType(type) override fun equals(other: Any?): Boolean { @@ -69,33 +69,33 @@ public class ArrayValue( override fun hashCode() = value.hashCode() } -public class BooleanValue( +class BooleanValue( value: Boolean, builtIns: KotlinBuiltIns ) : ConstantValue(value) { - override val type = builtIns.getBooleanType() + override val type = builtIns.booleanType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitBooleanValue(this, data) } -public class ByteValue( +class ByteValue( value: Byte, builtIns: KotlinBuiltIns ) : IntegerValueConstant(value) { - override val type = builtIns.getByteType() + override val type = builtIns.byteType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitByteValue(this, data) override fun toString(): String = "$value.toByte()" } -public class CharValue( +class CharValue( value: Char, builtIns: KotlinBuiltIns ) : IntegerValueConstant(value) { - override val type = builtIns.getCharType() + override val type = builtIns.charType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitCharValue(this, data) @@ -125,18 +125,18 @@ public class CharValue( } } -public class DoubleValue( +class DoubleValue( value: Double, builtIns: KotlinBuiltIns ) : ConstantValue(value) { - override val type = builtIns.getDoubleType() + override val type = builtIns.doubleType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitDoubleValue(this, data) override fun toString() = "$value.toDouble()" } -public class EnumValue( +class EnumValue( value: ClassDescriptor ) : ConstantValue(value) { @@ -145,7 +145,7 @@ public class EnumValue( override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitEnumValue(this, data) - override fun toString() = "$type.${value.getName()}" + override fun toString() = "$type.${value.name}" override fun equals(other: Any?): Boolean { if (this === other) return true @@ -157,7 +157,7 @@ public class EnumValue( override fun hashCode() = value.hashCode() } -public abstract class ErrorValue : ConstantValue(Unit) { +abstract class ErrorValue : ConstantValue(Unit) { @Deprecated("Should not be called, for this is not a real value, but a indication of an error") override val value: Unit @@ -165,7 +165,7 @@ public abstract class ErrorValue : ConstantValue(Unit) { override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitErrorValue(this, data) - public class ErrorValueWithMessage(public val message: String) : ErrorValue() { + class ErrorValueWithMessage(val message: String) : ErrorValue() { override val type = ErrorUtils.createErrorType(message) @@ -173,29 +173,29 @@ public abstract class ErrorValue : ConstantValue(Unit) { } companion object { - public fun create(message: String): ErrorValue { + fun create(message: String): ErrorValue { return ErrorValueWithMessage(message) } } } -public class FloatValue( +class FloatValue( value: Float, builtIns: KotlinBuiltIns ) : ConstantValue(value) { - override val type = builtIns.getFloatType() + override val type = builtIns.floatType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitFloatValue(this, data) override fun toString() = "$value.toFloat()" } -public class IntValue( +class IntValue( value: Int, builtIns: KotlinBuiltIns ) : IntegerValueConstant(value) { - override val type = builtIns.getIntType() + override val type = builtIns.intType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitIntValue(this, data) @@ -211,54 +211,54 @@ public class IntValue( override fun hashCode() = value } -public class KClassValue(override val type: KotlinType) : +class KClassValue(override val type: KotlinType) : ConstantValue(type) { override val value: KotlinType - get() = type.getArguments().single().getType() + get() = type.arguments.single().type override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitKClassValue(this, data) } -public class LongValue( +class LongValue( value: Long, builtIns: KotlinBuiltIns ) : IntegerValueConstant(value) { - override val type = builtIns.getLongType() + override val type = builtIns.longType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitLongValue(this, data) override fun toString() = "$value.toLong()" } -public class NullValue( +class NullValue( builtIns: KotlinBuiltIns ) : ConstantValue(null) { - override val type = builtIns.getNullableNothingType() + override val type = builtIns.nullableNothingType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitNullValue(this, data) override fun toString() = "null" } -public class ShortValue( +class ShortValue( value: Short, builtIns: KotlinBuiltIns ) : IntegerValueConstant(value) { - override val type = builtIns.getShortType() + override val type = builtIns.shortType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitShortValue(this, data) override fun toString() = "$value.toShort()" } -public class StringValue( +class StringValue( value: String, builtIns: KotlinBuiltIns ) : ConstantValue(value) { - override val type = builtIns.getStringType() + override val type = builtIns.stringType override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitStringValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/overridingUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/overridingUtils.kt index e23476394c1..089015cec2a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/overridingUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/overridingUtils.kt @@ -46,7 +46,7 @@ fun D.findOriginalTopMostOverriddenDescriptors(): Set is something that handles CallableDescriptor inside */ -public fun Collection.selectMostSpecificInEachOverridableGroup( +fun Collection.selectMostSpecificInEachOverridableGroup( descriptorByHandle: H.() -> CallableDescriptor ): Collection { if (size <= 1) return this diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index 06a7cec1f34..1b54bc79561 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -24,10 +24,10 @@ import org.jetbrains.kotlin.utils.Printer /** * Introduces a simple wrapper for internal scope. */ -public abstract class AbstractScopeAdapter : MemberScope { +abstract class AbstractScopeAdapter : MemberScope { protected abstract val workerScope: MemberScope - public fun getActualScope(): MemberScope = + fun getActualScope(): MemberScope = if (workerScope is AbstractScopeAdapter) (workerScope as AbstractScopeAdapter).getActualScope() else @@ -51,7 +51,7 @@ public abstract class AbstractScopeAdapter : MemberScope { } override fun printScopeStructure(p: Printer) { - p.println(javaClass.getSimpleName(), " {") + p.println(javaClass.simpleName, " {") p.pushIndent() p.print("worker =") diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt index b305b1d4bca..d03daf3f576 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.util.collectionUtils.getFirstMatch import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes import org.jetbrains.kotlin.utils.Printer -public class ChainedMemberScope( +class ChainedMemberScope( internal val debugName: String, private val scopes: List ) : MemberScope { @@ -44,7 +44,7 @@ public class ChainedMemberScope( override fun toString() = debugName override fun printScopeStructure(p: Printer) { - p.println(javaClass.getSimpleName(), ": ", debugName, " {") + p.println(javaClass.simpleName, ": ", debugName, " {") p.pushIndent() for (scope in scopes) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt index 268f4d639f1..9367427a37a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.Printer -public class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl() { +class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl() { override fun getContributedClassifier(name: Name, location: LookupLocation) = workerScope.getContributedClassifier(name, location) as? ClassDescriptor override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/LazyScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/LazyScopeAdapter.kt index 2bb6b9e7a85..0f017fc0a8a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/LazyScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/LazyScopeAdapter.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.storage.NotNullLazyValue -public class LazyScopeAdapter(private val scope: NotNullLazyValue) : AbstractScopeAdapter() { +class LazyScopeAdapter(private val scope: NotNullLazyValue) : AbstractScopeAdapter() { override val workerScope: MemberScope get() = scope() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt index 74009f73039..1a98245e2b5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt @@ -23,14 +23,14 @@ import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.lang.reflect.Modifier -public interface MemberScope : ResolutionScope { +interface MemberScope : ResolutionScope { - public override fun getContributedVariables(name: Name, location: LookupLocation): Collection + override fun getContributedVariables(name: Name, location: LookupLocation): Collection /** * Is supposed to be used in tests and debug only */ - public fun printScopeStructure(p: Printer) + fun printScopeStructure(p: Printer) object Empty : MemberScopeImpl() { override fun printScopeStructure(p: Printer) { @@ -39,26 +39,26 @@ public interface MemberScope : ResolutionScope { } companion object { - public val ALL_NAME_FILTER: (Name) -> Boolean = { true } + val ALL_NAME_FILTER: (Name) -> Boolean = { true } } } /** * The same as getDescriptors(kindFilter, nameFilter) but the result is guaranteed to be filtered by kind and name. */ -public fun MemberScope.getDescriptorsFiltered( +fun MemberScope.getDescriptorsFiltered( kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, nameFilter: (Name) -> Boolean = { true } ): Collection { if (kindFilter.kindMask == 0) return listOf() - return getContributedDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) } + return getContributedDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.name) } } -public class DescriptorKindFilter( +class DescriptorKindFilter( kindMask: Int, - public val excludes: List = listOf() + val excludes: List = listOf() ) { - public val kindMask: Int + val kindMask: Int init { var mask = kindMask @@ -66,31 +66,31 @@ public class DescriptorKindFilter( this.kindMask = mask } - public fun accepts(descriptor: DeclarationDescriptor): Boolean + fun accepts(descriptor: DeclarationDescriptor): Boolean = kindMask and descriptor.kind() != 0 && excludes.all { !it.excludes(descriptor) } - public fun acceptsKinds(kinds: Int): Boolean + fun acceptsKinds(kinds: Int): Boolean = kindMask and kinds != 0 - public infix fun exclude(exclude: DescriptorKindExclude): DescriptorKindFilter + infix fun exclude(exclude: DescriptorKindExclude): DescriptorKindFilter = DescriptorKindFilter(kindMask, excludes + listOf(exclude)) - public fun withoutKinds(kinds: Int): DescriptorKindFilter + fun withoutKinds(kinds: Int): DescriptorKindFilter = DescriptorKindFilter(kindMask and kinds.inv(), excludes) - public fun withKinds(kinds: Int): DescriptorKindFilter + fun withKinds(kinds: Int): DescriptorKindFilter = DescriptorKindFilter(kindMask or kinds, excludes) - public fun restrictedToKinds(kinds: Int): DescriptorKindFilter + fun restrictedToKinds(kinds: Int): DescriptorKindFilter = DescriptorKindFilter(kindMask and kinds, excludes) - public fun restrictedToKindsOrNull(kinds: Int): DescriptorKindFilter? { + fun restrictedToKindsOrNull(kinds: Int): DescriptorKindFilter? { val mask = kindMask and kinds if (mask == 0) return null return DescriptorKindFilter(mask, excludes) } - public fun intersect(other: DescriptorKindFilter) = DescriptorKindFilter(kindMask and other.kindMask, excludes + other.excludes) + fun intersect(other: DescriptorKindFilter) = DescriptorKindFilter(kindMask and other.kindMask, excludes + other.excludes) override fun toString(): String { val predefinedFilterName = DEBUG_PREDEFINED_FILTERS_MASK_NAMES.firstOrNull { it.mask == kindMask } ?.name @@ -104,7 +104,7 @@ public class DescriptorKindFilter( private fun DeclarationDescriptor.kind(): Int { return when (this) { - is ClassDescriptor -> if (this.getKind().isSingleton()) SINGLETON_CLASSIFIERS_MASK else NON_SINGLETON_CLASSIFIERS_MASK + is ClassDescriptor -> if (this.kind.isSingleton) SINGLETON_CLASSIFIERS_MASK else NON_SINGLETON_CLASSIFIERS_MASK is ClassifierDescriptor -> NON_SINGLETON_CLASSIFIERS_MASK is PackageFragmentDescriptor, is PackageViewDescriptor -> PACKAGES_MASK is FunctionDescriptor -> FUNCTIONS_MASK @@ -114,88 +114,88 @@ public class DescriptorKindFilter( } companion object { - public val NON_SINGLETON_CLASSIFIERS_MASK: Int = 0x01 - public val SINGLETON_CLASSIFIERS_MASK: Int = 0x02 - public val PACKAGES_MASK: Int = 0x04 - public val FUNCTIONS_MASK: Int = 0x08 - public val VARIABLES_MASK: Int = 0x10 + val NON_SINGLETON_CLASSIFIERS_MASK: Int = 0x01 + val SINGLETON_CLASSIFIERS_MASK: Int = 0x02 + val PACKAGES_MASK: Int = 0x04 + val FUNCTIONS_MASK: Int = 0x08 + val VARIABLES_MASK: Int = 0x10 - public val ALL_KINDS_MASK: Int = 0x1F - public val CLASSIFIERS_MASK: Int = NON_SINGLETON_CLASSIFIERS_MASK or SINGLETON_CLASSIFIERS_MASK - public val VALUES_MASK: Int = SINGLETON_CLASSIFIERS_MASK or FUNCTIONS_MASK or VARIABLES_MASK - public val CALLABLES_MASK: Int = FUNCTIONS_MASK or VARIABLES_MASK + val ALL_KINDS_MASK: Int = 0x1F + val CLASSIFIERS_MASK: Int = NON_SINGLETON_CLASSIFIERS_MASK or SINGLETON_CLASSIFIERS_MASK + val VALUES_MASK: Int = SINGLETON_CLASSIFIERS_MASK or FUNCTIONS_MASK or VARIABLES_MASK + val CALLABLES_MASK: Int = FUNCTIONS_MASK or VARIABLES_MASK - @JvmField public val ALL: DescriptorKindFilter = DescriptorKindFilter(ALL_KINDS_MASK) - @JvmField public val CALLABLES: DescriptorKindFilter = DescriptorKindFilter(CALLABLES_MASK) - @JvmField public val NON_SINGLETON_CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(NON_SINGLETON_CLASSIFIERS_MASK) - @JvmField public val SINGLETON_CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(SINGLETON_CLASSIFIERS_MASK) - @JvmField public val CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(CLASSIFIERS_MASK) - @JvmField public val PACKAGES: DescriptorKindFilter = DescriptorKindFilter(PACKAGES_MASK) - @JvmField public val FUNCTIONS: DescriptorKindFilter = DescriptorKindFilter(FUNCTIONS_MASK) - @JvmField public val VARIABLES: DescriptorKindFilter = DescriptorKindFilter(VARIABLES_MASK) - @JvmField public val VALUES: DescriptorKindFilter = DescriptorKindFilter(VALUES_MASK) + @JvmField val ALL: DescriptorKindFilter = DescriptorKindFilter(ALL_KINDS_MASK) + @JvmField val CALLABLES: DescriptorKindFilter = DescriptorKindFilter(CALLABLES_MASK) + @JvmField val NON_SINGLETON_CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(NON_SINGLETON_CLASSIFIERS_MASK) + @JvmField val SINGLETON_CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(SINGLETON_CLASSIFIERS_MASK) + @JvmField val CLASSIFIERS: DescriptorKindFilter = DescriptorKindFilter(CLASSIFIERS_MASK) + @JvmField val PACKAGES: DescriptorKindFilter = DescriptorKindFilter(PACKAGES_MASK) + @JvmField val FUNCTIONS: DescriptorKindFilter = DescriptorKindFilter(FUNCTIONS_MASK) + @JvmField val VARIABLES: DescriptorKindFilter = DescriptorKindFilter(VARIABLES_MASK) + @JvmField val VALUES: DescriptorKindFilter = DescriptorKindFilter(VALUES_MASK) private class MaskToName(val mask: Int, val name: String) private val DEBUG_PREDEFINED_FILTERS_MASK_NAMES = staticFields() .map { field -> val filter = field.get(null) as? DescriptorKindFilter - if (filter != null) MaskToName(filter.kindMask, field.getName()) else null + if (filter != null) MaskToName(filter.kindMask, field.name) else null } .filterNotNull() .toReadOnlyList() private val DEBUG_MASK_BIT_NAMES = staticFields() - .filter { it.getType() == Integer.TYPE } + .filter { it.type == Integer.TYPE } .map { field -> val mask = field.get(null) as Int val isOneBitMask = mask == (mask and (-mask)) - if (isOneBitMask) MaskToName(mask, field.getName()) else null + if (isOneBitMask) MaskToName(mask, field.name) else null } .filterNotNull() .toReadOnlyList() - private inline fun staticFields() = T::class.java.getFields().filter { Modifier.isStatic(it.getModifiers()) } + private inline fun staticFields() = T::class.java.fields.filter { Modifier.isStatic(it.modifiers) } } } -public abstract class DescriptorKindExclude { - public abstract fun excludes(descriptor: DeclarationDescriptor): Boolean +abstract class DescriptorKindExclude { + abstract fun excludes(descriptor: DeclarationDescriptor): Boolean - public abstract val fullyExcludedDescriptorKinds: Int + abstract val fullyExcludedDescriptorKinds: Int - override fun toString() = this.javaClass.getSimpleName() + override fun toString() = this.javaClass.simpleName - public object Extensions : DescriptorKindExclude() { + object Extensions : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor) - = descriptor is CallableDescriptor && descriptor.getExtensionReceiverParameter() != null + = descriptor is CallableDescriptor && descriptor.extensionReceiverParameter != null override val fullyExcludedDescriptorKinds: Int get() = 0 } - public object NonExtensions : DescriptorKindExclude() { + object NonExtensions : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor) - = descriptor !is CallableDescriptor || descriptor.getExtensionReceiverParameter() == null + = descriptor !is CallableDescriptor || descriptor.extensionReceiverParameter == null override val fullyExcludedDescriptorKinds: Int get() = DescriptorKindFilter.ALL_KINDS_MASK and (DescriptorKindFilter.FUNCTIONS_MASK or DescriptorKindFilter.VARIABLES_MASK).inv() } - public object EnumEntry : DescriptorKindExclude() { + object EnumEntry : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor) - = descriptor is ClassDescriptor && descriptor.getKind() == ClassKind.ENUM_ENTRY + = descriptor is ClassDescriptor && descriptor.kind == ClassKind.ENUM_ENTRY override val fullyExcludedDescriptorKinds: Int get() = 0 } - public object TopLevelPackages : DescriptorKindExclude() { + object TopLevelPackages : DescriptorKindExclude() { override fun excludes(descriptor: DeclarationDescriptor): Boolean { val fqName = when (descriptor) { is PackageFragmentDescriptor -> descriptor.fqName is PackageViewDescriptor -> descriptor.fqName else -> return false } - return fqName.parent().isRoot() + return fqName.parent().isRoot } override val fullyExcludedDescriptorKinds: Int get() = 0 diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt index d371f4e7d54..8c7fcf3f24d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt @@ -20,19 +20,19 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -public interface ResolutionScope { +interface ResolutionScope { - public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? + fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? - public fun getContributedVariables(name: Name, location: LookupLocation): Collection + fun getContributedVariables(name: Name, location: LookupLocation): Collection - public fun getContributedFunctions(name: Name, location: LookupLocation): Collection + fun getContributedFunctions(name: Name, location: LookupLocation): Collection /** * All visible descriptors from current scope possibly filtered by the given name and kind filters * (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage). */ - public fun getContributedDescriptors( + fun getContributedDescriptors( kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER ): Collection diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt index b0db93d6719..63a81630e57 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt @@ -27,13 +27,13 @@ import org.jetbrains.kotlin.utils.Printer import java.util.* // We don't need to track lookups here since this scope used only for introduce special Enum class members -public class StaticScopeForKotlinClass( +class StaticScopeForKotlinClass( private val containingClass: ClassDescriptor ) : MemberScopeImpl() { override fun getContributedClassifier(name: Name, location: LookupLocation) = null // TODO private val functions: List by lazy { - if (containingClass.getKind() != ClassKind.ENUM_CLASS) { + if (containingClass.kind != ClassKind.ENUM_CLASS) { listOf() } else { @@ -55,7 +55,7 @@ public class StaticScopeForKotlinClass( override fun getContributedVariables(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name } - override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList(2)) { it.getName() == name } + override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList(2)) { it.name == name } override fun printScopeStructure(p: Printer) { p.println("Static scope for $containingClass") diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index f3624eb84cb..289a0e2e9d5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize import org.jetbrains.kotlin.utils.sure import java.util.* -public class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor) : MemberScope { +class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor) : MemberScope { private val substitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor() @@ -76,7 +76,7 @@ public class SubstitutingScope(private val workerScope: MemberScope, givenSubsti nameFilter: (Name) -> Boolean) = _allDescriptors override fun printScopeStructure(p: Printer) { - p.println(javaClass.getSimpleName(), " {") + p.println(javaClass.simpleName, " {") p.pushIndent() p.println("substitutor = ") diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt index fdf31502d4f..22df1669cdc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.descriptors.annotations.Annotations -public abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType { +abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType { private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() } override fun getConstructor(): TypeConstructor = typeConstructor() @@ -42,9 +42,9 @@ public abstract class AbstractLazyType(storageManager: StorageManager) : Abstrac override fun getMemberScope() = memberScope() protected open fun computeMemberScope(): MemberScope { - val descriptor = constructor.getDeclarationDescriptor() + val descriptor = constructor.declarationDescriptor return when (descriptor) { - is TypeParameterDescriptor -> descriptor.getDefaultType().getMemberScope() + is TypeParameterDescriptor -> descriptor.getDefaultType().memberScope is ClassDescriptor -> descriptor.getMemberScope(substitution) else -> throw IllegalStateException("Unsupported classifier: $descriptor") } @@ -52,7 +52,7 @@ public abstract class AbstractLazyType(storageManager: StorageManager) : Abstrac override fun isMarkedNullable() = false - override fun isError() = getConstructor().getDeclarationDescriptor()?.let { d -> ErrorUtils.isError(d) } ?: false + override fun isError() = constructor.declarationDescriptor?.let { d -> ErrorUtils.isError(d) } ?: false override fun getAnnotations() = Annotations.EMPTY @@ -61,7 +61,7 @@ public abstract class AbstractLazyType(storageManager: StorageManager) : Abstrac return "Type constructor is not computed" } if (!arguments.isComputed()) { - return "" + getConstructor() + "" + return "" + constructor + "" } return super.toString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt index e23cbfca240..296127df9c9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.builtIns import java.util.* -public data class ApproximationBounds( - public val lower: T, - public val upper: T +data class ApproximationBounds( + val lower: T, + val upper: T ) private class TypeArgument( @@ -42,10 +42,10 @@ private class TypeArgument( private fun TypeArgument.toTypeProjection(): TypeProjection { assert(isConsistent) { "Only consistent enhanced type propection can be converted to type projection" } - fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.getVariance()) Variance.INVARIANT else variance + fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.variance) Variance.INVARIANT else variance return when { inProjection == outProjection -> TypeProjectionImpl(inProjection) - KotlinBuiltIns.isNothing(inProjection) && typeParameter.getVariance() != Variance.IN_VARIANCE -> + KotlinBuiltIns.isNothing(inProjection) && typeParameter.variance != Variance.IN_VARIANCE -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection) KotlinBuiltIns.isNullableAny(outProjection) -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.IN_VARIANCE), inProjection) else -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection) @@ -59,15 +59,15 @@ private fun TypeProjection.toTypeArgument(typeParameter: TypeParameterDescriptor Variance.OUT_VARIANCE -> TypeArgument(typeParameter, typeParameter.builtIns.nothingType, type) } -public fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?, approximateContravariant: Boolean): TypeProjection? { +fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?, approximateContravariant: Boolean): TypeProjection? { if (typeProjection == null) return null - if (typeProjection.isStarProjection()) return typeProjection + if (typeProjection.isStarProjection) return typeProjection - val type = typeProjection.getType() + val type = typeProjection.type if (!TypeUtils.containsSpecialType(type, { it.isCaptured() })) { return typeProjection } - val howThisTypeIsUsed = typeProjection.getProjectionKind() + val howThisTypeIsUsed = typeProjection.projectionKind if (howThisTypeIsUsed == Variance.OUT_VARIANCE) { // only 'return' type containing captured types should be over-approximated val approximation = approximateCapturedTypes(type) @@ -92,7 +92,7 @@ private fun substituteCapturedTypesWithProjections(typeProjection: TypeProjectio return typeSubstitutor.substituteWithoutApproximation(typeProjection) } -public fun approximateCapturedTypes(type: KotlinType): ApproximationBounds { +fun approximateCapturedTypes(type: KotlinType): ApproximationBounds { if (type.isFlexible()) { val boundsForFlexibleLower = approximateCapturedTypes(type.lowerIfFlexible()) val boundsForFlexibleUpper = approximateCapturedTypes(type.upperIfFlexible()) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt index 2e6b33ab691..3bfcdd5499f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt @@ -18,13 +18,12 @@ package org.jetbrains.kotlin.types; import org.jetbrains.kotlin.descriptors.annotations.Annotations -public class DisjointKeysUnionTypeSubstitution private constructor( +class DisjointKeysUnionTypeSubstitution private constructor( private val first: TypeSubstitution, private val second: TypeSubstitution ) : TypeSubstitution() { companion object { - @JvmStatic - public fun create(first: TypeSubstitution, second: TypeSubstitution): TypeSubstitution { + @JvmStatic fun create(first: TypeSubstitution, second: TypeSubstitution): TypeSubstitution { if (first.isEmpty()) return second if (second.isEmpty()) return first diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt index fa1b9cf72a8..b507325d929 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.scopes.MemberScope -public open class KotlinTypeImpl +open class KotlinTypeImpl private constructor( private val annotations: Annotations, private val constructor: TypeConstructor, @@ -31,23 +31,21 @@ private constructor( ) : AbstractKotlinType() { companion object { - @JvmStatic - public fun create(annotations: Annotations, - constructor: TypeConstructor, - nullable: Boolean, - arguments: List, - memberScope: MemberScope): KotlinTypeImpl + @JvmStatic fun create(annotations: Annotations, + constructor: TypeConstructor, + nullable: Boolean, + arguments: List, + memberScope: MemberScope): KotlinTypeImpl = KotlinTypeImpl(annotations, constructor, nullable, arguments, null, memberScope) - @JvmStatic - public fun create(annotations: Annotations, - constructor: TypeConstructor, - nullable: Boolean, - arguments: List, - substitution: TypeSubstitution, - memberScope: MemberScope, - capabilities: TypeCapabilities + @JvmStatic fun create(annotations: Annotations, + constructor: TypeConstructor, + nullable: Boolean, + arguments: List, + substitution: TypeSubstitution, + memberScope: MemberScope, + capabilities: TypeCapabilities ): KotlinTypeImpl { if (capabilities !== TypeCapabilities.NONE) { return WithCapabilities(annotations, constructor, nullable, arguments, substitution, memberScope, capabilities) @@ -55,11 +53,10 @@ private constructor( return KotlinTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) } - @JvmStatic - public fun create(annotations: Annotations, - descriptor: ClassDescriptor, - nullable: Boolean, - arguments: List): KotlinTypeImpl + @JvmStatic fun create(annotations: Annotations, + descriptor: ClassDescriptor, + nullable: Boolean, + arguments: List): KotlinTypeImpl = KotlinTypeImpl( annotations, descriptor.typeConstructor, nullable, arguments, null, descriptor.getMemberScope(arguments) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt index 309ca708f33..f4632371222 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt @@ -34,18 +34,18 @@ class StarProjectionImpl( override fun getType() = _type } -public fun TypeParameterDescriptor.starProjectionType(): KotlinType { - val classDescriptor = this.getContainingDeclaration() as ClassDescriptor - val typeParameters = classDescriptor.getTypeConstructor().getParameters().map { it.getTypeConstructor() } +fun TypeParameterDescriptor.starProjectionType(): KotlinType { + val classDescriptor = this.containingDeclaration as ClassDescriptor + val typeParameters = classDescriptor.typeConstructor.parameters.map { it.typeConstructor } return TypeSubstitutor.create( object : TypeConstructorSubstitution() { override fun get(key: TypeConstructor) = if (key in typeParameters) - TypeUtils.makeStarProjection(key.getDeclarationDescriptor() as TypeParameterDescriptor) + TypeUtils.makeStarProjection(key.declarationDescriptor as TypeParameterDescriptor) else null } - ).substitute(this.getUpperBounds().first(), Variance.OUT_VARIANCE)!! + ).substitute(this.upperBounds.first(), Variance.OUT_VARIANCE)!! } class TypeBasedStarProjectionImpl( diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt index 9a4d7b9df2c..9f0192847cb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt @@ -19,9 +19,9 @@ package org.jetbrains.kotlin.types import org.jetbrains.kotlin.descriptors.PossiblyInnerType import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -public interface TypeCapability +interface TypeCapability -public interface TypeCapabilities { +interface TypeCapabilities { object NONE : TypeCapabilities { override fun getCapability(capabilityClass: Class): T? = null } @@ -41,17 +41,17 @@ class SingletonTypeCapabilities(private val clazz: Class<*>, private val typeCap } } -public inline fun KotlinType.getCapability(): T? = getCapability(T::class.java) +inline fun KotlinType.getCapability(): T? = getCapability(T::class.java) -public interface Specificity : TypeCapability { +interface Specificity : TypeCapability { - public enum class Relation { + enum class Relation { LESS_SPECIFIC, MORE_SPECIFIC, DONT_KNOW } - public fun getSpecificityRelationTo(otherType: KotlinType): Relation + fun getSpecificityRelationTo(otherType: KotlinType): Relation } fun KotlinType.getSpecificityRelationTo(otherType: KotlinType) = @@ -63,46 +63,46 @@ fun oneMoreSpecificThanAnother(a: KotlinType, b: KotlinType) = // To facilitate laziness, any KotlinType implementation may inherit from this trait, // even if it turns out that the type an instance represents is not actually a type variable // (i.e. it is not derived from a type parameter), see isTypeVariable -public interface CustomTypeVariable : TypeCapability { - public val isTypeVariable: Boolean +interface CustomTypeVariable : TypeCapability { + val isTypeVariable: Boolean // If typeParameterDescriptor != null <=> isTypeVariable == true, this is not a type variable - public val typeParameterDescriptor: TypeParameterDescriptor? + val typeParameterDescriptor: TypeParameterDescriptor? // Throws an exception when isTypeVariable == false - public fun substitutionResult(replacement: KotlinType): KotlinType + fun substitutionResult(replacement: KotlinType): KotlinType } -public fun KotlinType.isCustomTypeVariable(): Boolean = this.getCapability(CustomTypeVariable::class.java)?.isTypeVariable ?: false -public fun KotlinType.getCustomTypeVariable(): CustomTypeVariable? = +fun KotlinType.isCustomTypeVariable(): Boolean = this.getCapability(CustomTypeVariable::class.java)?.isTypeVariable ?: false +fun KotlinType.getCustomTypeVariable(): CustomTypeVariable? = this.getCapability(CustomTypeVariable::class.java)?.let { if (it.isTypeVariable) it else null } -public interface SubtypingRepresentatives : TypeCapability { - public val subTypeRepresentative: KotlinType - public val superTypeRepresentative: KotlinType +interface SubtypingRepresentatives : TypeCapability { + val subTypeRepresentative: KotlinType + val superTypeRepresentative: KotlinType - public fun sameTypeConstructor(type: KotlinType): Boolean + fun sameTypeConstructor(type: KotlinType): Boolean } -public fun KotlinType.getSubtypeRepresentative(): KotlinType = +fun KotlinType.getSubtypeRepresentative(): KotlinType = this.getCapability(SubtypingRepresentatives::class.java)?.subTypeRepresentative ?: this -public fun KotlinType.getSupertypeRepresentative(): KotlinType = +fun KotlinType.getSupertypeRepresentative(): KotlinType = this.getCapability(SubtypingRepresentatives::class.java)?.superTypeRepresentative ?: this -public fun sameTypeConstructors(first: KotlinType, second: KotlinType): Boolean { +fun sameTypeConstructors(first: KotlinType, second: KotlinType): Boolean { val typeRangeCapability = SubtypingRepresentatives::class.java return first.getCapability(typeRangeCapability)?.sameTypeConstructor(second) ?: false || second.getCapability(typeRangeCapability)?.sameTypeConstructor(first) ?: false } interface CustomSubstitutionCapability : TypeCapability { - public val substitution: TypeSubstitution? - public val substitutionToComposeWith: TypeSubstitution? + val substitution: TypeSubstitution? + val substitutionToComposeWith: TypeSubstitution? } interface PossiblyInnerTypeCapability : TypeCapability { - public val possiblyInnerType: PossiblyInnerType? + val possiblyInnerType: PossiblyInnerType? } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index 057bfc970cc..88f2ddddd5e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -20,10 +20,9 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations -public abstract class TypeSubstitution { +abstract class TypeSubstitution { companion object { - @JvmField - public val EMPTY: TypeSubstitution = object : TypeSubstitution() { + @JvmField val EMPTY: TypeSubstitution = object : TypeSubstitution() { override fun get(key: KotlinType) = null override fun isEmpty() = true override fun toString() = "Empty TypeSubstitution" @@ -42,31 +41,27 @@ public abstract class TypeSubstitution { fun buildSubstitutor(): TypeSubstitutor = TypeSubstitutor.create(this) } -public abstract class TypeConstructorSubstitution : TypeSubstitution() { +abstract class TypeConstructorSubstitution : TypeSubstitution() { override fun get(key: KotlinType) = get(key.constructor) - public abstract fun get(key: TypeConstructor): TypeProjection? + abstract fun get(key: TypeConstructor): TypeProjection? companion object { - @JvmStatic - public fun createByConstructorsMap(map: Map): TypeConstructorSubstitution = + @JvmStatic fun createByConstructorsMap(map: Map): TypeConstructorSubstitution = object : TypeConstructorSubstitution() { override fun get(key: TypeConstructor) = map[key] override fun isEmpty() = map.isEmpty() } - @JvmStatic - public fun createByParametersMap(map: Map): TypeConstructorSubstitution = + @JvmStatic fun createByParametersMap(map: Map): TypeConstructorSubstitution = object : TypeConstructorSubstitution() { override fun get(key: TypeConstructor) = map[key.declarationDescriptor] override fun isEmpty() = map.isEmpty() } - @JvmStatic - public fun create(kotlinType: KotlinType) = create(kotlinType.constructor, kotlinType.arguments) + @JvmStatic fun create(kotlinType: KotlinType) = create(kotlinType.constructor, kotlinType.arguments) - @JvmStatic - public fun create(typeConstructor: TypeConstructor, arguments: List): TypeSubstitution { + @JvmStatic fun create(typeConstructor: TypeConstructor, arguments: List): TypeSubstitution { val parameters = typeConstructor.parameters if (parameters.lastOrNull()?.isCapturedFromOuterDeclaration ?: false) { @@ -78,7 +73,7 @@ public abstract class TypeConstructorSubstitution : TypeSubstitution() { } } -public class IndexedParametersSubstitution( +class IndexedParametersSubstitution( val parameters: Array, val arguments: Array, private val approximateCapturedTypes: Boolean = false @@ -109,7 +104,7 @@ public class IndexedParametersSubstitution( } } -public fun KotlinType.computeNewSubstitution( +fun KotlinType.computeNewSubstitution( typeConstructor: TypeConstructor, newArguments: List ): TypeSubstitution { @@ -122,7 +117,7 @@ public fun KotlinType.computeNewSubstitution( return composedSubstitution } -public fun KotlinType.replace( +fun KotlinType.replace( newArguments: List, annotations: Annotations = this@replace.annotations ): KotlinType { @@ -177,7 +172,7 @@ private class CompositeTypeSubstitution( override fun filterAnnotations(annotations: Annotations): Annotations = second.filterAnnotations(first.filterAnnotations(annotations)) } -public open class DelegatedTypeSubstitution(val substitution: TypeSubstitution): TypeSubstitution() { +open class DelegatedTypeSubstitution(val substitution: TypeSubstitution): TypeSubstitution() { override fun get(key: KotlinType) = substitution.get(key) override fun isEmpty() = substitution.isEmpty() diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 8b1703c8c22..35a3740651c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -24,13 +24,13 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import java.util.* -public enum class TypeNullability { +enum class TypeNullability { NOT_NULL, NULLABLE, FLEXIBLE } -public fun KotlinType.nullability(): TypeNullability { +fun KotlinType.nullability(): TypeNullability { return when { isNullabilityFlexible() -> TypeNullability.FLEXIBLE TypeUtils.isNullableType(this) -> TypeNullability.NULLABLE @@ -62,14 +62,14 @@ fun KotlinType?.isArrayOfNothing(): Boolean { } -public fun KotlinType.isSubtypeOf(superType: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(this, superType) +fun KotlinType.isSubtypeOf(superType: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(this, superType) -public fun KotlinType.cannotBeReified(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this) || this.isDynamic() +fun KotlinType.cannotBeReified(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this) || this.isDynamic() fun TypeProjection.substitute(doSubstitute: (KotlinType) -> KotlinType): TypeProjection { - return if (isStarProjection()) + return if (isStarProjection) this - else TypeProjectionImpl(getProjectionKind(), doSubstitute(getType())) + else TypeProjectionImpl(projectionKind, doSubstitute(type)) } fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType { @@ -81,7 +81,7 @@ fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType { } } -public fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: KotlinType?): Boolean { +fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: KotlinType?): Boolean { if (type1 === type2) return true if (type1 == null || type2 == null) return false return equalTypes(type1, type2) @@ -89,11 +89,11 @@ public fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: Kotlin fun KotlinType.containsError() = ErrorUtils.containsErrorType(this) -public fun List.defaultProjections(): List = map { TypeProjectionImpl(it) } +fun List.defaultProjections(): List = map { TypeProjectionImpl(it) } -public fun KotlinType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative()) +fun KotlinType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative()) -public fun createProjection(type: KotlinType, projectionKind: Variance, typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection = +fun createProjection(type: KotlinType, projectionKind: Variance, typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection = TypeProjectionImpl(if (typeParameterDescriptor?.variance == projectionKind) Variance.INVARIANT else projectionKind, type) fun Collection.closure(f: (KotlinType) -> Collection): Collection { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/Variance.kt b/core/descriptors/src/org/jetbrains/kotlin/types/Variance.kt index d5ec8f23cb2..039fddf0eb1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/Variance.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/Variance.kt @@ -16,24 +16,24 @@ package org.jetbrains.kotlin.types -public enum class Variance( - public val label: String, - public val allowsInPosition: Boolean, - public val allowsOutPosition: Boolean, +enum class Variance( + val label: String, + val allowsInPosition: Boolean, + val allowsOutPosition: Boolean, private val superpositionFactor: Int ) { INVARIANT("", true, true, 0), IN_VARIANCE("in", true, false, -1), OUT_VARIANCE("out", false, true, +1); - public fun allowsPosition(position: Variance): Boolean + fun allowsPosition(position: Variance): Boolean = when (position) { IN_VARIANCE -> allowsInPosition OUT_VARIANCE -> allowsOutPosition INVARIANT -> allowsInPosition && allowsOutPosition } - public fun superpose(other: Variance): Variance { + fun superpose(other: Variance): Variance { val r = this.superpositionFactor * other.superpositionFactor return when (r) { 0 -> INVARIANT @@ -43,7 +43,7 @@ public enum class Variance( } } - public fun opposite(): Variance { + fun opposite(): Variance { return when (this) { INVARIANT -> INVARIANT IN_VARIANCE -> OUT_VARIANCE diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt index b919cedc511..7b48fdb4cdb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt @@ -26,19 +26,19 @@ import java.util.* private class SubtypePathNode(val type: KotlinType, val previous: SubtypePathNode?) -public fun findCorrespondingSupertype( +fun findCorrespondingSupertype( subtype: KotlinType, supertype: KotlinType, typeCheckingProcedureCallbacks: TypeCheckingProcedureCallbacks ): KotlinType? { val queue = ArrayDeque() queue.add(SubtypePathNode(subtype, null)) - val supertypeConstructor = supertype.getConstructor() + val supertypeConstructor = supertype.constructor while (!queue.isEmpty()) { val lastPathNode = queue.poll() val currentSubtype = lastPathNode.type - val constructor = currentSubtype.getConstructor() + val constructor = currentSubtype.constructor if (typeCheckingProcedureCallbacks.assertEqualTypeConstructors(constructor, supertypeConstructor)) { var substituted = currentSubtype @@ -68,7 +68,7 @@ public fun findCorrespondingSupertype( return TypeUtils.makeNullableAsSpecified(substituted, isAnyMarkedNullable) } - for (immediateSupertype in constructor.getSupertypes()) { + for (immediateSupertype in constructor.supertypes) { queue.add(SubtypePathNode(immediateSupertype, lastPathNode)) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt index 88d77dd6872..0f40b313877 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt @@ -39,7 +39,7 @@ fun createDynamicType(builtIns: KotlinBuiltIns) = object : DelegatingFlexibleTyp DynamicTypeCapabilities ) {} -public object DynamicTypeCapabilities : FlexibleTypeCapabilities { +object DynamicTypeCapabilities : FlexibleTypeCapabilities { override val id: String get() = "kotlin.DynamicType" override fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/error/MissingDependencyErrorClass.kt b/core/descriptors/src/org/jetbrains/kotlin/types/error/MissingDependencyErrorClass.kt index 221d0c19c27..7a7470178b9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/error/MissingDependencyErrorClass.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/error/MissingDependencyErrorClass.kt @@ -19,6 +19,6 @@ package org.jetbrains.kotlin.types.error import org.jetbrains.kotlin.name.FqName // marker for DescriptorRenderer to treat specially in decompiler mode -public interface MissingDependencyErrorClass { - public val fullFqName: FqName +interface MissingDependencyErrorClass { + val fullFqName: FqName } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt index 9971ae26bc2..35ea21a598a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public interface FlexibleTypeCapabilities { +interface FlexibleTypeCapabilities { fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? val id: String @@ -31,20 +31,20 @@ public interface FlexibleTypeCapabilities { } } -public interface Flexibility : TypeCapability, SubtypingRepresentatives { +interface Flexibility : TypeCapability, SubtypingRepresentatives { companion object { // This is a "magic" classifier: when type resolver sees it in the code, e.g. ft, instead of creating a normal type, // it creates a flexible type, e.g. (Foo..Foo?). // This is used in tests and Evaluate Expression to have flexible types in the code, // but normal users should not be referencing this classifier - public val FLEXIBLE_TYPE_CLASSIFIER: ClassId = ClassId.topLevel(FqName("kotlin.internal.flexible.ft")) + val FLEXIBLE_TYPE_CLASSIFIER: ClassId = ClassId.topLevel(FqName("kotlin.internal.flexible.ft")) } // lowerBound is a subtype of upperBound - public val lowerBound: KotlinType - public val upperBound: KotlinType + val lowerBound: KotlinType + val upperBound: KotlinType - public val extraCapabilities: FlexibleTypeCapabilities + val extraCapabilities: FlexibleTypeCapabilities override val subTypeRepresentative: KotlinType get() = lowerBound @@ -55,10 +55,10 @@ public interface Flexibility : TypeCapability, SubtypingRepresentatives { override fun sameTypeConstructor(type: KotlinType) = false } -public fun KotlinType.isFlexible(): Boolean = this.getCapability(Flexibility::class.java) != null -public fun KotlinType.flexibility(): Flexibility = this.getCapability(Flexibility::class.java)!! +fun KotlinType.isFlexible(): Boolean = this.getCapability(Flexibility::class.java) != null +fun KotlinType.flexibility(): Flexibility = this.getCapability(Flexibility::class.java)!! -public fun KotlinType.isNullabilityFlexible(): Boolean { +fun KotlinType.isNullabilityFlexible(): Boolean { val flexibility = this.getCapability(Flexibility::class.java) ?: return false return TypeUtils.isNullableType(flexibility.lowerBound) != TypeUtils.isNullableType(flexibility.upperBound) } @@ -88,28 +88,28 @@ fun Collection.singleBestRepresentative(): KotlinType? { fun Collection.singleBestRepresentative(): TypeProjection? { if (this.size == 1) return this.first() - val projectionKinds = this.map { it.getProjectionKind() }.toSet() + val projectionKinds = this.map { it.projectionKind }.toSet() if (projectionKinds.size != 1) return null - val bestType = this.map { it.getType() }.singleBestRepresentative() + val bestType = this.map { it.type }.singleBestRepresentative() if (bestType == null) return null return TypeProjectionImpl(projectionKinds.single(), bestType) } -public fun KotlinType.lowerIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().lowerBound else this -public fun KotlinType.upperIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().upperBound else this +fun KotlinType.lowerIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().lowerBound else this +fun KotlinType.upperIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().upperBound else this -public interface NullAwareness : TypeCapability { - public fun makeNullableAsSpecified(nullable: Boolean): KotlinType - public fun computeIsNullable(): Boolean +interface NullAwareness : TypeCapability { + fun makeNullableAsSpecified(nullable: Boolean): KotlinType + fun computeIsNullable(): Boolean } interface FlexibleTypeDelegation : TypeCapability { - public val delegateType: KotlinType + val delegateType: KotlinType } -public open class DelegatingFlexibleType protected constructor( +open class DelegatingFlexibleType protected constructor( override val lowerBound: KotlinType, override val upperBound: KotlinType, override val extraCapabilities: FlexibleTypeCapabilities @@ -166,7 +166,7 @@ public open class DelegatingFlexibleType protected constructor( extraCapabilities) } - override fun computeIsNullable() = delegateType.isMarkedNullable() + override fun computeIsNullable() = delegateType.isMarkedNullable override fun isMarkedNullable(): Boolean = getCapability(NullAwareness::class.java)!!.computeIsNullable() diff --git a/core/descriptors/src/org/jetbrains/kotlin/util/scopeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/util/scopeUtils.kt index c03c6624380..606ef2156f6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/util/scopeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/util/scopeUtils.kt @@ -22,7 +22,7 @@ import java.util.* * Concatenates the contents of this collection with the given collection, avoiding allocations if possible. * Can modify `this` if it is a mutable collection. */ -public fun Collection?.concat(collection: Collection): Collection? { +fun Collection?.concat(collection: Collection): Collection? { if (collection.isEmpty()) { return this } @@ -39,7 +39,7 @@ public fun Collection?.concat(collection: Collection): Collection? return result } -public fun concatInOrder(c1: Collection?, c2: Collection?): Collection { +fun concatInOrder(c1: Collection?, c2: Collection?): Collection { val result = if (c1 == null || c1.isEmpty()) c2 else if (c2 == null || c2.isEmpty()) @@ -53,7 +53,7 @@ public fun concatInOrder(c1: Collection?, c2: Collection?): Collection return result ?: emptySet() } -public inline fun getFromAllScopes(scopes: List, callback: (Scope) -> Collection): Collection { +inline fun getFromAllScopes(scopes: List, callback: (Scope) -> Collection): Collection { if (scopes.isEmpty()) return emptySet() var result: Collection? = null for (scope in scopes) { @@ -62,7 +62,7 @@ public inline fun getFromAllScopes(scopes: List, callback: (Sc return result ?: emptySet() } -public inline fun getFirstMatch(scopes: List, callback: (Scope) -> T?): T? { +inline fun getFirstMatch(scopes: List, callback: (Scope) -> T?): T? { // NOTE: This is performance-sensitive; please don't replace with map().firstOrNull() for (scope in scopes) { val result = callback(scope) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 79b5baede32..3a9055de48e 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -36,13 +36,13 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf -public class AnnotationDeserializer(private val module: ModuleDescriptor) { +class AnnotationDeserializer(private val module: ModuleDescriptor) { private val builtIns: KotlinBuiltIns get() = module.builtIns private val factory = ConstantValueFactory(builtIns) - public fun deserializeAnnotation(proto: Annotation, nameResolver: NameResolver): AnnotationDescriptor { + fun deserializeAnnotation(proto: Annotation, nameResolver: NameResolver): AnnotationDescriptor { val annotationClass = resolveClass(nameResolver.getClassId(proto.id)) var arguments = emptyMap>() @@ -62,40 +62,40 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { parameterByName: Map, nameResolver: NameResolver ): Pair>? { - val parameter = parameterByName[nameResolver.getName(proto.getNameId())] ?: return null - return Pair(parameter, resolveValue(parameter.getType(), proto.getValue(), nameResolver)) + val parameter = parameterByName[nameResolver.getName(proto.nameId)] ?: return null + return Pair(parameter, resolveValue(parameter.type, proto.value, nameResolver)) } - public fun resolveValue( + fun resolveValue( expectedType: KotlinType, value: Value, nameResolver: NameResolver ): ConstantValue<*> { - val result: ConstantValue<*> = when (value.getType()) { - Type.BYTE -> factory.createByteValue(value.getIntValue().toByte()) - Type.CHAR -> factory.createCharValue(value.getIntValue().toChar()) - Type.SHORT -> factory.createShortValue(value.getIntValue().toShort()) - Type.INT -> factory.createIntValue(value.getIntValue().toInt()) - Type.LONG -> factory.createLongValue(value.getIntValue()) - Type.FLOAT -> factory.createFloatValue(value.getFloatValue()) - Type.DOUBLE -> factory.createDoubleValue(value.getDoubleValue()) - Type.BOOLEAN -> factory.createBooleanValue(value.getIntValue() != 0L) + val result: ConstantValue<*> = when (value.type) { + Type.BYTE -> factory.createByteValue(value.intValue.toByte()) + Type.CHAR -> factory.createCharValue(value.intValue.toChar()) + Type.SHORT -> factory.createShortValue(value.intValue.toShort()) + Type.INT -> factory.createIntValue(value.intValue.toInt()) + Type.LONG -> factory.createLongValue(value.intValue) + Type.FLOAT -> factory.createFloatValue(value.floatValue) + Type.DOUBLE -> factory.createDoubleValue(value.doubleValue) + Type.BOOLEAN -> factory.createBooleanValue(value.intValue != 0L) Type.STRING -> { - factory.createStringValue(nameResolver.getString(value.getStringValue())) + factory.createStringValue(nameResolver.getString(value.stringValue)) } Type.CLASS -> { // TODO: support class literals - error("Class literal annotation arguments are not supported yet (${nameResolver.getClassId(value.getClassId())})") + error("Class literal annotation arguments are not supported yet (${nameResolver.getClassId(value.classId)})") } Type.ENUM -> { - resolveEnumValue(nameResolver.getClassId(value.getClassId()), nameResolver.getName(value.getEnumValueId())) + resolveEnumValue(nameResolver.getClassId(value.classId), nameResolver.getName(value.enumValueId)) } Type.ANNOTATION -> { - AnnotationValue(deserializeAnnotation(value.getAnnotation(), nameResolver)) + AnnotationValue(deserializeAnnotation(value.annotation, nameResolver)) } Type.ARRAY -> { val expectedIsArray = KotlinBuiltIns.isArray(expectedType) || KotlinBuiltIns.isPrimitiveArray(expectedType) - val arrayElements = value.getArrayElementList() + val arrayElements = value.arrayElementList val actualArrayType = if (arrayElements.isNotEmpty()) { @@ -119,7 +119,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { actualArrayType ) } - else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)") + else -> error("Unsupported annotation argument type: ${value.type} (expected $expectedType)") } if (result.type.isSubtypeOf(expectedType)) { @@ -134,8 +134,8 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { // NOTE: see analogous code in BinaryClassAnnotationAndConstantLoaderImpl private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) - if (enumClass.getKind() == ClassKind.ENUM_CLASS) { - val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION) + if (enumClass.kind == ClassKind.ENUM_CLASS) { + val enumEntry = enumClass.unsubstitutedInnerClassesScope.getContributedClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION) if (enumEntry is ClassDescriptor) { return factory.createEnumValue(enumEntry) } @@ -145,7 +145,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { private fun resolveArrayElementType(value: Value, nameResolver: NameResolver): KotlinType = with(builtIns) { - when (value.getType()) { + when (value.type) { Type.BYTE -> getByteType() Type.CHAR -> getCharType() Type.SHORT -> getShortType() @@ -156,10 +156,10 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { Type.BOOLEAN -> getBooleanType() Type.STRING -> getStringType() Type.CLASS -> error("Arrays of class literals are not supported yet") // TODO: support arrays of class literals - Type.ENUM -> resolveClass(nameResolver.getClassId(value.getClassId())).getDefaultType() - Type.ANNOTATION -> resolveClass(nameResolver.getClassId(value.getAnnotation().getId())).getDefaultType() + Type.ENUM -> resolveClass(nameResolver.getClassId(value.classId)).defaultType + Type.ANNOTATION -> resolveClass(nameResolver.getClassId(value.annotation.id)).defaultType Type.ARRAY -> error("Array of arrays is impossible") - else -> error("Unknown type: ${value.getType()}") + else -> error("Unknown type: ${value.type}") } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDescriptorFactory.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDescriptorFactory.kt index 594fa389c45..bda2c5b05fe 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDescriptorFactory.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDescriptorFactory.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.name.ClassId -public interface ClassDescriptorFactory { - public fun createClass(classId: ClassId): ClassDescriptor? +interface ClassDescriptorFactory { + fun createClass(classId: ClassId): ClassDescriptor? - public object EMPTY : ClassDescriptorFactory { + object EMPTY : ClassDescriptorFactory { override fun createClass(classId: ClassId): ClassDescriptor? = null } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt index 606733c7cff..45d2d2391cd 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt @@ -21,13 +21,13 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.serialization.ClassDataWithSource import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor -public class ClassDeserializer(private val components: DeserializationComponents) { +class ClassDeserializer(private val components: DeserializationComponents) { private val classes: (ClassKey) -> ClassDescriptor? = components.storageManager.createMemoizedFunctionWithNullableValues { key -> createClass(key) } // Additional ClassDataWithSource parameter is needed to avoid calling ClassDataFinder#findClassData() // if it is already computed at the call site - public fun deserializeClass(classId: ClassId, classDataWithSource: ClassDataWithSource? = null): ClassDescriptor? = + fun deserializeClass(classId: ClassId, classDataWithSource: ClassDataWithSource? = null): ClassDescriptor? = classes(ClassKey(classId, classDataWithSource)) private fun createClass(key: ClassKey): ClassDescriptor? { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt index 9e7f04d409d..6ae484b5e94 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.storage.getValue import java.io.InputStream import javax.inject.Inject -public abstract class DeserializedPackageFragment( +abstract class DeserializedPackageFragment( fqName: FqName, protected val storageManager: StorageManager, module: ModuleDescriptor, diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolver.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolver.kt index a30c48b0f85..c35b5f5e0cd 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolver.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolver.kt @@ -19,6 +19,6 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.name.ClassId -public interface LocalClassResolver { - public fun resolveLocalClass(classId: ClassId): ClassDescriptor? +interface LocalClassResolver { + fun resolveLocalClass(classId: ClassId): ClassDescriptor? } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt index 196c74751c9..ec0f7ba9337 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt @@ -21,12 +21,11 @@ import org.jetbrains.kotlin.name.ClassId import javax.inject.Inject import kotlin.properties.Delegates -public class LocalClassResolverImpl : LocalClassResolver { - public var components: DeserializationComponents by Delegates.notNull() +class LocalClassResolverImpl : LocalClassResolver { + var components: DeserializationComponents by Delegates.notNull() // component dependency cycle - @Inject - public fun setDeserializationComponents(components: DeserializationComponents) { + @Inject fun setDeserializationComponents(components: DeserializationComponents) { this.components = components } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index a94e2f7ccb2..d0255c76103 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -30,9 +30,9 @@ import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.descriptors.* import org.jetbrains.kotlin.utils.toReadOnlyList -public class MemberDeserializer(private val c: DeserializationContext) { - public fun loadProperty(proto: ProtoBuf.Property): PropertyDescriptor { - val flags = proto.getFlags() +class MemberDeserializer(private val c: DeserializationContext) { + fun loadProperty(proto: ProtoBuf.Property): PropertyDescriptor { + val flags = proto.flags val property = DeserializedPropertyDescriptor( c.containingDeclaration, null, @@ -50,7 +50,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { c.packagePartSource ) - val local = c.childContext(property, proto.getTypeParameterList()) + val local = c.childContext(property, proto.typeParameterList) val hasGetter = Flags.HAS_GETTER.get(flags) val receiverAnnotations = if (hasGetter && proto.hasReceiver()) @@ -66,7 +66,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { ) val getter = if (hasGetter) { - val getterFlags = proto.getGetterFlags() + val getterFlags = proto.getterFlags val isNotDefault = proto.hasGetterFlags() && Flags.IS_NOT_DEFAULT.get(getterFlags) val isExternal = proto.hasGetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(getterFlags) val getter = if (isNotDefault) { @@ -92,7 +92,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { } val setter = if (Flags.HAS_SETTER.get(flags)) { - val setterFlags = proto.getSetterFlags() + val setterFlags = proto.setterFlags val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags) val isExternal = proto.hasSetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(setterFlags) if (isNotDefault) { @@ -135,7 +135,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { return property } - public fun loadFunction(proto: ProtoBuf.Function): FunctionDescriptor { + fun loadFunction(proto: ProtoBuf.Function): FunctionDescriptor { val annotations = getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION) val receiverAnnotations = if (proto.hasReceiver()) getReceiverParameterAnnotations(proto, AnnotatedCallableKind.FUNCTION) @@ -163,10 +163,10 @@ public class MemberDeserializer(private val c: DeserializationContext) { } private fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? { - return (c.containingDeclaration as? ClassDescriptor)?.getThisAsReceiverParameter() + return (c.containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter } - public fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ConstructorDescriptor { + fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ConstructorDescriptor { val classDescriptor = c.containingDeclaration as ClassDescriptor val descriptor = DeserializedConstructorDescriptor( classDescriptor, null, getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION), diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeCapabilitiesLoader.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeCapabilitiesLoader.kt index 79568bafa51..fbb98d76123 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeCapabilitiesLoader.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeCapabilitiesLoader.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.types.TypeCapabilities -public abstract class TypeCapabilitiesLoader { - public object NONE : TypeCapabilitiesLoader() { +abstract class TypeCapabilitiesLoader { + object NONE : TypeCapabilitiesLoader() { override fun loadCapabilities(type: ProtoBuf.Type): TypeCapabilities = TypeCapabilities.NONE } - public abstract fun loadCapabilities(type: ProtoBuf.Type): TypeCapabilities + abstract fun loadCapabilities(type: ProtoBuf.Type): TypeCapabilities } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt index a21eb5e70f8..c2b54cae945 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* -public class TypeDeserializer( +class TypeDeserializer( private val c: DeserializationContext, private val parent: TypeDeserializer?, private val typeParameterProtos: List, diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index cb8ddbd9dc4..ed61a70737b 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -40,26 +40,26 @@ import org.jetbrains.kotlin.utils.singletonOrEmptyList import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* -public class DeserializedClassDescriptor( +class DeserializedClassDescriptor( outerContext: DeserializationContext, val classProto: ProtoBuf.Class, nameResolver: NameResolver, private val sourceElement: SourceElement ) : ClassDescriptor, AbstractClassDescriptor( outerContext.storageManager, - nameResolver.getClassId(classProto.getFqName()).getShortClassName() + nameResolver.getClassId(classProto.fqName).shortClassName ) { - private val modality = Deserialization.modality(Flags.MODALITY.get(classProto.getFlags())) - private val visibility = Deserialization.visibility(Flags.VISIBILITY.get(classProto.getFlags())) - private val kindFromProto = Flags.CLASS_KIND.get(classProto.getFlags()) + private val modality = Deserialization.modality(Flags.MODALITY.get(classProto.flags)) + private val visibility = Deserialization.visibility(Flags.VISIBILITY.get(classProto.flags)) + private val kindFromProto = Flags.CLASS_KIND.get(classProto.flags) private val kind = Deserialization.classKind(kindFromProto) private val isCompanion = kindFromProto == ProtoBuf.Class.Kind.COMPANION_OBJECT - private val isInner = Flags.IS_INNER.get(classProto.getFlags()) + private val isInner = Flags.IS_INNER.get(classProto.flags) private val isData = Flags.IS_DATA.get(classProto.flags) val c = outerContext.childContext(this, classProto.typeParameterList, nameResolver, TypeTable(classProto.typeTable)) - private val classId = nameResolver.getClassId(classProto.getFqName()) + private val classId = nameResolver.getClassId(classProto.fqName) private val staticScope = StaticScopeForKotlinClass(this) private val typeConstructor = DeserializedClassTypeConstructor() @@ -73,7 +73,7 @@ public class DeserializedClassDescriptor( private val companionObjectDescriptor = c.storageManager.createNullableLazyValue { computeCompanionObjectDescriptor() } private val annotations = - if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) { + if (!Flags.HAS_ANNOTATIONS.get(classProto.flags)) { Annotations.EMPTY } else DeserializedAnnotations(c.storageManager) { @@ -129,7 +129,7 @@ public class DeserializedClassDescriptor( private fun computeCompanionObjectDescriptor(): ClassDescriptor? { if (!classProto.hasCompanionObjectName()) return null - val companionObjectName = c.nameResolver.getName(classProto.getCompanionObjectName()) + val companionObjectName = c.nameResolver.getName(classProto.companionObjectName) return memberScope.getContributedClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor } @@ -273,7 +273,7 @@ public class DeserializedClassDescriptor( private fun nestedClassNames(): Set { val result = LinkedHashSet() val nameResolver = c.nameResolver - for (index in classProto.getNestedClassNameList()) { + for (index in classProto.nestedClassNameList) { result.add(nameResolver.getName(index!!)) } return result diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index a61002df3fc..ecb3aa74861 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* -public abstract class DeserializedMemberScope protected constructor( +abstract class DeserializedMemberScope protected constructor( protected val c: DeserializationContext, functionList: Collection, propertyList: Collection diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt index 766d3cac7e7..2b0cb794965 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.serialization.deserialization.TypeTable import org.jetbrains.kotlin.storage.getValue import org.jetbrains.kotlin.utils.addIfNotNull -public open class DeserializedPackageMemberScope( +open class DeserializedPackageMemberScope( packageDescriptor: PackageFragmentDescriptor, proto: ProtoBuf.Package, nameResolver: NameResolver, diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt index 85b0dd4db3e..d8739b14b0e 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/findClassInModule.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.ClassId -public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? { +fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? { val packageViewDescriptor = getPackage(classId.packageFqName) val segments = classId.relativeClassName.pathSegments() val topLevelClass = packageViewDescriptor.memberScope.getContributedClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null diff --git a/core/reflection.jvm/src/kotlin/reflect/KClasses.kt b/core/reflection.jvm/src/kotlin/reflect/KClasses.kt index 6c566b12163..53fac410b1b 100644 --- a/core/reflection.jvm/src/kotlin/reflect/KClasses.kt +++ b/core/reflection.jvm/src/kotlin/reflect/KClasses.kt @@ -27,7 +27,7 @@ import kotlin.reflect.jvm.internal.KTypeImpl * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/classes.html#constructors) * for more information. */ -public val KClass.primaryConstructor: KFunction? +val KClass.primaryConstructor: KFunction? get() = (this as KClassImpl).constructors.firstOrNull { ((it as KFunctionImpl).descriptor as ConstructorDescriptor).isPrimary } @@ -37,7 +37,7 @@ public val KClass.primaryConstructor: KFunction? * Returns a [KClass] instance representing the companion object of a given class, * or `null` if the class doesn't have a companion object. */ -public val KClass<*>.companionObject: KClass<*>? +val KClass<*>.companionObject: KClass<*>? get() = nestedClasses.firstOrNull { (it as KClassImpl<*>).descriptor.isCompanionObject } @@ -46,7 +46,7 @@ public val KClass<*>.companionObject: KClass<*>? * Returns an instance of the companion object of a given class, * or `null` if the class doesn't have a companion object. */ -public val KClass<*>.companionObjectInstance: Any? +val KClass<*>.companionObjectInstance: Any? get() = companionObject?.objectInstance @@ -54,7 +54,7 @@ public val KClass<*>.companionObjectInstance: Any? * Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments. * For example, for class `MyMap` [defaultType] would return the type `MyMap`. */ -public val KClass<*>.defaultType: KType +val KClass<*>.defaultType: KType get() = KTypeImpl((this as KClassImpl<*>).descriptor.defaultType) { jClass } @@ -62,13 +62,13 @@ public val KClass<*>.defaultType: KType * Returns all functions declared in this class, including all non-static methods declared in the class * and the superclasses, as well as static methods declared in the class. */ -public val KClass<*>.functions: Collection> +val KClass<*>.functions: Collection> get() = members.filterIsInstance>() /** * Returns static functions declared in this class. */ -public val KClass<*>.staticFunctions: Collection> +val KClass<*>.staticFunctions: Collection> get() = (this as KClassImpl) .getMembers(staticScope, declaredOnly = false, nonExtensions = true, extensions = true) .filterIsInstance>() @@ -77,7 +77,7 @@ public val KClass<*>.staticFunctions: Collection> /** * Returns non-extension non-static functions declared in this class and all of its superclasses. */ -public val KClass<*>.memberFunctions: Collection> +val KClass<*>.memberFunctions: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = false, nonExtensions = true, extensions = false) .filterIsInstance>() @@ -86,7 +86,7 @@ public val KClass<*>.memberFunctions: Collection> /** * Returns extension functions declared in this class and all of its superclasses. */ -public val KClass<*>.memberExtensionFunctions: Collection> +val KClass<*>.memberExtensionFunctions: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = false, nonExtensions = false, extensions = true) .filterIsInstance>() @@ -97,7 +97,7 @@ public val KClass<*>.memberExtensionFunctions: Collection> * If this is a Java class, it includes all non-static methods (both extensions and non-extensions) * declared in the class and the superclasses, as well as static methods declared in the class. */ -public val KClass<*>.declaredFunctions: Collection> +val KClass<*>.declaredFunctions: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = true, nonExtensions = true, extensions = true) .plus(getMembers(staticScope, declaredOnly = true, nonExtensions = true, extensions = true)) @@ -107,7 +107,7 @@ public val KClass<*>.declaredFunctions: Collection> /** * Returns non-extension non-static functions declared in this class. */ -public val KClass<*>.declaredMemberFunctions: Collection> +val KClass<*>.declaredMemberFunctions: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = true, nonExtensions = true, extensions = false) .filterIsInstance>() @@ -116,7 +116,7 @@ public val KClass<*>.declaredMemberFunctions: Collection> /** * Returns extension functions declared in this class. */ -public val KClass<*>.declaredMemberExtensionFunctions: Collection> +val KClass<*>.declaredMemberExtensionFunctions: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = true, nonExtensions = false, extensions = true) .filterIsInstance>() @@ -126,7 +126,7 @@ public val KClass<*>.declaredMemberExtensionFunctions: Collection> * Returns static properties declared in this class. * Only properties representing static fields of Java classes are considered static. */ -public val KClass<*>.staticProperties: Collection> +val KClass<*>.staticProperties: Collection> get() = (this as KClassImpl) .getMembers(staticScope, declaredOnly = false, nonExtensions = true, extensions = false) .filterIsInstance>() @@ -135,7 +135,7 @@ public val KClass<*>.staticProperties: Collection> /** * Returns non-extension properties declared in this class and all of its superclasses. */ -public val KClass.memberProperties: Collection> +val KClass.memberProperties: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = false, nonExtensions = true, extensions = false) .filterIsInstance>() @@ -144,7 +144,7 @@ public val KClass.memberProperties: Collection> /** * Returns extension properties declared in this class and all of its superclasses. */ -public val KClass.memberExtensionProperties: Collection> +val KClass.memberExtensionProperties: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = false, nonExtensions = false, extensions = true) .filterIsInstance>() @@ -153,7 +153,7 @@ public val KClass.memberExtensionProperties: Collection KClass.declaredMemberProperties: Collection> +val KClass.declaredMemberProperties: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = true, nonExtensions = true, extensions = false) .filterIsInstance>() @@ -162,7 +162,7 @@ public val KClass.declaredMemberProperties: Collection KClass.declaredMemberExtensionProperties: Collection> +val KClass.declaredMemberExtensionProperties: Collection> get() = (this as KClassImpl) .getMembers(memberScope, declaredOnly = true, nonExtensions = false, extensions = true) .filterIsInstance>() diff --git a/core/reflection.jvm/src/kotlin/reflect/exceptions.kt b/core/reflection.jvm/src/kotlin/reflect/exceptions.kt index dbac6f3c1c4..76cc7f13d9e 100644 --- a/core/reflection.jvm/src/kotlin/reflect/exceptions.kt +++ b/core/reflection.jvm/src/kotlin/reflect/exceptions.kt @@ -24,7 +24,7 @@ package kotlin.reflect * * @see [kotlin.reflect.jvm.isAccessible] */ -public class IllegalCallableAccessException(cause: IllegalAccessException) : Exception(cause.message) { +class IllegalCallableAccessException(cause: IllegalAccessException) : Exception(cause.message) { init { @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (this as java.lang.Throwable).initCause(cause) @@ -35,7 +35,7 @@ public class IllegalCallableAccessException(cause: IllegalAccessException) : Exc * An exception that is thrown when the code tries to introspect a property of a class or a package * and that class or the package no longer has that property. */ -public class NoSuchPropertyException(cause: Exception? = null) : Exception() { +class NoSuchPropertyException(cause: Exception? = null) : Exception() { init { @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") if (cause != null) { @@ -47,4 +47,4 @@ public class NoSuchPropertyException(cause: Exception? = null) : Exception() { /** * Signals that Kotlin reflection had reached an inconsistent state from which it cannot recover. */ -public class KotlinReflectionInternalError(message: String) : Error(message) +class KotlinReflectionInternalError(message: String) : Error(message) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt index 9df29e5404a..cf773643099 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/KCallablesJvm.kt @@ -35,7 +35,7 @@ import kotlin.reflect.jvm.internal.asKCallableImpl * * @see [java.lang.reflect.AccessibleObject] */ -public var KCallable<*>.isAccessible: Boolean +var KCallable<*>.isAccessible: Boolean get() { return when (this) { is KMutableProperty -> diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt index f00d6466baf..afe4a145f8b 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/KClassesJvm.kt @@ -25,7 +25,7 @@ import kotlin.reflect.jvm.internal.KClassImpl * * @see [java.lang.Class.getName] */ -public val KClass<*>.jvmName: String +val KClass<*>.jvmName: String get() { return (this as KClassImpl).jClass.name } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt index 3456a227e13..6937a035a0c 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt @@ -33,21 +33,21 @@ import kotlin.reflect.jvm.internal.asKPropertyImpl * Returns a Java [Field] instance corresponding to the backing field of the given property, * or `null` if the property has no backing field. */ -public val KProperty<*>.javaField: Field? +val KProperty<*>.javaField: Field? get() = this.asKPropertyImpl()?.javaField /** * Returns a Java [Method] instance corresponding to the getter of the given property, * or `null` if the property has no getter, for example in case of a simple private `val` in a class. */ -public val KProperty<*>.javaGetter: Method? +val KProperty<*>.javaGetter: Method? get() = getter.javaMethod /** * Returns a Java [Method] instance corresponding to the setter of the given mutable property, * or `null` if the property has no setter, for example in case of a simple private `var` in a class. */ -public val KMutableProperty<*>.javaSetter: Method? +val KMutableProperty<*>.javaSetter: Method? get() = setter.javaMethod @@ -55,15 +55,14 @@ public val KMutableProperty<*>.javaSetter: Method? * Returns a Java [Method] instance corresponding to the given Kotlin function, * or `null` if this function is a constructor or cannot be represented by a Java [Method]. */ -public val KFunction<*>.javaMethod: Method? +val KFunction<*>.javaMethod: Method? get() = this.asKCallableImpl()?.caller?.member as? Method /** * Returns a Java [Constructor] instance corresponding to the given Kotlin function, * or `null` if this function is not a constructor or cannot be represented by a Java [Constructor]. */ -@Suppress("UNCHECKED_CAST") -public val KFunction.javaConstructor: Constructor? +@Suppress("UNCHECKED_CAST") val KFunction.javaConstructor: Constructor? get() = this.asKCallableImpl()?.caller?.member as? Constructor @@ -72,7 +71,7 @@ public val KFunction.javaConstructor: Constructor? * Note that one Kotlin type may correspond to different JVM types depending on where it appears. For example, [Unit] corresponds to * the JVM class [Unit] when it's the type of a parameter, or to `void` when it's the return type of a function. */ -public val KType.javaType: Type +val KType.javaType: Type get() = (this as KTypeImpl).javaType @@ -84,9 +83,9 @@ public val KType.javaType: Type * or `null` if this field cannot be represented by a Kotlin property * (for example, if it is a synthetic field). */ -public val Field.kotlinProperty: KProperty<*>? +val Field.kotlinProperty: KProperty<*>? get() { - if (isSynthetic()) return null + if (isSynthetic) return null // TODO: optimize (search by name) @@ -95,7 +94,7 @@ public val Field.kotlinProperty: KProperty<*>? return kotlinPackage.members.filterIsInstance>().firstOrNull { it.javaField == this } } - return getDeclaringClass().kotlin.memberProperties.firstOrNull { it.javaField == this } + return declaringClass.kotlin.memberProperties.firstOrNull { it.javaField == this } } @@ -112,7 +111,7 @@ private fun Member.getKPackage(): KDeclarationContainer? { * or `null` if this method cannot be represented by a Kotlin function * (for example, if it is a synthetic method). */ -public val Method.kotlinFunction: KFunction<*>? +val Method.kotlinFunction: KFunction<*>? get() { if (isSynthetic) return null @@ -141,9 +140,9 @@ public val Method.kotlinFunction: KFunction<*>? * or `null` if this constructor cannot be represented by a Kotlin function * (for example, if it is a synthetic constructor). */ -public val Constructor.kotlinFunction: KFunction? +val Constructor.kotlinFunction: KFunction? get() { - if (isSynthetic()) return null + if (isSynthetic) return null - return getDeclaringClass().kotlin.constructors.firstOrNull { it.javaConstructor == this } + return declaringClass.kotlin.constructors.firstOrNull { it.javaConstructor == this } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/_Deprecated.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/_Deprecated.kt index 80be186598f..2018982f9f4 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/_Deprecated.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/_Deprecated.kt @@ -19,37 +19,29 @@ package kotlin.reflect.jvm import java.lang.reflect.Field import kotlin.reflect.* -@Deprecated("Use kotlinProperty instead.", ReplaceWith("kotlinProperty")) -public val Field.kotlin: KProperty<*>? +@Deprecated("Use kotlinProperty instead.", ReplaceWith("kotlinProperty")) val Field.kotlin: KProperty<*>? get() = kotlinProperty -@Deprecated("Use memberProperties instead.", ReplaceWith("memberProperties")) -public val KClass.properties: Collection> +@Deprecated("Use memberProperties instead.", ReplaceWith("memberProperties")) val KClass.properties: Collection> get() = memberProperties -@Deprecated("Use extensionProperties instead.", ReplaceWith("extensionProperties")) -public val KClass.extensionProperties: Collection> +@Deprecated("Use extensionProperties instead.", ReplaceWith("extensionProperties")) val KClass.extensionProperties: Collection> get() = memberExtensionProperties -@Deprecated("Use declaredMemberProperties instead.", ReplaceWith("declaredMemberProperties")) -public val KClass.declaredProperties: Collection> +@Deprecated("Use declaredMemberProperties instead.", ReplaceWith("declaredMemberProperties")) val KClass.declaredProperties: Collection> get() = declaredMemberProperties -@Deprecated("Use declaredMemberExtensionProperties instead.", ReplaceWith("declaredMemberExtensionProperties")) -public val KClass.declaredExtensionProperties: Collection> +@Deprecated("Use declaredMemberExtensionProperties instead.", ReplaceWith("declaredMemberExtensionProperties")) val KClass.declaredExtensionProperties: Collection> get() = declaredMemberExtensionProperties -@Deprecated("Use isAccessible instead.", ReplaceWith("isAccessible")) -public var KProperty<*>.accessible: Boolean +@Deprecated("Use isAccessible instead.", ReplaceWith("isAccessible")) var KProperty<*>.accessible: Boolean get() = isAccessible set(value) { isAccessible = value } -@Deprecated("Moved to package kotlin.jvm", ReplaceWith("java"), level = DeprecationLevel.HIDDEN) -public val KClass.java: Class +@Deprecated("Moved to package kotlin.jvm", ReplaceWith("java"), level = DeprecationLevel.HIDDEN) val KClass.java: Class get() = java -@Deprecated("Moved to package kotlin.jvm", ReplaceWith("kotlin"), level = DeprecationLevel.HIDDEN) -public val Class.kotlin: KClass +@Deprecated("Moved to package kotlin.jvm", ReplaceWith("kotlin"), level = DeprecationLevel.HIDDEN) val Class.kotlin: KClass get() = kotlin diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/reflectLambda.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/reflectLambda.kt index e23c2b93546..fb51a9e12db 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/reflectLambda.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/reflectLambda.kt @@ -35,7 +35,7 @@ import kotlin.reflect.jvm.internal.getOrCreateModule * returns a [KFunction] instance providing introspection capabilities for that lambda or function expression and its parameters. * Not all features are currently supported, in particular [KCallable.call] and [KCallable.callBy] will fail at the moment. */ -public fun Function.reflect(): KFunction? { +fun Function.reflect(): KFunction? { val callable = javaClass.getAnnotation(KotlinFunction::class.java) ?: return null val input = BitEncoding.decodeBytes(callable.data).inputStream() val nameResolver = JvmNameResolver( diff --git a/core/runtime.jvm/src/kotlin/jvm/JvmClassMapping.kt b/core/runtime.jvm/src/kotlin/jvm/JvmClassMapping.kt index 6d8741c38d7..4883be911da 100644 --- a/core/runtime.jvm/src/kotlin/jvm/JvmClassMapping.kt +++ b/core/runtime.jvm/src/kotlin/jvm/JvmClassMapping.kt @@ -25,14 +25,14 @@ import kotlin.reflect.KClass /** * Returns a Java [Class] instance corresponding to the given [KClass] instance. */ -public val KClass.java: Class +val KClass.java: Class @JvmName("getJavaClass") get() = (this as ClassBasedDeclarationContainer).jClass as Class /** * Returns a Java [Class] instance representing the primitive type corresponding to the given [KClass] if it exists. */ -public val KClass.javaPrimitiveType: Class? +val KClass.javaPrimitiveType: Class? get() { val thisJClass = (this as ClassBasedDeclarationContainer).jClass if (thisJClass.isPrimitive) return thisJClass as Class @@ -54,7 +54,7 @@ public val KClass.javaPrimitiveType: Class? * Returns a Java [Class] instance corresponding to the given [KClass] instance. * In case of primitive types it returns corresponding wrapper classes. */ -public val KClass.javaObjectType: Class +val KClass.javaObjectType: Class get() { val thisJClass = (this as ClassBasedDeclarationContainer).jClass if (!thisJClass.isPrimitive) return thisJClass as Class @@ -75,7 +75,7 @@ public val KClass.javaObjectType: Class /** * Returns a [KClass] instance corresponding to the given Java [Class] instance. */ -public val Class.kotlin: KClass +val Class.kotlin: KClass @JvmName("getKotlinClass") get() = Reflection.createKotlinClass(this) as KClass @@ -83,23 +83,21 @@ public val Class.kotlin: KClass /** * Returns the runtime Java class of this object. */ -public val T.javaClass : Class - get() = (this as java.lang.Object).getClass() as Class +val T.javaClass : Class + get() = (this as java.lang.Object).`class` as Class -@Deprecated("Use 'java' property to get Java class corresponding to this Kotlin class or cast this instance to Any if you really want to get the runtime Java class of this implementation of KClass.", ReplaceWith("(this as Any).javaClass"), level = DeprecationLevel.ERROR) -public val KClass.javaClass: Class> +@Deprecated("Use 'java' property to get Java class corresponding to this Kotlin class or cast this instance to Any if you really want to get the runtime Java class of this implementation of KClass.", ReplaceWith("(this as Any).javaClass"), level = DeprecationLevel.ERROR) val KClass.javaClass: Class> @JvmName("getRuntimeClassOfKClassInstance") - get() = (this as java.lang.Object).getClass() as Class> + get() = (this as java.lang.Object).`class` as Class> /** * Checks if array can contain element of type [T]. */ -@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE") -public fun Array<*>.isArrayOf(): Boolean = +@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE") fun Array<*>.isArrayOf(): Boolean = T::class.java.isAssignableFrom(this.javaClass.componentType) /** * Returns a [KClass] instance corresponding to the annotation type of this annotation. */ -public val T.annotationClass: KClass +val T.annotationClass: KClass get() = (this as java.lang.annotation.Annotation).annotationType().kotlin as KClass diff --git a/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt b/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt index fa360efe319..670d086899f 100644 --- a/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt +++ b/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt @@ -37,4 +37,4 @@ package kotlin.jvm @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -public annotation class PurelyImplements(public val value: String) +annotation class PurelyImplements(val value: String) diff --git a/core/runtime.jvm/src/kotlin/jvm/annotations/JvmFlagAnnotations.kt b/core/runtime.jvm/src/kotlin/jvm/annotations/JvmFlagAnnotations.kt index b269039b78f..fcd5c1bf32a 100644 --- a/core/runtime.jvm/src/kotlin/jvm/annotations/JvmFlagAnnotations.kt +++ b/core/runtime.jvm/src/kotlin/jvm/annotations/JvmFlagAnnotations.kt @@ -25,7 +25,7 @@ import kotlin.annotation.AnnotationTarget.* @Target(FIELD) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Volatile +annotation class Volatile /** * Marks the JVM backing field of the annotated property as `transient`, meaning that it is not @@ -34,7 +34,7 @@ public annotation class Volatile @Target(FIELD) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Transient +annotation class Transient /** * Marks the JVM method generated from the annotated function as `strictfp`, meaning that the precision @@ -44,7 +44,7 @@ public annotation class Transient @Target(FUNCTION, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER, CLASS) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Strictfp +annotation class Strictfp /** * Marks the JVM method generated from the annotated function as `synchronized`, meaning that the method @@ -54,4 +54,4 @@ public annotation class Strictfp @Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Synchronized \ No newline at end of file +annotation class Synchronized \ No newline at end of file diff --git a/core/runtime.jvm/src/kotlin/jvm/annotations/JvmPlatformAnnotations.kt b/core/runtime.jvm/src/kotlin/jvm/annotations/JvmPlatformAnnotations.kt index fc5646e1234..4cf6a9a0ffc 100644 --- a/core/runtime.jvm/src/kotlin/jvm/annotations/JvmPlatformAnnotations.kt +++ b/core/runtime.jvm/src/kotlin/jvm/annotations/JvmPlatformAnnotations.kt @@ -27,7 +27,7 @@ import kotlin.reflect.KClass @Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR) @Retention(AnnotationRetention.BINARY) @MustBeDocumented -public annotation class JvmOverloads +annotation class JvmOverloads /** @@ -38,7 +38,7 @@ public annotation class JvmOverloads @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -public annotation class JvmStatic +annotation class JvmStatic /** * Specifies the name for the Java class or method which is generated from this element. @@ -49,7 +49,7 @@ public annotation class JvmStatic @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE) @Retention(AnnotationRetention.BINARY) @MustBeDocumented -public annotation class JvmName(public val name: String) +annotation class JvmName(val name: String) /** * Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts. @@ -58,11 +58,11 @@ public annotation class JvmName(public val name: String) @Target(AnnotationTarget.FILE) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class JvmMultifileClass +annotation class JvmMultifileClass @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD) @Retention(AnnotationRetention.SOURCE) -public annotation class JvmSynthetic +annotation class JvmSynthetic /** * This annotation indicates what exceptions should be declared by a function when compiled to a JVM method. @@ -84,7 +84,7 @@ public annotation class JvmSynthetic */ @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR) @Retention(AnnotationRetention.SOURCE) -public annotation class Throws(public vararg val exceptionClasses: KClass) +annotation class Throws(vararg val exceptionClasses: KClass) /** @@ -93,7 +93,7 @@ public annotation class Throws(public vararg val exceptionClasses: KClass : Function { +interface Function0 : Function { /** Invokes the function. */ - public operator fun invoke(): R + operator fun invoke(): R } /** A function that takes 1 argument. */ -public interface Function1 : Function { +interface Function1 : Function { /** Invokes the function with the specified argument. */ - public operator fun invoke(p1: P1): R + operator fun invoke(p1: P1): R } /** A function that takes 2 arguments. */ -public interface Function2 : Function { +interface Function2 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2): R + operator fun invoke(p1: P1, p2: P2): R } /** A function that takes 3 arguments. */ -public interface Function3 : Function { +interface Function3 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3): R + operator fun invoke(p1: P1, p2: P2, p3: P3): R } /** A function that takes 4 arguments. */ -public interface Function4 : Function { +interface Function4 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R } /** A function that takes 5 arguments. */ -public interface Function5 : Function { +interface Function5 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R } /** A function that takes 6 arguments. */ -public interface Function6 : Function { +interface Function6 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R } /** A function that takes 7 arguments. */ -public interface Function7 : Function { +interface Function7 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R } /** A function that takes 8 arguments. */ -public interface Function8 : Function { +interface Function8 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R } /** A function that takes 9 arguments. */ -public interface Function9 : Function { +interface Function9 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R } /** A function that takes 10 arguments. */ -public interface Function10 : Function { +interface Function10 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R } /** A function that takes 11 arguments. */ -public interface Function11 : Function { +interface Function11 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R } /** A function that takes 12 arguments. */ -public interface Function12 : Function { +interface Function12 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R } /** A function that takes 13 arguments. */ -public interface Function13 : Function { +interface Function13 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R } /** A function that takes 14 arguments. */ -public interface Function14 : Function { +interface Function14 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R } /** A function that takes 15 arguments. */ -public interface Function15 : Function { +interface Function15 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R } /** A function that takes 16 arguments. */ -public interface Function16 : Function { +interface Function16 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R } /** A function that takes 17 arguments. */ -public interface Function17 : Function { +interface Function17 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R } /** A function that takes 18 arguments. */ -public interface Function18 : Function { +interface Function18 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R } /** A function that takes 19 arguments. */ -public interface Function19 : Function { +interface Function19 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R } /** A function that takes 20 arguments. */ -public interface Function20 : Function { +interface Function20 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R } /** A function that takes 21 arguments. */ -public interface Function21 : Function { +interface Function21 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R } /** A function that takes 22 arguments. */ -public interface Function22 : Function { +interface Function22 : Function { /** Invokes the function with the specified arguments. */ - public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R + operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterator.kt b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterator.kt index dc057af2ef9..b6c441550c6 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterator.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterator.kt @@ -22,4 +22,4 @@ private class ArrayIterator(val array: Array) : Iterator { override fun next() = array[index++] } -public fun iterator(array: Array): Iterator = ArrayIterator(array) +fun iterator(array: Array): Iterator = ArrayIterator(array) diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt index 9287955bf6d..fa4b85c7626 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt @@ -66,11 +66,11 @@ private class ArrayBooleanIterator(private val array: BooleanArray) : BooleanIte override fun nextBoolean() = array[index++] } -public fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array) -public fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array) -public fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array) -public fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array) -public fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array) -public fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array) -public fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array) -public fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array) +fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array) +fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array) +fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array) +fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array) +fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array) +fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array) +fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array) +fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array) diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ClassBasedDeclarationContainer.kt b/core/runtime.jvm/src/kotlin/jvm/internal/ClassBasedDeclarationContainer.kt index 8c7ce308b64..a9a88ffb47a 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ClassBasedDeclarationContainer.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ClassBasedDeclarationContainer.kt @@ -19,5 +19,5 @@ package kotlin.jvm.internal import kotlin.reflect.KDeclarationContainer interface ClassBasedDeclarationContainer : KDeclarationContainer { - public val jClass: Class<*> + val jClass: Class<*> } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ClassReference.kt b/core/runtime.jvm/src/kotlin/jvm/internal/ClassReference.kt index b1331c91c51..589b004da99 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ClassReference.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ClassReference.kt @@ -20,7 +20,7 @@ import kotlin.reflect.KCallable import kotlin.reflect.KClass import kotlin.reflect.KFunction -public class ClassReference(override val jClass: Class<*>) : KClass, ClassBasedDeclarationContainer { +class ClassReference(override val jClass: Class<*>) : KClass, ClassBasedDeclarationContainer { override val simpleName: String? get() = error() diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt b/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt index 71d4cba4951..8ed80f05d0c 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt @@ -16,9 +16,9 @@ package kotlin.jvm.internal -public abstract class Lambda(private val arity: Int) : FunctionImpl() { +abstract class Lambda(private val arity: Int) : FunctionImpl() { override fun getArity() = arity @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - override fun toString() = "${(this as Object).getClass().getGenericInterfaces()[0]}" + override fun toString() = "${(this as Object).`class`.genericInterfaces[0]}" } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveCompanionObjects.kt b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveCompanionObjects.kt index 76f94d2ab73..6a93a5c533d 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveCompanionObjects.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveCompanionObjects.kt @@ -54,12 +54,12 @@ private object ByteCompanionObject { private object CharCompanionObject { - public const val MIN_HIGH_SURROGATE: Char = '\uD800' - public const val MAX_HIGH_SURROGATE: Char = '\uDBFF' - public const val MIN_LOW_SURROGATE: Char = '\uDC00' - public const val MAX_LOW_SURROGATE: Char = '\uDFFF' - public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE - public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE + const val MIN_HIGH_SURROGATE: Char = '\uD800' + const val MAX_HIGH_SURROGATE: Char = '\uDBFF' + const val MIN_LOW_SURROGATE: Char = '\uDC00' + const val MAX_LOW_SURROGATE: Char = '\uDFFF' + const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE + const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE } private object StringCompanionObject {} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt index fd8bf417383..0d57ef2776a 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt @@ -16,7 +16,7 @@ package kotlin.jvm.internal -public abstract class PrimitiveSpreadBuilder(private val size: Int) { +abstract class PrimitiveSpreadBuilder(private val size: Int) { abstract protected fun T.getSize(): Int protected var position: Int = 0 @@ -24,7 +24,7 @@ public abstract class PrimitiveSpreadBuilder(private val size: Int) { @Suppress("CAST_NEVER_SUCCEEDS") private val spreads: Array = arrayOfNulls(size) as Array - public fun addSpread(spreadArgument: T) { + fun addSpread(spreadArgument: T) { spreads[position++] = spreadArgument } @@ -60,90 +60,90 @@ public abstract class PrimitiveSpreadBuilder(private val size: Int) { } } -public class ByteSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class ByteSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: ByteArray = ByteArray(size) override fun ByteArray.getSize(): Int = this.size - public fun add(value: Byte) { + fun add(value: Byte) { values[position++] = value } - public fun toArray(): ByteArray = toArray(values, ByteArray(size())) + fun toArray(): ByteArray = toArray(values, ByteArray(size())) } -public class CharSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class CharSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: CharArray = CharArray(size) override fun CharArray.getSize(): Int = this.size - public fun add(value: Char) { + fun add(value: Char) { values[position++] = value } - public fun toArray(): CharArray = toArray(values, CharArray(size())) + fun toArray(): CharArray = toArray(values, CharArray(size())) } -public class DoubleSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class DoubleSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: DoubleArray = DoubleArray(size) override fun DoubleArray.getSize(): Int = this.size - public fun add(value: Double) { + fun add(value: Double) { values[position++] = value } - public fun toArray(): DoubleArray = toArray(values, DoubleArray(size())) + fun toArray(): DoubleArray = toArray(values, DoubleArray(size())) } -public class FloatSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class FloatSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: FloatArray = FloatArray(size) override fun FloatArray.getSize(): Int = this.size - public fun add(value: Float) { + fun add(value: Float) { values[position++] = value } - public fun toArray(): FloatArray = toArray(values, FloatArray(size())) + fun toArray(): FloatArray = toArray(values, FloatArray(size())) } -public class IntSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class IntSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: IntArray = IntArray(size) override fun IntArray.getSize(): Int = this.size - public fun add(value: Int) { + fun add(value: Int) { values[position++] = value } - public fun toArray(): IntArray = toArray(values, IntArray(size())) + fun toArray(): IntArray = toArray(values, IntArray(size())) } -public class LongSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class LongSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: LongArray = LongArray(size) override fun LongArray.getSize(): Int = this.size - public fun add(value: Long) { + fun add(value: Long) { values[position++] = value } - public fun toArray(): LongArray = toArray(values, LongArray(size())) + fun toArray(): LongArray = toArray(values, LongArray(size())) } -public class ShortSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class ShortSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: ShortArray = ShortArray(size) override fun ShortArray.getSize(): Int = this.size - public fun add(value: Short) { + fun add(value: Short) { values[position++] = value } - public fun toArray(): ShortArray = toArray(values, ShortArray(size())) + fun toArray(): ShortArray = toArray(values, ShortArray(size())) } -public class BooleanSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { +class BooleanSpreadBuilder(size: Int) : PrimitiveSpreadBuilder(size) { private val values: BooleanArray = BooleanArray(size) override fun BooleanArray.getSize(): Int = this.size - public fun add(value: Boolean) { + fun add(value: Boolean) { values[position++] = value } - public fun toArray(): BooleanArray = toArray(values, BooleanArray(size())) + fun toArray(): BooleanArray = toArray(values, BooleanArray(size())) } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/storage/ObservableStorageManager.kt b/core/util.runtime/src/org/jetbrains/kotlin/storage/ObservableStorageManager.kt index 40247e3d78e..34a3c3bf836 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/storage/ObservableStorageManager.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/storage/ObservableStorageManager.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.storage import java.util.concurrent.ConcurrentMap -public abstract class ObservableStorageManager(private val delegate: StorageManager) : StorageManager { +abstract class ObservableStorageManager(private val delegate: StorageManager) : StorageManager { protected abstract val (() -> T).observable: () -> T protected abstract val ((K) -> V).observable: (K) -> V diff --git a/core/util.runtime/src/org/jetbrains/kotlin/storage/StorageManager.kt b/core/util.runtime/src/org/jetbrains/kotlin/storage/StorageManager.kt index 2f17c80bc95..56adfeda304 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/storage/StorageManager.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/storage/StorageManager.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.storage import java.util.concurrent.ConcurrentMap -public interface StorageManager { +interface StorageManager { /** * Given a function compute: K -> V create a memoized version of it that computes a value only once for each key * @param compute the function to be memoized @@ -27,17 +27,17 @@ public interface StorageManager { * NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if * the value gets collected and then re-computed */ - public fun createMemoizedFunction(compute: (K) -> V): MemoizedFunctionToNotNull + fun createMemoizedFunction(compute: (K) -> V): MemoizedFunctionToNotNull - public fun createMemoizedFunctionWithNullableValues(compute: (K) -> V?): MemoizedFunctionToNullable + fun createMemoizedFunctionWithNullableValues(compute: (K) -> V?): MemoizedFunctionToNullable - public fun createMemoizedFunction(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNotNull + fun createMemoizedFunction(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNotNull - public fun createMemoizedFunctionWithNullableValues(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNullable + fun createMemoizedFunctionWithNullableValues(compute: (K) -> V, map: ConcurrentMap): MemoizedFunctionToNullable - public fun createLazyValue(computable: () -> T): NotNullLazyValue + fun createLazyValue(computable: () -> T): NotNullLazyValue - public fun createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue + fun createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue /** * @param onRecursiveCall is called if the computation calls itself recursively. @@ -46,17 +46,17 @@ public interface StorageManager { * otherwise it's executed and its result is returned * @param postCompute is called after the value is computed, but before any other thread sees it */ - public fun createLazyValueWithPostCompute(computable: () -> T, onRecursiveCall: ((Boolean) -> T)?, postCompute: (T) -> Unit): NotNullLazyValue + fun createLazyValueWithPostCompute(computable: () -> T, onRecursiveCall: ((Boolean) -> T)?, postCompute: (T) -> Unit): NotNullLazyValue - public fun createNullableLazyValue(computable: () -> T?): NullableLazyValue + fun createNullableLazyValue(computable: () -> T?): NullableLazyValue - public fun createRecursionTolerantNullableLazyValue(computable: () -> T?, onRecursiveCall: T?): NullableLazyValue + fun createRecursionTolerantNullableLazyValue(computable: () -> T?, onRecursiveCall: T?): NullableLazyValue /** * {@code postCompute} is called after the value is computed, but before any other thread sees it (the current thread may * see it in between) */ - public fun createNullableLazyValueWithPostCompute(computable: () -> T?, postCompute: (T?) -> Unit): NullableLazyValue + fun createNullableLazyValueWithPostCompute(computable: () -> T?, postCompute: (T?) -> Unit): NullableLazyValue - public fun compute(computable: () -> T): T + fun compute(computable: () -> T): T } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt b/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt index 6b355c8ff05..2c0c6750d34 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt @@ -18,24 +18,24 @@ package org.jetbrains.kotlin.storage import kotlin.reflect.KProperty -public interface MemoizedFunctionToNotNull : Function1 { - public fun isComputed(key: P): Boolean +interface MemoizedFunctionToNotNull : Function1 { + fun isComputed(key: P): Boolean } -public interface MemoizedFunctionToNullable : Function1 { - public fun isComputed(key: P): Boolean +interface MemoizedFunctionToNullable : Function1 { + fun isComputed(key: P): Boolean } -public interface NotNullLazyValue : Function0 { - public fun isComputed(): Boolean - public fun isComputing(): Boolean +interface NotNullLazyValue : Function0 { + fun isComputed(): Boolean + fun isComputing(): Boolean } -public interface NullableLazyValue : Function0 { - public fun isComputed(): Boolean - public fun isComputing(): Boolean +interface NullableLazyValue : Function0 { + fun isComputed(): Boolean + fun isComputing(): Boolean } -public operator fun NotNullLazyValue.getValue(_this: Any?, p: KProperty<*>): T = invoke() +operator fun NotNullLazyValue.getValue(_this: Any?, p: KProperty<*>): T = invoke() -public operator fun NullableLazyValue.getValue(_this: Any?, p: KProperty<*>): T? = invoke() +operator fun NullableLazyValue.getValue(_this: Any?, p: KProperty<*>): T? = invoke() diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt index d2f25a0798f..9dda07bd9a6 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt @@ -20,43 +20,43 @@ import java.lang.reflect.Modifier import java.util.* import java.util.concurrent.ConcurrentHashMap -public fun T?.singletonOrEmptyList(): List = if (this != null) Collections.singletonList(this) else Collections.emptyList() +fun T?.singletonOrEmptyList(): List = if (this != null) Collections.singletonList(this) else Collections.emptyList() -public fun T.singletonList(): List = Collections.singletonList(this) +fun T.singletonList(): List = Collections.singletonList(this) -public fun T?.singletonOrEmptySet(): Set = if (this != null) Collections.singleton(this) else Collections.emptySet() +fun T?.singletonOrEmptySet(): Set = if (this != null) Collections.singleton(this) else Collections.emptySet() -public inline fun Sequence<*>.firstIsInstanceOrNull(): T? { +inline fun Sequence<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } -public inline fun Iterable<*>.firstIsInstanceOrNull(): T? { +inline fun Iterable<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } -public inline fun Array<*>.firstIsInstanceOrNull(): T? { +inline fun Array<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } -public inline fun Sequence<*>.firstIsInstance(): T { +inline fun Sequence<*>.firstIsInstance(): T { for (element in this) if (element is T) return element throw NoSuchElementException("No element of given type found") } -public inline fun Iterable<*>.firstIsInstance(): T { +inline fun Iterable<*>.firstIsInstance(): T { for (element in this) if (element is T) return element throw NoSuchElementException("No element of given type found") } -public inline fun Array<*>.firstIsInstance(): T { +inline fun Array<*>.firstIsInstance(): T { for (element in this) if (element is T) return element throw NoSuchElementException("No element of given type found") } -public inline fun Iterable<*>.lastIsInstanceOrNull(): T? { +inline fun Iterable<*>.lastIsInstanceOrNull(): T? { when (this) { is List<*> -> { for (i in this.indices.reversed()) { @@ -72,18 +72,18 @@ public inline fun Iterable<*>.lastIsInstanceOrNull(): T? { } } -public fun sequenceOfLazyValues(vararg elements: () -> T): Sequence = elements.asSequence().map { it() } +fun sequenceOfLazyValues(vararg elements: () -> T): Sequence = elements.asSequence().map { it() } -public fun Pair.swap(): Pair = Pair(second, first) +fun Pair.swap(): Pair = Pair(second, first) -public fun T.check(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null +fun T.check(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null -public fun constant(calculator: () -> T): T { +fun constant(calculator: () -> T): T { val cached = constantMap[calculator] if (cached != null) return cached as T // safety check - val fields = calculator.javaClass.getDeclaredFields().filter { it.getModifiers().and(Modifier.STATIC) == 0 } + val fields = calculator.javaClass.declaredFields.filter { it.modifiers.and(Modifier.STATIC) == 0 } assert(fields.isEmpty()) { "No fields in the passed lambda expected but ${fields.joinToString()} found" } @@ -95,12 +95,12 @@ public fun constant(calculator: () -> T): T { private val constantMap = ConcurrentHashMap, Any>() -public fun String.indexOfOrNull(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int? { +fun String.indexOfOrNull(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int? { val index = indexOf(char, startIndex, ignoreCase) return if (index >= 0) index else null } -public fun String.lastIndexOfOrNull(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int? { +fun String.lastIndexOfOrNull(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int? { val index = lastIndexOf(char, startIndex, ignoreCase) return if (index >= 0) index else null } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/capitalizeDecapitalize.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/capitalizeDecapitalize.kt index 4f5999e1669..9f3a78da602 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/capitalizeDecapitalize.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/capitalizeDecapitalize.kt @@ -21,7 +21,7 @@ package org.jetbrains.kotlin.util.capitalizeDecapitalize * "FOOBar" -> "fooBar" * "FOO" -> "foo" */ -public fun String.decapitalizeSmart(asciiOnly: Boolean = false): String { +fun String.decapitalizeSmart(asciiOnly: Boolean = false): String { fun isUpperCaseCharAt(index: Int): Boolean { val c = this[index] return if (asciiOnly) c in 'A'..'Z' else c.isUpperCase() @@ -45,7 +45,7 @@ public fun String.decapitalizeSmart(asciiOnly: Boolean = false): String { * "FooBar" -> "FOOBar" * "foo" -> "FOO" */ -public fun String.capitalizeFirstWord(asciiOnly: Boolean = false): String { +fun String.capitalizeFirstWord(asciiOnly: Boolean = false): String { fun toUpperCase(string: String) = if (asciiOnly) string.toUpperCaseAsciiOnly() else string.toUpperCase() fun isLowerCaseCharAt(index: Int): Boolean { @@ -58,7 +58,7 @@ public fun String.capitalizeFirstWord(asciiOnly: Boolean = false): String { return toUpperCase(substring(0, secondWordStart)) + substring(secondWordStart) } -public fun String.capitalizeAsciiOnly(): String { +fun String.capitalizeAsciiOnly(): String { if (isEmpty()) return this val c = this[0] return if (c in 'a'..'z') @@ -67,7 +67,7 @@ public fun String.capitalizeAsciiOnly(): String { this } -public fun String.decapitalizeAsciiOnly(): String { +fun String.decapitalizeAsciiOnly(): String { if (isEmpty()) return this val c = this[0] return if (c in 'A'..'Z') @@ -76,7 +76,7 @@ public fun String.decapitalizeAsciiOnly(): String { this } -public fun String.toLowerCaseAsciiOnly(): String { +fun String.toLowerCaseAsciiOnly(): String { val builder = StringBuilder(length) for (c in this) { builder.append(if (c in 'A'..'Z') c.toLowerCase() else c) @@ -84,7 +84,7 @@ public fun String.toLowerCaseAsciiOnly(): String { return builder.toString() } -public fun String.toUpperCaseAsciiOnly(): String { +fun String.toUpperCaseAsciiOnly(): String { val builder = StringBuilder(length) for (c in this) { builder.append(if (c in 'a'..'z') c.toUpperCase() else c) diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt index cc44f301fc7..c3fbd2a3518 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt @@ -18,11 +18,11 @@ package org.jetbrains.kotlin.utils import java.util.* -public fun Iterable.keysToMap(value: (K) -> V): Map { +fun Iterable.keysToMap(value: (K) -> V): Map { return toMapBy({ it }, value) } -public fun Iterable.keysToMapExceptNulls(value: (K) -> V?): Map { +fun Iterable.keysToMapExceptNulls(value: (K) -> V?): Map { val map = LinkedHashMap() for (k in this) { val v = value(k) @@ -33,7 +33,7 @@ public fun Iterable.keysToMapExceptNulls(value: (K) -> V?): Map Iterable.mapToIndex(): Map { +fun Iterable.mapToIndex(): Map { val map = LinkedHashMap() for ((index, k) in this.withIndex()) { map[k] = index @@ -41,30 +41,30 @@ public fun Iterable.mapToIndex(): Map { return map } -public inline fun > C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this +inline fun > C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this -public inline fun Array.ifEmpty(body: () -> Array): Array = if (isEmpty()) body() else this +inline fun Array.ifEmpty(body: () -> Array): Array = if (isEmpty()) body() else this -public fun emptyOrSingletonList(item: T?): List = listOfNotNull(item) +fun emptyOrSingletonList(item: T?): List = listOfNotNull(item) -public fun MutableCollection.addIfNotNull(t: T?) { +fun MutableCollection.addIfNotNull(t: T?) { if (t != null) add(t) } -public fun newHashMapWithExpectedSize(expectedSize: Int): HashMap { +fun newHashMapWithExpectedSize(expectedSize: Int): HashMap { return HashMap(if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1) } -public fun newHashSetWithExpectedSize(expectedSize: Int): HashSet { +fun newHashSetWithExpectedSize(expectedSize: Int): HashSet { return HashSet(if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1) } -public fun Collection.toReadOnlyList(): List = +fun Collection.toReadOnlyList(): List = when (size) { 0 -> emptyList() 1 -> listOf(first()) else -> ArrayList(this) } -public fun T?.singletonOrEmptyList(): List = +fun T?.singletonOrEmptyList(): List = if (this != null) listOf(this) else emptyList() diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/coreLib.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/coreLib.kt index f29c3049166..f99a59904ad 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/coreLib.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/coreLib.kt @@ -16,4 +16,4 @@ package org.jetbrains.kotlin.utils -public inline fun T?.sure(message: () -> String): T = this ?: throw AssertionError(message()) +inline fun T?.sure(message: () -> String): T = this ?: throw AssertionError(message()) diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt index a9091d48563..2bda56778fb 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/exceptionUtils.kt @@ -25,11 +25,11 @@ import java.io.Closeable * throw ExceptionUtils.rethrow(e); * In this case compiler knows that code after this rethrowing won't be executed. */ -public fun rethrow(e: Throwable): RuntimeException { +fun rethrow(e: Throwable): RuntimeException { throw e } -public fun closeQuietly(closeable: Closeable?) { +fun closeQuietly(closeable: Closeable?) { if (closeable != null) { try { closeable.close() diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt index a613901dc93..5e08e58459d 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt @@ -18,15 +18,14 @@ package org.jetbrains.kotlin.utils private val IDENTITY: (Any?) -> Any? = { it } -@Suppress("UNCHECKED_CAST") -public fun identity(): (T) -> T = IDENTITY as (T) -> T +@Suppress("UNCHECKED_CAST") fun identity(): (T) -> T = IDENTITY as (T) -> T private val ALWAYS_TRUE: (Any?) -> Boolean = { true } -public fun alwaysTrue(): (T) -> Boolean = ALWAYS_TRUE +fun alwaysTrue(): (T) -> Boolean = ALWAYS_TRUE -public val DO_NOTHING: (Any?) -> Unit = { } +val DO_NOTHING: (Any?) -> Unit = { } -public fun doNothing(): (T) -> Unit = DO_NOTHING +fun doNothing(): (T) -> Unit = DO_NOTHING