From 0a6e39969b5667c85efca746a8f1b33c293b9564 Mon Sep 17 00:00:00 2001 From: Juraj Kirchheim Date: Sat, 7 Apr 2018 04:03:09 +0200 Subject: [PATCH] Fix direct initialization. --- src/tink/macro/Constructor.hx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/tink/macro/Constructor.hx b/src/tink/macro/Constructor.hx index 305c171..07f22d7 100644 --- a/src/tink/macro/Constructor.hx +++ b/src/tink/macro/Constructor.hx @@ -103,7 +103,7 @@ class Constructor { default: } addStatement((function () { - var fields = [for (f in Context.getLocalClass().get().fields.get()) f.name => f]; + var fields = [for (f in (macro this).typeof().sure().getClass().fields.get()) f.name => f]; function setDirectly(t:TypedExpr) { var direct = null; @@ -120,12 +120,8 @@ class Constructor { } return switch fields[name] { - case null: //trace(Context.getLocalClass().get().fields.get().length); throw ('assert'); - macro @:pos(pos) { - var v = this.$name; - v = $e; - (cast this).$name = v; - } + case null: + pos.error('this direct initialization causes the compiler to do really weird things'); case f: switch f.kind { case FVar(_, AccNormal | AccNo):