Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 2.1.0 #191

Merged
merged 22 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fc17449
Update Kotlin to 2.1.0-Beta1
rickclephas Sep 22, 2024
a4fd8ba
Use coneType instead of the removed type property
rickclephas Sep 22, 2024
71c39a1
Use ConeClassLikeType instead of ConeKotlinType for flowValueType
rickclephas Sep 22, 2024
a5d6f93
Update logic to get class property and function symbols
rickclephas Sep 22, 2024
ff15a47
Udpate compiler test data for Kotlin 2.1.0-Beta1
rickclephas Sep 22, 2024
d3b90d1
Update kotlin compile testing to 0.5.1
rickclephas Sep 22, 2024
d5b9997
Merge branch 'master' into feature/kotlin-2.1.0
rickclephas Sep 24, 2024
a77947a
Add Kotlin version suffix
rickclephas Sep 24, 2024
27e32fb
Merge branch 'master' into feature/kotlin-2.1.0
rickclephas Oct 20, 2024
1c8b3d0
Update Kotlin to 2.1.0-Beta2
rickclephas Oct 20, 2024
ae77983
Update yarn.lock for Kotlin 2.1.0-Beta2
rickclephas Oct 20, 2024
bdb6b46
KT-70846 update isNullable logic
rickclephas Oct 20, 2024
31bceb5
KT-71197 update codegen test
rickclephas Oct 20, 2024
fb2c5c1
Add Kotlin version suffix
rickclephas Oct 21, 2024
6453d9f
Merge branch 'master' into feature/kotlin-2.1.0
rickclephas Nov 9, 2024
c3ca337
Update Kotlin to 2.1.0-RC
rickclephas Nov 9, 2024
e9c87ef
Update Kotlin version suffix
rickclephas Nov 10, 2024
5124f71
Merge branch 'master' into feature/kotlin-2.1.0
rickclephas Nov 24, 2024
cdef8ff
Update Kotlin to 2.1.0-RC2
rickclephas Nov 24, 2024
e3589d6
Merge branch 'master' into feature/kotlin-2.1.0
rickclephas Nov 24, 2024
b3ba0fb
Update Kotlin version suffix
rickclephas Nov 24, 2024
f5ed84c
Update Kotlin to 2.1.0
rickclephas Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {

allprojects {
group = "com.rickclephas.kmp"
version = "1.0.0-ALPHA-37"
version = "1.0.0-ALPHA-37-kotlin-2.1.0-RC2"

repositories {
mavenCentral()
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]
kotlin = "2.0.21"
kotlin = "2.1.0"
kotlinx-coroutines = "1.9.0"
kotlinx-binary-compatibility-validator = "0.16.3"
ksp = "2.0.21-1.0.28"
ksp = "2.1.0-1.0.28"
kotlinpoet = "1.18.1"
junit = "5.9.1"

Expand All @@ -23,7 +23,7 @@ kotlin-script-runtime = { module = "org.jetbrains.kotlin:kotlin-script-runtime",
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-compiler-internalTestFramework = { module = "org.jetbrains.kotlin:kotlin-compiler-internal-test-framework", version.ref = "kotlin" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinCompileTesting-ksp = { module = "dev.zacsweers.kctfork:ksp", version = "0.3.2" }
kotlinCompileTesting-ksp = { module = "dev.zacsweers.kctfork:ksp", version = "0.5.1" }
junit = { module = "junit:junit", version = "4.13.2" }
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal fun buildAnnotation(
arguments: Map<Name, FirExpression> = emptyMap()
) = buildAnnotation {
annotationTypeRef = buildResolvedTypeRef {
type = classId.constructClassLikeType()
coneType = classId.constructClassLikeType()
}
argumentMapping = buildAnnotationArgumentMapping {
mapping.putAll(arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal fun FirExtension.buildStateFlowValueProperty(

returnTypeRef = firCallableSignature.getNativeType(callableSignature.returnType.valueType)
.applyIf(callableSignature.returnType.isNullable) {
withNullability(ConeNullability.NULLABLE, session.typeContext)
withNullability(true, session.typeContext)
}
.let(typeParameters.substitutor::substituteOrSelf)
.toFirResolvedTypeRef()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import com.rickclephas.kmp.nativecoroutines.compiler.fir.codegen.buildNativeFunc
import com.rickclephas.kmp.nativecoroutines.compiler.fir.codegen.buildNativeProperty
import com.rickclephas.kmp.nativecoroutines.compiler.fir.codegen.buildSharedFlowReplayCacheProperty
import com.rickclephas.kmp.nativecoroutines.compiler.fir.codegen.buildStateFlowValueProperty
import com.rickclephas.kmp.nativecoroutines.compiler.fir.utils.getFunctionSymbols
import com.rickclephas.kmp.nativecoroutines.compiler.fir.utils.getPropertySymbols
import com.rickclephas.kmp.nativecoroutines.compiler.utils.NativeCoroutinesAnnotation
import com.rickclephas.kmp.nativecoroutines.compiler.utils.NativeCoroutinesAnnotation.NativeCoroutines
import com.rickclephas.kmp.nativecoroutines.compiler.utils.NativeCoroutinesAnnotation.NativeCoroutinesIgnore
Expand All @@ -23,6 +21,9 @@ import org.jetbrains.kotlin.fir.declarations.utils.isOverride
import org.jetbrains.kotlin.fir.extensions.*
import org.jetbrains.kotlin.fir.extensions.predicate.LookupPredicate
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.scopes.getFunctions
import org.jetbrains.kotlin.fir.scopes.getProperties
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.Name
Expand Down Expand Up @@ -109,6 +110,7 @@ internal class KmpNativeCoroutinesDeclarationGenerationExtension(
context: MemberGenerationContext?
): List<FirNamedFunctionSymbol> = buildList {
generateFunctions(
context?.owner,
callableId, suffix,
setOf(NativeCoroutines, NativeCoroutinesRefined)
) { symbol, annotation ->
Expand All @@ -117,13 +119,17 @@ internal class KmpNativeCoroutinesDeclarationGenerationExtension(
}

private fun MutableList<FirNamedFunctionSymbol>.generateFunctions(
owner: FirClassSymbol<*>?,
callableId: CallableId,
suffix: String?,
annotations: Set<NativeCoroutinesAnnotation>,
generateFunction: (FirNamedFunctionSymbol, NativeCoroutinesAnnotation) -> FirNamedFunctionSymbol?
) {
val originalCallableName = callableId.callableName.withoutSuffix(suffix) ?: return
val symbols = session.symbolProvider.getFunctionSymbols(callableId.copy(originalCallableName))
val symbols = when (owner) {
null -> session.symbolProvider.getTopLevelFunctionSymbols(callableId.packageName, originalCallableName)
else -> owner.declaredMemberScope(session, null).getFunctions(originalCallableName)
}
for (symbol in symbols) {
val annotation = getAnnotationForSymbol(symbol) ?: continue
if (annotation !in annotations) continue
Expand All @@ -136,30 +142,35 @@ internal class KmpNativeCoroutinesDeclarationGenerationExtension(
context: MemberGenerationContext?
): List<FirPropertySymbol> = buildList {
generateProperties(
context?.owner,
callableId, suffix,
setOf(NativeCoroutines, NativeCoroutinesRefined)
) { symbol, annotation ->
buildNativeProperty(callableId, symbol, annotation, objCName = symbol.name.identifier)
}
generateProperties(
context?.owner,
callableId, flowValueSuffix,
setOf(NativeCoroutines, NativeCoroutinesRefined)
) { symbol, annotation ->
buildStateFlowValueProperty(callableId, symbol, annotation, objCNameSuffix = flowValueSuffix)
}
generateProperties(
context?.owner,
callableId, flowReplayCacheSuffix,
setOf(NativeCoroutines, NativeCoroutinesRefined)
) { symbol, annotation ->
buildSharedFlowReplayCacheProperty(callableId, symbol, annotation, flowReplayCacheSuffix)
}
generateProperties(
context?.owner,
callableId, stateSuffix,
setOf(NativeCoroutinesState, NativeCoroutinesRefinedState)
) { symbol, annotation ->
buildStateFlowValueProperty(callableId, symbol, annotation, objCName = symbol.name.identifier)
}
generateProperties(
context?.owner,
callableId, stateFlowSuffix,
setOf(NativeCoroutinesState, NativeCoroutinesRefinedState)
) { symbol, annotation ->
Expand All @@ -168,13 +179,18 @@ internal class KmpNativeCoroutinesDeclarationGenerationExtension(
}

private fun MutableList<FirPropertySymbol>.generateProperties(
owner: FirClassSymbol<*>?,
callableId: CallableId,
suffix: String?,
annotations: Set<NativeCoroutinesAnnotation>,
generateProperty: (FirPropertySymbol, NativeCoroutinesAnnotation) -> FirPropertySymbol?
) {
val originalCallableName = callableId.callableName.withoutSuffix(suffix) ?: return
val symbols = session.symbolProvider.getPropertySymbols(callableId.copy(originalCallableName))
val symbols = when (owner) {
null -> session.symbolProvider.getTopLevelPropertySymbols(callableId.packageName, originalCallableName)
else -> owner.declaredMemberScope(session, null)
.getProperties(originalCallableName).filterIsInstance<FirPropertySymbol>()
}
for (symbol in symbols) {
val annotation = getAnnotationForSymbol(symbol) ?: continue
if (annotation !in annotations) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class FirCallableSignature(
}

internal fun FirCallableSymbol<*>.getCallableSignature(session: FirSession): FirCallableSignature? {
val returnType = resolvedReturnTypeRefOrNull?.type?.fullyExpandedType(session) ?: return null
val returnType = resolvedReturnTypeRefOrNull?.coneType?.fullyExpandedType(session) ?: return null
return FirCallableSignature(session) {
val valueParameters = when (this@getCallableSignature) {
is FirFunctionSymbol<*> -> valueParameterSymbols.map {
Expand Down Expand Up @@ -94,8 +94,8 @@ private fun FirCallableSignature.Builder.createType(rawType: ConeKotlinType): Ca
return rawType.asRawType()
}

private val ConeKotlinType.flowValueType: ConeKotlinType
private val ConeClassLikeType.flowValueType: ConeKotlinType
get() = when (val argument = typeArguments.firstOrNull()) {
is ConeKotlinTypeProjection -> argument.type
is ConeStarProjection, null -> StandardClassIds.Any.constructClassLikeType(isNullable = true)
is ConeStarProjection, null -> StandardClassIds.Any.constructClassLikeType(isMarkedNullable = true)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import org.junit.jupiter.api.BeforeAll

abstract class AbstractFirBaseCodegenTest(
private val firParser: FirParser
): AbstractJvmBlackBoxCodegenTestBase<FirOutputArtifact, IrBackendInput>(
FrontendKinds.FIR, TargetBackend.JVM_IR
): AbstractJvmBlackBoxCodegenTestBase<FirOutputArtifact>(
FrontendKinds.FIR
) {

companion object {
Expand All @@ -61,8 +61,6 @@ abstract class AbstractFirBaseCodegenTest(
get() = ::FirFrontendFacade
final override val frontendToBackendConverter: Constructor<Frontend2BackendConverter<FirOutputArtifact, IrBackendInput>>
get() = ::Fir2IrResultsConverter
final override val backendFacade: Constructor<BackendFacade<IrBackendInput, BinaryArtifacts.Jvm>>
get() = ::JvmIrBackendFacade

override fun configure(builder: TestConfigurationBuilder) = with(builder) {
super.configure(builder)
Expand Down
Loading
Loading