Skip to content

Commit

Permalink
[KAPT] Suppress resolve error in annotation procssing
Browse files Browse the repository at this point in the history
#KT-33223
  • Loading branch information
Andrey Zinovyev authored Feb 10, 2021
1 parent d64f7dd commit 48ec227
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class KaptJavaLog(
"compiler.err.already.defined",
"compiler.err.annotation.type.not.applicable",
"compiler.err.doesnt.exist",
"compiler.err.cant.resolve.location",
"compiler.err.duplicate.annotation.missing.container",
"compiler.err.not.def.access.package.cant.access",
"compiler.err.package.not.visible",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package test

import apt.Anno
import generated.Test as TestGenerated
import generated.Property

@Anno
class Test {

@field:Anno
val property: String = ""

@Anno
fun function() {

}

}

interface Usage {
fun test(): TestGenerated
fun test1(): generated.Function
fun test2(): Property
}

fun main() {
println("Generated class: " + TestGenerated::class.java.name)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# copy
../kotlinFileGeneration/ap
ap

# mkdir
output/ap
output/stubs
output/classes
output/sources
output/kotlin-sources

# kotlinc
-cp %KOTLIN_STDLIB%
-d output/ap
ap/Processor.kt

# copy
../kotlinFileGeneration/ap/META-INF/services/javax.annotation.processing.Processor
output/ap/META-INF/services/javax.annotation.processing.Processor

# kapt
-Kapt-stubs=output/stubs
-Kapt-classes=output/classes
-Kapt-sources=output/sources
-Kapt-classpath=output/ap
-Kapt-option:kapt.kotlin.generated=output/kotlin-sources
-Kapt-correct-error-types=true
-d output/classes
-cp output/ap:%KOTLIN_STDLIB%
Test.kt

# java
-cp output/classes:output/ap:%KOTLIN_STDLIB%
test.TestKt

# after
Generated class: generated.Test
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,5 @@ class ErrorInDeclarations {
annotation class Anno(val a: KClass<Any>)

// EXPECTED_ERROR(kotlin:11:1) cannot find symbol
// EXPECTED_ERROR(kotlin:12:1) cannot find symbol
// EXPECTED_ERROR(kotlin:16:5) cannot find symbol
// EXPECTED_ERROR(kotlin:17:5) cannot find symbol
// EXPECTED_ERROR(kotlin:20:5) cannot find symbol
// EXPECTED_ERROR(kotlin:22:5) cannot find symbol
// EXPECTED_ERROR(kotlin:25:5) cannot find symbol
// EXPECTED_ERROR(kotlin:6:1) cannot find symbol
// EXPECTED_ERROR(kotlin:9:34) cannot find symbol
// EXPECTED_ERROR(kotlin:9:50) cannot find symbol
// EXPECTED_ERROR(kotlin:9:62) cannot find symbol
// EXPECTED_ERROR(kotlin:12:1) cannot find symbol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ enum class Color {
@Anno(Color.`WHI-TE`)
annotation class Anno(val color: Color)

// EXPECTED_ERROR(kotlin:5:1) cannot find symbol
// EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name
// EXPECTED_ERROR(kotlin:5:1) an enum annotation value must be an enum constant
// EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name
3 changes: 1 addition & 2 deletions plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class Foo(private val string: String) {
}
}

// EXPECTED_ERROR(kotlin:9:9) cannot find symbol
// EXPECTED_ERROR(other:-1:-1) Can't generate a stub for 'Foo$Bar$Bar'.
// EXPECTED_ERROR(other:-1:-1) Can't generate a stub for 'Foo$Bar$Bar'.

0 comments on commit 48ec227

Please sign in to comment.