diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/element/builder/FirElementBuilder.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/element/builder/FirElementBuilder.kt index f39671cc617..3b566cc9468 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/element/builder/FirElementBuilder.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/element/builder/FirElementBuilder.kt @@ -263,7 +263,8 @@ internal fun PsiElement.getNonLocalContainingOrThisDeclaration(predicate: (KtDec !notNullCandidate.isPartOf(parent) || parent is KtClassInitializer || parent is KtObjectLiteralExpression || - parent is KtCallElement + parent is KtCallElement || + parent is KtScript ) { // Candidate turned out to be local. Let's find another one. candidate = null diff --git a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersScript.txt b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersScript.txt index 4a0838c69d4..ecc8549eeb5 100644 --- a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersScript.txt +++ b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersScript.txt @@ -1,16 +1,16 @@ -/* anchor --> *//* anchor --> */class A /* anchor --> */constructor(/* anchor --> */a: Int/* <-- */)/* <-- */ { - /* anchor --> */fun boo() { +/* anchor --> */class A constructor(a: Int) { + fun boo() { fun bar() { } - }/* <-- */ + } - /* anchor --> */val i: Int = 42/* <-- */ + val i: Int = 42 - /* anchor --> */init { + init { fun foo() { } - }/* <-- */ -}/* <-- */ -/* <-- */ + } +} +/* <-- */ \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersWithPackage.txt b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersWithPackage.txt index 53191411dd9..674ce9796cc 100644 --- a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersWithPackage.txt +++ b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/classWithMembersWithPackage.txt @@ -1,18 +1,18 @@ package one/* anchor --> */ -/* anchor --> */class A /* anchor --> */constructor(/* anchor --> */a: Int/* <-- */)/* <-- */ { - /* anchor --> */fun boo() { +class A constructor(a: Int) { + fun boo() { fun bar() { } - }/* <-- */ + } - /* anchor --> */val i: Int = 42/* <-- */ + val i: Int = 42 - /* anchor --> */init { + init { fun foo() { } - }/* <-- */ -}/* <-- */ -/* <-- */ + } +} +/* <-- */ \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/statements.txt b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/statements.txt index 45571840c2c..d5f8bca75c4 100644 --- a/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/statements.txt +++ b/analysis/low-level-api-fir/testdata/nonLocalDeclarationAnchors/statements.txt @@ -1,12 +1,12 @@ -/* anchor --> *//* anchor --> */class Builder { - /* anchor --> */var version: String = ""/* <-- */ +/* anchor --> */class Builder { + var version: String = "" - /* anchor --> */fun execute() { + fun execute() { println(version) - }/* <-- */ -}/* <-- */ + } +} -fun build(/* anchor --> */action: Builder.() -> Unit/* <-- */) = Builder().apply(action) +fun build(action: Builder.() -> Unit) = Builder().apply(action) build { version = "123" @@ -24,4 +24,4 @@ val builder = build { } builder.execute() -/* <-- */ +/* <-- */ \ No newline at end of file