Przeglądaj źródła

[display] close monomorphs if we're completing on them

Simon Krajewski 5 lat temu
rodzic
commit
c862176a4f
2 zmienionych plików z 9 dodań i 1 usunięć
  1. 1 1
      src/context/display/displayFields.ml
  2. 8 0
      src/core/tUnification.ml

+ 1 - 1
src/context/display/displayFields.ml

@@ -120,7 +120,7 @@ let collect ctx e_ast e dk with_type p =
 	in
 	let rec loop items t =
 		let is_new_item items name = not (PMap.mem name items) in
-		match follow t with
+		match follow_and_close t with
 		| TInst ({cl_kind = KTypeParameter tl},_) ->
 			(* Type parameters can access the fields of their constraints *)
 			List.fold_left (fun acc t -> loop acc t) items tl

+ 8 - 0
src/core/tUnification.ml

@@ -174,6 +174,14 @@ module Monomorph = struct
 		m.tm_type <- None
 end
 
+let rec follow_and_close t = match follow t with
+	| TMono r as t ->
+		Monomorph.close r;
+		if r.tm_type <> None then follow_and_close t
+		else t
+	| t ->
+		t
+
 let rec link e a b =
 	(* tell if setting a == b will create a type-loop *)
 	let rec loop t =