Răsfoiți Sursa

add `Display.requires_full_typing`

Simon Krajewski 9 ani în urmă
părinte
comite
bfa86b376c
3 a modificat fișierele cu 10 adăugiri și 9 ștergeri
  1. 4 0
      src/display/display.ml
  2. 3 6
      src/main.ml
  3. 3 3
      src/typing/typeload.ml

+ 4 - 0
src/display/display.ml

@@ -26,6 +26,10 @@ exception DisplaySubExpression of Ast.expr
 exception DisplayFields of (string * t * display_field_kind option * documentation) list
 exception DisplayToplevel of identifier_type list
 
+let requires_full_typing = function
+	| DMUsage | DMNone -> true
+	| DMPosition | DMResolve _ | DMDefault | DMModuleSymbols | DMToplevel | DMType -> false
+
 let is_display_file p =
 	Common.unique_full_path p.pfile = (!Parser.resume_display).pfile
 

+ 3 - 6
src/main.ml

@@ -1566,12 +1566,9 @@ try
 		Typer.finalize tctx;
 		t();
 		if ctx.has_error then raise Abort;
-		begin match com.display with
-			| DMNone | DMUsage ->
-				()
-			| _ ->
-				if ctx.has_next then raise Abort;
-				failwith "No completion point was found";
+		if not (Display.requires_full_typing ctx.com.display) then begin
+			if ctx.has_next then raise Abort;
+			failwith "No completion point was found";
 		end;
 		let t = Common.timer "filters" in
 		let main, types, modules = Typer.generate tctx in

+ 3 - 3
src/typing/typeload.ml

@@ -2099,8 +2099,7 @@ module ClassInitializer = struct
 			| TMono r -> (match !r with None -> false | Some t -> is_full_type t)
 			| TAbstract _ | TInst _ | TEnum _ | TLazy _ | TDynamic _ | TAnon _ | TType _ -> true
 		in
-		match ctx.com.display with
-			| DMNone | DMUsage ->
+		if Display.requires_full_typing ctx.com.display then begin
 				if fctx.is_macro && not ctx.in_macro then
 					()
 				else begin
@@ -2108,7 +2107,7 @@ module ClassInitializer = struct
 					(* is_lib ? *)
 					cctx.delayed_expr <- (ctx,Some r) :: cctx.delayed_expr;
 				end
-			| _ ->
+		end else begin
 			if fctx.is_display_field then begin
 				if fctx.is_macro && not ctx.in_macro then
 					(* force macro system loading of this class in order to get completion *)
@@ -2123,6 +2122,7 @@ module ClassInitializer = struct
 					cf.cf_type <- TLazy r;
 				end;
 			end
+		end
 
 	let bind_var (ctx,cctx,fctx) cf e =
 		let c = cctx.tclass in