ForLoopsLowering: Use @file:OptIn(ExperimentalUnsignedTypes::class)

instead of annotating declarations.
This commit is contained in:
Mark Punzalan
2020-05-11 15:10:20 -07:00
committed by Alexander Udalov
parent b5b361bb09
commit 99856afc31
4 changed files with 4 additions and 10 deletions
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@file:OptIn(ExperimentalUnsignedTypes::class)
package org.jetbrains.kotlin.backend.common.lower.loops package org.jetbrains.kotlin.backend.common.lower.loops
import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.CommonBackendContext
@@ -71,7 +73,6 @@ internal class ProgressionHeaderInfo(
additionalNotEmptyCondition = additionalNotEmptyCondition additionalNotEmptyCondition = additionalNotEmptyCondition
) { ) {
@ExperimentalUnsignedTypes
val canOverflow: Boolean by lazy { val canOverflow: Boolean by lazy {
if (canOverflow != null) return@lazy canOverflow if (canOverflow != null) return@lazy canOverflow
@@ -268,7 +269,6 @@ internal abstract class HeaderInfoBuilder(context: CommonBackendContext, private
override fun visitElement(element: IrElement, data: IrCall?): HeaderInfo? = null override fun visitElement(element: IrElement, data: IrCall?): HeaderInfo? = null
/** Builds a [HeaderInfo] for iterable expressions that are calls (e.g., `.reversed()`, `.indices`. */ /** Builds a [HeaderInfo] for iterable expressions that are calls (e.g., `.reversed()`, `.indices`. */
@ExperimentalUnsignedTypes
override fun visitCall(iterable: IrCall, iteratorCall: IrCall?): HeaderInfo? { override fun visitCall(iterable: IrCall, iteratorCall: IrCall?): HeaderInfo? {
// Return the HeaderInfo from the first successful match. // Return the HeaderInfo from the first successful match.
// First, try to match a `reversed()` or `withIndex()` call. // First, try to match a `reversed()` or `withIndex()` call.
@@ -270,7 +270,6 @@ internal class ProgressionLoopHeader(
private var loopVariable: IrVariable? = null private var loopVariable: IrVariable? = null
@ExperimentalUnsignedTypes
override fun initializeIteration( override fun initializeIteration(
loopVariable: IrVariable?, loopVariable: IrVariable?,
loopVariableComponents: Map<Int, IrVariable>, loopVariableComponents: Map<Int, IrVariable>,
@@ -301,7 +300,6 @@ internal class ProgressionLoopHeader(
listOfNotNull(loopVariable, incrementInductionVariable(this)) listOfNotNull(loopVariable, incrementInductionVariable(this))
} }
@ExperimentalUnsignedTypes
override fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?) = override fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?) =
with(builder) { with(builder) {
val newLoop = if (headerInfo.canOverflow) { val newLoop = if (headerInfo.canOverflow) {
@@ -85,7 +85,6 @@ internal class UntilHandler(private val context: CommonBackendContext, private v
parameter(0) { it.type in progressionElementTypes } parameter(0) { it.type in progressionElementTypes }
} }
@ExperimentalUnsignedTypes
override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? = override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) { with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
with(data) { with(data) {
@@ -583,10 +582,8 @@ internal class DefaultProgressionHandler(private val context: CommonBackendConte
private val symbols = context.ir.symbols private val symbols = context.ir.symbols
@ExperimentalUnsignedTypes
override fun matchIterable(expression: IrExpression) = ProgressionType.fromIrType(expression.type, symbols) != null override fun matchIterable(expression: IrExpression) = ProgressionType.fromIrType(expression.type, symbols) != null
@ExperimentalUnsignedTypes
override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? = override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) { with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// Directly use the `first/last/step` properties of the progression. // Directly use the `first/last/step` properties of the progression.
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@file:OptIn(ExperimentalUnsignedTypes::class)
package org.jetbrains.kotlin.backend.common.lower.loops package org.jetbrains.kotlin.backend.common.lower.loops
import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.CommonBackendContext
@@ -51,7 +53,6 @@ internal sealed class ProgressionType(
} }
companion object { companion object {
@ExperimentalUnsignedTypes
fun fromIrType(irType: IrType, symbols: Symbols<CommonBackendContext>): ProgressionType? = when { fun fromIrType(irType: IrType, symbols: Symbols<CommonBackendContext>): ProgressionType? = when {
irType.isSubtypeOfClass(symbols.charProgression) -> CharProgressionType(symbols) irType.isSubtypeOfClass(symbols.charProgression) -> CharProgressionType(symbols)
irType.isSubtypeOfClass(symbols.intProgression) -> IntProgressionType(symbols) irType.isSubtypeOfClass(symbols.intProgression) -> IntProgressionType(symbols)
@@ -168,7 +169,6 @@ internal abstract class UnsignedProgressionType(
} }
} }
@ExperimentalUnsignedTypes
internal class UIntProgressionType(symbols: Symbols<CommonBackendContext>) : internal class UIntProgressionType(symbols: Symbols<CommonBackendContext>) :
UnsignedProgressionType( UnsignedProgressionType(
symbols, symbols,
@@ -186,7 +186,6 @@ internal class UIntProgressionType(symbols: Symbols<CommonBackendContext>) :
override fun DeclarationIrBuilder.zeroStepExpression() = irInt(0) override fun DeclarationIrBuilder.zeroStepExpression() = irInt(0)
} }
@ExperimentalUnsignedTypes
internal class ULongProgressionType(symbols: Symbols<CommonBackendContext>) : internal class ULongProgressionType(symbols: Symbols<CommonBackendContext>) :
UnsignedProgressionType( UnsignedProgressionType(
symbols, symbols,