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:
Mikhail Glukhikh
2020-01-16 13:20:40 +03:00
parent 621936e951
commit f27611939e
6 changed files with 22 additions and 5 deletions
@@ -776,7 +776,8 @@ class ExpressionsConverter(
FirFunctionCallImpl(null).apply {
calleeReference = FirSimpleNamedReference(null, Name.identifier("next"), null)
explicitReceiver = generateResolvedAccessExpression(null, iteratorVal)
}
},
parameter!!.firValueParameter.returnTypeRef
)
if (multiDeclaration != null) {
val destructuringBlock = generateDestructuringBlock(
@@ -291,12 +291,12 @@ internal fun generateDestructuringBlock(
}
fun generateTemporaryVariable(
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null
): FirVariable<*> =
FirPropertyImpl(
source,
session,
FirImplicitTypeRefImpl(source),
typeRef ?: FirImplicitTypeRefImpl(source),
null,
name,
initializer,
@@ -1189,7 +1189,8 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
FirFunctionCallImpl(loopSource).apply {
calleeReference = FirSimpleNamedReference(loopSource, Name.identifier("next"), null)
explicitReceiver = generateResolvedAccessExpression(loopSource, iteratorVal)
}
},
parameter.typeReference.toFirOrImplicitType()
)
if (multiDeclaration != null) {
val destructuringBlock = generateDestructuringBlock(
@@ -18,3 +18,9 @@ fun baz(set: Set<Some>) {
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#)
}
}
@@ -267,7 +267,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
println("Not traversed ${element.javaClass}: ${element.text}")
val traversedParent = element.parents.firstOrNull { it in psiSetViaFir }
if (traversedParent != null) {
println("(traversed parent: ${traversedParent.javaClass})")
println("(traversed parent: ${traversedParent.javaClass} ${traversedParent.text})")
}
}
println(firFile.render())