Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata not apply on generated @:generic classes #6500

Closed
aliokan opened this issue Aug 9, 2017 · 5 comments · Fixed by #11376
Closed

metadata not apply on generated @:generic classes #6500

aliokan opened this issue Aug 9, 2017 · 5 comments · Fixed by #11376
Milestone

Comments

@aliokan
Copy link
Contributor

aliokan commented Aug 9, 2017

On my case, I try to apply @:keep on @:generic classe, and keeping is not apply on generated classes.

with Haxe Compiler 3.4.2 (git build development @ ada466c), target JS

@back2dos provide a workaround by macro, but could be better if its support directly by the Compiler. :)

/**
 * Copy metadata in from generic class to concrete class
 * @example in hxml --macro com.utils.DCEMacroUtil.transplantMetaToGenericInstances()
 * link: http://try-haxe.mrcdk.com/#1b5E0
**/
macro static public function transplantMetaToGenericInstances() {
    haxe.macro.Context.onGenerate(function (types) {
        var marker = ':already transplanted';
        for (t in types)
            switch t {
                case TInst(_.get() => { meta: meta, kind: KGenericInstance(_.get() => original, _) }, _) if (!meta.has(marker)):
                    meta.add(marker, [], original.pos);
                    for (m in original.meta.get())
                        meta.add(m.name, m.params, m.pos);
                default:
            }
    });
    return macro null;
}
@nadako
Copy link
Member

nadako commented Aug 9, 2017

Hmm, could you provide a reproducible example of a problem? @:keep on a @:generic file works as expected (as in - it adds @:keep meta to generic instance classes).

@aliokan
Copy link
Contributor Author

aliokan commented Aug 9, 2017

http://try-haxe.mrcdk.com/#50756 to see the expected result uncomment line 7.

@aliokan
Copy link
Contributor Author

aliokan commented Aug 9, 2017

Base on discussion, meta are not copied on generic instance classes, at lease on Javascript target.

@nadako
Copy link
Member

nadako commented Aug 9, 2017

Well, looks like it's about @:keepSub, not @:keep.

@aliokan
Copy link
Contributor Author

aliokan commented Aug 9, 2017

true, @:keep looks working

@Simn Simn added this to the Design milestone Apr 17, 2018
Simn added a commit that referenced this issue Nov 14, 2023
@Simn Simn closed this as completed in 128261a Nov 15, 2023
0b1kn00b pushed a commit to 0b1kn00b/haxe that referenced this issue Jan 25, 2024
* change return of build_instance to record

* also rename

* also seperate

* also bring back typedef deprecation check

* alsp keep special cases in the right place

* mess around

* avoid some work if we need no params anyway

* make @:generic inference work again

* remove Generic_Exception

* push expected type before loading instance

closes HaxeFoundation#3864

* expand generic types on field call candidate when expanding generic function

closes HaxeFoundation#5482

* build generic parents as well

closes HaxeFoundation#6761

* inherit `@:autoBuild` to generic instance

closes HaxeFoundation#5536

* also inherit @:keepSub while we're at it

closes HaxeFoundation#6500

* deal with KExpr in generic classes properly

closes HaxeFoundation#7574

* don't inherit cf_expr_unoptimized to generic instances

closes HaxeFoundation#9358

* reroute FClosure in map_expr_type

closes HaxeFoundation#9395

* inherit cl_using to generic instances

closes HaxeFoundation#10528

* set inherited flags on generic instance fields at the right time

closes HaxeFoundation#11010

* I really don't care

* wild guess

* avoid the follow change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants