Skip to content

Commit 3325a09

Browse files
sandwwraithSpace Team
authored andcommitted
[FIR] Make synthetic FunctionN declarations MustUse by default
Since they are not declared in stdlib sources, we cannot compile them with the MustUse flag normally as any other stdlib builtin. To handle them correctly in UnusedReturnValueChecker, their status should be set where they are created. #KT-71195
1 parent e998c9f commit 3325a09

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirUnusedReturnValueChecker.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ private fun ConeKotlinType.isIgnorable(): Boolean {
171171
private fun FirCallableSymbol<*>.isExcluded(session: FirSession): Boolean = session.mustUseReturnValueStatusComponent.hasIgnorableLikeAnnotation(resolvedAnnotationClassIds)
172172

173173
private fun FirCallableSymbol<*>.isSubjectToCheck(): Boolean {
174-
// TODO KT-71195 : FunctionN seems to be a synthetic class, even recompiling stdlib in FULL mode
175-
// does not make it checked. Need to investigate another approach.
176-
if (this.callableId?.packageName?.asString() == "kotlin") return this.origin !is FirDeclarationOrigin.Enhancement
177174
callableId?.ifTypealiasedJvmCollection { return it }
178175

179176

compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirExtensionSyntheticFunctionInterfaceProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.fir.toFirResolvedTypeRef
3636
import org.jetbrains.kotlin.fir.types.*
3737
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
3838
import org.jetbrains.kotlin.name.*
39+
import org.jetbrains.kotlin.resolve.ReturnValueStatus
3940
import org.jetbrains.kotlin.types.Variance
4041
import org.jetbrains.kotlin.util.OperatorNameConventions
4142
import java.util.concurrent.ConcurrentHashMap
@@ -229,6 +230,7 @@ abstract class FirSyntheticFunctionInterfaceProviderBase(
229230
isOperator = true
230231
isSuspend = kind.isSuspendOrKSuspendFunction
231232
hasStableParameterNames = false
233+
returnValueStatus = ReturnValueStatus.MustUse
232234
}
233235
val typeArguments = typeParameters.map {
234236
ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false).toFirResolvedTypeRef()

0 commit comments

Comments
 (0)