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 { ).apply {
this.typeParameters += javaMethod.typeParameters.convertTypeParameters(javaTypeParameterStack) this.typeParameters += javaMethod.typeParameters.convertTypeParameters(javaTypeParameterStack)
addAnnotationsFrom(this@JavaSymbolProvider.session, javaMethod, javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaMethod, javaTypeParameterStack)
for (valueParameter in javaMethod.valueParameters) { for ((index, valueParameter) in javaMethod.valueParameters.withIndex()) {
valueParameters += valueParameter.toFirValueParameters( valueParameters += valueParameter.toFirValueParameter(
this@JavaSymbolProvider.session, javaTypeParameterStack this@JavaSymbolProvider.session, index, javaTypeParameterStack
) )
} }
} }
@@ -271,9 +271,9 @@ class JavaSymbolProvider(
).apply { ).apply {
this.typeParameters += javaConstructor.typeParameters.convertTypeParameters(javaTypeParameterStack) this.typeParameters += javaConstructor.typeParameters.convertTypeParameters(javaTypeParameterStack)
addAnnotationsFrom(this@JavaSymbolProvider.session, javaConstructor, javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaConstructor, javaTypeParameterStack)
for (valueParameter in javaConstructor.valueParameters) { for ((index, valueParameter) in javaConstructor.valueParameters.withIndex()) {
valueParameters += valueParameter.toFirValueParameters( valueParameters += valueParameter.toFirValueParameter(
this@JavaSymbolProvider.session, javaTypeParameterStack this@JavaSymbolProvider.session, index, javaTypeParameterStack
) )
} }
} }
@@ -197,15 +197,15 @@ internal fun FirAbstractAnnotatedElement.addAnnotationsFrom(
} }
} }
internal fun JavaValueParameter.toFirValueParameters( internal fun JavaValueParameter.toFirValueParameter(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack session: FirSession, index: Int, javaTypeParameterStack: JavaTypeParameterStack
): FirValueParameter { ): FirValueParameter {
return FirJavaValueParameter( 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), returnTypeRef = type.toFirJavaTypeRef(session, javaTypeParameterStack),
isVararg = isVararg isVararg = isVararg
).apply { ).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 BRANCH
if: CONST Boolean type=kotlin.Boolean value=true 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 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: K>: <none>
<class: V>: <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 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 FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY 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 $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 $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 $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