src/: Guess the metaclass early, unless we're explicitly bootstrapping.
[sod] / src / builtin.lisp
index 77eca39..5897da0 100644 (file)
@@ -279,7 +279,7 @@ static const SodClass *const ~A__cpl[] = {
 
 (definst suppliedp-struct (stream) (flags var)
   (format stream
-         "~@<struct { ~2I~_~{unsigned ~A : 1;~^ ~_~} ~I~_} ~A;~:>"
+         "~@<struct { ~2I~_~{unsigned ~A: 1;~^ ~_~} ~I~_} ~A;~:>"
          flags var))
 
 ;; Initialization.
@@ -295,15 +295,28 @@ static const SodClass *const ~A__cpl[] = {
   'initialization-effective-method)
 
 (defmethod method-keyword-argument-lists
-    ((method initialization-effective-method) direct-methods)
+    ((method initialization-effective-method) direct-methods state)
   (append (call-next-method)
          (mapcan (lambda (class)
-                   (let ((initargs (sod-class-initargs class)))
+                   (let* ((initargs (sod-class-initargs class))
+                          (map (make-hash-table))
+                          (arglist (mapcar
+                                    (lambda (initarg)
+                                      (let ((arg (sod-initarg-argument
+                                                  initarg)))
+                                        (setf (gethash arg map) initarg)
+                                        arg))
+                                    initargs)))
                      (and initargs
-                          (list (cons (format nil "initargs for ~A"
-                                              class)
-                                      (mapcar #'sod-initarg-argument
-                                              initargs))))))
+                          (list (cons (lambda (arg)
+                                        (info-with-location
+                                         (gethash arg map)
+                                         "Type `~A' from initarg ~
+                                          in class `~A' (here)"
+                                         (argument-type arg) class)
+                                        (report-inheritance-path
+                                         state class))
+                                      arglist)))))
                  (sod-class-precedence-list
                   (effective-method-class method)))))
 
@@ -504,9 +517,11 @@ static const SodClass *const ~A__cpl[] = {
    instance of `SodClass', and `SodClass' is a subclass of `SodObject' (and
    an instance of itself)."
   (let* ((sod-object (make-sod-class "SodObject" nil
-                                    (make-property-set :nick 'obj)))
+                                    (make-property-set :nick 'obj
+                                                       :%bootstrapping t)))
         (sod-class (make-sod-class "SodClass" (list sod-object)
-                                   (make-property-set :nick 'cls)))
+                                   (make-property-set :nick 'cls
+                                                      :%bootstrapping t)))
         (classes (list sod-object sod-class)))
 
     ;; Attach the built-in messages.