File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,6 +322,16 @@ private def mkSilentAnnotationIfHole (e : Expr) : TermElabM Expr := do
322322 -- Unify with expected type to resolve metavariables (e.g., `_` placeholders)
323323 discard <| isDefEq type expectedType
324324 let type ← instantiateMVars type
325+ -- Rebuild type with fresh synthetic mvars for instance-implicit args, so that
326+ -- synthesis is not influenced by the expected type's instance choices.
327+ let type ← do
328+ let fn := type.getAppFn
329+ let args := type.getAppArgs
330+ let (mvars, bis, _) ← forallMetaTelescope (← inferType fn)
331+ for i in [:args.size] do
332+ unless bis[i]!.isInstImplicit do
333+ mvars[i]!.mvarId!.assign args[i]!
334+ instantiateMVars (mkAppN fn mvars)
325335 let inst ← synthInstance type
326336 -- Normalize to instance normal form.
327337 let compile := !(← read).isNoncomputableSection && !(← read).declName?.any (Lean.isNoncomputable (← getEnv))
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ instance [MyMonad m] : MyMonad (MyStateRefT σ m) :=
1818instance [MyMonad m] [MyLawful m] : MyLawful (MyReaderT ρ m) where
1919 law := trivial
2020
21- --set_option backward.isDefEq.respectTransparency false in
21+ instance [MyMonad m] [MyLawful m] : MyLawful (MyStateRefT σ m) :=
22+ inferInstanceAs (MyLawful (MyReaderT σ m))
23+
2224instance [MyMonad m] [MyLawful m] : MyLawful (MyStateRefT σ m) :=
2325 inferInstanceAs (MyLawful (MyReaderT _ _))
You can’t perform that action at this time.
0 commit comments