Completes generic methods: the out-of-line implementation form now parses
and links, alongside the inline-body form added previously.
type TUtil = class
function Pick<T>(cond: Boolean; a, b: T): T; // declaration
end;
function TUtil.Pick<T>(cond: Boolean; a, b: T): T; // out-of-line body
begin if cond then Result := a else Result := b end;
- Parser: a method-level <T> appearing AFTER the qualified name
(Owner.Method<T>) is now parsed into TypeParams. (The <T> before the dot
remains the owner's type params, as for TList<T>.Add.)
- Semantic: LinkClassMethodImpls detects a generic-method impl
(TypeParams <> nil) and transfers its body onto the in-class
generic-method template, instead of trying to resolve its T-typed params.
Also fixes a real hole found via the out-of-line probe: generic-method
call arguments were not type-checked against the parameters (the path
bypasses ResolveMethodOverload), so e.g. passing a string for a Boolean
parameter compiled silently. The call site now validates argument count
and types against the monomorphised signature.
Verified out-of-line impl (string + Integer instantiations) on both
backends, and that a mismatched argument is now rejected. Adds
TE2EGenericsTests.TestRun_GenericMethod_OutOfLineImpl. Grammar and
language-rationale updated to drop the inline-only caveat.