Do nothing if there is no smap data on anonymous object transfromation during fun inline
This commit is contained in:
+7
-5
@@ -48,8 +48,6 @@ public class AnonymousObjectTransformer {
|
|||||||
|
|
||||||
private String debugInfo;
|
private String debugInfo;
|
||||||
|
|
||||||
private SMAP smap;
|
|
||||||
|
|
||||||
private SourceMapper sourceMapper;
|
private SourceMapper sourceMapper;
|
||||||
|
|
||||||
private final InliningContext inliningContext;
|
private final InliningContext inliningContext;
|
||||||
@@ -162,9 +160,13 @@ public class AnonymousObjectTransformer {
|
|||||||
}, ClassReader.SKIP_FRAMES);
|
}, ClassReader.SKIP_FRAMES);
|
||||||
|
|
||||||
if (!inliningContext.isInliningLambda) {
|
if (!inliningContext.isInliningLambda) {
|
||||||
assert debugInfo != null && !debugInfo.isEmpty() : "Debug info is null for " + oldObjectType;
|
if (debugInfo != null && !debugInfo.isEmpty()) {
|
||||||
smap = new SMAPParser(debugInfo, sourceInfo, "notused", 1, 2).parse();
|
sourceMapper = SourceMapper.OBJECT$.createFromSmap(SMAPParser.parse(debugInfo));
|
||||||
sourceMapper = SourceMapper.Default.createFromSmap(smap);
|
}
|
||||||
|
else {
|
||||||
|
//seems we can't do any clever mapping cause we don't know any about original class name
|
||||||
|
sourceMapper = IdenticalSourceMapper.INSTANCE$;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
classBuilder.visitSource(sourceInfo, debugInfo);
|
classBuilder.visitSource(sourceInfo, debugInfo);
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
//TODO: obtain name from context
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class InlineCodegenUtil {
|
|||||||
}
|
}
|
||||||
}, ClassReader.SKIP_FRAMES);
|
}, ClassReader.SKIP_FRAMES);
|
||||||
|
|
||||||
SMAP smap = new SMAPParser(debugInfo[1], debugInfo[0], classId.toString(), lines[0], lines[1]).parse();
|
SMAP smap = SMAPParser.parseOrCreateDefault(debugInfo[1], debugInfo[0], classId.toString(), lines[0], lines[1]);
|
||||||
return new SMAPAndMethodNode(node[0], smap);
|
return new SMAPAndMethodNode(node[0], smap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.codegen.inline
|
package org.jetbrains.kotlin.codegen.inline
|
||||||
|
|
||||||
class SMAPParser(val mappingInfo: String?, val source: String, val path: String, val methodStartLine: Int, val methodEndLine: Int) {
|
import kotlin.platform.platformStatic
|
||||||
|
|
||||||
val fileMappings = linkedMapOf<Int, FileMapping>()
|
object SMAPParser {
|
||||||
|
|
||||||
fun parse() : SMAP {
|
[platformStatic]
|
||||||
|
public fun parseOrCreateDefault(mappingInfo: String?, source: String, path: String, methodStartLine: Int, methodEndLine: Int): SMAP {
|
||||||
if (mappingInfo == null || mappingInfo.isEmpty()) {
|
if (mappingInfo == null || mappingInfo.isEmpty()) {
|
||||||
val fm = FileMapping(source, path)
|
val fm = FileMapping(source, path)
|
||||||
if (methodStartLine <= methodEndLine) {
|
if (methodStartLine <= methodEndLine) {
|
||||||
@@ -29,6 +30,12 @@ class SMAPParser(val mappingInfo: String?, val source: String, val path: String,
|
|||||||
}
|
}
|
||||||
return SMAP(listOf(fm))
|
return SMAP(listOf(fm))
|
||||||
}
|
}
|
||||||
|
return parse(mappingInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
[platformStatic]
|
||||||
|
public fun parse(mappingInfo: String): SMAP {
|
||||||
|
val fileMappings = linkedMapOf<Int, FileMapping>()
|
||||||
|
|
||||||
val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length()
|
val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length()
|
||||||
val lineSectionAnchor = mappingInfo.indexOf(SMAP.LINE_SECTION)
|
val lineSectionAnchor = mappingInfo.indexOf(SMAP.LINE_SECTION)
|
||||||
@@ -54,7 +61,7 @@ class SMAPParser(val mappingInfo: String?, val source: String, val path: String,
|
|||||||
/*only simple mapping now*/
|
/*only simple mapping now*/
|
||||||
val targetSplit = lineMapping.indexOf(':')
|
val targetSplit = lineMapping.indexOf(':')
|
||||||
val originalPart = lineMapping.substring(0, targetSplit)
|
val originalPart = lineMapping.substring(0, targetSplit)
|
||||||
var rangeSeparator = originalPart.indexOf(',').let { if (it < 0) targetSplit else it}
|
var rangeSeparator = originalPart.indexOf(',').let { if (it < 0) targetSplit else it }
|
||||||
|
|
||||||
val fileSeparator = lineMapping.indexOf('#')
|
val fileSeparator = lineMapping.indexOf('#')
|
||||||
val originalIndex = Integer.valueOf(originalPart.substring(0, fileSeparator))
|
val originalIndex = Integer.valueOf(originalPart.substring(0, fileSeparator))
|
||||||
|
|||||||
Reference in New Issue
Block a user