using System; using JetBrains.Annotations; namespace JetBrains.Core { /// /// Type that has no instances. Subclass of all classes, so can be casted to any class. /// // ReSharper disable once ClassNeverInstantiated.Global public class Nothing { private Nothing() { } /// /// Always throws . Could be used as a return value for unreachable code. /// /// /// always fail [PublicAPI] public T As() => throw new InvalidOperationException("This method should never be called. It's only for type checks."); /// /// Always throws . Could be used as a return value for unreachable code. /// /// /// always fail public static T Unreachable() => throw new InvalidOperationException("This method should never be called. It's must be unreachable for execution flow,"); /// /// Always throws . Could be used as an assertion in unreachable code. /// /// always fail public static Nothing Unreachable() => throw new InvalidOperationException("This method should never be called. It's unreachable for execution flow."); } }