Skip to content

Commit 2a49b1d

Browse files
committed
Fixed DI tracking for default lambdas
1 parent 565be9b commit 2a49b1d

File tree

2 files changed

+6
-3
lines changed
  • build-logic/build-logic-base/src/main/kotlin/com/ensody/buildlogic
  • reactivestate-core/src/commonMain/kotlin/com/ensody/reactivestate

2 files changed

+6
-3
lines changed

build-logic/build-logic-base/src/main/kotlin/com/ensody/buildlogic/Utils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ internal fun Project.detectProjectVersion(): String =
8282
versionRegex.matchEntire(it) != null
8383
}.maxByOrNull {
8484
VersionComparable(versionRegex.matchEntire(it)!!.destructured.toList())
85-
}?.removePrefix("v")?.removePrefix("-") ?: run {
85+
}?.removePrefix("v")?.removePrefix("-")?.takeIf { System.getenv("RUNNING_ON_CI") == "true" }
86+
?: run {
8687
val branchName = cli("git", "rev-parse", "--abbrev-ref", "HEAD")
8788
"999999.0.0-${sanitizeBranchName(branchName)}.1"
8889
}

reactivestate-core/src/commonMain/kotlin/com/ensody/reactivestate/DI.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ public class DIImpl {
134134
}
135135

136136
// We hide this function as an extension, so nobody can mistakenly get() arbitrary T values not belonging to the DI
137-
public inline fun <reified T : Any> DIResolver.get(noinline default: (() -> T)? = null): LazyProperty<T> =
137+
public inline fun <reified T : Any> DIResolver.get(
138+
noinline default: (DIResolver.() -> T)? = null,
139+
): LazyProperty<T> =
138140
InternalDI.run { get(this@get, T::class, default) }
139141

140142
public fun <T : Any> InternalDI.get(
141143
resolver: DIResolver,
142144
klass: KClass<T>,
143-
default: (() -> T)? = null,
145+
default: (DIResolver.() -> T)? = null,
144146
): LazyProperty<T> {
145147
if (default != null && klass !in deps) {
146148
register(klass) { default() }

0 commit comments

Comments
 (0)