FIR Java: use different names for anonymous parameters (p0, p1, p2, ...)

This commit is contained in:
Mikhail Glukhikh
2019-11-11 13:43:46 +03:00
parent c657d46437
commit 26281bfe89
3 changed files with 15 additions and 15 deletions
@@ -223,9 +223,9 @@ class JavaSymbolProvider(
).apply {
this.typeParameters += javaMethod.typeParameters.convertTypeParameters(javaTypeParameterStack)
addAnnotationsFrom(this@JavaSymbolProvider.session, javaMethod, javaTypeParameterStack)
for (valueParameter in javaMethod.valueParameters) {
valueParameters += valueParameter.toFirValueParameters(
this@JavaSymbolProvider.session, javaTypeParameterStack
for ((index, valueParameter) in javaMethod.valueParameters.withIndex()) {
valueParameters += valueParameter.toFirValueParameter(
this@JavaSymbolProvider.session, index, javaTypeParameterStack
)
}
}
@@ -271,9 +271,9 @@ class JavaSymbolProvider(
).apply {
this.typeParameters += javaConstructor.typeParameters.convertTypeParameters(javaTypeParameterStack)
addAnnotationsFrom(this@JavaSymbolProvider.session, javaConstructor, javaTypeParameterStack)
for (valueParameter in javaConstructor.valueParameters) {
valueParameters += valueParameter.toFirValueParameters(
this@JavaSymbolProvider.session, javaTypeParameterStack
for ((index, valueParameter) in javaConstructor.valueParameters.withIndex()) {
valueParameters += valueParameter.toFirValueParameter(
this@JavaSymbolProvider.session, index, javaTypeParameterStack
)
}
}
@@ -197,15 +197,15 @@ internal fun FirAbstractAnnotatedElement.addAnnotationsFrom(
}
}
internal fun JavaValueParameter.toFirValueParameters(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack
internal fun JavaValueParameter.toFirValueParameter(
session: FirSession, index: Int, javaTypeParameterStack: JavaTypeParameterStack
): FirValueParameter {
return FirJavaValueParameter(
session, (this as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), name ?: Name.special("<anonymous Java parameter>"),
session, (this as? JavaElementImpl<*>)?.psi?.toFirSourceElement(), name ?: Name.identifier("p$index"),
returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack),
isVararg = isVararg
).apply {
addAnnotationsFrom(session, this@toFirValueParameters, javaTypeParameterStack)
addAnnotationsFrom(session, this@toFirValueParameter, javaTypeParameterStack)
}
}
+5 -5
View File
@@ -15,16 +15,16 @@ FILE fqName:<root> fileName:/builtinMap.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public final fun apply (block: kotlin.Function1<T of <uninitialized parent>, kotlin.Unit>): T of <uninitialized parent> [inline] declared in kotlin' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (<anonymous Java parameter>: kotlin.collections.Map<out K of java.util.LinkedHashMap, out V of java.util.LinkedHashMap>?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (p0: kotlin.collections.Map<out K of java.util.LinkedHashMap, out V of java.util.LinkedHashMap>?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
<class: K>: <none>
<class: V>: <none>
<anonymous Java parameter>: GET_VAR '<this>: kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> origin=null
p0: GET_VAR '<this>: kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> origin=null
block: FUN_EXPR type=kotlin.Function1<java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public open fun put (<anonymous Java parameter>: K1 of <root>.plus, <anonymous Java parameter>: V1 of <root>.plus): V1 of <root>.plus declared in java.util.HashMap' type=V1 of <root>.plus origin=null
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus declared in java.util.HashMap' type=V1 of <root>.plus origin=null
$this: GET_VAR '<this>: java.util.HashMap declared in java.util.HashMap' type=java.util.HashMap<*, *> origin=null
<anonymous Java parameter>: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
<anonymous Java parameter>: CALL 'public final fun <get-second> (): V1 of <root>.plus declared in kotlin.Pair' type=V1 of <root>.plus origin=null
p1: CALL 'public final fun <get-second> (): V1 of <root>.plus declared in kotlin.Pair' type=V1 of <root>.plus origin=null
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null