Skip to content

[VFP] Make the compiler hack about THISFORM and FindForm() optional #2060

Description

@cpyrgas

Robert, when I use my own implementation for thisform etc (with regular properties), the compiler expects for a method "FindForm" to exist as well. Please make this behavior optional, as it's causing trouble creating a cleaner implementation and also leads to unnecessary late bound calls. Providing a compiler option that disables this functionality would be more than enough.

Also even by implementing this method, there's still something special about a property called "thisform" and the code fails at runtime, see below and test C976.

#pragma options("fox3", enable)
#pragma options("allowdot", enable)
#pragma options("lb", enable)
#pragma options("memvar", enable)
#pragma options("undeclared", enable)
CLASS MyForm INHERIT XSharp.VFP.Custom // problem happens even if not inheriting from any class
	PROPERTY Test AS INT AUTO
END CLASS

CLASS TestControl INHERIT XSharp.VFP.Custom // problem happens even if not inheriting from any class
	PROPERTY ThisForm AS MyForm AUTO

	// should compile also without this, but for now uncomment to run test:

/*	METHOD FindForm() AS MyForm // workaround because the compiler needs this method to exist
	RETURN SELF:ThisForm*/
		
	METHOD DoTest() AS VOID
		thisform := MyForm{}
		thisform.Test := 123
		? thisform.Test
END CLASS

FUNCTION Start() AS VOID
	TRY
		TestControl{}:DoTest()
	CATCH oException AS System.Reflection.ReflectionTypeLoadException
		FOREACH oLoaderException AS Exception IN oException:LoaderExceptions
			// System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method.  Type: 'ImplementClass'.
			? oLoaderException:ToString( )
		NEXT
	END TRY		

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions