Skip to content

Commit 4fc0d04

Browse files
steve-sansalond
authored andcommitted
RCodeBuilder#process 'clones' AST and should make sure children are adopted
(cherry picked from commit b0f373e)
1 parent d24d4b4 commit 4fc0d04

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RCodeBuilder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.List;
2929

3030
import com.oracle.truffle.api.RootCallTarget;
31+
import com.oracle.truffle.api.nodes.Node;
3132
import com.oracle.truffle.api.source.SourceSection;
3233
import com.oracle.truffle.r.runtime.ArgumentsSignature;
3334
import com.oracle.truffle.r.runtime.context.RContext;
@@ -138,7 +139,7 @@ static <T> Argument<T> argumentEmpty() {
138139
* functionality can be used to quickly create new AST snippets for existing code.
139140
*/
140141
default T process(RSyntaxElement original) {
141-
return new RSyntaxVisitor<T>() {
142+
T result = new RSyntaxVisitor<T>() {
142143

143144
@Override
144145
protected T visit(RSyntaxCall element) {
@@ -173,6 +174,10 @@ protected T visit(RSyntaxFunction element) {
173174
return function(RContext.getInstance().getLanguage(), element.getLazySourceSection(), params, accept(element.getSyntaxBody()), element.getSyntaxDebugName());
174175
}
175176
}.accept(original);
177+
if (result instanceof Node) {
178+
((Node) result).adoptChildren();
179+
}
180+
return result;
176181
}
177182

178183
static <T> ArrayList<Argument<T>> createArgumentList(ArgumentsSignature signature, T[] arguments) {

0 commit comments

Comments
 (0)