diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt index 1059c0285d7..9aaa8d89705 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt @@ -10,6 +10,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDesignation import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDesignationWithScript import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration +import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.isAutonomousDeclaration import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ContextCollector.ContextKind import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ContextCollector.Context import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ContextCollector.FilterResponse @@ -36,6 +37,9 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.typeContext import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.util.PrivateForInline import org.jetbrains.kotlin.utils.yieldIfNotNull @@ -107,7 +111,7 @@ object ContextCollector { } fun computeDesignation(file: FirFile, targetElement: PsiElement): FirDesignation? { - val contextKtDeclaration = targetElement.getNonLocalContainingOrThisDeclaration() + val contextKtDeclaration = targetElement.getNonLocalContainingOrThisDeclaration(::isValidTarget) if (contextKtDeclaration != null) { val designationPath = FirElementFinder.collectDesignationPath(file, contextKtDeclaration) if (designationPath != null) { @@ -124,6 +128,20 @@ object ContextCollector { return null } + private fun isValidTarget(declaration: KtDeclaration): Boolean { + if (declaration.isAutonomousDeclaration) { + return true + } + + if (declaration is KtParameter && declaration.isPropertyParameter()) { + // Prefer context for primary constructor properties. + // Context of the constructor itself can be computed by passing the 'KtPrimaryConstructor' element. + return true + } + + return false + } + /** * Processes the [FirFile], collecting contexts for elements matching the [filter]. * diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_initializerExpression.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_initializerExpression.txt index 7669ec12561..fbf617ee608 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_initializerExpression.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_initializerExpression.txt @@ -14,7 +14,7 @@ Tower Data Context: Element 6 Scope: FirNestedClassifierScopeWithSubstitution Classifiers: - FirRegularClassSymbol public final class Nested : R|kotlin/Any| + FirRegularClassSymbol public? final? class Nested : R|kotlin/Any| Static scope owner symbol: FirRegularClassSymbol public open class Base : R|kotlin/Any| Element 7 Scope: FirLocalScope @@ -22,20 +22,20 @@ Tower Data Context: FirValueParameterSymbol name: R|kotlin/String| = String(name) FILE: [ResolvedTo(IMPORTS)] primaryConstructorParameter_initializerExpression.kt - public open [ResolvedTo(ANNOTATION_ARGUMENTS)] class Base : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Base| { - super() + public open [ResolvedTo(STATUS)] class Base : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|test/Base| { + LAZY_super } - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Nested : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Base.Nested| { - super() + public? final? [ResolvedTo(RAW_FIR)] class Nested : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] constructor(): R|test/Base.Nested| { + LAZY_super } } - public final [ResolvedTo(BODY_RESOLVE)] val fromBase: R|kotlin/String| = String() - public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/String| + public final [ResolvedTo(STATUS)] val fromBase: R|kotlin/String| = LAZY_EXPRESSION + public [ResolvedTo(STATUS)] get(): R|kotlin/String| } public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Child : R|test/Base| { diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_typeRef.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_typeRef.txt index b391165b45a..a3c644ed7cf 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_typeRef.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/primaryConstructorParameter_typeRef.txt @@ -14,7 +14,7 @@ Tower Data Context: Element 6 Scope: FirNestedClassifierScopeWithSubstitution Classifiers: - FirRegularClassSymbol public final class Nested : R|kotlin/Any| + FirRegularClassSymbol public? final? class Nested : R|kotlin/Any| Static scope owner symbol: FirRegularClassSymbol public open class Base : R|kotlin/Any| Element 7 Scope: FirLocalScope @@ -22,14 +22,14 @@ Tower Data Context: FirValueParameterSymbol name: R|kotlin/String| FILE: [ResolvedTo(IMPORTS)] primaryConstructorParameter_typeRef.kt - public open [ResolvedTo(ANNOTATION_ARGUMENTS)] class Base : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Base| { - super() + public open [ResolvedTo(STATUS)] class Base : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|test/Base| { + LAZY_super } - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Nested : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Base.Nested| { - super() + public? final? [ResolvedTo(RAW_FIR)] class Nested : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] constructor(): R|test/Base.Nested| { + LAZY_super } } diff --git a/analysis/low-level-api-fir/testData/contextCollector/parameter.kt b/analysis/low-level-api-fir/testData/contextCollector/parameter.kt new file mode 100644 index 00000000000..94aeef07fb5 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/parameter.kt @@ -0,0 +1,4 @@ +class Foo { + fun foo(abc: Int) {} + fun other() {} +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/parameter.txt b/analysis/low-level-api-fir/testData/contextCollector/parameter.txt new file mode 100644 index 00000000000..2d68d1a0fd8 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/parameter.txt @@ -0,0 +1,34 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + Element 7 + Scope: FirLocalScope + Properties: + FirValueParameterSymbol abc: R|kotlin/Int| + +FILE: [ResolvedTo(IMPORTS)] parameter.kt + public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|Foo| { + LAZY_super + } + + public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] abc: R|kotlin/Int|): R|kotlin/Unit| { + } + + public final [ResolvedTo(STATUS)] fun other(): R|kotlin/Unit| { LAZY_BLOCK } + + } diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.kt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.kt new file mode 100644 index 00000000000..de6c0937518 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.kt @@ -0,0 +1,4 @@ +class Foo( + val a: String = "foo" + val b: Int = a.length +) \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.txt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.txt new file mode 100644 index 00000000000..6c087a5919d --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.txt @@ -0,0 +1,31 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + +FILE: [ResolvedTo(IMPORTS)] primaryConstructor.kt + public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] a: R|kotlin/String| = String(foo), [ResolvedTo(BODY_RESOLVE)] b: R|kotlin/Int| = R|/a|.R|kotlin/String.length|): R|Foo| { + super() + } + + public final [ResolvedTo(STATUS)] val a: R|kotlin/String| = R|/a| + public [ResolvedTo(STATUS)] get(): R|kotlin/String| + + public final [ResolvedTo(STATUS)] val b: R|kotlin/Int| = R|/b| + public [ResolvedTo(STATUS)] get(): R|kotlin/Int| + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.kt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.kt index 13c153a510e..8114524f086 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.kt +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.kt @@ -1,5 +1,5 @@ class Foo( - val a: String = "foo" - val b: Int = a.length, - val c: Long = (a.length - 1).toLong() + a: String = "foo", + b: Int = a.length, + c: Long = (a.length - 1).toLong() ) \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.txt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.txt index 34d0c10daab..192a42b087e 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.txt @@ -12,23 +12,16 @@ Tower Data Context: Element 5 Scope: FirExplicitSimpleImportingScope Element 6 - Implicit receiver: - FirRegularClassSymbol public final class Foo : R|kotlin/Any| - Type: Foo + Scope: FirLocalScope + Properties: + FirValueParameterSymbol a: R|kotlin/String| = String(foo) + FirValueParameterSymbol b: R|kotlin/Int| = R|/a|.R|kotlin/String.length| + FirValueParameterSymbol c: R|kotlin/Long| = R|/a|.R|kotlin/String.length|.R|kotlin/Int.minus|(Int(1)).R|kotlin/Int.toLong|() FILE: [ResolvedTo(IMPORTS)] primaryConstructorParameter.kt public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Foo : R|kotlin/Any| { - public [ResolvedTo(ANNOTATION_ARGUMENTS)] constructor([ResolvedTo(ANNOTATION_ARGUMENTS)] a: R|kotlin/String| = LAZY_EXPRESSION, [ResolvedTo(ANNOTATION_ARGUMENTS)] b: R|kotlin/Int| = LAZY_EXPRESSION, [ResolvedTo(ANNOTATION_ARGUMENTS)] c: R|kotlin/Long| = LAZY_EXPRESSION): R|Foo| { - LAZY_super + public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] a: R|kotlin/String| = String(foo), [ResolvedTo(BODY_RESOLVE)] b: R|kotlin/Int| = R|/a|.R|kotlin/String.length|, [ResolvedTo(BODY_RESOLVE)] c: R|kotlin/Long| = R|/a|.R|kotlin/String.length|.R|kotlin/Int.minus|(Int(1)).R|kotlin/Int.toLong|()): R|Foo| { + super() } - public final [ResolvedTo(STATUS)] val a: R|kotlin/String| = R|/a| - public [ResolvedTo(STATUS)] get(): R|kotlin/String| - - public final [ResolvedTo(BODY_RESOLVE)] val b: R|kotlin/Int| = R|/b| - public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| - - public final [ResolvedTo(STATUS)] val c: R|kotlin/Long| = R|/c| - public [ResolvedTo(STATUS)] get(): R|kotlin/Long| - } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.kt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.kt new file mode 100644 index 00000000000..13c153a510e --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.kt @@ -0,0 +1,5 @@ +class Foo( + val a: String = "foo" + val b: Int = a.length, + val c: Long = (a.length - 1).toLong() +) \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.txt b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.txt new file mode 100644 index 00000000000..7527dd6e535 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.txt @@ -0,0 +1,34 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + +FILE: [ResolvedTo(IMPORTS)] primaryConstructorProperty.kt + public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(ANNOTATION_ARGUMENTS)] constructor([ResolvedTo(ANNOTATION_ARGUMENTS)] a: R|kotlin/String| = LAZY_EXPRESSION, [ResolvedTo(ANNOTATION_ARGUMENTS)] b: R|kotlin/Int| = LAZY_EXPRESSION, [ResolvedTo(ANNOTATION_ARGUMENTS)] c: R|kotlin/Long| = LAZY_EXPRESSION): R|Foo| { + LAZY_super + } + + public final [ResolvedTo(STATUS)] val a: R|kotlin/String| = R|/a| + public [ResolvedTo(STATUS)] get(): R|kotlin/String| + + public final [ResolvedTo(BODY_RESOLVE)] val b: R|kotlin/Int| = R|/b| + public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| + + public final [ResolvedTo(STATUS)] val c: R|kotlin/Long| = R|/c| + public [ResolvedTo(STATUS)] get(): R|kotlin/Long| + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.kt b/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.kt new file mode 100644 index 00000000000..5d407d4e43e --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.kt @@ -0,0 +1,4 @@ +class Foo { + val x: Int + get() = 42 +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.txt b/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.txt new file mode 100644 index 00000000000..e65120d40c7 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.txt @@ -0,0 +1,34 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + Element 7 + Scope: FirLocalScope + Properties: + FirBackingFieldSymbol private : R|kotlin/Int| + +FILE: [ResolvedTo(IMPORTS)] propertyAccessor.kt + public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|Foo| { + LAZY_super + } + + public final [ResolvedTo(BODY_RESOLVE)] val x: R|kotlin/Int| + public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| { + ^ Int(42) + } + + } diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameter.kt b/analysis/low-level-api-fir/testData/contextCollector/typeParameter.kt new file mode 100644 index 00000000000..2e50038b5c7 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameter.kt @@ -0,0 +1,4 @@ +class Foo { + fun <T> foo(obj: T) {} + fun other() {} +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameter.txt b/analysis/low-level-api-fir/testData/contextCollector/typeParameter.txt new file mode 100644 index 00000000000..283da8b4933 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameter.txt @@ -0,0 +1,34 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + Element 7 + Scope: FirMemberTypeParameterScope + Classifiers: + FirTypeParameterSymbol T + +FILE: [ResolvedTo(IMPORTS)] typeParameter.kt + public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|Foo| { + LAZY_super + } + + public final [ResolvedTo(BODY_RESOLVE)] fun <[ResolvedTo(BODY_RESOLVE)] T> foo([ResolvedTo(BODY_RESOLVE)] obj: R|T|): R|kotlin/Unit| { + } + + public final [ResolvedTo(STATUS)] fun other(): R|kotlin/Unit| { LAZY_BLOCK } + + } diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeBound.txt b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeBound.txt index 232cc95aaaf..f2ed415afc5 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeBound.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeBound.txt @@ -29,12 +29,12 @@ Tower Data Context: FirTypeParameterSymbol T : R|MyParam| FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromInner_typeBound.kt - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Outer<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam> : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam>(): R|test/Outer| { - super() + public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer| { + LAZY_super } - public final inner [ResolvedTo(ANNOTATION_ARGUMENTS)] class Inner<[ResolvedTo(ANNOTATION_ARGUMENTS)] T : R|MyParam|, [ResolvedTo(ANNOTATION_ARGUMENTS)] Outer(MyParam)> : R|kotlin/Any| { + public final inner [ResolvedTo(ANNOTATION_ARGUMENTS)] class Inner<[ResolvedTo(ANNOTATION_ARGUMENTS)] T : R|MyParam|, [ResolvedTo(STATUS)] Outer(MyParam)> : R|kotlin/Any| { public [ResolvedTo(BODY_RESOLVE)] test/Outer.constructor<[ResolvedTo(ANNOTATION_ARGUMENTS)] T : R|MyParam|>(): R|test/Outer.Inner| { super() } diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeRefInMember.txt b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeRefInMember.txt index 5367a798e2f..6870149cc0f 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeRefInMember.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromInner_typeRefInMember.txt @@ -35,14 +35,14 @@ Tower Data Context: FirValueParameterSymbol p: R|MyParam| FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromInner_typeRefInMember.kt - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Outer<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam> : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam>(): R|test/Outer| { - super() + public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer| { + LAZY_super } - public final inner [ResolvedTo(ANNOTATION_ARGUMENTS)] class Inner<[ResolvedTo(ANNOTATION_ARGUMENTS)] Outer(MyParam)> : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] test/Outer.constructor(): R|test/Outer.Inner| { - super() + public final inner [ResolvedTo(STATUS)] class Inner<[ResolvedTo(STATUS)] Outer(MyParam)> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] test/Outer.constructor(): R|test/Outer.Inner| { + LAZY_super } public final [ResolvedTo(BODY_RESOLVE)] fun member([ResolvedTo(BODY_RESOLVE)] p: R|MyParam|): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeBound.txt b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeBound.txt index 064c5a3533f..102cf1a3e1d 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeBound.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeBound.txt @@ -29,9 +29,9 @@ Tower Data Context: FirTypeParameterSymbol T : FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeBound.kt - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Outer<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam> : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam>(): R|test/Outer| { - super() + public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer| { + LAZY_super } public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Nested<[ResolvedTo(ANNOTATION_ARGUMENTS)] T : > : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeRefInMember.txt b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeRefInMember.txt index e71328feae7..a6a0acf18e4 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeRefInMember.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/typeParameters/declaredInClass_fromNested_typeRefInMember.txt @@ -25,14 +25,14 @@ Tower Data Context: FirValueParameterSymbol p: FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeRefInMember.kt - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Outer<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam> : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(ANNOTATION_ARGUMENTS)] MyParam>(): R|test/Outer| { - super() + public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer| { + LAZY_super } - public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class Nested : R|kotlin/Any| { - public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Outer.Nested| { - super() + public final [ResolvedTo(STATUS)] class Nested : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor(): R|test/Outer.Nested| { + LAZY_super } public final [ResolvedTo(BODY_RESOLVE)] fun member([ResolvedTo(BODY_RESOLVE)] p: ): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorSourceTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorSourceTestGenerated.java index bf10ab9e01f..e021715be44 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorSourceTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorSourceTestGenerated.java @@ -96,12 +96,36 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto runTest("analysis/low-level-api-fir/testData/contextCollector/nestedClasses.kt"); } + @Test + @TestMetadata("parameter.kt") + public void testParameter() throws Exception { + runTest("analysis/low-level-api-fir/testData/contextCollector/parameter.kt"); + } + + @Test + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("analysis/low-level-api-fir/testData/contextCollector/primaryConstructor.kt"); + } + @Test @TestMetadata("primaryConstructorParameter.kt") public void testPrimaryConstructorParameter() throws Exception { runTest("analysis/low-level-api-fir/testData/contextCollector/primaryConstructorParameter.kt"); } + @Test + @TestMetadata("primaryConstructorProperty.kt") + public void testPrimaryConstructorProperty() throws Exception { + runTest("analysis/low-level-api-fir/testData/contextCollector/primaryConstructorProperty.kt"); + } + + @Test + @TestMetadata("propertyAccessor.kt") + public void testPropertyAccessor() throws Exception { + runTest("analysis/low-level-api-fir/testData/contextCollector/propertyAccessor.kt"); + } + @Test @TestMetadata("propertyDelegateInitializer.kt") public void testPropertyDelegateInitializer() throws Exception { @@ -114,6 +138,12 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto runTest("analysis/low-level-api-fir/testData/contextCollector/simple.kt"); } + @Test + @TestMetadata("typeParameter.kt") + public void testTypeParameter() throws Exception { + runTest("analysis/low-level-api-fir/testData/contextCollector/typeParameter.kt"); + } + @Test @TestMetadata("wholeDeclaration_class.kt") public void testWholeDeclaration_class() throws Exception {