Propagate replacement flag for autoload interfaces
authorAndy Wingo <wingo@pobox.com>
Thu, 5 Dec 2019 13:05:51 +0000 (14:05 +0100)
committerAndy Wingo <wingo@pobox.com>
Thu, 5 Dec 2019 13:05:51 +0000 (14:05 +0100)
* module/ice-9/boot-9.scm (make-autoload-interface): Propagate replaced
  binding flags to autoload interface.

module/ice-9/boot-9.scm

index a18a32b0d5485f11c2c5545552c927f0eb9852f7..b5ce5f355425d45783b9ec03960659a1d5af66b7 100644 (file)
@@ -3415,15 +3415,21 @@ error if selected binding does not exist in the used module."
   (let ((b (lambda (a sym definep)
              (false-if-exception
               (and (memq sym bindings)
-                   (let ((i (module-public-interface (resolve-module name))))
-                     (if (not i)
-                         (error "missing interface for module" name))
-                     (let ((autoload (memq a (module-uses module))))
-                       ;; Replace autoload-interface with actual interface if
-                       ;; that has not happened yet.
-                       (if (pair? autoload)
-                           (set-car! autoload i)))
-                     (module-local-variable i sym)))
+                   (let ((i (resolve-interface name #:select bindings)))
+                     (unless i
+                       (error "missing interface for module" name))
+                     (let ((uses (memq a (module-uses module))))
+                       (when uses
+                         ;; Replace autoload-interface with actual
+                         ;; interface.
+                         (set-car! uses i)))
+                     (for-each
+                      (lambda (name)
+                        (when (hashq-ref (module-replacements i) name)
+                          (hashq-set! (module-replacements a) name #t)))
+                      bindings)
+                     (or (module-local-variable i sym)
+                         (error "binding not presentin module" name sym))))
               #:warning "Failed to autoload ~a in ~a:\n" sym name))))
     (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f
                         (make-hash-table 0) '() (make-weak-value-hash-table) #f