Copy location info when copying JS AST subtrees

This is necessary to preserve source information of a function's body
after inlining.
This commit is contained in:
Alexey Andreev
2017-05-02 19:13:56 +03:00
parent 9218b61141
commit e5662ac2ad
4 changed files with 50 additions and 1 deletions
@@ -28,8 +28,12 @@ abstract class AbstractNode extends HasMetadata implements JsNode {
return out.toString();
}
protected <T extends HasMetadata> T withMetadataFrom(T other) {
protected <T extends HasMetadata & JsNode> T withMetadataFrom(T other) {
this.copyMetadataFrom(other);
Object otherSource = other.getSource();
if (otherSource != null) {
source(otherSource);
}
//noinspection unchecked
return (T) this;
}