Skip to content

Commit 2724f61

Browse files
authored
Merge pull request #1370 from swiftwasm/katei/merge-master-2020-07-04
Merge master 2020-07-04
2 parents 66efa12 + b445780 commit 2724f61

File tree

89 files changed

+1439
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1439
-384
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ various products. These incremental builds are a big timesaver when developing
252252
and debugging.
253253

254254
cd ${SWIFT_BUILD_DIR}
255-
ninja swift
255+
ninja swift-frontend
256256

257257
This will build the Swift compiler, but will not rebuild the standard library or
258258
any other target. Building the `swift-stdlib` target as an additional layer of
@@ -269,7 +269,7 @@ To open the Swift project in Xcode, open `${SWIFT_BUILD_DIR}/Swift.xcodeproj`.
269269
It will auto-create a *lot* of schemes for all of the available targets. A
270270
common debug flow would involve:
271271

272-
- Select the 'swift' scheme.
272+
- Select the 'swift-frontend' scheme.
273273
- Pull up the scheme editor (⌘⇧<).
274274
- Select the 'Arguments' tab and click the '+'.
275275
- Add the command line options.

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function(_add_host_variant_c_compile_link_flags name)
121121
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
122122
if (_lto_flag_out)
123123
target_compile_options(${name} PRIVATE ${_lto_flag_out})
124+
target_link_options(${name} PRIVATE ${_lto_flag_out})
124125
endif()
125126
endfunction()
126127

docs/StdlibRationales.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,6 @@ call an API with a different name, say ``lazyEnumerate()`` to opt into
174174
laziness. The problem is that the eager API, which would have a shorter and
175175
less obscure name, would be less efficient for the common case.
176176

