diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt index a17b1a5be4f..6b5cc33c6e3 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt @@ -27,15 +27,14 @@ import org.jetbrains.kotlin.types.isDynamic import org.jetbrains.kotlin.utils.keysToMapExceptNulls import java.util.Comparator -public object CodegenUtilKt { +object CodegenUtilKt { // class Foo : Bar by baz // descriptor = Foo // toInterface = Bar // delegateExpressionType = typeof(baz) // return Map - @JvmStatic - public fun getDelegates( + @JvmStatic fun getDelegates( descriptor: ClassDescriptor, toInterface: ClassDescriptor, delegateExpressionType: KotlinType? = null diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/bridges.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/bridges.kt index f3de897f053..dbeec69c710 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/bridges.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/bridges.kt @@ -19,22 +19,22 @@ package org.jetbrains.kotlin.backend.common.bridges import org.jetbrains.kotlin.utils.DFS import java.util.HashSet -public interface FunctionHandle { - public val isDeclaration: Boolean - public val isAbstract: Boolean +interface FunctionHandle { + val isDeclaration: Boolean + val isAbstract: Boolean - public fun getOverridden(): Iterable + fun getOverridden(): Iterable } -public data class Bridge( - public val from: Signature, - public val to: Signature +data class Bridge( + val from: Signature, + val to: Signature ) { override fun toString() = "$from -> $to" } -public fun generateBridges( +fun generateBridges( function: Function, signature: (Function) -> Signature ): Set> { @@ -69,7 +69,7 @@ public fun generateBridges( return bridgesToGenerate.map { Bridge(it, method) }.toSet() } -public fun findAllReachableDeclarations(function: Function): MutableSet { +fun findAllReachableDeclarations(function: Function): MutableSet { val collector = object : DFS.NodeHandlerWithListResult() { override fun afterChildren(current: Function) { if (current.isDeclaration) { @@ -86,7 +86,7 @@ public fun findAllReachableDeclarations(function: Fu * Given a concrete function, finds an implementation (a concrete declaration) of this function in the supertypes. * The implementation is guaranteed to exist because if it wouldn't, the given function would've been abstract */ -public fun findConcreteSuperDeclaration(function: Function): Function { +fun findConcreteSuperDeclaration(function: Function): Function { require(!function.isAbstract, { "Only concrete functions have implementations: $function" }) if (function.isDeclaration) return function diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt index d0c4e5b6f60..e8631bd8877 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.OverrideResolver import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized -public fun generateBridgesForFunctionDescriptor( +fun generateBridgesForFunctionDescriptor( descriptor: FunctionDescriptor, signature: (FunctionDescriptor) -> Signature ): Set> { @@ -47,16 +47,16 @@ public fun generateBridgesForFunctionDescriptor( * can generate a bridge near an implementation (of course, in case it has a super-declaration with a different signature). Ultimately this * eases the process of determining what bridges are already generated in our supertypes and need to be inherited, not regenerated. */ -public data class DescriptorBasedFunctionHandle(val descriptor: FunctionDescriptor) : FunctionHandle { - private val overridden = descriptor.getOverriddenDescriptors().map { DescriptorBasedFunctionHandle(it.getOriginal()) } +data class DescriptorBasedFunctionHandle(val descriptor: FunctionDescriptor) : FunctionHandle { + private val overridden = descriptor.overriddenDescriptors.map { DescriptorBasedFunctionHandle(it.original) } override val isDeclaration: Boolean = - descriptor.getKind().isReal() || + descriptor.kind.isReal || findTraitImplementation(descriptor) != null override val isAbstract: Boolean = - descriptor.getModality() == Modality.ABSTRACT || - DescriptorUtils.isInterface(descriptor.getContainingDeclaration()) + descriptor.modality == Modality.ABSTRACT || + DescriptorUtils.isInterface(descriptor.containingDeclaration) override fun getOverridden() = overridden } @@ -67,14 +67,14 @@ public data class DescriptorBasedFunctionHandle(val descriptor: FunctionDescript * trait implementation should be generated into the class containing the fake override; or null if the given function is not a fake * override of any trait implementation or such method was already generated into the superclass or is a method from Any. */ -public fun findTraitImplementation(descriptor: CallableMemberDescriptor): CallableMemberDescriptor? { - if (descriptor.getKind().isReal()) return null +fun findTraitImplementation(descriptor: CallableMemberDescriptor): CallableMemberDescriptor? { + if (descriptor.kind.isReal) return null if (isOrOverridesSynthesized(descriptor)) return null val implementation = findImplementationFromInterface(descriptor) ?: return null val immediateConcreteSuper = firstSuperMethodFromKotlin(descriptor, implementation) ?: return null - if (!DescriptorUtils.isInterface(immediateConcreteSuper.getContainingDeclaration())) { + if (!DescriptorUtils.isInterface(immediateConcreteSuper.containingDeclaration)) { // If this implementation is already generated into the superclass, we need not generate it again, it'll be inherited return null } @@ -86,7 +86,7 @@ public fun findTraitImplementation(descriptor: CallableMemberDescriptor): Callab * Given a fake override, returns an overridden non-abstract function from an interface which is the actual implementation of this function * that should be called when the given fake override is called. */ -public fun findImplementationFromInterface(descriptor: CallableMemberDescriptor): CallableMemberDescriptor? { +fun findImplementationFromInterface(descriptor: CallableMemberDescriptor): CallableMemberDescriptor? { val overridden = OverrideResolver.getOverriddenDeclarations(descriptor) val filtered = OverrideResolver.filterOutOverridden(overridden) @@ -102,12 +102,12 @@ public fun findImplementationFromInterface(descriptor: CallableMemberDescriptor) * returns the first immediate super function of the given fake override which overrides that implementation. * The returned function should be called from TImpl-bridges generated for the given fake override. */ -public fun firstSuperMethodFromKotlin( +fun firstSuperMethodFromKotlin( descriptor: CallableMemberDescriptor, implementation: CallableMemberDescriptor ): CallableMemberDescriptor? { - return descriptor.getOverriddenDescriptors().firstOrNull { overridden -> - overridden.getModality() != Modality.ABSTRACT && + return descriptor.overriddenDescriptors.firstOrNull { overridden -> + overridden.modality != Modality.ABSTRACT && (overridden == implementation || OverrideResolver.overrides(overridden, implementation)) } } diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/output/output.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/output/output.kt index 9d5380b5a49..f4050b9b159 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/output/output.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/output/output.kt @@ -18,24 +18,24 @@ package org.jetbrains.kotlin.backend.common.output import java.io.File -public interface OutputFileCollection { - public fun get(relativePath: String): OutputFile? - public fun asList(): List +interface OutputFileCollection { + fun get(relativePath: String): OutputFile? + fun asList(): List } -public class SimpleOutputFileCollection(private val outputFiles: List) : OutputFileCollection { +class SimpleOutputFileCollection(private val outputFiles: List) : OutputFileCollection { override fun get(relativePath: String): OutputFile? = outputFiles.firstOrNull { it.relativePath == relativePath } override fun asList(): List = outputFiles } -public interface OutputFile { - public val relativePath: String - public val sourceFiles: List - public fun asByteArray(): ByteArray - public fun asText(): String +interface OutputFile { + val relativePath: String + val sourceFiles: List + fun asByteArray(): ByteArray + fun asText(): String } -public class SimpleOutputFile( +class SimpleOutputFile( override val sourceFiles: List, override val relativePath: String, private val content: String @@ -46,7 +46,7 @@ public class SimpleOutputFile( override fun toString() = "$relativePath (compiled from $sourceFiles)" } -public class SimpleOutputBinaryFile( +class SimpleOutputBinaryFile( override val sourceFiles: List, override val relativePath: String, private val content: ByteArray diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AbstractAccessorForFunctionDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AbstractAccessorForFunctionDescriptor.kt index 3026db4b904..fe9ab459771 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AbstractAccessorForFunctionDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AbstractAccessorForFunctionDescriptor.kt @@ -24,18 +24,18 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import java.util.* -open public class AbstractAccessorForFunctionDescriptor( +open class AbstractAccessorForFunctionDescriptor( containingDeclaration: DeclarationDescriptor, name: Name ) : SimpleFunctionDescriptorImpl(containingDeclaration, null, Annotations.EMPTY, name, CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE) { - protected fun copyTypeParameters(descriptor: FunctionDescriptor): List = descriptor.getTypeParameters().map { + protected fun copyTypeParameters(descriptor: FunctionDescriptor): List = descriptor.typeParameters.map { val copy = TypeParameterDescriptorImpl.createForFurtherModification( - this, it.getAnnotations(), it.isReified(), - it.getVariance(), it.getName(), - it.getIndex(), SourceElement.NO_SOURCE) - for (upperBound in it.getUpperBounds()) { + this, it.annotations, it.isReified, + it.variance, it.name, + it.index, SourceElement.NO_SOURCE) + for (upperBound in it.upperBounds) { copy.addUpperBound(upperBound) } copy.setInitialized() @@ -43,5 +43,5 @@ open public class AbstractAccessorForFunctionDescriptor( } protected fun copyValueParameters(descriptor: FunctionDescriptor): List = - descriptor.getValueParameters().map { it.copy(this, it.getName()) } + descriptor.valueParameters.map { it.copy(this, it.name) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt index 5385524c994..e56a2f6b016 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor -public class AccessorForConstructorDescriptor( +class AccessorForConstructorDescriptor( private val calleeDescriptor: ConstructorDescriptor, containingDeclaration: DeclarationDescriptor, private val superCallTarget: ClassDescriptor? diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt index f3cdd804779..b578ec06307 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt @@ -147,8 +147,8 @@ open class BranchedValue( }, IFEQ) } - public fun cmp(opToken: IElementType, operandType: Type, left: StackValue, right: StackValue): StackValue = - if (operandType.getSort() == Type.OBJECT) + fun cmp(opToken: IElementType, operandType: Type, left: StackValue, right: StackValue): StackValue = + if (operandType.sort == Type.OBJECT) ObjectCompare(opToken, operandType, left, right) else NumberCompare(opToken, operandType, left, right) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt index 3a5a3c48b88..d587709a673 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt @@ -20,32 +20,32 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public interface Callable { - public val owner: Type +interface Callable { + val owner: Type - public val dispatchReceiverType: Type? + val dispatchReceiverType: Type? - public val extensionReceiverType: Type? + val extensionReceiverType: Type? - public val generateCalleeType: Type? + val generateCalleeType: Type? - public val valueParameterTypes: List + val valueParameterTypes: List - public val parameterTypes: Array + val parameterTypes: Array - public val returnType: Type + val returnType: Type - public fun genInvokeInstruction(v: InstructionAdapter) + fun genInvokeInstruction(v: InstructionAdapter) - public fun isStaticCall(): Boolean + fun isStaticCall(): Boolean - public fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, codegen: ExpressionCodegen): StackValue { + fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, codegen: ExpressionCodegen): StackValue { return StackValue.functionCall(returnType) { codegen.invokeMethodWithArguments(this, resolvedCall, receiver) } } - public fun afterReceiverGeneration(v: InstructionAdapter) { + fun afterReceiverGeneration(v: InstructionAdapter) { } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt index 627b591ddd2..734a52286be 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt @@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.commons.Method import org.jetbrains.org.objectweb.asm.util.Printer -public class CallableMethod( +class CallableMethod( override val owner: Type, private val defaultImplOwner: Type?, private val defaultMethodDesc: String, @@ -37,48 +37,48 @@ public class CallableMethod( override val extensionReceiverType: Type?, override val generateCalleeType: Type? ) : Callable { - public fun getValueParameters(): List = - signature.getValueParameters() + fun getValueParameters(): List = + signature.valueParameters override val valueParameterTypes: List - get() = signature.getValueParameters().filter { it.getKind() == JvmMethodParameterKind.VALUE }.map { it.getAsmType() } + get() = signature.valueParameters.filter { it.kind == JvmMethodParameterKind.VALUE }.map { it.asmType } - public fun getAsmMethod(): Method = - signature.getAsmMethod() + fun getAsmMethod(): Method = + signature.asmMethod override val parameterTypes: Array - get() = getAsmMethod().getArgumentTypes() + get() = getAsmMethod().argumentTypes - public override fun genInvokeInstruction(v: InstructionAdapter) { - v.visitMethodInsn(invokeOpcode, owner.getInternalName(), getAsmMethod().getName(), getAsmMethod().getDescriptor()) + override fun genInvokeInstruction(v: InstructionAdapter) { + v.visitMethodInsn(invokeOpcode, owner.internalName, getAsmMethod().name, getAsmMethod().descriptor) } - public fun genInvokeDefaultInstruction(v: InstructionAdapter) { + fun genInvokeDefaultInstruction(v: InstructionAdapter) { if (defaultImplOwner == null) { throw IllegalStateException() } val method = getAsmMethod() - if ("".equals(method.getName())) { + if ("".equals(method.name)) { v.aconst(null) - v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.getInternalName(), "", defaultMethodDesc, false) + v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.internalName, "", defaultMethodDesc, false) } else { - v.visitMethodInsn(INVOKESTATIC, defaultImplOwner.getInternalName(), - method.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, defaultMethodDesc, false) + v.visitMethodInsn(INVOKESTATIC, defaultImplOwner.internalName, + method.name + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, defaultMethodDesc, false) StackValue.coerce(Type.getReturnType(defaultMethodDesc), Type.getReturnType(signature.asmMethod.descriptor), v) } } override val returnType: Type - get() = signature.getReturnType() + get() = signature.returnType override fun isStaticCall(): Boolean = invokeOpcode == INVOKESTATIC override fun toString(): String = - "${Printer.OPCODES[invokeOpcode]} ${owner.getInternalName()}.$signature" + "${Printer.OPCODES[invokeOpcode]} ${owner.internalName}.$signature" } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassNameCollectionClassBuilderFactory.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassNameCollectionClassBuilderFactory.kt index 953374054fb..515e59dee66 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassNameCollectionClassBuilderFactory.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassNameCollectionClassBuilderFactory.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.RawSignature import org.jetbrains.org.objectweb.asm.FieldVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor -public abstract class ClassNameCollectionClassBuilderFactory( +abstract class ClassNameCollectionClassBuilderFactory( delegate: ClassBuilderFactory ) : DelegatingClassBuilderFactory(delegate) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CodegenFileClassesProvider.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CodegenFileClassesProvider.kt index 4cc20975a20..154ea494926 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CodegenFileClassesProvider.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CodegenFileClassesProvider.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider import org.jetbrains.kotlin.psi.KtFile -public class CodegenFileClassesProvider : JvmFileClassesProvider { - override public fun getFileClassInfo(file: KtFile): JvmFileClassInfo = +class CodegenFileClassesProvider : JvmFileClassesProvider { + override fun getFileClassInfo(file: KtFile): JvmFileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(file) } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt index 599fb9fcf0c..042eb20f527 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt @@ -65,14 +65,14 @@ class CollectionStubMethodGenerator( val (child, typeParameters) = createSyntheticSubclass() // If the original class has any type parameters, we copied them and now we need to substitute types of the newly created type // parameters as arguments for the type parameters of the original class - val parentType = newType(descriptor, typeParameters.map { TypeProjectionImpl(it.getDefaultType()) }) + val parentType = newType(descriptor, typeParameters.map { TypeProjectionImpl(it.defaultType) }) // Now we need to determine the arguments which should be substituted for the MutableCollection super class. To do that, // we look for type arguments which were substituted in the inheritance of the original class from Collection and use them // to construct the needed MutableCollection type. Since getAllSupertypes() may return several types which correspond to the // Collection class descriptor, we find the most specific one (which is guaranteed to exist by front-end) val readOnlyCollectionType = TypeUtils.getAllSupertypes(parentType).findMostSpecificTypeForClass(readOnlyClass) - val mutableCollectionType = newType(mutableClass, readOnlyCollectionType.getArguments()) + val mutableCollectionType = newType(mutableClass, readOnlyCollectionType.arguments) child.addSupertype(parentType) child.addSupertype(mutableCollectionType) @@ -81,10 +81,10 @@ class CollectionStubMethodGenerator( // Bind fake overrides and for each fake override originated from the MutableCollection, save its signature to generate a stub // or save its descriptor to generate all the needed bridges for (method in findFakeOverridesForMethodsFromMutableCollection(child, mutableClass)) { - if (method.getModality() == Modality.ABSTRACT) { + if (method.modality == Modality.ABSTRACT) { // If the fake override is abstract and it's _declared_ as abstract in the class, skip it because the method is already // present in the bytecode (abstract) and we don't want a duplicate signature error - if (method.findOverriddenFromDirectSuperClass(descriptor)?.getKind() == DECLARATION) continue + if (method.findOverriddenFromDirectSuperClass(descriptor)?.kind == DECLARATION) continue // Otherwise we can safely generate the stub with the substituted signature val signature = method.signature() @@ -160,18 +160,18 @@ class CollectionStubMethodGenerator( val collectionClasses = with(descriptor.builtIns) { listOf( - pair(getCollection(), getMutableCollection()), - pair(getSet(), getMutableSet()), - pair(getList(), getMutableList()), - pair(getMap(), getMutableMap()), - pair(getMapEntry(), getMutableMapEntry()), - pair(getIterable(), getMutableIterable()), - pair(getIterator(), getMutableIterator()), - pair(getListIterator(), getMutableListIterator()) + pair(collection, mutableCollection), + pair(set, mutableSet), + pair(list, mutableList), + pair(map, mutableMap), + pair(mapEntry, mutableMapEntry), + pair(iterable, mutableIterable), + pair(iterator, mutableIterator), + pair(listIterator, mutableListIterator) ) } - val allSuperClasses = TypeUtils.getAllSupertypes(descriptor.getDefaultType()).classes().toHashSet() + val allSuperClasses = TypeUtils.getAllSupertypes(descriptor.defaultType).classes().toHashSet() val ourSuperCollectionClasses = collectionClasses.filter { pair -> pair.readOnlyClass in allSuperClasses && pair.mutableClass !in allSuperClasses @@ -180,13 +180,13 @@ class CollectionStubMethodGenerator( // Filter out built-in classes which are overridden by other built-in classes in the list, to avoid duplicating methods. val redundantClasses = ourSuperCollectionClasses.flatMapTo(HashSet()) { pair -> - pair.readOnlyClass.getTypeConstructor().getSupertypes().classes() + pair.readOnlyClass.typeConstructor.supertypes.classes() } return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses } } private fun Collection.classes(): Collection = - this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor } + this.map { it.constructor.declarationDescriptor as ClassDescriptor } private fun findFakeOverridesForMethodsFromMutableCollection( klass: ClassDescriptor, @@ -212,7 +212,7 @@ class CollectionStubMethodGenerator( } private fun Collection.findMostSpecificTypeForClass(klass: ClassDescriptor): KotlinType { - val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass } + val types = this.filter { it.constructor.declarationDescriptor == klass } if (types.isEmpty()) error("No supertype of $klass in $this") if (types.size == 1) return types.first() // Find the first type in the list such that it's a subtype of every other type in that list @@ -222,11 +222,11 @@ class CollectionStubMethodGenerator( } private fun createSyntheticSubclass(): Pair> { - val child = MutableClassDescriptor(descriptor.getContainingDeclaration(), ClassKind.CLASS, false, - Name.special(""), descriptor.getSource()) - child.setModality(Modality.FINAL) - child.setVisibility(Visibilities.PUBLIC) - val typeParameters = descriptor.getTypeConstructor().getParameters() + val child = MutableClassDescriptor(descriptor.containingDeclaration, ClassKind.CLASS, false, + Name.special(""), descriptor.source) + child.modality = Modality.FINAL + child.visibility = Visibilities.PUBLIC + val typeParameters = descriptor.typeConstructor.parameters val newTypeParameters = ArrayList(typeParameters.size) DescriptorSubstitutor.substituteTypeParameters(typeParameters, TypeSubstitution.EMPTY, child, newTypeParameters) child.setTypeParameterDescriptors(typeParameters) @@ -234,7 +234,7 @@ class CollectionStubMethodGenerator( } private fun FunctionDescriptor.findOverriddenFromDirectSuperClass(classDescriptor: ClassDescriptor): FunctionDescriptor? { - return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor } + return this.overriddenDescriptors.firstOrNull { it.containingDeclaration == classDescriptor } } private fun newType(classDescriptor: ClassDescriptor, typeArguments: List): KotlinType { @@ -246,13 +246,13 @@ class CollectionStubMethodGenerator( private fun generateMethodStub(signature: JvmMethodSignature, synthetic: Boolean) { // TODO: investigate if it makes sense to generate abstract stubs in traits var access = ACC_PUBLIC - if (descriptor.getKind() == ClassKind.INTERFACE) access = access or ACC_ABSTRACT + if (descriptor.kind == ClassKind.INTERFACE) access = access or ACC_ABSTRACT if (synthetic) access = access or ACC_SYNTHETIC - val asmMethod = signature.getAsmMethod() - val genericSignature = if (synthetic) null else signature.getGenericsSignature() - val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, asmMethod.getName(), asmMethod.getDescriptor(), genericSignature, null) - if (descriptor.getKind() != ClassKind.INTERFACE) { + val asmMethod = signature.asmMethod + val genericSignature = if (synthetic) null else signature.genericsSignature + val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, asmMethod.name, asmMethod.descriptor, genericSignature, null) + if (descriptor.kind != ClassKind.INTERFACE) { mv.visitCode() AsmUtil.genThrow(InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection") FunctionCodegen.endVisit(mv, "built-in stub for $signature", null) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultCallMask.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultCallMask.kt index ce55fb9648b..c41d3928420 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultCallMask.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultCallMask.kt @@ -50,7 +50,7 @@ class DefaultCallMask(val size: Int) { return masks } - public fun generateOnStackIfNeeded(callGenerator: CallGenerator): Boolean { + fun generateOnStackIfNeeded(callGenerator: CallGenerator): Boolean { val toInts = toInts() for (mask in toInts) { callGenerator.putValueIfNeeded(null, Type.INT_TYPE, StackValue.constant(mask, Type.INT_TYPE)) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt index e0af26cd8d2..729fd76ca65 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt @@ -33,7 +33,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter * Generates Java overloads for functions and constructors that have the default * parameter values substituted. */ -public class DefaultParameterValueSubstitutor(val state: GenerationState) { +class DefaultParameterValueSubstitutor(val state: GenerationState) { /** * If all of the parameters of the specified constructor declare default values, * generates a no-argument constructor that passes default values for all arguments. @@ -118,19 +118,19 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { val typeMapper = state.typeMapper val isStatic = AsmUtil.isStaticMethod(contextKind, functionDescriptor) val flags = AsmUtil.getVisibilityAccessFlag(functionDescriptor) or (if (isStatic) Opcodes.ACC_STATIC else 0) - val remainingParameters = getRemainingParameters(functionDescriptor.getOriginal(), substituteCount) + val remainingParameters = getRemainingParameters(functionDescriptor.original, substituteCount) val signature = typeMapper.mapSignature(functionDescriptor, contextKind, remainingParameters) val mv = classBuilder.newMethod(OtherOrigin(methodElement, functionDescriptor), flags, - signature.getAsmMethod().getName(), - signature.getAsmMethod().getDescriptor(), - signature.getGenericsSignature(), + signature.asmMethod.name, + signature.asmMethod.descriptor, + signature.genericsSignature, FunctionCodegen.getThrownExceptions(functionDescriptor, typeMapper)) - AnnotationCodegen.forMethod(mv, typeMapper).genAnnotations(functionDescriptor, signature.getReturnType()) + AnnotationCodegen.forMethod(mv, typeMapper).genAnnotations(functionDescriptor, signature.returnType) remainingParameters.withIndex().forEach { val annotationCodegen = AnnotationCodegen.forParameter(it.index, mv, typeMapper) - annotationCodegen.genAnnotations(it.value, signature.getValueParameters()[it.index].getAsmType()) + annotationCodegen.genAnnotations(it.value, signature.valueParameters[it.index].asmType) } if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) { @@ -148,14 +148,14 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { v.load(thisIndex, methodOwner) // Load this on stack } else { - val delegateOwner = delegateFunctionDescriptor.getContainingDeclaration() - if (delegateOwner is ClassDescriptor && delegateOwner.isCompanionObject()) { + val delegateOwner = delegateFunctionDescriptor.containingDeclaration + if (delegateOwner is ClassDescriptor && delegateOwner.isCompanionObject) { val singletonValue = StackValue.singleton(delegateOwner, typeMapper) singletonValue.put(singletonValue.type, v); } } - val receiver = functionDescriptor.getExtensionReceiverParameter() + val receiver = functionDescriptor.extensionReceiverParameter if (receiver != null) { val receiverType = typeMapper.mapType(receiver) val receiverIndex = frameMap.enter(receiver, receiverType) @@ -167,8 +167,8 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { var mask = 0 val masks = arrayListOf() - for (parameterDescriptor in functionDescriptor.getValueParameters()) { - val paramType = typeMapper.mapType(parameterDescriptor.getType()) + for (parameterDescriptor in functionDescriptor.valueParameters) { + val paramType = typeMapper.mapType(parameterDescriptor.type) if (parameterDescriptor in remainingParameters) { val index = frameMap.getIndex(parameterDescriptor) StackValue.local(index, paramType).put(paramType, v) @@ -195,39 +195,39 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { val defaultMethod = typeMapper.mapDefaultMethod(delegateFunctionDescriptor, contextKind) if (functionDescriptor is ConstructorDescriptor) { - v.invokespecial(methodOwner.getInternalName(), defaultMethod.getName(), defaultMethod.getDescriptor(), false) + v.invokespecial(methodOwner.internalName, defaultMethod.name, defaultMethod.descriptor, false) } else { - v.invokestatic(methodOwner.getInternalName(), defaultMethod.getName(), defaultMethod.getDescriptor(), false) + v.invokestatic(methodOwner.internalName, defaultMethod.name, defaultMethod.descriptor, false) } - v.areturn(signature.getReturnType()) + v.areturn(signature.returnType) FunctionCodegen.endVisit(mv, null, methodElement) } private fun getRemainingParameters(functionDescriptor: FunctionDescriptor, substituteCount: Int): List { var remainingCount = functionDescriptor.countDefaultParameters() - substituteCount - return functionDescriptor.getValueParameters().filter { !it.declaresDefaultValue() || --remainingCount >= 0 } + return functionDescriptor.valueParameters.filter { !it.declaresDefaultValue() || --remainingCount >= 0 } } private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: KtClassOrObject): Boolean { - val classDescriptor = constructorDescriptor.getContainingDeclaration() - if (classDescriptor.getKind() != ClassKind.CLASS) return false + val classDescriptor = constructorDescriptor.containingDeclaration + if (classDescriptor.kind != ClassKind.CLASS) return false if (classOrObject.isLocal()) return false if (CodegenBinding.canHaveOuter(state.bindingContext, classDescriptor)) return false - if (Visibilities.isPrivate(classDescriptor.getVisibility()) || Visibilities.isPrivate(constructorDescriptor.getVisibility())) + if (Visibilities.isPrivate(classDescriptor.visibility) || Visibilities.isPrivate(constructorDescriptor.visibility)) return false - if (constructorDescriptor.getValueParameters().isEmpty()) return false + if (constructorDescriptor.valueParameters.isEmpty()) return false if (classOrObject is KtClass && hasSecondaryConstructorsWithNoParameters(classOrObject)) return false - return constructorDescriptor.getValueParameters().all { it.declaresDefaultValue() } + return constructorDescriptor.valueParameters.all { it.declaresDefaultValue() } } private fun hasSecondaryConstructorsWithNoParameters(klass: KtClass) = - klass.getSecondaryConstructors().any { it.getValueParameters().isEmpty() } + klass.getSecondaryConstructors().any { it.valueParameters.isEmpty() } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DelegatingClassBuilderFactory.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DelegatingClassBuilderFactory.kt index 24318e5a9b3..5efd5d2daa6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DelegatingClassBuilderFactory.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DelegatingClassBuilderFactory.kt @@ -25,18 +25,18 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.RawSignature import org.jetbrains.org.objectweb.asm.FieldVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor -public abstract class DelegatingClassBuilderFactory( +abstract class DelegatingClassBuilderFactory( protected val delegate: ClassBuilderFactory ) : ClassBuilderFactory by delegate { abstract override fun newClassBuilder(origin: JvmDeclarationOrigin): DelegatingClassBuilder - public override fun asBytes(builder: ClassBuilder?): ByteArray? { + override fun asBytes(builder: ClassBuilder?): ByteArray? { return delegate.asBytes((builder as DelegatingClassBuilder).getDelegate()) } - public override fun asText(builder: ClassBuilder?): String? { + override fun asText(builder: ClassBuilder?): String? { return delegate.asText((builder as DelegatingClassBuilder).getDelegate()) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/InlineCycleReporter.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/InlineCycleReporter.kt index 2376dd54a68..f11f31755f2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/InlineCycleReporter.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/InlineCycleReporter.kt @@ -23,14 +23,14 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -public class InlineCycleReporter(val diagnostics: DiagnosticSink) { +class InlineCycleReporter(val diagnostics: DiagnosticSink) { val processingFunctions = linkedMapOf() - public fun enterIntoInlining(call: ResolvedCall<*>?): Boolean { + fun enterIntoInlining(call: ResolvedCall<*>?): Boolean { //null call for default method inlining if (call != null) { - val callElement = call.getCall().getCallElement() + val callElement = call.call.callElement if (processingFunctions.contains(callElement)) { val cycle = processingFunctions.asSequence().dropWhile { it.key != callElement } cycle.forEach { @@ -38,14 +38,14 @@ public class InlineCycleReporter(val diagnostics: DiagnosticSink) { } return false } - processingFunctions.put(callElement, call.getResultingDescriptor().getOriginal()) + processingFunctions.put(callElement, call.resultingDescriptor.original) } return true } - public fun exitFromInliningOf(call: ResolvedCall<*>?) { + fun exitFromInliningOf(call: ResolvedCall<*>?) { if (call != null) { - val callElement = call.getCall().getCallElement() + val callElement = call.call.callElement processingFunctions.remove(callElement) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt index 6b6fbd5173a..5ac7f7caf48 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/InterfaceImplBodyCodegen.kt @@ -38,7 +38,7 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.Opcodes.* import java.util.* -public class InterfaceImplBodyCodegen( +class InterfaceImplBodyCodegen( aClass: KtClassOrObject, context: ClassContext, v: ClassBuilder, @@ -54,7 +54,7 @@ public class InterfaceImplBodyCodegen( typeMapper.mapDefaultImpls(descriptor).internalName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY ) - v.visitSource(myClass.getContainingFile().getName(), null) + v.visitSource(myClass.containingFile.name, null) } override fun classForInnerClassRecord(): ClassDescriptor? { @@ -69,12 +69,12 @@ public class InterfaceImplBodyCodegen( } override fun generateSyntheticParts() { - for (memberDescriptor in descriptor.getDefaultType().getMemberScope().getContributedDescriptors()) { + for (memberDescriptor in descriptor.defaultType.memberScope.getContributedDescriptors()) { if (memberDescriptor !is CallableMemberDescriptor) continue - if (memberDescriptor.getKind().isReal()) continue - if (memberDescriptor.getVisibility() == Visibilities.INVISIBLE_FAKE) continue - if (memberDescriptor.getModality() == Modality.ABSTRACT) continue + if (memberDescriptor.kind.isReal) continue + if (memberDescriptor.visibility == Visibilities.INVISIBLE_FAKE) continue + if (memberDescriptor.modality == Modality.ABSTRACT) continue val implementation = findImplementationFromInterface(memberDescriptor) ?: continue @@ -82,7 +82,7 @@ public class InterfaceImplBodyCodegen( if (implementation is JavaMethodDescriptor) continue // We create a copy of the function with kind = DECLARATION so that FunctionCodegen will generate its body - val copy = memberDescriptor.copy(memberDescriptor.getContainingDeclaration(), Modality.OPEN, memberDescriptor.getVisibility(), + val copy = memberDescriptor.copy(memberDescriptor.containingDeclaration, Modality.OPEN, memberDescriptor.visibility, CallableMemberDescriptor.Kind.DECLARATION, true) if (memberDescriptor is FunctionDescriptor) { @@ -90,13 +90,13 @@ public class InterfaceImplBodyCodegen( } else if (memberDescriptor is PropertyDescriptor) { implementation as PropertyDescriptor - val getter = (copy as PropertyDescriptor).getGetter() - val implGetter = implementation.getGetter() + val getter = (copy as PropertyDescriptor).getter + val implGetter = implementation.getter if (getter != null && implGetter != null) { generateDelegationToSuperTraitImpl(getter, implGetter) } - val setter = copy.getSetter() - val implSetter = implementation.getSetter() + val setter = copy.setter + val implSetter = implementation.setter if (setter != null && implSetter != null) { generateDelegationToSuperTraitImpl(setter, implSetter) } @@ -120,7 +120,7 @@ public class InterfaceImplBodyCodegen( val iv = codegen.v val method = typeMapper.mapToCallableMethod(delegateTo, true) - val myParameters = signature.getValueParameters() + val myParameters = signature.valueParameters val calleeParameters = method.getValueParameters() if (myParameters.size != calleeParameters.size) { @@ -135,14 +135,14 @@ public class InterfaceImplBodyCodegen( var k = 0 val it = calleeParameters.iterator() for (parameter in myParameters) { - val type = parameter.getAsmType() - StackValue.local(k, type).put(it.next().getAsmType(), iv) - k += type.getSize() + val type = parameter.asmType + StackValue.local(k, type).put(it.next().asmType, iv) + k += type.size } method.genInvokeInstruction(iv) - StackValue.coerce(method.returnType, signature.getReturnType(), iv) - iv.areturn(signature.getReturnType()) + StackValue.coerce(method.returnType, signature.returnType, iv) + iv.areturn(signature.returnType) } }) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmStaticGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmStaticGenerator.kt index 449ee9198ee..ec0e4b97834 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmStaticGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmStaticGenerator.kt @@ -79,15 +79,14 @@ class JvmStaticGenerator( } companion object { - @JvmStatic - public fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor { - val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.getCorrespondingProperty() else descriptor + @JvmStatic fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor { + val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.correspondingProperty else descriptor val copies = CodegenUtil.copyFunctions( memberDescriptor, memberDescriptor, - descriptor.getContainingDeclaration().getContainingDeclaration(), - descriptor.getModality(), - descriptor.getVisibility(), + descriptor.containingDeclaration.containingDeclaration, + descriptor.modality, + descriptor.visibility, CallableMemberDescriptor.Kind.SYNTHESIZED, false ) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt index 2afcd3da12e..760f31bc216 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassCodegen.kt @@ -54,9 +54,9 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import java.util.* -public class MultifileClassCodegen( +class MultifileClassCodegen( private val state: GenerationState, - public val files: Collection, + val files: Collection, private val facadeFqName: FqName ) { private val facadeClassType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(facadeFqName) @@ -74,7 +74,7 @@ public class MultifileClassCodegen( private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) = compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance() - public val packageParts = PackageParts(facadeFqName.parent().asString()) + val packageParts = PackageParts(facadeFqName.parent().asString()) private val classBuilder = ClassBuilderOnDemand { val originFile = files.firstOrNull() @@ -103,7 +103,7 @@ public class MultifileClassCodegen( classBuilder } - public fun generate(errorHandler: CompilationErrorHandler) { + fun generate(errorHandler: CompilationErrorHandler) { val generateCallableMemberTasks = HashMap Unit>() val partFqNames = arrayListOf() @@ -152,7 +152,7 @@ public class MultifileClassCodegen( writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames) } - public fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: FieldOwnerContext) { + fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: FieldOwnerContext) { MemberCodegen.genClassOrObject(packagePartContext, classOrObject, state, null) } @@ -292,7 +292,7 @@ public class MultifileClassCodegen( override fun generateKotlinAnnotation() = throw UnsupportedOperationException() } - public fun done() { + fun done() { classBuilder.done() } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassPartCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassPartCodegen.kt index 6bd48a76690..5302758b26c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassPartCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MultifileClassPartCodegen.kt @@ -31,7 +31,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type import java.util.* -public class MultifileClassPartCodegen( +class MultifileClassPartCodegen( v: ClassBuilder, file: KtFile, private val filePartType: Type, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index f0c2113d131..7bf7a7fda03 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -39,7 +39,7 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.commons.Method -public class PropertyReferenceCodegen( +class PropertyReferenceCodegen( state: GenerationState, parentCodegen: MemberCodegen<*>, context: ClassContext, @@ -68,22 +68,22 @@ public class PropertyReferenceCodegen( element, V1_6, ACC_FINAL or ACC_SUPER or AsmUtil.getVisibilityAccessFlagForAnonymous(classDescriptor), - asmType.getInternalName(), + asmType.internalName, null, - superAsmType.getInternalName(), + superAsmType.internalName, emptyArray() ) - v.visitSource(element.getContainingFile().getName(), null) + v.visitSource(element.containingFile.name, null) } // TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction? override fun generateBody() { - generateConstInstance(asmType, wrapperMethod.getReturnType()) + generateConstInstance(asmType, wrapperMethod.returnType) generateMethod("property reference init", 0, method("", Type.VOID_TYPE)) { load(0, OBJECT_TYPE) - invokespecial(superAsmType.getInternalName(), "", "()V", false) + invokespecial(superAsmType.internalName, "", "()V", false) } generateMethod("property reference getOwner", ACC_PUBLIC, method("getOwner", K_DECLARATION_CONTAINER_TYPE)) { @@ -91,7 +91,7 @@ public class PropertyReferenceCodegen( } generateMethod("property reference getName", ACC_PUBLIC, method("getName", JAVA_STRING_TYPE)) { - aconst(target.getName().asString()) + aconst(target.name.asString()) } generateMethod("property reference getSignature", ACC_PUBLIC, method("getSignature", JAVA_STRING_TYPE)) { @@ -108,11 +108,11 @@ public class PropertyReferenceCodegen( // return type and value parameter types. However, it's created only to be able to use // ExpressionCodegen#intermediateValueForProperty, which is poorly coupled with everything else. val fakeDescriptor = SimpleFunctionDescriptorImpl.create( - classDescriptor, Annotations.EMPTY, Name.identifier(method.getName()), CallableMemberDescriptor.Kind.DECLARATION, + classDescriptor, Annotations.EMPTY, Name.identifier(method.name), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE ) - fakeDescriptor.initialize(null, classDescriptor.getThisAsReceiverParameter(), emptyList(), emptyList(), - classDescriptor.builtIns.getAnyType(), Modality.OPEN, Visibilities.PUBLIC) + fakeDescriptor.initialize(null, classDescriptor.thisAsReceiverParameter, emptyList(), emptyList(), + classDescriptor.builtIns.anyType, Modality.OPEN, Visibilities.PUBLIC) val fakeCodegen = ExpressionCodegen( this, FrameMap(), OBJECT_TYPE, context.intoFunction(fakeDescriptor), state, this@PropertyReferenceCodegen @@ -147,13 +147,13 @@ public class PropertyReferenceCodegen( } private fun generateMethod(debugString: String, access: Int, method: Method, generate: InstructionAdapter.() -> Unit) { - val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, method.getName(), method.getDescriptor(), null, null) + val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, method.name, method.descriptor, null, null) if (state.classBuilderMode == ClassBuilderMode.FULL) { val iv = InstructionAdapter(mv) iv.visitCode() iv.generate() - iv.areturn(method.getReturnType()) + iv.areturn(method.returnType) FunctionCodegen.endVisit(mv, debugString, element) } } @@ -162,9 +162,9 @@ public class PropertyReferenceCodegen( writeKotlinSyntheticClassAnnotation(v, state) } - public fun putInstanceOnStack(): StackValue = - StackValue.operation(wrapperMethod.getReturnType()) { iv -> - iv.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, wrapperMethod.getReturnType().getDescriptor()) + fun putInstanceOnStack(): StackValue = + StackValue.operation(wrapperMethod.returnType) { iv -> + iv.getstatic(asmType.internalName, JvmAbi.INSTANCE_FIELD, wrapperMethod.returnType.descriptor) } companion object { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SignatureCollectingClassBuilderFactory.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/SignatureCollectingClassBuilderFactory.kt index fcebf8f9d41..a6fdc715afd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SignatureCollectingClassBuilderFactory.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SignatureCollectingClassBuilderFactory.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.RawSignature import org.jetbrains.org.objectweb.asm.FieldVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor -public abstract class SignatureCollectingClassBuilderFactory( +abstract class SignatureCollectingClassBuilderFactory( delegate: ClassBuilderFactory ) : DelegatingClassBuilderFactory(delegate) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SourceInfo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/SourceInfo.kt index 8582c2c5960..0f28b8d51c2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SourceInfo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SourceInfo.kt @@ -22,19 +22,19 @@ import org.jetbrains.kotlin.backend.common.CodegenUtil import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNamedFunction -data public class SourceInfo(val source: String, val pathOrCleanFQN: String, val linesInFile: Int) { +data class SourceInfo(val source: String, val pathOrCleanFQN: String, val linesInFile: Int) { companion object { fun createInfo(element: KtElement?, internalClassName: String): SourceInfo { assert(element != null) { "Couldn't create source mapper for null element " + internalClassName } - val lineNumbers = CodegenUtil.getLineNumberForElement(element!!.getContainingFile(), true) - assert(lineNumbers != null) { "Couldn't extract line count in " + element.getContainingFile() } + val lineNumbers = CodegenUtil.getLineNumberForElement(element!!.containingFile, true) + assert(lineNumbers != null) { "Couldn't extract line count in " + element.containingFile } //TODO hack condition for package parts cleaning val isTopLevel = element is KtFile || (element is KtNamedFunction && element.getParent() is KtFile) val cleanedClassFqName = if (!isTopLevel) internalClassName else internalClassName.substringBefore('$') - return SourceInfo(element.getContainingKtFile().getName(), cleanedClassFqName, lineNumbers!!) + return SourceInfo(element.getContainingKtFile().name, cleanedClassFqName, lineNumbers!!) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt index 00e99b1a641..01bb24a56bc 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt @@ -44,7 +44,7 @@ class CoercionValue( } -public class StackValueWithLeaveTask( +class StackValueWithLeaveTask( val stackValue: StackValue, val leaveTasks: (StackValue) -> Unit ) : StackValue(stackValue.type) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/annotation/AnnotatedWithOnlyTargetedAnnotations.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/annotation/AnnotatedWithOnlyTargetedAnnotations.kt index 323c7f44751..cd34624f08a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/annotation/AnnotatedWithOnlyTargetedAnnotations.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/annotation/AnnotatedWithOnlyTargetedAnnotations.kt @@ -22,15 +22,15 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.FqName -public interface WrappedAnnotated : Annotated { - public val originalAnnotated: Annotated +interface WrappedAnnotated : Annotated { + val originalAnnotated: Annotated } -public class AnnotatedWithFakeAnnotations(override val originalAnnotated: Annotated, private val actual: Annotations) : WrappedAnnotated { +class AnnotatedWithFakeAnnotations(override val originalAnnotated: Annotated, private val actual: Annotations) : WrappedAnnotated { override fun getAnnotations() = actual } -public class AnnotatedWithOnlyTargetedAnnotations(private val original: Annotated) : Annotated { +class AnnotatedWithOnlyTargetedAnnotations(private val original: Annotated) : Annotated { private val annotations: Annotations = UseSiteTargetedAnnotations(original.annotations) override fun getAnnotations() = annotations @@ -52,4 +52,4 @@ public class AnnotatedWithOnlyTargetedAnnotations(private val original: Annotate } } -public class AnnotatedSimple(annotations: Annotations) : AnnotatedImpl(annotations) \ No newline at end of file +class AnnotatedSimple(annotations: Annotations) : AnnotatedImpl(annotations) \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt index 887591c0985..c52455180ea 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/builtinSpecialBridges.kt @@ -43,8 +43,7 @@ class BridgeForBuiltinSpecial( ) object BuiltinSpecialBridgesUtil { - @JvmStatic - public fun generateBridgesForBuiltinSpecial( + @JvmStatic fun generateBridgesForBuiltinSpecial( function: FunctionDescriptor, signatureByDescriptor: (FunctionDescriptor) -> Signature ): Set> { @@ -93,8 +92,7 @@ object BuiltinSpecialBridgesUtil { return bridges } - @JvmStatic - public fun FunctionDescriptor.shouldHaveTypeSafeBarrier( + @JvmStatic fun FunctionDescriptor.shouldHaveTypeSafeBarrier( signatureByDescriptor: (FunctionDescriptor) -> Signature ): Boolean { if (BuiltinMethodsWithSpecialGenericSignature.getDefaultValueForOverriddenBuiltinFunction(this) == null) return false @@ -143,7 +141,7 @@ private fun needGenerateSpecialBridge( && signatureByDescriptor(it) == overriddenBuiltinSignature } } -public fun isValueArgumentForCallToMethodWithTypeCheckBarrier( +fun isValueArgumentForCallToMethodWithTypeCheckBarrier( element: KtElement, bindingContext: BindingContext ): Boolean { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt index 2a0d78d2ce6..5144bba7074 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt @@ -103,7 +103,7 @@ private fun generateNullCheckForNonSafeAs( } } -public fun SpecialSignatureInfo.replaceValueParametersIn(sourceSignature: String?): String? +fun SpecialSignatureInfo.replaceValueParametersIn(sourceSignature: String?): String? = valueParametersSignature?.let { sourceSignature?.replace("^\\(.*\\)".toRegex(), "($it)") } fun populateCompanionBackingFieldNamesToOuterContextIfNeeded(companion: KtObjectDeclaration, outerContext: FieldOwnerContext<*>, state: GenerationState) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContextUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContextUtil.kt index 85ab092dbc5..8416192015e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContextUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContextUtil.kt @@ -18,16 +18,14 @@ package org.jetbrains.kotlin.codegen.context import org.jetbrains.org.objectweb.asm.Type -public object CodegenContextUtil { - @JvmStatic - public fun getImplementationOwnerClassType(owner: CodegenContext<*>): Type? = +object CodegenContextUtil { + @JvmStatic fun getImplementationOwnerClassType(owner: CodegenContext<*>): Type? = when (owner) { is MultifileClassFacadeContext -> owner.filePartType is DelegatingToPartContext -> owner.implementationOwnerClassType else -> null } - @JvmStatic - public fun isImplClassOwner(owner: CodegenContext<*>): Boolean = + @JvmStatic fun isImplClassOwner(owner: CodegenContext<*>): Boolean = owner !is MultifileClassFacadeContext } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ClassBuilderInterceptorExtension.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ClassBuilderInterceptorExtension.kt index 5d9b45ea4a0..9c103571c2b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ClassBuilderInterceptorExtension.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ClassBuilderInterceptorExtension.kt @@ -21,11 +21,11 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor import org.jetbrains.kotlin.resolve.BindingContext -public interface ClassBuilderInterceptorExtension { +interface ClassBuilderInterceptorExtension { companion object : ProjectExtensionDescriptor( "org.jetbrains.kotlin.classBuilderFactoryInterceptorExtension", ClassBuilderInterceptorExtension::class.java) - public fun interceptClassBuilderFactory( + fun interceptClassBuilderFactory( interceptedFactory: ClassBuilderFactory, bindingContext: BindingContext, diagnostics: DiagnosticSink diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ExpressionCodegenExtension.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ExpressionCodegenExtension.kt index 277bf1d562c..8a2d4f957b6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ExpressionCodegenExtension.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/extensions/ExpressionCodegenExtension.kt @@ -26,28 +26,28 @@ import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.descriptors.* -public interface ExpressionCodegenExtension { +interface ExpressionCodegenExtension { companion object : ProjectExtensionDescriptor( "org.jetbrains.kotlin.expressionCodegenExtension", ExpressionCodegenExtension::class.java) - public class Context( - public val typeMapper: JetTypeMapper, - public val v: InstructionAdapter + class Context( + val typeMapper: JetTypeMapper, + val v: InstructionAdapter ) /** * Used for generating custom byte code for the property value obtain. This function has lazy semantics. * Returns new stack value. */ - public fun applyProperty(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null + fun applyProperty(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null /** * Used for generating custom byte code for the function call. This function has lazy semantics. * Returns new stack value. */ - public fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null + fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null - public fun generateClassSyntheticParts( + fun generateClassSyntheticParts( classBuilder: ClassBuilder, state: GenerationState, classOrObject: KtClassOrObject, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt index 1971971d491..12a740b4dae 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt @@ -25,26 +25,26 @@ import org.jetbrains.org.objectweb.asm.tree.* import java.util.Comparator import java.util.Collections -public abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { +abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { - public val tryBlocksMetaInfo: IntervalMetaInfo = IntervalMetaInfo() + val tryBlocksMetaInfo: IntervalMetaInfo = IntervalMetaInfo() - public val localVarsMetaInfo: IntervalMetaInfo = IntervalMetaInfo() + val localVarsMetaInfo: IntervalMetaInfo = IntervalMetaInfo() - public var nextFreeLocalIndex: Int = parameterSize + var nextFreeLocalIndex: Int = parameterSize private set - public fun getStartNodes(label: LabelNode): List { + fun getStartNodes(label: LabelNode): List { return tryBlocksMetaInfo.intervalStarts.get(label) } - public fun getEndNodes(label: LabelNode): List { + fun getEndNodes(label: LabelNode): List { return tryBlocksMetaInfo.intervalEnds.get(label) } - public open fun processInstruction(curInstr: AbstractInsnNode, directOrder: Boolean) { + open fun processInstruction(curInstr: AbstractInsnNode, directOrder: Boolean) { if (curInstr is VarInsnNode || curInstr is IincInsnNode) { - val argSize = InlineCodegenUtil.getLoadStoreArgSize(curInstr.getOpcode()) + val argSize = InlineCodegenUtil.getLoadStoreArgSize(curInstr.opcode) val varIndex = if (curInstr is VarInsnNode) curInstr.`var` else (curInstr as IincInsnNode).`var` nextFreeLocalIndex = Math.max(nextFreeLocalIndex, varIndex + argSize) } @@ -55,9 +55,9 @@ public abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { } } - public abstract fun instructionIndex(inst: AbstractInsnNode): Int + abstract fun instructionIndex(inst: AbstractInsnNode): Int - public fun sortTryCatchBlocks(intervals: List): List { + fun sortTryCatchBlocks(intervals: List): List { val comp = Comparator { t1: TryCatchBlockNodeInfo, t2: TryCatchBlockNodeInfo -> var result = instructionIndex(t1.handler) - instructionIndex(t2.handler) if (result == 0) { @@ -83,7 +83,7 @@ public abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { } - public fun substituteLocalVarTable(node: MethodNode) { + fun substituteLocalVarTable(node: MethodNode) { node.localVariables.clear() for (info in localVarsMetaInfo.getMeaningfulIntervals()) { node.localVariables.add(info.node) @@ -165,16 +165,16 @@ private fun Interval.isMeaningless(): Boolean { val start = this.startLabel var end: AbstractInsnNode = this.endLabel while (end != start && !end.isMeaningful) { - end = end.getPrevious() + end = end.previous } return start == end } -public fun > IntervalMetaInfo.getMeaningfulIntervals(): List { +fun > IntervalMetaInfo.getMeaningfulIntervals(): List { return allIntervals.filterNot { it.isMeaningless() } } -public class DefaultProcessor(val node: MethodNode, parameterSize: Int) : CoveringTryCatchNodeProcessor(parameterSize) { +class DefaultProcessor(val node: MethodNode, parameterSize: Int) : CoveringTryCatchNodeProcessor(parameterSize) { init { node.tryCatchBlocks.forEach { addTryNode(it) } @@ -194,7 +194,7 @@ public class DefaultProcessor(val node: MethodNode, parameterSize: Int) : Coveri } } -public class LocalVarNodeWrapper(val node: LocalVariableNode) : Interval, SplittableInterval { +class LocalVarNodeWrapper(val node: LocalVariableNode) : Interval, SplittableInterval { override val startLabel: LabelNode get() = node.start override val endLabel: LabelNode diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/DeferredMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/DeferredMethodVisitor.kt index 4cd6db29ebe..f2dba7275a1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/DeferredMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/DeferredMethodVisitor.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.inline import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.tree.MethodNode -public class DeferredMethodVisitor( +class DeferredMethodVisitor( val intermediate: MethodNode, val resultNode: () -> MethodVisitor ) : MethodVisitor(InlineCodegenUtil.API, intermediate) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/Parameters.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/Parameters.kt index e9572e62db9..21aeea9c2da 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/Parameters.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/Parameters.kt @@ -24,10 +24,10 @@ internal class Parameters(val real: List, val captured: List private val paramToDeclByteCodeIndex: HashMap = hashMapOf() - public val realArgsSizeOnStack = real.sumBy { it.type.size } - public val capturedArgsSizeOnStack = captured.sumBy { it.type.size } + val realArgsSizeOnStack = real.sumBy { it.type.size } + val capturedArgsSizeOnStack = captured.sumBy { it.type.size } - public val argsSizeOnStack = realArgsSizeOnStack + capturedArgsSizeOnStack + val argsSizeOnStack = realArgsSizeOnStack + capturedArgsSizeOnStack init { val declIndexesToActual = arrayOfNulls(argsSizeOnStack) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt index cb2b531d5ea..377fd7f5652 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt @@ -33,7 +33,7 @@ import org.jetbrains.org.objectweb.asm.tree.* private class ParameterNameAndNullability(val name: String, val nullable: Boolean) -public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParameterMappings?) { +class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParameterMappings?) { enum class OperationKind { NEW_ARRAY, AS, SAFE_AS, IS, JAVA_CLASS; @@ -43,25 +43,21 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame } companion object { - @JvmField - public val REIFIED_OPERATION_MARKER_METHOD_NAME = "reifiedOperationMarker" - @JvmField - public val NEED_CLASS_REIFICATION_MARKER_METHOD_NAME = "needClassReification" + @JvmField val REIFIED_OPERATION_MARKER_METHOD_NAME = "reifiedOperationMarker" + @JvmField val NEED_CLASS_REIFICATION_MARKER_METHOD_NAME = "needClassReification" private fun isOperationReifiedMarker(insn: AbstractInsnNode) = isReifiedMarker(insn) { it == REIFIED_OPERATION_MARKER_METHOD_NAME } private fun isReifiedMarker(insn: AbstractInsnNode, namePredicate: (String) -> Boolean): Boolean { - if (insn.getOpcode() != Opcodes.INVOKESTATIC || insn !is MethodInsnNode) return false + if (insn.opcode != Opcodes.INVOKESTATIC || insn !is MethodInsnNode) return false return insn.owner == IntrinsicMethods.INTRINSICS_CLASS_NAME && namePredicate(insn.name) } - @JvmStatic - public fun isNeedClassReificationMarker(insn: AbstractInsnNode): Boolean = + @JvmStatic fun isNeedClassReificationMarker(insn: AbstractInsnNode): Boolean = isReifiedMarker(insn) { s -> s == NEED_CLASS_REIFICATION_MARKER_METHOD_NAME } - @JvmStatic - public fun putNeedClassReificationMarker(v: MethodVisitor) { + @JvmStatic fun putNeedClassReificationMarker(v: MethodVisitor) { v.visitMethodInsn( Opcodes.INVOKESTATIC, IntrinsicMethods.INTRINSICS_CLASS_NAME, NEED_CLASS_REIFICATION_MARKER_METHOD_NAME, @@ -77,7 +73,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame * e.g. when we're generating inline function containing reified T * and another function containing reifiable parts is inlined into that function */ - public fun reifyInstructions(node: MethodNode): ReifiedTypeParametersUsages { + fun reifyInstructions(node: MethodNode): ReifiedTypeParametersUsages { if (parametersMapping == null) return ReifiedTypeParametersUsages() val instructions = node.instructions maxStackSize = 0 @@ -95,7 +91,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame return result } - public fun reifySignature(oldSignature: String): SignatureReificationResult { + fun reifySignature(oldSignature: String): SignatureReificationResult { if (parametersMapping == null) return SignatureReificationResult(oldSignature, ReifiedTypeParametersUsages()) val signatureRemapper = object : SignatureWriter() { @@ -223,13 +219,13 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame } private fun processNextTypeInsn(insn: MethodInsnNode, parameter: Type, expectedNextOpcode: Int): Boolean { - if (insn.getNext()?.getOpcode() != expectedNextOpcode) return false - (insn.getNext() as TypeInsnNode).desc = parameter.getInternalName() + if (insn.next?.opcode != expectedNextOpcode) return false + (insn.next as TypeInsnNode).desc = parameter.internalName return true } private fun processJavaClass(insn: MethodInsnNode, parameter: Type): Boolean { - val next = insn.getNext() + val next = insn.next if (next !is LdcInsnNode) return false next.cst = parameter return true @@ -255,14 +251,14 @@ private val MethodInsnNode.operationKind: ReifiedTypeInliner.OperationKind? get( ReifiedTypeInliner.OperationKind.values().getOrNull(it) } -public class ReifiedTypeParameterMappings() { +class ReifiedTypeParameterMappings() { private val mappingsByName = hashMapOf() - public fun addParameterMappingToType(name: String, type: KotlinType, asmType: Type, signature: String) { + fun addParameterMappingToType(name: String, type: KotlinType, asmType: Type, signature: String) { mappingsByName[name] = ReifiedTypeParameterMapping(name, type, asmType, newName = null, signature = signature) } - public fun addParameterMappingToNewParameter(name: String, type: KotlinType, newName: String) { + fun addParameterMappingToNewParameter(name: String, type: KotlinType, newName: String) { mappingsByName[name] = ReifiedTypeParameterMapping(name, type = type, asmType = null, newName = newName, signature = null) } @@ -271,20 +267,20 @@ public class ReifiedTypeParameterMappings() { } } -public class ReifiedTypeParameterMapping( +class ReifiedTypeParameterMapping( val name: String, val type: KotlinType, val asmType: Type?, val newName: String?, val signature: String? ) -public class ReifiedTypeParametersUsages { +class ReifiedTypeParametersUsages { val usedTypeParameters: MutableSet = hashSetOf() - public fun wereUsedReifiedParameters(): Boolean = usedTypeParameters.isNotEmpty() + fun wereUsedReifiedParameters(): Boolean = usedTypeParameters.isNotEmpty() - public fun addUsedReifiedParameter(name: String) { + fun addUsedReifiedParameter(name: String) { usedTypeParameters.add(name) } - public fun propagateChildUsagesWithinContext(child: ReifiedTypeParametersUsages, context: MethodContext) { + fun propagateChildUsagesWithinContext(child: ReifiedTypeParametersUsages, context: MethodContext) { if (!child.wereUsedReifiedParameters()) return // used for propagating reified TP usages from children member codegen to parent's // mark enclosing object-literal/lambda as needed reification iff @@ -298,7 +294,7 @@ public class ReifiedTypeParametersUsages { }.forEach { usedTypeParameters.add(it) } } - public fun mergeAll(other: ReifiedTypeParametersUsages) { + fun mergeAll(other: ReifiedTypeParametersUsages) { if (!other.wereUsedReifiedParameters()) return usedTypeParameters.addAll(other.usedTypeParameters) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt index d1636e7b94c..4c16c4ffbd7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt @@ -24,7 +24,7 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor import java.util.* //TODO join parameter -public class SMAPBuilder(val source: String, +class SMAPBuilder(val source: String, val path: String, val fileMappings: List) { @@ -62,7 +62,7 @@ public class SMAPBuilder(val source: String, } } -public open class NestedSourceMapper(parent: SourceMapper, val ranges: List, sourceInfo: SourceInfo) : DefaultSourceMapper(sourceInfo, parent) { +open class NestedSourceMapper(parent: SourceMapper, val ranges: List, sourceInfo: SourceInfo) : DefaultSourceMapper(sourceInfo, parent) { override fun visitLineNumber(iv: MethodVisitor, lineNumber: Int, start: Label) { val index = Collections.binarySearch(ranges, RangeMapping(lineNumber, lineNumber, 1)) { @@ -81,7 +81,7 @@ public open class NestedSourceMapper(parent: SourceMapper, val ranges: List get() = emptyList() @@ -178,7 +178,7 @@ public object IdenticalSourceMapper : SourceMapper { } } -public open class DefaultSourceMapper(val sourceInfo: SourceInfo, override val parent: SourceMapper?): SourceMapper { +open class DefaultSourceMapper(val sourceInfo: SourceInfo, override val parent: SourceMapper?): SourceMapper { protected var maxUsedValue: Int = sourceInfo.linesInFile @@ -273,7 +273,7 @@ class RawFileMapping(val name: String, val path: String) { } fun initRange(start: Int, end: Int) { - assert(lineMappings.isEmpty()) { "initRange should only be called for empty mapping" } + assert(lineMappings.isEmpty) { "initRange should only be called for empty mapping" } for (index in start..end) { lineMappings.put(index, index) } @@ -319,7 +319,7 @@ class RawFileMapping(val name: String, val path: String) { } } -open public class FileMapping(val name: String, val path: String) { +open class FileMapping(val name: String, val path: String) { val lineMappings = arrayListOf() var id = -1; @@ -329,7 +329,7 @@ open public class FileMapping(val name: String, val path: String) { lineMapping.parent = this } - public object SKIP : FileMapping("no-source-info", "no-source-info") { + object SKIP : FileMapping("no-source-info", "no-source-info") { init { addRangeMapping(RangeMapping.SKIP) } @@ -337,7 +337,7 @@ open public class FileMapping(val name: String, val path: String) { } //TODO comparable -data public class RangeMapping(val source: Int, val dest: Int, var range: Int = 1) { +data class RangeMapping(val source: Int, val dest: Int, var range: Int = 1) { var parent: FileMapping? = null; @@ -366,6 +366,6 @@ data public class RangeMapping(val source: Int, val dest: Int, var range: Int = } companion object { - public val SKIP = RangeMapping(-1, -1, 1) + val SKIP = RangeMapping(-1, -1, 1) } } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPAndMethodNode.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPAndMethodNode.kt index 6ab9f0511d2..250e6ffe377 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPAndMethodNode.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPAndMethodNode.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.codegen.SourceInfo class SMAPAndMethodNode(val node: MethodNode, val classSMAP: SMAP) { val lineNumbers = - InsnSequence(node.instructions.getFirst(), null).filterIsInstance().map { + InsnSequence(node.instructions.first, null).filterIsInstance().map { val index = Collections.binarySearch(classSMAP.intervals, RangeMapping(it.line, it.line, 1)) { value, key -> if (value.contains(key.dest)) 0 else RangeMapping.Comparator.compare(value, key) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPParser.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPParser.kt index 7878ae59e1d..99249300cc6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPParser.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAPParser.kt @@ -21,8 +21,7 @@ import com.intellij.util.SmartFMap object SMAPParser { @JvmStatic - /*null smap means that there is no any debug info in file (e.g. sourceName)*/ - public fun parseOrCreateDefault(mappingInfo: String?, source: String?, path: String, methodStartLine: Int, methodEndLine: Int): SMAP { + /*null smap means that there is no any debug info in file (e.g. sourceName)*/ fun parseOrCreateDefault(mappingInfo: String?, source: String?, path: String, methodStartLine: Int, methodEndLine: Int): SMAP { if (mappingInfo == null || mappingInfo.isEmpty()) { val fm: FileMapping if (source == null || source.isEmpty()) { @@ -40,8 +39,7 @@ object SMAPParser { return parse(mappingInfo) } - @JvmStatic - public fun parse(mappingInfo: String): SMAP { + @JvmStatic fun parse(mappingInfo: String): SMAP { val fileMappings = linkedMapOf() val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TryBlockClustering.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TryBlockClustering.kt index 462f770ada9..9df968012d4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TryBlockClustering.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TryBlockClustering.kt @@ -26,7 +26,7 @@ enum class TryCatchPosition { INNER } -public class SplitPair(val patchedPart: T, val newPart: T) +class SplitPair(val patchedPart: T, val newPart: T) class SimpleInterval(override val startLabel: LabelNode, override val endLabel: LabelNode ) : Interval @@ -35,7 +35,7 @@ interface Interval { val endLabel: LabelNode /*note that some intervals are mutable */ - public fun isEmpty(): Boolean = startLabel == endLabel + fun isEmpty(): Boolean = startLabel == endLabel } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt index c2a050d275e..1215f90fefd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt @@ -27,14 +27,14 @@ import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor -public val FunctionDescriptor.sourceFilePath: String +val FunctionDescriptor.sourceFilePath: String get() { val source = source as PsiSourceElement val containingFile = source.psi?.containingFile return containingFile?.virtualFile?.canonicalPath!! } -public fun FunctionDescriptor.getClassFilePath(typeMapper: JetTypeMapper, cache: IncrementalCache): String { +fun FunctionDescriptor.getClassFilePath(typeMapper: JetTypeMapper, cache: IncrementalCache): String { val container = containingDeclaration as? DeclarationDescriptorWithSource val source = container?.source diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayGet.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayGet.kt index a0c2217aa26..39c291b2518 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayGet.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayGet.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil.correctElementType import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class ArrayGet : IntrinsicMethod() { +class ArrayGet : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createIntrinsicCallable(method) { val type = correctElementType(calcReceiverType()) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayIterator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayIterator.kt index 785129ecff9..78a3a71d8d2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayIterator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArrayIterator.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class ArrayIterator : IntrinsicMethod() { +class ArrayIterator : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createUnaryIntrinsicCallable(method) { - val methodSignature = "(${method.owner.getDescriptor()})${returnType.getDescriptor()}" + val methodSignature = "(${method.owner.descriptor})${returnType.descriptor}" val intrinsicOwner = if (AsmUtil.isPrimitive(method.owner.elementType)) "kotlin/jvm/internal/ArrayIteratorsKt" diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt index 661678df1c1..ff1a2d7b5f0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class ArraySet : IntrinsicMethod() { +class ArraySet : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { val type = correctElementType(method.dispatchReceiverType) return object : IntrinsicCallable( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySize.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySize.kt index a3ce902f8b8..931ab5d3851 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySize.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySize.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.org.objectweb.asm.Type -public class ArraySize : IntrinsicPropertyGetter() { +class ArraySize : IntrinsicPropertyGetter() { override fun generate( resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, receiver: StackValue ) = StackValue.operation(returnType) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt index d1838b861e2..d5d4f12ed90 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt @@ -25,7 +25,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes.ISHR import org.jetbrains.org.objectweb.asm.Opcodes.IUSHR import org.jetbrains.org.objectweb.asm.Type -public class BinaryOp(private val opcode: Int) : IntrinsicMethod() { +class BinaryOp(private val opcode: Int) : IntrinsicMethod() { private fun shift(): Boolean = opcode == ISHL || opcode == ISHR || opcode == IUSHR diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Clone.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Clone.kt index 6f8e19686e1..1d07689de71 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Clone.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Clone.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE import org.jetbrains.org.objectweb.asm.Opcodes -public class Clone : IntrinsicMethod() { +class Clone : IntrinsicMethod() { override fun toCallable(method: CallableMethod, isSuperCall: Boolean): Callable = createUnaryIntrinsicCallable(method, OBJECT_TYPE) { val opcode = if (isSuperCall) Opcodes.INVOKESPECIAL else Opcodes.INVOKEVIRTUAL diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt index 1efcbba662c..a24c15e84f9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class CompareTo : IntrinsicMethod() { +class CompareTo : IntrinsicMethod() { private fun genInvoke(type: Type?, v: InstructionAdapter) { when (type) { Type.INT_TYPE -> v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(II)I", false) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Concat.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Concat.kt index 586083826fb..8e0b804bb93 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Concat.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Concat.kt @@ -31,7 +31,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class Concat : IntrinsicMethod() { +class Concat : IntrinsicMethod() { fun generateImpl( codegen: ExpressionCodegen, v: InstructionAdapter, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt index bba863b13a4..dae2903af2c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE -public class Equals : IntrinsicMethod() { +class Equals : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createBinaryIntrinsicCallable( method.returnType, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt index 22c7d2628ba..d0843622ee6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt @@ -22,7 +22,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class HashCode : IntrinsicMethod() { +class HashCode : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = object : IntrinsicCallable( Type.INT_TYPE, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IdentityEquals.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IdentityEquals.kt index 7fed3f13b64..c3989013330 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IdentityEquals.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IdentityEquals.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE -public class IdentityEquals : IntrinsicMethod() { +class IdentityEquals : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = object : IntrinsicCallable(method) { override fun invokeMethodWithArguments( @@ -34,17 +34,17 @@ public class IdentityEquals : IntrinsicMethod() { receiver: StackValue, codegen: ExpressionCodegen ): StackValue { - val element = resolvedCall.getCall().getCallElement() + val element = resolvedCall.call.callElement val left: StackValue val right: StackValue if (element is KtCallExpression) { left = StackValue.receiver(resolvedCall, receiver, codegen, this) - right = codegen.gen(resolvedCall.getValueArgumentsByIndex()!!.single().getArguments().single().getArgumentExpression()) + right = codegen.gen(resolvedCall.valueArgumentsByIndex!!.single().arguments.single().getArgumentExpression()) } else { element as KtBinaryExpression - left = codegen.gen(element.getLeft()) - right = codegen.gen(element.getRight()) + left = codegen.gen(element.left) + right = codegen.gen(element.right) } return StackValue.cmp(KtTokens.EQEQEQ, OBJECT_TYPE, left, right) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt index 566f640de35..dc8a135de96 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt @@ -22,11 +22,11 @@ import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.kotlin.psi.KtPrefixExpression import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -public class Increment(private val myDelta: Int) : IntrinsicMethod() { +class Increment(private val myDelta: Int) : IntrinsicMethod() { override fun toCallable(method: CallableMethod, isSuper: Boolean, resolvedCall: ResolvedCall<*>): Callable = createIntrinsicCallable(method) { - val jetExpression = resolvedCall.getCall().getCalleeExpression() - assert(jetExpression !is KtPrefixExpression) { "There should be postfix increment ${jetExpression!!.getText()}" } + val jetExpression = resolvedCall.call.calleeExpression + assert(jetExpression !is KtPrefixExpression) { "There should be postfix increment ${jetExpression!!.text}" } genIncrement(returnType, myDelta, it) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt index ece3de1bef8..11e98d1fd00 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public open class IntrinsicCallable( +open class IntrinsicCallable( override val returnType: Type, override val valueParameterTypes: List, override val dispatchReceiverType: Type?, @@ -45,7 +45,7 @@ public open class IntrinsicCallable( invokeIntrinsic(v) } - public open fun invokeIntrinsic(v: InstructionAdapter) { + open fun invokeIntrinsic(v: InstructionAdapter) { invoke(v) } @@ -60,7 +60,7 @@ public open class IntrinsicCallable( override val owner: Type get() = throw UnsupportedOperationException() - public fun calcReceiverType(): Type = + fun calcReceiverType(): Type = extensionReceiverType ?: dispatchReceiverType!! } @@ -80,7 +80,7 @@ fun createBinaryIntrinsicCallable( } } -public fun createUnaryIntrinsicCallable( +fun createUnaryIntrinsicCallable( callable: CallableMethod, newReturnType: Type? = null, needPrimitiveCheck: Boolean = false, @@ -103,7 +103,7 @@ public fun createUnaryIntrinsicCallable( return intrinsic } -public fun createIntrinsicCallable( +fun createIntrinsicCallable( callable: CallableMethod, invoke: IntrinsicCallable.(v: InstructionAdapter) -> Unit ): IntrinsicCallable { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicPropertyGetter.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicPropertyGetter.kt index fed6580a3e8..b7eb4f5b559 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicPropertyGetter.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicPropertyGetter.kt @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.org.objectweb.asm.Type -public abstract class IntrinsicPropertyGetter : IntrinsicMethod() { - public abstract fun generate( +abstract class IntrinsicPropertyGetter : IntrinsicMethod() { + abstract fun generate( resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt index b788fcf6622..5afc75c05bd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.org.objectweb.asm.Type -public class Inv : IntrinsicMethod() { +class Inv : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { val type = numberFunctionOperandType(method.returnType) return createUnaryIntrinsicCallable(method, newThisType = type) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt index 09be848ce53..a8e20a9094b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class IteratorNext : IntrinsicMethod() { +class IteratorNext : IntrinsicMethod() { private fun getIteratorName(returnType: Type): String { return when (returnType) { Type.CHAR_TYPE -> "Char" @@ -47,7 +47,7 @@ public class IteratorNext : IntrinsicMethod() { v.invokevirtual( BUILT_INS_PACKAGE_FQ_NAME.asString() + "/" + name + "Iterator", "next$name", - "()" + returnType.getDescriptor(), + "()" + returnType.descriptor, false ) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassArray.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassArray.kt index 5a2853ff4d6..24e2f8923fe 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassArray.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassArray.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class JavaClassArray : IntrinsicMethod() { +class JavaClassArray : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createIntrinsicCallable(method) { //do nothing all generated as vararg diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassFunction.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassFunction.kt index 09e9d22215d..28157f6c9c3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassFunction.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassFunction.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class JavaClassFunction : IntrinsicMethod() { +class JavaClassFunction : IntrinsicMethod() { override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable { - val javaClass = resolvedCall.getResultingDescriptor().getReturnType()!!.getArguments().first().getType() + val javaClass = resolvedCall.resultingDescriptor.returnType!!.arguments.first().type return object : IntrinsicCallable(getType(Class::class.java), listOf(), null, null) { override fun invokeIntrinsic(v: InstructionAdapter) { codegen.putReifiedOperationMarkerIfTypeIsReifiedParameter(javaClass, ReifiedTypeInliner.OperationKind.JAVA_CLASS) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassProperty.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassProperty.kt index dd4fb6b76be..98a4ce523e8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassProperty.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/JavaClassProperty.kt @@ -28,8 +28,8 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class JavaClassProperty : IntrinsicPropertyGetter() { - public override fun generate( +class JavaClassProperty : IntrinsicPropertyGetter() { + override fun generate( resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, @@ -47,7 +47,7 @@ public class JavaClassProperty : IntrinsicPropertyGetter() { receiver.put(type, v) AsmUtil.pop(v, type) } - v.getstatic(boxType(type).getInternalName(), "TYPE", "Ljava/lang/Class;") + v.getstatic(boxType(type).internalName, "TYPE", "Ljava/lang/Class;") } else { receiver.put(type, v) @@ -58,11 +58,11 @@ public class JavaClassProperty : IntrinsicPropertyGetter() { } override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable { - val classType = codegen.getState().typeMapper.mapType(resolvedCall.getCall().getDispatchReceiver()!!.getType()) + val classType = codegen.getState().typeMapper.mapType(resolvedCall.call.dispatchReceiver!!.type) return object : IntrinsicCallable(getType(Class::class.java), listOf(), classType, null) { override fun invokeIntrinsic(v: InstructionAdapter) { if (isPrimitive(classType)) { - v.getstatic(boxType(classType).getInternalName(), "TYPE", "Ljava/lang/Class;") + v.getstatic(boxType(classType).internalName, "TYPE", "Ljava/lang/Class;") } else { v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt index 3a00838e5ea..544524978ec 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class KClassJavaProperty : IntrinsicPropertyGetter() { +class KClassJavaProperty : IntrinsicPropertyGetter() { override fun generate(resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, receiver: StackValue): StackValue? { val extensionReceiver = resolvedCall!!.extensionReceiver as ReceiverValue val type = extensionReceiver.type.arguments.single().type diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NewArray.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NewArray.kt index 7744c6673a2..8002ac6b1df 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NewArray.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NewArray.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class NewArray : IntrinsicMethod() { +class NewArray : IntrinsicMethod() { override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable { - val jetType = resolvedCall.getResultingDescriptor().getReturnType()!! + val jetType = resolvedCall.resultingDescriptor.returnType!! val type = codegen.getState().typeMapper.mapType(jetType) return object : IntrinsicCallable(type, listOf(Type.INT_TYPE), null, null) { override fun invokeIntrinsic(v: InstructionAdapter) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Not.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Not.kt index b6812e9ab60..6db8e08f031 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Not.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Not.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.kotlin.psi.KtPrefixExpression import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -public class Not : IntrinsicMethod() { +class Not : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = object : IntrinsicCallable(method) { override fun invokeMethodWithArguments( @@ -31,10 +31,10 @@ public class Not : IntrinsicMethod() { receiver: StackValue, codegen: ExpressionCodegen ): StackValue { - val element = resolvedCall.getCall().getCallElement() + val element = resolvedCall.call.callElement val stackValue = if (element is KtPrefixExpression) { - codegen.gen(element.getBaseExpression()) + codegen.gen(element.baseExpression) } else { StackValue.receiver(resolvedCall, receiver, codegen, this) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt index 5014246f62c..c207cadef30 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod import org.jetbrains.kotlin.codegen.StackValue -public class NumberCast : IntrinsicMethod() { +class NumberCast : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createUnaryIntrinsicCallable(method) { StackValue.coerce(calcReceiverType(), returnType, it) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt index 8c900a29558..36dca6d3b0d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt @@ -23,7 +23,7 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.Type.* import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public class RangeTo : IntrinsicMethod() { +class RangeTo : IntrinsicMethod() { private fun nameToPrimitive(name: String): Type = when (name) { "Double" -> DOUBLE_TYPE @@ -37,7 +37,7 @@ public class RangeTo : IntrinsicMethod() { } override fun toCallable(method: CallableMethod): Callable { - val argType = nameToPrimitive(method.returnType.getInternalName().substringAfter("kotlin/").substringBefore("Range")) + val argType = nameToPrimitive(method.returnType.internalName.substringAfter("kotlin/").substringBefore("Range")) return object : IntrinsicCallable( method.returnType, method.valueParameterTypes.map { argType }, @@ -60,7 +60,7 @@ public class RangeTo : IntrinsicMethod() { } override fun invokeIntrinsic(v: InstructionAdapter) { - v.invokespecial(returnType.getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE, argType, argType), false) + v.invokespecial(returnType.internalName, "", Type.getMethodDescriptor(Type.VOID_TYPE, argType, argType), false) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringGetChar.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringGetChar.kt index 61f7e6b3b86..83050406970 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringGetChar.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringGetChar.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class StringGetChar : IntrinsicMethod() { +class StringGetChar : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createIntrinsicCallable(method) { it.invokevirtual("java/lang/String", "charAt", "(I)C", false) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringPlus.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringPlus.kt index b534eedbdaa..dd256a277bc 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringPlus.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/StringPlus.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class StringPlus : IntrinsicMethod() { +class StringPlus : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createIntrinsicCallable(method) { it.invokestatic("kotlin/jvm/internal/Intrinsics", "stringPlus", diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt index 691790c8244..f291f991d2f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt @@ -20,11 +20,11 @@ import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class ToString : IntrinsicMethod() { +class ToString : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { val type = AsmUtil.stringValueOfType(method.dispatchReceiverType ?: method.extensionReceiverType) return createUnaryIntrinsicCallable(method, newThisType = type) { - it.invokestatic("java/lang/String", "valueOf", "(${type.getDescriptor()})Ljava/lang/String;", false) + it.invokestatic("java/lang/String", "valueOf", "(${type.descriptor})Ljava/lang/String;", false) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt index e162d9fc295..61a10646b1d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt @@ -25,8 +25,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.tree.* import kotlin.text.Regex -public object TypeIntrinsics { - public @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: KotlinType, boxedAsmType: Type) { +object TypeIntrinsics { + @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: KotlinType, boxedAsmType: Type) { val functionTypeArity = getFunctionTypeArity(jetType) if (functionTypeArity >= 0) { v.iconst(functionTypeArity) @@ -57,7 +57,7 @@ public object TypeIntrinsics { LdcInsnNode(Integer(value)) } - public @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type) { + @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type) { val functionTypeArity = getFunctionTypeArity(jetType) if (functionTypeArity >= 0) { instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity)) @@ -78,8 +78,7 @@ public object TypeIntrinsics { instanceofInsn.desc = asmType.internalName } - @JvmStatic - public fun checkcast( + @JvmStatic fun checkcast( v: InstructionAdapter, kotlinType: KotlinType, asmType: Type, // This parameter is just for sake of optimization: diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt index 1a8578daa21..9cf3a239c6a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class UnaryMinus : IntrinsicMethod() { +class UnaryMinus : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createUnaryIntrinsicCallable(method, numberFunctionOperandType(method.returnType), needPrimitiveCheck = true) { it.neg(returnType) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryPlus.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryPlus.kt index e5981092f09..f775557540b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryPlus.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryPlus.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -public class UnaryPlus : IntrinsicMethod() { +class UnaryPlus : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createUnaryIntrinsicCallable(method) { //nothing diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/DeadCodeEliminationMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/DeadCodeEliminationMethodTransformer.kt index 86b08a18827..3fd369385d5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/DeadCodeEliminationMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/DeadCodeEliminationMethodTransformer.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful -public class DeadCodeEliminationMethodTransformer : MethodTransformer() { +class DeadCodeEliminationMethodTransformer : MethodTransformer() { override fun transform(internalClassName: String, methodNode: MethodNode) { val frames = MethodTransformer.analyze(internalClassName, methodNode, OptimizationBasicInterpreter()) val insnList = methodNode.instructions diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt index 46493588d6f..81a7bb8c945 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer import org.jetbrains.org.objectweb.asm.Label import org.jetbrains.org.objectweb.asm.tree.* -public class LabelNormalizationMethodTransformer : MethodTransformer() { - public override fun transform(internalClassName: String, methodNode: MethodNode) { +class LabelNormalizationMethodTransformer : MethodTransformer() { + override fun transform(internalClassName: String, methodNode: MethodNode) { TransformerForMethod(methodNode).transform() } @@ -29,7 +29,7 @@ public class LabelNormalizationMethodTransformer : MethodTransformer() { val instructions = methodNode.instructions val newLabelNodes = hashMapOf() - public fun transform() { + fun transform() { if (rewriteLabelInstructions()) { rewriteNonLabelInstructions() rewriteTryCatchBlocks() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt index ccf606a6042..29cbb66ddd5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt @@ -20,11 +20,11 @@ import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransfor import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer import org.jetbrains.org.objectweb.asm.tree.MethodNode -public class MandatoryMethodTransformer : MethodTransformer() { +class MandatoryMethodTransformer : MethodTransformer() { private val labelNormalization = LabelNormalizationMethodTransformer() private val fixStack = FixStackMethodTransformer() - public override fun transform(internalClassName: String, methodNode: MethodNode) { + override fun transform(internalClassName: String, methodNode: MethodNode) { labelNormalization.transform(internalClassName, methodNode) fixStack.transform(internalClassName, methodNode) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt index 1d33a8675d4..72043f4a3b1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt @@ -24,7 +24,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.tree.JumpInsnNode import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful -public class RedundantGotoMethodTransformer : MethodTransformer() { +class RedundantGotoMethodTransformer : MethodTransformer() { /** * Removes redundant GOTO's, i.e. to subsequent labels */ @@ -35,7 +35,7 @@ public class RedundantGotoMethodTransformer : MethodTransformer() { val currentLabels = hashSetOf() for (insn in insns) { if (insn.isMeaningful) { - if (insn.getOpcode() == Opcodes.GOTO && (insn as JumpInsnNode).label in currentLabels) { + if (insn.opcode == Opcodes.GOTO && (insn as JumpInsnNode).label in currentLabels) { insnsToRemove.add(insn) } else { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/NullabilityInterpreter.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/NullabilityInterpreter.kt index b637309f74f..e3a1d80cc07 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/NullabilityInterpreter.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/NullabilityInterpreter.kt @@ -23,7 +23,7 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode import org.jetbrains.org.objectweb.asm.Opcodes -public class NullabilityInterpreter(insns: InsnList) : BoxingInterpreter(insns) { +class NullabilityInterpreter(insns: InsnList) : BoxingInterpreter(insns) { override fun unaryOperation(insn: AbstractInsnNode, value: BasicValue) = makeNotNullIfNeeded(insn, super.unaryOperation(insn, value)) override fun newOperation(insn: AbstractInsnNode) = makeNotNullIfNeeded(insn, super.newOperation(insn)) @@ -35,7 +35,7 @@ public class NullabilityInterpreter(insns: InsnList) : BoxingInterpreter(insns) } private fun makeNotNullIfNeeded(insn: AbstractInsnNode, value: BasicValue?): BasicValue? = - when (insn.getOpcode()) { + when (insn.opcode) { Opcodes.ANEWARRAY, Opcodes.NEWARRAY, Opcodes.LDC, Opcodes.NEW -> NotNullBasicValue(value) else -> value } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt index 1a6cd5f70c1..6d8c917428f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt @@ -25,15 +25,15 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter import org.jetbrains.org.objectweb.asm.tree.analysis.Value import java.util.* -public open class MethodAnalyzer( - public val owner: String, - public val method: MethodNode, +open class MethodAnalyzer( + val owner: String, + val method: MethodNode, protected val interpreter: Interpreter ) { - public val instructions: InsnList = method.instructions - public val nInsns: Int = instructions.size() + val instructions: InsnList = method.instructions + val nInsns: Int = instructions.size() - public val frames: Array?> = arrayOfNulls(nInsns) + val frames: Array?> = arrayOfNulls(nInsns) private val handlers: Array?> = arrayOfNulls(nInsns) private val queued: BooleanArray = BooleanArray(nInsns) @@ -45,7 +45,7 @@ public open class MethodAnalyzer( protected open fun newFrame(nLocals: Int, nStack: Int): Frame = Frame(nLocals, nStack) protected open fun newFrame(src: Frame): Frame { - val frame = newFrame(src.getLocals(), src.getMaxStackSize()) + val frame = newFrame(src.locals, src.maxStackSize) frame.init(src) return frame } @@ -57,7 +57,7 @@ public open class MethodAnalyzer( protected open fun visitControlFlowExceptionEdge(insn: Int, tcb: TryCatchBlockNode): Boolean = visitControlFlowExceptionEdge(insn, instructions.indexOf(tcb.handler)) - public fun analyze(): Array?> { + fun analyze(): Array?> { if (nInsns == 0) return frames checkAssertions() @@ -75,8 +75,8 @@ public open class MethodAnalyzer( val insnNode = method.instructions[insn] try { - val insnOpcode = insnNode.getOpcode() - val insnType = insnNode.getType() + val insnOpcode = insnNode.opcode + val insnType = insnNode.type if (insnType == AbstractInsnNode.LABEL || insnType == AbstractInsnNode.LINE || insnType == AbstractInsnNode.FRAME) { visitNopInsn(f, insn) @@ -121,11 +121,11 @@ public open class MethodAnalyzer( return frames } - public fun getFrame(insn: AbstractInsnNode): Frame? = + fun getFrame(insn: AbstractInsnNode): Frame? = frames[instructions.indexOf(insn)] private fun checkAssertions() { - if (instructions.toArray().any { it.getOpcode() == Opcodes.JSR || it.getOpcode() == Opcodes.RET }) + if (instructions.toArray().any { it.opcode == Opcodes.JSR || it.opcode == Opcodes.RET }) throw AssertionError("Subroutines are deprecated since Java 6") } @@ -179,7 +179,7 @@ public open class MethodAnalyzer( } for (arg in args) { current.setLocal(local++, interpreter.newValue(arg)) - if (arg.getSize() == 2) { + if (arg.size == 2) { current.setLocal(local++, interpreter.newValue(null)) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt index 29ab5499a5e..5f6b041c60c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt @@ -21,20 +21,20 @@ import org.jetbrains.org.objectweb.asm.tree.* import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue val AbstractInsnNode.isMeaningful: Boolean get() = - when (this.getType()) { + when (this.type) { AbstractInsnNode.LABEL, AbstractInsnNode.LINE, AbstractInsnNode.FRAME -> false else -> true } -public class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequence { - public constructor(insnList: InsnList) : this(insnList.getFirst(), null) +class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequence { + constructor(insnList: InsnList) : this(insnList.first, null) override fun iterator(): Iterator { return object : Iterator { var current: AbstractInsnNode? = from override fun next(): AbstractInsnNode { val result = current - current = current!!.getNext() + current = current!!.next return result!! } override fun hasNext() = current != to @@ -58,11 +58,11 @@ fun MethodNode.prepareForEmitting() { // We should remove linenumbers after last meaningful instruction // because they point to index of non-existing instruction and it leads to VerifyError - var current = instructions.getLast() + var current = instructions.last while (!current.isMeaningful) { - val prev = current.getPrevious() + val prev = current.previous - if (current.getType() == AbstractInsnNode.LINE) { + if (current.type == AbstractInsnNode.LINE) { instructions.remove(current) } @@ -70,7 +70,7 @@ fun MethodNode.prepareForEmitting() { } } -abstract class BasicValueWrapper(val wrappedValue: BasicValue?) : BasicValue(wrappedValue?.getType()) { +abstract class BasicValueWrapper(val wrappedValue: BasicValue?) : BasicValue(wrappedValue?.type) { val basicValue: BasicValue? get() = (wrappedValue as? BasicValueWrapper)?.basicValue ?: wrappedValue override fun equals(other: Any?): Boolean { @@ -79,23 +79,23 @@ abstract class BasicValueWrapper(val wrappedValue: BasicValue?) : BasicValue(wra } inline fun AbstractInsnNode.findNextOrNull(predicate: (AbstractInsnNode) -> Boolean): AbstractInsnNode? { - var finger = this.getNext() + var finger = this.next while (finger != null && !predicate(finger)) { - finger = finger.getNext() + finger = finger.next } return finger } inline fun AbstractInsnNode.findPreviousOrNull(predicate: (AbstractInsnNode) -> Boolean): AbstractInsnNode? { - var finger = this.getPrevious() + var finger = this.previous while (finger != null && !predicate(finger)) { - finger = finger.getPrevious() + finger = finger.previous } return finger } fun AbstractInsnNode.hasOpcode(): Boolean = - getOpcode() >= 0 + opcode >= 0 // See InstructionAdapter // diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt index e8d00217541..e23a36b2e09 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -40,31 +40,31 @@ internal class FixStackAnalyzer( val savedStacks = hashMapOf>() var maxExtraStackSize = 0; private set - protected override fun visitControlFlowEdge(insn: Int, successor: Int): Boolean { + override fun visitControlFlowEdge(insn: Int, successor: Int): Boolean { val insnNode = instructions[insn] return !(insnNode is JumpInsnNode && context.breakContinueGotoNodes.contains(insnNode)) } - protected override fun newFrame(nLocals: Int, nStack: Int): Frame = + override fun newFrame(nLocals: Int, nStack: Int): Frame = FixStackFrame(nLocals, nStack) private fun indexOf(node: AbstractInsnNode) = method.instructions.indexOf(node) - public inner class FixStackFrame(nLocals: Int, nStack: Int) : Frame(nLocals, nStack) { + inner class FixStackFrame(nLocals: Int, nStack: Int) : Frame(nLocals, nStack) { val extraStack = Stack() - public override fun init(src: Frame): Frame { + override fun init(src: Frame): Frame { extraStack.clear() extraStack.addAll((src as FixStackFrame).extraStack) return super.init(src) } - public override fun clearStack() { + override fun clearStack() { extraStack.clear() super.clearStack() } - public override fun execute(insn: AbstractInsnNode, interpreter: Interpreter) { + override fun execute(insn: AbstractInsnNode, interpreter: Interpreter) { when { PseudoInsn.SAVE_STACK_BEFORE_TRY.isa(insn) -> executeSaveStackBeforeTry(insn) @@ -83,15 +83,15 @@ internal class FixStackAnalyzer( super.execute(insn, interpreter) } - public fun getStackContent(): List { + fun getStackContent(): List { val savedStack = arrayListOf() IntRange(0, super.getStackSize() - 1).mapTo(savedStack) { super.getStack(it) } savedStack.addAll(extraStack) return savedStack } - public override fun push(value: BasicValue) { - if (super.getStackSize() < getMaxStackSize()) { + override fun push(value: BasicValue) { + if (super.getStackSize() < maxStackSize) { super.push(value) } else { @@ -100,11 +100,11 @@ internal class FixStackAnalyzer( } } - public fun pushAll(values: Collection) { + fun pushAll(values: Collection) { values.forEach { push(it) } } - public override fun pop(): BasicValue { + override fun pop(): BasicValue { if (extraStack.isNotEmpty()) { return extraStack.pop() } @@ -113,12 +113,12 @@ internal class FixStackAnalyzer( } } - public override fun getStack(i: Int): BasicValue { + override fun getStack(i: Int): BasicValue { if (i < super.getMaxStackSize()) { return super.getStack(i) } else { - return extraStack[i - getMaxStackSize()] + return extraStack[i - maxStackSize] } } } @@ -135,7 +135,7 @@ internal class FixStackAnalyzer( private fun FixStackFrame.executeAfterInlineCallMarker(insn: AbstractInsnNode) { val beforeInlineMarker = context.openingInlineMethodMarker[insn] - if (getStackSize() > 0) { + if (stackSize > 0) { val returnValue = pop() clearStack() val savedValues = savedStacks[beforeInlineMarker] diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt index 4ca75d2a542..3dfd5b7860e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt @@ -77,23 +77,23 @@ internal class FixStackContext(val methodNode: MethodNode) { } private fun visitFixStackBeforeJump(insnNode: AbstractInsnNode) { - val next = insnNode.getNext() - assert(next.getOpcode() == Opcodes.GOTO) { "${indexOf(insnNode)}: should be followed by GOTO" } + val next = insnNode.next + assert(next.opcode == Opcodes.GOTO) { "${indexOf(insnNode)}: should be followed by GOTO" } breakContinueGotoNodes.add(next as JumpInsnNode) } private fun visitFakeAlwaysTrueIfeq(insnNode: AbstractInsnNode) { - assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ) { "${indexOf(insnNode)}: should be followed by IFEQ" } + assert(insnNode.next.opcode == Opcodes.IFEQ) { "${indexOf(insnNode)}: should be followed by IFEQ" } fakeAlwaysTrueIfeqMarkers.add(insnNode) } private fun visitFakeAlwaysFalseIfeq(insnNode: AbstractInsnNode) { - assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ) { "${indexOf(insnNode)}: should be followed by IFEQ" } + assert(insnNode.next.opcode == Opcodes.IFEQ) { "${indexOf(insnNode)}: should be followed by IFEQ" } fakeAlwaysFalseIfeqMarkers.add(insnNode) } private fun visitSaveStackBeforeTry(insnNode: AbstractInsnNode) { - val tryStartLabel = insnNode.getNext() + val tryStartLabel = insnNode.next assert(tryStartLabel is LabelNode) { "${indexOf(insnNode)}: save should be followed by a label" } saveStackNodesForTryStartLabel[tryStartLabel as LabelNode] = insnNode } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt index 5d009c35b59..923bb6ea321 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.codegen.pseudoInsns.parsePseudoInsnOrNull import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode import org.jetbrains.org.objectweb.asm.tree.MethodNode -public class FixStackMethodTransformer : MethodTransformer() { - public override fun transform(internalClassName: String, methodNode: MethodNode) { +class FixStackMethodTransformer : MethodTransformer() { + override fun transform(internalClassName: String, methodNode: MethodNode) { val context = FixStackContext(methodNode) if (!context.hasAnyMarkers()) return @@ -73,19 +73,19 @@ public class FixStackMethodTransformer : MethodTransformer() { val labelIndex = methodNode.instructions.indexOf(gotoNode.label) val DEAD_CODE = -1 // Stack size is always non-negative - val actualStackSize = analyzer.frames[gotoIndex]?.getStackSize() ?: DEAD_CODE - val expectedStackSize = analyzer.frames[labelIndex]?.getStackSize() ?: DEAD_CODE + val actualStackSize = analyzer.frames[gotoIndex]?.stackSize ?: DEAD_CODE + val expectedStackSize = analyzer.frames[labelIndex]?.stackSize ?: DEAD_CODE if (actualStackSize != DEAD_CODE && expectedStackSize != DEAD_CODE) { assert(expectedStackSize <= actualStackSize) { "Label at $labelIndex, jump at $gotoIndex: stack underflow: $expectedStackSize > $actualStackSize" } val frame = analyzer.frames[gotoIndex]!! - actions.add({ replaceMarkerWithPops(methodNode, gotoNode.getPrevious(), expectedStackSize, frame) }) + actions.add({ replaceMarkerWithPops(methodNode, gotoNode.previous, expectedStackSize, frame) }) } else if (actualStackSize != DEAD_CODE && expectedStackSize == DEAD_CODE) { throw AssertionError("Live jump $gotoIndex to dead label $labelIndex") } else { - val marker = gotoNode.getPrevious() + val marker = gotoNode.previous actions.add({ methodNode.instructions.remove(marker) }) } } @@ -153,8 +153,8 @@ public class FixStackMethodTransformer : MethodTransformer() { val savedStackDescriptor = localVariablesManager.getBeforeInlineDescriptor(inlineMarker) val afterInlineFrame = analyzer.getFrame(inlineMarker) as FixStackAnalyzer.FixStackFrame? if (afterInlineFrame != null && savedStackDescriptor.isNotEmpty()) { - assert(afterInlineFrame.getStackSize() <= 1) { "Inline method should not leave more than 1 value on stack" } - if (afterInlineFrame.getStackSize() == 1) { + assert(afterInlineFrame.stackSize <= 1) { "Inline method should not leave more than 1 value on stack" } + if (afterInlineFrame.stackSize == 1) { val afterInlineStackValues = afterInlineFrame.getStackContent() val returnValue = afterInlineStackValues.last() val returnValueLocalVarIndex = localVariablesManager.createReturnValueVariable(returnValue) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt index 009a5740125..c7748ef8d3f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt @@ -91,7 +91,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun createReturnValueVariable(returnValue: BasicValue): Int { val returnValueIndex = getFirstUnusedLocalVariableIndex() - updateMaxLocals(returnValueIndex + returnValue.getSize()) + updateMaxLocals(returnValueIndex + returnValue.size) return returnValueIndex } } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt index bb8819f872f..527819463b2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt @@ -26,13 +26,13 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.Value -public inline fun InsnList.forEachPseudoInsn(block: (PseudoInsn, AbstractInsnNode) -> Unit) { +inline fun InsnList.forEachPseudoInsn(block: (PseudoInsn, AbstractInsnNode) -> Unit) { InsnSequence(this).forEach { insn -> parsePseudoInsnOrNull(insn)?.let { block(it, insn) } } } -public inline fun InsnList.forEachInlineMarker(block: (String, MethodInsnNode) -> Unit) { +inline fun InsnList.forEachInlineMarker(block: (String, MethodInsnNode) -> Unit) { InsnSequence(this).forEach { insn -> if (InlineCodegenUtil.isInlineMarker(insn)) { val methodInsnNode = insn as MethodInsnNode @@ -41,15 +41,15 @@ public inline fun InsnList.forEachInlineMarker(block: (String, MethodInsnNode) - } } -public fun Frame.top(): V? { - val stackSize = getStackSize() +fun Frame.top(): V? { + val stackSize = stackSize if (stackSize == 0) return null else return getStack(stackSize - 1) } -public fun MethodNode.updateMaxLocals(newMaxLocals: Int) { +fun MethodNode.updateMaxLocals(newMaxLocals: Int) { maxLocals = Math.max(maxLocals, newMaxLocals) } @@ -57,10 +57,10 @@ class SavedStackDescriptor( val savedValues: List, val firstLocalVarIndex: Int ) { - val savedValuesSize = savedValues.fold(0, { size, value -> size + value.getSize() }) + val savedValuesSize = savedValues.fold(0, { size, value -> size + value.size }) val firstUnusedLocalVarIndex = firstLocalVarIndex + savedValuesSize - public override fun toString(): String = + override fun toString(): String = "@$firstLocalVarIndex: [$savedValues]" fun isNotEmpty(): Boolean = savedValues.isNotEmpty() @@ -93,9 +93,9 @@ fun restoreStackWithReturnValue( returnValueLocalVarIndex: Int ) { with(methodNode.instructions) { - insertBefore(nodeToReplace, VarInsnNode(returnValue.getType().getOpcode(Opcodes.ISTORE), returnValueLocalVarIndex)) + insertBefore(nodeToReplace, VarInsnNode(returnValue.type.getOpcode(Opcodes.ISTORE), returnValueLocalVarIndex)) generateLoadInstructions(methodNode, nodeToReplace, savedStackDescriptor) - insertBefore(nodeToReplace, VarInsnNode(returnValue.getType().getOpcode(Opcodes.ILOAD), returnValueLocalVarIndex)) + insertBefore(nodeToReplace, VarInsnNode(returnValue.type.getOpcode(Opcodes.ILOAD), returnValueLocalVarIndex)) remove(nodeToReplace) } } @@ -104,22 +104,22 @@ fun generateLoadInstructions(methodNode: MethodNode, location: AbstractInsnNode, var localVarIndex = savedStackDescriptor.firstLocalVarIndex for (value in savedStackDescriptor.savedValues) { methodNode.instructions.insertBefore(location, - VarInsnNode(value.getType().getOpcode(Opcodes.ILOAD), localVarIndex)) - localVarIndex += value.getSize() + VarInsnNode(value.type.getOpcode(Opcodes.ILOAD), localVarIndex)) + localVarIndex += value.size } } fun generateStoreInstructions(methodNode: MethodNode, location: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor) { var localVarIndex = savedStackDescriptor.firstUnusedLocalVarIndex for (value in savedStackDescriptor.savedValues.asReversed()) { - localVarIndex -= value.getSize() + localVarIndex -= value.size methodNode.instructions.insertBefore(location, - VarInsnNode(value.getType().getOpcode(Opcodes.ISTORE), localVarIndex)) + VarInsnNode(value.type.getOpcode(Opcodes.ISTORE), localVarIndex)) } } fun getPopInstruction(top: BasicValue) = - InsnNode(when (top.getSize()) { + InsnNode(when (top.size) { 1 -> Opcodes.POP 2 -> Opcodes.POP2 else -> throw AssertionError("Unexpected value type size") @@ -127,14 +127,14 @@ fun getPopInstruction(top: BasicValue) = fun removeAlwaysFalseIfeq(methodNode: MethodNode, node: AbstractInsnNode) { with (methodNode.instructions) { - remove(node.getNext()) + remove(node.next) remove(node) } } fun replaceAlwaysTrueIfeqWithGoto(methodNode: MethodNode, node: AbstractInsnNode) { with (methodNode.instructions) { - val next = node.getNext() as JumpInsnNode + val next = node.next as JumpInsnNode insertBefore(node, JumpInsnNode(Opcodes.GOTO, next.label)) remove(node) remove(next) @@ -143,7 +143,7 @@ fun replaceAlwaysTrueIfeqWithGoto(methodNode: MethodNode, node: AbstractInsnNode fun replaceMarkerWithPops(methodNode: MethodNode, node: AbstractInsnNode, expectedStackSize: Int, frame: Frame) { with (methodNode.instructions) { - while (frame.getStackSize() > expectedStackSize) { + while (frame.stackSize > expectedStackSize) { val top = frame.pop() insertBefore(node, getPopInstruction(top)) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt index eacbebbef63..6c97f50d1dc 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt @@ -23,9 +23,9 @@ import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode import org.jetbrains.org.objectweb.asm.tree.InsnList import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode -public val PSEUDO_INSN_CALL_OWNER: String = "kotlin/jvm/internal/\$PseudoInsn" +val PSEUDO_INSN_CALL_OWNER: String = "kotlin/jvm/internal/\$PseudoInsn" -public enum class PseudoInsn(val signature: String = "()V") { +enum class PseudoInsn(val signature: String = "()V") { FIX_STACK_BEFORE_JUMP(), FAKE_ALWAYS_TRUE_IFEQ("()I"), FAKE_ALWAYS_FALSE_IFEQ("()I"), @@ -33,36 +33,36 @@ public enum class PseudoInsn(val signature: String = "()V") { RESTORE_STACK_IN_TRY_CATCH() ; - public fun emit(iv: InstructionAdapter) { + fun emit(iv: InstructionAdapter) { iv.invokestatic(PSEUDO_INSN_CALL_OWNER, toString(), signature, false) } - public fun createInsnNode(): MethodInsnNode = + fun createInsnNode(): MethodInsnNode = MethodInsnNode(Opcodes.INVOKESTATIC, PSEUDO_INSN_CALL_OWNER, toString(), signature, false) - public fun isa(node: AbstractInsnNode): Boolean = + fun isa(node: AbstractInsnNode): Boolean = this == parsePseudoInsnOrNull(node) } -public fun isPseudoInsn(insn: AbstractInsnNode): Boolean = +fun isPseudoInsn(insn: AbstractInsnNode): Boolean = insn is MethodInsnNode && insn.getOpcode() == Opcodes.INVOKESTATIC && insn.owner == PSEUDO_INSN_CALL_OWNER -public fun parsePseudoInsnOrNull(insn: AbstractInsnNode): PseudoInsn? = +fun parsePseudoInsnOrNull(insn: AbstractInsnNode): PseudoInsn? = if (isPseudoInsn(insn)) PseudoInsn.valueOf((insn as MethodInsnNode).name) else null -public fun InstructionAdapter.fixStackAndJump(label: Label) { +fun InstructionAdapter.fixStackAndJump(label: Label) { PseudoInsn.FIX_STACK_BEFORE_JUMP.emit(this) this.goTo(label) } -public fun InstructionAdapter.fakeAlwaysTrueIfeq(label: Label) { +fun InstructionAdapter.fakeAlwaysTrueIfeq(label: Label) { PseudoInsn.FAKE_ALWAYS_TRUE_IFEQ.emit(this) this.ifeq(label) } -public fun InstructionAdapter.fakeAlwaysFalseIfeq(label: Label) { +fun InstructionAdapter.fakeAlwaysFalseIfeq(label: Label) { PseudoInsn.FAKE_ALWAYS_FALSE_IFEQ.emit(this) this.ifeq(label) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmStringTable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmStringTable.kt index 10d631de03e..f1f1f1999ca 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmStringTable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmStringTable.kt @@ -31,7 +31,7 @@ import java.util.* // TODO: optimize by reordering records to minimize storage of 'range' fields class JvmStringTable(private val typeMapper: JetTypeMapper) : StringTable { - public val strings = ArrayList() + val strings = ArrayList() private val records = ArrayList() private val map = HashMap() private val localNames = HashSet() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/KotlinToJvmSignatureMapperImpl.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/KotlinToJvmSignatureMapperImpl.kt index faecf8faacb..85f0a4d62ac 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/KotlinToJvmSignatureMapperImpl.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/KotlinToJvmSignatureMapperImpl.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper -public class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper { +class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper { // We use empty BindingContext, because it is only used by JetTypeMapper for purposes irrelevant to the needs of this class private val typeMapper: JetTypeMapper = JetTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null, JvmAbi.DEFAULT_MODULE_NAME) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt index 54073a20721..25d4a9a0c42 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/BuilderFactoryForDuplicateSignatureDiagnostics.kt @@ -120,17 +120,17 @@ class BuilderFactoryForDuplicateSignatureDiagnostics( var ownNonFakeCount = 0 for (origin in origins) { val member = origin.descriptor as? CallableMemberDescriptor? - if (member != null && member.containingDeclaration == classOrigin.descriptor && member.getKind() != FAKE_OVERRIDE) { + if (member != null && member.containingDeclaration == classOrigin.descriptor && member.kind != FAKE_OVERRIDE) { ownNonFakeCount++ // If there's more than one real element, the clashing signature is already reported. // Only clashes between fake overrides are interesting here if (ownNonFakeCount > 1) continue@signatures - if (member.getKind() != DELEGATION) { + if (member.kind != DELEGATION) { // Delegates don't have declarations in the code memberElement = origin.element ?: DescriptorToSourceUtils.descriptorToDeclaration(member) if (memberElement == null && member is PropertyAccessorDescriptor) { - memberElement = DescriptorToSourceUtils.descriptorToDeclaration(member.getCorrespondingProperty()) + memberElement = DescriptorToSourceUtils.descriptorToDeclaration(member.correspondingProperty) } } } @@ -154,18 +154,18 @@ class BuilderFactoryForDuplicateSignatureDiagnostics( fun processMember(member: DeclarationDescriptor?) { // a member of super is not visible: no override - if (member is DeclarationDescriptorWithVisibility && member.getVisibility() == Visibilities.INVISIBLE_FAKE) return + if (member is DeclarationDescriptorWithVisibility && member.visibility == Visibilities.INVISIBLE_FAKE) return // if a signature clashes with a SAM-adapter or something like that, there's no harm if (member is CallableMemberDescriptor && isOrOverridesSamAdapter(member)) return if (member is PropertyDescriptor) { - processMember(member.getGetter()) - processMember(member.getSetter()) + processMember(member.getter) + processMember(member.setter) } else if (member is FunctionDescriptor) { val methodSignature = typeMapper.mapSignature(member) val rawSignature = RawSignature( - methodSignature.getAsmMethod().getName()!!, methodSignature.getAsmMethod().getDescriptor()!!, MemberKind.METHOD) + methodSignature.asmMethod.name!!, methodSignature.asmMethod.descriptor!!, MemberKind.METHOD) groupedBySignature.putValue(rawSignature, OtherOrigin(member)) } } @@ -185,7 +185,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics( private fun isOrOverridesSamAdapter(descriptor: CallableMemberDescriptor): Boolean { if (descriptor is SamAdapterDescriptor<*>) return true - return descriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE - && descriptor.getOverriddenDescriptors().all { isOrOverridesSamAdapter(it) } + return descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE + && descriptor.overriddenDescriptors.all { isOrOverridesSamAdapter(it) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 42e430b58f4..1df5fbdc654 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -44,40 +44,39 @@ import org.jetbrains.kotlin.resolve.DelegatingBindingTrace import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics import java.io.File -public class GenerationState @JvmOverloads constructor( - public val project: Project, +class GenerationState @JvmOverloads constructor( + val project: Project, builderFactory: ClassBuilderFactory, - public val module: ModuleDescriptor, + val module: ModuleDescriptor, bindingContext: BindingContext, - public val files: List, + val files: List, disableCallAssertions: Boolean = true, disableParamAssertions: Boolean = true, - public val generateDeclaredClassFilter: GenerationState.GenerateClassFilter = GenerationState.GenerateClassFilter.GENERATE_ALL, + val generateDeclaredClassFilter: GenerationState.GenerateClassFilter = GenerationState.GenerateClassFilter.GENERATE_ALL, disableInline: Boolean = false, disableOptimization: Boolean = false, - public val useTypeTableInSerializer: Boolean = false, - public val packagesWithObsoleteParts: Collection = emptySet(), - public val obsoleteMultifileClasses: Collection = emptySet(), + val useTypeTableInSerializer: Boolean = false, + val packagesWithObsoleteParts: Collection = emptySet(), + val obsoleteMultifileClasses: Collection = emptySet(), // for PackageCodegen in incremental compilation mode - public val targetId: TargetId? = null, + val targetId: TargetId? = null, moduleName: String? = null, // 'outDirectory' is a hack to correctly determine if a compiled class is from the same module as the callee during // partial compilation. Module chunks are treated as a single module. // TODO: get rid of it with the proper module infrastructure - public val outDirectory: File? = null, - public val incrementalCompilationComponents: IncrementalCompilationComponents? = null, - public val generateOpenMultifileClasses: Boolean = false, - public val progress: Progress = Progress.DEAF + val outDirectory: File? = null, + val incrementalCompilationComponents: IncrementalCompilationComponents? = null, + val generateOpenMultifileClasses: Boolean = false, + val progress: Progress = Progress.DEAF ) { - public abstract class GenerateClassFilter { - public abstract fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean - public abstract fun shouldGenerateClass(processingClassOrObject: KtClassOrObject): Boolean - public abstract fun shouldGeneratePackagePart(jetFile: KtFile): Boolean - public abstract fun shouldGenerateScript(script: KtScript): Boolean + abstract class GenerateClassFilter { + abstract fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean + abstract fun shouldGenerateClass(processingClassOrObject: KtClassOrObject): Boolean + abstract fun shouldGeneratePackagePart(jetFile: KtFile): Boolean + abstract fun shouldGenerateScript(script: KtScript): Boolean companion object { - @JvmField - public val GENERATE_ALL: GenerateClassFilter = object : GenerateClassFilter() { + @JvmField val GENERATE_ALL: GenerateClassFilter = object : GenerateClassFilter() { override fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean = true override fun shouldGenerateClass(processingClassOrObject: KtClassOrObject): Boolean = true @@ -89,7 +88,7 @@ public class GenerationState @JvmOverloads constructor( } } - public val fileClassesProvider: CodegenFileClassesProvider = CodegenFileClassesProvider() + val fileClassesProvider: CodegenFileClassesProvider = CodegenFileClassesProvider() private fun getIncrementalCacheForThisTarget() = if (incrementalCompilationComponents != null && targetId != null) @@ -100,47 +99,47 @@ public class GenerationState @JvmOverloads constructor( private val interceptedBuilderFactory: ClassBuilderFactory private var used = false - public val diagnostics: DiagnosticSink get() = extraJvmDiagnosticsTrace - public val collectedExtraJvmDiagnostics: Diagnostics = LazyJvmDiagnostics { + val diagnostics: DiagnosticSink get() = extraJvmDiagnosticsTrace + val collectedExtraJvmDiagnostics: Diagnostics = LazyJvmDiagnostics { duplicateSignatureFactory.reportDiagnostics() extraJvmDiagnosticsTrace.bindingContext.diagnostics } - public val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module) - public val classBuilderMode: ClassBuilderMode = builderFactory.getClassBuilderMode() - public val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState") - public val bindingContext: BindingContext = bindingTrace.getBindingContext() - public val typeMapper: JetTypeMapper = JetTypeMapper(this.bindingContext, classBuilderMode, fileClassesProvider, getIncrementalCacheForThisTarget(), this.moduleName) - public val intrinsics: IntrinsicMethods = IntrinsicMethods() - public val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this) - public val inlineCycleReporter: InlineCycleReporter = InlineCycleReporter(diagnostics) - public val mappingsClassesForWhenByEnum: MappingsClassesForWhenByEnum = MappingsClassesForWhenByEnum(this) - public val reflectionTypes: ReflectionTypes = ReflectionTypes(module) - public val jvmRuntimeTypes: JvmRuntimeTypes = JvmRuntimeTypes() - public val factory: ClassFileFactory + val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module) + val classBuilderMode: ClassBuilderMode = builderFactory.classBuilderMode + val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState") + val bindingContext: BindingContext = bindingTrace.bindingContext + val typeMapper: JetTypeMapper = JetTypeMapper(this.bindingContext, classBuilderMode, fileClassesProvider, getIncrementalCacheForThisTarget(), this.moduleName) + val intrinsics: IntrinsicMethods = IntrinsicMethods() + val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this) + val inlineCycleReporter: InlineCycleReporter = InlineCycleReporter(diagnostics) + val mappingsClassesForWhenByEnum: MappingsClassesForWhenByEnum = MappingsClassesForWhenByEnum(this) + val reflectionTypes: ReflectionTypes = ReflectionTypes(module) + val jvmRuntimeTypes: JvmRuntimeTypes = JvmRuntimeTypes() + val factory: ClassFileFactory private val duplicateSignatureFactory: BuilderFactoryForDuplicateSignatureDiagnostics - public val replSpecific = ForRepl() + val replSpecific = ForRepl() //TODO: should be refactored out - public class ForRepl { - public var earlierScriptsForReplInterpreter: List? = null - public var scriptResultFieldName: String? = null - public val shouldGenerateScriptResultValue: Boolean get() = scriptResultFieldName != null - public var hasResult: Boolean = false + class ForRepl { + var earlierScriptsForReplInterpreter: List? = null + var scriptResultFieldName: String? = null + val shouldGenerateScriptResultValue: Boolean get() = scriptResultFieldName != null + var hasResult: Boolean = false } - public val isCallAssertionsEnabled: Boolean = !disableCallAssertions + val isCallAssertionsEnabled: Boolean = !disableCallAssertions @JvmName("isCallAssertionsEnabled") get - public val isParamAssertionsEnabled: Boolean = !disableParamAssertions + val isParamAssertionsEnabled: Boolean = !disableParamAssertions @JvmName("isParamAssertionsEnabled") get - public val isInlineEnabled: Boolean = !disableInline + val isInlineEnabled: Boolean = !disableInline @JvmName("isInlineEnabled") get - public val rootContext: CodegenContext<*> = RootContext(this) + val rootContext: CodegenContext<*> = RootContext(this) init { val optimizationClassBuilderFactory = OptimizationClassBuilderFactory(builderFactory, disableOptimization) @@ -162,7 +161,7 @@ public class GenerationState @JvmOverloads constructor( this.factory = ClassFileFactory(this, interceptedBuilderFactory) } - public fun beforeCompile() { + fun beforeCompile() { markUsed() CodegenBinding.initTrace(this) @@ -174,7 +173,7 @@ public class GenerationState @JvmOverloads constructor( used = true } - public fun destroy() { + fun destroy() { interceptedBuilderFactory.close() } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt index 0ed334e6c0d..aa9bedff79a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt @@ -56,7 +56,7 @@ private fun KotlinType.canHaveSubtypesIgnoringNullability(): Boolean { return false } -public fun getEffectiveVariance(parameterVariance: Variance, projectionKind: Variance): Variance { +fun getEffectiveVariance(parameterVariance: Variance, projectionKind: Variance): Variance { if (parameterVariance === Variance.INVARIANT) { return projectionKind } diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt index 43a966f9737..fbaeeabb928 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt @@ -48,11 +48,11 @@ import java.io.ByteArrayOutputStream import java.io.DataOutputStream import java.io.File -public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) { +class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) { private var totalSize = 0 private var totalFiles = 0 - public fun serialize( + fun serialize( destDir: File, srcDirs: List, extraClassPath: List, diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt index 4dce8692d8b..1e0442225ad 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase import org.jetbrains.kotlin.serialization.ProtoBuf -public class BuiltInsSerializerExtension : KotlinSerializerExtensionBase(BuiltInSerializerProtocol) { +class BuiltInsSerializerExtension : KotlinSerializerExtensionBase(BuiltInSerializerProtocol) { override fun shouldUseTypeTable(): Boolean = true override fun serializePackage(packageFragments: Collection, proto: ProtoBuf.Package.Builder) { diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt index 9377fd7d0f0..1f0a64fa783 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.cli.common -public val KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY = "kotlin.environment.keepalive" +val KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY = "kotlin.environment.keepalive" fun String?.toBooleanLenient(): Boolean? = when (this?.toLowerCase()) { diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/messages/CompilerMessageLocation.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/messages/CompilerMessageLocation.kt index b8150ae452a..f49e065f5e1 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/messages/CompilerMessageLocation.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/messages/CompilerMessageLocation.kt @@ -16,21 +16,19 @@ package org.jetbrains.kotlin.cli.common.messages -public data class CompilerMessageLocation private constructor( - public val path: String?, - public val line: Int, - public val column: Int, - public val lineContent: String? +data class CompilerMessageLocation private constructor( + val path: String?, + val line: Int, + val column: Int, + val lineContent: String? ) { override fun toString(): String = path + (if (line != -1 || column != -1) " ($line:$column)" else "") companion object { - @JvmField - public val NO_LOCATION: CompilerMessageLocation = CompilerMessageLocation(null, -1, -1, null) + @JvmField val NO_LOCATION: CompilerMessageLocation = CompilerMessageLocation(null, -1, -1, null) - @JvmStatic - public fun create( + @JvmStatic fun create( path: String?, line: Int, column: Int, diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/modules/ModuleBuilder.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/modules/ModuleBuilder.kt index d208b7c7f7a..fdf0b382dbe 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/modules/ModuleBuilder.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/modules/ModuleBuilder.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.modules.Module import org.jetbrains.kotlin.modules.JavaRootPath import java.util.* -public class ModuleBuilder( +class ModuleBuilder( private val name: String, private val outputDir: String, private val type: String @@ -30,19 +30,19 @@ public class ModuleBuilder( private val javaSourceRoots = ArrayList() private val friendDirs = ArrayList() - public fun addSourceFiles(pattern: String) { + fun addSourceFiles(pattern: String) { sourceFiles.add(pattern) } - public fun addClasspathEntry(name: String) { + fun addClasspathEntry(name: String) { classpathRoots.add(name) } - public fun addJavaSourceRoot(rootPath: JavaRootPath) { + fun addJavaSourceRoot(rootPath: JavaRootPath) { javaSourceRoots.add(rootPath) } - public fun addFriendDir(friendDir: String) { + fun addFriendDir(friendDir: String) { friendDirs.add(friendDir) } diff --git a/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt b/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt index 1b36669c74c..fa227a1ce50 100644 --- a/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt +++ b/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt @@ -20,7 +20,7 @@ import java.io.File import java.io.FileNotFoundException import java.util.* -public object Main { +object Main { private val KOTLIN_HOME: File init { @@ -99,8 +99,7 @@ public object Main { runner.run(classpath, arguments) } - @JvmStatic - public fun main(args: Array) { + @JvmStatic fun main(args: Array) { try { run(args) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DefaultDiagnosticReporter.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DefaultDiagnosticReporter.kt index 62b19e547c0..72986a5c6e1 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DefaultDiagnosticReporter.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DefaultDiagnosticReporter.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticUtils /** * This class behaviour is the same as [MessageCollector.report] in [AnalyzerWithCompilerReport.reportDiagnostic]. */ -public class DefaultDiagnosticReporter(override val messageCollector: MessageCollector) : MessageCollectorBasedReporter +class DefaultDiagnosticReporter(override val messageCollector: MessageCollector) : MessageCollectorBasedReporter -public interface MessageCollectorBasedReporter : DiagnosticMessageReporter { +interface MessageCollectorBasedReporter : DiagnosticMessageReporter { val messageCollector: MessageCollector diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DiagnosticMessageReporter.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DiagnosticMessageReporter.kt index aa11bd8c918..246781e6187 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DiagnosticMessageReporter.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/DiagnosticMessageReporter.kt @@ -19,6 +19,6 @@ package org.jetbrains.kotlin.cli.common.messages import com.intellij.psi.PsiFile import org.jetbrains.kotlin.diagnostics.Diagnostic -public interface DiagnosticMessageReporter { +interface DiagnosticMessageReporter { fun report(diagnostic: Diagnostic, file: PsiFile, render: String) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/output/outputUtils.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/output/outputUtils.kt index 9567e733ec2..64167628794 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/output/outputUtils.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/output/outputUtils.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector import java.io.File import com.intellij.openapi.util.io.FileUtil -public fun OutputFileCollection.writeAll(outputDir: File, report: (sources: List, output: File) -> Unit) { +fun OutputFileCollection.writeAll(outputDir: File, report: (sources: List, output: File) -> Unit) { for (file in asList()) { val sources = file.sourceFiles val output = File(outputDir, file.relativePath) @@ -35,11 +35,11 @@ public fun OutputFileCollection.writeAll(outputDir: File, report: (sources: List private val REPORT_NOTHING = { sources: List, output: File -> } -public fun OutputFileCollection.writeAllTo(outputDir: File) { +fun OutputFileCollection.writeAllTo(outputDir: File) { writeAll(outputDir, REPORT_NOTHING) } -public fun OutputFileCollection.writeAll(outputDir: File, messageCollector: MessageCollector) { +fun OutputFileCollection.writeAll(outputDir: File, messageCollector: MessageCollector) { writeAll(outputDir) { sources, output -> messageCollector.report(CompilerMessageSeverity.OUTPUT, OutputMessageUtil.formatOutputMessage(sources, output), CompilerMessageLocation.NO_LOCATION) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 5fa3854b827..077bf531dbb 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -45,7 +45,7 @@ import java.io.File import java.lang.management.ManagementFactory import java.util.concurrent.TimeUnit -public open class K2JVMCompiler : CLICompiler() { +open class K2JVMCompiler : CLICompiler() { override fun doExecute(arguments: K2JVMCompilerArguments, services: Services, messageCollector: MessageCollector, rootDisposable: Disposable): ExitCode { val messageSeverityCollector = MessageSeverityCollector(messageCollector) @@ -54,7 +54,7 @@ public open class K2JVMCompiler : CLICompiler() { else PathUtil.getKotlinPathsForCompiler() - messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Using Kotlin home directory " + paths.getHomePath(), CompilerMessageLocation.NO_LOCATION) + messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Using Kotlin home directory " + paths.homePath, CompilerMessageLocation.NO_LOCATION) PerformanceCounter.setTimeCounterEnabled(arguments.reportPerf); val configuration = CompilerConfiguration() @@ -108,7 +108,7 @@ public open class K2JVMCompiler : CLICompiler() { for (arg in arguments.freeArgs) { configuration.addKotlinSourceRoot(arg) val file = File(arg) - if (file.isDirectory()) { + if (file.isDirectory) { configuration.addJavaSourceRoot(file) } } @@ -159,14 +159,14 @@ public open class K2JVMCompiler : CLICompiler() { messageSeverityCollector.report(CompilerMessageSeverity.WARNING, "The '-d' option with a directory destination is ignored because '-module' is specified", CompilerMessageLocation.NO_LOCATION) } - val directory = File(arguments.module).getAbsoluteFile().getParentFile() + val directory = File(arguments.module).absoluteFile.parentFile - val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.getModules(), directory) + val compilerConfiguration = KotlinToJVMBytecodeCompiler.createCompilerConfiguration(configuration, moduleScript.modules, directory) environment = createCoreEnvironment(rootDisposable, compilerConfiguration) if (messageSeverityCollector.anyReported(CompilerMessageSeverity.ERROR)) return COMPILATION_ERROR - KotlinToJVMBytecodeCompiler.compileModules(environment, configuration, moduleScript.getModules(), directory, jar, friendPaths, arguments.includeRuntime) + KotlinToJVMBytecodeCompiler.compileModules(environment, configuration, moduleScript.modules, directory, jar, friendPaths, arguments.includeRuntime) } else if (arguments.script) { val scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size) @@ -200,7 +200,7 @@ public open class K2JVMCompiler : CLICompiler() { return OK } catch (e: CompilationException) { - messageSeverityCollector.report(CompilerMessageSeverity.EXCEPTION, OutputMessageUtil.renderException(e), MessageUtil.psiElementToMessageLocation(e.getElement())) + messageSeverityCollector.report(CompilerMessageSeverity.EXCEPTION, OutputMessageUtil.renderException(e), MessageUtil.psiElementToMessageLocation(e.element)) return INTERNAL_ERROR } @@ -235,18 +235,17 @@ public open class K2JVMCompiler : CLICompiler() { private var elapsedJITTime = 0L private var shouldReportPerf = true - public fun resetInitStartTime() { + fun resetInitStartTime() { if (initStartNanos == 0L) { initStartNanos = System.nanoTime() } } - @JvmStatic - public fun main(args: Array) { + @JvmStatic fun main(args: Array) { CLICompiler.doMain(K2JVMCompiler(), args) } - public fun reportPerf(configuration: CompilerConfiguration, message: String) { + fun reportPerf(configuration: CompilerConfiguration, message: String) { if (!shouldReportPerf) return val collector = configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!! @@ -255,17 +254,17 @@ public open class K2JVMCompiler : CLICompiler() { fun reportGCTime(configuration: CompilerConfiguration) { ManagementFactory.getGarbageCollectorMXBeans().forEach { - val currentTime = it.getCollectionTime() - val elapsedTime = elapsedGCTime.getOrElse(it.getName()) { 0 } + val currentTime = it.collectionTime + val elapsedTime = elapsedGCTime.getOrElse(it.name) { 0 } val time = currentTime - elapsedTime - reportPerf(configuration, "GC time for ${it.getName()} is $time ms") - elapsedGCTime[it.getName()] = currentTime + reportPerf(configuration, "GC time for ${it.name} is $time ms") + elapsedGCTime[it.name] = currentTime } } fun reportCompilationTime(configuration: CompilerConfiguration) { val bean = ManagementFactory.getCompilationMXBean() ?: return - val currentTime = bean.getTotalCompilationTime() + val currentTime = bean.totalCompilationTime reportPerf(configuration, "JIT time is ${currentTime - elapsedJITTime} ms") elapsedJITTime = currentTime } @@ -284,7 +283,7 @@ public open class K2JVMCompiler : CLICompiler() { classpath.addAll(arguments.classpath.split(File.pathSeparatorChar).map { File(it) }) } if (!arguments.noStdlib) { - classpath.add(paths.getRuntimePath()) + classpath.add(paths.runtimePath) } return classpath } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt index 02c4bbabdaf..953f11e22ad 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt @@ -26,7 +26,7 @@ import java.net.URLClassLoader import java.util.* -public object PluginCliParser { +object PluginCliParser { @JvmStatic fun loadPlugins(arguments: CommonCompilerArguments, configuration: CompilerConfiguration) { @@ -35,7 +35,7 @@ public object PluginCliParser { ?.map { File(it).toURI().toURL() } ?.toTypedArray() ?: arrayOf(), - javaClass.getClassLoader() + javaClass.classLoader ) val componentRegistrars = ServiceLoader.load(ComponentRegistrar::class.java, classLoader).toArrayList() @@ -93,7 +93,7 @@ public object PluginCliParser { } } -private class PluginURLClassLoader(urls: Array, parent: ClassLoader) : ClassLoader(Thread.currentThread().getContextClassLoader()) { +private class PluginURLClassLoader(urls: Array, parent: ClassLoader) : ClassLoader(Thread.currentThread().contextClassLoader) { private val childClassLoader: SelfThenParentURLClassLoader = SelfThenParentURLClassLoader(urls, parent) @Synchronized diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt index b0716d309ed..febc9ca56b5 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt @@ -62,7 +62,7 @@ import kotlin.properties.Delegates * To mitigate this, CliLightClassGenerationSupport hold a trace that is shared between the analyzer and JetLightClasses */ -public class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSupport(), CodeAnalyzerInitializer { +class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSupport(), CodeAnalyzerInitializer { private val psiManager = PsiManager.getInstance(project) private var bindingContext: BindingContext by Delegates.notNull() private var module: ModuleDescriptor by Delegates.notNull() @@ -172,7 +172,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera return NoScopeRecordCliBindingTrace() } - public class NoScopeRecordCliBindingTrace : CliBindingTrace() { + class NoScopeRecordCliBindingTrace : CliBindingTrace() { override fun record(slice: WritableSlice, key: K, value: V) { if (slice === BindingContext.LEXICAL_SCOPE) { // In the compiler there's no need to keep scopes @@ -186,14 +186,14 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera } } - public open class CliBindingTrace @TestOnly constructor() : BindingTraceContext() { + open class CliBindingTrace @TestOnly constructor() : BindingTraceContext() { private var kotlinCodeAnalyzer: KotlinCodeAnalyzer? = null override fun toString(): String { return CliBindingTrace::class.java.name } - public fun setKotlinCodeAnalyzer(kotlinCodeAnalyzer: KotlinCodeAnalyzer) { + fun setKotlinCodeAnalyzer(kotlinCodeAnalyzer: KotlinCodeAnalyzer) { this.kotlinCodeAnalyzer = kotlinCodeAnalyzer } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinder.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinder.kt index 5e311d721e4..c011cf16f4b 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinder.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinder.kt @@ -20,13 +20,13 @@ import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClassFinder import org.jetbrains.kotlin.name.ClassId -public class JvmCliVirtualFileFinder(private val index: JvmDependenciesIndex) : VirtualFileKotlinClassFinder() { +class JvmCliVirtualFileFinder(private val index: JvmDependenciesIndex) : VirtualFileKotlinClassFinder() { override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? { - val classFileName = classId.getRelativeClassName().asString().replace('.', '$') + val classFileName = classId.relativeClassName.asString().replace('.', '$') return index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, rootType -> dir.findChild("$classFileName.class")?.let { - if (it.isValid()) it else null + if (it.isValid) it else null } } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinderFactory.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinderFactory.kt index dc7a11137c7..45b6813fb80 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinderFactory.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmCliVirtualFileFinderFactory.kt @@ -20,6 +20,6 @@ import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory -public class JvmCliVirtualFileFinderFactory(private val index: JvmDependenciesIndex) : JvmVirtualFileFinderFactory { +class JvmCliVirtualFileFinderFactory(private val index: JvmDependenciesIndex) : JvmVirtualFileFinderFactory { override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder = JvmCliVirtualFileFinder(index) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmDependenciesIndex.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmDependenciesIndex.kt index 16baa569a94..480bf4470b8 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmDependenciesIndex.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmDependenciesIndex.kt @@ -24,22 +24,22 @@ import java.util.ArrayList import java.util.EnumSet import java.util.HashMap -public data class JavaRoot(public val file: VirtualFile, public val type: JavaRoot.RootType, public val prefixFqName: FqName? = null) { - public enum class RootType { +data class JavaRoot(val file: VirtualFile, val type: JavaRoot.RootType, val prefixFqName: FqName? = null) { + enum class RootType { SOURCE, BINARY } companion object RootTypes { - public val OnlyBinary: Set = EnumSet.of(RootType.BINARY) - public val SourceAndBinary: Set = EnumSet.of(RootType.BINARY, RootType.SOURCE) + val OnlyBinary: Set = EnumSet.of(RootType.BINARY) + val SourceAndBinary: Set = EnumSet.of(RootType.BINARY, RootType.SOURCE) } } // speeds up finding files/classes in classpath/java source roots // NOT THREADSAFE, needs to be adapted/removed if we want compiler to be multithreaded // the main idea of this class is for each package to store roots which contains it to avoid excessive file system traversal -public class JvmDependenciesIndex(_roots: List) { +class JvmDependenciesIndex(_roots: List) { //these fields are computed based on _roots passed to constructor which are filled in later private val roots: List by lazy { _roots.toList() } @@ -78,7 +78,7 @@ public class JvmDependenciesIndex(_roots: List) { // findClassGivenDirectory MUST check whether the class with this classId exists in given package - public fun findClass( + fun findClass( classId: ClassId, acceptedRootTypes: Set = JavaRoot.SourceAndBinary, findClassGivenDirectory: (VirtualFile, JavaRoot.RootType) -> T? @@ -89,7 +89,7 @@ public class JvmDependenciesIndex(_roots: List) { } } - public fun traverseDirectoriesInPackage( + fun traverseDirectoriesInPackage( packageFqName: FqName, acceptedRootTypes: Set = JavaRoot.SourceAndBinary, continueSearch: (VirtualFile, JavaRoot.RootType) -> Boolean diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmPackagePartProvider.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmPackagePartProvider.kt index 0b05af981ab..05acdddd629 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmPackagePartProvider.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/JvmPackagePartProvider.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider import org.jetbrains.kotlin.load.kotlin.ModuleMapping import java.io.EOFException -public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePartProvider { +class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePartProvider { val roots by lazy { env.configuration.getList(CommonConfigurationKeys.CONTENT_ROOTS). diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt index 28cc4f384a2..f2419147c90 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt @@ -33,19 +33,19 @@ import org.jetbrains.kotlin.util.PerformanceCounter import java.util.ArrayList import kotlin.properties.Delegates -public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) +class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJavaFileManager(myPsiManager), KotlinCliJavaFileManager { private val perfCounter = PerformanceCounter.create("Find Java class") private var index: JvmDependenciesIndex by Delegates.notNull() - public fun initIndex(packagesCache: JvmDependenciesIndex) { + fun initIndex(packagesCache: JvmDependenciesIndex) { this.index = packagesCache } - public override fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? { + override fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? { return perfCounter.time { - val classNameWithInnerClasses = classId.getRelativeClassName().asString() + val classNameWithInnerClasses = classId.relativeClassName.asString() index.findClass(classId) { dir, type -> findClassGivenPackage(searchScope, dir, classNameWithInnerClasses, type) } @@ -65,8 +65,8 @@ public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) val classIdAsTopLevelClass = qName.toSafeTopLevelClassId() ?: return@time super.findClasses(qName, scope) val result = ArrayList() - val classNameWithInnerClasses = classIdAsTopLevelClass.getRelativeClassName().asString() - index.traverseDirectoriesInPackage(classIdAsTopLevelClass.getPackageFqName()) { dir, rootType -> + val classNameWithInnerClasses = classIdAsTopLevelClass.relativeClassName.asString() + index.traverseDirectoriesInPackage(classIdAsTopLevelClass.packageFqName) { dir, rootType -> val psiClass = findClassGivenPackage(scope, dir, classNameWithInnerClasses, rootType) if (psiClass != null) { result.add(psiClass) @@ -108,8 +108,8 @@ public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) JavaRoot.RootType.SOURCE -> packageDir.findChild("$topLevelClassName.java") } ?: return null - if (!vFile.isValid()) { - LOG.error("Invalid child of valid parent: ${vFile.getPath()}; ${packageDir.isValid()} path=${packageDir.getPath()}") + if (!vFile.isValid) { + LOG.error("Invalid child of valid parent: ${vFile.path}; ${packageDir.isValid} path=${packageDir.path}") return null } if (vFile !in scope) { @@ -124,7 +124,7 @@ public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) private val LOG = Logger.getInstance(KotlinCliJavaFileManagerImpl::class.java) private fun findClassInPsiFile(classNameWithInnerClassesDotSeparated: String, file: PsiClassOwner): PsiClass? { - for (topLevelClass in file.getClasses()) { + for (topLevelClass in file.classes) { val candidate = findClassByTopLevelClass(classNameWithInnerClassesDotSeparated, topLevelClass) if (candidate != null) { return candidate @@ -135,11 +135,11 @@ public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) private fun findClassByTopLevelClass(className: String, topLevelClass: PsiClass): PsiClass? { if (className.indexOf('.') < 0) { - return if (className == topLevelClass.getName()) topLevelClass else null + return if (className == topLevelClass.name) topLevelClass else null } val segments = StringUtil.split(className, ".").iterator() - if (!segments.hasNext() || segments.next() != topLevelClass.getName()) { + if (!segments.hasNext() || segments.next() != topLevelClass.name) { return null } var curClass = topLevelClass diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt index 89422cce182..c759846efbe 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt @@ -94,7 +94,7 @@ import org.jetbrains.kotlin.utils.PathUtil import java.io.File import java.util.* -public class KotlinCoreEnvironment private constructor( +class KotlinCoreEnvironment private constructor( parentDisposable: Disposable, applicationEnvironment: JavaCoreApplicationEnvironment, configuration: CompilerConfiguration @@ -108,7 +108,7 @@ public class KotlinCoreEnvironment private constructor( private val sourceFiles = ArrayList() private val javaRoots = ArrayList() - public val configuration: CompilerConfiguration = configuration.copy().let { + val configuration: CompilerConfiguration = configuration.copy().let { it.setReadOnly(true) it } @@ -118,7 +118,7 @@ public class KotlinCoreEnvironment private constructor( } init { - val project = projectEnvironment.getProject() + val project = projectEnvironment.project project.registerService(DeclarationProviderFactoryService::class.java, CliDeclarationProviderFactoryService(sourceFiles)) project.registerService(ModuleVisibilityManager::class.java, CliModuleVisibilityManagerImpl()) @@ -136,7 +136,7 @@ public class KotlinCoreEnvironment private constructor( })) sourceFiles.sortedWith(object : Comparator { override fun compare(o1: KtFile, o2: KtFile): Int { - return o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath(), ignoreCase = true) + return o1.virtualFile.path.compareTo(o2.virtualFile.path, ignoreCase = true) } }) @@ -157,20 +157,20 @@ public class KotlinCoreEnvironment private constructor( } private val applicationEnvironment: CoreApplicationEnvironment - get() = projectEnvironment.getEnvironment() + get() = projectEnvironment.environment - public val application: MockApplication - get() = applicationEnvironment.getApplication() + val application: MockApplication + get() = applicationEnvironment.application - public val project: Project - get() = projectEnvironment.getProject() + val project: Project + get() = projectEnvironment.project - public val sourceLinesOfCode: Int by lazy { countLinesOfCode(sourceFiles) } + val sourceLinesOfCode: Int by lazy { countLinesOfCode(sourceFiles) } - public fun countLinesOfCode(sourceFiles: List): Int = + fun countLinesOfCode(sourceFiles: List): Int = sourceFiles.sumBy { - val text = it.getText() - StringUtil.getLineBreakCount(it.getText()) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1) + val text = it.text + StringUtil.getLineBreakCount(it.text) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1) } private fun fillClasspath(configuration: CompilerConfiguration) { @@ -203,10 +203,10 @@ public class KotlinCoreEnvironment private constructor( fun contentRootToVirtualFile(root: JvmContentRoot): VirtualFile? { when (root) { is JvmClasspathRoot -> { - return if (root.file.isFile()) findJarRoot(root) else findLocalDirectory(root) + return if (root.file.isFile) findJarRoot(root) else findLocalDirectory(root) } is JavaSourceRoot -> { - return if (root.file.isDirectory()) findLocalDirectory(root) else null + return if (root.file.isDirectory) findLocalDirectory(root) else null } else -> throw IllegalStateException("Unexpected root: $root") } @@ -214,7 +214,7 @@ public class KotlinCoreEnvironment private constructor( private fun findLocalDirectory(root: JvmContentRoot): VirtualFile? { val path = root.file - val localFile = applicationEnvironment.getLocalFileSystem().findFileByPath(path.getAbsolutePath()) + val localFile = applicationEnvironment.localFileSystem.findFileByPath(path.absolutePath) if (localFile == null) { report(WARNING, "Classpath entry points to a non-existent location: $path") return null @@ -224,7 +224,7 @@ public class KotlinCoreEnvironment private constructor( private fun findJarRoot(root: JvmClasspathRoot): VirtualFile? { val path = root.file - val jarFile = applicationEnvironment.getJarFileSystem().findFileByPath("${path}!/") + val jarFile = applicationEnvironment.jarFileSystem.findFileByPath("${path}!/") if (jarFile == null) { report(WARNING, "Classpath entry points to a file that is not a JAR archive: $path") return null @@ -244,7 +244,7 @@ public class KotlinCoreEnvironment private constructor( return uniqueSourceRoots } - public fun getSourceFiles(): List = sourceFiles + fun getSourceFiles(): List = sourceFiles private fun report(severity: CompilerMessageSeverity, message: String) { val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) @@ -258,8 +258,7 @@ public class KotlinCoreEnvironment private constructor( private var ourApplicationEnvironment: JavaCoreApplicationEnvironment? = null private var ourProjectCount = 0 - @JvmStatic - public fun createForProduction( + @JvmStatic fun createForProduction( parentDisposable: Disposable, configuration: CompilerConfiguration, configFilePaths: List ): KotlinCoreEnvironment { val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration, configFilePaths) @@ -287,8 +286,7 @@ public class KotlinCoreEnvironment private constructor( } @TestOnly - @JvmStatic - public fun createForTests( + @JvmStatic fun createForTests( parentDisposable: Disposable, configuration: CompilerConfiguration, extensionConfigs: List ): KotlinCoreEnvironment { // Tests are supposed to create a single project and dispose it right after use @@ -296,7 +294,7 @@ public class KotlinCoreEnvironment private constructor( } // used in the daemon for jar cache cleanup - public val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment + val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment private fun getOrCreateApplicationEnvironmentForProduction(configuration: CompilerConfiguration, configFilePaths: List): JavaCoreApplicationEnvironment { synchronized (APPLICATION_LOCK) { @@ -317,11 +315,11 @@ public class KotlinCoreEnvironment private constructor( } } - public fun disposeApplicationEnvironment() { + fun disposeApplicationEnvironment() { synchronized (APPLICATION_LOCK) { val environment = ourApplicationEnvironment ?: return ourApplicationEnvironment = null - Disposer.dispose(environment.getParentDisposable()) + Disposer.dispose(environment.parentDisposable) } } @@ -356,15 +354,15 @@ public class KotlinCoreEnvironment private constructor( private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) { val locator = configuration.get(JVMConfigurationKeys.COMPILER_JAR_LOCATOR) - var pluginRoot = if (locator == null) PathUtil.getPathUtilJar() else locator.getCompilerJar() + var pluginRoot = if (locator == null) PathUtil.getPathUtilJar() else locator.compilerJar val app = ApplicationManager.getApplication() - val parentFile = pluginRoot.getParentFile() + val parentFile = pluginRoot.parentFile - if (pluginRoot.isDirectory() && app != null && app.isUnitTestMode() - && FileUtil.toCanonicalPath(parentFile.getPath()).endsWith("out/production")) { + if (pluginRoot.isDirectory && app != null && app.isUnitTestMode + && FileUtil.toCanonicalPath(parentFile.path).endsWith("out/production")) { // hack for load extensions when compiler run directly from out directory(e.g. in tests) - val srcDir = parentFile.getParentFile().getParentFile() + val srcDir = parentFile.parentFile.parentFile pluginRoot = File(srcDir, "idea/src") } @@ -378,14 +376,13 @@ public class KotlinCoreEnvironment private constructor( } // made public for Upsource - @JvmStatic - public fun registerApplicationServices(applicationEnvironment: JavaCoreApplicationEnvironment) { + @JvmStatic fun registerApplicationServices(applicationEnvironment: JavaCoreApplicationEnvironment) { with(applicationEnvironment) { registerFileType(KotlinFileType.INSTANCE, "kt") registerFileType(KotlinFileType.INSTANCE, KotlinParserDefinition.STD_SCRIPT_SUFFIX) registerParserDefinition(KotlinParserDefinition()) - getApplication().registerService(KotlinBinaryClassCache::class.java, KotlinBinaryClassCache()) - getApplication().registerService(JavaClassSupers::class.java, JavaClassSupersImpl::class.java) + application.registerService(KotlinBinaryClassCache::class.java, KotlinBinaryClassCache()) + application.registerService(JavaClassSupers::class.java, JavaClassSupersImpl::class.java) } } @@ -395,9 +392,8 @@ public class KotlinCoreEnvironment private constructor( } // made public for Upsource - @JvmStatic - public fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment) { - with (projectEnvironment.getProject()) { + @JvmStatic fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment) { + with (projectEnvironment.project) { registerService(KotlinScriptDefinitionProvider::class.java, KotlinScriptDefinitionProvider()) registerService(KotlinJavaPsiFacade::class.java, KotlinJavaPsiFacade(this)) registerService(KtLightClassForFacade.FacadeStubCache::class.java, KtLightClassForFacade.FacadeStubCache(this)) @@ -405,7 +401,7 @@ public class KotlinCoreEnvironment private constructor( } private fun registerProjectServicesForCLI(projectEnvironment: JavaCoreProjectEnvironment) { - with (projectEnvironment.getProject()) { + with (projectEnvironment.project) { registerService(CoreJavaFileManager::class.java, ServiceManager.getService(this, JavaFileManager::class.java) as CoreJavaFileManager) val cliLightClassGenerationSupport = CliLightClassGenerationSupport(this) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreProjectEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreProjectEnvironment.kt index 7243f21335e..9b03483c83d 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreProjectEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreProjectEnvironment.kt @@ -25,5 +25,5 @@ open class KotlinCoreProjectEnvironment( disposable: Disposable, applicationEnvironment: JavaCoreApplicationEnvironment ) : JavaCoreProjectEnvironment(disposable, applicationEnvironment) { - override fun createCoreFileManager() = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(getProject())) + override fun createCoreFileManager() = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(project)) } \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/JvmContentRoots.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/JvmContentRoots.kt index 03f2b9e9f32..7a576c6948a 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/JvmContentRoots.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/JvmContentRoots.kt @@ -21,29 +21,27 @@ import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.ContentRoot import java.io.File -public data class JvmClasspathRoot(public override val file: File): JvmContentRoot +data class JvmClasspathRoot(override val file: File): JvmContentRoot -public data class JavaSourceRoot(public override val file: File, public val packagePrefix: String?): JvmContentRoot +data class JavaSourceRoot(override val file: File, val packagePrefix: String?): JvmContentRoot -public interface JvmContentRoot : ContentRoot { - public val file: File +interface JvmContentRoot : ContentRoot { + val file: File } -public fun CompilerConfiguration.addJvmClasspathRoot(file: File) { +fun CompilerConfiguration.addJvmClasspathRoot(file: File) { add(CommonConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(file)) } -public fun CompilerConfiguration.addJvmClasspathRoots(files: List): Unit = files.forEach { addJvmClasspathRoot(it) } +fun CompilerConfiguration.addJvmClasspathRoots(files: List): Unit = files.forEach { addJvmClasspathRoot(it) } -public val CompilerConfiguration.jvmClasspathRoots: List +val CompilerConfiguration.jvmClasspathRoots: List get() { return get(CommonConfigurationKeys.CONTENT_ROOTS)?.filterIsInstance()?.map { it.file } ?: emptyList() } -@JvmOverloads -public fun CompilerConfiguration.addJavaSourceRoot(file: File, packagePrefix: String? = null) { +@JvmOverloads fun CompilerConfiguration.addJavaSourceRoot(file: File, packagePrefix: String? = null) { add(CommonConfigurationKeys.CONTENT_ROOTS, JavaSourceRoot(file, packagePrefix)) } -@JvmOverloads -public fun CompilerConfiguration.addJavaSourceRoots(files: List, packagePrefix: String? = null): Unit = files.forEach { addJavaSourceRoot(it, packagePrefix) } \ No newline at end of file +@JvmOverloads fun CompilerConfiguration.addJavaSourceRoots(files: List, packagePrefix: String? = null): Unit = files.forEach { addJavaSourceRoot(it, packagePrefix) } \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/ModuleName.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/ModuleName.kt index 606b65b52ef..c793e6c231b 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/ModuleName.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/config/ModuleName.kt @@ -18,4 +18,4 @@ package org.jetbrains.kotlin.cli.jvm.config import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -public fun KotlinCoreEnvironment.getModuleName(): String = configuration.get(JVMConfigurationKeys.MODULE_NAME)!! \ No newline at end of file +fun KotlinCoreEnvironment.getModuleName(): String = configuration.get(JVMConfigurationKeys.MODULE_NAME)!! \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/DiagnosticMessageHolder.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/DiagnosticMessageHolder.kt index c8eacaa3c8b..362d9dc7202 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/DiagnosticMessageHolder.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/DiagnosticMessageHolder.kt @@ -18,6 +18,6 @@ package org.jetbrains.kotlin.cli.jvm.repl.messages import org.jetbrains.kotlin.cli.common.messages.DiagnosticMessageReporter -public interface DiagnosticMessageHolder : DiagnosticMessageReporter { +interface DiagnosticMessageHolder : DiagnosticMessageReporter { val renderedDiagnostics: String } \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplErrorLogger.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplErrorLogger.kt index ba273693f36..8f3f568ddf9 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplErrorLogger.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplErrorLogger.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.utils.rethrow import java.io.PrintWriter import java.io.StringWriter -public class ReplErrorLogger(private val ideMode: Boolean, private val replWriter: ReplWriter) { +class ReplErrorLogger(private val ideMode: Boolean, private val replWriter: ReplWriter) { fun logException(e: Throwable?) { if (ideMode) { val errorStringWriter = StringWriter() diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplIdeDiagnosticMessageHolder.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplIdeDiagnosticMessageHolder.kt index d1858d2e5be..3215474e171 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplIdeDiagnosticMessageHolder.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplIdeDiagnosticMessageHolder.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticUtils import org.w3c.dom.ls.DOMImplementationLS import javax.xml.parsers.DocumentBuilderFactory -public class ReplIdeDiagnosticMessageHolder : DiagnosticMessageHolder { +class ReplIdeDiagnosticMessageHolder : DiagnosticMessageHolder { private val diagnostics = arrayListOf>() override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemInWrapper.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemInWrapper.kt index 636d7fab2cd..1a18aba58cc 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemInWrapper.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemInWrapper.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.cli.jvm.repl.messages import java.io.ByteArrayOutputStream import java.io.InputStream -public class ReplSystemInWrapper( +class ReplSystemInWrapper( private val stdin: InputStream, private val replWriter: ReplWriter ) : InputStream() { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemOutWrapperForIde.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemOutWrapperForIde.kt index b71fb49becf..5ae54106cf8 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemOutWrapperForIde.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplSystemOutWrapperForIde.kt @@ -23,7 +23,7 @@ import java.io.PrintStream val END_LINE: String = LineSeparator.getSystemLineSeparator().separatorString val XML_PREAMBLE = "" -public class ReplSystemOutWrapperForIde(standardOut: PrintStream) : PrintStream(standardOut, true), ReplWriter { +class ReplSystemOutWrapperForIde(standardOut: PrintStream) : PrintStream(standardOut, true), ReplWriter { private enum class EscapeType { INITIAL_PROMPT, HELP_PROMPT, diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplTerminalDiagnosticMessageHolder.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplTerminalDiagnosticMessageHolder.kt index 2fff57e610c..5a40c15b69a 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplTerminalDiagnosticMessageHolder.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/ReplTerminalDiagnosticMessageHolder.kt @@ -21,7 +21,7 @@ import java.io.ByteArrayOutputStream import java.io.PrintStream import java.nio.ByteBuffer -public class ReplTerminalDiagnosticMessageHolder() : MessageCollectorBasedReporter, DiagnosticMessageHolder { +class ReplTerminalDiagnosticMessageHolder() : MessageCollectorBasedReporter, DiagnosticMessageHolder { private val outputStream = ByteArrayOutputStream() override val messageCollector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.WITHOUT_PATHS, false) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/UnescapeUtils.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/UnescapeUtils.kt index 3ce7b58210b..153137048eb 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/UnescapeUtils.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/messages/UnescapeUtils.kt @@ -23,8 +23,8 @@ import java.io.ByteArrayInputStream import javax.xml.parsers.DocumentBuilderFactory // using '#' to avoid collisions with xml escaping -public val SOURCE_CHARS: Array = arrayOf("\n", "#") -public val XML_REPLACEMENTS: Array = arrayOf("#n", "#diez") +val SOURCE_CHARS: Array = arrayOf("\n", "#") +val XML_REPLACEMENTS: Array = arrayOf("#n", "#diez") fun parseXml(inputMessage: String): String { fun strToSource(s: String) = InputSource(ByteArrayInputStream(s.toByteArray())) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ConsoleReplCommandReader.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ConsoleReplCommandReader.kt index 8c618c750c4..0387a2ce563 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ConsoleReplCommandReader.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ConsoleReplCommandReader.kt @@ -21,7 +21,7 @@ import jline.console.history.FileHistory import org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal import java.io.File -public class ConsoleReplCommandReader : ReplCommandReader { +class ConsoleReplCommandReader : ReplCommandReader { private val consoleReader = ConsoleReader("kotlin", System.`in`, System.`out`, null).apply { isHistoryEnabled = true expandEvents = false diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/IdeReplCommandReader.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/IdeReplCommandReader.kt index ba240910786..95d54a8aedb 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/IdeReplCommandReader.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/IdeReplCommandReader.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.repl.reader import org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal -public class IdeReplCommandReader : ReplCommandReader { +class IdeReplCommandReader : ReplCommandReader { override fun readLine(next: ReplFromTerminal.WhatNextAfterOneLine) = readLine() override fun flushHistory() = Unit } \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ReplCommandReader.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ReplCommandReader.kt index 3fd0bda9f6f..3fb48b0a8bd 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ReplCommandReader.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/reader/ReplCommandReader.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.repl.reader import org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal -public interface ReplCommandReader { - public fun readLine(next: ReplFromTerminal.WhatNextAfterOneLine): String? - public fun flushHistory() +interface ReplCommandReader { + fun readLine(next: ReplFromTerminal.WhatNextAfterOneLine): String? + fun flushHistory() } \ No newline at end of file diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt index 467950d092c..f64c10ff127 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt @@ -30,21 +30,21 @@ import java.io.IOException -public data class Profile(val name: String, val evaluator: Evaluator, val targetRoot: File) +data class Profile(val name: String, val evaluator: Evaluator, val targetRoot: File) -public fun createJvmProfile(targetRoot: File, version: Int): Profile = Profile("JVM$version", JvmPlatformEvaluator(version), File(targetRoot, "jvm$version")) -public fun createJsProfile(targetRoot: File): Profile = Profile("JS", JsPlatformEvaluator(), File(targetRoot, "js")) +fun createJvmProfile(targetRoot: File, version: Int): Profile = Profile("JVM$version", JvmPlatformEvaluator(version), File(targetRoot, "jvm$version")) +fun createJsProfile(targetRoot: File): Profile = Profile("JS", JsPlatformEvaluator(), File(targetRoot, "js")) -public val profileEvaluators: Map Evaluator> = +val profileEvaluators: Map Evaluator> = listOf(6, 7, 8).toMapBy({ version -> "JVM$version" }, { version -> { JvmPlatformEvaluator(version) } }) + ("JS" to { JsPlatformEvaluator() }) -public fun createProfile(name: String, targetRoot: File): Profile { +fun createProfile(name: String, targetRoot: File): Profile { val (profileName, evaluator) = profileEvaluators.entries.firstOrNull { it.key.equals(name, ignoreCase = true) } ?: throw IllegalArgumentException("Profile with name '$name' is not supported") return Profile(profileName, evaluator(), targetRoot) } -public class Preprocessor(val logger: Logger = SystemOutLogger) { +class Preprocessor(val logger: Logger = SystemOutLogger) { val fileType = KotlinFileType.INSTANCE val jetPsiFactory: KtPsiFactory @@ -70,7 +70,7 @@ public class Preprocessor(val logger: Logger = SystemOutLogger) { override fun toString() = this.javaClass.simpleName } - public fun processSources(sourceRoot: File, profile: Profile) { + fun processSources(sourceRoot: File, profile: Profile) { processDirectorySingleEvaluator(sourceRoot, profile.targetRoot, profile.evaluator) } diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/logging.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/logging.kt index c4a38f4ebd3..c1ccd77ea03 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/logging.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/logging.kt @@ -16,17 +16,17 @@ package org.jetbrains.kotlin.preprocessor -public interface Logger { +interface Logger { fun debug(msg: CharSequence) fun info(msg: CharSequence) fun warn(msg: CharSequence) fun error(msg: CharSequence) } -public object SystemOutLogger : Logger { +object SystemOutLogger : Logger { private fun out(level: String, msg: CharSequence) = println("[$level] $msg") - public var isDebugEnabled: Boolean = true + var isDebugEnabled: Boolean = true override fun debug(msg: CharSequence) { if (isDebugEnabled) out("DEBUG", msg) } @@ -35,9 +35,9 @@ public object SystemOutLogger : Logger { override fun error(msg: CharSequence) = out("ERROR", msg) } -public fun Logger.withPrefix(prefix: String): Logger = PrefixedLogger(prefix, this) +fun Logger.withPrefix(prefix: String): Logger = PrefixedLogger(prefix, this) -public class PrefixedLogger(val prefix: String, val logger: Logger) : Logger { +class PrefixedLogger(val prefix: String, val logger: Logger) : Logger { private fun prefix(msg: CharSequence): CharSequence = StringBuilder().apply { append(prefix) append(": ") diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt b/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt index 4aef34a7eaf..8300c8f378b 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt @@ -61,10 +61,10 @@ private fun traverseClass(c: Class<*>): ClassInfo { private fun getSetterInfos(c: Class<*>): List { val setterInfos = ArrayList() - for (method in c.getMethods()) { - for (annotation in method.getDeclaredAnnotations()) { - if (annotation.annotationClass.java.getName().endsWith(".Inject")) { - setterInfos.add(SetterInfo(method, method.getGenericParameterTypes().toList())) + for (method in c.methods) { + for (annotation in method.declaredAnnotations) { + if (annotation.annotationClass.java.name.endsWith(".Inject")) { + setterInfos.add(SetterInfo(method, method.genericParameterTypes.toList())) } } } @@ -72,16 +72,16 @@ private fun getSetterInfos(c: Class<*>): List { } private fun getConstructorInfo(c: Class<*>): ConstructorInfo? { - if (Modifier.isAbstract(c.getModifiers()) || c.isPrimitive()) + if (Modifier.isAbstract(c.modifiers) || c.isPrimitive) return null - val constructors = c.getConstructors() - val hasSinglePublicConstructor = constructors.singleOrNull()?.let { Modifier.isPublic(it.getModifiers()) } ?: false + val constructors = c.constructors + val hasSinglePublicConstructor = constructors.singleOrNull()?.let { Modifier.isPublic(it.modifiers) } ?: false if (!hasSinglePublicConstructor) return null val constructor = constructors.single() - return ConstructorInfo(constructor, constructor.getGenericParameterTypes().toList()) + return ConstructorInfo(constructor, constructor.genericParameterTypes.toList()) } @@ -89,10 +89,10 @@ private fun collectInterfacesRecursive(type: Type, result: MutableSet) { // TODO: should apply generic substitution through hierarchy val klass : Class<*>? = when(type) { is Class<*> -> type - is ParameterizedType -> type.getRawType() as? Class<*> + is ParameterizedType -> type.rawType as? Class<*> else -> null } - klass?.getGenericInterfaces()?.forEach { + klass?.genericInterfaces?.forEach { if (result.add(it)) { collectInterfacesRecursive(it, result) } @@ -104,8 +104,8 @@ private fun getRegistrations(klass: Class<*>): List { val superClasses = sequence(klass) { when (it) { - is Class<*> -> it.getGenericSuperclass() - is ParameterizedType -> (it.getRawType() as? Class<*>)?.getGenericSuperclass() + is Class<*> -> it.genericSuperclass + is ParameterizedType -> (it.rawType as? Class<*>)?.genericSuperclass else -> null } } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Components.kt b/compiler/container/src/org/jetbrains/kotlin/container/Components.kt index ed46308acdd..1a0f02d44fd 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Components.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Components.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.container import java.lang.reflect.* -public class InstanceComponentDescriptor(val instance: Any) : ComponentDescriptor { +class InstanceComponentDescriptor(val instance: Any) : ComponentDescriptor { override fun getValue(): Any = instance override fun getRegistrations(): Iterable = instance.javaClass.getInfo().registrations @@ -26,7 +26,7 @@ public class InstanceComponentDescriptor(val instance: Any) : ComponentDescripto override fun getDependencies(context: ValueResolveContext): Collection> = emptyList() override fun toString(): String { - return "Instance: ${instance.javaClass.getSimpleName()}" + return "Instance: ${instance.javaClass.simpleName}" } } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Container.kt b/compiler/container/src/org/jetbrains/kotlin/container/Container.kt index 764fca5fb84..867deef1b68 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Container.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Container.kt @@ -24,13 +24,13 @@ import java.lang.reflect.WildcardType class ContainerConsistencyException(message: String) : Exception(message) -public interface ComponentContainer { +interface ComponentContainer { fun createResolveContext(requestingDescriptor: ValueDescriptor): ValueResolveContext } -public interface ComponentProvider { - public fun resolve(request: Type): ValueDescriptor? - public fun create(request: Class): T +interface ComponentProvider { + fun resolve(request: Type): ValueDescriptor? + fun create(request: Class): T } object DynamicComponentDescriptor : ValueDescriptor { @@ -38,8 +38,8 @@ object DynamicComponentDescriptor : ValueDescriptor { override fun toString(): String = "Dynamic" } -public class StorageComponentContainer(id: String) : ComponentContainer, ComponentProvider, Closeable { - public val unknownContext: ComponentResolveContext by lazy { ComponentResolveContext(this, DynamicComponentDescriptor) } +class StorageComponentContainer(id: String) : ComponentContainer, ComponentProvider, Closeable { + val unknownContext: ComponentResolveContext by lazy { ComponentResolveContext(this, DynamicComponentDescriptor) } val componentStorage = ComponentStorage(id) override fun createResolveContext(requestingDescriptor: ValueDescriptor): ValueResolveContext { @@ -59,7 +59,7 @@ public class StorageComponentContainer(id: String) : ComponentContainer, Compone override fun close() = componentStorage.dispose() - public fun resolve(request: Type, context: ValueResolveContext): ValueDescriptor? { + fun resolve(request: Type, context: ValueResolveContext): ValueDescriptor? { return componentStorage.resolve(request, context) ?: resolveIterable(request, context) } @@ -69,14 +69,14 @@ public class StorageComponentContainer(id: String) : ComponentContainer, Compone private fun resolveIterable(request: Type, context: ValueResolveContext): ValueDescriptor? { if (request !is ParameterizedType) return null - val rawType = request.getRawType() + val rawType = request.rawType if (rawType != Iterable::class.java) return null - val typeArguments = request.getActualTypeArguments() + val typeArguments = request.actualTypeArguments if (typeArguments.size != 1) return null val iterableTypeArgument = typeArguments[0] val iterableType = when (iterableTypeArgument) { is WildcardType -> { - val upperBounds = iterableTypeArgument.getUpperBounds() + val upperBounds = iterableTypeArgument.upperBounds if (upperBounds.size != 1) return null upperBounds[0] } @@ -87,7 +87,7 @@ public class StorageComponentContainer(id: String) : ComponentContainer, Compone return IterableDescriptor(componentStorage.resolveMultiple(iterableType, context)) } - public fun resolveMultiple(request: Class<*>, context: ValueResolveContext = unknownContext): Iterable { + fun resolveMultiple(request: Class<*>, context: ValueResolveContext = unknownContext): Iterable { return componentStorage.resolveMultiple(request, context) } @@ -103,18 +103,18 @@ public class StorageComponentContainer(id: String) : ComponentContainer, Compone } } -public fun StorageComponentContainer.registerSingleton(klass: Class<*>): StorageComponentContainer { +fun StorageComponentContainer.registerSingleton(klass: Class<*>): StorageComponentContainer { return registerDescriptors(listOf(SingletonTypeComponentDescriptor(this, klass))) } -public fun StorageComponentContainer.registerInstance(instance: Any): StorageComponentContainer { +fun StorageComponentContainer.registerInstance(instance: Any): StorageComponentContainer { return registerDescriptors(listOf(InstanceComponentDescriptor(instance))) } -public inline fun StorageComponentContainer.resolve(context: ValueResolveContext = unknownContext): ValueDescriptor? { +inline fun StorageComponentContainer.resolve(context: ValueResolveContext = unknownContext): ValueDescriptor? { return resolve(T::class.java, context) } -public inline fun StorageComponentContainer.resolveMultiple(context: ValueResolveContext = unknownContext): Iterable { +inline fun StorageComponentContainer.resolveMultiple(context: ValueResolveContext = unknownContext): Iterable { return resolveMultiple(T::class.java, context) } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt b/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt index 24b98c02748..712221c0f41 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.container import java.util.ArrayList import java.util.HashSet -public fun topologicalSort(items: Iterable, dependencies: (T) -> Iterable): List { +fun topologicalSort(items: Iterable, dependencies: (T) -> Iterable): List { val itemsInProgress = HashSet() val completedItems = HashSet() val result = ArrayList() @@ -48,4 +48,4 @@ public fun topologicalSort(items: Iterable, dependencies: (T) -> Iterable return result.apply { reverse() } } -public class CycleInTopoSortException : Exception() \ No newline at end of file +class CycleInTopoSortException : Exception() \ No newline at end of file diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt b/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt index 41fb2eef21d..723bffc98f9 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt @@ -18,8 +18,8 @@ package org.jetbrains.kotlin.container import java.lang.reflect.* -public interface ValueDescriptor { - public fun getValue(): Any +interface ValueDescriptor { + fun getValue(): Any } internal interface ComponentDescriptor : ValueDescriptor { @@ -29,7 +29,7 @@ internal interface ComponentDescriptor : ValueDescriptor { get() = false } -public class IterableDescriptor(val descriptors: Iterable) : ValueDescriptor { +class IterableDescriptor(val descriptors: Iterable) : ValueDescriptor { override fun getValue(): Any { return descriptors.map { it.getValue() } } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt b/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt index e6090414a34..0820532ced0 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt @@ -18,27 +18,26 @@ package org.jetbrains.kotlin.container import kotlin.reflect.KProperty -public fun createContainer(id: String, init: StorageComponentContainer.() -> Unit): StorageComponentContainer { +fun createContainer(id: String, init: StorageComponentContainer.() -> Unit): StorageComponentContainer { val c = StorageComponentContainer(id) c.init() c.compose() return c } -public inline fun StorageComponentContainer.useImpl() { +inline fun StorageComponentContainer.useImpl() { registerSingleton(T::class.java) } -public inline fun ComponentProvider.get(): T { +inline fun ComponentProvider.get(): T { return getService(T::class.java) } -@Suppress("UNCHECKED_CAST") -public fun ComponentProvider.getService(request: Class): T { +@Suppress("UNCHECKED_CAST") fun ComponentProvider.getService(request: Class): T { return resolve(request)!!.getValue() as T } -public fun StorageComponentContainer.useInstance(instance: Any) { +fun StorageComponentContainer.useInstance(instance: Any) { registerInstance(instance) } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Registry.kt b/compiler/container/src/org/jetbrains/kotlin/container/Registry.kt index bb94c2517ae..8251d8850e9 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Registry.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Registry.kt @@ -33,11 +33,11 @@ internal class ComponentRegistry { private var registrationMap = MultiMap.createLinkedSet() - public fun addAll(descriptors: Collection) { + fun addAll(descriptors: Collection) { registrationMap.putAllValues(buildRegistrationMap(descriptors)) } - public fun tryGetEntry(request: Type): Collection { + fun tryGetEntry(request: Type): Collection { return registrationMap.get(request) } } \ No newline at end of file diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Resolve.kt b/compiler/container/src/org/jetbrains/kotlin/container/Resolve.kt index d6fd73e6d20..208bc621fa6 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Resolve.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Resolve.kt @@ -22,30 +22,30 @@ import java.lang.reflect.Method import java.lang.reflect.Type import java.util.ArrayList -public interface ValueResolver { +interface ValueResolver { fun resolve(request: Type, context: ValueResolveContext): ValueDescriptor? } -public interface ValueResolveContext { +interface ValueResolveContext { fun resolve(registration: Type): ValueDescriptor? } -public class ComponentResolveContext(val container: StorageComponentContainer, val requestingDescriptor: ValueDescriptor) : ValueResolveContext { +class ComponentResolveContext(val container: StorageComponentContainer, val requestingDescriptor: ValueDescriptor) : ValueResolveContext { override fun resolve(registration: Type): ValueDescriptor? = container.resolve(registration, this) override fun toString(): String = "for $requestingDescriptor in $container" } -public class ConstructorBinding(val constructor: Constructor<*>, val argumentDescriptors: List) +class ConstructorBinding(val constructor: Constructor<*>, val argumentDescriptors: List) -public class MethodBinding(val method: Method, val argumentDescriptors: List) { +class MethodBinding(val method: Method, val argumentDescriptors: List) { fun invoke(instance: Any) { val arguments = computeArguments(argumentDescriptors).toTypedArray() method.invoke(instance, *arguments) } } -public fun computeArguments(argumentDescriptors: List): List = argumentDescriptors.map { it.getValue() } +fun computeArguments(argumentDescriptors: List): List = argumentDescriptors.map { it.getValue() } fun Class<*>.bindToConstructor(context: ValueResolveContext): ConstructorBinding { val constructorInfo = getInfo().constructorInfo!! @@ -54,7 +54,7 @@ fun Class<*>.bindToConstructor(context: ValueResolveContext): ConstructorBinding } fun Method.bindToMethod(context: ValueResolveContext): MethodBinding { - return MethodBinding(this, bindArguments(getGenericParameterTypes().toList(), context)) + return MethodBinding(this, bindArguments(genericParameterTypes.toList(), context)) } private fun Member.bindArguments(parameters: List, context: ValueResolveContext): List { diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt b/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt index 70df19e3530..d5ec9b63190 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt @@ -29,12 +29,12 @@ enum class ComponentState { Disposed } -public abstract class SingletonDescriptor(val container: ComponentContainer) : ComponentDescriptor, Closeable { +abstract class SingletonDescriptor(val container: ComponentContainer) : ComponentDescriptor, Closeable { private var instance: Any? = null protected var state: ComponentState = ComponentState.Null private val disposableObjects by lazy { ArrayList() } - public override fun getValue(): Any { + override fun getValue(): Any { when { state == ComponentState.Corrupted -> throw ContainerConsistencyException("Component descriptor $this is corrupted and cannot be accessed") state == ComponentState.Disposed -> throw ContainerConsistencyException("Component descriptor $this is disposed and cannot be accessed") @@ -115,9 +115,9 @@ public abstract class SingletonDescriptor(val container: ComponentContainer) : C get() = true } -public open class SingletonTypeComponentDescriptor(container: ComponentContainer, val klass: Class<*>) : SingletonDescriptor(container) { +open class SingletonTypeComponentDescriptor(container: ComponentContainer, val klass: Class<*>) : SingletonDescriptor(container) { override fun createInstance(context: ValueResolveContext): Any = createInstanceOf(klass, context) - public override fun getRegistrations(): Iterable = klass.getInfo().registrations + override fun getRegistrations(): Iterable = klass.getInfo().registrations private fun createInstanceOf(klass: Class<*>, context: ValueResolveContext): Any { val binding = klass.bindToConstructor(context) @@ -141,11 +141,11 @@ public open class SingletonTypeComponentDescriptor(container: ComponentContainer return classInfo.constructorInfo?.parameters.orEmpty() + classInfo.setterInfos.flatMap { it.parameters } } - override fun toString(): String = "Singleton: ${klass.getSimpleName()}" + override fun toString(): String = "Singleton: ${klass.simpleName}" } class ImplicitSingletonTypeComponentDescriptor(container: ComponentContainer, klass: Class<*>) : SingletonTypeComponentDescriptor(container, klass) { override fun toString(): String { - return "Implicit: ${klass.getSimpleName()}" + return "Implicit: ${klass.simpleName}" } } \ No newline at end of file diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt b/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt index 10caf0b28e6..c8c2fbfe916 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt @@ -26,7 +26,7 @@ import java.util.ArrayList import java.util.HashSet import java.util.LinkedHashSet -public enum class ComponentStorageState { +enum class ComponentStorageState { Initial, Initialized, Disposing, @@ -35,7 +35,7 @@ public enum class ComponentStorageState { internal class InvalidCardinalityException(message: String, val descriptors: Collection) : Exception(message) -public class ComponentStorage(val myId: String) : ValueResolver { +class ComponentStorage(val myId: String) : ValueResolver { var state = ComponentStorageState.Initial private val registry = ComponentRegistry() private val descriptors = LinkedHashSet() @@ -65,7 +65,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { } } - public fun dump(printer: PrintStream): Unit = with (printer) { + fun dump(printer: PrintStream): Unit = with (printer) { val heading = "Container: $myId" println(heading) println("=".repeat(heading.length)) @@ -88,7 +88,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { } - public fun resolveMultiple(request: Type, context: ValueResolveContext): Iterable { + fun resolveMultiple(request: Type, context: ValueResolveContext): Iterable { registerDependency(request, context) return registry.tryGetEntry(request) } @@ -106,7 +106,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { } - public fun compose(context: ComponentResolveContext) { + fun compose(context: ComponentResolveContext) { if (state != ComponentStorageState.Initial) throw ContainerConsistencyException("Container $myId was already composed.") @@ -154,13 +154,13 @@ public class ComponentStorage(val myId: String) : ValueResolver { if (entry.isEmpty()) { val rawType: Class<*>? = when (type) { is Class<*> -> type - is ParameterizedType -> type.getRawType() as? Class<*> + is ParameterizedType -> type.rawType as? Class<*> else -> null } if (rawType == null) continue - if (!Modifier.isAbstract(rawType.getModifiers()) && !rawType.isPrimitive()) { + if (!Modifier.isAbstract(rawType.modifiers) && !rawType.isPrimitive) { val implicitDescriptor = ImplicitSingletonTypeComponentDescriptor(context.container, rawType) adhocDescriptors.add(implicitDescriptor) collectAdhocComponents(context, implicitDescriptor, visitedTypes, adhocDescriptors) @@ -178,7 +178,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { } } - public fun dispose() { + fun dispose() { if (state != ComponentStorageState.Initialized) { if (state == ComponentStorageState.Initial) return // it is valid to dispose container which was not initialized diff --git a/compiler/container/tests/org/jetbrains/kotlin/container/tests/TestComponents.kt b/compiler/container/tests/org/jetbrains/kotlin/container/tests/TestComponents.kt index bbeb3b452f8..3505df6f654 100644 --- a/compiler/container/tests/org/jetbrains/kotlin/container/tests/TestComponents.kt +++ b/compiler/container/tests/org/jetbrains/kotlin/container/tests/TestComponents.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.container.tests import java.io.* interface TestComponentInterface { - public val disposed: Boolean + val disposed: Boolean fun foo() } @@ -27,7 +27,7 @@ interface TestClientComponentInterface { } class TestComponent : TestComponentInterface, Closeable { - public override var disposed: Boolean = false + override var disposed: Boolean = false override fun close() { disposed = true } @@ -38,7 +38,7 @@ class TestComponent : TestComponentInterface, Closeable { } class ManualTestComponent(val name: String) : TestComponentInterface, Closeable { - public override var disposed: Boolean = false + override var disposed: Boolean = false override fun close() { disposed = true } diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt index 815285a323c..a3570880df3 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt @@ -341,9 +341,9 @@ object KotlinCompilerClient { } -data class DaemonReportMessage(public val category: DaemonReportCategory, public val message: String) +data class DaemonReportMessage(val category: DaemonReportCategory, val message: String) -class DaemonReportingTargets(public val out: PrintStream? = null, public val messages: MutableCollection? = null) +class DaemonReportingTargets(val out: PrintStream? = null, val messages: MutableCollection? = null) internal fun isProcessAlive(process: Process) = diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassInfo.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassInfo.kt index 299d8d35fa8..1fa9d77c214 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassInfo.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassInfo.kt @@ -18,14 +18,14 @@ package org.jetbrains.kotlin.fileClasses import org.jetbrains.kotlin.name.FqName -public interface JvmFileClassInfo { - public val fileClassFqName: FqName - public val facadeClassFqName: FqName - public val withJvmName: Boolean - public val withJvmMultifileClass: Boolean +interface JvmFileClassInfo { + val fileClassFqName: FqName + val facadeClassFqName: FqName + val withJvmName: Boolean + val withJvmMultifileClass: Boolean } -public class JvmSimpleFileClassInfo( +class JvmSimpleFileClassInfo( override val fileClassFqName: FqName, override val withJvmName: Boolean ) : JvmFileClassInfo { @@ -33,7 +33,7 @@ public class JvmSimpleFileClassInfo( override val withJvmMultifileClass: Boolean get() = false } -public class JvmMultifileClassPartInfo( +class JvmMultifileClassPartInfo( override val fileClassFqName: FqName, override val facadeClassFqName: FqName ) : JvmFileClassInfo { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassUtil.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassUtil.kt index 0ed3454cc75..4bb43d7368b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassUtil.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/JvmFileClassUtil.kt @@ -26,61 +26,51 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor -public object JvmFileClassUtil { - public val JVM_NAME: FqName = FqName("kotlin.jvm.JvmName") - public val JVM_NAME_SHORT: String = JVM_NAME.shortName().asString() +object JvmFileClassUtil { + val JVM_NAME: FqName = FqName("kotlin.jvm.JvmName") + val JVM_NAME_SHORT: String = JVM_NAME.shortName().asString() - public val JVM_MULTIFILE_CLASS: FqName = FqName("kotlin.jvm.JvmMultifileClass") - public val JVM_MULTIFILE_CLASS_SHORT = JVM_MULTIFILE_CLASS.shortName().asString() + val JVM_MULTIFILE_CLASS: FqName = FqName("kotlin.jvm.JvmMultifileClass") + val JVM_MULTIFILE_CLASS_SHORT = JVM_MULTIFILE_CLASS.shortName().asString() - @JvmStatic - public fun getFileClassInfo(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations?): JvmFileClassInfo = + @JvmStatic fun getFileClassInfo(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations?): JvmFileClassInfo = if (jvmFileClassAnnotations != null) getFileClassInfoForAnnotation(file, jvmFileClassAnnotations) else getDefaultFileClassInfo(file) - @JvmStatic - public fun getFileClassInfoForAnnotation(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): JvmFileClassInfo = + @JvmStatic fun getFileClassInfoForAnnotation(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): JvmFileClassInfo = if (jvmFileClassAnnotations.multipleFiles) JvmMultifileClassPartInfo(getHiddenPartFqName(file, jvmFileClassAnnotations), getFacadeFqName(file, jvmFileClassAnnotations)) else JvmSimpleFileClassInfo(getFacadeFqName(file, jvmFileClassAnnotations), true) - @JvmStatic - public fun getDefaultFileClassInfo(file: KtFile): JvmFileClassInfo = + @JvmStatic fun getDefaultFileClassInfo(file: KtFile): JvmFileClassInfo = JvmSimpleFileClassInfo(PackagePartClassUtils.getPackagePartFqName(file.packageFqName, file.name), false) - @JvmStatic - public fun getFacadeFqName(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): FqName = + @JvmStatic fun getFacadeFqName(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): FqName = file.packageFqName.child(Name.identifier(jvmFileClassAnnotations.name)) - @JvmStatic - public fun getPartFqNameForDeserializedCallable(callable: DeserializedCallableMemberDescriptor): FqName { + @JvmStatic fun getPartFqNameForDeserializedCallable(callable: DeserializedCallableMemberDescriptor): FqName { val implClassName = getImplClassName(callable) ?: error("No implClassName for $callable") val packageFqName = (callable.containingDeclaration as PackageFragmentDescriptor).fqName return packageFqName.child(implClassName) } - @JvmStatic - public fun getImplClassName(callable: DeserializedCallableMemberDescriptor): Name? = + @JvmStatic fun getImplClassName(callable: DeserializedCallableMemberDescriptor): Name? = callable.getImplClassNameForDeserialized() - @JvmStatic - public fun getHiddenPartFqName(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): FqName = + @JvmStatic fun getHiddenPartFqName(file: KtFile, jvmFileClassAnnotations: ParsedJvmFileClassAnnotations): FqName = file.packageFqName.child(Name.identifier(manglePartName(jvmFileClassAnnotations.name, file.name))) - @JvmStatic - public fun manglePartName(facadeName: String, fileName: String): String = + @JvmStatic fun manglePartName(facadeName: String, fileName: String): String = "${facadeName}__${PackagePartClassUtils.getFilePartShortName(fileName)}" - @JvmStatic - public fun getFileClassInfoNoResolve(file: KtFile): JvmFileClassInfo = + @JvmStatic fun getFileClassInfoNoResolve(file: KtFile): JvmFileClassInfo = getFileClassInfo(file, parseJvmNameOnFileNoResolve(file)) - @JvmStatic - public fun parseJvmNameOnFileNoResolve(file: KtFile): ParsedJvmFileClassAnnotations? { + @JvmStatic fun parseJvmNameOnFileNoResolve(file: KtFile): ParsedJvmFileClassAnnotations? { val jvmName = findAnnotationEntryOnFileNoResolve(file, JVM_NAME_SHORT) ?: return null val nameExpr = jvmName.valueArguments.firstOrNull()?.getArgumentExpression() ?: return null val name = getLiteralStringFromRestrictedConstExpression(nameExpr) ?: return null @@ -89,8 +79,7 @@ public object JvmFileClassUtil { return ParsedJvmFileClassAnnotations(name, isMultifileClassPart) } - @JvmStatic - public fun findAnnotationEntryOnFileNoResolve(file: KtFile, shortName: String): KtAnnotationEntry? = + @JvmStatic fun findAnnotationEntryOnFileNoResolve(file: KtFile, shortName: String): KtAnnotationEntry? = file.fileAnnotationList?.annotationEntries?.firstOrNull { it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == shortName } @@ -105,9 +94,9 @@ public object JvmFileClassUtil { } } -private class ParsedJvmFileClassAnnotations(public val name: String, public val multipleFiles: Boolean) +private class ParsedJvmFileClassAnnotations(val name: String, val multipleFiles: Boolean) -public val KtFile.javaFileFacadeFqName: FqName +val KtFile.javaFileFacadeFqName: FqName get() { return CachedValuesManager.getCachedValue(this) { val facadeFqName = @@ -117,7 +106,7 @@ public val KtFile.javaFileFacadeFqName: FqName } } -public fun KtDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve( +fun KtDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve( getContainingKtFile(), JvmFileClassUtil.JVM_MULTIFILE_CLASS_SHORT ) != null diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/NoResolveFileClassesProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/NoResolveFileClassesProvider.kt index 04fd00e197e..b9e5238169c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/NoResolveFileClassesProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/fileClasses/NoResolveFileClassesProvider.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.fileClasses import org.jetbrains.kotlin.psi.KtFile -public object NoResolveFileClassesProvider : JvmFileClassesProvider { +object NoResolveFileClassesProvider : JvmFileClassesProvider { override fun getFileClassInfo(file: KtFile): JvmFileClassInfo = JvmFileClassUtil.getFileClassInfo(file, JvmFileClassUtil.parseJvmNameOnFileNoResolve(file)) } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt index a61fa7062ed..5a3736b7c81 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory -public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentScope: GlobalSearchScope, project: Project, lookupTracker: LookupTracker) { +fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentScope: GlobalSearchScope, project: Project, lookupTracker: LookupTracker) { useInstance(moduleContentScope) useInstance(lookupTracker) useImpl() @@ -66,7 +66,7 @@ public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentS useImpl() } -public fun createContainerForLazyResolveWithJava( +fun createContainerForLazyResolveWithJava( moduleContext: ModuleContext, bindingTrace: BindingTrace, declarationProviderFactory: DeclarationProviderFactory, moduleContentScope: GlobalSearchScope, moduleClassResolver: ModuleClassResolver, targetEnvironment: TargetEnvironment = CompilerEnvironment, @@ -91,7 +91,7 @@ public fun createContainerForLazyResolveWithJava( } -public fun createContainerForTopDownAnalyzerForJvm( +fun createContainerForTopDownAnalyzerForJvm( moduleContext: ModuleContext, bindingTrace: BindingTrace, declarationProviderFactory: DeclarationProviderFactory, @@ -121,7 +121,7 @@ private fun StorageComponentContainer.javaAnalysisInit() { get().postCreate() } -public class ContainerForTopDownAnalyzerForJvm(container: StorageComponentContainer) { +class ContainerForTopDownAnalyzerForJvm(container: StorageComponentContainer) { val lazyTopDownAnalyzerForTopLevel: LazyTopDownAnalyzerForTopLevel by container val javaDescriptorResolver: JavaDescriptorResolver by container val deserializationComponentsForJava: DeserializationComponentsForJava by container diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/inline/inlineUtil.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/inline/inlineUtil.kt index 64ccc1a7d7b..dde4f074de6 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/inline/inlineUtil.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/inline/inlineUtil.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.TypeTable import org.jetbrains.kotlin.serialization.jvm.BitEncoding import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil -public fun inlineFunctionsJvmNames(bytes: ByteArray): Set { +fun inlineFunctionsJvmNames(bytes: ByteArray): Set { val header = readKotlinHeader(bytes) val annotationData = header.annotationData val strings = header.strings diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt index 8dcee1a3756..71e2a0254d2 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt @@ -30,8 +30,8 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, public val message: String) { - public interface DataFlowExtras { +class RuntimeAssertionInfo(val needNotNullAssertion: Boolean, val message: String) { + interface DataFlowExtras { class OnlyMessage(message: String) : DataFlowExtras { override val canBeNull: Boolean get() = true override val possibleTypes: Set get() = setOf() @@ -44,8 +44,7 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ } companion object { - @JvmStatic - public fun create( + @JvmStatic fun create( expectedType: KotlinType, expressionType: KotlinType, dataFlowExtras: DataFlowExtras @@ -77,11 +76,11 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ } private fun KotlinType.hasEnhancedNullability() - = getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null + = annotations.findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null } } -public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { +object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) { if (TypeUtils.noExpectedType(c.expectedType)) return @@ -94,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { override val possibleTypes: Set get() = c.dataFlowInfo.getCollectedTypes(dataFlowValue) override val presentableText: String - get() = StringUtil.trimMiddle(expression.getText(), 50) + get() = StringUtil.trimMiddle(expression.text, 50) private val dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, expressionType, c) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt index d2e4dda2cfb..06cf92a7149 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt @@ -23,4 +23,4 @@ import org.jetbrains.kotlin.util.slicedMap.RewritePolicy import org.jetbrains.kotlin.util.slicedMap.WritableSlice import org.jetbrains.kotlin.utils.DO_NOTHING -public val RUNTIME_ASSERTION_INFO: WritableSlice = BasicWritableSlice(RewritePolicy.DO_NOTHING) +val RUNTIME_ASSERTION_INFO: WritableSlice = BasicWritableSlice(RewritePolicy.DO_NOTHING) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaClassFinderPostConstruct.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaClassFinderPostConstruct.kt index fc97255d6e9..3008e2c2dfd 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaClassFinderPostConstruct.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaClassFinderPostConstruct.kt @@ -23,22 +23,22 @@ import javax.annotation.PostConstruct import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer -public open class JavaClassFinderPostConstruct { +open class JavaClassFinderPostConstruct { @PostConstruct - public open fun postCreate() {} + open fun postCreate() {} } -public class JavaLazyAnalyzerPostConstruct : JavaClassFinderPostConstruct() { - public var project: Project? = null +class JavaLazyAnalyzerPostConstruct : JavaClassFinderPostConstruct() { + var project: Project? = null @Inject set - public var trace: BindingTrace? = null + var trace: BindingTrace? = null @Inject set - public var codeAnalyzer: KotlinCodeAnalyzer? = null + var codeAnalyzer: KotlinCodeAnalyzer? = null @Inject set @PostConstruct override fun postCreate() { - CodeAnalyzerInitializer.getInstance(project!!).initialize(trace!!, codeAnalyzer!!.getModuleDescriptor(), codeAnalyzer!!) + CodeAnalyzerInitializer.getInstance(project!!).initialize(trace!!, codeAnalyzer!!.moduleDescriptor, codeAnalyzer!!) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaFlexibleTypeCapabilitiesProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaFlexibleTypeCapabilitiesProvider.kt index 5e633f19396..d7022d8597e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaFlexibleTypeCapabilitiesProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/JavaFlexibleTypeCapabilitiesProvider.kt @@ -20,6 +20,6 @@ import org.jetbrains.kotlin.resolve.TypeResolver.FlexibleTypeCapabilitiesProvide import org.jetbrains.kotlin.types.FlexibleTypeCapabilities import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver -public class JavaFlexibleTypeCapabilitiesProvider : FlexibleTypeCapabilitiesProvider() { +class JavaFlexibleTypeCapabilitiesProvider : FlexibleTypeCapabilitiesProvider() { override fun getCapabilities(): FlexibleTypeCapabilities = LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaSourceElementFactoryImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaSourceElementFactoryImpl.kt index c3b69a0a994..6ac8b4788a7 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaSourceElementFactoryImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/JavaSourceElementFactoryImpl.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.load.java.sources.JavaSourceElement private class JavaSourceElementImpl(override val javaElement: JavaElement) : PsiSourceElement, JavaSourceElement { override val psi: PsiElement? - get() = (javaElement as JavaElementImpl<*>).getPsi() + get() = (javaElement as JavaElementImpl<*>).psi } -public class JavaSourceElementFactoryImpl : JavaSourceElementFactory { +class JavaSourceElementFactoryImpl : JavaSourceElementFactory { override fun source(javaElement: JavaElement): JavaSourceElement = JavaSourceElementImpl(javaElement) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt index 326000a67d3..745b63f6907 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.BindingContext.* import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.BindingContextUtils -public class LazyResolveBasedCache(private val resolveSession: ResolveSession) : JavaResolverCache { +class LazyResolveBasedCache(private val resolveSession: ResolveSession) : JavaResolverCache { private val trace: BindingTrace get() = resolveSession.trace @@ -37,23 +37,23 @@ public class LazyResolveBasedCache(private val resolveSession: ResolveSession) : } override fun recordMethod(method: JavaMethod, descriptor: SimpleFunctionDescriptor) { - BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, (method as JavaMethodImpl).getPsi(), descriptor) + BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, (method as JavaMethodImpl).psi, descriptor) } override fun recordConstructor(element: JavaElement, descriptor: ConstructorDescriptor) { - trace.record(CONSTRUCTOR, (element as JavaElementImpl<*>).getPsi(), descriptor) + trace.record(CONSTRUCTOR, (element as JavaElementImpl<*>).psi, descriptor) } override fun recordField(field: JavaField, descriptor: PropertyDescriptor) { - trace.record(VARIABLE, (field as JavaFieldImpl).getPsi(), descriptor) + trace.record(VARIABLE, (field as JavaFieldImpl).psi, descriptor) } override fun recordClass(javaClass: JavaClass, descriptor: ClassDescriptor) { - trace.record(CLASS, (javaClass as JavaClassImpl).getPsi(), descriptor) + trace.record(CLASS, (javaClass as JavaClassImpl).psi, descriptor) } private fun findInPackageFragments(fullFqName: FqName): ClassDescriptor? { - var fqName = if (fullFqName.isRoot()) fullFqName else fullFqName.parent() + var fqName = if (fullFqName.isRoot) fullFqName else fullFqName.parent() while (true) { val packageDescriptor = resolveSession.getPackageFragment(fqName) @@ -62,7 +62,7 @@ public class LazyResolveBasedCache(private val resolveSession: ResolveSession) : val result = ResolveSessionUtils.findClassByRelativePath(packageDescriptor.getMemberScope(), fullFqName.tail(fqName)) if (result != null) return result - if (fqName.isRoot()) break + if (fqName.isRoot) break fqName = fqName.parent() } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt index 2e418d64309..07cfea96e29 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt @@ -27,23 +27,21 @@ import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter import org.jetbrains.kotlin.util.slicedMap.Slices import org.jetbrains.kotlin.util.slicedMap.WritableSlice -public class TraceBasedErrorReporter(private val trace: BindingTrace) : ErrorReporter { +class TraceBasedErrorReporter(private val trace: BindingTrace) : ErrorReporter { companion object { private val LOG = Logger.getInstance(TraceBasedErrorReporter::class.java) - @JvmField - public val ABI_VERSION_ERRORS: WritableSlice = Slices.createCollectiveSlice() + @JvmField val ABI_VERSION_ERRORS: WritableSlice = Slices.createCollectiveSlice() // TODO: MutableList is a workaround for KT-5792 Covariant types in Kotlin translated to wildcard types in Java - @JvmField - public val INCOMPLETE_HIERARCHY: WritableSlice> = Slices.createCollectiveSlice() + @JvmField val INCOMPLETE_HIERARCHY: WritableSlice> = Slices.createCollectiveSlice() } - public data class AbiVersionErrorData( - public val actualVersion: BinaryVersion, - public val filePath: String, - public val classId: ClassId + data class AbiVersionErrorData( + val actualVersion: BinaryVersion, + val filePath: String, + val classId: ClassId ) override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: BinaryVersion) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt index 3e918c83653..c11d47c13ad 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import java.util.* -public object SamConversionResolverImpl : SamConversionResolver { +object SamConversionResolverImpl : SamConversionResolver { override fun resolveSamConstructor(constructorOwner: DeclarationDescriptor, classifier: () -> ClassifierDescriptor?): SamConstructorDescriptor? { val classifierDescriptor = classifier() if (classifierDescriptor !is LazyJavaClassDescriptor || classifierDescriptor.functionTypeForSamInterface == null) return null @@ -55,13 +55,13 @@ public object SamConversionResolverImpl : SamConversionResolver { classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor ): KotlinType? { - val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null + val jClass = (classDescriptor.source as? JavaSourceElement)?.javaElement as? JavaClass ?: return null val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null - val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) { + val abstractMethod = if (jClass.fqName == samInterfaceMethod.containingClass.fqName) { resolveMethod(samInterfaceMethod) } else { - findFunctionWithMostSpecificReturnType(TypeUtils.getAllSupertypes(classDescriptor.getDefaultType())) + findFunctionWithMostSpecificReturnType(TypeUtils.getAllSupertypes(classDescriptor.defaultType)) } return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod) } @@ -79,8 +79,8 @@ public object SamConversionResolverImpl : SamConversionResolver { } var currentMostSpecificType = candidates[0] for (candidate in candidates) { - val candidateReturnType = candidate.getReturnType() - val currentMostSpecificReturnType = currentMostSpecificType.getReturnType() + val candidateReturnType = candidate.returnType + val currentMostSpecificReturnType = currentMostSpecificType.returnType assert(candidateReturnType != null && currentMostSpecificReturnType != null) { "$candidate, $currentMostSpecificReturnType" } if (KotlinTypeChecker.DEFAULT.isSubtypeOf(candidateReturnType!!, currentMostSpecificReturnType!!)) { currentMostSpecificType = candidate diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt index 9a1076186ff..79acff38300 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPackageImpl.kt @@ -25,17 +25,17 @@ import org.jetbrains.kotlin.load.java.structure.impl.JavaElementCollectionFromPs import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -public class JavaPackageImpl(psiPackage: PsiPackage, private val scope: GlobalSearchScope) : JavaElementImpl(psiPackage), JavaPackage { +class JavaPackageImpl(psiPackage: PsiPackage, private val scope: GlobalSearchScope) : JavaElementImpl(psiPackage), JavaPackage { override fun getClasses(nameFilter: (Name) -> Boolean): Collection { - val psiClasses = getPsi().getClasses(scope).filter { - val name = it.getName() + val psiClasses = psi.getClasses(scope).filter { + val name = it.name name != null && nameFilter(Name.identifier(name)) } return classes(psiClasses) } - override fun getSubPackages() = packages(getPsi().getSubPackages(scope), scope) + override fun getSubPackages() = packages(psi.getSubPackages(scope), scope) - override fun getFqName() = FqName(getPsi().getQualifiedName()) + override fun getFqName() = FqName(psi.qualifiedName) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt index 50229ad1676..bb99bd3e739 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt @@ -25,16 +25,16 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -public class JavaPropertyInitializerEvaluatorImpl : JavaPropertyInitializerEvaluator { +class JavaPropertyInitializerEvaluatorImpl : JavaPropertyInitializerEvaluator { override fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor): ConstantValue<*>? { - val initializer = (field as JavaFieldImpl).getInitializer() + val initializer = (field as JavaFieldImpl).initializer val evaluated = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false) ?: return null val factory = ConstantValueFactory(descriptor.builtIns) when (evaluated) { //Note: evaluated expression may be of class that does not match field type in some cases // tested for Int, left other checks just in case is Byte, is Short, is Int, is Long -> { - return factory.createIntegerConstantValue((evaluated as Number).toLong(), descriptor.getType()) + return factory.createIntegerConstantValue((evaluated as Number).toLong(), descriptor.type) } else -> { return factory.createConstantValue(evaluated) @@ -45,6 +45,6 @@ public class JavaPropertyInitializerEvaluatorImpl : JavaPropertyInitializerEvalu override fun isNotNullCompileTimeConstant(field: JavaField): Boolean { // PsiUtil.isCompileTimeConstant returns false for null-initialized fields, // see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression() - return PsiUtil.isCompileTimeConstant((field as JavaFieldImpl).getPsi()) + return PsiUtil.isCompileTimeConstant((field as JavaFieldImpl).psi) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt index 99fd986f76a..81b364fca31 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/annotationArgumentsImpl.kt @@ -25,7 +25,7 @@ abstract class JavaAnnotationArgumentImpl( ) : JavaAnnotationArgument { companion object Factory { fun create(argument: PsiAnnotationMemberValue, name: Name?): JavaAnnotationArgument { - val value = JavaPsiFacade.getInstance(argument.getProject()).getConstantEvaluationHelper().computeConstantExpression(argument) + val value = JavaPsiFacade.getInstance(argument.project).constantEvaluationHelper.computeConstantExpression(argument) if (value is Enum<*>) { return JavaEnumValueAnnotationArgumentImpl(argument as PsiReferenceExpression, name) } @@ -53,7 +53,7 @@ class JavaArrayAnnotationArgumentImpl( private val psiValue: PsiArrayInitializerMemberValue, name: Name? ) : JavaAnnotationArgumentImpl(name), JavaArrayAnnotationArgument { - override fun getElements() = psiValue.getInitializers().map { JavaAnnotationArgumentImpl.create(it, null) } + override fun getElements() = psiValue.initializers.map { JavaAnnotationArgumentImpl.create(it, null) } } class JavaEnumValueAnnotationArgumentImpl( @@ -65,7 +65,7 @@ class JavaEnumValueAnnotationArgumentImpl( return when (element) { null -> null is PsiEnumConstant -> JavaFieldImpl(element) - else -> throw IllegalStateException("Reference argument should be an enum value, but was $element: ${element.getText()}") + else -> throw IllegalStateException("Reference argument should be an enum value, but was $element: ${element.text}") } } } @@ -74,7 +74,7 @@ class JavaClassObjectAnnotationArgumentImpl( private val psiExpression: PsiClassObjectAccessExpression, name: Name? ) : JavaAnnotationArgumentImpl(name), JavaClassObjectAnnotationArgument { - override fun getReferencedType() = JavaTypeImpl.create(psiExpression.getOperand().getType()) + override fun getReferencedType() = JavaTypeImpl.create(psiExpression.operand.type) } class JavaAnnotationAsAnnotationArgumentImpl( diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt index f8670e2d617..9472d1bb5cf 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt @@ -41,11 +41,11 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import java.lang.annotation.Target -public class JavaAnnotationCallChecker : CallChecker { +class JavaAnnotationCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { - val resultingDescriptor = resolvedCall.getResultingDescriptor().getOriginal() + val resultingDescriptor = resolvedCall.resultingDescriptor.original if (resultingDescriptor !is JavaConstructorDescriptor || - resultingDescriptor.getContainingDeclaration().getKind() != ClassKind.ANNOTATION_CLASS) return + resultingDescriptor.containingDeclaration.kind != ClassKind.ANNOTATION_CLASS) return reportErrorsOnPositionedArguments(resolvedCall, context) reportDeprecatedJavaAnnotation(resolvedCall, context) @@ -73,7 +73,7 @@ public class JavaAnnotationCallChecker : CallChecker { argument: Map.Entry, diagnostic: DiagnosticFactory0 ) { - argument.value.getArguments().forEach { + argument.value.arguments.forEach { if (it.getArgumentExpression() != null) { context.trace.report( diagnostic.on( diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinder.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinder.kt index 1ad9fe83160..b28616d73f4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinder.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinder.kt @@ -20,10 +20,9 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope -public interface JvmVirtualFileFinder : VirtualFileFinder, KotlinClassFinder { - public object SERVICE { - @JvmStatic - public fun getInstance(project: Project): JvmVirtualFileFinder = +interface JvmVirtualFileFinder : VirtualFileFinder, KotlinClassFinder { + object SERVICE { + @JvmStatic fun getInstance(project: Project): JvmVirtualFileFinder = ServiceManager.getService(project, JvmVirtualFileFinderFactory::class.java).create(GlobalSearchScope.allScope(project)) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinderFactory.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinderFactory.kt index b51dabe9bcc..27273c9e8a4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinderFactory.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JvmVirtualFileFinderFactory.kt @@ -20,12 +20,11 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope -public interface JvmVirtualFileFinderFactory : VirtualFileFinderFactory { +interface JvmVirtualFileFinderFactory : VirtualFileFinderFactory { override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder - public object SERVICE { - @JvmStatic - public fun getInstance(project: Project): JvmVirtualFileFinderFactory = + object SERVICE { + @JvmStatic fun getInstance(project: Project): JvmVirtualFileFinderFactory = ServiceManager.getService(project, JvmVirtualFileFinderFactory::class.java) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/PackagePartClassUtils.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/PackagePartClassUtils.kt index 1b9cefa2513..44df6a0f645 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/PackagePartClassUtils.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/PackagePartClassUtils.kt @@ -29,14 +29,13 @@ import org.jetbrains.kotlin.psi.KtScript import org.jetbrains.kotlin.resolve.jvm.JvmClassName import java.util.* -public object PackagePartClassUtils { - @JvmStatic - public fun getPathHashCode(file: VirtualFile): Int = +object PackagePartClassUtils { + @JvmStatic fun getPathHashCode(file: VirtualFile): Int = file.path.toLowerCase().hashCode() private val PART_CLASS_NAME_SUFFIX = "Kt" - public @JvmStatic fun getPartClassName(str: String): String = + @JvmStatic fun getPartClassName(str: String): String = if (str.isEmpty()) "_$PART_CLASS_NAME_SUFFIX" else @@ -51,45 +50,37 @@ public object PackagePartClassUtils { "_$str" @TestOnly - @JvmStatic - public fun getDefaultFileClassFqName(packageFqName: FqName, file: VirtualFile): FqName = + @JvmStatic fun getDefaultFileClassFqName(packageFqName: FqName, file: VirtualFile): FqName = getPackagePartFqName(packageFqName, file.name) @TestOnly - @JvmStatic - public fun getDefaultPartFqName(facadeClassFqName: FqName, file: VirtualFile): FqName = + @JvmStatic fun getDefaultPartFqName(facadeClassFqName: FqName, file: VirtualFile): FqName = getPackagePartFqName(facadeClassFqName.parent(), file.name) - @JvmStatic - public fun getPackagePartFqName(packageFqName: FqName, fileName: String): FqName { + @JvmStatic fun getPackagePartFqName(packageFqName: FqName, fileName: String): FqName { val partClassName = getFilePartShortName(fileName) return packageFqName.child(Name.identifier(partClassName)) } @Deprecated("Migrate to JvmFileClassesProvider") - @JvmStatic - public fun getPackagePartInternalName(file: KtFile): String = + @JvmStatic fun getPackagePartInternalName(file: KtFile): String = JvmClassName.byFqNameWithoutInnerClasses(getPackagePartFqName(file)).internalName @Deprecated("Migrate to JvmFileClassesProvider") - @JvmStatic - public fun getPackagePartFqName(file: KtFile): FqName = + @JvmStatic fun getPackagePartFqName(file: KtFile): FqName = getPackagePartFqName(file.packageFqName, file.name) - @JvmStatic - public fun getFilesWithCallables(files: Collection): List = + @JvmStatic fun getFilesWithCallables(files: Collection): List = files.filter { fileHasTopLevelCallables(it) } - @JvmStatic - public fun fileHasTopLevelCallables(file: KtFile): Boolean = + @JvmStatic fun fileHasTopLevelCallables(file: KtFile): Boolean = file.declarations.any { it is KtProperty || it is KtNamedFunction || it is KtScript } - @JvmStatic - public fun getFilePartShortName(fileName: String): String = + @JvmStatic fun getFilePartShortName(fileName: String): String = getPartClassName(FileUtil.getNameWithoutExtension(fileName)) } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt index 00af70bbd02..16fb8de8dfe 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt @@ -26,14 +26,14 @@ import org.jetbrains.kotlin.utils.rethrow import java.io.FileNotFoundException import java.io.IOException -public class VirtualFileKotlinClass private constructor( - public val file: VirtualFile, +class VirtualFileKotlinClass private constructor( + val file: VirtualFile, className: ClassId, classHeader: KotlinClassHeader, innerClasses: FileBasedKotlinClass.InnerClassesInfo ) : FileBasedKotlinClass(className, classHeader, innerClasses) { - override fun getLocation() = file.getPath() + override fun getLocation() = file.path override fun getFileContents(): ByteArray { try { @@ -47,7 +47,7 @@ public class VirtualFileKotlinClass private constructor( override fun equals(other: Any?) = other is VirtualFileKotlinClass && other.file == file override fun hashCode() = file.hashCode() - override fun toString() = "${javaClass.getSimpleName()}: $file" + override fun toString() = "${javaClass.simpleName}: $file" companion object Factory { private val LOG = Logger.getInstance(VirtualFileKotlinClass::class.java) @@ -56,7 +56,7 @@ public class VirtualFileKotlinClass private constructor( @Deprecated("Use KotlinBinaryClassCache") fun create(file: VirtualFile, fileContent: ByteArray?): VirtualFileKotlinClass? { return perfCounter.time { - assert(file.getFileType() == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" } + assert(file.fileType == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" } try { val byteContent = fileContent ?: file.contentsToByteArray(false) @@ -78,6 +78,6 @@ public class VirtualFileKotlinClass private constructor( } private fun renderFileReadingErrorMessage(file: VirtualFile): String = - "Could not read file: ${file.getPath()}; size in bytes: ${file.getLength()}; file type: ${file.getFileType().getName()}" + "Could not read file: ${file.path}; size in bytes: ${file.length}; file type: ${file.fileType.name}" } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt index a989c5bf366..e1b0f4bea53 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClassFinder.kt @@ -21,29 +21,29 @@ import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.utils.sure -public abstract class VirtualFileKotlinClassFinder : JvmVirtualFileFinder { +abstract class VirtualFileKotlinClassFinder : JvmVirtualFileFinder { override fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? { val file = findVirtualFileWithHeader(classId) ?: return null return KotlinBinaryClassCache.getKotlinBinaryClass(file) } override fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? { - var file = (javaClass as JavaClassImpl).getPsi().getContainingFile()!!.getVirtualFile() ?: return null + var file = (javaClass as JavaClassImpl).psi.containingFile!!.virtualFile ?: return null if (javaClass.getOuterClass() != null) { // For nested classes we get a file of the containing class, to get the actual class file for A.B.C, // we take the file for A, take its parent directory, then in this directory we look for A$B$C.class - file = file.getParent()!!.findChild(classFileName(javaClass) + ".class").sure { "Virtual file not found for $javaClass" } + file = file.parent!!.findChild(classFileName(javaClass) + ".class").sure { "Virtual file not found for $javaClass" } } return KotlinBinaryClassCache.getKotlinBinaryClass(file) } private fun classFileName(jClass: JavaClass): String { - val outerClass = jClass.getOuterClass() + val outerClass = jClass.outerClass if (outerClass == null) { - return jClass.getName().asString() + return jClass.name.asString() } - return classFileName(outerClass) + "$" + jClass.getName().asString() + return classFileName(outerClass) + "$" + jClass.name.asString() } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/annotationUtil.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/annotationUtil.kt index 301b50baa56..d9502d63cd6 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/annotationUtil.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/annotationUtil.kt @@ -23,10 +23,10 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument fun getJavaAnnotationCallValueArgumentsThatShouldBeNamed(resolvedCall: ResolvedCall<*>): Map = - resolvedCall.getValueArguments().filter { + resolvedCall.valueArguments.filter { p -> - p.key.getName() != JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME && + p.key.name != JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME && p.value is ExpressionValueArgument && - !((p.value as ExpressionValueArgument).getValueArgument()?.isNamed() ?: true) + !((p.value as ExpressionValueArgument).valueArgument?.isNamed() ?: true) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackageFragmentProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackageFragmentProvider.kt index 87e5d4241ea..d513f3ce511 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackageFragmentProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackageFragmentProvider.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* -public class IncrementalPackageFragmentProvider( +class IncrementalPackageFragmentProvider( sourceFiles: Collection, val moduleDescriptor: ModuleDescriptor, val storageManager: StorageManager, @@ -51,7 +51,7 @@ public class IncrementalPackageFragmentProvider( ) : PackageFragmentProvider { companion object { - public fun fqNamesToLoad(obsoletePackageParts: Collection, sourceFiles: Collection): Set = + fun fqNamesToLoad(obsoletePackageParts: Collection, sourceFiles: Collection): Set = (obsoletePackageParts.map { JvmClassName.byInternalName(it).packageFqName } + PackagePartClassUtils.getFilesWithCallables(sourceFiles).map { it.packageFqName }).toSet() } @@ -67,7 +67,7 @@ public class IncrementalPackageFragmentProvider( return } - if (!fqName.isRoot()) { + if (!fqName.isRoot) { val parent = fqName.parent() createPackageFragment(parent) fqNameToSubFqNames.putValue(parent, fqName) @@ -88,8 +88,8 @@ public class IncrementalPackageFragmentProvider( } - public inner class IncrementalPackageFragment(fqName: FqName) : PackageFragmentDescriptorImpl(moduleDescriptor, fqName) { - public val target: TargetId + inner class IncrementalPackageFragment(fqName: FqName) : PackageFragmentDescriptorImpl(moduleDescriptor, fqName) { + val target: TargetId get() = this@IncrementalPackageFragmentProvider.target val memberScope: NotNullLazyValue = storageManager.createLazyValue { @@ -126,7 +126,7 @@ public class IncrementalPackageFragmentProvider( } } - public fun getPackageFragmentForMultifileClass(multifileClassFqName: FqName): IncrementalMultifileClassPackageFragment? { + fun getPackageFragmentForMultifileClass(multifileClassFqName: FqName): IncrementalMultifileClassPackageFragment? { val facadeInternalName = JvmClassName.byFqNameWithoutInnerClasses(multifileClassFqName).internalName val partsNames = incrementalCache.getStableMultifileFacadeParts(facadeInternalName) ?: return null return IncrementalMultifileClassPackageFragment(multifileClassFqName, partsNames) @@ -134,7 +134,7 @@ public class IncrementalPackageFragmentProvider( override fun getMemberScope(): MemberScope = memberScope() - public inner class IncrementalMultifileClassPackageFragment( + inner class IncrementalMultifileClassPackageFragment( val multifileClassFqName: FqName, val partsNames: Collection ) : PackageFragmentDescriptorImpl(moduleDescriptor, multifileClassFqName.parent()) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackagePartProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackagePartProvider.kt index 0a6ae1b798e..eb214851bea 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackagePartProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/IncrementalPackagePartProvider.kt @@ -43,8 +43,7 @@ internal class IncrementalPackagePartProvider private constructor( } companion object { - @JvmStatic - public fun create( + @JvmStatic fun create( parent: PackagePartProvider, sourceFiles: Collection, targets: List?, diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCache.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCache.kt index 205d2a33ed7..ffb52105de5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCache.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCache.kt @@ -20,22 +20,22 @@ import java.io.Serializable data class JvmPackagePartProto(val data: ByteArray, val strings: Array) : Serializable -public interface IncrementalCache { - public fun getObsoletePackageParts(): Collection +interface IncrementalCache { + fun getObsoletePackageParts(): Collection - public fun getObsoleteMultifileClasses(): Collection + fun getObsoleteMultifileClasses(): Collection - public fun getStableMultifileFacadeParts(facadeInternalName: String): Collection? + fun getStableMultifileFacadeParts(facadeInternalName: String): Collection? - public fun getMultifileFacade(partInternalName: String): String? + fun getMultifileFacade(partInternalName: String): String? - public fun getPackagePartData(partInternalName: String): JvmPackagePartProto? + fun getPackagePartData(partInternalName: String): JvmPackagePartProto? - public fun getModuleMappingData(): ByteArray? + fun getModuleMappingData(): ByteArray? - public fun registerInline(fromPath: String, jvmSignature: String, toPath: String) + fun registerInline(fromPath: String, jvmSignature: String, toPath: String) - public fun getClassFilePath(internalClassName: String): String + fun getClassFilePath(internalClassName: String): String - public fun close() + fun close() } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCompilationComponents.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCompilationComponents.kt index 69ab35b14ba..3fafb3802fa 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCompilationComponents.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/incremental/components/IncrementalCompilationComponents.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.kotlin.incremental.components import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.modules.TargetId -public interface IncrementalCompilationComponents { - public fun getIncrementalCache(target: TargetId): IncrementalCache - public fun getLookupTracker(): LookupTracker +interface IncrementalCompilationComponents { + fun getIncrementalCache(target: TargetId): IncrementalCache + fun getLookupTracker(): LookupTracker } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt index 2b90fd6f570..c4f1574d00d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt @@ -34,18 +34,17 @@ interface ModuleVisibilityManager { fun addModule(module: Module) fun addFriendPath(path: String) - public object SERVICE { - @JvmStatic - public fun getInstance(project: Project): ModuleVisibilityManager = + object SERVICE { + @JvmStatic fun getInstance(project: Project): ModuleVisibilityManager = ServiceManager.getService(project, ModuleVisibilityManager::class.java) } } -public val DeclarationDescriptor.isFromIncrementalPackageFragment: Boolean +val DeclarationDescriptor.isFromIncrementalPackageFragment: Boolean get() = DescriptorUtils.getParentOfType(this, PackageFragmentDescriptor::class.java, false) is IncrementalPackageFragmentProvider.IncrementalPackageFragment -public fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outDirectory: File?): Boolean { +fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outDirectory: File?): Boolean { val packageFragment = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java, false) if (packageFragment is IncrementalPackageFragmentProvider.IncrementalPackageFragment) return true diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt index 30447acfab5..9341b3acf66 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt @@ -26,11 +26,11 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean { +fun DeclarationDescriptor.hasNativeAnnotation(): Boolean { return this is FunctionDescriptor && this.isExternal } -public class NativeFunChecker : DeclarationChecker { +class NativeFunChecker : DeclarationChecker { override fun check( declaration: KtDeclaration, descriptor: DeclarationDescriptor, @@ -39,11 +39,11 @@ public class NativeFunChecker : DeclarationChecker { ) { if (!descriptor.hasNativeAnnotation()) return - if (DescriptorUtils.isInterface(descriptor.getContainingDeclaration())) { + if (DescriptorUtils.isInterface(descriptor.containingDeclaration)) { diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE.on(declaration)) } else if (descriptor is CallableMemberDescriptor && - descriptor.getModality() == Modality.ABSTRACT) { + descriptor.modality == Modality.ABSTRACT) { diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration)) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt index 7ef951f718f..894e6eb1a65 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/JvmAnalyzerFacade.kt @@ -39,12 +39,12 @@ import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService import java.util.* -public class JvmPlatformParameters( - public val moduleByJavaClass: (JavaClass) -> ModuleInfo? +class JvmPlatformParameters( + val moduleByJavaClass: (JavaClass) -> ModuleInfo? ) : PlatformAnalysisParameters -public object JvmAnalyzerFacade : AnalyzerFacade() { +object JvmAnalyzerFacade : AnalyzerFacade() { override fun createResolverForModule( moduleInfo: M, moduleDescriptor: ModuleDescriptorImpl, @@ -105,8 +105,7 @@ public object JvmAnalyzerFacade : AnalyzerFacade() { return ResolverForModule(CompositePackageFragmentProvider(providersForModule), container) } - @JvmStatic - public fun getAllFilesToAnalyze(project: Project, moduleInfo: ModuleInfo?, baseFiles: Collection): List { + @JvmStatic fun getAllFilesToAnalyze(project: Project, moduleInfo: ModuleInfo?, baseFiles: Collection): List { val allFiles = ArrayList(baseFiles) for (externalDeclarationsProvider in ExternalDeclarationsProvider.getInstances(project)) { allFiles.addAll(externalDeclarationsProvider.getExternalDeclarations(moduleInfo)) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/KotlinCliJavaFileManager.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/KotlinCliJavaFileManager.kt index 51471843de8..2a0037bccde 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/KotlinCliJavaFileManager.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/KotlinCliJavaFileManager.kt @@ -21,6 +21,6 @@ import com.intellij.psi.impl.file.impl.JavaFileManager import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.name.ClassId -public interface KotlinCliJavaFileManager : JavaFileManager { - public fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? +interface KotlinCliJavaFileManager : JavaFileManager { + fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/annotationUtil.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/annotationUtil.kt index d9985d8fb5e..4c762c2dc56 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/annotationUtil.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/annotationUtil.kt @@ -23,11 +23,11 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils -public fun DeclarationDescriptor.hasJvmOverloadsAnnotation(): Boolean { - return getAnnotations().findAnnotation(FqName("kotlin.jvm.JvmOverloads")) != null +fun DeclarationDescriptor.hasJvmOverloadsAnnotation(): Boolean { + return annotations.findAnnotation(FqName("kotlin.jvm.JvmOverloads")) != null } -public fun DeclarationDescriptor.findJvmFieldAnnotation(): AnnotationDescriptor? { +fun DeclarationDescriptor.findJvmFieldAnnotation(): AnnotationDescriptor? { val fqName = FqName("kotlin.jvm.JvmField") val annotation = annotations.findAnnotation(fqName) if (annotation != null) { @@ -37,11 +37,11 @@ public fun DeclarationDescriptor.findJvmFieldAnnotation(): AnnotationDescriptor? return annotations.getUseSiteTargetedAnnotations().asSequence().filter { it.target == AnnotationUseSiteTarget.FIELD }.map { it.annotation }.firstOrNull { - val descriptor = it.getType().getConstructor().getDeclarationDescriptor() + val descriptor = it.type.constructor.declarationDescriptor descriptor is ClassDescriptor && fqName.toUnsafe() == DescriptorUtils.getFqName(descriptor) } } -public fun DeclarationDescriptor.hasJvmFieldAnnotation(): Boolean { +fun DeclarationDescriptor.hasJvmFieldAnnotation(): Boolean { return findJvmFieldAnnotation() != null } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt index 6dc3dcdb75d..4ac7620b20d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.types.KotlinTypeImpl import org.jetbrains.kotlin.types.TypeProjectionImpl -public class JavaClassOnCompanionChecker : CallChecker { +class JavaClassOnCompanionChecker : CallChecker { override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { val descriptor = resolvedCall.resultingDescriptor if (descriptor !is PropertyDescriptor || descriptor.name.asString() != "javaClass") return diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt index 80ce4f19012..857b11b8ee8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt @@ -42,22 +42,22 @@ import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible -public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { +class JavaNullabilityWarningsChecker : AdditionalTypeChecker { private fun KotlinType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? { - if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN + if (!isError && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN - if (getAnnotations().isMarkedNullable()) return ErrorsJvm.NullabilityInformationSource.JAVA + if (annotations.isMarkedNullable()) return ErrorsJvm.NullabilityInformationSource.JAVA return null } private fun KotlinType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? { - if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN + if (!isError && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN - if (!isMarkedNullable() && getAnnotations().isMarkedNotNull()) return ErrorsJvm.NullabilityInformationSource.JAVA + if (!isMarkedNullable && annotations.isMarkedNotNull()) return ErrorsJvm.NullabilityInformationSource.JAVA return null } @@ -99,10 +99,10 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { when (expression) { is KtWhenExpression -> - if (expression.getElseExpression() == null) { + if (expression.elseExpression == null) { // Check for conditionally-exhaustive when on platform enums, see KT-6399 - val type = expression.getSubjectExpression()?.let { c.trace.getType(it) } ?: return - if (type.isFlexible() && TypeUtils.isNullableType(type.flexibility().upperBound) && !type.getAnnotations().isMarkedNotNull()) { + val type = expression.subjectExpression?.let { c.trace.getType(it) } ?: return + if (type.isFlexible() && TypeUtils.isNullableType(type.flexibility().upperBound) && !type.annotations.isMarkedNotNull()) { val enumClassDescriptor = WhenChecker.getClassDescriptorOfTypeIfEnum(type) ?: return if (WhenChecker.isWhenOnEnumExhaustive(expression, c.trace, enumClassDescriptor) @@ -113,8 +113,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } } is KtPostfixExpression -> - if (expression.getOperationToken() == KtTokens.EXCLEXCL) { - val baseExpression = expression.getBaseExpression() ?: return + if (expression.operationToken == KtTokens.EXCLEXCL) { + val baseExpression = expression.baseExpression ?: return val baseExpressionType = c.trace.getType(baseExpression) ?: return doIfNotNull( DataFlowValueFactory.createDataFlowValue(baseExpression, baseExpressionType, c), @@ -124,9 +124,9 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } } is KtBinaryExpression -> - when (expression.getOperationToken()) { + when (expression.operationToken) { KtTokens.ELVIS -> { - val baseExpression = expression.getLeft() + val baseExpression = expression.left val baseExpressionType = baseExpression?.let{ c.trace.getType(it) } ?: return doIfNotNull( DataFlowValueFactory.createDataFlowValue(baseExpression!!, baseExpressionType, c), @@ -139,9 +139,9 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { KtTokens.EXCLEQ, KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ -> { - if (expression.getLeft() != null && expression.getRight() != null) { + if (expression.left != null && expression.right != null) { SenselessComparisonChecker.checkSenselessComparisonWithNull( - expression, expression.getLeft()!!, expression.getRight()!!, c, + expression, expression.left!!, expression.right!!, c, { c.trace.getType(it) }, { value -> @@ -171,8 +171,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, c) if (!safeAccess) { doCheckType( - receiverArgument.getType(), - receiverParameter.getType(), + receiverArgument.type, + receiverParameter.type, dataFlowValue, c.dataFlowInfo ) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ReflectionAPICallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ReflectionAPICallChecker.kt index b331f46a06d..c2ac35bc467 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ReflectionAPICallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ReflectionAPICallChecker.kt @@ -48,15 +48,15 @@ class ReflectionAPICallChecker(private val module: ModuleDescriptor, storageMana override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { if (isReflectionAvailable) return - val descriptor = resolvedCall.getResultingDescriptor() - val containingClass = descriptor.getContainingDeclaration() as? ClassDescriptor ?: return + val descriptor = resolvedCall.resultingDescriptor + val containingClass = descriptor.containingDeclaration as? ClassDescriptor ?: return if (!ReflectionTypes.isReflectionClass(containingClass)) return // Skip some symbols which are supposed to work fine without kotlin-reflect.jar: // - 'name' on anything // - 'invoke' on functions (or on anything else for that matter) // - 'get'/'set' on properties - val name = descriptor.getName() + val name = descriptor.name when { name == OperatorNameConventions.INVOKE -> return name.asString() == "name" -> return diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/TraitDefaultMethodCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/TraitDefaultMethodCallChecker.kt index bc77f2088ce..9a7be614980 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/TraitDefaultMethodCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/TraitDefaultMethodCallChecker.kt @@ -28,13 +28,13 @@ import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -public class TraitDefaultMethodCallChecker : CallChecker { +class TraitDefaultMethodCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { if (getSuperCallExpression(resolvedCall.getCall()) == null) return - val targetDescriptor = resolvedCall.getResultingDescriptor().getOriginal() - val containerDescriptor = targetDescriptor.getContainingDeclaration() + val targetDescriptor = resolvedCall.resultingDescriptor.original + val containerDescriptor = targetDescriptor.containingDeclaration if (containerDescriptor is JavaClassDescriptor && DescriptorUtils.isInterface(containerDescriptor)) { //is java interface default method called from trait diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt index d284603eee5..8208631543c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils -public object RepeatableAnnotationChecker: AdditionalAnnotationChecker { +object RepeatableAnnotationChecker: AdditionalAnnotationChecker { override fun checkEntries(entries: List, actualTargets: List, trace: BindingTrace) { val entryTypesWithAnnotations = hashMapOf>() @@ -57,7 +57,7 @@ public object RepeatableAnnotationChecker: AdditionalAnnotationChecker { } } -public object FileClassAnnotationsChecker: AdditionalAnnotationChecker { +object FileClassAnnotationsChecker: AdditionalAnnotationChecker { // JvmName & JvmMultifileClass annotations are applicable to multi-file class parts regardless of their retention. private val ALWAYS_APPLICABLE = hashSetOf(JvmFileClassUtil.JVM_NAME, JvmFileClassUtil.JVM_MULTIFILE_CLASS) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt index 74289df1119..3b182f5a70d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmFieldAnnotation import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -public class LocalFunInlineChecker : DeclarationChecker { +class LocalFunInlineChecker : DeclarationChecker { override fun check( declaration: KtDeclaration, @@ -44,13 +44,13 @@ public class LocalFunInlineChecker : DeclarationChecker { if (InlineUtil.isInline(descriptor) && declaration is KtNamedFunction && descriptor is FunctionDescriptor && - descriptor.getVisibility() == Visibilities.LOCAL) { + descriptor.visibility == Visibilities.LOCAL) { diagnosticHolder.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor)) } } } -public class PlatformStaticAnnotationChecker : DeclarationChecker { +class PlatformStaticAnnotationChecker : DeclarationChecker { override fun check( declaration: KtDeclaration, @@ -98,7 +98,7 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker { } } -public class JvmNameAnnotationChecker : DeclarationChecker { +class JvmNameAnnotationChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink, bindingContext: BindingContext) { val platformNameAnnotation = DescriptorUtils.getJvmNameAnnotation(descriptor) if (platformNameAnnotation != null) { @@ -135,7 +135,7 @@ public class JvmNameAnnotationChecker : DeclarationChecker { } } -public class VolatileAnnotationChecker : DeclarationChecker { +class VolatileAnnotationChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, @@ -150,7 +150,7 @@ public class VolatileAnnotationChecker : DeclarationChecker { } } -public class SynchronizedAnnotationChecker : DeclarationChecker { +class SynchronizedAnnotationChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, @@ -165,7 +165,7 @@ public class SynchronizedAnnotationChecker : DeclarationChecker { } } -public class OverloadsAnnotationChecker: DeclarationChecker { +class OverloadsAnnotationChecker: DeclarationChecker { override fun check( declaration: KtDeclaration, descriptor: DeclarationDescriptor, @@ -181,20 +181,20 @@ public class OverloadsAnnotationChecker: DeclarationChecker { if (descriptor !is CallableDescriptor) { return } - if (descriptor is FunctionDescriptor && descriptor.getModality() == Modality.ABSTRACT) { + if (descriptor is FunctionDescriptor && descriptor.modality == Modality.ABSTRACT) { diagnosticHolder.report(ErrorsJvm.OVERLOADS_ABSTRACT.on(declaration)) } - else if ((!descriptor.getVisibility().isPublicAPI && descriptor.getVisibility() != Visibilities.INTERNAL) || + else if ((!descriptor.visibility.isPublicAPI && descriptor.visibility != Visibilities.INTERNAL) || DescriptorUtils.isLocal(descriptor)) { diagnosticHolder.report(ErrorsJvm.OVERLOADS_PRIVATE.on(declaration)) } - else if (descriptor.getValueParameters().none { it.declaresDefaultValue() }) { + else if (descriptor.valueParameters.none { it.declaresDefaultValue() }) { diagnosticHolder.report(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS.on(declaration)) } } } -public class TypeParameterBoundIsNotArrayChecker : DeclarationChecker { +class TypeParameterBoundIsNotArrayChecker : DeclarationChecker { override fun check( declaration: KtDeclaration, descriptor: DeclarationDescriptor, @@ -214,7 +214,7 @@ public class TypeParameterBoundIsNotArrayChecker : DeclarationChecker { } } -public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { +class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { override fun check( declaration: KtDeclaration, @@ -223,7 +223,7 @@ public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { bindingContext: BindingContext ) { if (descriptor is CallableDescriptor && !InlineUtil.isInline(descriptor)) { - checkTypeParameterDescriptorsAreNotReified(descriptor.getTypeParameters(), diagnosticHolder) + checkTypeParameterDescriptorsAreNotReified(descriptor.typeParameters, diagnosticHolder) } if (descriptor is ClassDescriptor) { @@ -236,7 +236,7 @@ public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { typeParameterDescriptors: List, diagnosticHolder: DiagnosticSink ) { - for (reifiedTypeParameterDescriptor in typeParameterDescriptors.filter { it.isReified() }) { + for (reifiedTypeParameterDescriptor in typeParameterDescriptors.filter { it.isReified }) { val typeParameterDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(reifiedTypeParameterDescriptor) if (typeParameterDeclaration !is KtTypeParameter) throw AssertionError("JetTypeParameter expected") diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ConflictingJvmDeclarationsData.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ConflictingJvmDeclarationsData.kt index 5d1a30368c4..5f1857575fe 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ConflictingJvmDeclarationsData.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ConflictingJvmDeclarationsData.kt @@ -16,9 +16,9 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics -public class ConflictingJvmDeclarationsData( - public val classInternalName: String?, - public val classOrigin: JvmDeclarationOrigin, - public val signature: RawSignature, - public val signatureOrigins: Collection +class ConflictingJvmDeclarationsData( + val classInternalName: String?, + val classOrigin: JvmDeclarationOrigin, + val signature: RawSignature, + val signatureOrigins: Collection ) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/JvmDeclarationOrigin.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/JvmDeclarationOrigin.kt index f2253273494..bdbde630c63 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/JvmDeclarationOrigin.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/JvmDeclarationOrigin.kt @@ -24,11 +24,11 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.* -public enum class MemberKind { FIELD, METHOD } +enum class MemberKind { FIELD, METHOD } -public data class RawSignature(public val name: String, public val desc: String, public val kind: MemberKind) +data class RawSignature(val name: String, val desc: String, val kind: MemberKind) -public enum class JvmDeclarationOriginKind { +enum class JvmDeclarationOriginKind { OTHER, PACKAGE_PART, INTERFACE_DEFAULT_IMPL, @@ -40,43 +40,42 @@ public enum class JvmDeclarationOriginKind { SYNTHETIC // this means that there's no proper descriptor for this jvm declaration } -public class JvmDeclarationOrigin( - public val originKind: JvmDeclarationOriginKind, - public val element: PsiElement?, - public val descriptor: DeclarationDescriptor? +class JvmDeclarationOrigin( + val originKind: JvmDeclarationOriginKind, + val element: PsiElement?, + val descriptor: DeclarationDescriptor? ) { companion object { - @JvmField - public val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin(OTHER, null, null) + @JvmField val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin(OTHER, null, null) } } -public fun OtherOrigin(element: PsiElement?, descriptor: DeclarationDescriptor?): JvmDeclarationOrigin = +fun OtherOrigin(element: PsiElement?, descriptor: DeclarationDescriptor?): JvmDeclarationOrigin = if (element == null && descriptor == null) JvmDeclarationOrigin.NO_ORIGIN else JvmDeclarationOrigin(OTHER, element, descriptor) -public fun OtherOrigin(element: PsiElement): JvmDeclarationOrigin = OtherOrigin(element, null) +fun OtherOrigin(element: PsiElement): JvmDeclarationOrigin = OtherOrigin(element, null) -public fun OtherOrigin(descriptor: DeclarationDescriptor): JvmDeclarationOrigin = OtherOrigin(null, descriptor) +fun OtherOrigin(descriptor: DeclarationDescriptor): JvmDeclarationOrigin = OtherOrigin(null, descriptor) -public fun Bridge(descriptor: DeclarationDescriptor, element: PsiElement? = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)): JvmDeclarationOrigin = +fun Bridge(descriptor: DeclarationDescriptor, element: PsiElement? = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)): JvmDeclarationOrigin = JvmDeclarationOrigin(BRIDGE, element, descriptor) -public fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor) +fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor) /** * @param representativeFile one of the files representing this multifile class (will be used for diagnostics) */ -public fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin = +fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin = JvmDeclarationOrigin(MULTIFILE_CLASS, representativeFile, descriptor) -public fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin = +fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin = JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor) -public fun TraitImpl(element: KtClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor) -public fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = +fun TraitImpl(element: KtClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor) +fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION_TO_DEFAULT_IMPLS, element, descriptor) -public fun Delegation(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION, element, descriptor) +fun Delegation(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION, element, descriptor) -public fun Synthetic(element: PsiElement?, descriptor: CallableMemberDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(SYNTHETIC, element, descriptor) \ No newline at end of file +fun Synthetic(element: PsiElement?, descriptor: CallableMemberDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(SYNTHETIC, element, descriptor) \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/AnalysisCompletedHandlerExtension.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/AnalysisCompletedHandlerExtension.kt index c44f7ce8dc6..94b84e30b2d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/AnalysisCompletedHandlerExtension.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/AnalysisCompletedHandlerExtension.kt @@ -24,13 +24,13 @@ import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.BindingContext -public interface AnalysisCompletedHandlerExtension { +interface AnalysisCompletedHandlerExtension { companion object : ProjectExtensionDescriptor( "org.jetbrains.kotlin.analyzeCompleteHandlerExtension", AnalysisCompletedHandlerExtension::class.java ) - public fun analysisCompleted( + fun analysisCompleted( project: Project, module: ModuleDescriptor, bindingContext: BindingContext, diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/PackageFragmentProviderExtension.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/PackageFragmentProviderExtension.kt index 280e76918d8..87371c8b066 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/PackageFragmentProviderExtension.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/extensions/PackageFragmentProviderExtension.kt @@ -23,13 +23,13 @@ import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.storage.StorageManager -public interface PackageFragmentProviderExtension { +interface PackageFragmentProviderExtension { companion object : ProjectExtensionDescriptor( "org.jetbrains.kotlin.packageFragmentProviderExtension", PackageFragmentProviderExtension::class.java ) - public fun getPackageFragmentProvider( + fun getPackageFragmentProvider( project: Project, module: ModuleDescriptor, storageManager: StorageManager, diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/KotlinToJvmSignatureMapper.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/KotlinToJvmSignatureMapper.kt index 159ad3ab83b..c6bece60f03 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/KotlinToJvmSignatureMapper.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/KotlinToJvmSignatureMapper.kt @@ -18,18 +18,18 @@ package org.jetbrains.kotlin.resolve.jvm.jvmSignature import org.jetbrains.kotlin.descriptors.FunctionDescriptor -public interface KotlinToJvmSignatureMapper { - public fun mapToJvmMethodSignature(function: FunctionDescriptor): JvmMethodSignature +interface KotlinToJvmSignatureMapper { + fun mapToJvmMethodSignature(function: FunctionDescriptor): JvmMethodSignature } fun erasedSignaturesEqualIgnoringReturnTypes(subFunction: JvmMethodSignature, superFunction: JvmMethodSignature): Boolean { - val subParams = subFunction.getValueParameters() - val superParams = superFunction.getValueParameters() + val subParams = subFunction.valueParameters + val superParams = superFunction.valueParameters if (subParams.size != superParams.size) return false return subParams.zip(superParams).all { p -> val (subParam, superParam) = p - subParam.getAsmType() == superParam.getAsmType() + subParam.asmType == superParam.asmType } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt index 2ed6a718bd0..24a1550a0ee 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure -public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker { +object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker { // Prohibits covariant type argument conversions `List -> (MutableList..List)` when expected type's lower bound is invariant. // It's needed to prevent accident unsafe covariant conversions of mutable collections. // diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt index 876e40bf3b7..2520cae2a30 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope import java.util.* -public object JvmPlatform : TargetPlatform("JVM") { +object JvmPlatform : TargetPlatform("JVM") { override val defaultModuleParameters = object : ModuleParameters { override val platformToKotlinClassMap: PlatformToKotlinClassMap get() = JavaToKotlinClassMap.INSTANCE diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt index 8e1c8487ee2..1da91f6e047 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.synthetic.JavaSyntheticScopes import org.jetbrains.kotlin.types.DynamicTypesSettings -public object JvmPlatformConfigurator : PlatformConfigurator( +object JvmPlatformConfigurator : PlatformConfigurator( DynamicTypesSettings(), additionalDeclarationCheckers = listOf( PlatformStaticAnnotationChecker(), diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index 8eb07b5ef0c..b4f3d263746 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -49,12 +49,12 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { companion object { fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, syntheticScopes: SyntheticScopes): SyntheticJavaPropertyDescriptor? { - val name = getterOrSetter.getName() - if (name.isSpecial()) return null - val identifier = name.getIdentifier() + val name = getterOrSetter.name + if (name.isSpecial) return null + val identifier = name.identifier if (!identifier.startsWith("get") && !identifier.startsWith("is") && !identifier.startsWith("set")) return null // optimization - val owner = getterOrSetter.getContainingDeclaration() as? ClassDescriptor ?: return null + val owner = getterOrSetter.containingDeclaration as? ClassDescriptor ?: return null val originalGetterOrSetter = getterOrSetter.original return syntheticScopes.collectSyntheticExtensionProperties(listOf(owner.defaultType)) @@ -209,7 +209,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l val classifier = type.declarationDescriptor if (classifier is ClassDescriptor) { - for (descriptor in classifier.getUnsubstitutedMemberScope().getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)) { + for (descriptor in classifier.unsubstitutedMemberScope.getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Pair(classifier, propertyName)).descriptor) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticScopes.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticScopes.kt index 7a68a467698..7372775e2d2 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticScopes.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticScopes.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes import org.jetbrains.kotlin.storage.StorageManager -public class JavaSyntheticScopes(storageManager: StorageManager, lookupTracker: LookupTracker): SyntheticScopes { +class JavaSyntheticScopes(storageManager: StorageManager, lookupTracker: LookupTracker): SyntheticScopes { override val scopes = listOf(JavaSyntheticPropertiesScope(storageManager, lookupTracker), SamAdapterFunctionsScope(storageManager)) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt index 1fa62d80c78..f96cf4df11e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalysisResult.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.ErrorUtils -public open class AnalysisResult protected constructor( - public val bindingContext: BindingContext, - public val moduleDescriptor: ModuleDescriptor, - public val shouldGenerateCode: Boolean = true +open class AnalysisResult protected constructor( + val bindingContext: BindingContext, + val moduleDescriptor: ModuleDescriptor, + val shouldGenerateCode: Boolean = true ) { override fun equals(other: Any?): Boolean { @@ -46,12 +46,12 @@ public open class AnalysisResult protected constructor( operator fun component3() = shouldGenerateCode - public val error: Throwable + val error: Throwable get() = if (this is Error) this.exception else throw IllegalStateException("Should only be called for error analysis result") - public fun isError(): Boolean = this is Error + fun isError(): Boolean = this is Error - public fun throwIfError() { + fun throwIfError() { if (isError()) { throw IllegalStateException("failed to analyze: " + error, error) } @@ -60,20 +60,17 @@ public open class AnalysisResult protected constructor( private class Error(bindingContext: BindingContext, val exception: Throwable) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule()) companion object { - public val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.getErrorModule()) + val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.getErrorModule()) - @JvmStatic - public fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalysisResult { + @JvmStatic fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalysisResult { return AnalysisResult(bindingContext, module, true) } - @JvmStatic - public fun success(bindingContext: BindingContext, module: ModuleDescriptor, shouldGenerateCode: Boolean): AnalysisResult { + @JvmStatic fun success(bindingContext: BindingContext, module: ModuleDescriptor, shouldGenerateCode: Boolean): AnalysisResult { return AnalysisResult(bindingContext, module, shouldGenerateCode) } - @JvmStatic - public fun error(bindingContext: BindingContext, error: Throwable): AnalysisResult { + @JvmStatic fun error(bindingContext: BindingContext, error: Throwable): AnalysisResult { return Error(bindingContext, error) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt index 42aea7e6c6a..d3336bce6db 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt @@ -35,9 +35,9 @@ import org.jetbrains.kotlin.resolve.TargetPlatform import org.jetbrains.kotlin.resolve.createModule import java.util.* -public class ResolverForModule( - public val packageFragmentProvider: PackageFragmentProvider, - public val componentProvider: ComponentProvider +class ResolverForModule( + val packageFragmentProvider: PackageFragmentProvider, + val componentProvider: ComponentProvider ) abstract class ResolverForProject { @@ -52,7 +52,7 @@ abstract class ResolverForProject { override fun toString() = "$name" } -public class EmptyResolverForProject : ResolverForProject() { +class EmptyResolverForProject : ResolverForProject() { override val name: String get() = "Empty resolver" @@ -62,7 +62,7 @@ public class EmptyResolverForProject : ResolverForProject() { override val allModules: Collection = listOf() } -public class ResolverForProjectImpl( +class ResolverForProjectImpl( private val debugName: String, val descriptorByModule: Map, val delegateResolver: ResolverForProject = EmptyResolverForProject() @@ -102,29 +102,29 @@ public class ResolverForProjectImpl( } } -public data class ModuleContent( - public val syntheticFiles: Collection, - public val moduleContentScope: GlobalSearchScope +data class ModuleContent( + val syntheticFiles: Collection, + val moduleContentScope: GlobalSearchScope ) -public interface PlatformAnalysisParameters +interface PlatformAnalysisParameters -public interface ModuleInfo { - public val isLibrary: Boolean +interface ModuleInfo { + val isLibrary: Boolean get() = false - public val name: Name - public fun dependencies(): List - public fun friends(): Collection = listOf() - public fun dependencyOnBuiltins(): DependencyOnBuiltins = DependenciesOnBuiltins.LAST + val name: Name + fun dependencies(): List + fun friends(): Collection = listOf() + fun dependencyOnBuiltins(): DependencyOnBuiltins = DependenciesOnBuiltins.LAST val capabilities: Map, Any?> get() = emptyMap() //TODO: (module refactoring) provide dependency on builtins after runtime in IDEA - public interface DependencyOnBuiltins { - public fun adjustDependencies(builtinsModule: ModuleDescriptorImpl, dependencies: MutableList) + interface DependencyOnBuiltins { + fun adjustDependencies(builtinsModule: ModuleDescriptorImpl, dependencies: MutableList) } - public enum class DependenciesOnBuiltins : DependencyOnBuiltins { + enum class DependenciesOnBuiltins : DependencyOnBuiltins { NONE { override fun adjustDependencies(builtinsModule: ModuleDescriptorImpl, dependencies: MutableList) { @@ -144,8 +144,8 @@ public interface ModuleInfo { } } -public abstract class AnalyzerFacade { - public fun setupResolverForProject( +abstract class AnalyzerFacade { + fun setupResolverForProject( debugName: String, projectContext: ProjectContext, modules: Collection, @@ -234,7 +234,7 @@ public abstract class AnalyzerFacade { packagePartProvider: PackagePartProvider ): ResolverForModule - public abstract val targetPlatform: TargetPlatform + abstract val targetPlatform: TargetPlatform } //NOTE: relies on delegate to be lazily computed and cached diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt index 474cd6a7d84..a80fef37b65 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeTraverser.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDec import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterInstruction -public fun Pseudocode.traverse( +fun Pseudocode.traverse( traversalOrder: TraversalOrder, analyzeInstruction: (Instruction) -> Unit ) { @@ -38,7 +38,7 @@ public fun Pseudocode.traverse( } } -public fun Pseudocode.traverse( +fun Pseudocode.traverse( traversalOrder: TraversalOrder, edgesMap: Map>, analyzeInstruction: (Instruction, D, D) -> Unit @@ -55,7 +55,7 @@ public fun Pseudocode.traverse( } } -public fun > Pseudocode.collectData( +fun > Pseudocode.collectData( traversalOrder: TraversalOrder, mergeDataWithLocalDeclarations: Boolean, mergeEdges: (Instruction, Collection) -> Edges, @@ -81,7 +81,7 @@ private fun Pseudocode.initializeEdgesMap( edgesMap: MutableMap>, initialInfo: I ) { - val instructions = getInstructions() + val instructions = instructions val initialEdge = Edges(initialInfo, initialInfo) for (instruction in instructions) { edgesMap.put(instruction, initialEdge) @@ -175,7 +175,7 @@ enum class TraverseInstructionResult { } // returns false when interrupted by handler -public fun traverseFollowingInstructions( +fun traverseFollowingInstructions( rootInstruction: Instruction, visited: MutableSet, order: TraversalOrder, @@ -197,19 +197,19 @@ public fun traverseFollowingInstructions( return true } -public enum class TraversalOrder { +enum class TraversalOrder { FORWARD, BACKWARD } fun Pseudocode.getStartInstruction(traversalOrder: TraversalOrder): Instruction = - if (traversalOrder == FORWARD) getEnterInstruction() else getSinkInstruction() + if (traversalOrder == FORWARD) enterInstruction else sinkInstruction fun Pseudocode.getLastInstruction(traversalOrder: TraversalOrder): Instruction = - if (traversalOrder == FORWARD) getSinkInstruction() else getEnterInstruction() + if (traversalOrder == FORWARD) sinkInstruction else enterInstruction fun Pseudocode.getInstructions(traversalOrder: TraversalOrder): MutableList = - if (traversalOrder == FORWARD) getInstructions() else getReversedInstructions() + if (traversalOrder == FORWARD) instructions else reversedInstructions fun Instruction.getNextInstructions(traversalOrder: TraversalOrder): Collection = if (traversalOrder == FORWARD) nextInstructions else previousInstructions diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariableDataCollector.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariableDataCollector.kt index 43045672f65..e62dcc06148 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariableDataCollector.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariableDataCollector.kt @@ -29,13 +29,13 @@ import org.jetbrains.kotlin.resolve.BindingContext import java.util.ArrayList import java.util.HashMap -public class PseudocodeVariableDataCollector( +class PseudocodeVariableDataCollector( private val bindingContext: BindingContext, private val pseudocode: Pseudocode ) { val lexicalScopeVariableInfo = computeLexicalScopeVariableInfo(pseudocode) - public fun > collectData( + fun > collectData( traversalOrder: TraversalOrder, mergeDataWithLocalDeclarations: Boolean, initialInfo: I, @@ -80,7 +80,7 @@ public class PseudocodeVariableDataCollector( descriptor.toString() assert(descriptor is VariableDescriptor) { - "Variable descriptor should correspond to the instruction for ${instruction.element.getText()}.\n" + + "Variable descriptor should correspond to the instruction for ${instruction.element.text}.\n" + "Descriptor: $descriptor" } lexicalScopeVariableInfo.registerVariableDeclaredInScope( @@ -93,12 +93,12 @@ public class PseudocodeVariableDataCollector( } } -public interface LexicalScopeVariableInfo { +interface LexicalScopeVariableInfo { val declaredIn : Map val scopeVariables : Map> } -public class LexicalScopeVariableInfoImpl : LexicalScopeVariableInfo { +class LexicalScopeVariableInfoImpl : LexicalScopeVariableInfo { override val declaredIn = HashMap() override val scopeVariables = HashMap>() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/UnreachableCode.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/UnreachableCode.kt index d2a0a4bf680..7653132d5fc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/UnreachableCode.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/UnreachableCode.kt @@ -45,7 +45,7 @@ class UnreachableCodeImpl( element.getLeavesOrReachableChildren().removeReachableElementsWithMeaninglessSiblings().mergeAdjacentTextRanges() } else { - listOf(element.getTextRange()!!) + listOf(element.textRange!!) } } @@ -58,7 +58,7 @@ class UnreachableCodeImpl( acceptChildren(object : PsiElementVisitor() { override fun visitElement(element: PsiElement) { val isReachable = element is KtElement && reachableElements.contains(element) && !element.hasChildrenInSet(unreachableElements) - if (isReachable || element.getChildren().size == 0) { + if (isReachable || element.children.size == 0) { children.add(element) } else { @@ -71,7 +71,7 @@ class UnreachableCodeImpl( fun List.removeReachableElementsWithMeaninglessSiblings(): List { fun PsiElement.isMeaningless() = this is PsiWhiteSpace - || this.getNode()?.getElementType() == KtTokens.COMMA + || this.node?.elementType == KtTokens.COMMA || this is PsiComment val childrenToRemove = HashSet() @@ -101,11 +101,11 @@ class UnreachableCodeImpl( val lastRange = fold(null as TextRange?) { currentTextRange, element -> - val elementRange = element.getTextRange()!! + val elementRange = element.textRange!! if (currentTextRange == null) { elementRange } - else if (currentTextRange.getEndOffset() == elementRange.getStartOffset()) { + else if (currentTextRange.endOffset == elementRange.startOffset) { currentTextRange.union(elementRange) } else { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt index 2b1fc1d591d..9351b8b2216 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudoValue.kt @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.cfg.pseudocode import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue -public interface PseudoValue { - public val debugName: String - public val element: KtElement? - public val createdAt: InstructionWithValue? +interface PseudoValue { + val debugName: String + val element: KtElement? + val createdAt: InstructionWithValue? } -public interface PseudoValueFactory { - public fun newValue(element: KtElement?, instruction: InstructionWithValue?): PseudoValue +interface PseudoValueFactory { + fun newValue(element: KtElement?, instruction: InstructionWithValue?): PseudoValue } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt index f3b169b15fd..e8785c95dc8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt @@ -23,48 +23,48 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public interface TypePredicate: (KotlinType) -> Boolean { +interface TypePredicate: (KotlinType) -> Boolean { override fun invoke(typeToCheck: KotlinType): Boolean } -public data class SingleType(val targetType: KotlinType): TypePredicate { +data class SingleType(val targetType: KotlinType): TypePredicate { override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType) override fun toString(): String = targetType.render() } -public data class AllSubtypes(val upperBound: KotlinType): TypePredicate { +data class AllSubtypes(val upperBound: KotlinType): TypePredicate { override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound) override fun toString(): String = "{<: ${upperBound.render()}}" } -public data class ForAllTypes(val typeSets: List): TypePredicate { +data class ForAllTypes(val typeSets: List): TypePredicate { override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.all { it(typeToCheck) } override fun toString(): String = "AND{${typeSets.joinToString(", ")}}" } -public data class ForSomeType(val typeSets: List): TypePredicate { +data class ForSomeType(val typeSets: List): TypePredicate { override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.any { it(typeToCheck) } override fun toString(): String = "OR{${typeSets.joinToString(", ")}}" } -public object AllTypes : TypePredicate { +object AllTypes : TypePredicate { override fun invoke(typeToCheck: KotlinType): Boolean = true override fun toString(): String = "*" } // todo: simplify computed type predicate when possible -public fun and(predicates: Collection): TypePredicate = +fun and(predicates: Collection): TypePredicate = when (predicates.size) { 0 -> AllTypes 1 -> predicates.first() else -> ForAllTypes(predicates.toList()) } -public fun or(predicates: Collection): TypePredicate? = +fun or(predicates: Collection): TypePredicate? = when (predicates.size) { 0 -> null 1 -> predicates.first() @@ -73,7 +73,7 @@ public fun or(predicates: Collection): TypePredicate? = fun KotlinType.getSubtypesPredicate(): TypePredicate { return when { - KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes + KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable -> AllTypes TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this) else -> SingleType(this) } @@ -82,5 +82,5 @@ fun KotlinType.getSubtypesPredicate(): TypePredicate { private fun KotlinType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this) -public fun TypePredicate.expectedTypeFor(keys: Iterable): Map = +fun TypePredicate.expectedTypeFor(keys: Iterable): Map = keys.fold(SmartFMap.emptyMap()) { map, key -> map.plus(key, this) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt index 9e7e9cb20d4..708507d3159 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/Instruction.kt @@ -19,20 +19,20 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue -public interface Instruction { - public var owner: Pseudocode +interface Instruction { + var owner: Pseudocode - public val previousInstructions: Collection - public val nextInstructions: Collection + val previousInstructions: Collection + val nextInstructions: Collection - public val dead: Boolean + val dead: Boolean - public val lexicalScope: LexicalScope + val lexicalScope: LexicalScope - public val inputValues: List + val inputValues: List - public val copies: Collection + val copies: Collection - public fun accept(visitor: InstructionVisitor) - public fun accept(visitor: InstructionVisitorWithResult): R + fun accept(visitor: InstructionVisitor) + fun accept(visitor: InstructionVisitorWithResult): R } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt index 3c0656e40dd..61b4227db80 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionImpl.kt @@ -21,7 +21,7 @@ import java.util.LinkedHashSet import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue -public abstract class InstructionImpl(override val lexicalScope: LexicalScope): Instruction { +abstract class InstructionImpl(override val lexicalScope: LexicalScope): Instruction { private var _owner: Pseudocode? = null override var owner: Pseudocode @@ -49,7 +49,7 @@ public abstract class InstructionImpl(override val lexicalScope: LexicalScope): return instruction } - public var markedAsDead: Boolean = false + var markedAsDead: Boolean = false override val dead: Boolean get() = allCopies?.all { it.markedAsDead } ?: markedAsDead diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt index d0666bd1765..15a92efa6db 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitor.kt @@ -21,95 +21,95 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.* -public open class InstructionVisitor() { - public open fun visitAccessInstruction(instruction: AccessValueInstruction) { +open class InstructionVisitor() { + open fun visitAccessInstruction(instruction: AccessValueInstruction) { visitInstructionWithNext(instruction) } - public open fun visitReadValue(instruction: ReadValueInstruction) { + open fun visitReadValue(instruction: ReadValueInstruction) { visitAccessInstruction(instruction) } - public open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction) { + open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction) { visitInstructionWithNext(instruction) } - public open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction) { + open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction) { visitInstructionWithNext(instruction) } - public open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction) { + open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction) { visitJump(instruction) } - public open fun visitConditionalJump(instruction: ConditionalJumpInstruction) { + open fun visitConditionalJump(instruction: ConditionalJumpInstruction) { visitJump(instruction) } - public open fun visitReturnValue(instruction: ReturnValueInstruction) { + open fun visitReturnValue(instruction: ReturnValueInstruction) { visitJump(instruction) } - public open fun visitReturnNoValue(instruction: ReturnNoValueInstruction) { + open fun visitReturnNoValue(instruction: ReturnNoValueInstruction) { visitJump(instruction) } - public open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction) { + open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction) { visitJump(instruction) } - public open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction) { + open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction) { visitInstruction(instruction) } - public open fun visitSubroutineExit(instruction: SubroutineExitInstruction) { + open fun visitSubroutineExit(instruction: SubroutineExitInstruction) { visitInstruction(instruction) } - public open fun visitSubroutineSink(instruction: SubroutineSinkInstruction) { + open fun visitSubroutineSink(instruction: SubroutineSinkInstruction) { visitInstruction(instruction) } - public open fun visitJump(instruction: AbstractJumpInstruction) { + open fun visitJump(instruction: AbstractJumpInstruction) { visitInstruction(instruction) } - public open fun visitInstructionWithNext(instruction: InstructionWithNext) { + open fun visitInstructionWithNext(instruction: InstructionWithNext) { visitInstruction(instruction) } - public open fun visitInstruction(instruction: Instruction) { + open fun visitInstruction(instruction: Instruction) { } - public open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction) { + open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction) { visitInstructionWithNext(instruction) } - public open fun visitWriteValue(instruction: WriteValueInstruction) { + open fun visitWriteValue(instruction: WriteValueInstruction) { visitAccessInstruction(instruction) } - public open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction) { + open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction) { visitInstructionWithNext(instruction) } - public open fun visitOperation(instruction: OperationInstruction) { + open fun visitOperation(instruction: OperationInstruction) { visitInstructionWithNext(instruction) } - public open fun visitCallInstruction(instruction: CallInstruction) { + open fun visitCallInstruction(instruction: CallInstruction) { visitOperation(instruction) } - public open fun visitMerge(instruction: MergeInstruction) { + open fun visitMerge(instruction: MergeInstruction) { visitOperation(instruction) } - public open fun visitMarkInstruction(instruction: MarkInstruction) { + open fun visitMarkInstruction(instruction: MarkInstruction) { visitInstructionWithNext(instruction) } - public open fun visitMagic(instruction: MagicInstruction) { + open fun visitMagic(instruction: MagicInstruction) { visitOperation(instruction) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt index e9a54a9fd6a..ca834819184 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt @@ -21,94 +21,94 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.* -public abstract class InstructionVisitorWithResult() { - public abstract fun visitInstruction(instruction: Instruction): R +abstract class InstructionVisitorWithResult() { + abstract fun visitInstruction(instruction: Instruction): R - public open fun visitAccessInstruction(instruction: AccessValueInstruction): R { + open fun visitAccessInstruction(instruction: AccessValueInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitReadValue(instruction: ReadValueInstruction): R { + open fun visitReadValue(instruction: ReadValueInstruction): R { return visitAccessInstruction(instruction) } - public open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction): R { + open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction): R { + open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction): R { + open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction): R { return visitJump(instruction) } - public open fun visitConditionalJump(instruction: ConditionalJumpInstruction): R { + open fun visitConditionalJump(instruction: ConditionalJumpInstruction): R { return visitJump(instruction) } - public open fun visitReturnValue(instruction: ReturnValueInstruction): R { + open fun visitReturnValue(instruction: ReturnValueInstruction): R { return visitJump(instruction) } - public open fun visitReturnNoValue(instruction: ReturnNoValueInstruction): R { + open fun visitReturnNoValue(instruction: ReturnNoValueInstruction): R { return visitJump(instruction) } - public open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction): R { + open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction): R { return visitJump(instruction) } - public open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction): R { + open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction): R { return visitInstruction(instruction) } - public open fun visitSubroutineExit(instruction: SubroutineExitInstruction): R { + open fun visitSubroutineExit(instruction: SubroutineExitInstruction): R { return visitInstruction(instruction) } - public open fun visitSubroutineSink(instruction: SubroutineSinkInstruction): R { + open fun visitSubroutineSink(instruction: SubroutineSinkInstruction): R { return visitInstruction(instruction) } - public open fun visitJump(instruction: AbstractJumpInstruction): R { + open fun visitJump(instruction: AbstractJumpInstruction): R { return visitInstruction(instruction) } - public open fun visitInstructionWithNext(instruction: InstructionWithNext): R { + open fun visitInstructionWithNext(instruction: InstructionWithNext): R { return visitInstruction(instruction) } - public open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction): R { + open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitWriteValue(instruction: WriteValueInstruction): R { + open fun visitWriteValue(instruction: WriteValueInstruction): R { return visitAccessInstruction(instruction) } - public open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction): R { + open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitOperation(instruction: OperationInstruction): R { + open fun visitOperation(instruction: OperationInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitCallInstruction(instruction: CallInstruction): R { + open fun visitCallInstruction(instruction: CallInstruction): R { return visitOperation(instruction) } - public open fun visitMerge(instruction: MergeInstruction): R { + open fun visitMerge(instruction: MergeInstruction): R { return visitOperation(instruction) } - public open fun visitMarkInstruction(instruction: MarkInstruction): R { + open fun visitMarkInstruction(instruction: MarkInstruction): R { return visitInstructionWithNext(instruction) } - public open fun visitMagic(instruction: MagicInstruction): R { + open fun visitMagic(instruction: MagicInstruction): R { return visitOperation(instruction) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt index 6fc82983616..1567c620f41 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/InstructionWithNext.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.utils.emptyOrSingletonList -public abstract class InstructionWithNext( +abstract class InstructionWithNext( element: KtElement, lexicalScope: LexicalScope ) : KtElementInstructionImpl(element, lexicalScope) { - public var next: Instruction? = null + var next: Instruction? = null set(value: Instruction?) { field = outgoingEdgeTo(value) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt index a17cb5a5de6..2fac76d9c0c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstruction.kt @@ -18,6 +18,6 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions import org.jetbrains.kotlin.psi.KtElement -public interface KtElementInstruction : Instruction { - public val element: KtElement +interface KtElementInstruction : Instruction { + val element: KtElement } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt index 6561cccc606..fe08eca0e75 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/KtElementInstructionImpl.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtElement -public abstract class KtElementInstructionImpl( +abstract class KtElementInstructionImpl( override val element: KtElement, lexicalScope: LexicalScope ) : InstructionImpl(lexicalScope), KtElementInstruction { protected fun render(element: PsiElement): String = - element.getText()?.replace("\\s+".toRegex(), " ") ?: "" + element.text?.replace("\\s+".toRegex(), " ") ?: "" } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/LexicalScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/LexicalScope.kt index 086bca9b715..bec174fc317 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/LexicalScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/LexicalScope.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement -public class LexicalScope(val parentScope: LexicalScope?, val element: KtElement) { +class LexicalScope(val parentScope: LexicalScope?, val element: KtElement) { //todo remove after KT-4126 private val d = (parentScope?.depth ?: 0) + 1 val depth: Int get() = d diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt index 043dfa35481..da5145dcdfc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithReceivers.kt @@ -20,6 +20,6 @@ import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -public interface InstructionWithReceivers: Instruction { - public val receiverValues: Map +interface InstructionWithReceivers: Instruction { + val receiverValues: Map } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt index 032674d312a..bab7573cd22 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/InstructionWithValue.kt @@ -19,6 +19,6 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions.eval import org.jetbrains.kotlin.cfg.pseudocode.instructions.KtElementInstruction import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue -public interface InstructionWithValue : KtElementInstruction { - public val outputValue: PseudoValue? +interface InstructionWithValue : KtElementInstruction { + val outputValue: PseudoValue? } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt index 3991db4a618..1cc1c409fe5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/LoadUnitValueInstruction.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult -public class LoadUnitValueInstruction( +class LoadUnitValueInstruction( expression: KtExpression, lexicalScope: LexicalScope ) : InstructionWithNext(expression, lexicalScope) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt index 029ae655c85..e920098bf48 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt @@ -25,35 +25,35 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -public sealed class AccessTarget { - public class Declaration(val descriptor: VariableDescriptor): AccessTarget() { +sealed class AccessTarget { + class Declaration(val descriptor: VariableDescriptor): AccessTarget() { override fun equals(other: Any?) = other is Declaration && descriptor == other.descriptor override fun hashCode() = descriptor.hashCode() } - public class Call(val resolvedCall: ResolvedCall<*>): AccessTarget() { + class Call(val resolvedCall: ResolvedCall<*>): AccessTarget() { override fun equals(other: Any?) = other is Call && resolvedCall == other.resolvedCall override fun hashCode() = resolvedCall.hashCode() } - public object BlackBox: AccessTarget() + object BlackBox: AccessTarget() } -public abstract class AccessValueInstruction protected constructor( +abstract class AccessValueInstruction protected constructor( element: KtElement, lexicalScope: LexicalScope, - public val target: AccessTarget, + val target: AccessTarget, override val receiverValues: Map ) : InstructionWithNext(element, lexicalScope), InstructionWithReceivers -public class ReadValueInstruction private constructor( +class ReadValueInstruction private constructor( element: KtElement, lexicalScope: LexicalScope, target: AccessTarget, receiverValues: Map, private var _outputValue: PseudoValue? ) : AccessValueInstruction(element, lexicalScope, target, receiverValues), InstructionWithValue { - public constructor( + constructor( element: KtElement, lexicalScope: LexicalScope, target: AccessTarget, @@ -81,9 +81,9 @@ public class ReadValueInstruction private constructor( val inVal = if (receiverValues.isEmpty()) "" else "|${receiverValues.keys.joinToString()}" val targetName = when (target) { is AccessTarget.Declaration -> target.descriptor - is AccessTarget.Call -> target.resolvedCall.getResultingDescriptor() + is AccessTarget.Call -> target.resolvedCall.resultingDescriptor else -> null - }?.getName()?.asString() + }?.name?.asString() val elementText = render(element) val description = if (targetName != null && targetName != elementText) "$elementText, $targetName" else elementText @@ -94,13 +94,13 @@ public class ReadValueInstruction private constructor( ReadValueInstruction(element, lexicalScope, target, receiverValues, outputValue) } -public class WriteValueInstruction( +class WriteValueInstruction( assignment: KtElement, lexicalScope: LexicalScope, target: AccessTarget, receiverValues: Map, - public val lValue: KtElement, - public val rValue: PseudoValue + val lValue: KtElement, + val rValue: PseudoValue ) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) { override val inputValues: List // as is necessary: see KT-10384 @@ -115,7 +115,7 @@ public class WriteValueInstruction( } override fun toString(): String { - val lhs = (lValue as? KtNamedDeclaration)?.getName() ?: render(lValue) + val lhs = (lValue as? KtNamedDeclaration)?.name ?: render(lValue) return "w($lhs|${inputValues.joinToString(", ")})" } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt index 2735de394fe..a7bfdc2aefe 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -public abstract class OperationInstruction protected constructor( +abstract class OperationInstruction protected constructor( element: KtElement, lexicalScope: LexicalScope, override val inputValues: List @@ -53,16 +53,16 @@ public abstract class OperationInstruction protected constructor( } } -public class CallInstruction private constructor( +class CallInstruction private constructor( element: KtElement, lexicalScope: LexicalScope, val resolvedCall: ResolvedCall<*>, override val receiverValues: Map, - public val arguments: Map + val arguments: Map ) : OperationInstruction(element, lexicalScope, (receiverValues.keys as Collection) + arguments.keys), InstructionWithReceivers { // as is necessary above: see KT-10384 - public constructor ( + constructor ( element: KtElement, lexicalScope: LexicalScope, resolvedCall: ResolvedCall<*>, @@ -85,7 +85,7 @@ public class CallInstruction private constructor( CallInstruction(element, lexicalScope, resolvedCall, receiverValues, arguments).setResult(resultValue) override fun toString() = - renderInstruction("call", "${render(element)}, ${resolvedCall.getResultingDescriptor()!!.getName()}") + renderInstruction("call", "${render(element)}, ${resolvedCall.resultingDescriptor!!.name}") } // Introduces black-box operation @@ -93,13 +93,13 @@ public class CallInstruction private constructor( // consume input values (so that they aren't considered unused) // denote value transformation which can't be expressed by other instructions (such as call or read) // pass more than one value to instruction which formally requires only one (e.g. jump) -public class MagicInstruction( +class MagicInstruction( element: KtElement, lexicalScope: LexicalScope, inputValues: List, val kind: MagicKind ) : OperationInstruction(element, lexicalScope, inputValues) { - public constructor ( + constructor ( element: KtElement, valueElement: KtElement?, lexicalScope: LexicalScope, @@ -110,7 +110,7 @@ public class MagicInstruction( setResult(factory, valueElement) } - public val synthetic: Boolean get() = outputValue.element == null + val synthetic: Boolean get() = outputValue.element == null override val outputValue: PseudoValue get() = resultValue!! @@ -125,7 +125,7 @@ public class MagicInstruction( override fun toString() = renderInstruction("magic[$kind]", render(element)) } -public enum class MagicKind(val sideEffectFree: Boolean = false) { +enum class MagicKind(val sideEffectFree: Boolean = false) { // builtin operations STRING_TEMPLATE(true), AND(true), @@ -153,7 +153,7 @@ class MergeInstruction private constructor( lexicalScope: LexicalScope, inputValues: List ): OperationInstruction(element, lexicalScope, inputValues) { - public constructor ( + constructor ( element: KtElement, lexicalScope: LexicalScope, inputValues: List, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt index 2c6a7071740..d7f3e02ecc7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/AbstractJumpInstruction.kt @@ -24,19 +24,19 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.utils.emptyOrSingletonList -public abstract class AbstractJumpInstruction( +abstract class AbstractJumpInstruction( element: KtElement, - public val targetLabel: Label, + val targetLabel: Label, lexicalScope: LexicalScope ) : KtElementInstructionImpl(element, lexicalScope), JumpInstruction { - public var resolvedTarget: Instruction? = null + var resolvedTarget: Instruction? = null set(value: Instruction?) { field = outgoingEdgeTo(value) } protected abstract fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction - public fun copy(newLabel: Label): Instruction { + fun copy(newLabel: Label): Instruction { return updateCopyInfo(createCopy(newLabel, lexicalScope)) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt index 097acb94ab4..7f4201f8cd2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt @@ -26,22 +26,22 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor import org.jetbrains.kotlin.utils.emptyOrSingletonList -public class ConditionalJumpInstruction( +class ConditionalJumpInstruction( element: KtElement, - public val onTrue: Boolean, + val onTrue: Boolean, lexicalScope: LexicalScope, targetLabel: Label, - public val conditionValue: PseudoValue?) : AbstractJumpInstruction(element, targetLabel, lexicalScope) { + val conditionValue: PseudoValue?) : AbstractJumpInstruction(element, targetLabel, lexicalScope) { private var _nextOnTrue: Instruction? = null private var _nextOnFalse: Instruction? = null - public var nextOnTrue: Instruction + var nextOnTrue: Instruction get() = _nextOnTrue!! set(value: Instruction) { _nextOnTrue = outgoingEdgeTo(value) } - public var nextOnFalse: Instruction + var nextOnFalse: Instruction get() = _nextOnFalse!! set(value: Instruction) { _nextOnFalse = outgoingEdgeTo(value) @@ -64,7 +64,7 @@ public class ConditionalJumpInstruction( override fun toString(): String { val instr = if (onTrue) "jt" else "jf" val inValue = conditionValue?.let { "|" + it } ?: "" - return "$instr(${targetLabel.getName()}$inValue)" + return "$instr(${targetLabel.name}$inValue)" } override fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction = diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt index 82c3b34452d..0437d6b1140 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/JumpInstruction.kt @@ -18,4 +18,4 @@ package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction -public interface JumpInstruction : Instruction +interface JumpInstruction : Instruction diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt index 49736d4a331..865d62283f9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/NondeterministicJumpInstruction.kt @@ -29,24 +29,24 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl import org.jetbrains.kotlin.utils.emptyOrSingletonList -public class NondeterministicJumpInstruction( +class NondeterministicJumpInstruction( element: KtElement, targetLabels: List