Closed sliekens closed 9 years ago
Suggested fix: define a single constructor that requires a parameter of the base type Element
, and a numeric parameter that indicates the alternative that was chosen.
public Alternative(Element element, int choice, ITextContext context)
: base(element.Data, context)
{
switch (choice)
{
case 1:
if (false == element is T1)
throw new ArgumentException();
break;
case 2:
if (false == element is T2)
throw new ArgumentException();
break;
default:
throw new ArgumentException();
}
this.element = element;
}
The
Alternative<T, T2>
class (and friends) define constructor overloads that take parameters of the generic types. Using the same type forT
andT2
results in an ambiguous constructor overload.