-
Notifications
You must be signed in to change notification settings - Fork 417
Description
Description
Generic interfaces like IFoo<T> should support dynamic dispatch when used as interface variants.
Test Cases
interface ICalculator<T>
{
T compute(T a, T b);
}
struct Adder : ICalculator<float>
{
float compute(float a, float b) { return a + b; }
}
struct Multiplier : ICalculator<float>
{
float compute(float a, float b) { return a * b; }
}
ICalculator<float> makeCalc(int id)
{
if (id == 0) return Adder();
else return Multiplier();
}
void test()
{
ICalculator<float> calc = makeCalc(0);
float result = calc.compute(3.0, 4.0); // Should dispatch correctly
}Expected Behavior
Compiles and dispatches correctly at runtime for generic interface types.
Notes
- Also test variadic generics:
IFoo<each Ts>if supported - Test with different type arguments (int, float, structs)
Reactions are currently unavailable