Changeset 14092


Ignore:
Timestamp:
08/15/12 07:12:24 (2 years ago)
Author:
rschlatte
Message:

Don't clobber class hierarchy when defining forward-referenced classes

  • Use initargs when calling change-class for the class metaobject
  • Robustify make-instances-obsolete against non-finalized classes (e.g. forward-referenced-class)
  • Report and diagnosis by Stas Boukarev to armedbear-devel on August 11, 2012 ("Forward referenced classes woes")
  • Fixes ansi tests DEFCLASS.FORWARD-REF.3, DEFCLASS.FORWARD-REF.4
Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Layout.java

    r13444 r14092  
    266266        final LispObject lispClass = arg;
    267267        LispObject oldLayout;
    268         if (lispClass instanceof LispClass)
    269             oldLayout = ((LispClass)lispClass).getClassLayout();
    270         else
    271             oldLayout = Symbol.CLASS_LAYOUT.execute(lispClass);
     268        // Non-finalized classes might not have a valid layout, but they do
     269        // not have instances either so we can abort.
     270        if (lispClass instanceof LispClass) {
     271          if (!((LispClass)lispClass).isFinalized())
     272            return arg;
     273          oldLayout = ((LispClass)lispClass).getClassLayout();
     274        } else if (lispClass instanceof StandardObject) {
     275          if (((StandardObject)arg)
     276              .getInstanceSlotValue(StandardClass.symFinalizedP) == NIL)
     277            return arg;
     278          oldLayout = Symbol.CLASS_LAYOUT.execute(lispClass);
     279        } else {
     280          return error(new TypeError(arg, Symbol.CLASS));
     281        }
    272282
    273283        Layout newLayout = new Layout((Layout)oldLayout);
  • trunk/abcl/src/org/armedbear/lisp/clos.lisp

    r14080 r14092  
    31263126  (remf all-keys :metaclass)
    31273127  (unless (classp metaclass) (setf metaclass (find-class metaclass)))
    3128   (change-class class metaclass)
     3128  (apply #'change-class class metaclass all-keys)
    31293129  (apply #'reinitialize-instance class
    31303130         :name name
Note: See TracChangeset for help on using the changeset viewer.