- = initRn dflags hit hst pcs (panic "checkOldIface: bogus mod") $
-
- -- Load the old interface file, if we havn't already got it
- loadOldIface iface_path maybe_iface `thenRn` \ maybe_iface2 ->
-
- -- Check versions
- recompileRequired iface_path source_unchanged maybe_iface2 `thenRn` \ recompile ->
-
- returnRn (recompile, maybe_iface2)
+ = case maybe_iface of
+ Just old_iface -> -- Use the one we already have
+ startRn (mi_module old_iface) $
+ check_versions old_iface
+ Nothing -- try and read it from a file
+ -> do read_result <- readIface do_traceRn iface_path
+ case read_result of
+ Left err -> -- Old interface file not found, or garbled; give up
+ return (pcs, False, (outOfDate, Nothing))
+ Right parsed_iface
+ -> startRn (pi_mod parsed_iface) $
+ loadOldIface parsed_iface `thenRn` \ m_iface ->
+ check_versions m_iface
+ where
+ check_versions :: ModIface -> RnMG (RecompileRequired, Maybe ModIface)
+ check_versions iface
+ = -- Check versions
+ recompileRequired iface_path source_unchanged iface
+ `thenRn` \ recompile ->
+ returnRn (recompile, Just iface)
+
+ do_traceRn = dopt Opt_D_dump_rn_trace dflags
+ ioTraceRn sdoc = if do_traceRn then printErrs sdoc else return ()
+ startRn mod = initRn dflags hit hst pcs mod