Skip to content

Commit

Permalink
Point class specialization failures at offending source (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Nov 4, 2024
1 parent 7d69c04 commit 30ad9bc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,32 @@ class BurstKotlinPluginTest {
}

@Test
fun unexpectedArgumentType() {
fun unexpectedClassArgumentType() {
val result = compile(
sourceFile = SourceFile.kotlin(
"CoffeeTest.kt",
"""
import app.cash.burst.Burst
import kotlin.test.Test
@Burst
class CoffeeTest(espresso: String) {
@Test
fun test() {
}
}
""",
),
)
assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode, result.messages)
assertThat(result.messages).contains(
"CoffeeTest.kt:5:18 " +
"@Burst parameter must be a boolean, an enum, or have a burstValues() default value",
)
}

@Test
fun unexpectedFunctionArgumentType() {
val result = compile(
sourceFile = SourceFile.kotlin(
"CoffeeTest.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ class BurstIrGenerationExtension(
}

if (classHasAtBurst && classDeclaration.modality != Modality.ABSTRACT) {
ClassSpecializer(
pluginContext = pluginContext,
burstApis = burstApis,
originalParent = currentFile,
original = classDeclaration,
).generateSpecializations()
try {
ClassSpecializer(
pluginContext = pluginContext,
burstApis = burstApis,
originalParent = currentFile,
original = classDeclaration,
).generateSpecializations()
} catch (e: BurstCompilationException) {
messageCollector.report(e.severity, e.message, currentFile.locationOf(e.element))
}
}

// Snapshot the original functions because the loop mutates them.
Expand Down

0 comments on commit 30ad9bc

Please sign in to comment.