[FIR] Remove duplicated code discovered by running inspection
This commit is contained in:
committed by
Space Team
parent
1a28067b76
commit
4d24a8b40c
+1
-18
@@ -28,9 +28,8 @@ import org.jetbrains.kotlin.fir.originalOrSelf
|
|||||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
||||||
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenFunctions
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenProperties
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.retrieveDirectOverriddenOf
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
@@ -56,22 +55,6 @@ object FirOverrideChecker : FirClassChecker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirTypeScope.retrieveDirectOverriddenOf(memberSymbol: FirCallableSymbol<*>): List<FirCallableSymbol<*>> {
|
|
||||||
return when (memberSymbol) {
|
|
||||||
is FirNamedFunctionSymbol -> {
|
|
||||||
processFunctionsByName(memberSymbol.name) {}
|
|
||||||
getDirectOverriddenFunctions(memberSymbol)
|
|
||||||
}
|
|
||||||
|
|
||||||
is FirPropertySymbol -> {
|
|
||||||
processPropertiesByName(memberSymbol.name) {}
|
|
||||||
getDirectOverriddenProperties(memberSymbol)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("unexpected member kind $memberSymbol")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ConeKotlinType.substituteAllTypeParameters(
|
private fun ConeKotlinType.substituteAllTypeParameters(
|
||||||
overrideDeclaration: FirCallableSymbol<*>,
|
overrideDeclaration: FirCallableSymbol<*>,
|
||||||
baseDeclaration: FirCallableSymbol<*>,
|
baseDeclaration: FirCallableSymbol<*>,
|
||||||
|
|||||||
+9
-15
@@ -890,21 +890,7 @@ class LightTreeRawFirExpressionBuilder(
|
|||||||
baseSource = whenCondition.toFirSourceElement(),
|
baseSource = whenCondition.toFirSourceElement(),
|
||||||
operationReferenceSource = conditionSource
|
operationReferenceSource = conditionSource
|
||||||
)
|
)
|
||||||
return if (hasSubject) {
|
return createWhenConditionConvertedResults(hasSubject, result, whenCondition)
|
||||||
WhenConditionConvertedResults(result, false)
|
|
||||||
} else {
|
|
||||||
WhenConditionConvertedResults(
|
|
||||||
buildErrorExpression {
|
|
||||||
source = whenCondition.toFirSourceElement()
|
|
||||||
diagnostic = ConeSimpleDiagnostic(
|
|
||||||
"No expression in condition with expression",
|
|
||||||
DiagnosticKind.ExpressionExpected
|
|
||||||
)
|
|
||||||
nonExpressionElement = result
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun convertWhenConditionIsPattern(
|
private fun convertWhenConditionIsPattern(
|
||||||
@@ -934,6 +920,14 @@ class LightTreeRawFirExpressionBuilder(
|
|||||||
argumentList = buildUnaryArgumentList(subjectExpression)
|
argumentList = buildUnaryArgumentList(subjectExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return createWhenConditionConvertedResults(hasSubject, result, whenCondition)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createWhenConditionConvertedResults(
|
||||||
|
hasSubject: Boolean,
|
||||||
|
result: FirExpression,
|
||||||
|
whenCondition: LighterASTNode,
|
||||||
|
): WhenConditionConvertedResults {
|
||||||
return if (hasSubject) {
|
return if (hasSubject) {
|
||||||
WhenConditionConvertedResults(result, false)
|
WhenConditionConvertedResults(result, false)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user