;;; -*- Mode:Common-Lisp; Package:TICLOS; Base:10; Patch-file:T -*-

;;; Reason: Fix to update MAKE-INSTANCE methods to accept new keyword arguments for 
;;; INITIALIZE-INSTANCE methods defined on a superclass of a superclass.  
;;; [SPR 9690]


;;;                           RESTRICTED RIGHTS LEGEND
;;;
;;; Use, duplication, or disclosure by the Government is subject to
;;; restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
;;; Technical Data and Computer Software clause at 52.227-7013.
;;;
;;;   TEXAS INSTRUMENTS INCORPORATED      
;;;   P.O. BOX 149149, M/S 2151             
;;;   AUSTIN, TEXAS 78714
;;;
;;; Copyright (C) 1989 Texas Instruments Incorporated.
;;; All rights reserved.

;;; Patch file for TI-CLOS version 6.13
;;; Written 07/05/89 15:12:50 by GRAY,
;;; while running on Kelvin from band LOD2
;;; With SYSTEM 6.10, VIRTUAL-MEMORY 6.1, EH 6.3, MAKE-SYSTEM 6.0, MICRONET 6.0, LOCAL-FILE 6.0,
;;;  BASIC-PATHNAME 6.0, NETWORK-SUPPORT-COLD 6.0, BASIC-NAMESPACE 6.1, NETWORK-NAMESPACE 6.0,
;;;  DISK-IO 6.0, DISK-LABEL 6.0, BASIC-FILE 6.2, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.0,
;;;  COMPILER 6.6, TV 6.12, DATALINK 6.0, CHAOSNET 6.0, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.1,
;;;  SYSLOG 6.1, STREAMER-TAPE 6.3, UCL 6.0, INPUT-EDITOR 6.0, Inconsistent METER 6.1,
;;;  ZWEI 6.3, DEBUG-TOOLS 6.3, NETWORK-SUPPORT 6.0, NETWORK-SERVICE 6.1, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.2, MAC-PRINTER-TYPES 6.1, PRINTER-TYPES 6.0,
;;;  IMAGEN 6.0, SUGGESTIONS 6.0, MAIL-DAEMON 6.2, MAIL-READER 6.0, TELNET 6.0, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.0, PROFILE 6.1, VISIDOC 6.2, Inconsistent TI-CLOS 6.12, CLEH 6.4,
;;;  IP 3.47, Experimental BUG 11.10, Experimental CLX 6.2, CLUE 6.6, X11M 6.1, Experimental DOCUMENTER 619.0,
;;;  Experimental GRAPHICS-WINDOW 6.0, Inconsistent GED 6.2,  microcode 429, Band Name: 6.0 SLE 6/5 + u429 6/8

;;; BUG REPORT NUMBER:  9690
;;;
;;; PROBLEM:  If an INITIALIZE-INSTANCE :AFTER method is redefined to accept 
;;;	an additional keyword argument, then MAKE-INSTANCE of a sub-class of a 
;;;	sub-class of the INITIALIZE-INSTANCE method class does not accept the new 
;;;	keyword.
;;;
;;; SOLUTION:  Fix (:METHOD INIT-GENERIC-FUNCTION :AFTER :ADD-METHOD) so that 
;;;	it not only rebuilds the MAKE-INSTANCE methods for the current class and 
;;;	its direct subclasses, but does so recursively to all levels of subclasses.

#!C
; From file MAKE-INSTANCE.LISP#> CLOS; MR-X:
#10R TICLOS#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "TICLOS"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* SYS:COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: CLOS; MAKE-INSTANCE.#"


;  7/05/89 DNG - Use new function REFINALIZE-METHODS so that 
;		subclasses to all levels are processed. [SPR 9690]
(defmethod (init-generic-function :after :add-method) (method)
  (LET((first-class (first (method-parameter-specializers method))))
    (when (AND (not (combined-method-p method))
	       (not (getf (method-plist method ) 'computed-method))
	       (not (individual-typep first-class)))
      (refinalize-methods first-class))))

;;  7/05/89 DNG - Original.
(defun refinalize-methods (class)
  (when (internal-class-finalized-p class)
    (finalize-inheritance-internal class :methods t))
  (when (class-composed-p class)
    (dolist (c (class-direct-subclasses class))
      (if (not (class-composed-p c))
	  ;; We shouldn't ever get here, but just in case the data structures have 
	  ;; gotten into an inconsistent state, this should clean things up.
	  (clos:finalize-inheritance c)
	(refinalize-methods c))))
  (values))
))
