protected void Inherit(CodeType extend, FileDiagnostics diagnostics, DocRange range) { if (extend == null) { throw new ArgumentNullException(nameof(extend)); } string errorMessage = null; if (!extend.CanBeExtended) { errorMessage = "Type '" + extend.Name + "' cannot be inherited."; } else if (extend == this) { errorMessage = "Cannot extend self."; } else if (extend.Implements(this)) { errorMessage = $"The class {extend.Name} extends this class."; } if (errorMessage != null) { if (diagnostics == null || range == null) { throw new Exception(errorMessage); } else { diagnostics.Error(errorMessage, range); return; } } Extends = extend; }
protected override bool DoesImplement(CodeType type) => base.DoesImplement(type) || type.Implements(_supplier.Boolean());
public static bool IsAny(ITypeSupplier supplier, CodeType type) => type.Implements(supplier.Any());