…riables
Assigning a Variant that holds an interface reference to a script
variable of an interface type only worked when the destination was
exactly IDispatch; every other interface destination failed with a
plain 'Type Mismatch'. Assignments between differently declared
interface types blindly copied the reference without ever consulting
QueryInterface.
SetVariantValue's btInterface branch now:
- accepts Variants holding varUnknown/varDispatch values (including
by-ref variants) for ANY interface destination, casting via
QueryInterface on the destination's GUID; empty/nil Variants assign
nil. Destinations declared as IUnknown (or without a GUID) receive
the reference as-is, preserving existing behaviour.
- performs interface-to-interface assignments of differently declared
types via QueryInterface as well; same-GUID (and nil) assignments
stay plain reference copies.
Failed casts raise a descriptive, script-catchable error that names the
destination type (or its GUID when the type is unnamed) instead of the
generic type mismatch. Pre-Delphi3 builds keep their previous paths.
Note: the companion fix 'Make failing interface/object casts catchable'
covers the explicit cast-import path (CastProc); together they make all
interface conversion failures catchable with descriptive messages.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Assigning a Variant that holds an interface reference to a script
variable of an interface type only worked when the destination was
exactly IDispatch; every other interface destination failed with a
plain 'Type Mismatch'. Assignments between differently declared
interface types blindly copied the reference without ever consulting
QueryInterface.
SetVariantValue's btInterface branch now:
by-ref variants) for ANY interface destination, casting via
QueryInterface on the destination's GUID; empty/nil Variants assign
nil. Destinations declared as IUnknown (or without a GUID) receive
the reference as-is, preserving existing behaviour.
types via QueryInterface as well; same-GUID (and nil) assignments
stay plain reference copies.
Failed casts raise a descriptive, script-catchable error that names the
destination type (or its GUID when the type is unnamed) instead of the
generic type mismatch. Pre-Delphi3 builds keep their previous paths.
Note: the companion fix 'Make failing interface/object casts catchable'
covers the explicit cast-import path (CastProc); together they make all
interface conversion failures catchable with descriptive messages.
Note: the "failing cast is catchable" check of the included repro additionally needs the catchable-cast-errors PR; the two branches merge cleanly together.
🤖 Generated with Claude Code