Fix some compiler warnings in FIR modules
This commit is contained in:
+7
-7
@@ -20,15 +20,15 @@ import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
|
||||
object ArrayEqualityCanBeReplacedWithEquals : FirBasicExpresionChecker() {
|
||||
override fun check(equality: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (equality !is FirEqualityOperatorCall) return
|
||||
if (equality.operation != FirOperation.EQ && equality.operation != FirOperation.NOT_EQ) return
|
||||
val left = equality.arguments.getOrNull(0) ?: return
|
||||
val right = equality.arguments.getOrNull(1) ?: return
|
||||
override fun check(functionCall: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (functionCall !is FirEqualityOperatorCall) return
|
||||
if (functionCall.operation != FirOperation.EQ && functionCall.operation != FirOperation.NOT_EQ) return
|
||||
val left = functionCall.arguments.getOrNull(0) ?: return
|
||||
val right = functionCall.arguments.getOrNull(1) ?: return
|
||||
|
||||
if (left.typeRef.coneType.classId != StandardClassIds.Array) return
|
||||
if (right.typeRef.coneType.classId != StandardClassIds.Array) return
|
||||
|
||||
reporter.report(equality.psi?.children?.get(1)?.toFirPsiSourceElement(), ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS)
|
||||
reporter.report(functionCall.psi?.children?.get(1)?.toFirPsiSourceElement(), ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -20,14 +20,14 @@ import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
||||
|
||||
object RedundantSingleExpressionStringTemplateChecker : FirBasicExpresionChecker() {
|
||||
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (expression.source?.kind != FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
|
||||
if (expression !is FirFunctionCall) return
|
||||
override fun check(functionCall: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (functionCall.source?.kind != FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
|
||||
if (functionCall !is FirFunctionCall) return
|
||||
if (
|
||||
expression.explicitReceiver?.typeRef?.coneType?.classId == StandardClassIds.String
|
||||
&& expression.psi?.findStringParent()?.children?.size == 1 // there is no more children in original string template
|
||||
functionCall.explicitReceiver?.typeRef?.coneType?.classId == StandardClassIds.String
|
||||
&& functionCall.psi?.findStringParent()?.children?.size == 1 // there is no more children in original string template
|
||||
) {
|
||||
reporter.report(expression.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE)
|
||||
reporter.report(functionCall.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,4 @@ object RedundantSingleExpressionStringTemplateChecker : FirBasicExpresionChecker
|
||||
return if (this.parent != null) this.parent.findStringParent()
|
||||
else null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -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.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNCHECKED_CAST")
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
+1
@@ -152,6 +152,7 @@ class FirJvmSerializerExtension @JvmOverloads constructor(
|
||||
writeLocalProperties(proto, partAsmType, JvmProtoBuf.packageLocalVariable)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private fun <MessageType : GeneratedMessageLite.ExtendableMessage<MessageType>, BuilderType : GeneratedMessageLite.ExtendableBuilder<MessageType, BuilderType>> writeLocalProperties(
|
||||
proto: BuilderType,
|
||||
classAsmType: Type,
|
||||
|
||||
+2
-3
@@ -600,7 +600,7 @@ class CallAndReferenceGenerator(
|
||||
val argumentMapping = call.argumentMapping
|
||||
if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) {
|
||||
if (valueParameters != null) {
|
||||
return applyArgumentsWithReorderingIfNeeded(call, argumentMapping, valueParameters, annotationMode)
|
||||
return applyArgumentsWithReorderingIfNeeded(argumentMapping, valueParameters, annotationMode)
|
||||
}
|
||||
}
|
||||
for ((index, argument) in call.arguments.withIndex()) {
|
||||
@@ -631,7 +631,6 @@ class CallAndReferenceGenerator(
|
||||
}
|
||||
|
||||
private fun IrMemberAccessExpression<*>.applyArgumentsWithReorderingIfNeeded(
|
||||
call: FirCall,
|
||||
argumentMapping: Map<FirExpression, FirValueParameter>,
|
||||
valueParameters: List<FirValueParameter>,
|
||||
annotationMode: Boolean
|
||||
@@ -771,7 +770,7 @@ class CallAndReferenceGenerator(
|
||||
|
||||
private fun FirQualifiedAccess.findBoundReceiver(explicitReceiverExpression: IrExpression?, isDispatch: Boolean): IrExpression? {
|
||||
val firReceiver = if (isDispatch) dispatchReceiver else extensionReceiver
|
||||
if (firReceiver == null || firReceiver is FirNoReceiverExpression) {
|
||||
if (firReceiver is FirNoReceiverExpression) {
|
||||
return null
|
||||
}
|
||||
return findIrReceiver(explicitReceiverExpression, isDispatch)
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ open class FirPackageFragmentDescriptor(override val fqName: FqName, val moduleD
|
||||
return fqName.shortName()
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D): R {
|
||||
return visitor?.visitPackageFragmentDescriptor(this, data) as R
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: D by lazy {
|
||||
when (val owner = owner) {
|
||||
val result = when (val owner = owner) {
|
||||
is IrEnumEntry -> WrappedEnumEntryDescriptor().apply { bind(owner) }
|
||||
is IrClass -> WrappedClassDescriptor().apply { bind(owner) }
|
||||
is IrConstructor -> WrappedClassConstructorDescriptor().apply { bind(owner) }
|
||||
@@ -64,7 +64,10 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
is IrField -> WrappedFieldDescriptor().apply { bind(owner) }
|
||||
is IrTypeAlias -> WrappedTypeAliasDescriptor().apply { bind(owner) }
|
||||
else -> throw IllegalStateException("Unsupported owner in Fir2IrBindableSymbol: $owner")
|
||||
} as D
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
result as D
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -159,14 +159,14 @@ internal class FirJavaClassBuilder : FirRegularClassBuilder(), FirAnnotationCont
|
||||
@Deprecated("Modification of 'hasLazyNestedClassifiers' has no impact for FirRegularClassImplBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var companionObject: FirRegularClass?
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaClassBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -157,35 +157,35 @@ class FirJavaConstructorBuilder : FirConstructorBuilder() {
|
||||
@Deprecated("Modification of 'body' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var body: FirBlock?
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'delegatedConstructor' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var delegatedConstructor: FirDelegatedConstructorCall?
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'resolvePhase' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var resolvePhase: FirResolvePhase
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'receiverTypeRef' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var receiverTypeRef: FirTypeRef?
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaConstructorBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.java.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirImplementationDetail
|
||||
@@ -14,8 +13,6 @@ import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirFieldBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol
|
||||
@@ -166,7 +163,7 @@ internal class FirJavaFieldBuilder : FirFieldBuilder() {
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaFieldBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class FirJavaMethodBuilder : FirSimpleFunctionBuilder() {
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaFunctionBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -70,35 +70,35 @@ class FirJavaValueParameterBuilder : FirValueParameterBuilder() {
|
||||
@Deprecated("Modification of 'resolvePhase' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var resolvePhase: FirResolvePhase
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of '' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var symbol: FirVariableSymbol<FirValueParameter>
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'isCrossinline' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var isCrossinline: Boolean
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'isNoinline' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var isNoinline: Boolean
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'origin' has no impact for FirJavaValueParameterBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var origin: FirDeclarationOrigin
|
||||
get() = throw IllegalStateException()
|
||||
set(value) {
|
||||
set(@Suppress("UNUSED_PARAMETER") value) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -169,7 +169,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
return JvmProtoBufUtil.readClassDataFrom(data, strings)
|
||||
}
|
||||
|
||||
private fun ConeClassLikeLookupTag.toDefaultResolvedTypeRef(classId: ClassId): FirResolvedTypeRef =
|
||||
private fun ConeClassLikeLookupTag.toDefaultResolvedTypeRef(): FirResolvedTypeRef =
|
||||
buildResolvedTypeRef {
|
||||
type = constructClassType(emptyArray(), isNullable = false)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
private fun ClassLiteralValue.toFirClassReferenceExpression(): FirClassReferenceExpression {
|
||||
val literalLookupTag = ConeClassLikeLookupTagImpl(classId)
|
||||
return buildClassReferenceExpression {
|
||||
classTypeRef = literalLookupTag.toDefaultResolvedTypeRef(classId)
|
||||
classTypeRef = literalLookupTag.toDefaultResolvedTypeRef()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
|
||||
override fun visitEnd() {
|
||||
result += buildAnnotationCall {
|
||||
annotationTypeRef = lookupTag.toDefaultResolvedTypeRef(annotationClassId)
|
||||
annotationTypeRef = lookupTag.toDefaultResolvedTypeRef()
|
||||
argumentList = buildArgumentList {
|
||||
for ((name, expression) in argumentMap) {
|
||||
arguments += buildNamedArgumentExpression {
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.typeContext
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
@@ -172,7 +171,7 @@ private fun ConeKotlinType.enhanceInflexibleType(
|
||||
typeArguments
|
||||
} else {
|
||||
var globalArgIndex = index + 1
|
||||
typeArguments.mapIndexed { localArgIndex, arg ->
|
||||
typeArguments.map { arg ->
|
||||
if (arg.kind != ProjectionKind.INVARIANT) {
|
||||
globalArgIndex++
|
||||
arg
|
||||
@@ -277,7 +276,7 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String):
|
||||
buildQualifiedAccessExpression {
|
||||
calleeReference = buildResolvedNamedReference {
|
||||
this.name = name
|
||||
resolvedSymbol = firStaticProperty.symbol as FirCallableSymbol<*>
|
||||
resolvedSymbol = firStaticProperty.symbol
|
||||
}
|
||||
}
|
||||
} else null
|
||||
|
||||
+1
-3
@@ -66,8 +66,6 @@ class LightTree2Fir(
|
||||
val lightTree = buildLightTree(code)
|
||||
|
||||
return DeclarationsConverter(session, scopeProvider, stubMode, lightTree)
|
||||
.convertFile(lightTree.root, fileName).also {
|
||||
it
|
||||
}
|
||||
.convertFile(lightTree.root, fileName)
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.fir.builder
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiErrorElement
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
@@ -28,7 +27,6 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.*
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirReferenceForUnresolvedAnnotations
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
@@ -43,14 +41,13 @@ import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import java.util.*
|
||||
|
||||
class RawFirBuilder(
|
||||
session: FirSession, val baseScopeProvider: FirScopeProvider, val stubMode: Boolean
|
||||
@@ -188,7 +185,7 @@ class RawFirBuilder(
|
||||
delegatedSuperType: FirTypeRef,
|
||||
delegatedSelfType: FirResolvedTypeRef,
|
||||
owner: KtClassOrObject,
|
||||
ownerClassBuilder: FirClassBuilder, hasPrimaryConstructor: Boolean,
|
||||
ownerClassBuilder: FirClassBuilder,
|
||||
ownerTypeParameters: List<FirTypeParameterRef>
|
||||
): FirDeclaration {
|
||||
return when (this) {
|
||||
@@ -197,7 +194,6 @@ class RawFirBuilder(
|
||||
delegatedSuperType,
|
||||
delegatedSelfType,
|
||||
owner,
|
||||
hasPrimaryConstructor,
|
||||
ownerTypeParameters
|
||||
)
|
||||
}
|
||||
@@ -718,7 +714,6 @@ class RawFirBuilder(
|
||||
delegatedSelfType = delegatedEntrySelfType,
|
||||
ktEnumEntry,
|
||||
ownerClassBuilder = this,
|
||||
hasPrimaryConstructor = true,
|
||||
ownerTypeParameters = emptyList()
|
||||
)
|
||||
}
|
||||
@@ -801,7 +796,7 @@ class RawFirBuilder(
|
||||
delegatedSuperType,
|
||||
delegatedSelfType,
|
||||
classOrObject,
|
||||
this, hasPrimaryConstructor = primaryConstructor != null,
|
||||
this,
|
||||
typeParameters
|
||||
),
|
||||
)
|
||||
@@ -872,7 +867,6 @@ class RawFirBuilder(
|
||||
delegatedSelfType,
|
||||
owner = objectDeclaration,
|
||||
ownerClassBuilder = this,
|
||||
hasPrimaryConstructor = false,
|
||||
ownerTypeParameters = emptyList()
|
||||
)
|
||||
}
|
||||
@@ -1070,7 +1064,6 @@ class RawFirBuilder(
|
||||
delegatedSuperTypeRef: FirTypeRef,
|
||||
delegatedSelfTypeRef: FirTypeRef,
|
||||
owner: KtClassOrObject,
|
||||
hasPrimaryConstructor: Boolean,
|
||||
ownerTypeParameters: List<FirTypeParameterRef>
|
||||
): FirConstructor {
|
||||
val target = FirFunctionTarget(labelName = null, isLambda = false)
|
||||
@@ -1091,7 +1084,6 @@ class RawFirBuilder(
|
||||
delegatedConstructor = getDelegationCall().convert(
|
||||
delegatedSuperTypeRef,
|
||||
delegatedSelfTypeRef,
|
||||
hasPrimaryConstructor
|
||||
)
|
||||
this@RawFirBuilder.context.firFunctionTargets += target
|
||||
extractAnnotationsTo(this)
|
||||
@@ -1108,7 +1100,6 @@ class RawFirBuilder(
|
||||
private fun KtConstructorDelegationCall.convert(
|
||||
delegatedSuperTypeRef: FirTypeRef,
|
||||
delegatedSelfTypeRef: FirTypeRef,
|
||||
hasPrimaryConstructor: Boolean,
|
||||
): FirDelegatedConstructorCall {
|
||||
val isThis = isCallToThis //|| (isImplicit && hasPrimaryConstructor)
|
||||
val source = if (isImplicit) {
|
||||
|
||||
@@ -232,12 +232,11 @@ class FirCallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
var resultExpression = qualifiedAccess.transformCalleeReference(StoreNameReference, nameReference) as T
|
||||
var resultExpression = qualifiedAccess.transformCalleeReference(StoreNameReference, nameReference)
|
||||
if (reducedCandidates.size == 1) {
|
||||
val candidate = reducedCandidates.single()
|
||||
resultExpression = resultExpression.transformDispatchReceiver(StoreReceiver, candidate.dispatchReceiverExpression()) as T
|
||||
resultExpression = resultExpression.transformExtensionReceiver(StoreReceiver, candidate.extensionReceiverExpression()) as T
|
||||
resultExpression = resultExpression.transformDispatchReceiver(StoreReceiver, candidate.dispatchReceiverExpression())
|
||||
resultExpression = resultExpression.transformExtensionReceiver(StoreReceiver, candidate.extensionReceiverExpression())
|
||||
}
|
||||
if (resultExpression is FirExpression) transformer.storeTypeFromCallee(resultExpression)
|
||||
return resultExpression
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions
|
||||
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
||||
@@ -26,7 +25,7 @@ fun FirSimpleFunction.lowestVisibilityAmongOverrides(
|
||||
session: FirSession,
|
||||
scopeSession: ScopeSession
|
||||
): Visibility {
|
||||
val firTypeScope = containingClass.unsubstitutedScope(session, scopeSession) as FirTypeScope
|
||||
val firTypeScope = containingClass.unsubstitutedScope(session, scopeSession)
|
||||
var visibility = visibility
|
||||
|
||||
// required; otherwise processOverriddenFunctions()
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver {
|
||||
|
||||
val fqName = ClassId(
|
||||
prefix.packageFqName,
|
||||
parts.drop(1).fold(prefix.relativeClassName) { prefix, suffix -> prefix.child(suffix.name) },
|
||||
parts.drop(1).fold(prefix.relativeClassName) { result, suffix -> result.child(suffix.name) },
|
||||
false
|
||||
)
|
||||
return symbolProvider.getClassLikeSymbolByFqName(fqName)
|
||||
|
||||
@@ -66,7 +66,7 @@ enum class ProcessorAction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun FirScope.processClassifiersByName(
|
||||
name: Name,
|
||||
noinline processor: (FirClassifierSymbol<*>) -> Unit
|
||||
|
||||
+10
-8
@@ -7,36 +7,38 @@ package org.jetbrains.kotlin.fir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
|
||||
sealed class CompositeTransformResult<out T : Any>() {
|
||||
sealed class CompositeTransformResult<out T : Any> {
|
||||
|
||||
class Single<out T : Any>(val _single: T) : CompositeTransformResult<T>()
|
||||
|
||||
class Multiple<out T : Any>(val _list: List<T>) : CompositeTransformResult<T>()
|
||||
|
||||
companion object {
|
||||
fun <T : Any> empty() = CompositeTransformResult.Multiple<T>(emptyList<T>())
|
||||
fun <T : Any> single(t: T) = CompositeTransformResult.Single(t)
|
||||
fun <T : Any> many(l: List<T>) = CompositeTransformResult.Multiple(l)
|
||||
fun <T : Any> empty() = Multiple(emptyList<T>())
|
||||
fun <T : Any> single(t: T) = Single(t)
|
||||
fun <T : Any> many(l: List<T>) = Multiple(l)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val list: List<T>
|
||||
get() = when (this) {
|
||||
is CompositeTransformResult.Multiple<*> -> _list as List<T>
|
||||
is Multiple<*> -> _list as List<T>
|
||||
else -> error("!")
|
||||
}
|
||||
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val single: T
|
||||
get() = when (this) {
|
||||
is CompositeTransformResult.Single<*> -> _single as T
|
||||
is Single<*> -> _single as T
|
||||
else -> error("!")
|
||||
}
|
||||
|
||||
val isSingle
|
||||
get() = this is CompositeTransformResult.Single<*>
|
||||
get() = this is Single<*>
|
||||
|
||||
val isEmpty
|
||||
get() = this is CompositeTransformResult.Multiple<*> && this.list.isEmpty()
|
||||
get() = this is Multiple<*> && this.list.isEmpty()
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
println("(")
|
||||
withIndent {
|
||||
fieldsWithoutDefault.forEachIndexed { i, field ->
|
||||
fieldsWithoutDefault.forEachIndexed { _, field ->
|
||||
printField(field, isImplementation = true, override = true, end = ",")
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -52,9 +52,11 @@ private fun updateKinds(solution: List<Boolean>, elementMapping: ElementMapping)
|
||||
val element = elementMapping[index * 2].origin
|
||||
val existingKind = element.kind
|
||||
if (isClass) {
|
||||
when (existingKind) {
|
||||
Implementation.Kind.Interface -> throw IllegalStateException(element.toString())
|
||||
null -> element.kind = when (element) {
|
||||
if (existingKind == Implementation.Kind.Interface)
|
||||
throw IllegalStateException(element.toString())
|
||||
|
||||
if (existingKind == null) {
|
||||
element.kind = when (element) {
|
||||
is Implementation -> {
|
||||
if (elementMapping.hasInheritors(element))
|
||||
Implementation.Kind.AbstractClass
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
}
|
||||
|
||||
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
|
||||
val firLabel = lambdaExpression.firstOfType<FirLabel>()
|
||||
//val firLabel = lambdaExpression.firstOfType<FirLabel>()
|
||||
|
||||
stack.push("<anonymous>")
|
||||
//firLabel?.let { addAnnotation("${it.name}@$innerLambdaCount", lambdaExpression) }
|
||||
|
||||
Reference in New Issue
Block a user