internal override bool UnionEquals(AnalysisValue ns, int strength) { if (strength >= MergeStrength.ToObject) { var type = ProjectState.ClassInfos[BuiltinTypeId.Type]; return(ns is ClassInfo || ns is BuiltinClassInfo || ns == type || ns == type.Instance); } else if (strength >= MergeStrength.ToBaseClass) { return(ClassInfo.GetFirstCommonBase(ProjectState, this, ns) != null); } return(base.UnionEquals(ns, strength)); }
internal override AnalysisValue UnionMergeTypes(AnalysisValue ns, int strength) { if (strength >= MergeStrength.ToObject) { // II + II => BII(object) // II + BII => BII(object) return(ProjectState.ClassInfos[BuiltinTypeId.Object].Instance); } else if (strength >= MergeStrength.ToBaseClass) { AnalysisValue newCls = null; AnalysisValue defaultResult = this; if (ns is InstanceInfo ii) { newCls = ClassInfo.GetFirstCommonBase(ProjectState, ClassInfo, ii.ClassInfo); if (ClassInfo.IsFirstForMroUnion(ii.ClassInfo, ClassInfo)) { defaultResult = ns; } } else if (ns is BuiltinInstanceInfo bii) { newCls = ClassInfo.GetFirstCommonBase(ProjectState, ClassInfo, bii.ClassInfo); if (ClassInfo.IsFirstForMroUnion(bii.ClassInfo, ClassInfo)) { defaultResult = ns; } } if (newCls == null) { return(defaultResult); } return(newCls.GetInstanceType().Single()); } return(base.UnionMergeTypes(ns, strength)); }
internal override AnalysisValue UnionMergeTypes(AnalysisValue ns, int strength) { if (strength >= MergeStrength.ToObject) { AnalysisValue type; if (TypeId == ns.TypeId && (type = ProjectState.ClassInfos[TypeId]) != null) { return(type); } return(ProjectState.ClassInfos[BuiltinTypeId.Type]); } else if (strength >= MergeStrength.ToBaseClass) { var commonBase = ClassInfo.GetFirstCommonBase(ProjectState, this, ns); if (commonBase != null) { return(commonBase); } return(ProjectState.ClassInfos[BuiltinTypeId.Object]); } return(base.UnionMergeTypes(ns, strength)); }