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

Handled exception inside FindMethod() in late bound code with method named Set_foo and assign Foo #1702

Open
cpyrgas opened this issue Mar 5, 2025 · 0 comments

Comments

@cpyrgas
Copy link

cpyrgas commented Mar 5, 2025

Was fighting to find the cause of a handled exception in a user's app, found out it's related to have a similar named method and assign. In this particular case it's harmless, because the late binding code later does find the method correctly and calls it, but it might be worth resolving this in the future, as it might be causing a problem in a different case.

Note that if the middle class is missing, the compiler does warn about having a same named method and property setter. But not in this case.

CLASS Parent
	ASSIGN Test(u)
		? "assign called"
END CLASS

CLASS Middle INHERIT Parent
END CLASS

CLASS Child INHERIT Middle
	METHOD Set_test() CLIPPER
		? "method called"
	RETURN NIL
END CLASS

FUNCTION Start() AS VOID
	LOCAL u AS USUAL
	u := Child{}
	u:Set_test() // System.Reflection.AmbiguousMatchException
System.Reflection.AmbiguousMatchException
Ambiguous match found.

Callstack : 
System.RuntimeType.[Method System.RuntimeType.GetMethodImpl(name:System.String, bindingAttr:System.Reflection.BindingFlags, binder:System.Reflection.Binder, callConv:System.Reflection.CallingConventions, types:System.Type[], modifiers:System.Reflection.ParameterModifier[]):System.Reflection.MethodInfo]
System.RuntimeType.[Method System.Type.GetMethod(name:System.String, bindingAttr:System.Reflection.BindingFlags):System.Reflection.MethodInfo]
[Method XSharp.RT.OOPHelpers.FindMethod(t:System.Type, cName:System.String, lSelf:System.Boolean, lInstance:System.Boolean):System.Reflection.MethodInfo]
[Method XSharp.RT.OOPHelpers.SendHelper(oObject:System.Object, cMethod:System.String, uArgs:XSharp.__Usual[], out result:XSharp.__Usual&, lCallBase:System.Boolean):System.Boolean]
[Method XSharp.RT.OOPHelpers.DoSend(oObject:System.Object, cMethod:System.String, args:XSharp.__Usual[], cCaller:System.String):XSharp.__Usual]
[Method XSharp.RT.Functions.__InternalSend(oObject:XSharp.__Usual, cMethod:System.String, params args:XSharp.__Usual[]):XSharp.__Usual]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant