Fix attribute clash between STATIC_INLINE_CLASS_REPLACEMENT and original

Attributes are used to name continuation classes and are generated
before inline classes processing. During the processing, for override
functions in inlined classes, the compiler generates
STATIC_INLINE_CLASS_REPLACEMENT function with body of the override.
The override's body is replaced with delegating call to
STATIC_INLINE_CLASS_REPLACEMENT. However, since we need to keep the name
of the continuation class, we copy attributes from the override to
STATIC_INLINE_CLASS_REPLACEMENT. This leads to attribute clash during
AddContinuationLowering.
So, to fix the issue, do not use the attribute of
STATIC_INLINE_CLASS_REPLACEMENT in original->suspend map.
As an optimization, do not generate continuation for the override
function.
This commit is contained in:
Ilmir Usmanov
2020-05-12 20:28:29 +02:00
parent d2a691d157
commit 0acaedef92
9 changed files with 71 additions and 2 deletions
@@ -0,0 +1,31 @@
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
import helpers.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
class Delegate {
fun build(): String = "OK"
}
interface Digest {
suspend fun build(): String
}
inline class DigestImpl(val delegate: Delegate) : Digest {
override suspend fun build(): String = delegate.build()
}
fun box(): String {
var res = "FAIL"
val digest: Digest = DigestImpl(Delegate())
builder {
res = digest.build()
}
return res
}