[FIR] Implement RESOLUTION_TO_CLASSIFIER

This commit is contained in:
Ivan Kochurkin
2021-06-30 18:33:20 +03:00
parent 2574dc907c
commit d4e1cded59
51 changed files with 88 additions and 483 deletions
@@ -41,7 +41,7 @@ FILE: inner.kt
public final fun test(): R|kotlin/Unit| {
lval o: R|Owner| = R|/Owner.Owner|()
R|<local>/o|.R|/Owner.foo|()
lval err: <ERROR TYPE REF: Unresolved name: Inner> = Q|Owner|.<Unresolved name: Inner>#()
lval err: <ERROR TYPE REF: Resolution to classifier> = Q|Owner|.<Resolution to classifier>#()
R|<local>/err|.<Unresolved name: baz>#()
lval i: R|Owner.Inner| = R|<local>/o|.R|/Owner.Inner.Inner|()
R|<local>/i|.R|/Owner.Inner.gau|()
@@ -31,7 +31,7 @@ class Owner {
fun test() {
val o = Owner()
o.foo()
val err = Owner.<!UNRESOLVED_REFERENCE!>Inner<!>()
val err = Owner.<!RESOLUTION_TO_CLASSIFIER!>Inner<!>()
err.<!UNRESOLVED_REFERENCE!>baz<!>()
val i = o.Inner()
i.gau()
@@ -124,6 +124,9 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
parameter<String>("expression")
parameter<ConeKotlinType>("type")
}
val RESOLUTION_TO_CLASSIFIER by error<PsiElement> {
parameter<FirRegularClassSymbol>("classSymbol")
}
}
val SUPER by object : DiagnosticGroup("Super") {
@@ -134,6 +134,7 @@ object FirErrors {
val ILLEGAL_SELECTOR by error0<PsiElement>()
val NO_RECEIVER_ALLOWED by error0<PsiElement>()
val FUNCTION_EXPECTED by error2<PsiElement, String, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val RESOLUTION_TO_CLASSIFIER by error1<PsiElement, FirRegularClassSymbol>()
// Super
val SUPER_IS_NOT_AN_EXPRESSION by error0<PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
@@ -329,6 +329,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REIFIED_TYPE_PARA
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_BOUND
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_MODIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESERVED_MEMBER_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESOLUTION_TO_CLASSIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESULT_TYPE_MISMATCH
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_NOT_ALLOWED
@@ -502,6 +503,11 @@ class FirDefaultErrorMessages {
FUNCTION_EXPECTED,
"Expression ''{0}'' of type {1} cannot be invoked as a function. The function 'invoke()' is not found", TO_STRING, RENDER_TYPE
)
map.put(
RESOLUTION_TO_CLASSIFIER,
"Constructor of inner class {0} can be called only with receiver of containing class",
SYMBOL
)
map.put(ILLEGAL_SELECTOR, "The expression cannot be a selector (occur after a dot)")
map.put(NO_RECEIVER_ALLOWED, "No receiver can be passed to this function or property")
@@ -42,6 +42,7 @@ private fun ConeDiagnostic.toFirDiagnostic(
is ConeUnresolvedQualifierError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier)
is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters)
is ConeFunctionExpectedError -> FirErrors.FUNCTION_EXPECTED.createOn(source, this.expression, this.type)
is ConeResolutionToClassifierError -> FirErrors.RESOLUTION_TO_CLASSIFIER.createOn(source, this.classSymbol)
is ConeHiddenCandidateError -> FirErrors.INVISIBLE_REFERENCE.createOn(source, this.candidateSymbol)
is ConeAmbiguityError -> when {
applicability.isSuccess -> FirErrors.OVERLOAD_RESOLUTION_AMBIGUITY.createOn(source, this.candidates.map { it.symbol })
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.calls.*
import org.jetbrains.kotlin.fir.resolve.calls.tower.FirTowerResolver
import org.jetbrains.kotlin.fir.resolve.calls.tower.TowerResolveManager
import org.jetbrains.kotlin.fir.resolve.dfa.symbol
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
import org.jetbrains.kotlin.fir.resolve.inference.ResolvedCallableReferenceAtom
import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents
@@ -605,15 +604,20 @@ class FirCallResolver(
candidate?.let { isValueParametersNotEmpty(it) } ?: candidates.any { isValueParametersNotEmpty(it) })
} else {
val singleExpectedCandidate = expectedCandidates?.singleOrNull()
if (singleExpectedCandidate?.symbol?.fir is FirRegularClass) {
ConeUnresolvedNameError(name)
// TODO: ConeResolutionToClassifierError()
var fir = singleExpectedCandidate?.symbol?.fir
if (fir is FirTypeAlias) {
fir = (fir.expandedTypeRef.coneType.fullyExpandedType(session).toSymbol(session) as? FirRegularClassSymbol)?.fir
}
if (fir is FirRegularClass) {
ConeResolutionToClassifierError(fir.symbol)
} else {
val coneType = explicitReceiver?.typeRef?.coneType
if (coneType != null && !coneType.isUnit) {
ConeFunctionExpectedError(
name.asString(),
(singleExpectedCandidate?.symbol?.fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
)
} else {
ConeUnresolvedNameError(name)
@@ -80,7 +80,7 @@ internal abstract class FirBaseTowerResolveTask(
protected fun FirScope.toScopeTowerLevel(
extensionReceiver: ReceiverValue? = null,
extensionsOnly: Boolean = false,
includeInnerConstructors: Boolean = true
includeInnerConstructors: Boolean = extensionReceiver != null,
): ScopeTowerLevel = ScopeTowerLevel(
session, components, this,
extensionReceiver, extensionsOnly, includeInnerConstructors
@@ -54,6 +54,10 @@ class ConeFunctionExpectedError(val expression: String, val type: ConeKotlinType
override val reason: String get() = "Expression '$expression' of type '$type' cannot be invoked as a function"
}
class ConeResolutionToClassifierError(val classSymbol: FirRegularClassSymbol) : ConeDiagnostic() {
override val reason: String get() = "Resolution to classifier"
}
class ConeHiddenCandidateError(
val candidateSymbol: FirBasedSymbol<*>
) : ConeDiagnostic() {
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import A.Inner
class A {
inner class Inner
}
fun main() {
::Inner
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import A.Inner
@@ -1,34 +0,0 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
import kotlin.reflect.KFunction1
class A {
inner class Inner
fun main() {
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, Inner>>(y)
}
companion object {
fun main() {
::Inner
val y = A::Inner
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
}
class B {
fun main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
checkSubtype<KFunction1<A, A.Inner>>(y)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
@@ -43,7 +43,7 @@ fun f() {
C.O
C.O.InO
C.A()
C.<!UNRESOLVED_REFERENCE!>B<!>()
C.<!RESOLUTION_TO_CLASSIFIER!>B<!>()
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
@@ -43,7 +43,7 @@ fun f() {
C.O
C.O.InO
C.A()
C.<!UNRESOLVED_REFERENCE!>B<!>()
C.<!RESOLUTION_TO_CLASSIFIER!>B<!>()
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
@@ -6,7 +6,7 @@ typealias FunAlias = IsolatedFunFace
fun referIsolatedFunFace(iff: IsolatedFunFace) {}
fun callIsolatedFunFace() {
referIsolatedFunFace(<!UNRESOLVED_REFERENCE!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!UNRESOLVED_REFERENCE!>FunAlias<!> {})
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>IsolatedFunFace<!> {})
referIsolatedFunFace(<!RESOLUTION_TO_CLASSIFIER!>FunAlias<!> {})
referIsolatedFunFace(<!ARGUMENT_TYPE_MISMATCH!>{}<!>)
}
@@ -1,32 +0,0 @@
class Outer1 {
class Nested
class C1 { val b = Nested() }
class C2(val b: Any = Nested())
inner class C3 { val b = Nested() }
inner class C4(val b: Any = Nested())
inner class Inner
class C5 { val b = Inner() }
class C6(val b: Any = Inner())
inner class C7 { val b = Inner() }
inner class C8(val b: Any = Inner())
}
class Outer2 {
class Nested {
fun foo() = Outer2()
fun bar() = Inner()
}
inner class Inner {
fun foo() = Outer2()
fun bar() = Nested()
}
fun foo() {
Nested()
Inner()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Outer1 {
class Nested
@@ -1,36 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
package abc
class Outer {
inner class Inner() {
constructor(x: Int) : this() {}
}
companion object {
fun baz() {
Inner()
Inner(1)
}
}
}
fun foo() {
Outer.<!UNRESOLVED_REFERENCE!>Inner<!>()
Outer.<!UNRESOLVED_REFERENCE!>Inner<!>(1)
}
// FILE: imported.kt
import abc.Outer
import abc.Outer.Inner
fun bar() {
Inner()
Inner(1)
with(Outer()) {
Inner()
Inner(1)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
// FILE: Outer.kt
@@ -12,8 +12,8 @@ class Outer {
fun baz() {
// Diagnostic here could be better (why can't I call the constructor above?)
Inner()
Inner(1)
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
Inner("")
}
}
@@ -31,8 +31,8 @@ import abc.Outer.Inner
import abc.Outer.Companion.Inner
fun bar() {
Inner()
Inner(1)
Inner(<!NO_VALUE_FOR_PARAMETER!>)<!>
Inner(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
Inner("")
with(Outer()) {
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = InnerClass()
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -10,7 +10,7 @@ class Test {
}
fun more(): InnerClass {
val b = InnerClass()
val b = <!RESOLUTION_TO_CLASSIFIER!>InnerClass<!>()
val testVal = <!UNRESOLVED_REFERENCE!>inClass<!>
<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -1,17 +0,0 @@
class Outer {
class Nested {
class NestedNested
}
inner class Inner {
inner class InnerInner
}
}
fun f1() = Outer()
fun f2() = Outer.Nested()
fun f3() = Outer.Nested.NestedNested()
fun f4() = Outer.<!UNRESOLVED_REFERENCE!>Inner<!>()
fun f5() = Outer.Inner.<!UNRESOLVED_REFERENCE!>InnerInner<!>()
fun f6() = Outer().Inner()
fun f7() = Outer().Inner().InnerInner()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Outer {
class Nested {
class NestedNested
@@ -1,25 +0,0 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo
expect class Bar()
expect class Baz constructor()
expect class FooBar {
constructor()
}
fun test() {
<!UNRESOLVED_REFERENCE!>Foo<!>()
Bar()
Baz()
FooBar()
}
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual class Foo
actual class Bar
actual class Baz
actual class FooBar
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
@@ -1,16 +0,0 @@
// KT-4827 UOE at PackageType.throwException()
// EA-53605
public interface TestInterface {
}
class C {
inner class I {
}
}
fun f() {
<!UNRESOLVED_REFERENCE!>TestInterface<!>()
C.<!UNRESOLVED_REFERENCE!>I<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-4827 UOE at PackageType.throwException()
// EA-53605
@@ -1,6 +0,0 @@
interface MutableMatrix<T> {
}
fun <T> toMutableMatrix(): MutableMatrix<T> {
return <!UNRESOLVED_REFERENCE!>MutableMatrix<!><T>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface MutableMatrix<T> {
}
@@ -6,7 +6,7 @@ object B
class C
fun test() {
val interface_as_fun = <!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = <!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = <!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = <!INVISIBLE_REFERENCE!>B<!>()
@@ -8,7 +8,7 @@ object X {
}
fun testX() {
val interface_as_fun = X.<!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = X.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = X.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = X.<!INVISIBLE_REFERENCE!>B<!>()
@@ -23,7 +23,7 @@ class Y {
}
fun testY() {
val interface_as_fun = Y.<!UNRESOLVED_REFERENCE!>A<!>()
val interface_as_fun = Y.<!RESOLUTION_TO_CLASSIFIER!>A<!>()
val interface_as_val = Y.<!NO_COMPANION_OBJECT!>A<!>
val object_as_fun = Y.<!INVISIBLE_REFERENCE!>B<!>()
@@ -4,7 +4,7 @@ class A(
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = Inner(),
inn2: Inner = <!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
@@ -19,7 +19,7 @@ class A(
n: Nested = foo(),
n2: Nested = Nested(),
inn: Inner = null!!,
inn2: Inner = Inner(),
inn2: Inner = <!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i: Interface = null!!,
c: Int = CONST,
cc: Int = Companion.CONST,
@@ -31,7 +31,7 @@ class A(
foo(),
Nested(),
inn,
Inner(),
<!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
i,
CONST,
Companion.CONST,
@@ -1,50 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface I
open class S(
n: A.Nested,
n2: A.Nested,
inn: A.Inner,
c: Int,
cc: Int,
cn: Int,
ci: Int,
t1: Int,
t2: Int
) : I
class A : I by S(
foo(),
Nested(),
Inner(),
CONST,
Companion.CONST,
Nested.CONST,
Interface.CONST,
<!UNRESOLVED_REFERENCE!>a<!>,
<!UNRESOLVED_REFERENCE!>b<!>()
) {
class Nested {
companion object {
const val CONST = 2
}
}
inner class Inner
interface Interface {
companion object {
const val CONST = 3
}
}
val a = 1
fun b() = 2
companion object {
const val CONST = 1
fun foo(): Nested = null!!
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface I
@@ -1,48 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class S(
n: A.Nested,
n2: A.Nested,
inn: A.Inner,
c: Int,
cc: Int,
cn: Int,
ci: Int,
t1: Int,
t2: Int
)
class A : S (
foo(),
Nested(),
Inner(),
CONST,
Companion.CONST,
Nested.CONST,
Interface.CONST,
<!UNRESOLVED_REFERENCE!>a<!>,
<!UNRESOLVED_REFERENCE!>b<!>()
) {
class Nested {
companion object {
const val CONST = 2
}
}
inner class Inner
interface Interface {
companion object {
const val CONST = 3
}
}
val a = 1
fun b() = 2
companion object {
const val CONST = 1
fun foo(): Nested = null!!
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class S(
@@ -17,7 +17,7 @@ class A : S {
constructor() : super(
foo(),
Nested(),
Inner(),
<!RESOLUTION_TO_CLASSIFIER!>Inner<!>(),
CONST,
Companion.CONST,
Nested.CONST,
@@ -35,10 +35,10 @@ class E: A() {
object Z {
init {
B().foo()
B().<!UNRESOLVED_REFERENCE!>bar<!>()
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
<!RESOLUTION_TO_CLASSIFIER!>B<!>().<!UNRESOLVED_REFERENCE!>bar<!>()
D()
<!RESOLUTION_TO_CLASSIFIER!>D<!>()
<!UNRESOLVED_REFERENCE!>C<!>()
}
}
@@ -60,7 +60,7 @@ class F: A() {
companion object {
init {
B().fas()
D().f()
<!RESOLUTION_TO_CLASSIFIER!>D<!>().<!UNRESOLVED_REFERENCE!>f<!>()
}
}
}
@@ -1,90 +0,0 @@
// FILE: A.java
public interface A {
public class A_S { // static
}
}
// FILE: B.java
public class B {
public static class B_S {
}
public class B_ {
}
}
// FILE: C.java
public class C extends B implements A {
}
// FILE: 1.kt
class X: A {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
A.A_S()
X.<!UNRESOLVED_REFERENCE!>A_S<!>()
}
object xD {
val a_: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
}
}
}
class Y: B() {
val b_: B_ = null!!
val b_s: B_S = null!!
init {
B_()
B.<!UNRESOLVED_REFERENCE!>B_<!>()
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
B_S()
B.B_S()
Y.<!UNRESOLVED_REFERENCE!>B_S<!>()
}
object X {
val b_: B_ = null!!
val b_s: B_S = null!!
init {
B_()
B_S()
}
}
}
class Z: C() {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
val b_: B_ = null!!
val b_s: B_S = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
B_()
B_S()
}
object X {
val a_s: <!UNRESOLVED_REFERENCE!>A_S<!> = null!!
val b_: B_ = null!!
val b_s: B_S = null!!
init {
<!UNRESOLVED_REFERENCE!>A_S<!>()
B_()
B_S()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
public class A_S { // static
@@ -1,82 +0,0 @@
// FILE: A.java
public interface A {
class A_S {
}
}
// FILE: B.java
public class B {
static class B_S {
}
class B_ {
}
}
// FILE: C.java
public class C extends B implements A {
}
// FILE: 1.kt
interface E {
class E_S
}
open class D: C(), E
// FILE: F.java
public class F extends D {
}
// FILE: 2.kt
class X: D() {
init {
B_()
B.<!UNRESOLVED_REFERENCE!>B_<!>()
C.<!UNRESOLVED_REFERENCE!>B_<!>()
D.<!UNRESOLVED_REFERENCE!>B_<!>()
X.<!UNRESOLVED_REFERENCE!>B_<!>()
<!UNRESOLVED_REFERENCE!>A_S<!>()
A.A_S()
C.<!UNRESOLVED_REFERENCE!>A_S<!>()
D.<!UNRESOLVED_REFERENCE!>A_S<!>()
X.<!UNRESOLVED_REFERENCE!>A_S<!>()
B_S()
B.B_S()
C.<!UNRESOLVED_REFERENCE!>B_S<!>()
D.<!UNRESOLVED_REFERENCE!>B_S<!>()
X.<!UNRESOLVED_REFERENCE!>B_S<!>()
<!UNRESOLVED_REFERENCE!>E_S<!>()
E.E_S()
D.<!UNRESOLVED_REFERENCE!>E_S<!>()
X.<!UNRESOLVED_REFERENCE!>E_S<!>()
}
}
class Y: F() {
init {
B_()
F.<!UNRESOLVED_REFERENCE!>B_<!>()
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
<!UNRESOLVED_REFERENCE!>A_S<!>()
F.<!UNRESOLVED_REFERENCE!>A_S<!>()
Y.<!UNRESOLVED_REFERENCE!>A_S<!>()
B_S()
F.<!UNRESOLVED_REFERENCE!>B_S<!>()
Y.<!UNRESOLVED_REFERENCE!>B_S<!>()
<!UNRESOLVED_REFERENCE!>E_S<!>()
F.<!UNRESOLVED_REFERENCE!>E_S<!>()
Y.<!UNRESOLVED_REFERENCE!>E_S<!>()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public interface A {
class A_S {
@@ -6,6 +6,6 @@ class Outer {
}
constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x + Inner().prop <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop) :
this(x + Inner().prop <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop)
constructor(x: Int, y: Int, z: Int = <!TYPE_MISMATCH!>x <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!RESOLUTION_TO_CLASSIFIER!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop<!>) :
this(<!ARGUMENT_TYPE_MISMATCH!>x <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> <!RESOLUTION_TO_CLASSIFIER!>Inner<!>().<!UNRESOLVED_REFERENCE!>prop<!> + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>Inner<!>().prop<!>)
}
@@ -17,8 +17,8 @@ typealias TI = Interface
object AnObject
typealias TO = AnObject
val test6 = <!UNRESOLVED_REFERENCE!>TI<!>()
val test6a = <!UNRESOLVED_REFERENCE!>Interface<!>()
val test6 = <!RESOLUTION_TO_CLASSIFIER!>TI<!>()
val test6a = <!RESOLUTION_TO_CLASSIFIER!>Interface<!>()
val test7 = <!INVISIBLE_REFERENCE!>TO<!>()
val test7a = <!INVISIBLE_REFERENCE!>AnObject<!>()
@@ -2,5 +2,5 @@ interface IFoo
typealias Test = IFoo
val testAsFunction = <!UNRESOLVED_REFERENCE!>Test<!>()
val testAsValue = Test
val testAsFunction = <!RESOLUTION_TO_CLASSIFIER!>Test<!>()
val testAsValue = Test
@@ -26,8 +26,8 @@ class Outer {
}
typealias Test5 = Outer.Inner
val test5 = <!UNRESOLVED_REFERENCE!>Test5<!>()
val test5a = Outer.<!UNRESOLVED_REFERENCE!>Inner<!>()
val test5 = <!RESOLUTION_TO_CLASSIFIER!>Test5<!>()
val test5a = Outer.<!RESOLUTION_TO_CLASSIFIER!>Inner<!>()
val test5b = Outer.<!UNRESOLVED_REFERENCE!>TestInner<!>()
val test5c = Outer().<!UNRESOLVED_REFERENCE!>TestInner<!>()
val test5d = Outer().Inner()
@@ -335,6 +335,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.RESOLUTION_TO_CLASSIFIER) { firDiagnostic ->
ResolutionToClassifierImpl(
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.a.fir),
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirErrors.SUPER_IS_NOT_AN_EXPRESSION) { firDiagnostic ->
SuperIsNotAnExpressionImpl(
firDiagnostic as FirPsiDiagnostic,
@@ -263,6 +263,11 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val type: KtType
}
abstract class ResolutionToClassifier : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = ResolutionToClassifier::class
abstract val classSymbol: KtClassLikeSymbol
}
abstract class SuperIsNotAnExpression : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = SuperIsNotAnExpression::class
}
@@ -390,6 +390,14 @@ internal class FunctionExpectedImpl(
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class ResolutionToClassifierImpl(
override val classSymbol: KtClassLikeSymbol,
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.ResolutionToClassifier(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class SuperIsNotAnExpressionImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,