blob: 0213a919cc093c13dd36259d81d59673dfb7bb8f [file] [log] [blame]
//===--- Substitution.cpp - Type substitutions ----------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file implements the Substitution class and operations on it.
//
//===----------------------------------------------------------------------===//
#include "swift/AST/Substitution.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/Module.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/SubstitutionMap.h"
#include "swift/AST/Types.h"
#include "llvm/ADT/DenseMap.h"
using namespace swift;
bool Substitution::operator==(const Substitution &other) const {
// The archetypes may be missing, but we can compare them directly
// because archetypes are always canonical.
return
Replacement->isEqual(other.Replacement) &&
Conformance.equals(other.Conformance);
}
Substitution::Substitution(Type Replacement,
ArrayRef<ProtocolConformanceRef> Conformance)
: Replacement(Replacement), Conformance(Conformance)
{
// The replacement type must be materializable.
assert(Replacement->isMaterializable()
&& "cannot substitute with a non-materializable type");
}