Fix ThreadLocal marking for mutable objects

This commit is contained in:
Pavel Punegov
2018-08-17 15:21:14 +03:00
committed by Pavel Punegov
parent 5ce370bc11
commit a8951f9fcb
@@ -710,14 +710,18 @@ class RunExternalTestGroup extends RunStandaloneKonanTest {
} }
static String markMutableObjects(String text) { static String markMutableObjects(String text) {
def idx = text.indexOf("object ") def lines = text.readLines()
// FIXME: find only those who has vars inside def result = new ArrayList<String>(lines.size())
if (idx != -1) { lines.forEach { line ->
def lineBeforeIdx = text.substring(0, idx).lastIndexOf("\n") // FIXME: find only those who has vars inside
text = text.substring(0, lineBeforeIdx) + "\n@kotlin.native.ThreadLocal" + text.substring(lineBeforeIdx) // Find object declarations and companion objects
if (line.matches("(?m)^\\s*object [a-zA-Z_][a-zA-Z0-9_]*\\s*.*")
|| line.matches("(?m)^\\s*companion object.*")) {
result += "@kotlin.native.ThreadLocal"
}
result += line
} }
return result.join(System.lineSeparator())
return text
} }
List<String> createTestFiles() { List<String> createTestFiles() {