Skip to content

Commit

Permalink
Kotlin 2.1.0-Beta2
Browse files Browse the repository at this point in the history
* KSP 2.1.0-Beta2-1.0.25
* KCT fork 0.6.0-alpha01
* Update yarn lock
* Drop reflection and use safe coneTypeOrNull property
* Update compatibility testing matrix
  • Loading branch information
drewhamilton committed Oct 18, 2024
1 parent e440847 commit 8774fd2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
needs: build
strategy:
matrix:
poko_sample_kotlin_version: [ 2.0.0, 2.0.10, 2.0.20, ~, 2.1.0-Beta2 ]
poko_sample_kotlin_version: [ 2.0.0, 2.0.10, 2.0.20, 2.0.21, ~ ]
env:
poko_sample_kotlin_version: ${{ matrix.poko_sample_kotlin_version }}
steps:
Expand Down
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.

7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

androidx-compose-runtime = "1.7.4"

kotlin = "2.0.21"
kotlin = "2.1.0-Beta2"
kotlinCompileTesting = "1.6.0"
kotlinCompileTestingFork = "0.5.1"
# https://central.sonatype.com/artifact/dev.zacsweers.kctfork/core/versions:
kotlinCompileTestingFork = "0.6.0-alpha01"
# https://github.com/google/ksp/releases:
ksp = "2.0.21-1.0.25"
ksp = "2.1.0-Beta2-1.0.25"

[libraries]

Expand Down
15 changes: 11 additions & 4 deletions kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ js-yaml@^4.1.0:
dependencies:
argparse "^2.0.1"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286"
integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw==
dependencies:
format-util "^1.0.5"

locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
Expand All @@ -296,10 +303,10 @@ minimatch@^5.0.1, minimatch@^5.1.6:
dependencies:
brace-expansion "^2.0.1"

[email protected].0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a"
integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==
[email protected].3:
version "10.7.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752"
integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==
dependencies:
ansi-colors "^4.1.3"
browser-stdout "^1.3.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package dev.drewhamilton.poko.fir

import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
import org.jetbrains.kotlin.fir.extensions.FirExtensionSessionComponent
import org.jetbrains.kotlin.fir.extensions.FirExtensionSessionComponent.Factory
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.classId
import org.jetbrains.kotlin.fir.types.coneTypeSafe
import org.jetbrains.kotlin.fir.types.coneTypeOrNull
import org.jetbrains.kotlin.name.ClassId

internal class PokoFirExtensionSessionComponent(
Expand All @@ -26,31 +20,7 @@ internal class PokoFirExtensionSessionComponent(
}

private fun FirAnnotation.classId(): ClassId? {
val coneClassLikeType = try {
annotationTypeRef.coneTypeSafe<ConeClassLikeType>()
} catch (noSuchMethodError: NoSuchMethodError) {
val annotationTypeRef = annotationTypeRef
if (annotationTypeRef is FirResolvedTypeRef) {
// The `coneTypeSafe` inline function uses a getter that changes names from `type`
// to `coneType` in 2.1+, so we access the latter via reflection here:
FirResolvedTypeRef::class.java
.methods
.single { it.name == "getConeType" }
.invoke(annotationTypeRef)
as? ConeClassLikeType
} else {
null
}
}
return coneClassLikeType?.classId
}

@OptIn(ExperimentalContracts::class)
private inline fun <reified T : ConeKotlinType> FirTypeRef.coneTypeSafeReflection(): T? {
contract {
returnsNotNull() implies (this@coneTypeSafeReflection is FirResolvedTypeRef)
}
return (this as? FirResolvedTypeRef)?.type as? T
return annotationTypeRef.coneTypeOrNull?.classId
}

internal companion object {
Expand Down
15 changes: 11 additions & 4 deletions sample/kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ js-yaml@^4.1.0:
dependencies:
argparse "^2.0.1"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286"
integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw==
dependencies:
format-util "^1.0.5"

locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
Expand All @@ -296,10 +303,10 @@ minimatch@^5.0.1, minimatch@^5.1.6:
dependencies:
brace-expansion "^2.0.1"

[email protected].0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a"
integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==
[email protected].3:
version "10.7.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752"
integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==
dependencies:
ansi-colors "^4.1.3"
browser-stdout "^1.3.1"
Expand Down

0 comments on commit 8774fd2

Please sign in to comment.