From eb1a6ab1df473c7ec0e1cbb20fc7124706326ce1 Mon Sep 17 00:00:00 2001
From: sheaf <sam.derbyshire@gmail.com>
Date: Thu, 13 Jul 2023 16:03:31 +0200
Subject: [PATCH] Don't use substTyUnchecked in newMetaTyVar

There were some comments that explained that we needed to use an
unchecked substitution function because of issue #12931, but that
has since been fixed, so we should be able to use substTy instead now.
---
 compiler/GHC/Tc/Utils/TcMType.hs | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/compiler/GHC/Tc/Utils/TcMType.hs b/compiler/GHC/Tc/Utils/TcMType.hs
index 55cad5847284..239b293a9150 100644
--- a/compiler/GHC/Tc/Utils/TcMType.hs
+++ b/compiler/GHC/Tc/Utils/TcMType.hs
@@ -1001,16 +1001,7 @@ new_meta_tv_x info subst tv
         ; let subst1 = extendTvSubstWithClone subst tv new_tv
         ; return (subst1, new_tv) }
   where
-    substd_kind = substTyUnchecked subst (tyVarKind tv)
-      -- NOTE: #12549 is fixed so we could use
-      -- substTy here, but the tc_infer_args problem
-      -- is not yet fixed so leaving as unchecked for now.
-      -- OLD NOTE:
-      -- Unchecked because we call newMetaTyVarX from
-      -- tcInstTyBinder, which is called from tcInferTyApps
-      -- which does not yet take enough trouble to ensure
-      -- the in-scope set is right; e.g. #12785 trips
-      -- if we use substTy here
+    substd_kind = substTy subst (tyVarKind tv)
 
 newMetaTyVarTyAtLevel :: TcLevel -> TcKind -> TcM TcType
 newMetaTyVarTyAtLevel tc_lvl kind
-- 
GitLab