Przeglądaj źródła

[display] respect `dms_inline` for inline variables

closes #7098
Simon Krajewski 7 lat temu
rodzic
commit
22f39966f5

+ 9 - 8
src/core/type.ml

@@ -1071,6 +1071,14 @@ let s_const = function
 	| TThis -> "this"
 	| TSuper -> "super"
 
+let s_field_access s_type fa = match fa with
+	| FStatic (c,f) -> "static(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ ")"
+	| FInstance (c,_,f) -> "inst(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ " : " ^ s_type f.cf_type ^ ")"
+	| FClosure (c,f) -> "closure(" ^ (match c with None -> f.cf_name | Some (c,_) -> s_type_path c.cl_path ^ "." ^ f.cf_name)  ^ ")"
+	| FAnon f -> "anon(" ^ f.cf_name ^ ")"
+	| FEnum (en,f) -> "enum(" ^ s_type_path en.e_path ^ "." ^ f.ef_name ^ ")"
+	| FDynamic f -> "dynamic(" ^ f ^ ")"
+
 let rec s_expr s_type e =
 	let sprintf = Printf.sprintf in
 	let slist f l = String.concat "," (List.map f l) in
@@ -1090,14 +1098,7 @@ let rec s_expr s_type e =
 	| TEnumParameter (e1,_,i) ->
 		sprintf "%s[%i]" (loop e1) i
 	| TField (e,f) ->
-		let fstr = (match f with
-			| FStatic (c,f) -> "static(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ ")"
-			| FInstance (c,_,f) -> "inst(" ^ s_type_path c.cl_path ^ "." ^ f.cf_name ^ " : " ^ s_type f.cf_type ^ ")"
-			| FClosure (c,f) -> "closure(" ^ (match c with None -> f.cf_name | Some (c,_) -> s_type_path c.cl_path ^ "." ^ f.cf_name)  ^ ")"
-			| FAnon f -> "anon(" ^ f.cf_name ^ ")"
-			| FEnum (en,f) -> "enum(" ^ s_type_path en.e_path ^ "." ^ f.ef_name ^ ")"
-			| FDynamic f -> "dynamic(" ^ f ^ ")"
-		) in
+		let fstr = s_field_access s_type f in
 		sprintf "%s.%s" (loop e) fstr
 	| TTypeExpr m ->
 		sprintf "TypeExpr %s" (s_type_path (t_path m))

+ 2 - 0
src/typing/calls.ml

@@ -450,6 +450,8 @@ let rec acc_get ctx g p =
 			mk (TField (e,cmode)) t p
 		| None ->
 			error "Recursive inline is not supported" p
+		| Some _ when not (ctx.com.display.dms_inline) ->
+			mk (TField (e,cmode)) t p
 		| Some { eexpr = TFunction _ } ->
 			let chk_class c = (c.cl_extern || f.cf_extern) && not (Meta.has Meta.Runtime f.cf_meta) in
 			let wrap_extern c =

+ 14 - 1
src/typing/typerBase.ml

@@ -143,4 +143,17 @@ let rec type_module_type ctx t tparams p =
 		mk (TTypeExpr (TAbstractDecl a)) (TType (t_tmp,[])) p
 
 let type_type ctx tpath p =
-	type_module_type ctx (Typeload.load_type_def ctx p { tpackage = fst tpath; tname = snd tpath; tparams = []; tsub = None }) None p
+	type_module_type ctx (Typeload.load_type_def ctx p { tpackage = fst tpath; tname = snd tpath; tparams = []; tsub = None }) None p
+
+let s_access_kind acc =
+	let st = s_type (print_context()) in
+	let se = s_expr_pretty true "" false st in
+	let sfa = s_field_access st in
+	match acc with
+	| AKNo s -> "AKNo " ^ s
+	| AKExpr e -> "AKExpr " ^ (se e)
+	| AKSet(e,t,cf) -> Printf.sprintf "AKSet(%s, %s, %s)" (se e) (st t) cf.cf_name
+	| AKInline(e,cf,fa,t) -> Printf.sprintf "AKInline(%s, %s, %s, %s)" (se e) cf.cf_name (sfa fa) (st t)
+	| AKMacro(e,cf) -> Printf.sprintf "AKMacro(%s, %s)" (se e) cf.cf_name
+	| AKUsing(e1,c,cf,e2) -> Printf.sprintf "AKMacro(%s, %s, %s, %s)" (se e1) (s_type_path c.cl_path) cf.cf_name (se e2)
+	| AKAccess(a,tl,c,e1,e2) -> Printf.sprintf "AKAccess(%s, [%s], %s, %s, %s)" (s_type_path a.a_path) (String.concat ", " (List.map st tl)) (s_type_path c.cl_path) (se e1) (se e2)

+ 16 - 0
tests/display/src/cases/Issue7098.hx

@@ -0,0 +1,16 @@
+package cases;
+
+class Issue7098 extends DisplayTestCase {
+	/**
+	import misc.issue7098.Bar;
+	class Main {
+		public static function main() {
+			Bar.foo(Va{-1-}lue);
+		}
+	}
+	**/
+	function test() {
+		var pos = position(pos(1));
+		eq("Bar.hx:4: characters 6-11", pos.substr(-25));
+	}
+}

+ 9 - 0
tests/display/src/misc/issue7098/Bar.hx

@@ -0,0 +1,9 @@
+package misc.issue7098;
+
+@:enum abstract Foo(Int) {
+	var Value = 0;
+}
+
+class Bar {
+	public static function foo(f:Foo) {}
+}