//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// public IType substitute(TypeParameterInstantiation instantiation) { IType result = instantiation.map(typeVariable); if (result == null) { result = this; } return(result); }
///////////////////////////////////////////////////////////////////////////////////////////////////// public MapType substituteMap(TypeParameterInstantiation instantiation) { foreach (var tp in typeParameters) { Debug.Assert(instantiation.map(tp) == null); } // Debug.Assert(mapTypeArguments.Length == mapTypeArguments.Length); bool clone = false; var newDomain = new IType[domain.Count()]; for (int i = 0; i < domain.Count(); i++) { newDomain[i] = domain[i].substitute(instantiation); if (newDomain[i] != domain[i]) { clone = true; } } IType newRange = range.substitute(instantiation); if (newRange != range) { clone = true; } TypeConstructorInstance newOriginalType = substituteOriginalType(instantiation); if (newOriginalType != originalType) { clone = true; } MapType result; if (clone) { result = new MapType((TypeVariable[])typeParameters.Clone(), newDomain, newRange, newOriginalType); result.originalSubstitution = this; } else { result = this; } return(result); }