K2: report MISSING_DEPENDENCY_CLASS in case of error type of expression

This commit is intended to get a more clear diagnostic in case when
the type checker creates an inconsistent error type due to some
classifier inaccessibility. Before this commit, we reported simply
ARGUMENT_TYPE_MISMATCH (see test). Now we report also
MISSING_DEPENDENCY_CLASS by analyzing an error type of a qualified
expression.

#KT-66356 Fixed
This commit is contained in:
Mikhail Glukhikh
2024-03-18 12:19:55 +01:00
committed by Space Team
parent 2d755aabe7
commit 3fbb7bc920
7 changed files with 34 additions and 7 deletions
@@ -0,0 +1,5 @@
// -- Module: <missing> --
// -- Module: <library> --
// -- Module: <main> --
@@ -0,0 +1,3 @@
/module_main_BoxedInaccessibleGenericTypeUsedByDependencies.fir.kt:(84,112): error: Cannot access class 'InaccessibleType'. Check your module classpath for missing or conflicting dependencies.
/module_main_BoxedInaccessibleGenericTypeUsedByDependencies.fir.kt:(84,114): error: Argument type mismatch: actual type is 'Box<CapturedType(out ERROR CLASS: Inconsistent type: InaccessibleType<kotlin/Any?> (parameters.size = 0, arguments.size = 1))>', but 'Box<InaccessibleType<kotlin.Any?>>' was expected.
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
// MODULE: missing
class InaccessibleType<ITTP>
@@ -12,5 +13,5 @@ fun consumeBoxedInaccessibleType(arg: Box<InaccessibleType<Any?>>) {}
// MODULE: main(library)
fun test() {
consumeBoxedInaccessibleType(<!ARGUMENT_TYPE_MISMATCH("Box<InaccessibleType<kotlin.Any?>>; Box<CapturedType(out ERROR CLASS: Inconsistent type: InaccessibleType<kotlin/Any?> (parameters.size = 0, arguments.size = 1))>")!>produceBoxedInaccessibleType()<!>)
consumeBoxedInaccessibleType(<!ARGUMENT_TYPE_MISMATCH!><!MISSING_DEPENDENCY_CLASS!>produceBoxedInaccessibleType<!>()<!>)
}
@@ -1,3 +1,4 @@
// RENDER_DIAGNOSTICS_FULL_TEXT
// MODULE: missing
class InaccessibleType<ITTP>