make adhoc_overloading respect type constraints
authorKevin Kappelmann <kevin.kappelmann@tum.de>
Wed, 17 Apr 2024 15:04:27 +0200
changeset 80127 39f9084a9668
parent 80126 b73df63e0f52
child 80128 2fe244c4bb01
make adhoc_overloading respect type constraints
src/HOL/Library/adhoc_overloading.ML
--- a/src/HOL/Library/adhoc_overloading.ML	Tue Apr 16 17:28:58 2024 +0200
+++ b/src/HOL/Library/adhoc_overloading.ML	Wed Apr 17 15:04:27 2024 +0200
@@ -154,7 +154,9 @@
 fun get_candidates ctxt (c, T) =
   get_variants ctxt c
   |> Option.map (map_filter (fn (t, T') =>
-    if unifiable_with (Proof_Context.theory_of ctxt) T T' then SOME t
+    if unifiable_with (Proof_Context.theory_of ctxt) T T'
+    (*keep the type constraint for the type-inference check phase*)
+    then SOME (Type.constraint T t)
     else NONE));
 
 fun insert_variants ctxt t (oconst as Const (c, T)) =