[Analysis API] Ignore FirClassUseSiteMemberScope scopes in KtFirReferenceShortener

Those scopes always contain all nested classifiers,
while only some of them are available without
explicit import. There are other, more reliable
scopes (like FirNestedClassifierScopeWithSubstitution)
which are stricter about which classifiers
they recognise as valid

^KTIJ-24684 Fixed
^KTIJ-24662 Fixed
This commit is contained in:
Ilya Kirillov
2022-10-28 10:35:23 +02:00
committed by teamcity
parent d783bbe5e9
commit 3ec032212c
15 changed files with 190 additions and 3 deletions
@@ -0,0 +1,9 @@
// FILE: main.kt
interface MyInterface {
class Nested
}
class Foo : MyInterface {
<expr>val prop: MyInterface.Nested = MyInterface.Nested()</expr>
}
@@ -0,0 +1,9 @@
Before shortening: val prop: MyInterface.Nested = MyInterface.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
@@ -0,0 +1,10 @@
// FILE: main.kt
import MyInterface.Nested
interface MyInterface {
class Nested
}
class Foo : MyInterface {
<expr>val prop: MyInterface.Nested = MyInterface.Nested()</expr>
}
@@ -0,0 +1,11 @@
Before shortening: val prop: MyInterface.Nested = MyInterface.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
@@ -0,0 +1,8 @@
// FILE: main.kt
open class MyBaseClass {
class Nested
}
class Foo : MyBaseClass() {
<expr>val prop: MyBaseClass.Nested = MyBaseClass.Nested()</expr>
}
@@ -0,0 +1,11 @@
Before shortening: val prop: MyBaseClass.Nested = MyBaseClass.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] MyBaseClass.Nested
[qualifier] MyBaseClass.Nested()
with SHORTEN_AND_IMPORT:
[type] MyBaseClass.Nested
[qualifier] MyBaseClass.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyBaseClass.Nested
[qualifier] MyBaseClass.Nested()
@@ -0,0 +1,6 @@
// FILE: main.kt
interface MyInterface {
class Nested
<expr>val prop: MyInterface.Nested get() = MyInterface.Nested()</expr>
}
@@ -0,0 +1,11 @@
Before shortening: val prop: MyInterface.Nested get() = MyInterface.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
@@ -0,0 +1,8 @@
// FILE: main.kt
interface MyInterface {
class Nested
}
fun MyInterface.foo() {
<expr>val prop: MyInterface.Nested = MyInterface.Nested()</expr>
}
@@ -0,0 +1,9 @@
Before shortening: val prop: MyInterface.Nested = MyInterface.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyInterface.Nested
[qualifier] MyInterface.Nested()
@@ -0,0 +1,8 @@
// FILE: main.kt
open class MyBaseClass {
class Nested
}
fun MyBaseClass.foo() {
<expr>val prop: MyBaseClass.Nested = MyBaseClass.Nested()</expr>
}
@@ -0,0 +1,9 @@
Before shortening: val prop: MyBaseClass.Nested = MyBaseClass.Nested()
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] MyBaseClass.Nested
[qualifier] MyBaseClass.Nested()
with SHORTEN_AND_STAR_IMPORT:
[type] MyBaseClass.Nested
[qualifier] MyBaseClass.Nested()