Skip to content

Commit

Permalink
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -58,10 +58,6 @@ public Object execute(VirtualFrame frame) {

DynamicObject lexicalParentModule = (DynamicObject) lexicalParentObject;

final RubyConstant constant = DefineModuleNode.lookupForExistingModule(
frame, getContext(), name, lexicalParentModule, indirectCallNode);

final DynamicObject definingClass;
final Object superClassObject = superClass.execute(frame);

if (!RubyGuards.isRubyClass(superClassObject)) {
@@ -76,6 +72,11 @@ public Object execute(VirtualFrame frame) {
throw new RaiseException(coreExceptions().typeError("can't make subclass of virtual class", this));
}

final RubyConstant constant = DefineModuleNode.lookupForExistingModule(
frame, getContext(), name, lexicalParentModule, indirectCallNode);

final DynamicObject definingClass;

if (needToDefineProfile.profile(constant == null)) {
definingClass = ClassNodes.createInitializedRubyClass(getContext(), lexicalParentModule, superClassModule, name);

@@ -93,8 +94,12 @@ public Object execute(VirtualFrame frame) {

definingClass = (DynamicObject) constant.getValue();

if (!isBlankOrRootClass(superClassModule) && !isBlankOrRootClass(definingClass)
&& ClassNodes.getSuperClass(definingClass) != superClassModule) {
final DynamicObject currentSuperClass = ClassNodes.getSuperClass(definingClass);

if (!isBlankOrRootClass(superClassModule)
&& !isBlankOrRootClass(definingClass)
&& currentSuperClass != superClassModule
&& (superClassModule != definingClass || currentSuperClass == coreLibrary().getObjectClass())) {
errorProfile.enter();

throw new RaiseException(coreExceptions().superclassMismatch(
Original file line number Diff line number Diff line change
@@ -29,6 +29,15 @@ public static String replacementName(SourceSection sourceSection, String name) {
}
}

// The method_source gem checks if RUBY_ENGINE is defined and regexp matches 'jruby'. If it does,
// it uses Java interop to get source locations for JRuby. We rename the constant being looked for
// to one that doesn't exist so the defined? lookup fails.
if (sourceSection.getSource().getName().endsWith("source_location.rb")) {
if (name.equals("RUBY_ENGINE")) {
return name + "_NONEXISTENT";
}
}

return name;
}

0 comments on commit 205160a

Please sign in to comment.