Skip to content

Commit

Permalink
Support ErrorType without parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed May 25, 2022
1 parent 36931de commit 1de3316
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.error.ErrorType
import org.jetbrains.kotlin.types.error.ErrorTypeConstructor
import org.jetbrains.kotlin.types.error.ErrorTypeKind

fun TypeReference.Companion.from(d: ReceiverParameterDescriptor): TypeReference? =
when (d.value) {
Expand All @@ -37,8 +38,12 @@ private fun TypeReference.Companion.fromPossiblyRecursive(t: KotlinType, paramTr

private fun TypeReference.Companion.from(t: KotlinType, paramTrace: List<KotlinType>): TypeReference {
if (t is ErrorType) {
val errorConstructor = t.constructor as? ErrorTypeConstructor
return TypeConstructor(
(t.constructor as? ErrorTypeConstructor)?.getParam(0).orEmpty(),
if (errorConstructor?.kind == ErrorTypeKind.UNRESOLVED_TYPE && errorConstructor.parameters.isNotEmpty())
errorConstructor.getParam(0)
else
t.constructor.toString(),
t.arguments.map { fromProjection(it, paramTrace) }
)
}
Expand Down

0 comments on commit 1de3316

Please sign in to comment.