Browse Source

fix some `@:impl` positions (closes #5684)

Simon Krajewski 9 years ago
parent
commit
908b5ca3e4
2 changed files with 17 additions and 2 deletions
  1. 2 2
      src/typing/typeload.ml
  2. 15 0
      tests/display/src/cases/Issue5684.hx

+ 2 - 2
src/typing/typeload.ml

@@ -42,7 +42,7 @@ let transform_abstract_field com this_t a_t a f =
 		let init p = (EVars [("this",null_pos),Some this_t,None],p) in
 		let init p = (EVars [("this",null_pos),Some this_t,None],p) in
 		let cast e = (ECast(e,None)),pos e in
 		let cast e = (ECast(e,None)),pos e in
 		let ret p = (EReturn (Some (cast (EConst (Ident "this"),p))),p) in
 		let ret p = (EReturn (Some (cast (EConst (Ident "this"),p))),p) in
-		let meta = (Meta.Impl,[],p) :: f.cff_meta in
+		let meta = (Meta.Impl,[],null_pos) :: f.cff_meta in
 		let meta = if Meta.has Meta.MultiType a.a_meta then begin
 		let meta = if Meta.has Meta.MultiType a.a_meta then begin
 			if List.mem AInline f.cff_access then error "MultiType constructors cannot be inline" f.cff_pos;
 			if List.mem AInline f.cff_access then error "MultiType constructors cannot be inline" f.cff_pos;
 			if fu.f_expr <> None then error "MultiType constructors cannot have a body" f.cff_pos;
 			if fu.f_expr <> None then error "MultiType constructors cannot have a body" f.cff_pos;
@@ -65,7 +65,7 @@ let transform_abstract_field com this_t a_t a f =
 	| FFun fu when not stat ->
 	| FFun fu when not stat ->
 		if Meta.has Meta.From f.cff_meta then error "@:from cast functions must be static" f.cff_pos;
 		if Meta.has Meta.From f.cff_meta then error "@:from cast functions must be static" f.cff_pos;
 		let fu = { fu with f_args = (if List.mem AMacro f.cff_access then fu.f_args else (("this",null_pos),false,[],Some this_t,None) :: fu.f_args) } in
 		let fu = { fu with f_args = (if List.mem AMacro f.cff_access then fu.f_args else (("this",null_pos),false,[],Some this_t,None) :: fu.f_args) } in
-		{ f with cff_kind = FFun fu; cff_access = AStatic :: f.cff_access; cff_meta = (Meta.Impl,[],p) :: f.cff_meta }
+		{ f with cff_kind = FFun fu; cff_access = AStatic :: f.cff_access; cff_meta = (Meta.Impl,[],null_pos) :: f.cff_meta }
 	| _ ->
 	| _ ->
 		f
 		f
 
 

+ 15 - 0
tests/display/src/cases/Issue5684.hx

@@ -0,0 +1,15 @@
+package cases;
+
+class Issue5684 extends DisplayTestCase {
+	/**
+	abstract Test(String) {
+		public function hi(){
+			this.{-1-}
+		}
+	}
+	**/
+	function testType1() {
+		// eq("Int", type(pos(1)));
+		eq(true, hasField(fields(pos(1)), "length", "Int"));
+	}
+}