Quellcode durchsuchen

Revert "don't generate constructor on abstract classes"

This reverts commit d38ba0ea2a86b3942ba8b99cb2a71fc0359068da.
Simon Krajewski vor 4 Monaten
Ursprung
Commit
85362b9614

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1781,7 +1781,7 @@ let init_class ctx_c cctx c p herits fields =
 		| _ ->
 			()
 	end;
-	if not has_struct_init && not (has_class_flag c CAbstract) then
+	if not has_struct_init then
 		(* add_constructor does not deal with overloads correctly *)
 		if not com.config.pf_overload then TypeloadFunction.add_constructor ctx_c c cctx.force_constructor p;
 	finalize_class cctx

+ 0 - 22
tests/misc/projects/Issue12023/Macro.hx

@@ -1,22 +0,0 @@
-import haxe.macro.Context;
-import haxe.macro.Expr.Field;
-import haxe.macro.Type.ClassType;
-
-using haxe.macro.TypeTools;
-
-class Macro {
-	public static macro function build():Array<Field> {
-		var fields:Array<Field> = Context.getBuildFields();
-		var classType:ClassType = Context.getLocalClass().get();
-
-		if (classType.isAbstract) {
-			fields.push({
-				name: "someFieldToAbstractClass",
-				pos: Context.currentPos(),
-				kind: FVar(macro :Int, macro $v{1})
-			});
-		}
-
-		return fields;
-	}
-}

+ 0 - 16
tests/misc/projects/Issue12023/Main.hx

@@ -1,16 +0,0 @@
-class Main extends MyAbstractClass {
-	static function main() {
-		trace('myVar = ${new Main().myVar}');
-	}
-
-	public function new() {}
-}
-
-abstract class MyAbstractClass implements MyInterface {
-	public final myVar:Int;
-}
-
-@:autoBuild(Macro.build())
-interface MyInterface {
-	public final myVar:Int;
-}

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

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

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

@@ -1,2 +0,0 @@
-Main.hx:1: characters 7-11 : Some final fields are uninitialized in this class
-Main.hx:10: characters 15-20 : Uninitialized field