-
-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3228 from nadako/3198_anon_extend
store structure extended types and expose it to the macro api with AnonStatus.AExtend (closes #3198)
- Loading branch information
Showing
7 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package unit.issues; | ||
|
||
#if macro | ||
import haxe.macro.Context; | ||
#end | ||
|
||
private typedef A = {a:Int} | ||
private typedef B = {b:Int} | ||
private typedef C = {>A,} | ||
private typedef D = {>A, >B,} | ||
|
||
class Issue3198 extends Test { | ||
function test() { | ||
eq(getExtends((null : C)), "A"); | ||
eq(getExtends((null : D)), "A,B"); | ||
} | ||
|
||
static macro function getExtends(e) { | ||
switch (Context.follow(Context.typeof(e))) { | ||
case TAnonymous(_.get() => {status: AExtend(_.get() => tl)}): | ||
var p = []; | ||
for (t in tl) switch (t) { | ||
case TType(_.get() => dt, []): | ||
p.push(dt.name); | ||
default: | ||
throw false; | ||
} | ||
return macro $v{p.join(",")}; | ||
default: | ||
throw false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters