K2: report MISSING_DEPENDENCY_CLASS for lambda parameters if needed

#KT-62525 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-12-01 15:20:28 +01:00
committed by Space Team
parent c03830556f
commit 06ce57ea56
23 changed files with 325 additions and 41 deletions
@@ -0,0 +1,10 @@
// -- Module: <m1> --
// -- Module: <m2> --
// -- Module: <m3> --
// -- Module: <m4> --
/Call.kt:90:19: error: unresolved reference: result
fun simple(b: com.result.B<*>) {}
^
@@ -0,0 +1,7 @@
/Call.kt:(253,262): error: Cannot access class 'com.result.B'. Check your module classpath for missing or conflicting dependencies.
/Call.kt:(294,296): error: Cannot access class 'com.result.B'. Check your module classpath for missing or conflicting dependencies.
/Call.kt:(346,355): error: Cannot access class 'com.result.Owner.Nested.VeryNested'. Check your module classpath for missing or conflicting dependencies.
/Call.kt:(383,389): error: Unresolved reference 'result'.
+90
View File
@@ -0,0 +1,90 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// RENDER_DIAGNOSTICS_FULL_TEXT
// ISSUE: KT-62525
// MODULE: m1
// FILE: Request.kt
package com.request
sealed class Result<out Success, out Error> {
class Success<out Success>(val value: Success) : Result<Success, Nothing>()
class Error<out Error>(val error: Error) : Result<Nothing, Error>()
inline fun <Mapped> mapError(transform: (Error) -> Mapped): Result<Success, Mapped> =
when (this) {
is Result.Success -> this
is Result.Error -> Error(transform(error))
}
}
fun <T, U> request(success: T, error: U): Result<T, U> {
if (1 + 1 + 2 == 4) {
return Result.Success(success)
} else {
return Result.Error(error)
}
}
// MODULE: m2
// FILE: Result.kt
package com.result
class A {}
sealed class B<T> {
class HttpError<T>(val response: T) : B<T>() {}
class Exception<T>(val exception: Throwable) : B<T>() {}
}
class C {}
class Owner<T> {
inner class Nested<S> {
inner class VeryNested<R, P>
}
}
// MODULE: m3(m1, m2)
// FILE: Repo.kt
package com.repo
import com.request.Result
import com.request.request
import com.result.A
import com.result.B
import com.result.C
import com.result.Owner
import java.lang.RuntimeException
fun request_a(): Result<A, B<C>> {
return request<A, B<C>>(A(), B.Exception(RuntimeException("Error")))
}
fun request_withNested(): Result<Owner<C>.Nested<A>, Owner<A>.Nested<C>.VeryNested<C, A>> {
return request<Owner<C>.Nested<A>, Owner<A>.Nested<C>.VeryNested<C, A>>(Owner<C>().Nested<A>(), Owner<A>().Nested<C>().VeryNested<C, A>())
}
// MODULE: m4(m3, m1)
// FILE: Call.kt
package com.call
import com.repo.request_a
import com.repo.request_withNested
class Model {
fun call() {
request_a().mapError <!MISSING_DEPENDENCY_CLASS!>{ 1 + 1 }<!>
request_a().mapError { <!MISSING_DEPENDENCY_CLASS!>it<!> -> 1 + 1 }
request_withNested().mapError <!MISSING_DEPENDENCY_CLASS!>{ 1 + 1 }<!>
}
}
fun simple(b: com.<!UNRESOLVED_REFERENCE!>result<!>.B<*>) {}
+90
View File
@@ -0,0 +1,90 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// RENDER_DIAGNOSTICS_FULL_TEXT
// ISSUE: KT-62525
// MODULE: m1
// FILE: Request.kt
package com.request
sealed class Result<out Success, out Error> {
class Success<out Success>(val value: Success) : Result<Success, Nothing>()
class Error<out Error>(val error: Error) : Result<Nothing, Error>()
inline fun <Mapped> mapError(transform: (Error) -> Mapped): Result<Success, Mapped> =
when (this) {
is Result.Success -> <!DEBUG_INFO_SMARTCAST!>this<!>
is Result.Error -> Error(transform(<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>error<!>))
}
}
fun <T, U> request(success: T, error: U): Result<T, U> {
if (1 + 1 + 2 == 4) {
return Result.Success(success)
} else {
return Result.Error(error)
}
}
// MODULE: m2
// FILE: Result.kt
package com.result
class A {}
sealed class B<T> {
class HttpError<T>(val response: T) : B<T>() {}
class Exception<T>(val exception: Throwable) : B<T>() {}
}
class C {}
class Owner<T> {
inner class Nested<S> {
inner class VeryNested<R, P>
}
}
// MODULE: m3(m1, m2)
// FILE: Repo.kt
package com.repo
import com.request.Result
import com.request.request
import com.result.A
import com.result.B
import com.result.C
import com.result.Owner
import java.lang.RuntimeException
fun request_a(): Result<A, B<C>> {
return request<A, B<C>>(A(), B.Exception(RuntimeException("Error")))
}
fun request_withNested(): Result<Owner<C>.Nested<A>, Owner<A>.Nested<C>.VeryNested<C, A>> {
return request<Owner<C>.Nested<A>, Owner<A>.Nested<C>.VeryNested<C, A>>(Owner<C>().Nested<A>(), Owner<A>().Nested<C>().VeryNested<C, A>())
}
// MODULE: m4(m3, m1)
// FILE: Call.kt
package com.call
import com.repo.request_a
import com.repo.request_withNested
class Model {
fun call() {
request_a().mapError { 1 + 1 }
request_a().mapError { it -> 1 + 1 }
request_withNested().mapError { 1 + 1 }
}
}
fun simple(b: com.<!UNRESOLVED_REFERENCE!>result<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>B<!><*>) {}