Skip to content

Commit

Permalink
[Truffle] Regexp#=~ should not try the reverse operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Nov 3, 2014
1 parent f2b0494 commit b8bdaac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
Expand Up @@ -63,16 +63,12 @@ public Object match(RubyRegexp regexp, RubyString string) {
@CoreMethod(names = "=~", required = 1)
public abstract static class MatchOperatorNode extends CoreMethodNode {

@Child protected DispatchHeadNode matchNode;

public MatchOperatorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
matchNode = new DispatchHeadNode(context);
}

public MatchOperatorNode(MatchOperatorNode prev) {
super(prev);
matchNode = prev.matchNode;
}

@Specialization
Expand All @@ -83,10 +79,14 @@ public Object match(RubyRegexp regexp, RubyString string) {
}

@Specialization
public Object match(VirtualFrame frame, RubyRegexp regexp, RubyBasicObject other) {
public Object match(RubyRegexp regexp, RubyBasicObject other) {
notDesignedForCompilation();

return matchNode.call(frame, other, "=~", null, regexp);
if (other instanceof RubyString) {
return match(regexp, (RubyString) other);
} else {
return getContext().getCoreLibrary().getNilObject();
}
}

}
Expand Down

0 comments on commit b8bdaac

Please sign in to comment.