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

[C#] Wrong type parameter for typed(Generic) functions with and Array<T> #5838

Closed
Muxeu opened this issue Nov 25, 2016 · 1 comment · Fixed by #11551
Closed

[C#] Wrong type parameter for typed(Generic) functions with and Array<T> #5838

Muxeu opened this issue Nov 25, 2016 · 1 comment · Fixed by #11551
Assignees
Labels
platform-cs Everything related to c#
Milestone

Comments

@Muxeu
Copy link

Muxeu commented Nov 25, 2016

class Main {
    public function new() {
        var arr:Array<Foo> = [];
        shuffleArray(arr);
    }

    public function shuffleArray<T>(arr:Array<T>):Void {
        //do something with array
    }
}

@:nativeGen
class Foo {
    public function new() { }
}

Generates:

public class Main {
	public Main() {
		global::haxe.root.Array<object> arr = new global::haxe.root.Array<object>(new object[]{});
		this.shuffleArray<global::Foo>(( arr as global::haxe.root.Array<object> ));
	}
	
	public virtual void shuffleArray<T>(global::haxe.root.Array<T> arr) {
	}
}

public class Foo {
	public Foo() {
	}
}

Problems in line
this.shuffleArray<global::Foo>(( arr as global::haxe.root.Array<object> ));

global::Foo should be object

@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 added the platform-cs Everything related to c# label Apr 18, 2018
@Simn Simn added this to the Bugs milestone Apr 18, 2018
kLabz added a commit to kLabz/haxe that referenced this issue Jun 8, 2019
@kLabz
Copy link
Contributor

kLabz commented Jun 8, 2019

I get this with current dev (35ce1e7), which seems fine:

	protected static void __hx_ctor__Main(global::Main __hx_this) {
		global::Array<object> arr = new global::Array<object>(new object[]{});
		__hx_this.shuffleArray<object>(((global::Array<object>) (arr) ));
	}
	
	
	public virtual void shuffleArray<T>(global::Array<T> arr) {
	}

With https://github.com/kLabz/haxe/tree/testissue/5838/tests/misc/projects/Issue5838/

@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-cs Everything related to c#
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants