Skip to content

Commit 824ba6e

Browse files
committed
Kotlin: Catch exception thrown by kotlinc
1 parent ac30713 commit 824ba6e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,15 @@ open class KotlinFileExtractor(
9797
if (d.isFakeOverride) {
9898
return true
9999
}
100-
if ((d as? IrFunction)?.descriptor?.isHiddenToOvercomeSignatureClash == true) {
101-
return true
100+
try {
101+
if ((d as? IrFunction)?.descriptor?.isHiddenToOvercomeSignatureClash == true) {
102+
return true
103+
}
104+
}
105+
catch (e: NotImplementedError) {
106+
// `org.jetbrains.kotlin.ir.descriptors.IrBasedClassConstructorDescriptor.isHiddenToOvercomeSignatureClash` throws the exception
107+
logger.warnElement("Couldn't query if element is fake, deciding it's not.", d, e)
108+
return false
102109
}
103110
return false
104111
}

java/kotlin-extractor/src/main/kotlin/utils/Logger.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ open class Logger(val loggerBase: LoggerBase, open val tw: TrapWriter) {
248248
}
249249

250250
class FileLogger(loggerBase: LoggerBase, override val tw: FileTrapWriter): Logger(loggerBase, tw) {
251-
fun warnElement(msg: String, element: IrElement) {
251+
fun warnElement(msg: String, element: IrElement, exn: Throwable? = null) {
252252
val locationString = tw.getLocationString(element)
253253
val mkLocationId = { tw.getLocation(element) }
254-
loggerBase.diagnostic(tw, Severity.Warn, msg, null, locationString, mkLocationId)
254+
loggerBase.diagnostic(tw, Severity.Warn, msg, exn?.stackTraceToString(), locationString, mkLocationId)
255255
}
256256

257-
fun errorElement(msg: String, element: IrElement) {
257+
fun errorElement(msg: String, element: IrElement, exn: Throwable? = null) {
258258
val locationString = tw.getLocationString(element)
259259
val mkLocationId = { tw.getLocation(element) }
260-
loggerBase.diagnostic(tw, Severity.Error, msg, null, locationString, mkLocationId)
260+
loggerBase.diagnostic(tw, Severity.Error, msg, exn?.stackTraceToString(), locationString, mkLocationId)
261261
}
262262
}

0 commit comments

Comments
 (0)