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

[cs] invalid cast methods generated #6352

Closed
nadako opened this issue Jun 11, 2017 · 3 comments
Closed

[cs] invalid cast methods generated #6352

nadako opened this issue Jun 11, 2017 · 3 comments
Assignees
Labels
bug platform-cs Everything related to c#

Comments

@nadako
Copy link
Member

nadako commented Jun 11, 2017

reduced from our test suite, which compiles only because we have a name clash between a type parameter name and some class name

class Base<T> {}
class Child1<A, B> extends Base<B> {}
class Child2<T> extends Child1<T, T> {}
error CS0246: The type or namespace name 'A' could not be found (are you missing a using directive or an assembly reference?)

problematic generated code:

public class Child2<T> : global::Child1<T, T>, global::Child2 {

	// ...snip...
		
	public override object Base_cast<T_c>() {
		return this.Child2_cast<A>();
	}

	// ...snip...
	
}
@nadako nadako added bug platform-cs Everything related to c# labels Jun 11, 2017
@nadako
Copy link
Member Author

nadako commented Jun 12, 2017

I spent several hours trying to understand what's going on there in RealTypeParamsModf.create_stub_casts but type parameter handling is just beyond my comprehension.
It seems that when it's processing Child1<A,B> while generating cast for the Child2<T> there's only Child1.A in reverse_params, but when it tries to process further and gets to Base<T>, it tries to find a mapping from Child1.B to Base.T and fails because reverse_params only has Child1.A... So to say, I don't even understand what did I just write :-P

@waneck pls halp

@nadako
Copy link
Member Author

nadako commented Jun 14, 2017

Note that 94809e3 surfaced this issue in our unit tests (because some types were eliminated by DCE that accidentally had the same name as type params), so I added #if !cs at TestOverloads.hx with a TODO note for now. Please, don't forget to remove that after fixing this issue :)

@waneck waneck closed this as completed in 11d5a91 Jun 17, 2017
@waneck
Copy link
Member

waneck commented Jun 17, 2017

Yeah that type parameter handling gave me a headache :P The issue was that reverse_params should store the type parameters that the current cast function should be called, when in reference to the current parent class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-cs Everything related to c#
Projects
None yet
Development

No branches or pull requests

2 participants