KTIJ-26024 [Analysis API] Provide correct context for class header from FirTowerDataContextAllElementsCollector

To correctly provide the context for class header resolution, we save
the additional copy of the context right before `withRegularClass`
wrapper call in `LLFirBodyLazyResolver`. Otherwise we would have to
clear the existing context by hand, which is too cumbersome
(if at all possible)

^KTIJ-26024 Fixed
^KTIJ-24832 Fixed
This commit is contained in:
Roman Golyshev
2023-06-28 16:42:41 +02:00
committed by Space Team
parent d7d2c1f260
commit 88450c69b3
27 changed files with 423 additions and 4 deletions
@@ -0,0 +1,8 @@
// FILE: main.kt
abstract class Outer {
annotation class Ann
}
<expr>@Outer.Ann</expr>
class Foo : Outer()
@@ -0,0 +1,7 @@
Before shortening: @Outer.Ann
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Ann
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Ann
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
annotation class Ann
}
class Foo <expr>@Outer.Ann</expr> constructor() : Outer()
@@ -0,0 +1,8 @@
Before shortening: @Outer.Ann
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] Outer.Ann
with SHORTEN_AND_IMPORT:
[type] Outer.Ann
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Ann
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
annotation class Ann
}
class Foo(<expr>@Outer.Ann</expr> val p: Any) : Outer()
@@ -0,0 +1,8 @@
Before shortening: @Outer.Ann
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] Outer.Ann
with SHORTEN_AND_IMPORT:
[type] Outer.Ann
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Ann
@@ -0,0 +1,8 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
context(<expr>Outer.Nested</expr>)
class Foo : Outer.Nested()
@@ -0,0 +1,7 @@
Before shortening: Outer.Nested
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
class Foo(<expr>val param: Outer.Nested = Outer.Nested()</expr>) : Outer.Nested()
@@ -0,0 +1,11 @@
Before shortening: val param: Outer.Nested = Outer.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] Outer.Nested
[qualifier] Outer.Nested()
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
[qualifier] Outer.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested
[qualifier] Outer.Nested()
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
<expr>class Foo : Outer.Nested { constructor(): super() }</expr>
@@ -0,0 +1,7 @@
Before shortening: class Foo : Outer.Nested { constructor(): super() }
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
<expr>class Foo : Outer.Nested()</expr>
@@ -0,0 +1,7 @@
Before shortening: class Foo : Outer.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested
@@ -0,0 +1,9 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested(a: Any) : Outer()
class OtherNested
}
class Foo : Outer.Nested(<expr>Outer.OtherNested()</expr>)
@@ -0,0 +1,8 @@
Before shortening: Outer.OtherNested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[qualifier] Outer.OtherNested()
with SHORTEN_AND_IMPORT:
[qualifier] Outer.OtherNested()
with SHORTEN_AND_STAR_IMPORT:
[qualifier] Outer.OtherNested()
@@ -0,0 +1,11 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer(), Marker
interface class Marker
class MarkerImpl() : Marker
}
class Foo : Outer.Nested(), <expr>Outer.Marker by Outer.MarkerImpl()</expr>
@@ -0,0 +1,10 @@
Before shortening: Outer.Marker by Outer.MarkerImpl()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[qualifier] Outer.MarkerImpl()
with SHORTEN_AND_IMPORT:
[type] Outer.Marker
[qualifier] Outer.MarkerImpl()
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Marker
[qualifier] Outer.MarkerImpl()
@@ -0,0 +1,9 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested<T> : Outer()
class OtherNested
}
class Foo : <expr>Outer.Nested<Outer.OtherNested></expr> { constructor(): super() }
@@ -0,0 +1,9 @@
Before shortening: Outer.Nested<Outer.OtherNested>
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested<Outer.OtherNested>
[type] Outer.OtherNested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested<Outer.OtherNested>
[type] Outer.OtherNested
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
class Foo<T : <expr>Outer.Nested</expr>> : Outer.Nested()
@@ -0,0 +1,7 @@
Before shortening: Outer.Nested
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested