Remove asMemberOf workaround in XProcessing
The KSP bug around java overriding kotlin properties is now
fixed hence we don't need the workaround anymore.
Issue: https://github.com/google/ksp/issues/462
Bug: 160322705
Test: existing tests pass without the workaround
Change-Id: I36b0b0b83f314738d4decc5d8acccb71aef50b20
diff --git a/room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSAsMemberOf.kt b/room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSAsMemberOf.kt
index 1fd802b..53cd24a 100644
--- a/room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSAsMemberOf.kt
+++ b/room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSAsMemberOf.kt
@@ -16,13 +16,10 @@
package androidx.room.compiler.processing.ksp
-import com.google.devtools.ksp.symbol.KSFunction
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
import com.google.devtools.ksp.symbol.KSPropertyDeclaration
import com.google.devtools.ksp.symbol.KSType
-import com.google.devtools.ksp.symbol.KSTypeParameter
import com.google.devtools.ksp.symbol.KSValueParameter
-import java.lang.UnsupportedOperationException
/**
* Returns the type of a property as if it is member of the given [ksType].
@@ -67,7 +64,7 @@
if (ksType == null) {
return resolved
}
- val asMember = functionDeclaration.safeAsMemberOf(
+ val asMember = functionDeclaration.asMemberOf(
containing = ksType
)
// TODO b/173224718
@@ -89,42 +86,8 @@
// object
resolved
}
- else -> this.safeAsMemberOf(
+ else -> this.asMemberOf(
containing = ksType
).returnType
} ?: error("cannot find return type for $this")
}
-
-/**
- * Runs asMemberOf while working around a KSP bug where if a java method overrides a property,
- * calling as member of fails it.
- */
-private fun KSFunctionDeclaration.safeAsMemberOf(
- containing: KSType
-): KSFunction {
- return try {
- asMemberOf(containing)
- } catch (unsupported: UnsupportedOperationException) {
- SyntheticKSFunction(this)
- }
-}
-
-/**
- * Workaround for https://github.com/google/ksp/issues/462
- */
-private class SyntheticKSFunction(
- val declaration: KSFunctionDeclaration
-) : KSFunction {
- override val extensionReceiverType: KSType?
- get() = declaration.extensionReceiver?.resolve()
- override val isError: Boolean
- get() = false
- override val parameterTypes: List<KSType?>
- get() = declaration.parameters.map { param ->
- param.type.resolve()
- }
- override val returnType: KSType?
- get() = declaration.returnType?.resolve()
- override val typeParameters: List<KSTypeParameter>
- get() = declaration.typeParameters
-}
\ No newline at end of file