From b8817d58842d987cf7a49b228d4aeb248f914284 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Wed, 14 Oct 2020 11:33:13 -0700 Subject: [PATCH] FIR2IR: clean up dead code regarding overriding utils --- .../kotlin/fir/backend/ConversionUtils.kt | 41 ------------------- .../fir/backend/Fir2IrDeclarationStorage.kt | 14 ------- 2 files changed, 55 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 0e2a147a82e..93545c16f54 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -268,47 +268,6 @@ internal fun FirProperty.generateOverriddenAccessorSymbols( return overriddenSet.toList() } -fun isOverriding( - irBuiltIns: IrBuiltIns, - target: IrDeclaration, - superCandidate: IrDeclaration -): Boolean { - val typeCheckerContext = IrTypeCheckerContext(irBuiltIns) as AbstractTypeCheckerContext - fun equalTypes(first: IrType, second: IrType): Boolean { - if (first is IrErrorType || second is IrErrorType) return false - return AbstractTypeChecker.equalTypes( - typeCheckerContext, first, second - ) || - // TODO: should pass type parameter cache, and make sure target type is indeed a matched type argument. - second.classifierOrNull is IrTypeParameterSymbol - - } - - return when { - target is IrFunction && superCandidate is IrFunction -> { - // Not checking the return type (they should match each other if everything other match, otherwise it's a compilation error) - target.name == superCandidate.name && - target.extensionReceiverParameter?.type?.let { - val superCandidateReceiverType = superCandidate.extensionReceiverParameter?.type - superCandidateReceiverType != null && equalTypes(it, superCandidateReceiverType) - } != false && - target.valueParameters.size == superCandidate.valueParameters.size && - target.valueParameters.zip(superCandidate.valueParameters).all { (targetParameter, superCandidateParameter) -> - equalTypes(targetParameter.type, superCandidateParameter.type) - } - } - target is IrField && superCandidate is IrField -> { - // Not checking the field type (they should match each other if everything other match, otherwise it's a compilation error) - target.name == superCandidate.name - } - target is IrProperty && superCandidate is IrProperty -> { - // Not checking the property type (they should match each other if names match, otherwise it's a compilation error) - target.name == superCandidate.name - } - else -> false - } -} - private val nameToOperationConventionOrigin = mutableMapOf( OperatorNameConventions.PLUS to IrStatementOrigin.PLUS, OperatorNameConventions.MINUS to IrStatementOrigin.MINUS, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 78ca2aa5801..ad9723267a2 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -776,20 +776,6 @@ class Fir2IrDeclarationStorage( return irField } - internal fun findOverriddenFirFunction(irFunction: IrSimpleFunction, superClassId: ClassId): FirFunction<*>? { - val functions = getFirClassByFqName(superClassId)?.declarations?.filter { - it is FirFunction<*> && functionCache.containsKey(it) && irFunction.overrides(functionCache[it]!!) - } - return if (functions.isNullOrEmpty()) null else functions.first() as FirFunction<*> - } - - internal fun findOverriddenFirProperty(irProperty: IrProperty, superClassId: ClassId): FirProperty? { - val properties = getFirClassByFqName(superClassId)?.declarations?.filter { - it is FirProperty && it.name == irProperty.name - } - return if (properties.isNullOrEmpty()) null else properties.first() as FirProperty - } - private fun getFirClassByFqName(classId: ClassId): FirClass<*>? { val declaration = firSymbolProvider.getClassLikeSymbolByFqName(classId) return declaration?.fir as? FirClass<*>