Skip to content

Commit

Permalink
fix forced constructor creation (closes #4557)
Browse files Browse the repository at this point in the history
Instead of not generating constructor for classes that extend a forced constructor class, we create a constructor but retain the `@:compilerGenerated` metadata.
  • Loading branch information
Simn committed Nov 26, 2015
1 parent 0826647 commit 4560d28
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions tests/unit/src/unit/issues/Issue4557.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package unit.issues;

private class Ghost {
public var value:String;
public function new(value) {
this.value = value;
}
}

private class A {
public var ghost = new Ghost("booh!");
}

private class B extends A { }

private class C extends B {
public function new() { }
}

class Issue4557 extends Test {
function test() {
var c = new C();
eq("booh!", c.ghost.value);
}
}
4 changes: 2 additions & 2 deletions typeload.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,11 @@ let check_strict_meta ctx metas =

let rec add_constructor ctx c force_constructor p =
match c.cl_constructor, c.cl_super with
| None, Some ({ cl_constructor = Some cfsup } as csup,cparams) when not c.cl_extern && not (Meta.has Meta.CompilerGenerated cfsup.cf_meta) ->
| None, Some ({ cl_constructor = Some cfsup } as csup,cparams) when not c.cl_extern ->
let cf = {
cfsup with
cf_pos = p;
cf_meta = [];
cf_meta = List.filter (fun (m,_,_) -> m = Meta.CompilerGenerated) cfsup.cf_meta;
cf_doc = None;
cf_expr = None;
} in
Expand Down

0 comments on commit 4560d28

Please sign in to comment.