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

generic function returning generic type #5482

Closed
romamik opened this issue Jul 27, 2016 · 0 comments · Fixed by #11376
Closed

generic function returning generic type #5482

romamik opened this issue Jul 27, 2016 · 0 comments · Fixed by #11376
Assignees
Milestone

Comments

@romamik
Copy link
Contributor

romamik commented Jul 27, 2016

package;


@:generic 
class Temp<T> {
    var t:T;
    public function new(t:T) {
        this.t = t;
    }
}

class Main {

    @:generic
    static function makeTemp<T>(c:T):Temp<T> return new Temp<T>(c);

    static function main() {
        // Entry point

        //var tt:Temp<Int> = makeTemp(10);
        //  compile error:
        //  src/Main.hx:20: characters 21-33 : Temp<Unknown<0>> should be Temp_Int
        //  src/Main.hx:20: characters 2-34 : Temp<Int> should be Temp_Int

        var tt = makeTemp(10); 
        //  flash: runtime error: Type Coercion failed: cannot convert Temp_Int@40fdc89 to Temp.
        //  neko: works as expected
        //  cpp: c++ compiler fails to compile, saying Temp_Int is not a member of global namespace
        //src/Main.hx:20: characters 21-33 : Temp<Unknown<0>> should be Temp_Int
        //src/Main.hx:20: characters 2-34 : Temp<Int> should be Temp_Int


        trace(tt);
    }

}
@Simn Simn modified the milestone: 4.0 Jan 9, 2017
@Simn Simn removed this from the Release 4.0 milestone Apr 17, 2018
@Simn Simn self-assigned this Apr 19, 2018
@Simn Simn added this to the Bugs milestone Apr 19, 2018
@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
Simn added a commit that referenced this issue Nov 15, 2023
* 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 #3864

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

closes #5482

* build generic parents as well

closes #6761

* inherit `@:autoBuild` to generic instance

closes #5536

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

closes #6500

* deal with KExpr in generic classes properly

closes #7574

* don't inherit cf_expr_unoptimized to generic instances

closes #9358

* reroute FClosure in map_expr_type

closes #9395

* inherit cl_using to generic instances

closes #10528

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

closes #11010

* I really don't care

* wild guess

* avoid the follow change
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants