diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs index 223ea10314..f8b29465b2 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs @@ -1124,6 +1124,29 @@ private ConstructorDeclarationSyntax createConstructor(XP.FoxclassContext contex ctor.XGenerated = true; } } + else + { + // Subclass without its own INIT: VFP calls the parent's INIT + // with all the arguments passed to CREATEOBJECT(). Generate a + // Clipper-calling-convention constructor that forwards + // _ClipperArgs to the base class constructor, so the parent + // INIT receives the arguments instead of getting NIL/empty. + ParameterListSyntax pars = GetClipperParameters(); + var arg = MakeArgument(GenerateSimpleName(XSharpSpecialNames.ClipperArgs)); + ArgumentListSyntax args = MakeArgumentList(arg); + var chain = _syntaxFactory.ConstructorInitializer(SyntaxKind.BaseConstructorInitializer, + SyntaxFactory.ColonToken, + SyntaxFactory.MakeToken(SyntaxKind.BaseKeyword), + args + ); + var mods = TokenList(SyntaxKind.PublicKeyword); + var id = context.Id.Get(); + GenerateAttributeList(attributeLists, SystemQualifiedNames.CompilerGenerated); + attributeLists.Add(MakeClipperCallingConventionAttribute(new List())); + var body = MakeBlock(stmts); + ctor = _syntaxFactory.ConstructorDeclaration(attributeLists, mods, id, pars, chain, body, null, null); + ctor.XGenerated = true; + } _pool.Free(attributeLists); return ctor; }