Skip to content

Commit aaa3fc0

Browse files
authored
Merge pull request #10353 from tamasvajk/kotlin-fix-not-implemented
Kotlin: Catch exception thrown by kotlinc
2 parents 8689539 + 824ba6e commit aaa3fc0

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
@@ -101,8 +101,15 @@ open class KotlinFileExtractor(
101101
if (d.isFakeOverride) {
102102
return true
103103
}
104-
if ((d as? IrFunction)?.descriptor?.isHiddenToOvercomeSignatureClash == true) {
105-
return true
104+
try {
105+
if ((d as? IrFunction)?.descriptor?.isHiddenToOvercomeSignatureClash == true) {
106+
return true
107+
}
108+
}
109+
catch (e: NotImplementedError) {
110+
// `org.jetbrains.kotlin.ir.descriptors.IrBasedClassConstructorDescriptor.isHiddenToOvercomeSignatureClash` throws the exception
111+
logger.warnElement("Couldn't query if element is fake, deciding it's not.", d, e)
112+
return false
106113
}
107114
return false
108115
}

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)