Suppress K2 specific warnings in the codebase
^KT-62472
This commit is contained in:
committed by
Space Team
parent
9e66a7b999
commit
704e2ef5c5
+1
@@ -577,6 +577,7 @@ internal class KtFirCallResolver(
|
||||
@Suppress("UNCHECKED_CAST") // safe because of the above check on targetKtSymbol
|
||||
KtSimpleFunctionCall(
|
||||
partiallyAppliedSymbol as KtPartiallyAppliedFunctionSymbol<KtFunctionLikeSymbol>,
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
argumentMappingWithoutExtensionReceiver
|
||||
?.createArgumentMapping(partiallyAppliedSymbol.signature as KtFunctionLikeSignature<*>)
|
||||
?: LinkedHashMap(),
|
||||
|
||||
+1
-1
@@ -212,4 +212,4 @@ public inline fun prettyPrintWithSettingsFrom(other: PrettyPrinter, body: Pretty
|
||||
callsInPlace(body, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return PrettyPrinter(other.indentSize).apply(body).toString()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -71,6 +71,7 @@ class KtLightMethodForDecompiledDeclaration(
|
||||
override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean): List<MethodSignatureBackedByPsiMethod> =
|
||||
PsiSuperMethodImplUtil.findSuperMethodSignaturesIncludingStatic(this, checkAccess)
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION") // K2 warning suppression, TODO: KT-62472
|
||||
override fun findDeepestSuperMethod() = PsiSuperMethodImplUtil.findDeepestSuperMethod(this)
|
||||
|
||||
override fun findDeepestSuperMethods(): Array<out PsiMethod> = PsiSuperMethodImplUtil.findDeepestSuperMethods(this)
|
||||
@@ -117,4 +118,4 @@ class KtLightMethodForDecompiledDeclaration(
|
||||
visitor.visitElement(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -157,6 +157,7 @@ abstract class KtLightMethodImpl protected constructor(
|
||||
|
||||
override fun getBody() = null
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION") // K2 warning suppression, TODO: KT-62472
|
||||
abstract override fun findDeepestSuperMethod(): PsiMethod?
|
||||
|
||||
abstract override fun findDeepestSuperMethods(): Array<out PsiMethod>
|
||||
|
||||
+1
@@ -120,6 +120,7 @@ internal class FirTowerDataContextAllElementsCollector : FirResolveContextCollec
|
||||
*
|
||||
* Otherwise, invokes this function recursively on the parent.
|
||||
*/
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
private tailrec fun PsiElement.closestParentExpressionWithSameContextOrSelf(): KtExpression? {
|
||||
if (this is KtExpression) {
|
||||
if (
|
||||
|
||||
+1
@@ -88,6 +88,7 @@ internal class SymbolLightClassForFacade(
|
||||
for (fileSymbol in fileSymbols) {
|
||||
for (callableSymbol in fileSymbol.getFileScope().getCallableSymbols()) {
|
||||
if (callableSymbol !is KtFunctionSymbol && callableSymbol !is KtKotlinPropertySymbol) continue
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
if (callableSymbol !is KtSymbolWithVisibility) continue
|
||||
if ((callableSymbol as? KtAnnotatedSymbol)?.hasInlineOnlyAnnotation() == true) continue
|
||||
if (multiFileClass && callableSymbol.toPsiVisibilityForMember() == PsiModifier.PRIVATE) continue
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ internal abstract class SymbolLightMethodBase(
|
||||
override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean): List<MethodSignatureBackedByPsiMethod> =
|
||||
PsiSuperMethodImplUtil.findSuperMethodSignaturesIncludingStatic(this, checkAccess)
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION") // K2 warning suppression, TODO: KT-62472
|
||||
override fun findDeepestSuperMethod() = PsiSuperMethodImplUtil.findDeepestSuperMethod(this)
|
||||
|
||||
override fun findDeepestSuperMethods(): Array<out PsiMethod> = PsiSuperMethodImplUtil.findDeepestSuperMethods(this)
|
||||
|
||||
@@ -12,6 +12,7 @@ open class BuildReporter<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
protected open val buildMetricsReporter: BuildMetricsReporter<B, P>,
|
||||
) : ICReporter by icReporter, BuildMetricsReporter<B, P> by buildMetricsReporter
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class RemoteBuildReporter<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
override val icReporter: RemoteICReporter,
|
||||
override val buildMetricsReporter: RemoteBuildMetricsReporter<B, P>,
|
||||
@@ -22,5 +23,6 @@ class RemoteBuildReporter<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
object DoNothingBuildReporter :
|
||||
BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>(DoNothingICReporter, DoNothingBuildMetricsReporter)
|
||||
|
||||
@@ -421,6 +421,7 @@ class MethodInliner(
|
||||
|
||||
private fun getNewIndex(`var`: Int): Int {
|
||||
val lambdaInfo = inliningContext.lambdaInfo
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
if (reorderIrLambdaParameters && lambdaInfo is IrExpressionLambda) {
|
||||
val extensionSize = if (lambdaInfo.isExtensionLambda) lambdaInfo.invokeMethod.argumentTypes[0].size else 0
|
||||
return when {
|
||||
|
||||
@@ -48,6 +48,7 @@ fun classFileContainsMethod(descriptor: FunctionDescriptor, state: GenerationSta
|
||||
(descriptor.containingDeclaration as DeserializedClassDescriptor).classId ?: return null
|
||||
}
|
||||
descriptor.containerSource is JvmPackagePartSource -> {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
(descriptor.containerSource as JvmPackagePartSource).classId
|
||||
}
|
||||
else -> {
|
||||
|
||||
@@ -610,6 +610,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
|
||||
val isAccessor = property is AccessorForPropertyDescriptor
|
||||
val propertyName = if (isAccessor)
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
(property as AccessorForPropertyDescriptor).accessorSuffix
|
||||
else
|
||||
property.name.asString()
|
||||
|
||||
+1
@@ -207,6 +207,7 @@ object FirCallsEffectAnalyzer : FirControlFlowChecker() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class LambdaInvocationInfo(
|
||||
map: PersistentMap<FirBasedSymbol<*>, EventOccurrencesRange> = persistentMapOf(),
|
||||
) : EventOccurrencesRangeInfo<LambdaInvocationInfo, FirBasedSymbol<*>>(map) {
|
||||
|
||||
+1
@@ -95,6 +95,7 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
|
||||
val typeContext = context.session.typeContext
|
||||
|
||||
val isReturn = node is JumpNode && node.fir is FirReturnExpression
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
val resultExpression = if (isReturn) (node.fir as FirReturnExpression).result else node.fir
|
||||
|
||||
val expressionType = (resultExpression as? FirExpression)?.resolvedType
|
||||
|
||||
+2
@@ -10,6 +10,7 @@ import kotlinx.collections.immutable.persistentMapOf
|
||||
import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
abstract class EventOccurrencesRangeInfo<E : EventOccurrencesRangeInfo<E, K>, K : Any>(
|
||||
map: PersistentMap<K, EventOccurrencesRange> = persistentMapOf()
|
||||
) : ControlFlowInfo<E, K, EventOccurrencesRange>(map) {
|
||||
@@ -38,6 +39,7 @@ abstract class EventOccurrencesRangeInfo<E : EventOccurrencesRangeInfo<E, K>, K
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class PropertyInitializationInfo(
|
||||
map: PersistentMap<FirPropertySymbol, EventOccurrencesRange> = persistentMapOf()
|
||||
) : EventOccurrencesRangeInfo<PropertyInitializationInfo, FirPropertySymbol>(map) {
|
||||
|
||||
@@ -204,6 +204,7 @@ fun CheckerContext.findClosestClassOrObject(): FirClass? {
|
||||
it is FirRegularClass ||
|
||||
it is FirAnonymousObject
|
||||
) {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
return it as FirClass
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
object FirAmbiguousAnonymousTypeChecker : FirBasicDeclarationChecker() {
|
||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (declaration !is FirFunction && declaration !is FirProperty) return
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
require(declaration is FirCallableDeclaration)
|
||||
// if source is not null then this type was declared in source
|
||||
// so it can not be inferred to anonymous type
|
||||
|
||||
+1
@@ -122,6 +122,7 @@ object UnusedChecker : AbstractFirPropertyInitializationChecker() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class VariableStatusInfo(
|
||||
map: PersistentMap<FirPropertySymbol, VariableStatus> = persistentMapOf()
|
||||
) : ControlFlowInfo<VariableStatusInfo, FirPropertySymbol, VariableStatus>(map) {
|
||||
|
||||
+1
@@ -535,6 +535,7 @@ class FirElementSerializer private constructor(
|
||||
}
|
||||
|
||||
for (typeParameter in function.typeParameters) {
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
if (typeParameter !is FirTypeParameter) continue
|
||||
builder.addTypeParameter(local.typeParameterProto(typeParameter))
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@ fun FirReference.extractSymbolForCall(): FirBasedSymbol<*>? {
|
||||
if (symbol.origin == FirDeclarationOrigin.SubstitutionOverride.CallSite) {
|
||||
symbol = symbol.fir.unwrapUseSiteSubstitutionOverrides<FirCallableDeclaration>().symbol
|
||||
}
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
symbol = (symbol as FirCallableSymbol<*>).unwrapCallRepresentative()
|
||||
}
|
||||
return symbol
|
||||
|
||||
+1
@@ -136,6 +136,7 @@ class Fir2IrCallableDeclarationsGenerator(val components: Fir2IrComponents) : Fi
|
||||
?: if (isLambda) SpecialNames.ANONYMOUS else SpecialNames.NO_NAME_PROVIDED
|
||||
val visibility = simpleFunction?.visibility ?: Visibilities.Local
|
||||
val isSuspend =
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
if (isLambda) ((function as FirAnonymousFunction).typeRef as? FirResolvedTypeRef)?.type?.isSuspendOrKSuspendFunctionType(session) == true
|
||||
else function.isSuspend
|
||||
val created = function.convertWithOffsets { startOffset, endOffset ->
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.ir.util.isFacadeClass
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class Fir2IrLazyPropertyAccessor(
|
||||
components: Fir2IrComponents,
|
||||
startOffset: Int,
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class Fir2IrLazySimpleFunction(
|
||||
components: Fir2IrComponents,
|
||||
startOffset: Int,
|
||||
|
||||
@@ -46,6 +46,7 @@ fun FirClassSymbol<*>.collectEnumEntries(): Collection<FirEnumEntrySymbol> {
|
||||
* sequence of FirTypeAlias'es points to starting
|
||||
* with `this`. Or null if something goes wrong or we have anonymous object symbol.
|
||||
*/
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
tailrec fun FirClassLikeSymbol<*>.fullyExpandedClass(useSiteSession: FirSession): FirRegularClassSymbol? {
|
||||
return when (this) {
|
||||
is FirRegularClassSymbol -> this
|
||||
|
||||
+1
@@ -852,6 +852,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
}
|
||||
require(operation == FirOperation.ASSIGN)
|
||||
|
||||
@Suppress("SENSELESS_COMPARISON") // K2 warning suppression, TODO: KT-62472
|
||||
if (this?.elementType == SAFE_ACCESS_EXPRESSION && this != null) {
|
||||
val safeCallNonAssignment = convert() as? FirSafeCallExpression
|
||||
if (safeCallNonAssignment != null) {
|
||||
|
||||
+1
@@ -189,6 +189,7 @@ private fun processConstructors(
|
||||
}
|
||||
}
|
||||
is FirClassSymbol -> {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
val firClass = matchedSymbol.fir as FirClass
|
||||
when (firClass.classKind) {
|
||||
ClassKind.INTERFACE -> null
|
||||
|
||||
+3
-1
@@ -21,6 +21,7 @@ interface VariableInitReadOnlyControlFlowInfo :
|
||||
fun checkDefiniteInitializationInWhen(merge: VariableInitReadOnlyControlFlowInfo): Boolean
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class VariableInitControlFlowInfo(map: ImmutableMap<VariableDescriptor, VariableControlFlowState> = ImmutableHashMap.empty()) :
|
||||
VariableUsageControlFlowInfo<VariableInitControlFlowInfo, VariableControlFlowState>(map),
|
||||
VariableInitReadOnlyControlFlowInfo {
|
||||
@@ -42,6 +43,7 @@ class VariableInitControlFlowInfo(map: ImmutableMap<VariableDescriptor, Variable
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class UsageVariableControlFlowInfo(map: ImmutableMap<VariableDescriptor, VariableUseState> = ImmutableHashMap.empty()) :
|
||||
VariableUsageControlFlowInfo<UsageVariableControlFlowInfo, VariableUseState>(map),
|
||||
VariableUsageReadOnlyControlInfo {
|
||||
@@ -128,4 +130,4 @@ enum class VariableUseState(private val priority: Int) {
|
||||
@JvmStatic
|
||||
fun isUsed(variableUseState: VariableUseState?): Boolean = variableUseState != null && variableUseState != UNUSED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -825,6 +825,7 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
KtPsiUtil.deparenthesize(it) ?: it
|
||||
}
|
||||
if (expression != null) {
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
if (expression.isNull() && expression is KtConstantExpression) {
|
||||
val factory = when (diagnostic) {
|
||||
is ArgumentNullabilityErrorDiagnostic -> NULL_FOR_NONNULL_TYPE
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ class KotlinToResolvedCallTransformer(
|
||||
}
|
||||
|
||||
is CompletedCallResolutionResult, is ErrorCallResolutionResult -> {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
val candidate = (baseResolvedCall as SingleCallResolutionResult).resultCallAtom
|
||||
|
||||
val resultSubstitutor =
|
||||
|
||||
+4
@@ -29,7 +29,9 @@ object ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker :
|
||||
val (actual, expect) = matchActualWithNonFinalExpect(declaration, descriptor, context) ?: return
|
||||
|
||||
// The explicit casts won't be necessary when we start compiling kotlin with K2. K1 doesn't build CFG properly
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
declaration as KtClassLikeDeclaration
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
descriptor as ClassifierDescriptorWithTypeParameters
|
||||
|
||||
checkSupertypes(expect, actual, context, declaration, descriptor)
|
||||
@@ -105,7 +107,9 @@ internal fun matchActualWithNonFinalExpect(
|
||||
// Common supertype of KtTypeAlias and KtClassOrObject is KtClassLikeDeclaration.
|
||||
// Common supertype of TypeAliasDescriptor and ClassDescriptor is ClassifierDescriptorWithTypeParameters.
|
||||
// The explicit casts won't be necessary when we start compiling kotlin with K2.
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
declaration as KtClassLikeDeclaration
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
descriptor as ClassifierDescriptorWithTypeParameters
|
||||
|
||||
if (!descriptor.isActual) return null
|
||||
|
||||
+2
@@ -27,7 +27,9 @@ object ExpectActualClassifiersAreInBetaChecker : DeclarationChecker {
|
||||
// Common supertype of KtTypeAlias and KtClassOrObject is KtClassLikeDeclaration.
|
||||
// Common supertype of TypeAliasDescriptor and ClassDescriptor is ClassifierDescriptorWithTypeParameters.
|
||||
// The explicit casts won't be necessary when we start compiling kotlin with K2.
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
check(declaration is KtClassLikeDeclaration)
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
check(descriptor is ClassifierDescriptorWithTypeParameters)
|
||||
|
||||
if (descriptor.isExpect || descriptor.isActual) {
|
||||
|
||||
+1
@@ -73,6 +73,7 @@ abstract class InventNamesForLocalClasses(
|
||||
val isLocal = parent is IrFile && declaration.isAnonymousObject
|
||||
if (!isLocal) return processClass(declaration, data)
|
||||
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
val enclosingName = (parent as IrFile).name.removeSuffix(".kt").plus("Kt").capitalizeAsciiOnly()
|
||||
processClass(declaration, data.copy(enclosingName = enclosingName, isLocal = true))
|
||||
}
|
||||
|
||||
+1
@@ -105,6 +105,7 @@ abstract class UsefulDeclarationProcessor(
|
||||
addReachabilityInfoIfNeeded(from, this, description, isContagiousOverridableDeclaration)
|
||||
|
||||
if (isContagiousOverridableDeclaration) {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
contagiousReachableDeclarations.add(this as IrOverridableDeclaration<*>)
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ open class KotlinSourceFileMap<out T>(files: Map<KotlinLibraryFile, Map<KotlinSo
|
||||
operator fun get(libFile: KotlinLibraryFile, sourceFile: KotlinSourceFile): T? = get(libFile)?.get(sourceFile)
|
||||
}
|
||||
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
|
||||
class KotlinSourceFileMutableMap<T>(
|
||||
private val files: MutableMap<KotlinLibraryFile, MutableMap<KotlinSourceFile, T>> = hashMapOf()
|
||||
) : KotlinSourceFileMap<T>(files) {
|
||||
|
||||
+1
@@ -262,6 +262,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower
|
||||
var cursor = irFunction.parentAsClass.parent
|
||||
while (cursor is IrClass) {
|
||||
if (cursor == param.parent) return true
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
cursor = (cursor as IrClass).parent
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -350,6 +350,7 @@ val IrDeclaration.parentAsClass: IrClass
|
||||
fun IrElement.getPackageFragment(): IrPackageFragment? =
|
||||
this as? IrPackageFragment ?: (this as? IrDeclaration)?.getPackageFragment()
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
tailrec fun IrDeclaration.getPackageFragment(): IrPackageFragment {
|
||||
val parent = this.parent
|
||||
return parent as? IrPackageFragment
|
||||
@@ -1547,4 +1548,4 @@ private fun Any?.toIrConstOrNull(irType: IrType, startOffset: Int = SYNTHETIC_OF
|
||||
|
||||
fun Any?.toIrConst(irType: IrType, startOffset: Int = SYNTHETIC_OFFSET, endOffset: Int = SYNTHETIC_OFFSET): IrConst<*> =
|
||||
toIrConstOrNull(irType, startOffset, endOffset)
|
||||
?: throw UnsupportedOperationException("Unsupported const element type ${irType.makeNotNull().render()}")
|
||||
?: throw UnsupportedOperationException("Unsupported const element type ${irType.makeNotNull().render()}")
|
||||
|
||||
@@ -34,6 +34,7 @@ abstract class KtExpressionImpl(node: ASTNode) : KtElementImpl(node), KtExpressi
|
||||
if (newElement is KtExpression) {
|
||||
when (parent) {
|
||||
is KtExpression, is KtValueArgument -> {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
if (KtPsiUtil.areParenthesesNecessary(newElement, expression, parent as KtElement)) {
|
||||
val factory = KtPsiFactory(expression.project)
|
||||
return rawReplaceHandler(factory.createExpressionByPattern("($0)", newElement, reformat = reformat))
|
||||
|
||||
@@ -22,8 +22,10 @@ import org.jetbrains.kotlin.name.Name
|
||||
|
||||
open class KtExpressionWithLabel(node: ASTNode) : KtExpressionImpl(node) {
|
||||
|
||||
fun getTargetLabel(): KtSimpleNameExpression? =
|
||||
labelQualifier?.findChildByType(KtNodeTypes.LABEL) as? KtSimpleNameExpression
|
||||
fun getTargetLabel(): KtSimpleNameExpression? {
|
||||
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
|
||||
return labelQualifier?.findChildByType(KtNodeTypes.LABEL) as? KtSimpleNameExpression
|
||||
}
|
||||
|
||||
val labelQualifier: KtContainerNode?
|
||||
get() = findChildByType(KtNodeTypes.LABEL_QUALIFIER)
|
||||
|
||||
@@ -707,6 +707,7 @@ fun getTrailingCommaByElementsList(elementList: PsiElement?): PsiElement? {
|
||||
val KtNameReferenceExpression.isUnderscoreInBackticks
|
||||
get() = getReferencedName() == "`_`"
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
tailrec fun KtTypeElement.unwrapNullability(): KtTypeElement? {
|
||||
return when (this) {
|
||||
is KtNullableType -> this.innerType?.unwrapNullability()
|
||||
|
||||
@@ -201,6 +201,7 @@ inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranches(
|
||||
return getParentOfType<T>(strict)?.getIfChildIsInBranches(this, branches)
|
||||
}
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
tailrec fun PsiElement.getOutermostParentContainedIn(container: PsiElement): PsiElement? {
|
||||
val parent = parent
|
||||
return if (parent == container) this else parent?.getOutermostParentContainedIn(container)
|
||||
|
||||
@@ -85,6 +85,7 @@ fun DeclarationDescriptor.containingPackage(): FqName? {
|
||||
if (container == null || container is PackageFragmentDescriptor) break
|
||||
container = container.containingDeclaration
|
||||
}
|
||||
@Suppress("USELESS_IS_CHECK") // K2 warning suppression, TODO: KT-62472
|
||||
require(container is PackageFragmentDescriptor?)
|
||||
return container?.fqName
|
||||
}
|
||||
@@ -110,4 +111,4 @@ fun FunctionDescriptor.overridesEqualsFromAny(): Boolean = name == OperatorNameC
|
||||
tailrec fun DeclarationDescriptor.findPackage(): PackageFragmentDescriptor {
|
||||
return if (this is PackageFragmentDescriptor) this
|
||||
else this.containingDeclaration!!.findPackage()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ object DescriptorEquivalenceForOverrides {
|
||||
return a.index == b.index // We ignore type parameter names
|
||||
}
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
private tailrec fun CallableDescriptor.singleSource(): SourceElement? {
|
||||
if (this !is CallableMemberDescriptor || kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return source
|
||||
|
||||
|
||||
+2
-1
@@ -346,5 +346,6 @@ internal fun getTopLevelPropertyDeclarationName(scope: KotlinScope, property: Pr
|
||||
}
|
||||
|
||||
// Try to use the provided name. If failed, mangle it with underscore and try again:
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
private tailrec fun getTopLevelPropertyDeclarationName(scope: KotlinScope, receiver: String?, name: String): String =
|
||||
scope.declareProperty(receiver, name) ?: getTopLevelPropertyDeclarationName(scope, receiver, name + "_")
|
||||
scope.declareProperty(receiver, name) ?: getTopLevelPropertyDeclarationName(scope, receiver, name + "_")
|
||||
|
||||
+1
@@ -232,6 +232,7 @@ internal fun ObjCExportMapper.getBaseProperties(descriptor: PropertyDescriptor):
|
||||
.distinct()
|
||||
}
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
internal tailrec fun KotlinType.getErasedTypeClass(): ClassDescriptor =
|
||||
TypeUtils.getClassDescriptor(this) ?: this.constructor.supertypes.first().getErasedTypeClass()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user