FIR: don't call toString() inside string concatenations
This commit is contained in:
+1
-1
@@ -8,5 +8,5 @@ FILE: stringTemplates.kt
|
||||
public final fun foo(s: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(a: R|A|): R|kotlin/Unit| {
|
||||
R|/foo|(<strcat>(R|<local>/a|.R|kotlin/Any.toString|()))
|
||||
R|/foo|(<strcat>(R|<local>/a|))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ FILE: const.kt
|
||||
public get(): R|kotlin/String|
|
||||
public final const val f: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(2)).R|kotlin/Int.times|(Int(3)).R|kotlin/Int.div|(Int(4)).R|kotlin/Int.rem|(Int(5)).R|kotlin/Int.minus|(Int(1))
|
||||
public get(): R|kotlin/Int|
|
||||
public final const val g: R|kotlin/String| = <strcat>(String(string ), R|/f|.R|kotlin/Any.toString|())
|
||||
public final const val g: R|kotlin/String| = <strcat>(String(string ), R|/f|)
|
||||
public get(): R|kotlin/String|
|
||||
public final const val h: R|kotlin/String| = String(string).R|kotlin/String.plus|(R|/g|)
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
Vendored
+1
-1
@@ -50,5 +50,5 @@ FILE: annotationArgumentMustBeConst.kt
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
@R|Ann1|(vararg(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/bar|), <strcat>(R|/foo|.R|kotlin/Any.toString|(), String( ), R|/bar|.R|kotlin/Any.toString|()), <strcat>(R|/baz|().R|kotlin/Any.toString|(), String( )))) @R|Ann2|(<implicitArrayOf>(R|/bar|, R|/baz|(), R|/bar|.R|kotlin/Int.plus|(R|/cnst|))) @R|Ann3|(R|/arr|) public final fun test(): R|kotlin/Unit| {
|
||||
@R|Ann1|(vararg(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/bar|), <strcat>(R|/foo|, String( ), R|/bar|), <strcat>(R|/baz|(), String( )))) @R|Ann2|(<implicitArrayOf>(R|/bar|, R|/baz|(), R|/bar|.R|kotlin/Int.plus|(R|/cnst|))) @R|Ann3|(R|/arr|) public final fun test(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ FILE: lambda.kt
|
||||
}
|
||||
)
|
||||
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| <inline=NoInline> {
|
||||
^ <strcat>(String(this is ), R|<local>/it|.R|kotlin/Any.toString|(), String( test))
|
||||
^ <strcat>(String(this is ), R|<local>/it|, String( test))
|
||||
}
|
||||
)
|
||||
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| <inline=NoInline> {
|
||||
^ <strcat>(String(This is test of ), R|<local>/a|.R|kotlin/Any.toString|(), String(, ), R|<local>/b|.R|kotlin/Any.toString|())
|
||||
^ <strcat>(String(This is test of ), R|<local>/a|, String(, ), R|<local>/b|)
|
||||
}
|
||||
)
|
||||
lval s: R|kotlin/String| = fun <anonymous>(): R|kotlin/String| <inline=Unknown> {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
FILE: StringTemplate.kt
|
||||
public abstract interface IC : R|kotlin/Any| {
|
||||
public open fun toString(x: R|kotlin/String|): R|kotlin/String| {
|
||||
^toString <strcat>(String(IC), R|<local>/x|.R|kotlin/Any.toString|())
|
||||
^toString <strcat>(String(IC), R|<local>/x|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -57,7 +57,7 @@ FILE: RedundantExplicitTypeChecker.kt
|
||||
|
||||
}
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval s: R|kotlin/String| = <strcat>(String(Hello ), Int(10).R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|())
|
||||
lval s: R|kotlin/String| = <strcat>(String(Hello ), Int(10).R|kotlin/Int.plus|(Int(1)))
|
||||
lval str: R|kotlin/String?| = String()
|
||||
lval o: R|Obj| = Q|Obj|
|
||||
lval p: R|Point| = R|/PointImpl.PointImpl|(Int(1), Int(2))
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ FILE: RedundantSetterParameterTypeChecker.kt
|
||||
public final var x: R|kotlin/String| = String()
|
||||
public get(): R|kotlin/String|
|
||||
public set(param: R|kotlin/String|): R|kotlin/Unit| {
|
||||
F|/x| = <strcat>(R|<local>/param|.R|kotlin/Any.toString|(), String( ))
|
||||
F|/x| = <strcat>(R|<local>/param|, String( ))
|
||||
}
|
||||
public final class My : R|kotlin/Any| {
|
||||
public constructor(): R|My| {
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
FILE: RedundantSingleExpressionStringTemplateChecker.kt
|
||||
public final val x: R|kotlin/String| = String(Hello)
|
||||
public get(): R|kotlin/String|
|
||||
public final val y: R|kotlin/String| = <strcat>(R|/x|.R|kotlin/Any.toString|())
|
||||
public final val y: R|kotlin/String| = <strcat>(R|/x|)
|
||||
public get(): R|kotlin/String|
|
||||
public final val z: R|kotlin/String| = <strcat>(R|/y|.R|kotlin/Any.hashCode|().R|kotlin/Any.toString|())
|
||||
public final val z: R|kotlin/String| = <strcat>(R|/y|.R|kotlin/Any.hashCode|())
|
||||
public get(): R|kotlin/String|
|
||||
public final fun toString(x: R|kotlin/String|): R|kotlin/String| {
|
||||
^toString <strcat>(String(IC), R|<local>/x|.R|kotlin/Any.toString|())
|
||||
^toString <strcat>(String(IC), R|<local>/x|)
|
||||
}
|
||||
public final data class ProductGroup : R|kotlin/Any| {
|
||||
public constructor(short_name: R|kotlin/String|, parent: R|ProductGroup?|): R|ProductGroup| {
|
||||
@@ -24,7 +24,7 @@ FILE: RedundantSingleExpressionStringTemplateChecker.kt
|
||||
this@R|/ProductGroup|.R|/ProductGroup.short_name|
|
||||
}
|
||||
else -> {
|
||||
<strcat>(this@R|/ProductGroup|.R|/ProductGroup.parent|.R|/ProductGroup.name|.R|kotlin/Any.toString|(), String( ), this@R|/ProductGroup|.R|/ProductGroup.short_name|.R|kotlin/Any.toString|())
|
||||
<strcat>(this@R|/ProductGroup|.R|/ProductGroup.parent|.R|/ProductGroup.name|, String( ), this@R|/ProductGroup|.R|/ProductGroup.short_name|)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ FILE: NotNullTypeChain.kt
|
||||
public final val list1: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1))
|
||||
public get(): R|kotlin/collections/List<kotlin/Int>|
|
||||
public final val list: R|kotlin/collections/List<kotlin/String>| = R|/list1|.R|kotlin/collections/orEmpty|<R|kotlin/Int|>().R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/String|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/String| <inline=Inline, kind=UNKNOWN> {
|
||||
^ <strcat>(R|<local>/it|.R|kotlin/Any.toString|())
|
||||
^ <strcat>(R|<local>/it|)
|
||||
}
|
||||
)
|
||||
public get(): R|kotlin/collections/List<kotlin/String>|
|
||||
|
||||
@@ -7,7 +7,7 @@ FILE: test.kt
|
||||
lval otherResult: R|ft<kotlin/String, kotlin/String?>| = R|<local>/map|.R|SubstitutionOverride</MyMap.getOrDefault: R|ft<kotlin/String, kotlin/String?>|>|(String(key), String(value))
|
||||
lval anotherResult: R|kotlin/String?| = R|<local>/map|.R|SubstitutionOverride</MyMap.replace: R|kotlin/String?|>|(String(key), String(value))
|
||||
R|<local>/map|.R|SubstitutionOverride</MyMap.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|ft<kotlin/String, kotlin/String?>|, value: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Unit| <inline=NoInline> {
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
|
||||
R|<local>/key|.R|kotlin/String.length|
|
||||
R|<local>/value|.R|kotlin/String.length|
|
||||
}
|
||||
@@ -15,7 +15,7 @@ FILE: test.kt
|
||||
R|<local>/map|.R|kotlin/collections/forEach|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<ft<kotlin/String, kotlin/String?>, ft<kotlin/String, kotlin/String?>>|): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
||||
lval key: R|ft<kotlin/String, kotlin/String?>| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>()
|
||||
lval value: R|ft<kotlin/String, kotlin/String?>| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>()
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
|
||||
R|<local>/key|.R|kotlin/String.length|
|
||||
R|<local>/value|.R|kotlin/String.length|
|
||||
}
|
||||
@@ -29,7 +29,7 @@ FILE: test.kt
|
||||
lval otherResult: R|kotlin/String| = R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.getOrDefault: R|kotlin/String|>|(String(key), String(value))
|
||||
lval anotherResult: R|kotlin/String?| = R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.replace: R|kotlin/String?|>|(String(key), String(value))
|
||||
R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|ft<kotlin/String, kotlin/String?>|, value: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Unit| <inline=NoInline> {
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
|
||||
R|<local>/key|.R|kotlin/String.length|
|
||||
R|<local>/value|.R|kotlin/String.length|
|
||||
}
|
||||
@@ -37,7 +37,7 @@ FILE: test.kt
|
||||
R|<local>/map|.R|kotlin/collections/forEach|<R|kotlin/String|, R|kotlin/String|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<kotlin/String, kotlin/String>|): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
||||
lval key: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|kotlin/String|, R|kotlin/String|>()
|
||||
lval value: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|kotlin/String|, R|kotlin/String|>()
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
|
||||
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
|
||||
R|<local>/key|.R|kotlin/String.length|
|
||||
R|<local>/value|.R|kotlin/String.length|
|
||||
}
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ fun main(args: Array<String>) {
|
||||
alias<FirSafeCallExpression>("SafeCallExpressionChecker")
|
||||
alias<FirEqualityOperatorCall>("EqualityOperatorCallChecker")
|
||||
alias<FirAnonymousFunction>("AnonymousFunctionAsExpressionChecker")
|
||||
alias<FirStringConcatenationCall>("StringConcatenationCallChecker")
|
||||
}
|
||||
|
||||
val declarationPackage = "org.jetbrains.kotlin.fir.analysis.checkers.declaration"
|
||||
|
||||
+4
@@ -43,6 +43,8 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
|
||||
get() = _equalityOperatorCallCheckers
|
||||
override val anonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker>
|
||||
get() = _anonymousFunctionAsExpressionCheckers
|
||||
override val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker>
|
||||
get() = _stringConcatenationCallCheckers
|
||||
|
||||
private val _basicExpressionCheckers: MutableSet<FirBasicExpressionChecker> = mutableSetOf()
|
||||
private val _qualifiedAccessCheckers: MutableSet<FirQualifiedAccessChecker> = mutableSetOf()
|
||||
@@ -59,6 +61,7 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
|
||||
private val _safeCallExpressionCheckers: MutableSet<FirSafeCallExpressionChecker> = mutableSetOf()
|
||||
private val _equalityOperatorCallCheckers: MutableSet<FirEqualityOperatorCallChecker> = mutableSetOf()
|
||||
private val _anonymousFunctionAsExpressionCheckers: MutableSet<FirAnonymousFunctionAsExpressionChecker> = mutableSetOf()
|
||||
private val _stringConcatenationCallCheckers: MutableSet<FirStringConcatenationCallChecker> = mutableSetOf()
|
||||
|
||||
@CheckersComponentInternal
|
||||
internal fun register(checkers: ExpressionCheckers) {
|
||||
@@ -77,5 +80,6 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
|
||||
_safeCallExpressionCheckers += checkers.safeCallExpressionCheckers
|
||||
_equalityOperatorCallCheckers += checkers.equalityOperatorCallCheckers
|
||||
_anonymousFunctionAsExpressionCheckers += checkers.anonymousFunctionAsExpressionCheckers
|
||||
_stringConcatenationCallCheckers += checkers.stringConcatenationCallCheckers
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -32,6 +32,7 @@ abstract class ExpressionCheckers {
|
||||
open val safeCallExpressionCheckers: Set<FirSafeCallExpressionChecker> = emptySet()
|
||||
open val equalityOperatorCallCheckers: Set<FirEqualityOperatorCallChecker> = emptySet()
|
||||
open val anonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker> = emptySet()
|
||||
open val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker> = emptySet()
|
||||
|
||||
@CheckersComponentInternal internal val allBasicExpressionCheckers: Set<FirBasicExpressionChecker> get() = basicExpressionCheckers
|
||||
@CheckersComponentInternal internal val allQualifiedAccessCheckers: Set<FirQualifiedAccessChecker> get() = qualifiedAccessCheckers + basicExpressionCheckers
|
||||
@@ -48,4 +49,5 @@ abstract class ExpressionCheckers {
|
||||
@CheckersComponentInternal internal val allSafeCallExpressionCheckers: Set<FirSafeCallExpressionChecker> get() = safeCallExpressionCheckers + basicExpressionCheckers
|
||||
@CheckersComponentInternal internal val allEqualityOperatorCallCheckers: Set<FirEqualityOperatorCallChecker> get() = equalityOperatorCallCheckers + basicExpressionCheckers
|
||||
@CheckersComponentInternal internal val allAnonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker> get() = anonymousFunctionAsExpressionCheckers + basicExpressionCheckers
|
||||
@CheckersComponentInternal internal val allStringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker> get() = stringConcatenationCallCheckers + basicExpressionCheckers
|
||||
}
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirSafeCallExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirTryExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
||||
@@ -41,3 +42,4 @@ typealias FirGetClassCallChecker = FirExpressionChecker<FirGetClassCall>
|
||||
typealias FirSafeCallExpressionChecker = FirExpressionChecker<FirSafeCallExpression>
|
||||
typealias FirEqualityOperatorCallChecker = FirExpressionChecker<FirEqualityOperatorCall>
|
||||
typealias FirAnonymousFunctionAsExpressionChecker = FirExpressionChecker<FirAnonymousFunction>
|
||||
typealias FirStringConcatenationCallChecker = FirExpressionChecker<FirStringConcatenationCall>
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||
object RedundantCallOfConversionMethod : FirQualifiedAccessChecker() {
|
||||
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (expression !is FirFunctionCall) return
|
||||
if (expression.source?.kind == FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
|
||||
val functionName = expression.calleeReference.name.asString()
|
||||
val qualifiedType = targetClassMap[functionName] ?: return
|
||||
|
||||
|
||||
+11
-10
@@ -9,29 +9,30 @@ import com.intellij.lang.LighterASTNode
|
||||
import com.intellij.lang.PsiBuilder
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.FirLightSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirStringConcatenationCallChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.getChildren
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.arguments
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
||||
|
||||
object RedundantSingleExpressionStringTemplateChecker : FirFunctionCallChecker() {
|
||||
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (expression.source?.kind != FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
|
||||
if (expression.explicitReceiver?.typeRef?.coneType?.classId == StandardClassIds.String
|
||||
&& expression.stringParentChildrenCount() == 1 // there is no more children in original string template
|
||||
) {
|
||||
reporter.reportOn(expression.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE, context)
|
||||
object RedundantSingleExpressionStringTemplateChecker : FirStringConcatenationCallChecker() {
|
||||
override fun check(expression: FirStringConcatenationCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
for (argumentExpression in expression.arguments) {
|
||||
if (argumentExpression.typeRef.coneType.classId == StandardClassIds.String &&
|
||||
argumentExpression.stringParentChildrenCount() == 1 // there is no more children in original string template
|
||||
) {
|
||||
reporter.reportOn(argumentExpression.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class ExpressionCheckersDiagnosticComponent(
|
||||
}
|
||||
|
||||
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: CheckerContext) {
|
||||
checkers.allBasicExpressionCheckers.check(stringConcatenationCall, data, reporter)
|
||||
checkers.allStringConcatenationCallCheckers.check(stringConcatenationCall, data, reporter)
|
||||
}
|
||||
|
||||
override fun visitCheckNotNullCall(checkNotNullCall: FirCheckNotNullCall, data: CheckerContext) {
|
||||
|
||||
+4
@@ -28,6 +28,10 @@ object ExtendedExpressionCheckers : ExpressionCheckers() {
|
||||
override val functionCallCheckers: Set<FirFunctionCallChecker>
|
||||
get() = setOf(
|
||||
EmptyRangeChecker,
|
||||
)
|
||||
|
||||
override val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker>
|
||||
get() = setOf(
|
||||
RedundantSingleExpressionStringTemplateChecker,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ FILE: for.kt
|
||||
lval <destruct>: <implicit> = R|<local>/<iterator>|.next#()
|
||||
lval x: <implicit> = R|<local>/<destruct>|.component1#()
|
||||
lval y: <implicit> = R|<local>/<destruct>|.component2#()
|
||||
println#(<strcat>(String(x = ), x#.toString#(), String( y = ), y#.toString#()))
|
||||
println#(<strcat>(String(x = ), x#, String( y = ), y#))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-10
@@ -402,16 +402,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
}
|
||||
SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> {
|
||||
hasExpressions = true
|
||||
val firExpression = entry.convertTemplateEntry("Incorrect template argument")
|
||||
val source = firExpression.source?.fakeElement(FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry)
|
||||
buildFunctionCall {
|
||||
this.source = source
|
||||
explicitReceiver = firExpression
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
this.source = source
|
||||
name = Name.identifier("toString")
|
||||
}
|
||||
}
|
||||
entry.convertTemplateEntry("Incorrect template argument")
|
||||
}
|
||||
else -> {
|
||||
hasExpressions = true
|
||||
|
||||
@@ -843,6 +843,12 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
callNode.mergeIncomingFlow()
|
||||
}
|
||||
|
||||
fun exitStringConcatenationCall(call: FirStringConcatenationCall) {
|
||||
val (callNode, unionNode) = graphBuilder.exitStringConcatenationCall(call)
|
||||
unionNode?.let { unionFlowFromArguments(it) }
|
||||
callNode.mergeIncomingFlow()
|
||||
}
|
||||
|
||||
|
||||
private fun unionFlowFromArguments(node: UnionFunctionCallArgumentsNode) {
|
||||
node.flow = logicSystem.unionFlow(node.previousNodes.map { it.flow }).also {
|
||||
|
||||
@@ -606,6 +606,17 @@ class DelegatedConstructorCallNode(
|
||||
}
|
||||
}
|
||||
|
||||
class StringConcatenationCallNode(
|
||||
owner: ControlFlowGraph,
|
||||
override val fir: FirStringConcatenationCall,
|
||||
level: Int,
|
||||
id: Int
|
||||
) : CFGNode<FirStringConcatenationCall>(owner, level, id) {
|
||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||
return visitor.visitStringConcatenationCallNode(this, data)
|
||||
}
|
||||
}
|
||||
|
||||
class ThrowExceptionNode(
|
||||
owner: ControlFlowGraph,
|
||||
override val fir: FirThrowExpression,
|
||||
|
||||
@@ -60,6 +60,7 @@ fun CFGNode<*>.render(): String =
|
||||
is VariableAssignmentNode -> "Assignment: ${fir.lValue.render(CfgRenderMode)}"
|
||||
is FunctionCallNode -> "Function call: ${fir.render(CfgRenderMode)}"
|
||||
is DelegatedConstructorCallNode -> "Delegated constructor call: ${fir.render(CfgRenderMode)}"
|
||||
is StringConcatenationCallNode -> "String concatenation call: ${fir.render(CfgRenderMode)}"
|
||||
is ThrowExceptionNode -> "Throw: ${fir.render(CfgRenderMode)}"
|
||||
|
||||
is TryExpressionEnterNode -> "Try expression enter"
|
||||
|
||||
+8
@@ -989,6 +989,14 @@ class ControlFlowGraphBuilder {
|
||||
return node to unionNode
|
||||
}
|
||||
|
||||
fun exitStringConcatenationCall(call: FirStringConcatenationCall): Pair<StringConcatenationCallNode, UnionFunctionCallArgumentsNode?> {
|
||||
levelCounter--
|
||||
val node = createStringConcatenationCallNode(call)
|
||||
val (kind, unionNode) = processUnionOfArguments(node, true)
|
||||
addNewSimpleNode(node, preferredKind = kind)
|
||||
return node to unionNode
|
||||
}
|
||||
|
||||
fun exitConstExpression(constExpression: FirConstExpression<*>): ConstExpressionNode {
|
||||
return createConstExpressionNode(constExpression).also { addNewSimpleNode(it) }
|
||||
}
|
||||
|
||||
+3
@@ -131,6 +131,9 @@ fun ControlFlowGraphBuilder.createCallableReferenceNode(fir: FirCallableReferenc
|
||||
fun ControlFlowGraphBuilder.createDelegatedConstructorCallNode(fir: FirDelegatedConstructorCall): DelegatedConstructorCallNode =
|
||||
DelegatedConstructorCallNode(currentGraph, fir, levelCounter, createId())
|
||||
|
||||
fun ControlFlowGraphBuilder.createStringConcatenationCallNode(fir: FirStringConcatenationCall): StringConcatenationCallNode =
|
||||
StringConcatenationCallNode(currentGraph, fir, levelCounter, createId())
|
||||
|
||||
fun ControlFlowGraphBuilder.createVariableAssignmentNode(fir: FirVariableAssignment): VariableAssignmentNode =
|
||||
VariableAssignmentNode(currentGraph, fir, levelCounter, createId())
|
||||
|
||||
|
||||
+4
@@ -295,6 +295,10 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
|
||||
return visitNode(node, data)
|
||||
}
|
||||
|
||||
open fun visitStringConcatenationCallNode(node: StringConcatenationCallNode, data: D): R {
|
||||
return visitNode(node, data)
|
||||
}
|
||||
|
||||
open fun visitThrowExceptionNode(node: ThrowExceptionNode, data: D): R {
|
||||
return visitNode(node, data)
|
||||
}
|
||||
|
||||
+8
@@ -249,6 +249,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
||||
visitNode(node)
|
||||
}
|
||||
|
||||
open fun visitStringConcatenationCallNode(node: StringConcatenationCallNode) {
|
||||
visitNode(node)
|
||||
}
|
||||
|
||||
open fun visitThrowExceptionNode(node: ThrowExceptionNode) {
|
||||
visitNode(node)
|
||||
}
|
||||
@@ -538,6 +542,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
||||
visitDelegatedConstructorCallNode(node)
|
||||
}
|
||||
|
||||
final override fun visitStringConcatenationCallNode(node: StringConcatenationCallNode, data: Nothing?) {
|
||||
visitStringConcatenationCallNode(node)
|
||||
}
|
||||
|
||||
final override fun visitThrowExceptionNode(node: ThrowExceptionNode, data: Nothing?) {
|
||||
visitThrowExceptionNode(node)
|
||||
}
|
||||
|
||||
+4
@@ -107,6 +107,10 @@ open class FirBodyResolveTransformer(
|
||||
return expressionsTransformer.transformFunctionCall(functionCall, data)
|
||||
}
|
||||
|
||||
override fun transformStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: ResolutionMode): FirStatement {
|
||||
return expressionsTransformer.transformStringConcatenationCall(stringConcatenationCall, data)
|
||||
}
|
||||
|
||||
override fun transformCallableReferenceAccess(
|
||||
callableReferenceAccess: FirCallableReferenceAccess,
|
||||
data: ResolutionMode
|
||||
|
||||
+7
@@ -979,6 +979,13 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
return arrayOfCall
|
||||
}
|
||||
|
||||
override fun transformStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: ResolutionMode): FirStatement {
|
||||
dataFlowAnalyzer.enterCall()
|
||||
stringConcatenationCall.transformChildren(transformer, ResolutionMode.ContextIndependent)
|
||||
dataFlowAnalyzer.exitStringConcatenationCall(stringConcatenationCall)
|
||||
return stringConcatenationCall
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
|
||||
|
||||
@@ -136,9 +136,6 @@ sealed class FirFakeSourceElementKind : FirSourceElementKind() {
|
||||
// where a + 2 will have a fake source
|
||||
object DesugaredCompoundAssignment : FirFakeSourceElementKind()
|
||||
|
||||
//"$a" --> a.toString() where toString call source is marked as a fake one
|
||||
object GeneratedToStringCallOnTemplateEntry : FirFakeSourceElementKind()
|
||||
|
||||
// `a > b` will be wrapped in FirComparisonExpression
|
||||
// with real source which points to initial `a > b` expression
|
||||
// and inner FirFunctionCall will refer to a fake source
|
||||
|
||||
@@ -87,10 +87,9 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
|
||||
CALL 'public final fun appendLine (value: kotlin.String?): java.lang.StringBuilder [inline] declared in kotlin.text.StringsKt' type=java.lang.StringBuilder origin=null
|
||||
$receiver: GET_VAR '<this>: java.lang.StringBuilder declared in <root>.test.localFunc.<anonymous>' type=java.lang.StringBuilder origin=null
|
||||
value: STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
|
||||
$this: GET_VAR 'val i: kotlin.Int [val] declared in <root>.test.localFunc' type=kotlin.Int origin=null
|
||||
other: GET_VAR 'val j: kotlin.Int [val] declared in <root>.test.localFunc.<anonymous>' type=kotlin.Int origin=null
|
||||
CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
|
||||
$this: GET_VAR 'val i: kotlin.Int [val] declared in <root>.test.localFunc' type=kotlin.Int origin=null
|
||||
other: GET_VAR 'val j: kotlin.Int [val] declared in <root>.test.localFunc.<anonymous>' type=kotlin.Int origin=null
|
||||
CALL 'public final fun takeString (s: kotlin.String): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
s: GET_VAR 'val s: kotlin.String [val] declared in <root>.test.localFunc' type=kotlin.String origin=null
|
||||
CALL 'local final fun localFunc (): kotlin.Unit declared in <root>.test' type=kotlin.Unit origin=null
|
||||
@@ -108,5 +107,4 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Fail: "
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-result> (): kotlin.Int declared in <root>' type=kotlin.Int origin=GET_PROPERTY
|
||||
CALL 'public final fun <get-result> (): kotlin.Int declared in <root>' type=kotlin.Int origin=GET_PROPERTY
|
||||
|
||||
@@ -5,7 +5,7 @@ class X {}
|
||||
val s = java
|
||||
val ss = System
|
||||
val sss = X
|
||||
val x = "${<!UNRESOLVED_REFERENCE!>System<!>}"
|
||||
val x = "${System}"
|
||||
val xs = java.lang
|
||||
val xss = java.lang.System
|
||||
val xsss = foo.X
|
||||
|
||||
@@ -50,7 +50,7 @@ open enum class A : Enum<A> {
|
||||
}
|
||||
|
||||
open fun f(): String {
|
||||
return <this>.<get-prop1>().toString() + "#" + <this>.<get-prop2>().toString() + "#" + <this>.<get-prop3>().toString()
|
||||
return <this>.<get-prop1>() + "#" + <this>.<get-prop2>() + "#" + <this>.<get-prop3>()
|
||||
}
|
||||
|
||||
fun values(): Array<A> /* Synthetic body for ENUM_VALUES */
|
||||
|
||||
@@ -159,17 +159,14 @@ FILE fqName:<root> fileName:/enumWithMultipleCtors.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun f (): kotlin.String declared in <root>.A'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-prop1> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
CALL 'public final fun <get-prop1> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
CONST String type=kotlin.String value="#"
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-prop2> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
CALL 'public final fun <get-prop2> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
CONST String type=kotlin.String value="#"
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-prop3> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
CALL 'public final fun <get-prop3> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A.f' type=<root>.A origin=null
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<<root>.A>
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:<root>.A
|
||||
|
||||
@@ -65,7 +65,7 @@ fun testContinueDoWhile() {
|
||||
when {
|
||||
greater(arg0 = k, arg1 = 2) -> continue
|
||||
}
|
||||
s = s.plus(other = k.toString() + ";")
|
||||
s = s.plus(other = k + ";")
|
||||
// } while (less(arg0 = k, arg1 = 10))
|
||||
}
|
||||
when {
|
||||
|
||||
@@ -126,8 +126,7 @@ FILE fqName:<root> fileName:/breakContinueInWhen.kt
|
||||
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'var s: kotlin.String [var] declared in <root>.testContinueDoWhile' type=kotlin.String origin=null
|
||||
other: STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'var k: kotlin.Int [var] declared in <root>.testContinueDoWhile' type=kotlin.Int origin=null
|
||||
GET_VAR 'var k: kotlin.Int [var] declared in <root>.testContinueDoWhile' type=kotlin.Int origin=null
|
||||
CONST String type=kotlin.String value=";"
|
||||
condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'var k: kotlin.Int [var] declared in <root>.testContinueDoWhile' type=kotlin.Int origin=null
|
||||
|
||||
@@ -23,14 +23,14 @@ const val testConst4: String
|
||||
get
|
||||
|
||||
fun test1(x: Int): String {
|
||||
return "\uD83E" + "\uDD17" + x.toString()
|
||||
return "\uD83E" + "\uDD17" + x
|
||||
}
|
||||
|
||||
fun test2(x: Int): String {
|
||||
return x.toString() + "\uD83E" + "\uDD17"
|
||||
return x + "\uD83E" + "\uDD17"
|
||||
}
|
||||
|
||||
fun test3(x: Int): String {
|
||||
return x.toString() + "\uD83E" + "\uDD17" + x.toString()
|
||||
return x + "\uD83E" + "\uDD17" + x
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -60,15 +60,13 @@ FILE fqName:<root> fileName:/kt28006.kt
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="\uD83E"
|
||||
CONST String type=kotlin.String value="\uDD17"
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'x: kotlin.Int declared in <root>.test1' type=kotlin.Int origin=null
|
||||
GET_VAR 'x: kotlin.Int declared in <root>.test1' type=kotlin.Int origin=null
|
||||
FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.String
|
||||
VALUE_PARAMETER name:x index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test2 (x: kotlin.Int): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'x: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
|
||||
GET_VAR 'x: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
|
||||
CONST String type=kotlin.String value="\uD83E"
|
||||
CONST String type=kotlin.String value="\uDD17"
|
||||
FUN name:test3 visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.String
|
||||
@@ -76,9 +74,7 @@ FILE fqName:<root> fileName:/kt28006.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test3 (x: kotlin.Int): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'x: kotlin.Int declared in <root>.test3' type=kotlin.Int origin=null
|
||||
GET_VAR 'x: kotlin.Int declared in <root>.test3' type=kotlin.Int origin=null
|
||||
CONST String type=kotlin.String value="\uD83E"
|
||||
CONST String type=kotlin.String value="\uDD17"
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'x: kotlin.Int declared in <root>.test3' type=kotlin.Int origin=null
|
||||
GET_VAR 'x: kotlin.Int declared in <root>.test3' type=kotlin.Int origin=null
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
object A {
|
||||
private constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
private val a: String
|
||||
field = "$"
|
||||
private get
|
||||
|
||||
private val b: String
|
||||
field = "1234" + <this>.<get-a>().toString()
|
||||
private get
|
||||
|
||||
private val c: Int
|
||||
field = 10000
|
||||
private get
|
||||
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
FILE fqName:<root> fileName:/objectReferenceInFieldInitializer.kt
|
||||
CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
|
||||
CONSTRUCTOR visibility:private <> () returnType:<root>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
PROPERTY name:a visibility:private modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="$"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:private modality:FINAL <> ($this:<root>.A) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:private modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='private final fun <get-a> (): kotlin.String declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-a>' type=<root>.A origin=null
|
||||
PROPERTY name:b visibility:private modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="1234"
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'private final fun <get-a> (): kotlin.String declared in <root>.A' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:private modality:FINAL <> ($this:<root>.A) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:b visibility:private modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='private final fun <get-b> (): kotlin.String declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-b>' type=<root>.A origin=null
|
||||
PROPERTY name:c visibility:private modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=10000
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:private modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:c visibility:private modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='private final fun <get-c> (): kotlin.Int declared in <root>.A'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-c>' type=<root>.A origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
@@ -1,3 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
object A {
|
||||
private val a = "$"
|
||||
private val b = "1234$a"
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
fun foo(): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
val x: Int
|
||||
field = 42
|
||||
get
|
||||
|
||||
val test1: String
|
||||
field = ""
|
||||
get
|
||||
|
||||
val test2: String
|
||||
field = "abc"
|
||||
get
|
||||
|
||||
val test3: String
|
||||
field = ""
|
||||
get
|
||||
|
||||
val test4: String
|
||||
field = "abc"
|
||||
get
|
||||
|
||||
val test5: String
|
||||
field = "\nabc\n"
|
||||
get
|
||||
|
||||
val test6: String
|
||||
field = <get-test1>().toString() + " " + foo().toString()
|
||||
get
|
||||
|
||||
val test7: String
|
||||
field = <get-test1>().toString()
|
||||
get
|
||||
|
||||
val test8: String
|
||||
field = foo().toString()
|
||||
get
|
||||
|
||||
val test9: String
|
||||
field = <get-x>().toString()
|
||||
get
|
||||
@@ -1,106 +0,0 @@
|
||||
FILE fqName:<root> fileName:/stringTemplates.kt
|
||||
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value=""
|
||||
PROPERTY name:x visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=kotlin.Int value=42
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-x> (): kotlin.Int declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null
|
||||
PROPERTY name:test1 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value=""
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test1> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test1> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="abc"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test2> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test2> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test3 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value=""
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test3> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test3> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test4 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="abc"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test4> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test4> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test5 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="\nabc\n"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test5> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test5> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test6 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-test1> (): kotlin.String declared in <root>' type=kotlin.String origin=GET_PROPERTY
|
||||
CONST String type=kotlin.String value=" "
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun foo (): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test6> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test6> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test7 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test7 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-test1> (): kotlin.String declared in <root>' type=kotlin.String origin=GET_PROPERTY
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test7> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test7 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test7> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test7 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test8 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test8 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun foo (): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test8> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test8> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test8 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
PROPERTY name:test9 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test9 type:kotlin.String visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: CALL 'public final fun <get-x> (): kotlin.Int declared in <root>' type=kotlin.Int origin=GET_PROPERTY
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test9> visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:test9 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-test9> (): kotlin.String declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test9 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null
|
||||
@@ -1,3 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
fun foo(): String = ""
|
||||
val x = 42
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ class Flaf {
|
||||
var result: Flaf? = <this>.<get-INSTANCES>().get(key = javaName)
|
||||
when {
|
||||
EQEQ(arg0 = result, arg1 = null) -> { // BLOCK
|
||||
result = <this>.<get-INSTANCES>().get(key = javaName.toString() + "_alternative")
|
||||
result = <this>.<get-INSTANCES>().get(key = javaName + "_alternative")
|
||||
when {
|
||||
EQEQ(arg0 = result, arg1 = null) -> { // BLOCK
|
||||
result = Flaf(javaName = javaName)
|
||||
|
||||
@@ -50,8 +50,7 @@ FILE fqName:<root> fileName:/inapplicableCollectionSet.kt
|
||||
$this: CALL 'private final fun <get-INSTANCES> (): kotlin.collections.MutableMap<kotlin.String, <root>.Flaf> declared in <root>.Flaf' type=kotlin.collections.MutableMap<kotlin.String, <root>.Flaf> origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.Flaf declared in <root>.Flaf.forJavaName' type=<root>.Flaf origin=null
|
||||
key: STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'javaName: kotlin.String declared in <root>.Flaf.forJavaName' type=kotlin.String origin=null
|
||||
GET_VAR 'javaName: kotlin.String declared in <root>.Flaf.forJavaName' type=kotlin.String origin=null
|
||||
CONST String type=kotlin.String value="_alternative"
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
|
||||
@@ -4,7 +4,7 @@ fun box(): String {
|
||||
var i: Int = 0
|
||||
while (x.hasNext()) { // BLOCK
|
||||
when {
|
||||
ieee754equals(arg0 = a.get(index = i), arg1 = x.next()).not() -> return "Fail " + i.toString()
|
||||
ieee754equals(arg0 = a.get(index = i), arg1 = x.next()).not() -> return "Fail " + i
|
||||
}
|
||||
val <unary>: Int = i
|
||||
i = <unary>.inc()
|
||||
|
||||
@@ -25,8 +25,7 @@ FILE fqName:<root> fileName:/coercionInLoop.kt
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Fail "
|
||||
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'var i: kotlin.Int [var] declared in <root>.box' type=kotlin.Int origin=null
|
||||
GET_VAR 'var i: kotlin.Int [var] declared in <root>.box' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
|
||||
GET_VAR 'var i: kotlin.Int [var] declared in <root>.box' type=kotlin.Int origin=null
|
||||
SET_VAR 'var i: kotlin.Int [var] declared in <root>.box' type=kotlin.Unit origin=EQ
|
||||
|
||||
Reference in New Issue
Block a user