KTIJ-28167 [AA] Support SAM constructors in KtFirReferenceShortener

Utilize `FirSamResolver` to obtain the potential SAM constructor
from the classifier

Also, accept K2_SYNTHETIC_RESOLVED in the `resolveUnqualifiedAccess`,
since this is the kind of resolve success which corresponds to the
SAM constructor call resolution

^KTIJ-28167 Fixed
This commit is contained in:
Roman Golyshev
2024-01-04 01:13:38 +01:00
committed by Space Team
parent e561de8a22
commit df8c6c694a
9 changed files with 117 additions and 5 deletions
@@ -0,0 +1,13 @@
// FILE: main.kt
package test
val handler = <expr>dependency.Outer.NestedSAM {}</expr>
// FILE: dependency.kt
package dependency
class Outer {
fun interface NestedSAM {
fun method()
}
}
@@ -0,0 +1,9 @@
Before shortening: dependency.Outer.NestedSAM {}
with default settings:
[qualifier] dependency.Outer
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] dependency.Outer.NestedSAM {}
with SHORTEN_AND_STAR_IMPORT:
[qualifier] dependency.Outer.NestedSAM {}
@@ -0,0 +1,7 @@
package test
fun interface KotlinSAM {
fun method()
}
val handler = <expr>test.KotlinSAM {}</expr>
@@ -0,0 +1,10 @@
Before shortening: test.KotlinSAM {}
with default settings:
[qualifier] test.KotlinSAM {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[qualifier] test.KotlinSAM {}
with SHORTEN_AND_IMPORT:
[qualifier] test.KotlinSAM {}
with SHORTEN_AND_STAR_IMPORT:
[qualifier] test.KotlinSAM {}
@@ -0,0 +1,11 @@
// FILE: main.kt
package test
val handler = <expr>test.JavaSAM {}</expr>
// FILE: test/JavaSAM.java
package test;
public interface JavaSAM {
void method();
}
@@ -0,0 +1,10 @@
Before shortening: test.JavaSAM {}
with default settings:
[qualifier] test.JavaSAM {}
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[qualifier] test.JavaSAM {}
with SHORTEN_AND_IMPORT:
[qualifier] test.JavaSAM {}
with SHORTEN_AND_STAR_IMPORT:
[qualifier] test.JavaSAM {}