Browse Source

[typer] the _Impl_ are everywhere...

closes #7076
Simon Krajewski 7 years ago
parent
commit
3d584593b1

+ 8 - 1
src/core/type.ml

@@ -2832,4 +2832,11 @@ module TClass = struct
 
 	let get_all_fields c tl =
 		get_member_fields' true c tl
-end
+end
+
+let s_class_path c =
+	let path = match c.cl_kind with
+		| KAbstractImpl a -> a.a_path
+		| _ -> c.cl_path
+	in
+	s_type_path path

+ 1 - 1
src/typing/typer.ml

@@ -1809,7 +1809,7 @@ and type_new ctx path el with_type p =
 	let build_constructor_call c tl =
 		let ct, f = get_constructor ctx c tl p in
 		if (Meta.has Meta.CompilerGenerated f.cf_meta) then display_error ctx (error_msg (No_constructor (TClassDecl c))) p;
-		if not (can_access ctx c f true || is_parent c ctx.curclass) && not ctx.untyped then display_error ctx (Printf.sprintf "Cannot access private constructor of %s" (s_type_path c.cl_path)) p;
+		if not (can_access ctx c f true || is_parent c ctx.curclass) && not ctx.untyped then display_error ctx (Printf.sprintf "Cannot access private constructor of %s" (s_class_path c)) p;
 		(match f.cf_kind with
 		| Var { v_read = AccRequire (r,msg) } -> (match msg with Some msg -> error msg p | None -> error_require r p)
 		| _ -> ());

+ 9 - 0
tests/misc/projects/Issue7076/Main.hx

@@ -0,0 +1,9 @@
+class Main {
+	public static function main() {
+		new Foo(0);
+	}
+}
+
+abstract Foo(Int) {
+	function new(value:Int) this = value;
+}

+ 2 - 0
tests/misc/projects/Issue7076/compile-fail.hxml

@@ -0,0 +1,2 @@
+-main Main
+--interp

+ 1 - 0
tests/misc/projects/Issue7076/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:3: characters 3-13 : Cannot access private constructor of Foo