packages feed

ghc-tcplugin-api 0.5.0.0 → 0.5.1.0

raw patch · 3 files changed

+15/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,4 +1,8 @@ 
+# Version 0.5.1.0 (2021-08-31)
+
+- Fix a bug in the type-family rewriting compatibility layer (GHC 8.10, 9.0, 9.2)
+  by correctly downgrading the coercion used to cast the evidence, when necessary.
 
 # Version 0.5.0.0 (2021-08-30)
 
ghc-tcplugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version:  3.0
 name:           ghc-tcplugin-api
-version:        0.5.0.0
+version:        0.5.1.0
 synopsis:       An API for type-checker plugins.
 license:        BSD-3-Clause
 build-type:     Simple
src/GHC/TcPlugin/API/Internal/Shim.hs view
@@ -50,7 +50,8 @@ 
 -- ghc
 import GHC.Core.Coercion
-  ( mkReflCo, mkSymCo
+  ( coercionRole
+  , mkReflCo, mkSymCo
   , mkAppCos, mkNomReflCo, mkSubCo
   , mkTyConAppCo, tyConRolesX
   , tyConRolesRepresentational
@@ -310,11 +311,16 @@         Given     -> error "ghc-tcplugin-api: unexpected Given in reduceCt"
         Wanted {} -> newWanted  ( ctLoc ct ) predTy'
         Derived   -> newDerived ( ctLoc ct ) predTy'
+      let
+        role :: Role
+        role = coercionRole co
+        cast_co :: Coercion
+        cast_co = mkSymCo $ case role of
+          Nominal -> mkSubCo co
+          _       -> co
       pure ( Just
               ( mkNonCanonical ctEv'
-              , ( evCast ( ctEvExpr ctEv' ) ( mkSymCo co )
-                , ct
-                )
+              , ( evCast ( ctEvExpr ctEv' ) cast_co, ct )
               )
            , newCts
            )