Skip to content

Commit 29daa48

Browse files
committed
Minor. Clarify generateSyntheticCheckNotNullFunction
- Use clearer names - Get rid of unnecessary `typeArgument` node - Move `valueParameterTypeRef` closer to the single usage
1 parent fd59a78 commit 29daa48

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,20 @@ class FirSyntheticCallGenerator(
473473
// Synthetic function signature:
474474
// fun <K : Any> checkNotNull(arg: K?): K
475475
val functionSymbol = FirSyntheticFunctionSymbol(SyntheticCallableId.CHECK_NOT_NULL)
476-
val (typeParameter, returnType) = generateSyntheticSelectTypeParameter(functionSymbol, isNullableBound = false)
477-
478-
val argumentType = buildResolvedTypeRef {
479-
type = returnType.type.withNullability(ConeNullability.NULLABLE, session.typeContext)
480-
}
481-
val typeArgument = buildTypeProjectionWithVariance {
482-
typeRef = returnType
483-
variance = Variance.INVARIANT
484-
}
476+
val (typeParameter, typeParameterTypeRef) = generateSyntheticSelectTypeParameter(functionSymbol, isNullableBound = false)
485477

486478
return generateMemberFunction(
487479
functionSymbol,
488480
SyntheticCallableId.CHECK_NOT_NULL.callableName,
489-
typeArgument.typeRef
481+
typeParameterTypeRef,
490482
).apply {
491483
typeParameters += typeParameter
492-
valueParameters += argumentType.toValueParameter("arg", functionSymbol)
484+
485+
val valueParameterTypeRef = buildResolvedTypeRef {
486+
type = typeParameterTypeRef.type.withNullability(ConeNullability.NULLABLE, session.typeContext)
487+
}
488+
489+
valueParameters += valueParameterTypeRef.toValueParameter("arg", functionSymbol)
493490
}.build()
494491
}
495492

0 commit comments

Comments
 (0)