[IR] Support try for MFVC
#KT-1179
This commit is contained in:
committed by
teamcity
parent
ca789607ba
commit
afe67f9bc1
@@ -0,0 +1,43 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double) {
|
||||
init {
|
||||
require(x != 0.0 && y != 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
fun tryOk() = try {
|
||||
DPoint(1.0, 2.0)
|
||||
} catch(_: Throwable) {
|
||||
DPoint(0.0, 3.0)
|
||||
} finally {
|
||||
DPoint(4.0, 5.0)
|
||||
}
|
||||
|
||||
fun tryFail1() = try {
|
||||
DPoint(0.0, 1.0)
|
||||
} catch(_: Throwable) {
|
||||
DPoint(2.0, 3.0)
|
||||
} finally {
|
||||
DPoint(4.0, 5.0)
|
||||
}
|
||||
|
||||
fun tryFail2() = try {
|
||||
DPoint(1.0, 2.0)
|
||||
} catch(_: Throwable) {
|
||||
DPoint(3.0, 4.0)
|
||||
} finally {
|
||||
DPoint(5.0, 0.0)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
require(runCatching { tryOk() } == Result.success(DPoint(1.0, 2.0)))
|
||||
require(runCatching { tryFail1() } == Result.success(DPoint(2.0, 3.0)))
|
||||
require(runCatching { tryFail2() }.isFailure)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class DPoint {
|
||||
// source: 'tryExpressions.kt'
|
||||
private final field field-0: double
|
||||
private final field field-1: double
|
||||
private synthetic method <init>(p0: double, p1: double): void
|
||||
public synthetic final static method box-impl(p0: double, p1: double): DPoint
|
||||
public final static method constructor-impl(p0: double, p1: double): void
|
||||
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: double, p1: double, p2: java.lang.Object): boolean
|
||||
public final static method equals-impl0(p0: double, p1: double, p2: double, p3: double): boolean
|
||||
public final static method getX-impl(p0: double, p1: double): double
|
||||
public final static method getY-impl(p0: double, p1: double): double
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: double, p1: double): int
|
||||
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||
public static method toString-impl(p0: double, p1: double): java.lang.String
|
||||
public synthetic final method unbox-impl-0(): double
|
||||
public synthetic final method unbox-impl-1(): double
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TryExpressionsKt {
|
||||
// source: 'tryExpressions.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static @org.jetbrains.annotations.NotNull method tryFail1(): DPoint
|
||||
public final static @org.jetbrains.annotations.NotNull method tryFail2(): DPoint
|
||||
public final static @org.jetbrains.annotations.NotNull method tryOk(): DPoint
|
||||
public final inner class kotlin/Result$Companion
|
||||
}
|
||||
Reference in New Issue
Block a user