[FIR] Fix analysis of FirScript contents

Running the
`FirScriptCodegenTestGenerated.testSecondLevelFunction` test results
in "Expected is `FirResolvedDeclarationStatus`, but was
`FirDeclarationStatusImpl`. This is similar to the
`FirIdeNormalAnalysisSourceModuleCodeFragmentCollectDiagnosticsTestGenerated.testLocalFunction`
test, but that one was fixed by `9514f8f8`.
Looks like the situation here is the same,
it's just `FirScript` that needs to be
fixed.

The changed regarding the approximation is needed to avoid exposing
the anonymous type in
`FirScriptLazyDeclarationResolveTestGenerated.testDelegatesScript`.

The difference in the
`ScriptInBlockModificationTestGenerated.testRawContractScript`
test appeared because previously
the contract used to be
`FirRawContractDescription`, but
it now resolves to
`FirEmptyContractDescription`.
This commit is contained in:
Nikolay Lunyak
2023-09-08 13:19:39 +03:00
committed by Space Team
parent a1cb6258bc
commit fa600a58ac
6 changed files with 10 additions and 13 deletions
@@ -50,7 +50,7 @@ internal abstract class LLFirAbstractBodyTargetResolver(
}
override fun withScript(firScript: FirScript, action: () -> Unit) {
transformer.context.withScopesForScript(firScript, transformer.components, action)
transformer.context.withScript(firScript, transformer.components, action)
}
override fun withFile(firFile: FirFile, action: () -> Unit) {
@@ -294,7 +294,7 @@ private class ContextCollectorVisitor(
}
override fun visitScript(script: FirScript) {
context.withScopesForScript(script, holder) {
context.withScript(script, holder) {
withInterceptor {
super.visitScript(script)
}
@@ -1,11 +1,5 @@
BEFORE MODIFICATION:
public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] arg: R|kotlin/Any?|, [ResolvedTo(BODY_RESOLVE)] num: R|kotlin/Int?|, [ResolvedTo(BODY_RESOLVE)] block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[Contract description] <
<Unresolved name: returns>#().<Unresolved name: implies>#((R|<local>/arg| is R|kotlin/String|)),
<Unresolved name: returns>#().<Unresolved name: implies>#(!=(R|<local>/num|, Null(null))),
<Unresolved name: callsInPlace>#(R|<local>/block|, <Unresolved name: InvocationKind>#.<Unresolved name: EXACTLY_ONCE>#)
>
{
public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] arg: R|kotlin/Any?|, [ResolvedTo(BODY_RESOLVE)] num: R|kotlin/Int?|, [ResolvedTo(BODY_RESOLVE)] block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
<Unresolved name: require>#((R|<local>/arg| is R|kotlin/String|))
<Unresolved name: require>#(!=(R|<local>/num|, Null(null)))
R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()