Browse Source

[typer] don't check abstract classes that are loaded from externs

Simon Krajewski 5 years ago
parent
commit
2d25286467

+ 0 - 2
src/typing/typeloadCheck.ml

@@ -539,8 +539,6 @@ module Inheritance = struct
 					end
 				end else begin
 					if (has_class_flag csup CInterface) then error "Cannot extend by using an interface" p;
-					if (has_class_flag csup CAbstract) && not (has_class_flag c CAbstract) then
-						delay ctx PForce (fun () -> check_abstract_class ctx c csup params);
 					c.cl_super <- Some (csup,params)
 				end;
 				(fun () ->

+ 9 - 2
src/typing/typeloadFields.ml

@@ -516,7 +516,7 @@ let create_class_context ctx c context_init p =
 			ctx.com.error msg ep;
 			(* macros expressions might reference other code, let's recall which class we are actually compiling *)
 			let open TFunctions in
-			if !locate_macro_error && (is_pos_outside_class c ep) && not (is_module_fields_class c) then ctx.com.error (compl_msg "Defined in this class") c.cl_pos
+			if not (ExtString.String.starts_with msg "...") && !locate_macro_error && (is_pos_outside_class c ep) && not (is_module_fields_class c) then ctx.com.error (compl_msg "Defined in this class") c.cl_pos
 		);
 	} in
 	(* a lib type will skip most checks *)
@@ -1513,7 +1513,14 @@ let init_class ctx c p context_init herits fields =
 	let fields = build_fields (ctx,cctx) c fields in
 	if cctx.is_core_api && ctx.com.display.dms_check_core_api then delay ctx PForce (fun() -> init_core_api ctx c);
 	if not cctx.is_lib then begin
-		delay ctx PForce (fun() -> check_overloads ctx c)
+		delay ctx PForce (fun() -> check_overloads ctx c);
+		begin match c.cl_super with
+		| Some(csup,tl) ->
+			if (has_class_flag csup CAbstract) && not (has_class_flag c CAbstract) then
+				delay ctx PForce (fun () -> TypeloadCheck.Inheritance.check_abstract_class ctx c csup tl);
+		| None ->
+			()
+		end
 	end;
 	let rec has_field f = function
 		| None -> false

+ 1 - 2
tests/misc/projects/Issue5949/compile-fail.hxml.stderr

@@ -1,3 +1,2 @@
 Main.hx:11: characters 11-14 : Field a has different @:native value than in superclass
-Main.hx:6: characters 18-19 : ... Base field is defined here
-Main.hx:10: lines 10-12 : ... Defined in this class
+Main.hx:6: characters 18-19 : ... Base field is defined here

+ 1 - 3
tests/misc/projects/Issue9010/NativeMeta-fail.hxml.stderr

@@ -1,6 +1,4 @@
 NativeMeta.hx:4: characters 11-24 : Field some has different @:native value than in superclass
 NativeMeta.hx:16: characters 11-25 : ... Base field is defined here
-NativeMeta.hx:1: lines 1-13 : ... Defined in this class
 NativeMeta.hx:9: characters 11-25 : Field noNative has different @:native value than in superclass
-NativeMeta.hx:20: characters 18-26 : ... Base field is defined here
-NativeMeta.hx:1: lines 1-13 : ... Defined in this class
+NativeMeta.hx:20: characters 18-26 : ... Base field is defined here