Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created October 20, 2013 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnsholt/7068002 to your computer and use it in GitHub Desktop.
Save arnsholt/7068002 to your computer and use it in GitHub Desktop.
First attempt at fixing mixin bug
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java b/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
index dc9fd60..9cb26cb 100644
--- a/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
+++ b/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
@@ -644,7 +644,7 @@ public class P6Opaque extends REPR {
// Ensure target type is also P6opaque-based.
if (!(newType.st.REPR instanceof P6Opaque))
throw ExceptionHandling.dieInternal(tc, "P6opaque can only rebless to another P6opaque-based type");
-
+
// Ensure that the MROs overlap properly.
P6OpaqueREPRData ourREPRData = (P6OpaqueREPRData)obj.st.REPRData;
P6OpaqueREPRData targetREPRData = (P6OpaqueREPRData)newType.st.REPRData;
@@ -658,14 +658,15 @@ public class P6Opaque extends REPR {
// If there's a different number of attributes, need to set up delegate.
// Note the condition below works because we don't make an entry in the
// class handles list for a type with no attributes.
- if (ourREPRData.classHandles.length != targetREPRData.classHandles.length) {
+ P6OpaqueBaseInstance opaqueInstance = (P6OpaqueBaseInstance) obj;
+ if (ourREPRData.classHandles.length != targetREPRData.classHandles.length || opaqueInstance.delegate != null) {
// Create delegate.
SixModelObject delegate = newType.st.REPR.allocate(tc, newType.st);
// Find original object.
SixModelObject orig;
- if (((P6OpaqueBaseInstance)obj).delegate != null)
- orig = ((P6OpaqueBaseInstance)obj).delegate;
+ if (opaqueInstance.delegate != null)
+ orig = opaqueInstance.delegate;
else
orig = obj;
@@ -679,7 +680,7 @@ public class P6Opaque extends REPR {
catch (IllegalAccessException e) { throw new RuntimeException(e); }
// Install.
- ((P6OpaqueBaseInstance)obj).delegate = delegate;
+ opaqueInstance.delegate = delegate;
}
// Switch STable over to the new type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment