public void Validate(ComputationContext ctx) { if (this.HasConst && this.HasMutable) { ctx.AddError(ErrorCode.ConflictingModifier, this); } if (!ctx.Env.Options.AllowProtocols && this.HasProtocol) { ctx.AddError(ErrorCode.DisabledProtocols, this); } }
public void Evaluate(ComputationContext ctx) { { if (this.isLocal) { if (ctx.EvalLocalNames != null && ctx.EvalLocalNames.TryGet <IAnchor>(this, out IAnchor anchor)) { this.binding = new Option <ILabelBindable>(anchor); } } else { TypeDefinition curr_type = this.EnclosingScope <TypeDefinition>(); IReadOnlyCollection <ILabelBindable> found = curr_type.NestedEntities() .WhereType <ILabelBindable>(it => EntityBareNameComparer.Instance.Equals(it.Label, this)).StoreReadOnly(); if (found.Count > 0) { this.binding = new Option <ILabelBindable>(found.First()); if (found.Count > 1) { ctx.AddError(ErrorCode.AmbiguousReference, this); } } } if (!this.binding.HasValue) { this.binding = new Option <ILabelBindable>(null); ctx.ErrorManager.AddError(ErrorCode.ReferenceNotFound, this); } } }
public void Validate(ComputationContext ctx) { foreach (NameReference base_of in this.BaseOfNames) { // we allow slicing because we just need if the hierarchy is not reversed, not to pass actual values if (this.InheritsNames.Any(it => { TypeMatch match = it.Evaluation.Components.MatchesTarget(ctx, base_of.Evaluation.Components, TypeMatching.Create(ctx.Env.Options.InterfaceDuckTyping, allowSlicing: true)); return(match == TypeMatch.Same || match == TypeMatch.Substitute); })) { ctx.AddError(ErrorCode.ConstraintConflictingTypeHierarchy, base_of); } } // the left side: target match (i.e. template inner parameter type) -> template // the right side: this -> template parameter -> name definition -> template if (this.Name.Binding.Match.Instance.Target.Owner != this.Owner.Owner.Owner) { ctx.AddError(ErrorCode.MisplacedConstraint, this); } }