Skip to content

Commit 8fcc516

Browse files
committed
Remove fields support
1 parent eaaba79 commit 8fcc516

File tree

22 files changed

+48
-1421
lines changed

22 files changed

+48
-1421
lines changed

compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcDeclarationScanner.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
1111
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
1212
import org.jetbrains.kotlin.ir.declarations.IrProperty
1313
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
14-
import org.jetbrains.kotlin.ir.types.classOrNull
1514
import org.jetbrains.kotlin.ir.util.dumpKotlinLike
1615

1716
/**
@@ -47,16 +46,10 @@ internal object RpcDeclarationScanner {
4746
return@memoryOptimizedMap null
4847
}
4948

50-
val symbol = declaration.getter!!.returnType.classOrNull
51-
52-
val flowType = when (symbol) {
53-
ctx.flow -> ServiceDeclaration.FlowField.Kind.Plain
54-
ctx.sharedFlow -> ServiceDeclaration.FlowField.Kind.Shared
55-
ctx.stateFlow -> ServiceDeclaration.FlowField.Kind.State
56-
else -> return@memoryOptimizedMap unsupportedDeclaration(service, declaration, logger)
57-
}
58-
59-
ServiceDeclaration.FlowField(declaration, flowType)
49+
error(
50+
"Fields are not supported in @Rpc services, this error should be caught by frontend. " +
51+
"Please report this issue to the kotlinx-rpc maintainers."
52+
)
6053
}
6154

6255
is IrClass -> {
@@ -80,8 +73,7 @@ internal object RpcDeclarationScanner {
8073
return ServiceDeclaration(
8174
service = service,
8275
stubClass = stubClassNotNull,
83-
methods = declarations.filterIsInstance<ServiceDeclaration.Method>(),
84-
fields = declarations.filterIsInstance<ServiceDeclaration.FlowField>(),
76+
methods = declarations.filterNotNull(),
8577
)
8678
}
8779
}

compiler-plugin/compiler-plugin-backend/src/main/core/kotlinx/rpc/codegen/extension/RpcIrContext.kt

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
1010
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
1111
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
1212
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
13-
import org.jetbrains.kotlin.ir.types.classOrNull
1413
import org.jetbrains.kotlin.ir.types.makeNullable
1514
import org.jetbrains.kotlin.ir.util.functions
1615
import org.jetbrains.kotlin.ir.util.isVararg
@@ -45,18 +44,6 @@ internal class RpcIrContext(
4544
getIrClassSymbol("kotlin.reflect", "KType")
4645
}
4746

48-
val lazy by lazy {
49-
getIrClassSymbol("kotlin", "Lazy")
50-
}
51-
52-
val function0 by lazy {
53-
getIrClassSymbol("kotlin", "Function0")
54-
}
55-
56-
val function1 by lazy {
57-
getIrClassSymbol("kotlin", "Function1")
58-
}
59-
6047
val suspendFunction0 by lazy {
6148
getIrClassSymbol("kotlin.coroutines", "SuspendFunction0")
6249
}
@@ -77,10 +64,6 @@ internal class RpcIrContext(
7764
getIrClassSymbol("kotlinx.coroutines.flow", "StateFlow")
7865
}
7966

80-
val kProperty1 by lazy {
81-
getIrClassSymbol("kotlin.reflect", "KProperty1")
82-
}
83-
8467
val pair by lazy {
8568
getIrClassSymbol("kotlin", "Pair")
8669
}
@@ -97,10 +80,6 @@ internal class RpcIrContext(
9780
getRpcIrClassSymbol("WithServiceDescriptor", "internal")
9881
}
9982

100-
val rpcEagerFieldAnnotation by lazy {
101-
getRpcIrClassSymbol("RpcEagerField")
102-
}
103-
10483
val rpcServiceDescriptor by lazy {
10584
getRpcIrClassSymbol("RpcServiceDescriptor", "descriptor")
10685
}
@@ -121,10 +100,6 @@ internal class RpcIrContext(
121100
rpcInvokator.subClass("Method")
122101
}
123102

124-
val rpcInvokatorField by lazy {
125-
rpcInvokator.subClass("Field")
126-
}
127-
128103
val rpcParameter by lazy {
129104
getRpcIrClassSymbol("RpcParameter", "descriptor")
130105
}
@@ -133,10 +108,6 @@ internal class RpcIrContext(
133108
getRpcIrClassSymbol("RpcDeferredField", "internal")
134109
}
135110

136-
val fieldDataObject by lazy {
137-
getRpcIrClassSymbol("FieldDataObject", "internal")
138-
}
139-
140111
val rpcMethodClass by lazy {
141112
getRpcIrClassSymbol("RpcMethodClass", "internal")
142113
}
@@ -156,18 +127,6 @@ internal class RpcIrContext(
156127
val functions = Functions()
157128

158129
inner class Functions {
159-
val registerPlainFlowField by lazy {
160-
namedFunction("kotlinx.rpc", "registerPlainFlowField")
161-
}
162-
163-
val registerSharedFlowField by lazy {
164-
namedFunction("kotlinx.rpc", "registerSharedFlowField")
165-
}
166-
167-
val registerStateFlowField by lazy {
168-
namedFunction("kotlinx.rpc", "registerStateFlowField")
169-
}
170-
171130
val dataCast by lazy {
172131
namedFunction("kotlinx.rpc.internal", "rpcInternalDataCast")
173132
}
@@ -200,30 +159,6 @@ internal class RpcIrContext(
200159
namedFunction("kotlinx.rpc.internal", "scopedClientCall")
201160
}
202161

203-
val lazy by lazy {
204-
namedFunction("kotlin", "lazy") {
205-
vsApi {
206-
it.owner.valueParametersVS().size == 1
207-
}
208-
}
209-
}
210-
211-
val lazyGetValue by lazy {
212-
namedFunction("kotlin", "getValue") {
213-
vsApi {
214-
it.owner.extensionReceiverParameterVS?.type?.classOrNull == this@RpcIrContext.lazy
215-
}
216-
}
217-
}
218-
219-
val listOf by lazy {
220-
namedFunction("kotlin.collections", "listOf") {
221-
vsApi {
222-
it.owner.valueParametersVS().singleOrNull()?.isVararg ?: false
223-
}
224-
}
225-
}
226-
227162
val emptyList by lazy {
228163
namedFunction("kotlin.collections", "emptyList")
229164
}

0 commit comments

Comments
 (0)