Shadow addSuppressed member with an extension
#KT-38777
This commit is contained in:
@@ -10,7 +10,8 @@ import kotlin.internal.PlatformImplementations
|
|||||||
|
|
||||||
internal open class JDK7PlatformImplementations : PlatformImplementations() {
|
internal open class JDK7PlatformImplementations : PlatformImplementations() {
|
||||||
|
|
||||||
override fun addSuppressed(cause: Throwable, exception: Throwable) = cause.addSuppressed(exception)
|
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
|
override fun addSuppressed(cause: Throwable, exception: Throwable) = (cause as java.lang.Throwable).addSuppressed(exception)
|
||||||
|
|
||||||
override fun getSuppressed(exception: Throwable): List<Throwable> = exception.suppressed.asList()
|
override fun getSuppressed(exception: Throwable): List<Throwable> = exception.suppressed.asList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public actual fun Throwable.stackTraceToString(): String {
|
|||||||
* suppressed in order to deliver this exception.
|
* suppressed in order to deliver this exception.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
|
@kotlin.internal.HidesMembers
|
||||||
public actual fun Throwable.addSuppressed(exception: Throwable) {
|
public actual fun Throwable.addSuppressed(exception: Throwable) {
|
||||||
if (this !== exception)
|
if (this !== exception)
|
||||||
IMPLEMENTATIONS.addSuppressed(this, exception)
|
IMPLEMENTATIONS.addSuppressed(this, exception)
|
||||||
|
|||||||
@@ -81,6 +81,11 @@ class ExceptionJVMTest {
|
|||||||
e1.addSuppressed(e2)
|
e1.addSuppressed(e2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun addSuppressedSelfDoesNotThrow() {
|
||||||
|
val e1 = Throwable()
|
||||||
|
e1.addSuppressed(e1) // should not throw
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun circularCauseStackTrace() {
|
@Test fun circularCauseStackTrace() {
|
||||||
val e1 = Exception("cause")
|
val e1 = Exception("cause")
|
||||||
val e2 = Error("induced", e1)
|
val e2 = Error("induced", e1)
|
||||||
|
|||||||
Reference in New Issue
Block a user