Skip to content

Commit

Permalink
include synthetic accessors for checked exception
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Jun 13, 2024
1 parent 00862a1 commit ee4ff8b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class ResolverAAImpl(

override fun getJvmCheckedException(accessor: KSPropertyAccessor): Sequence<KSType> {
return when (accessor.origin) {
Origin.KOTLIN -> {
Origin.KOTLIN, Origin.SYNTHETIC -> {
extractThrowsAnnotation(accessor)
}
Origin.KOTLIN_LIB, Origin.JAVA_LIB -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class ThrowListProcessor : AbstractTestProcessor() {
val propertyA = klass.declarations.single { it.simpleName.asString() == "a" } as KSPropertyDeclaration
result.add(resolver.getJvmCheckedException(propertyA.getter!!).toResult())
result.add(resolver.getJvmCheckedException(propertyA.setter!!).toResult())
klass.declarations.filter { it.simpleName.asString() == "syntheticAccessors" }.map {
resolver.getJvmCheckedException((it as KSPropertyDeclaration).getter!!).toResult()
}.sorted().forEach { result.add(it) }
klass.declarations.filter { it.simpleName.asString() == "syntheticAccessors" }.map {
resolver.getJvmCheckedException((it as KSPropertyDeclaration).setter!!).toResult()
}.sorted().forEach { result.add(it) }
val jlib = resolver.getClassDeclarationByName("JavaLib")!!
val klib = resolver.getClassDeclarationByName("KtLib")!!
klib.declarations.filter { it.simpleName.asString() == "throwsLibKt" }.map {
Expand All @@ -65,6 +71,12 @@ class ThrowListProcessor : AbstractTestProcessor() {
klib.declarations.filter { it.simpleName.asString() == "bothThrows" }.map {
resolver.getJvmCheckedException((it as KSPropertyDeclaration).setter!!).toResult()
}.sorted().forEach { result.add(it) }
klib.declarations.filter { it.simpleName.asString() == "syntheticAccessors" }.map {
resolver.getJvmCheckedException((it as KSPropertyDeclaration).getter!!).toResult()
}.sorted().forEach { result.add(it) }
klib.declarations.filter { it.simpleName.asString() == "syntheticAccessors" }.map {
resolver.getJvmCheckedException((it as KSPropertyDeclaration).setter!!).toResult()
}.sorted().forEach { result.add(it) }
jlib.declarations.filter { it.simpleName.asString() == "foo" }.map {
resolver.getJvmCheckedException(it as KSFunctionDeclaration).toResult()
}.sorted().forEach { result.add(it) }
Expand Down
12 changes: 12 additions & 0 deletions test-utils/testData/api/throwList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
// ThrowsException.method.T
// java.io.IOException,java.util.NoSuchElementException
// java.lang.IndexOutOfBoundsException
// java.util.NoSuchElementException
// java.lang.IndexOutOfBoundsException
// java.io.IOException
// java.io.IOException,java.lang.IndexOutOfBoundsException
// java.lang.IndexOutOfBoundsException
// java.lang.IllegalArgumentException
// java.lang.IllegalStateException
// java.io.IOException
// java.lang.IllegalStateException,java.lang.IllegalArgumentException
// java.util.NoSuchElementException
// java.lang.IndexOutOfBoundsException
// java.io.IOException
// java.io.IOException,java.lang.IndexOutOfBoundsException
// java.lang.IndexOutOfBoundsException
Expand Down Expand Up @@ -80,6 +84,10 @@ class KtLib {
@get:Throws(IOException::class)
@set:Throws(IllegalStateException::class, IllegalArgumentException::class)
var bothThrows: Int = 3

@set:Throws(java.lang.IndexOutOfBoundsException::class)
@get:Throws(java.util.NoSuchElementException::class)
var syntheticAccessors: Int = 0
}
// MODULE: main(lib)
// FILE: ThrowsException.java
Expand Down Expand Up @@ -107,4 +115,8 @@ class ThrowsKt {
set(a: Int) {

}

@set:Throws(java.lang.IndexOutOfBoundsException::class)
@get:Throws(java.util.NoSuchElementException::class)
var syntheticAccessors: Int
}

0 comments on commit ee4ff8b

Please sign in to comment.