Skip to content

Commit

Permalink
Add missing opt-in annotations (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex authored Sep 22, 2024
1 parent 2e37d43 commit 77160db
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.createType
import org.jetbrains.kotlin.ir.util.IdSignature
Expand Down Expand Up @@ -73,6 +74,7 @@ internal class PokoMembersTransformer(
return super.visitFunctionNew(declaration)
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrClass.isPokoClass(): Boolean = when {
!hasAnnotation(pokoAnnotationName.asSingleFqName()) -> {
messageCollector.log("Not Poko class")
Expand Down Expand Up @@ -106,6 +108,7 @@ internal class PokoMembersTransformer(
}
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private inline fun IrFunction.convertToGenerated(
generateFunctionBody: IrBlockBodyBuilder.(List<IrProperty>) -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.types.isNullable
Expand Down Expand Up @@ -215,6 +216,7 @@ private fun IrBuilderWithScope.irCallContentDeepEquals(
* function if it represents a primitive array.
*/
context(IrPluginContext)
@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBuilderWithScope.findContentDeepEqualsFunctionSymbol(
classifier: IrClassifierSymbol,
): IrSimpleFunctionSymbol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classOrNull
Expand Down Expand Up @@ -124,6 +125,7 @@ private val IrTypeParameterSymbol.hasArrayOrPrimitiveArrayUpperBound: Boolean
return false
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
internal val IrTypeParameter.erasedUpperBound: IrClass
get() {
// Pick the (necessarily unique) non-interface upper bound if it exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrFail
Expand Down Expand Up @@ -141,6 +142,7 @@ private fun IrBlockBodyBuilder.getHashCodeOfProperty(
* [org.jetbrains.kotlin.fir.backend.generators.DataClassMembersGenerator].
*/
context(IrPluginContext)
@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.getHashCodeOf(
property: IrProperty,
value: IrExpression,
Expand Down Expand Up @@ -265,6 +267,7 @@ private fun IrBlockBodyBuilder.maybeFindArrayContentHashCodeFunction(
}

context(IrPluginContext)
@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.findArrayContentDeepHashCodeFunction(
propertyClassifier: IrClassifierSymbol,
): IrSimpleFunctionSymbol {
Expand All @@ -286,6 +289,7 @@ private fun IrBlockBodyBuilder.findArrayContentDeepHashCodeFunction(
}
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.getStandardHashCodeFunctionSymbol(
classifier: IrClassifierSymbol?,
): IrSimpleFunctionSymbol = when {
Expand All @@ -299,6 +303,7 @@ private fun IrBlockBodyBuilder.getStandardHashCodeFunctionSymbol(
error("Unknown classifier kind $classifier")
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.getHashCodeFunctionForClass(
irClass: IrClass
): IrSimpleFunctionSymbol {
Expand All @@ -311,6 +316,7 @@ private fun IrBlockBodyBuilder.getHashCodeFunctionForClass(
?: context.irBuiltIns.anyClass.functions.single { it.owner.name.asString() == "hashCode" }
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.irCallHashCodeFunction(
hashCodeFunctionSymbol: IrSimpleFunctionSymbol,
value: IrExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.ir.expressions.addArgument
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.types.isNullable
Expand Down Expand Up @@ -187,6 +188,7 @@ private fun IrBlockBodyBuilder.irArrayTypeCheckAndContentDeepToStringBranch(
* `contentToString` function if it is a primitive array.
*/
context(IrPluginContext)
@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBuilderWithScope.findContentDeepToStringFunctionSymbol(
propertyClassifier: IrClassifierSymbol,
): IrSimpleFunctionSymbol {
Expand All @@ -209,6 +211,7 @@ private fun IrBuilderWithScope.findContentDeepToStringFunctionSymbol(
}
}

@OptIn(UnsafeDuringIrConstructionAPI::class)
private fun IrBlockBodyBuilder.irCallToStringFunction(
toStringFunctionSymbol: IrSimpleFunctionSymbol,
value: IrExpression,
Expand Down

0 comments on commit 77160db

Please sign in to comment.