Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 00471be866cd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7a224a52c582
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on May 6, 2016

  1. [Truffle] When opening a class, the superclass expression is evaluate…

    …d before the name is looked up.
    chrisseaton committed May 6, 2016
    Copy the full SHA
    066f5c2 View commit details
  2. [Truffle] Allow a class's superclass to be modified to be itself if i…

    …t was previously Object.
    chrisseaton committed May 6, 2016
    Copy the full SHA
    7a224a5 View commit details
Showing with 11 additions and 6 deletions.
  1. +11 −6 truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
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(