Skip to content

Commit bcc2ff3

Browse files
committed
[Type checker] s/meet/join, so we get our terminology straight.
(cherry picked from commit 1b99f7f)
1 parent 5833f8b commit bcc2ff3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

include/swift/AST/Type.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ class Type {
184184
/// Get the canonical type, or return null if the type is null.
185185
CanType getCanonicalTypeOrNull() const; // in Types.h
186186

187-
/// Computes the meet between two types.
187+
/// Computes the join between two types.
188188
///
189-
/// The meet of two types is the most specific type that is a supertype of
190-
/// both \c type1 and \c type2. For example, given a simple class hierarchy as
191-
/// follows:
189+
/// The join of two types is the most specific type that is a supertype of
190+
/// both \c type1 and \c type2, e.g., the least upper bound in the type
191+
/// lattice. For example, given a simple class hierarchy as follows:
192192
///
193193
/// \code
194194
/// class A { }
@@ -197,15 +197,15 @@ class Type {
197197
/// class D { }
198198
/// \endcode
199199
///
200-
/// The meet of B and C is A, the meet of A and B is A. However, there is no
201-
/// meet of D and A (or D and B, or D and C) because there is no common
200+
/// The join of B and C is A, the join of A and B is A. However, there is no
201+
/// join of D and A (or D and B, or D and C) because there is no common
202202
/// superclass. One would have to jump to an existential (e.g., \c AnyObject)
203203
/// to find a common type.
204204
///
205-
/// \returns the meet of the two types, if there is a concrete type that can
206-
/// express the meet, or a null type if the only meet would be a more-general
205+
/// \returns the join of the two types, if there is a concrete type that can
206+
/// express the join, or a null type if the only join would be a more-general
207207
/// existential type (e.g., \c Any).
208-
static Type meet(Type type1, Type type2);
208+
static Type join(Type type1, Type type2);
209209

210210
private:
211211
// Direct comparison is disabled for types, because they may not be canonical.

lib/AST/TypeJoinMeet.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- TypeJoinMeet.cpp - Swift Type "Join" and "Meet" -----------------===//
1+
//===--- TypeJoinjoin.cpp - Swift Type "join" and "meet" -----------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,8 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212
//
13-
// This file implements the "meet" operation for types (and, eventually,
14-
// "join").
13+
// This file implements the "join" operation for types (and, eventually,
14+
// "meet").
1515
//
1616
//===----------------------------------------------------------------------===//
1717
#include "swift/AST/ASTContext.h"
@@ -20,15 +20,15 @@
2020
#include "llvm/ADT/SmallPtrSet.h"
2121
using namespace swift;
2222

23-
Type Type::meet(Type type1, Type type2) {
23+
Type Type::join(Type type1, Type type2) {
2424
assert(!type1->hasTypeVariable() && !type2->hasTypeVariable() &&
25-
"Cannot compute meet of types involving type variables");
25+
"Cannot compute join of types involving type variables");
2626

2727
// FIXME: This algorithm is woefully incomplete, and is only currently used
2828
// for optimizing away extra exploratory work in the constraint solver. It
2929
// should eventually encompass all of the subtyping rules of the language.
3030

31-
// If the types are equivalent, the meet is obvious.
31+
// If the types are equivalent, the join is obvious.
3232
if (type1->isEqual(type2))
3333
return type1;
3434

@@ -64,7 +64,7 @@ Type Type::meet(Type type1, Type type2) {
6464
return nullptr;
6565
}
6666

67-
// The meet can only be an existential.
67+
// The join can only be an existential.
6868
return nullptr;
6969
}
7070

lib/Sema/CSSolver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,18 +711,18 @@ static PotentialBindings getPotentialBindings(ConstraintSystem &cs,
711711
// coalescing supertype bounds when we are able to compute the meet.
712712
auto addPotentialBinding = [&](PotentialBinding binding) {
713713
// If this is a non-defaulted supertype binding, check whether we can
714-
// combine it with another supertype binding by computing the 'meet' of the
714+
// combine it with another supertype binding by computing the 'join' of the
715715
// types.
716716
if (binding.Kind == AllowedBindingKind::Supertypes &&
717717
!binding.BindingType->hasTypeVariable() &&
718718
!binding.DefaultedProtocol &&
719719
!binding.IsDefaultableBinding) {
720720
if (lastSupertypeIndex) {
721-
// Can we compute a meet?
721+
// Can we compute a join?
722722
auto &lastBinding = result.Bindings[*lastSupertypeIndex];
723723
if (auto meet =
724-
Type::meet(lastBinding.BindingType, binding.BindingType)) {
725-
// Replace the last supertype binding with the meet. We're done.
724+
Type::join(lastBinding.BindingType, binding.BindingType)) {
725+
// Replace the last supertype binding with the join. We're done.
726726
lastBinding.BindingType = meet;
727727
return;
728728
}

0 commit comments

Comments
 (0)