Raw FIR builder: fix situation with explicit type of for parameter
Before this commit we omitted for parameter type, even if it was stated explicitly. This also fixes PSI consistency test
This commit is contained in:
+2
-1
@@ -776,7 +776,8 @@ class ExpressionsConverter(
|
|||||||
FirFunctionCallImpl(null).apply {
|
FirFunctionCallImpl(null).apply {
|
||||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("next"), null)
|
calleeReference = FirSimpleNamedReference(null, Name.identifier("next"), null)
|
||||||
explicitReceiver = generateResolvedAccessExpression(null, iteratorVal)
|
explicitReceiver = generateResolvedAccessExpression(null, iteratorVal)
|
||||||
}
|
},
|
||||||
|
parameter!!.firValueParameter.returnTypeRef
|
||||||
)
|
)
|
||||||
if (multiDeclaration != null) {
|
if (multiDeclaration != null) {
|
||||||
val destructuringBlock = generateDestructuringBlock(
|
val destructuringBlock = generateDestructuringBlock(
|
||||||
|
|||||||
@@ -291,12 +291,12 @@ internal fun generateDestructuringBlock(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun generateTemporaryVariable(
|
fun generateTemporaryVariable(
|
||||||
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression
|
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null
|
||||||
): FirVariable<*> =
|
): FirVariable<*> =
|
||||||
FirPropertyImpl(
|
FirPropertyImpl(
|
||||||
source,
|
source,
|
||||||
session,
|
session,
|
||||||
FirImplicitTypeRefImpl(source),
|
typeRef ?: FirImplicitTypeRefImpl(source),
|
||||||
null,
|
null,
|
||||||
name,
|
name,
|
||||||
initializer,
|
initializer,
|
||||||
|
|||||||
@@ -1189,7 +1189,8 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
|||||||
FirFunctionCallImpl(loopSource).apply {
|
FirFunctionCallImpl(loopSource).apply {
|
||||||
calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("next"), null)
|
calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("next"), null)
|
||||||
explicitReceiver = generateResolvedAccessExpression(loopSource, iteratorVal)
|
explicitReceiver = generateResolvedAccessExpression(loopSource, iteratorVal)
|
||||||
}
|
},
|
||||||
|
parameter.typeReference.toFirOrImplicitType()
|
||||||
)
|
)
|
||||||
if (multiDeclaration != null) {
|
if (multiDeclaration != null) {
|
||||||
val destructuringBlock = generateDestructuringBlock(
|
val destructuringBlock = generateDestructuringBlock(
|
||||||
|
|||||||
@@ -18,3 +18,9 @@ fun baz(set: Set<Some>) {
|
|||||||
println("x = $x y = $y")
|
println("x = $x y = $y")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun withParameter(list: List<Some>) {
|
||||||
|
for (s: Some in list) {
|
||||||
|
println(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,3 +58,12 @@ FILE: for.kt
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public? final? fun withParameter(list: List<Some>): R|kotlin/Unit| {
|
||||||
|
lval <range>: <implicit> = list#
|
||||||
|
lval <iterator>: <implicit> = R|<local>/<range>|.iterator#()
|
||||||
|
while(R|<local>/<iterator>|.hasNext#()) {
|
||||||
|
lval s: Some = R|<local>/<iterator>|.next#()
|
||||||
|
println#(s#)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -267,7 +267,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
|
|||||||
println("Not traversed ${element.javaClass}: ${element.text}")
|
println("Not traversed ${element.javaClass}: ${element.text}")
|
||||||
val traversedParent = element.parents.firstOrNull { it in psiSetViaFir }
|
val traversedParent = element.parents.firstOrNull { it in psiSetViaFir }
|
||||||
if (traversedParent != null) {
|
if (traversedParent != null) {
|
||||||
println("(traversed parent: ${traversedParent.javaClass})")
|
println("(traversed parent: ${traversedParent.javaClass} ${traversedParent.text})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println(firFile.render())
|
println(firFile.render())
|
||||||
|
|||||||
Reference in New Issue
Block a user