[FIR2IR] Fix crash caused by unresolved annotation argument in deserialized class
#KT-60181 Fixed
This commit is contained in:
committed by
Space Team
parent
b1884456b8
commit
987867fe12
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorClassImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.defaultConstructor
|
||||
@@ -1414,6 +1415,11 @@ class Fir2IrVisitor(
|
||||
}
|
||||
is FirClassReferenceExpression -> {
|
||||
(argument.classTypeRef.coneType.lowerBoundIfFlexible() as? ConeClassLikeType)?.toIrClassSymbol()
|
||||
// A null value means we have some unresolved code, possibly in a binary dependency that's missing a transitive dependency,
|
||||
// see KT-60181.
|
||||
// Returning null will lead to convertToIrExpression(argument) being called below which leads to a crash.
|
||||
// Instead, we return an error symbol.
|
||||
?: IrErrorClassImpl.symbol
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
+17
@@ -120,4 +120,21 @@ class CustomK2Tests : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Java binary dependency class contains unresolved annotation argument. KT-60181")
|
||||
fun kt60181JavaDependencyAnnotatedWithUnresolved(gradleVersion: GradleVersion) {
|
||||
with(
|
||||
project(
|
||||
"k2-java-dep-unresolved-annotation-argument",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(languageVersion = "2.0"),
|
||||
)
|
||||
) {
|
||||
val taskToExecute = ":compileKotlin"
|
||||
build(taskToExecute) {
|
||||
assertTasksExecuted(taskToExecute)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-actuator-autoconfigure:2.7.12")
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import org.springframework.beans.factory.ObjectProvider
|
||||
import org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration
|
||||
import org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorProperties
|
||||
import org.springframework.boot.actuate.health.HealthContributor
|
||||
import org.springframework.boot.jdbc.metadata.DataSourcePoolMetadataProvider
|
||||
import javax.sql.DataSource
|
||||
|
||||
class MyDataSourceHealthContributorAutoConfiguration(
|
||||
metadataProviders: ObjectProvider<DataSourcePoolMetadataProvider>,
|
||||
) : DataSourceHealthContributorAutoConfiguration(metadataProviders) {
|
||||
override fun dbHealthContributor(
|
||||
dataSources: MutableMap<String, DataSource>,
|
||||
dataSourceHealthIndicatorProperties: DataSourceHealthIndicatorProperties,
|
||||
): HealthContributor? {
|
||||
return super.dbHealthContributor(dataSources, dataSourceHealthIndicatorProperties)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user