Skip to content

Commit 33d7bd0

Browse files
committed
Replace more NotProvided.INSTANCE block values with Nil.INSTANCE
These are the less obvious places where a `NotProvided` value is being used to represent a block. I found them by doing a manual audit of `NotProvided` uses.
1 parent 3e37885 commit 33d7bd0

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

src/main/java/org/truffleruby/cext/CExtNodes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import org.truffleruby.interop.TranslateInteropExceptionNode;
6969
import org.truffleruby.core.string.ImmutableRubyString;
7070
import org.truffleruby.language.LexicalScope;
71-
import org.truffleruby.language.NotProvided;
7271
import org.truffleruby.language.RubyContextNode;
7372
import org.truffleruby.language.RubyDynamicObject;
7473
import org.truffleruby.language.RubyGuards;
@@ -1119,7 +1118,7 @@ protected RubyClass classNew(RubyClass superclass) {
11191118

11201119
RubyClass klass = (RubyClass) allocateNode
11211120
.call(getContext().getCoreLibrary().classClass, "__allocate__");
1122-
return initializeClassNode.executeInitialize(klass, superclass, NotProvided.INSTANCE);
1121+
return initializeClassNode.executeInitialize(klass, superclass, nil);
11231122
}
11241123

11251124
}

src/main/java/org/truffleruby/core/array/ArrayNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ private Object delete(VirtualFrame frame, RubyArray array, Object value, Object
697697
array.size = i;
698698
return found;
699699
} else {
700-
if (maybeBlock == NotProvided.INSTANCE) {
700+
if (maybeBlock == nil) {
701701
return nil;
702702
} else {
703703
return yield((RubyProc) maybeBlock, value);

src/main/java/org/truffleruby/core/hash/HashNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ protected Object deletePackedArray(RubyHash hash, Object key, Object maybeBlock,
382382

383383
assert HashOperations.verifyStore(getContext(), hash);
384384

385-
if (maybeBlock == NotProvided.INSTANCE) {
385+
if (maybeBlock == nil) {
386386
return nil;
387387
} else {
388388
return yieldNode.executeDispatch((RubyProc) maybeBlock, key);
@@ -397,7 +397,7 @@ protected Object delete(RubyHash hash, Object key, Object maybeBlock) {
397397
final Entry entry = lookupResult.getEntry();
398398

399399
if (entry == null) {
400-
if (maybeBlock == NotProvided.INSTANCE) {
400+
if (maybeBlock == nil) {
401401
return nil;
402402
} else {
403403
return yieldNode.executeDispatch((RubyProc) maybeBlock, key);

src/main/java/org/truffleruby/core/inlined/InlinedCallNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.oracle.truffle.api.nodes.ExplodeLoop;
1717

1818
import org.truffleruby.RubyLanguage;
19-
import org.truffleruby.language.NotProvided;
2019
import org.truffleruby.language.RubyNode;
2120
import org.truffleruby.language.dispatch.RubyCallNodeParameters;
2221
import org.truffleruby.language.methods.InternalMethod;
@@ -72,8 +71,7 @@ public Object execute(VirtualFrame frame) {
7271

7372
public Object executeWithArgumentsEvaluated(VirtualFrame frame, Object receiverObject, Object blockObject,
7473
Object[] argumentsObjects) {
75-
final Object blockArgument = blockObject == nil ? NotProvided.INSTANCE : blockObject;
76-
return inlinedMethod.inlineExecute(frame, receiverObject, argumentsObjects, blockArgument);
74+
return inlinedMethod.inlineExecute(frame, receiverObject, argumentsObjects, blockObject);
7775
}
7876

7977
private Object executeBlock(VirtualFrame frame) {

src/main/java/org/truffleruby/core/method/MethodNodes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.truffleruby.core.string.RubyString;
3232
import org.truffleruby.core.string.StringNodes;
3333
import org.truffleruby.core.symbol.RubySymbol;
34-
import org.truffleruby.language.NotProvided;
3534
import org.truffleruby.language.RubyContextSourceNode;
3635
import org.truffleruby.language.RubyRootNode;
3736
import org.truffleruby.language.Visibility;
@@ -134,7 +133,7 @@ public abstract static class CallNode extends CoreMethodArrayArgumentsNode {
134133
@Specialization
135134
protected Object call(VirtualFrame frame, RubyMethod method, Object[] arguments, Object maybeBlock) {
136135
return callBoundMethodNode
137-
.execute(frame, method, arguments, maybeBlock == NotProvided.INSTANCE ? nil : maybeBlock);
136+
.execute(frame, method, arguments, maybeBlock);
138137
}
139138

140139
}

src/main/java/org/truffleruby/core/module/ModuleNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ protected RubySymbol defineMethodBlock(
12241224
String name,
12251225
NotProvided proc,
12261226
RubyProc block) {
1227-
return defineMethodProc(frame, module, name, block, NotProvided.INSTANCE);
1227+
return defineMethodProc(frame, module, name, block, nil);
12281228
}
12291229

12301230
@Specialization

0 commit comments

Comments
 (0)