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