internal override OverloadedTypeSymbol OverloadType(TypeSymbolBase newTypeSymBase) { if (newTypeSymBase is OverloadedTypeSymbol newTypeOverload) { // We've encountered an overloaded type symbol over a previous simple // type symbol. return(newTypeOverload.OverloadType(this)); } else { // We've encountered two simple types... just create an overload for them if // possible. if (newTypeSymBase is TypeSymbol newTypeSym && this.CanOverload(newTypeSym)) { return(new OverloadedTypeSymbol(name, this, newTypeSym)); } } return(null); }
internal override OverloadedTypeSymbol OverloadType(TypeSymbolBase newTypeSymBase) { List <TypeSymbol> newOverloads = new List <TypeSymbol>(); TypeSymbol typeSym = null; if (newTypeSymBase is OverloadedTypeSymbol newTypeOverload) { newOverloads.AddRange(newTypeOverload.TypeSymbols); } else { // We've encountered a simple type... just create an overload for them if // possible. typeSym = newTypeSymBase as TypeSymbol; if (typeSym != null) { newOverloads.Add(typeSym); } } // If every item in this overloaded type symbol is overloadable with the new one, // add to the new list all our items. foreach (TypeSymbol thisTypeSym in this.TypeSymbols) { foreach (TypeSymbol newTypeSym in newOverloads) { if (!newTypeSym.CanOverload(thisTypeSym)) { return(null); // Can't overload } } newOverloads.Add(thisTypeSym); } return(new OverloadedTypeSymbol(name, newOverloads)); }
internal abstract OverloadedTypeSymbol OverloadType(TypeSymbolBase typeSymBase);