K2: remove dependency fir-deserialization -> compiler.common.jvm
- Rename DeserializedClassConfigurator -> FirDeserializationExtension to abstract the existing behavior (about the Serializable supertype), as well as any future JVM-specific deserialization behavior. - Rename JvmDeserializedClassConfigurator -> FirJvmDeserializationExtension and move it to fir:java.
This commit is contained in:
committed by
Space Team
parent
6943d03883
commit
3e313bca78
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.java.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInsSignatures
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirRegularClassBuilder
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationExtension
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.toLookupTag
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class FirJvmDeserializationExtension(session: FirSession) : FirDeserializationExtension(session) {
|
||||
override fun FirRegularClassBuilder.configureDeserializedClass(classId: ClassId) {
|
||||
addSerializableIfNeeded(classId)
|
||||
}
|
||||
|
||||
private fun FirRegularClassBuilder.addSerializableIfNeeded(classId: ClassId) {
|
||||
if (!JvmBuiltInsSignatures.isSerializableInJava(classId.asSingleFqName().toUnsafe())) return
|
||||
superTypeRefs += buildResolvedTypeRef {
|
||||
type = ConeClassLikeTypeImpl(
|
||||
JAVA_IO_SERIALIZABLE.toLookupTag(),
|
||||
typeArguments = emptyArray(),
|
||||
isNullable = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val JAVA_IO_SERIALIZABLE = ClassId.topLevel(FqName("java.io.Serializable"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user