Răsfoiți Sursa

[java] make @:strict more strict

closes #10517
Simon Krajewski 3 ani în urmă
părinte
comite
cb4a2ae729

+ 21 - 9
src/typing/typeloadModule.ml

@@ -136,18 +136,30 @@ module StrictMeta = struct
 		let pf = ctx.com.platform in
 		let changed_expr, fields_to_check, ctype = match params with
 			| [ECall(ef, el),p] ->
-				(* check last argument *)
-				let el, fields = match List.rev el with
-					| (EObjectDecl(decl),_) :: el ->
-						List.rev el, decl
-					| _ ->
-						el, []
-				in
 				let tpath = field_to_type_path ctx ef in
-				if pf = Cs then
+				begin match pf with
+				| Cs ->
+					let el, fields = match List.rev el with
+						| (EObjectDecl(decl),_) :: el ->
+							List.rev el, decl
+						| _ ->
+							el, []
+					in
 					(ENew((tpath,snd ef), el), p), fields, CTPath tpath
-				else
+				| Java ->
+					let fields = match el with
+					| [EObjectDecl(fields),_] ->
+						fields
+					| [] ->
+						[]
+					| (_,p) :: _ ->
+						display_error ctx "Object declaration expected" p;
+						[]
+					in
 					ef, fields, CTPath tpath
+				| _ ->
+					Error.typing_error "@:strict is not supported on this target" p
+				end
 			| [EConst(Ident i),p as expr] ->
 				let tpath = { tpackage=[]; tname=i; tparams=[]; tsub=None } in
 				if pf = Cs then

+ 6 - 0
tests/misc/java/projects/Issue10517/Main.hx

@@ -0,0 +1,6 @@
+@:strict(jvm.annotation.ClassReflectionInformation(hasSuperClass = false))
+class Main {
+	static function main() {
+
+	}
+}

+ 3 - 0
tests/misc/java/projects/Issue10517/compile-fail.hxml

@@ -0,0 +1,3 @@
+-main Main
+--jvm whatever.jar
+--no-output

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

@@ -0,0 +1 @@
+Main.hx:1: characters 52-73 : Object declaration expected