[LL API] Check declaration resolution status in 'ContextCollector' tests
This commit is contained in:
@@ -27,3 +27,17 @@ Tower Data Context:
|
|||||||
Label: Bar
|
Label: Bar
|
||||||
Element 9
|
Element 9
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] contextReceivers.kt
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Foo : R|kotlin/Any| {
|
||||||
|
public abstract [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Int|
|
||||||
|
|
||||||
|
}
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Bar : R|kotlin/Any| {
|
||||||
|
public abstract [ResolvedTo(CONTRACTS)] fun bar(): R|kotlin/Int|
|
||||||
|
|
||||||
|
}
|
||||||
|
context(R|Foo|, R|Bar|)
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/Unit| {
|
||||||
|
this@R|/test|.R|/Foo.foo|().R|kotlin/Int.plus|(this@R|/test|.R|/Bar.bar|())
|
||||||
|
}
|
||||||
+17
@@ -28,3 +28,20 @@ Tower Data Context:
|
|||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
Element 10
|
Element 10
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] contextReceiversClass.kt
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Foo : R|kotlin/Any| {
|
||||||
|
public abstract [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Int|
|
||||||
|
|
||||||
|
}
|
||||||
|
context(R|Foo|)
|
||||||
|
public final [ResolvedTo(STATUS)] class Test : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] constructor(): R|Test| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/Unit| {
|
||||||
|
this@R|/Test|.R|/Foo.foo|()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,3 +21,10 @@ Tower Data Context:
|
|||||||
Type: kotlin/String
|
Type: kotlin/String
|
||||||
Element 9
|
Element 9
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] extensionFunction.kt
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun R|kotlin/String|.test(): R|kotlin/Unit| {
|
||||||
|
R|/consume|(this@R|/test|)
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun consume([ResolvedTo(CONTRACTS)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
@@ -33,3 +33,19 @@ Tower Data Context:
|
|||||||
Type: kotlin/Int
|
Type: kotlin/Int
|
||||||
Element 14
|
Element 14
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] extensionLambdas.kt
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/Unit| {
|
||||||
|
R|/block|<R|kotlin/String|>(String(foo), <L> = [ResolvedTo(BODY_RESOLVE)] foo@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
|
||||||
|
R|/block|<R|kotlin/Int|>(Int(42), <L> = [ResolvedTo(BODY_RESOLVE)] num@fun R|kotlin/Int|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
|
||||||
|
R|/consume|(this@R|special/anonymous|.R|kotlin/String.length|.R|kotlin/Int.plus|(this@R|special/anonymous|))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun <[ResolvedTo(CONTRACTS)] T> block([ResolvedTo(CONTRACTS)] reciever: R|T|, [ResolvedTo(CONTRACTS)] block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||||
|
receiver#.block#()
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun consume([ResolvedTo(CONTRACTS)] num: R|kotlin/Int|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ Tower Data Context:
|
|||||||
Element 8
|
Element 8
|
||||||
Scope: FirNestedClassifierScopeImpl
|
Scope: FirNestedClassifierScopeImpl
|
||||||
Classifiers:
|
Classifiers:
|
||||||
FirRegularClassSymbol public final inner class Bar<B, F> : R|kotlin/Any|
|
FirRegularClassSymbol public final inner class Bar<B, Outer(F)> : R|kotlin/Any|
|
||||||
Element 9
|
Element 9
|
||||||
Implicit receiver:
|
Implicit receiver:
|
||||||
FirRegularClassSymbol public final class Foo<F> : R|kotlin/Any|
|
FirRegularClassSymbol public final class Foo<F> : R|kotlin/Any|
|
||||||
@@ -31,7 +31,7 @@ Tower Data Context:
|
|||||||
FirTypeParameterSymbol B
|
FirTypeParameterSymbol B
|
||||||
Element 11
|
Element 11
|
||||||
Implicit receiver:
|
Implicit receiver:
|
||||||
FirRegularClassSymbol public final inner class Bar<B, F> : R|kotlin/Any|
|
FirRegularClassSymbol public final inner class Bar<B, Outer(F)> : R|kotlin/Any|
|
||||||
Type: test/Foo.Bar<B, F>
|
Type: test/Foo.Bar<B, F>
|
||||||
Element 12
|
Element 12
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
@@ -40,3 +40,24 @@ Tower Data Context:
|
|||||||
FirValueParameterSymbol f: R|F|
|
FirValueParameterSymbol f: R|F|
|
||||||
Element 13
|
Element 13
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] innerClasses.kt
|
||||||
|
public final [ResolvedTo(STATUS)] class Foo<[ResolvedTo(STATUS)] F> : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] F>(): R|test/Foo<F>| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final inner [ResolvedTo(STATUS)] class Bar<[ResolvedTo(STATUS)] B, [ResolvedTo(STATUS)] Outer(F)> : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] test/Foo<F>.constructor<[ResolvedTo(STATUS)] B>(): R|test/Foo.Bar<B, F>| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test([ResolvedTo(BODY_RESOLVE)] f: R|F|, [ResolvedTo(BODY_RESOLVE)] b: R|B|): R|kotlin/Unit| {
|
||||||
|
R|test/consume<Inapplicable(INAPPLICABLE): test/consume>#|(R|<local>/f|)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun consume([ResolvedTo(CONTRACTS)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
@@ -29,3 +29,17 @@ Tower Data Context:
|
|||||||
FirValueParameterSymbol n: R|kotlin/Int|
|
FirValueParameterSymbol n: R|kotlin/Int|
|
||||||
Element 12
|
Element 12
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] lambdaArguments.kt
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/Unit| {
|
||||||
|
R|/block|<R|kotlin/String|>(String(foo), <L> = [ResolvedTo(BODY_RESOLVE)] block@fun <anonymous>([ResolvedTo(BODY_RESOLVE)] s: R|kotlin/String|): R|kotlin/Unit| <inline=NoInline> {
|
||||||
|
R|/block|<R|kotlin/Int|>(Int(42), <L> = [ResolvedTo(BODY_RESOLVE)] block@fun <anonymous>([ResolvedTo(BODY_RESOLVE)] n: R|kotlin/Int|): R|kotlin/Unit| <inline=NoInline> {
|
||||||
|
R|<local>/s|.R|kotlin/String.length|.R|kotlin/Int.plus|(R|<local>/n|)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun <[ResolvedTo(CONTRACTS)] T> block([ResolvedTo(CONTRACTS)] obj: R|T|, [ResolvedTo(CONTRACTS)] block: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||||
|
block#(obj#)
|
||||||
|
}
|
||||||
@@ -31,3 +31,24 @@ Tower Data Context:
|
|||||||
FirValueParameterSymbol b: R|B|
|
FirValueParameterSymbol b: R|B|
|
||||||
Element 11
|
Element 11
|
||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] nestedClasses.kt
|
||||||
|
public final [ResolvedTo(STATUS)] class Foo<[ResolvedTo(STATUS)] F> : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] F>(): R|test/Foo<F>| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [ResolvedTo(STATUS)] class Bar<[ResolvedTo(STATUS)] B> : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] B>(): R|test/Foo.Bar<B>| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test([ResolvedTo(BODY_RESOLVE)] b: R|B|): R|kotlin/Unit| {
|
||||||
|
R|test/consume<Inapplicable(INAPPLICABLE): test/consume>#|(R|<local>/b|)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun consume([ResolvedTo(CONTRACTS)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
@@ -8,3 +8,12 @@ class Foo {
|
|||||||
<expr>print(x)</expr>
|
<expr>print(x)</expr>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Unrelated {
|
||||||
|
val unrelatedMember: Boolean
|
||||||
|
get() = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unrelatedFunction(): Int {
|
||||||
|
return "foo".length
|
||||||
|
}
|
||||||
@@ -25,3 +25,29 @@ Tower Data Context:
|
|||||||
Scope: FirLocalScope
|
Scope: FirLocalScope
|
||||||
Properties:
|
Properties:
|
||||||
FirPropertySymbol lval x: R|kotlin/Float|
|
FirPropertySymbol lval x: R|kotlin/Float|
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] simple.kt
|
||||||
|
public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| {
|
||||||
|
public [ResolvedTo(STATUS)] constructor(): R|foo/Foo| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [ResolvedTo(STATUS)] val a: R|kotlin/Int|
|
||||||
|
public [ResolvedTo(STATUS)] get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] p: R|kotlin/String|): R|kotlin/Unit| {
|
||||||
|
[ResolvedTo(BODY_RESOLVE)] lval x: R|kotlin/Float| = Float(1.0)
|
||||||
|
<Unresolved name: print>#(R|<local>/x|)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? [ResolvedTo(RAW_FIR)] class Unrelated : R|kotlin/Any| {
|
||||||
|
public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Unrelated| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [ResolvedTo(RAW_FIR)] val unrelatedMember: Boolean
|
||||||
|
public? [ResolvedTo(RAW_FIR)] get(): Boolean { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? [ResolvedTo(RAW_FIR)] fun unrelatedFunction(): Int { LAZY_BLOCK }
|
||||||
@@ -26,3 +26,17 @@ Smart Casts:
|
|||||||
Types:
|
Types:
|
||||||
Foo
|
Foo
|
||||||
kotlin/Any
|
kotlin/Any
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] smartCastArgument.kt
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test([ResolvedTo(BODY_RESOLVE)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
when () {
|
||||||
|
(R|<local>/obj| is R|Foo|) -> {
|
||||||
|
R|/consume|(R|<local>/obj|)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun consume([ResolvedTo(CONTRACTS)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
+21
@@ -29,3 +29,24 @@ Smart Casts:
|
|||||||
Foo
|
Foo
|
||||||
kotlin/Any
|
kotlin/Any
|
||||||
Bar
|
Bar
|
||||||
|
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] smartCastReceiverArgument.kt
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public abstract [ResolvedTo(STATUS)] interface Bar : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(BODY_RESOLVE)] fun test([ResolvedTo(BODY_RESOLVE)] obj: R|kotlin/Any|): R|kotlin/Unit| {
|
||||||
|
when () {
|
||||||
|
(R|<local>/obj| is R|Foo|) -> {
|
||||||
|
when () {
|
||||||
|
(R|<local>/obj| is R|Bar|) -> {
|
||||||
|
R|<local>/obj|.R|/consume|(R|<local>/obj|)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final [ResolvedTo(CONTRACTS)] fun R|Bar|.consume([ResolvedTo(CONTRACTS)] obj: R|Foo|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
+11
-6
@@ -51,17 +51,22 @@ abstract class AbstractContextCollectorTest : AbstractAnalysisApiBasedSingleModu
|
|||||||
val elementContext = ContextCollector.process(firFile, sessionHolder, targetElement)
|
val elementContext = ContextCollector.process(firFile, sessionHolder, targetElement)
|
||||||
?: error("Context not found for element $targetElement")
|
?: error("Context not found for element $targetElement")
|
||||||
|
|
||||||
val actualText = ElementContextRenderer.render(elementContext)
|
val firRenderer = FirRenderer.withResolvePhase()
|
||||||
|
|
||||||
|
val actualText = buildString {
|
||||||
|
ElementContextRenderer.render(elementContext, this)
|
||||||
|
appendLine()
|
||||||
|
append(firRenderer.renderElementAsString(firFile, trim = true))
|
||||||
|
}
|
||||||
|
|
||||||
testServices.assertions.assertEqualsToTestDataFileSibling(actualText)
|
testServices.assertions.assertEqualsToTestDataFileSibling(actualText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private object ElementContextRenderer {
|
private object ElementContextRenderer {
|
||||||
fun render(context: ContextCollector.Context): String {
|
fun render(context: ContextCollector.Context, builder: StringBuilder) = with(builder) {
|
||||||
return buildString {
|
renderTowerDataContext(context.towerDataContext)
|
||||||
renderTowerDataContext(context.towerDataContext)
|
renderSmartCasts(context.smartCasts)
|
||||||
renderSmartCasts(context.smartCasts)
|
|
||||||
}.trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun StringBuilder.renderTowerDataContext(towerDataContext: FirTowerDataContext) {
|
private fun StringBuilder.renderTowerDataContext(towerDataContext: FirTowerDataContext) {
|
||||||
|
|||||||
Reference in New Issue
Block a user