compiler: cleanup 'public', property access syntax

This commit is contained in:
Dmitry Jemerov
2016-01-07 17:57:35 +01:00
parent b72ea1ff07
commit 117a0d8b7b
488 changed files with 3147 additions and 3287 deletions
@@ -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<member of Foo, corresponding member of typeOf(baz)>
@JvmStatic
public fun getDelegates(
@JvmStatic fun getDelegates(
descriptor: ClassDescriptor,
toInterface: ClassDescriptor,
delegateExpressionType: KotlinType? = null
@@ -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<FunctionHandle>
fun getOverridden(): Iterable<FunctionHandle>
}
public data class Bridge<Signature>(
public val from: Signature,
public val to: Signature
data class Bridge<Signature>(
val from: Signature,
val to: Signature
) {
override fun toString() = "$from -> $to"
}
public fun <Function : FunctionHandle, Signature> generateBridges(
fun <Function : FunctionHandle, Signature> generateBridges(
function: Function,
signature: (Function) -> Signature
): Set<Bridge<Signature>> {
@@ -69,7 +69,7 @@ public fun <Function : FunctionHandle, Signature> generateBridges(
return bridgesToGenerate.map { Bridge(it, method) }.toSet()
}
public fun <Function : FunctionHandle> findAllReachableDeclarations(function: Function): MutableSet<Function> {
fun <Function : FunctionHandle> findAllReachableDeclarations(function: Function): MutableSet<Function> {
val collector = object : DFS.NodeHandlerWithListResult<Function, Function>() {
override fun afterChildren(current: Function) {
if (current.isDeclaration) {
@@ -86,7 +86,7 @@ public fun <Function : FunctionHandle> 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 <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function): Function {
fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function): Function {
require(!function.isAbstract, { "Only concrete functions have implementations: $function" })
if (function.isDeclaration) return function
@@ -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 <Signature> generateBridgesForFunctionDescriptor(
fun <Signature> generateBridgesForFunctionDescriptor(
descriptor: FunctionDescriptor,
signature: (FunctionDescriptor) -> Signature
): Set<Bridge<Signature>> {
@@ -47,16 +47,16 @@ public fun <Signature> 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))
}
}
@@ -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<OutputFile>
interface OutputFileCollection {
fun get(relativePath: String): OutputFile?
fun asList(): List<OutputFile>
}
public class SimpleOutputFileCollection(private val outputFiles: List<OutputFile>) : OutputFileCollection {
class SimpleOutputFileCollection(private val outputFiles: List<OutputFile>) : OutputFileCollection {
override fun get(relativePath: String): OutputFile? = outputFiles.firstOrNull { it.relativePath == relativePath }
override fun asList(): List<OutputFile> = outputFiles
}
public interface OutputFile {
public val relativePath: String
public val sourceFiles: List<File>
public fun asByteArray(): ByteArray
public fun asText(): String
interface OutputFile {
val relativePath: String
val sourceFiles: List<File>
fun asByteArray(): ByteArray
fun asText(): String
}
public class SimpleOutputFile(
class SimpleOutputFile(
override val sourceFiles: List<File>,
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<File>,
override val relativePath: String,
private val content: ByteArray