Skip to content

Commit 5d86b23

Browse files
authored
[compiler] remove unused argument to scalarAdapterInitializer() (#5996)
1 parent 2be9524 commit 5d86b23

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinResolver.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,28 +182,28 @@ internal class KotlinResolver(
182182
is IrListType2 -> adapterInitializer2(type.ofType, jsExport)?.list(jsExport)
183183
is IrScalarType2 -> {
184184
if (scalarMapping.containsKey(type.name)) {
185-
scalarAdapterInitializer(type.name, customScalarAdapters)
185+
scalarAdapterInitializer(type.name)
186186
} else {
187187
null
188188
}
189189
}
190190

191191
is IrEnumType2 -> {
192-
adapterInitializer(IrEnumType(type.name), false, jsExport, "")
192+
adapterInitializer(IrEnumType(type.name), false, jsExport)
193193
}
194194

195195
is IrCompositeType2 -> null
196196
}
197197
}
198198

199-
internal fun adapterInitializer(type: IrType, requiresBuffering: Boolean, jsExport: Boolean, runtimeAdapterPrefix: String): CodeBlock {
199+
internal fun adapterInitializer(type: IrType, requiresBuffering: Boolean, jsExport: Boolean): CodeBlock {
200200
return when {
201201
type.optional -> {
202202
val presentFun = MemberName("com.apollographql.apollo3.api", "present")
203-
CodeBlock.of("%L.%M()", adapterInitializer(type.optional(false), requiresBuffering, jsExport, runtimeAdapterPrefix), presentFun)
203+
CodeBlock.of("%L.%M()", adapterInitializer(type.optional(false), requiresBuffering, jsExport), presentFun)
204204
}
205205
type.catchTo != IrCatchTo.NoCatch -> {
206-
adapterInitializer(type.catchTo(IrCatchTo.NoCatch), requiresBuffering, jsExport, runtimeAdapterPrefix).let {
206+
adapterInitializer(type.catchTo(IrCatchTo.NoCatch), requiresBuffering, jsExport).let {
207207
val member = when (type.catchTo) {
208208
IrCatchTo.Null -> KotlinSymbols.catchToNull
209209
IrCatchTo.Result -> KotlinSymbols.catchToResult
@@ -213,7 +213,7 @@ internal class KotlinResolver(
213213
}
214214
}
215215
type.maybeError -> {
216-
adapterInitializer(type.maybeError(false), requiresBuffering, jsExport, runtimeAdapterPrefix).let {
216+
adapterInitializer(type.maybeError(false), requiresBuffering, jsExport).let {
217217
CodeBlock.of("%L.%M()", it, KotlinSymbols.errorAware)
218218
}
219219
}
@@ -232,23 +232,23 @@ internal class KotlinResolver(
232232

233233
else -> {
234234
val nullableFun = MemberName("com.apollographql.apollo3.api", "nullable")
235-
CodeBlock.of("%L.%M()", adapterInitializer(type.nullable(false), requiresBuffering, jsExport, runtimeAdapterPrefix), nullableFun)
235+
CodeBlock.of("%L.%M()", adapterInitializer(type.nullable(false), requiresBuffering, jsExport), nullableFun)
236236
}
237237
}
238238
}
239239
else -> {
240240
when (type) {
241241
is IrListType -> {
242-
adapterInitializer(type.ofType, requiresBuffering, jsExport, runtimeAdapterPrefix).list(jsExport)
242+
adapterInitializer(type.ofType, requiresBuffering, jsExport).list(jsExport)
243243
}
244244

245245
is IrScalarType -> {
246-
scalarAdapterInitializer(type.name, runtimeAdapterPrefix)
246+
scalarAdapterInitializer(type.name)
247247
}
248248

249249
is IrEnumType -> {
250250
if (jsExport) {
251-
scalarAdapterInitializer("String", runtimeAdapterPrefix)
251+
scalarAdapterInitializer("String")
252252
} else {
253253
CodeBlock.of("%T", resolveAndAssert(ResolverKeyKind.SchemaTypeAdapter, type.name))
254254
}
@@ -272,7 +272,7 @@ internal class KotlinResolver(
272272
return CodeBlock.of("%T.$type", resolveAndAssert(ResolverKeyKind.SchemaType, name))
273273
}
274274

275-
private fun scalarAdapterInitializer(name: String, runtimeAdaptersPrefix: String): CodeBlock {
275+
private fun scalarAdapterInitializer(name: String): CodeBlock {
276276
return when (val adapterInitializer = scalarMapping[name]?.adapterInitializer) {
277277
is ExpressionAdapterInitializer -> {
278278
CodeBlock.of(adapterInitializer.expression)
@@ -281,7 +281,7 @@ internal class KotlinResolver(
281281
is RuntimeAdapterInitializer -> {
282282
val target = resolveScalarTarget(name)
283283
CodeBlock.of(
284-
"$runtimeAdaptersPrefix.responseAdapterFor<%T>(%L)",
284+
"$customScalarAdapters.responseAdapterFor<%T>(%L)",
285285
target,
286286
resolveCompiledType(name)
287287
)
@@ -300,7 +300,7 @@ internal class KotlinResolver(
300300
CodeBlock.of("%M", KotlinSymbols.AnyAdapter)
301301
} else {
302302
CodeBlock.of(
303-
"$runtimeAdaptersPrefix.responseAdapterFor<%T>(%L)",
303+
"$customScalarAdapters.responseAdapterFor<%T>(%L)",
304304
target,
305305
resolveCompiledType(name)
306306
)

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/AdapterCommon.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal fun readFromResponseCodeBlock(
7171
.add(
7272
regularProperties.mapIndexed { index, property ->
7373
val variableName = property.info.responseName.variableName()
74-
val adapterInitializer = context.resolver.adapterInitializer(property.info.type, property.requiresBuffering, context.jsExport, customScalarAdapters)
74+
val adapterInitializer = context.resolver.adapterInitializer(property.info.type, property.requiresBuffering, context.jsExport)
7575
CodeBlock.of(
7676
"%L·->·%N·=·%L.$fromJson($reader${customScalarAdapters})",
7777
index,
@@ -215,7 +215,7 @@ private fun IrProperty.writeToResponseCodeBlock(context: KotlinContext): CodeBlo
215215
val propertyName = context.layout.propertyName(info.responseName)
216216

217217
if (!isSynthetic) {
218-
val adapterInitializer = context.resolver.adapterInitializer(info.type, requiresBuffering, context.jsExport, customScalarAdapters)
218+
val adapterInitializer = context.resolver.adapterInitializer(info.type, requiresBuffering, context.jsExport)
219219
builder.addStatement("${writer}.name(%S)", info.responseName)
220220
builder.addStatement(
221221
"%L.$toJson($writer, $customScalarAdapters, $value.%N)",

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/InputAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private fun List<NamedType>.writeToResponseCodeBlock(context: KotlinContext): Co
7373
}
7474

7575
private fun NamedType.writeToResponseCodeBlock(context: KotlinContext): CodeBlock {
76-
val adapterInitializer = context.resolver.adapterInitializer(type, false, context.jsExport, customScalarAdapters)
76+
val adapterInitializer = context.resolver.adapterInitializer(type, false, context.jsExport)
7777
val builder = CodeBlock.builder()
7878
val propertyName = context.layout.propertyName(graphQlName)
7979

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/operations/util/ExecutableCommon.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ internal fun adapterFunSpec(
6464
.addCode(
6565
CodeBlock.of(
6666
"return·%L",
67-
context.resolver.adapterInitializer(type, property.requiresBuffering, context.jsExport, "")
67+
context.resolver.adapterInitializer(type, property.requiresBuffering, context.jsExport)
6868
)
6969
)
7070
.build()

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/operations/util/VariablesAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private fun List<IrVariable>.writeToResponseCodeBlock(context: KotlinContext): C
5050
}
5151

5252
private fun IrVariable.writeToResponseCodeBlock(context: KotlinContext): CodeBlock {
53-
val adapterInitializer = context.resolver.adapterInitializer(type, false, context.jsExport, customScalarAdapters)
53+
val adapterInitializer = context.resolver.adapterInitializer(type, false, context.jsExport)
5454
val builder = CodeBlock.builder()
5555
val propertyName = context.layout.propertyName(name)
5656

0 commit comments

Comments
 (0)