[Psi2Ir] Untangle psi2ir from frontend.java
Add extension method to detect and unwrap `JavaSyntheticProperty`
This commit is contained in:
committed by
teamcityserver
parent
3f5e6a79c7
commit
4d5186d332
+8
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmFieldAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.isJvmRecord
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
|
||||
@@ -177,4 +178,11 @@ open class JvmGeneratorExtensionsImpl(private val generateFacades: Boolean = tru
|
||||
|
||||
override val rawTypeAnnotationConstructor: IrConstructor =
|
||||
rawTypeAnnotationClass.constructors.single()
|
||||
|
||||
override fun unwrapSyntheticJavaProperty(descriptor: PropertyDescriptor): Pair<FunctionDescriptor, FunctionDescriptor?>? {
|
||||
if (descriptor is SyntheticJavaPropertyDescriptor) {
|
||||
return descriptor.getMethod to descriptor.setMethod
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ plugins {
|
||||
dependencies {
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:frontend.java"))
|
||||
compile(project(":compiler:backend-common"))
|
||||
compile(project(":compiler:ir.tree"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
|
||||
+3
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.IrScriptSymbol
|
||||
@@ -39,4 +40,6 @@ open class GeneratorExtensions : StubGeneratorExtensions() {
|
||||
get() = false
|
||||
|
||||
open fun getPreviousScripts(): List<IrScriptSymbol>? = null
|
||||
|
||||
open fun unwrapSyntheticJavaProperty(descriptor: PropertyDescriptor): Pair<FunctionDescriptor, FunctionDescriptor?>? = null
|
||||
}
|
||||
|
||||
+5
-5
@@ -38,8 +38,6 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||
|
||||
@@ -501,12 +499,14 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
||||
|
||||
private fun resolvePropertySymbol(descriptor: PropertyDescriptor, mutable: Boolean): DelegatedPropertySymbols {
|
||||
val symbol = context.symbolTable.referenceProperty(descriptor)
|
||||
if (descriptor is SyntheticJavaPropertyDescriptor) {
|
||||
val syntheticJavaProperty = context.extensions.unwrapSyntheticJavaProperty(descriptor)
|
||||
if (syntheticJavaProperty != null) {
|
||||
val (getMethod, setMethod) = syntheticJavaProperty
|
||||
// This is the special case of synthetic java properties when requested property doesn't even exist but IR design
|
||||
// requires its symbol to be bound so let do that
|
||||
// see `irText/declarations/provideDelegate/javaDelegate.kt` and KT-45297
|
||||
val getterSymbol = context.symbolTable.referenceSimpleFunction(descriptor.getMethod)
|
||||
val setterSymbol = if (mutable) descriptor.setMethod?.let {
|
||||
val getterSymbol = context.symbolTable.referenceSimpleFunction(getMethod)
|
||||
val setterSymbol = if (mutable) setMethod?.let {
|
||||
context.symbolTable.referenceSimpleFunction(it)
|
||||
} else null
|
||||
if (!symbol.isBound) {
|
||||
|
||||
Reference in New Issue
Block a user