Suppress warnings about possible slot name conflicts with slots from SB-PCL.
authorStas Boukarev <stassats@gmail.com>
Sat, 1 Dec 2012 19:44:37 +0000 (23:44 +0400)
committerStas Boukarev <stassats@gmail.com>
Sat, 1 Dec 2012 19:44:37 +0000 (23:44 +0400)
When inheriting from STANDARD-CLASS and using common slot names, like
SLOTS or NAME, SBCL signals a style-warning about possible package
problems with slots with the same name from SB-PCL, which is unlikely
to ever cause a problem.

src/pcl/std-class.lisp

index 9c077f9..c1e6af3 100644 (file)
                       (eq (class-of o) (class-of n)))
            (return nil)))))))
 
+(defun style-warn-about-duplicate-slots (class)
+  (do* ((slots (slot-value class 'slots) (cdr slots))
+        (dupes nil))
+       ((null slots)
+        (when dupes
+          (style-warn
+           "~@<slot names with the same SYMBOL-NAME but ~
+                  different SYMBOL-PACKAGE (possible package problem) ~
+                  for class ~S:~4I~@:_~<~@{~/sb-impl::print-symbol-with-prefix/~^~:@_~}~:>~@:>"
+           class dupes)))
+    (let* ((slot-name (slot-definition-name (car slots)))
+           (oslots (and (not (eq (symbol-package slot-name)
+                                 *pcl-package*))
+                        (remove-if
+                         (lambda (slot-name-2)
+                           (or (eq (symbol-package slot-name-2)
+                                   *pcl-package*)
+                               (string/= slot-name slot-name-2)))
+                         (cdr slots)
+                         :key #'slot-definition-name))))
+      (when oslots
+        (pushnew (cons slot-name
+                       (mapcar #'slot-definition-name oslots))
+                 dupes
+                 :test #'string= :key #'car)))))
+
 (defun %update-slots (class eslotds)
   (multiple-value-bind (instance-slots class-slots custom-slots)
       (classify-slotds eslotds)
             (wrapper-slot-table nwrapper) (make-slot-table class eslotds)
             (wrapper-length nwrapper) nslots
             (slot-value class 'wrapper) nwrapper)
-      (do* ((slots (slot-value class 'slots) (cdr slots))
-            (dupes nil))
-           ((null slots)
-            (when dupes
-              (style-warn
-               "~@<slot names with the same SYMBOL-NAME but ~
-                  different SYMBOL-PACKAGE (possible package problem) ~
-                  for class ~S:~4I~@:_~<~@{~/sb-impl::print-symbol-with-prefix/~^~:@_~}~:>~@:>"
-               class dupes)))
-        (let* ((slot (car slots))
-               (oslots (remove (slot-definition-name slot) (cdr slots)
-                               :test #'string/=
-                               :key #'slot-definition-name)))
-          (when oslots
-            (pushnew (cons (slot-definition-name slot)
-                           (mapcar #'slot-definition-name oslots))
-                     dupes
-                     :test #'string= :key #'car))))
+      (style-warn-about-duplicate-slots class)
       (setf (slot-value class 'finalized-p) t)
       (unless (eq owrapper nwrapper)
         (maybe-update-standard-slot-locations class)))))