177-
Use of ``BooleanType`` in library APIs
178-
--------------------------------------
179-
180-
Use ``Bool`` instead of a generic function over a ``BooleanType``, unless there
181-
are special circumstances (for example, ``func &&`` is designed to work on all
182-
boolean values so that ``&&`` feels like a part of the language).
183-
184-
``BooleanType`` is a protocol to which only ``Bool`` and ``ObjCBool`` conform.
185-
Users don't usually interact ``ObjCBool`` instances, except when using certain
186-
specific APIs (for example, APIs that operate on pointers to ``BOOL``). If
187-
someone already has an ``ObjCBool`` instance for whatever strange reason, they
188-
can just convert it to ``Bool``. We think this is the right tradeoff:
189-
simplifying function signatures is more important than making a marginal
190-
usecase a bit more convenient.
191-
192177
Possible future directions
193178
==========================
194179

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,11 +1801,11 @@ ERROR(type_cannot_conform_to_nsobject,none,
18011801

18021802
ERROR(use_of_equal_instead_of_equality,none,
18031803
"use of '=' in a boolean context, did you mean '=='?", ())
1804-
18051804
ERROR(type_cannot_conform, none,
1806-
"%select{|value of protocol }0type %1 cannot conform to %2; "
1807-
"only struct/enum/class types can conform to protocols",
1808-
(bool, Type, Type))
1805+
"%select{type %1|protocol %1 as a type}0 cannot conform to "
1806+
"%select{%3|the protocol itself}2; "
1807+
"only concrete types such as structs, enums and classes can conform to protocols",
1808+
(bool, Type, bool, Type))
18091809
NOTE(required_by_opaque_return,none,
18101810
"required by opaque return type of %0 %1", (DescriptiveDeclKind, DeclName))
18111811
NOTE(required_by_decl,none,

include/swift/AST/EducationalNotes.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,23 @@ EDUCATIONAL_NOTES(property_wrapper_failable_init,
5959
EDUCATIONAL_NOTES(property_wrapper_type_requirement_not_accessible,
6060
"property-wrapper-requirements.md")
6161

62+
EDUCATIONAL_NOTES(opaque_type_var_no_init, "opaque-type-inference.md")
63+
EDUCATIONAL_NOTES(opaque_type_no_underlying_type_candidates,
64+
"opaque-type-inference.md")
65+
EDUCATIONAL_NOTES(opaque_type_mismatched_underlying_type_candidates,
66+
"opaque-type-inference.md")
67+
EDUCATIONAL_NOTES(opaque_type_self_referential_underlying_type,
68+
"opaque-type-inference.md")
69+
EDUCATIONAL_NOTES(opaque_type_var_no_underlying_type,
70+
"opaque-type-inference.md")
71+
72+
6273
EDUCATIONAL_NOTES(missing_append_interpolation,
6374
"string-interpolation-conformance.md")
6475
EDUCATIONAL_NOTES(append_interpolation_static,
6576
"string-interpolation-conformance.md")
6677
EDUCATIONAL_NOTES(append_interpolation_void_or_discardable,
6778
"string-interpolation-conformance.md")
79+
EDUCATIONAL_NOTES(type_cannot_conform, "protocol-type-non-conformance.md")
6880

6981
#undef EDUCATIONAL_NOTES

include/swift/AST/Types.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
785785

786786
/// Check if this is a nominal type defined at the top level of the Swift module
787787
bool isStdlibType();
788+
789+
/// Check if this is either an Array, Set or Dictionary collection type defined
790+
/// at the top level of the Swift module
791+
bool isKnownStdlibCollectionType();
788792

789793
/// If this is a class type or a bound generic class type, returns the
790794
/// (possibly generic) class.
@@ -5571,25 +5575,7 @@ class ArchetypeType : public SubstitutableType,
55715575
/// find a particular nested type by name, directly, or look at the
55725576
/// protocols to which this archetype conforms.
55735577
ArrayRef<std::pair<Identifier, Type>>
5574-
getKnownNestedTypes(bool resolveTypes = true) const {
5575-
return getAllNestedTypes(/*resolveTypes=*/false);
5576-
}
5577-
5578-
/// Retrieve the nested types of this archetype.
5579-
///
5580-
/// \param resolveTypes Whether to eagerly resolve the nested types
5581-
/// (defaults to \c true). Otherwise, the nested types might be
5582-
/// null.
5583-
///
5584-
/// FIXME: This operation should go away, because it breaks recursive
5585-
/// protocol constraints.
5586-
ArrayRef<std::pair<Identifier, Type>>
5587-
getAllNestedTypes(bool resolveTypes = true) const;
5588-
5589-
/// Set the nested types to a copy of the given array of
5590-
/// archetypes.
5591-
void setNestedTypes(ASTContext &Ctx,
5592-
ArrayRef<std::pair<Identifier, Type>> Nested);
5578+
getKnownNestedTypes() const;
55935579

55945580
/// Register a nested type with the given name.
55955581
void registerNestedType(Identifier name, Type nested);

include/swift/SIL/AbstractionPattern.h

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,26 @@ class AbstractionPattern {
179179
/// type. ObjCMethod is valid. OtherData is an encoded foreign
180180
/// error index.
181181
ObjCMethodType,
182-
/// The uncurried imported type of a C++ method. OrigType is valid and is a
183-
/// function type. CXXMethod is valid.
182+
/// The uncurried imported type of a C++ non-operator non-static member
183+
/// function. OrigType is valid and is a function type. CXXMethod is valid.
184184
CXXMethodType,
185-
/// The curried imported type of a C++ method. OrigType is valid and is a
186-
/// function type. CXXMethod is valid.
185+
/// The curried imported type of a C++ non-operator non-static member
186+
/// function. OrigType is valid and is a function type. CXXMethod is valid.
187187
CurriedCXXMethodType,
188-
/// The partially-applied curried imported type of a C++ method. OrigType is
189-
/// valid and is a function type. CXXMethod is valid.
188+
/// The partially-applied curried imported type of a C++ non-operator
189+
/// non-static member function. OrigType is valid and is a function type.
190+
/// CXXMethod is valid.
190191
PartialCurriedCXXMethodType,
192+
/// The uncurried imported type of a C++ operator non-static member
193+
/// function. OrigType is valid and is a function type. CXXMethod is valid.
194+
CXXOperatorMethodType,
195+
/// The curried imported type of a C++ operator non-static member function.
196+
/// OrigType is valid and is a function type. CXXMethod is valid.
197+
CurriedCXXOperatorMethodType,
198+
/// The partially-applied curried imported type of a C++ operator non-static
199+
/// member function. OrigType is valid and is a function type. CXXMethod is
200+
/// valid.
201+
PartialCurriedCXXOperatorMethodType,
191202
/// A Swift function whose parameters and results are opaque. This is
192203
/// like `AP::Type<T>((T) -> T)`, except that the number of parameters is
193204
/// unspecified.
@@ -341,6 +352,9 @@ class AbstractionPattern {
341352
case Kind::CXXMethodType:
342353
case Kind::CurriedCXXMethodType:
343354
case Kind::PartialCurriedCXXMethodType:
355+
case Kind::CXXOperatorMethodType:
356+
case Kind::CurriedCXXOperatorMethodType:
357+
case Kind::PartialCurriedCXXOperatorMethodType:
344358
return true;
345359

346360
default:
@@ -465,6 +479,9 @@ class AbstractionPattern {
465479
case Kind::CXXMethodType:
466480
case Kind::CurriedCXXMethodType:
467481
case Kind::PartialCurriedCXXMethodType:
482+
case Kind::CXXOperatorMethodType:
483+
case Kind::CurriedCXXOperatorMethodType:
484+
case Kind::PartialCurriedCXXOperatorMethodType:
468485
return true;
469486
case Kind::Invalid:
470487
case Kind::Opaque:
@@ -541,6 +558,10 @@ class AbstractionPattern {
541558
static AbstractionPattern
542559
getCurriedCXXMethod(CanType origType, const AbstractFunctionDecl *function);
543560

561+
static AbstractionPattern
562+
getCurriedCXXOperatorMethod(CanType origType,
563+
const AbstractFunctionDecl *function);
564+
544565
/// Return an abstraction pattern for the uncurried type of a C++ method.
545566
///
546567
/// For example, if the original function is:
@@ -556,6 +577,15 @@ class AbstractionPattern {
556577
return pattern;
557578
}
558579

580+
static AbstractionPattern
581+
getCXXOperatorMethod(CanType origType, const clang::CXXMethodDecl *method) {
582+
assert(isa<AnyFunctionType>(origType));
583+
AbstractionPattern pattern;
584+
pattern.initCXXMethod(nullptr, origType, method,
585+
Kind::CXXOperatorMethodType);
586+
return pattern;
587+
}
588+
559589
/// Return an abstraction pattern for the curried type of a C++ method.
560590
///
561591
/// For example, if the original function is:
@@ -572,6 +602,16 @@ class AbstractionPattern {
572602
return pattern;
573603
}
574604

605+
static AbstractionPattern
606+
getCurriedCXXOperatorMethod(CanType origType,
607+
const clang::CXXMethodDecl *method) {
608+
assert(isa<AnyFunctionType>(origType));
609+
AbstractionPattern pattern;
610+
pattern.initCXXMethod(nullptr, origType, method,
611+
Kind::CurriedCXXOperatorMethodType);
612+
return pattern;
613+
}
614+
575615
/// For a C-function-as-method pattern,
576616
/// get the index of the C function parameter that was imported as the
577617
/// `self` parameter of the imported method, or None if this is a static
@@ -678,6 +718,17 @@ class AbstractionPattern {
678718
return pattern;
679719
}
680720

721+
static AbstractionPattern
722+
getPartialCurriedCXXOperatorMethod(CanGenericSignature signature,
723+
CanType origType,
724+
const clang::CXXMethodDecl *method) {
725+
assert(isa<AnyFunctionType>(origType));
726+
AbstractionPattern pattern;
727+
pattern.initCXXMethod(signature, origType, method,
728+
Kind::PartialCurriedCXXOperatorMethodType);
729+
return pattern;
730+
}
731+
681732
public:
682733
/// Return an abstraction pattern for the type of an Objective-C method.
683734
static AbstractionPattern
@@ -813,6 +864,9 @@ class AbstractionPattern {
813864
case Kind::CXXMethodType:
814865
case Kind::CurriedCXXMethodType:
815866
case Kind::PartialCurriedCXXMethodType:
867+
case Kind::CXXOperatorMethodType:
868+
case Kind::CurriedCXXOperatorMethodType:
869+
case Kind::PartialCurriedCXXOperatorMethodType:
816870
case Kind::Type:
817871
case Kind::Discard:
818872
return OrigType;
@@ -849,6 +903,9 @@ class AbstractionPattern {
849903
case Kind::CXXMethodType:
850904
case Kind::CurriedCXXMethodType:
851905
case Kind::PartialCurriedCXXMethodType:
906+
case Kind::CXXOperatorMethodType:
907+
case Kind::CurriedCXXOperatorMethodType:
908+
case Kind::PartialCurriedCXXOperatorMethodType:
852909
case Kind::Type:
853910
case Kind::Discard:
854911
assert(signature || !type->hasTypeParameter());
@@ -886,6 +943,9 @@ class AbstractionPattern {
886943
case Kind::CXXMethodType:
887944
case Kind::CurriedCXXMethodType:
888945
case Kind::PartialCurriedCXXMethodType:
946+
case Kind::CXXOperatorMethodType:
947+
case Kind::CurriedCXXOperatorMethodType:
948+
case Kind::PartialCurriedCXXOperatorMethodType:
889949
return true;
890950
}
891951
llvm_unreachable("bad kind");
@@ -923,7 +983,9 @@ class AbstractionPattern {
923983
/// If so, it is legal to call getCXXMethod().
924984
bool isCXXMethod() const {
925985
return (getKind() == Kind::CXXMethodType ||
926-
getKind() == Kind::CurriedCXXMethodType);
986+
getKind() == Kind::CurriedCXXMethodType ||
987+
getKind() == Kind::CXXOperatorMethodType ||
988+
getKind() == Kind::CurriedCXXOperatorMethodType);
927989
}
928990

929991
const clang::CXXMethodDecl *getCXXMethod() const {
@@ -958,6 +1020,9 @@ class AbstractionPattern {
9581020
case Kind::CXXMethodType:
9591021
case Kind::CurriedCXXMethodType:
9601022
case Kind::PartialCurriedCXXMethodType:
1023+
case Kind::CXXOperatorMethodType:
1024+
case Kind::CurriedCXXOperatorMethodType:
1025+
case Kind::PartialCurriedCXXOperatorMethodType:
9611026
case Kind::OpaqueFunction:
9621027
case Kind::OpaqueDerivativeFunction:
9631028
return false;
@@ -994,6 +1059,9 @@ class AbstractionPattern {
9941059
case Kind::CXXMethodType:
9951060
case Kind::CurriedCXXMethodType:
9961061
case Kind::PartialCurriedCXXMethodType:
1062+
case Kind::CXXOperatorMethodType:
1063+
case Kind::CurriedCXXOperatorMethodType:
1064+
case Kind::PartialCurriedCXXOperatorMethodType:
9971065
case Kind::Type:
9981066
case Kind::Discard:
9991067
return dyn_cast<TYPE>(getType());
@@ -1022,6 +1090,9 @@ class AbstractionPattern {
10221090
case Kind::CXXMethodType:
10231091
case Kind::CurriedCXXMethodType:
10241092
case Kind::PartialCurriedCXXMethodType:
1093+
case Kind::CXXOperatorMethodType:
1094+
case Kind::CurriedCXXOperatorMethodType:
1095+
case Kind::PartialCurriedCXXOperatorMethodType:
10251096
case Kind::OpaqueFunction:
10261097
case Kind::OpaqueDerivativeFunction:
10271098
// We assume that the Clang type might provide additional structure.
@@ -1051,6 +1122,9 @@ class AbstractionPattern {
10511122
case Kind::CXXMethodType:
10521123
case Kind::CurriedCXXMethodType:
10531124
case Kind::PartialCurriedCXXMethodType:
1125+
case Kind::CXXOperatorMethodType:
1126+
case Kind::CurriedCXXOperatorMethodType:
1127+
case Kind::PartialCurriedCXXOperatorMethodType:
10541128
case Kind::OpaqueFunction:
10551129
case Kind::OpaqueDerivativeFunction:
10561130
return false;
@@ -1078,6 +1152,9 @@ class AbstractionPattern {
10781152
case Kind::CXXMethodType:
10791153
case Kind::CurriedCXXMethodType:
10801154
case Kind::PartialCurriedCXXMethodType:
1155+
case Kind::CXXOperatorMethodType:
1156+
case Kind::CurriedCXXOperatorMethodType:
1157+
case Kind::PartialCurriedCXXOperatorMethodType:
10811158
case Kind::OpaqueFunction:
10821159
case Kind::OpaqueDerivativeFunction:
10831160
llvm_unreachable("pattern is not a tuple");

include/swift/SIL/SILType.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef SWIFT_SIL_SILTYPE_H
1919
#define SWIFT_SIL_SILTYPE_H
2020

21-
#include "swift/AST/CanTypeVisitor.h"
2221
#include "swift/AST/SILLayout.h"
2322
#include "swift/AST/Types.h"
2423
#include "llvm/ADT/PointerIntPair.h"
@@ -622,10 +621,19 @@ template<> Can##ID##Type SILType::getAs<ID##Type>() const = delete; \
622621
template<> Can##ID##Type SILType::castTo<ID##Type>() const = delete; \
623622
template<> bool SILType::is<ID##Type>() const = delete;
624623
NON_SIL_TYPE(Function)
624+
NON_SIL_TYPE(GenericFunction)
625625
NON_SIL_TYPE(AnyFunction)
626626
NON_SIL_TYPE(LValue)
627+
NON_SIL_TYPE(InOut)
627628
#undef NON_SIL_TYPE
628629

630+
#define TYPE(ID, PARENT)
631+
#define UNCHECKED_TYPE(ID, PARENT) \
632+
template<> Can##ID##Type SILType::getAs<ID##Type>() const = delete; \
633+
template<> Can##ID##Type SILType::castTo<ID##Type>() const = delete; \
634+
template<> bool SILType::is<ID##Type>() const = delete;
635+
#include "swift/AST/TypeNodes.def"
636+
629637
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SILType T) {
630638
T.print(OS);
631639
return OS;

0 commit comments

Comments
 (0)