help
Root Question Message
ISymbol
. This interface has tons of derived interfaces (INamedSymbol
, ITypeSymbol
, IFunctionSymbol
, IVariableSymbol
, among others), which all can have multiple implementations. However, I also have an interface called IErrorSymbol
which just represents an error which has been produced somewhere. There are several cases in which I have to cast between these interfaces, and many times I also have to perform is
checks. The IErrorSymbol
is meant to act as a more or less general-purpose interface which can describe any error, but which also can be used in place of any of the other interfaces.ErrorSymbol : IErrorSymbol
implementation, as well as a couple specialized ones like NamedErrorSymbol : INamedSymbol, IErrorSymbol
and ErrorTypeSymbol : ITypeSymbol, IErrorSymbol
, although having one of these for every kind of error feels very annoying. What I would love to have is just a single (or at least very few) implementations which can serve the roll of any of the interfaces, however which don't necessarily implicitly implement those interfaces. Does that even make sense? Like, in my ideal world, new ErrorSymbol() is ITypeSymbol
would be false, but (ITypeSymbol)new ErrorSymbol()
would be acceptable. Is there any decent way to describe/implement this?public static explicit operator ITypeSymbol(ErrorSymbol e)
, because you can't define implicit or explicit operators to/from an interface.NamedErrorSymbol
is an error for when an INamedSymbol
was expectedIErrorSymbol
that wraps the deduced symbol, or just use a normal named symbol while recording the errors, I guessfoo(x: Int32, x: String): Something;
x: String
?String
is not defined, there's no error with x
x
, you get an IErrorTypeSymbol
M(1, 2)
, where M
is undefined, and someone asks for the method symbol. What could you return other than null
?x
being redefined