Skip to content
This repository has been archived by the owner on Feb 15, 2025. It is now read-only.

Commit

Permalink
Сlarify an error message in case when a type unresolved. (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Krishtal <[email protected]>
  • Loading branch information
KR1sis and Sergey Krishtal authored Oct 18, 2021
1 parent 2b38474 commit aa84f07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ internal fun KSTypeReference.resolveToUnderlying(): KSType {
candidate = declaration.type.resolve()
declaration = candidate.declaration
}
if (candidate.isError) {
throw NonRecoverableProcessorException("Unable to resolve type reference: $this", node = this)
}
return candidate
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,23 @@ internal class ProcessorErrorsTest {
""".trimIndent()))
}

@Test
fun `unresolved type error`() {
expectError("Unable to resolve type reference: UnknownType", kotlin("source.kt", """
import com.daugeldauge.kinzhal.annotations.Component
import com.daugeldauge.kinzhal.annotations.Inject
@Component
interface AppComponent {
fun app(): App
}
class App @Inject constructor(
unknownInstance: UnknownType
)
""".trimIndent()))
}


private fun expectError(message: String, vararg sourceFiles: SourceFile) {
val result = compile(*sourceFiles)
Expand Down

0 comments on commit aa84f07

Please sign in to comment.