Skip to content

Commit

Permalink
Reformat code.
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDolnik committed Nov 10, 2023
1 parent ddca706 commit 33bd2dc
Show file tree
Hide file tree
Showing 26 changed files with 29 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class KirBuiltins(

val kotlinSuperType = KotlinTypeFactory.simpleType(
baseType = extraDescriptorBuiltins.NSMutableDictionary.defaultType,
arguments = listOf(keyArgument, valueArgument)
arguments = listOf(keyArgument, valueArgument),
)

superTypes.add(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.touchlab.skie.kir.element

import co.touchlab.skie.kir.configuration.KirConfiguration
import co.touchlab.skie.kir.irbuilder.impl.namespace.nameOrError
import co.touchlab.skie.kir.type.ReferenceKirType
import co.touchlab.skie.oir.element.OirClass
import co.touchlab.skie.sir.element.SirClass
Expand Down Expand Up @@ -92,7 +91,6 @@ val KirClass.classDescriptorOrNull: ClassDescriptor?
val KirClass.classDescriptorOrError: ClassDescriptor
get() = classDescriptorOrNull ?: error("Class descriptor is not available for file classes. Was: $this")


val KirClass.sourceFileOrNull: SourceFile?
get() = when (val descriptor = descriptor) {
is KirClass.Descriptor.Class -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class KirEnumEntry(
init {
parent.enumEntries.add(this)
}

override fun toString(): String = "${this::class.simpleName}: $descriptor"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package co.touchlab.skie.oir

import co.touchlab.skie.kir.KirProvider
import co.touchlab.skie.kir.descriptor.ExtraDescriptorBuiltins
import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirModule
import co.touchlab.skie.kir.element.classDescriptorOrNull
import co.touchlab.skie.kir.element.sourceFileOrNull
import co.touchlab.skie.oir.builtin.OirBuiltins
import co.touchlab.skie.oir.element.OirClass
import co.touchlab.skie.oir.element.OirFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import co.touchlab.skie.oir.OirProvider
import co.touchlab.skie.oir.element.OirClass
import co.touchlab.skie.oir.element.OirTypeParameter
import co.touchlab.skie.oir.element.toTypeParameterUsage
import co.touchlab.skie.oir.type.TypeParameterUsageOirType

@Suppress("PropertyName")
class OirBuiltins(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import co.touchlab.skie.sir.SkieNamespaceProvider
import co.touchlab.skie.sir.builtin.SirBuiltins
import co.touchlab.skie.sir.type.translation.SirTypeTranslator
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamer
import org.jetbrains.kotlin.builtins.KotlinBuiltIns

interface SirPhase : SkiePhase<SirPhase.Context> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import co.touchlab.skie.sir.element.SirClass
import co.touchlab.skie.sir.element.SirEnumCase
import co.touchlab.skie.sir.element.SirExtension
import co.touchlab.skie.sir.element.SirFile
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirGetter
import co.touchlab.skie.sir.element.SirProperty
import co.touchlab.skie.sir.element.SirScope
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirTypeAlias
import co.touchlab.skie.sir.element.SirVisibility
import co.touchlab.skie.sir.element.isExported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirEnumEntry
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.sir.element.SirClass
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirScope
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirTypeAlias
import co.touchlab.skie.sir.element.SirValueParameter
import co.touchlab.skie.sir.element.SirVisibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import co.touchlab.skie.kir.element.KirCallableDeclaration
import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirConstructor
import co.touchlab.skie.kir.element.KirFunction
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirProperty
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirValueParameter
import co.touchlab.skie.kir.element.classDescriptorOrError
import co.touchlab.skie.kir.type.BlockPointerKirType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import co.touchlab.skie.sir.element.SirExtension
import co.touchlab.skie.sir.element.SirFile
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.receiverDeclaration
import co.touchlab.skie.sir.element.resolveAsSirClassType
import co.touchlab.skie.sir.element.resolveAsSirClass
import co.touchlab.skie.sir.element.resolveAsSirClassType
import co.touchlab.skie.sir.type.DeclaredSirType
import co.touchlab.skie.sir.type.NullableSirType
import co.touchlab.skie.sir.type.OirDeclaredSirType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import co.touchlab.skie.configuration.getConfiguration
import co.touchlab.skie.kir.element.KirCallableDeclaration
import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirConstructor
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirProperty
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.phases.SirPhase

class FileScopeConvertor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.sir.element.SirClass
import co.touchlab.skie.sir.element.SirConstructor
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirProperty
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirValueParameter
import co.touchlab.skie.sir.element.SirVisibility
import co.touchlab.skie.sir.element.copyTypeParametersFrom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private data class BridgeModel(
val kotlinBridgingKirFunction: KirSimpleFunction,
) {

val originalFunction: SirSimpleFunction = suspendKirFunction.bridgedSirFunction ?: error("Suspend function $suspendKirFunction does not have an async bridge.")
val originalFunction: SirSimpleFunction =
suspendKirFunction.bridgedSirFunction ?: error("Suspend function $suspendKirFunction does not have an async bridge.")

val kotlinBridgingFunction: SirSimpleFunction = kotlinBridgingKirFunction.originalSirFunction

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.touchlab.skie.phases.header

import co.touchlab.skie.oir.element.OirClass
import co.touchlab.skie.oir.element.renderForwardDeclaration
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.phases.header.util.BaseHeaderModificationPhase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import co.touchlab.skie.kir.element.KirCallableDeclaration.Origin
import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirConstructor
import co.touchlab.skie.kir.element.KirFunction
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirProperty
import co.touchlab.skie.kir.element.KirScope
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirValueParameter
import co.touchlab.skie.kir.util.addOverrides
import co.touchlab.skie.oir.element.OirFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package co.touchlab.skie.phases.memberconflicts

import co.touchlab.skie.sir.element.SirCallableDeclaration
import co.touchlab.skie.sir.element.SirConstructor
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.SirProperty
import co.touchlab.skie.sir.element.SirSimpleFunction
import co.touchlab.skie.sir.element.getEntireOverrideHierarchy

class UniqueSignatureSet {
Expand Down Expand Up @@ -52,8 +52,8 @@ class UniqueSignatureSet {
val lastValueParameter = this.valueParameters.lastOrNull()
?: error(
"Cannot mangle $this because it does not have any value parameters. " +
"This should never happen because constructors without value parameters " +
"shouldn't create conflicts (as they are processed first)."
"This should never happen because constructors without value parameters " +
"shouldn't create conflicts (as they are processed first).",
)

lastValueParameter.label = lastValueParameter.labelOrName + "_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import co.touchlab.skie.oir.element.constructors
import co.touchlab.skie.oir.element.copyValueParametersFrom
import co.touchlab.skie.oir.element.superClass
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.sir.element.SirConstructor
import co.touchlab.skie.sir.element.SirVisibility
import co.touchlab.skie.sir.element.copyValueParametersFrom
import co.touchlab.skie.sir.element.shallowCopy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ExtraClassExportPhase(
}

val allFlowArguments = descriptorProvider.allExposedMembers.flatMap { it.getAllFlowArgumentClasses() } +
descriptorProvider.exposedClasses.flatMap { it.getAllFlowArgumentClasses() }
descriptorProvider.exposedClasses.flatMap { it.getAllFlowArgumentClasses() }

val allExposableFlowArguments = allFlowArguments.filter { descriptorProvider.isExposable(it) }

Expand Down Expand Up @@ -139,12 +139,12 @@ private fun ClassDescriptor.getAllFlowArgumentClasses(): List<ClassDescriptor> =

private fun CallableMemberDescriptor.getAllFlowArgumentClasses(): List<ClassDescriptor> =
typeParameters.flatMap { it.getAllFlowArgumentClasses() } +
valueParameters.flatMap { it.type.getAllFlowArgumentClasses() } +
(returnType?.getAllFlowArgumentClasses() ?: emptyList()) +
(contextReceiverParameters + listOfNotNull(
dispatchReceiverParameter,
extensionReceiverParameter
)).flatMap { it.getAllFlowArgumentClasses() }
valueParameters.flatMap { it.type.getAllFlowArgumentClasses() } +
(returnType?.getAllFlowArgumentClasses() ?: emptyList()) +
(contextReceiverParameters + listOfNotNull(
dispatchReceiverParameter,
extensionReceiverParameter,
)).flatMap { it.getAllFlowArgumentClasses() }

// Sacrifices some completeness for simplicity - otherwise it would have to check all usages of the type parameter.
private fun TypeParameterDescriptor.getAllFlowArgumentClasses(): List<ClassDescriptor> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ object VerifyMinOSVersionPhase : ClassExportPhase {
if (currentMinVersion.isLowerVersionThan(minRequiredVersion)) {
error(
"Minimum OS version for ${configurables.target.name} must be at least $minRequiredVersion to support Swift Async. " +
"However, the configured minimum OS version is only $currentMinVersion. " +
"This is most likely a bug in SKIE Gradle plugin which should have set the minimum required version automatically.",
"However, the configured minimum OS version is only $currentMinVersion. " +
"This is most likely a bug in SKIE Gradle plugin which should have set the minimum required version automatically.",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package co.touchlab.skie.phases.sir.member

import co.touchlab.skie.kir.element.KirCallableDeclaration
import co.touchlab.skie.kir.element.KirConstructor
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirProperty
import co.touchlab.skie.kir.element.KirSimpleFunction
import co.touchlab.skie.kir.element.KirValueParameter
import co.touchlab.skie.phases.SirPhase

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.touchlab.skie.phases.sir.type

import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.classDescriptorOrNull
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.sir.element.SirTypeAlias
import co.touchlab.skie.sir.element.SirVisibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ object SwiftCacheSetupPhase : SirPhase {

// Must use `or` to prevent short circuit optimization.
return framework.kotlinHeader.copyFileToIfDifferent(dummyFramework.kotlinHeader) or
framework.modulemapFile.copyFileToIfDifferent(dummyFramework.modulemapFile) or
skieBuildDirectory.swiftCompiler.apiNotes.apiNotes(framework.moduleName)
.copyFileToIfDifferent(dummyFramework.apiNotes)
framework.modulemapFile.copyFileToIfDifferent(dummyFramework.modulemapFile) or
skieBuildDirectory.swiftCompiler.apiNotes.apiNotes(framework.moduleName)
.copyFileToIfDifferent(dummyFramework.apiNotes)
}

// Solves a bug in Swift compiler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object RenameTypesConflictingWithKotlinModulePhase : SirPhase {
private fun logModuleNameCollisionWarning(moduleName: String) {
reporter.warning(
"Type '$moduleName' was renamed to '${moduleName}_' " +
"because it has the same name as the produced framework which is forbidden.",
"because it has the same name as the produced framework which is forbidden.",
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.touchlab.skie.sir.element

import co.touchlab.skie.sir.element.util.sirDeclarationParent
import io.outfoxx.swiftpoet.FunctionSpec
import io.outfoxx.swiftpoet.Modifier

class SirConstructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.touchlab.skie.sir.type

import co.touchlab.skie.sir.element.SirTypeParameter
import co.touchlab.skie.sir.element.toTypeParameterUsage
import io.outfoxx.swiftpoet.AttributeSpec
import io.outfoxx.swiftpoet.FunctionTypeName
import io.outfoxx.swiftpoet.ParameterSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class OirDeclaredSirType(

private fun getType(selectedClass: SirClass): SirDeclaredSirType {
val convertedTypeArguments = selectedClass.typeParameters
.mapIndexed { index, typeParameter -> typeParameter to (typeArguments.getOrNull(index) ?: SpecialReferenceOirType.Id) }
.mapIndexed { index, typeParameter -> typeParameter to (typeArguments.getOrNull(index) ?: SpecialReferenceOirType.Id) }
.map { (typeParameter, typeArgument) ->
mapTypeArgument(typeArgument, typeParameter)
}
Expand Down

0 comments on commit 33bd2dc

Please sign in to comment.