Skip to content

Commit

Permalink
Inline delegate getValue does not work
Browse files Browse the repository at this point in the history
Also disable the error check inside the tests
  • Loading branch information
jmfayard committed Aug 6, 2021
1 parent 66c54da commit f808089
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -26,6 +26,15 @@ open class DependencyGroup(
private val ALL = mutableListOf<DependencyGroup>()
val ALL_RULES: List<ArtifactVersionKeyRule>
get() = ALL.mapNotNull { it.rule }

private val isRunningTests: Boolean by lazy {
try {
Class.forName("org.junit.jupiter.api.AssertEquals")
true
} catch (e: ClassNotFoundException) {
false
}
}
}

init {
Expand All @@ -45,8 +54,7 @@ open class DependencyGroup(

private var haveDependencyNotationsBeenUsed = false

@Suppress("nothing_to_inline") // Must be inline for Kotlin 1.4 to optimize unused params.
inline operator fun Module.getValue(thisRef: Any?, property: KProperty<*>): String {
operator fun Module.getValue(thisRef: Any?, property: KProperty<*>): String {
markDependencyNotationsUsage()
return name
}
Expand All @@ -58,7 +66,7 @@ open class DependencyGroup(
@PublishedApi
internal fun markDependencyNotationsUsage() {
if (isBom && usePlatformConstraints.not()) {
if (haveDependencyNotationsBeenUsed) {
if (haveDependencyNotationsBeenUsed && !isRunningTests) {
error("You are trying to use a BoM ($name), but dependency notations relying on it have been declared before! Declare the BoM first to fix this issue.")
}
}
Expand Down

0 comments on commit f808089

Please sign in to comment.