Skip to content

Merge master 2020-07-04 #1370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
53b4ce0
fix confusing protocol diagnostic
OnyekachiSamuel Jun 24, 2020
cbdb274
add protocol self conformance exception note
OnyekachiSamuel Jun 26, 2020
c642a7f
update diagnostics
OnyekachiSamuel Jun 26, 2020
434607d
fix broken tests
OnyekachiSamuel Jun 26, 2020
42b9b48
update educational notes
OnyekachiSamuel Jun 30, 2020
38e2998
implement feedback changes
OnyekachiSamuel Jul 1, 2020
b9e600b
test: make `round-trip-syntax-test` Python 3 friendly
compnerd Jun 24, 2020
14f72b7
test: appease python linter (NFC)
compnerd Jul 1, 2020
93df7f4
PathSanitizingFileCheck: improve Python3 compatibility
compnerd Jun 29, 2020
96127ca
Update round-trip-syntax-test
compnerd Jul 1, 2020
a7679c0
[test] Add OpenBSD to stable ABI testing targets.
3405691582 Mar 23, 2020
cacfb01
Revert subset of "[Gardening] Clean Up OS-Test Patterns Across The Co…
varungandhi-apple Jul 1, 2020
ff26a06
fix broken test
OnyekachiSamuel Jul 2, 2020
c69baa8
[EduNotes] Explain some opaque type diagnostics
owenv Jun 7, 2020
7b89eae
AST: Remove unused ArchetypeType::getAllNestedTypes() method
slavapestov Jul 2, 2020
a08f421
fix failing tests
OnyekachiSamuel Jul 2, 2020
1992579
Merge pull request #32674 from slavapestov/remove-archetype-get-all-n…
slavapestov Jul 2, 2020
49d4893
Remove BooleanType from docs/StdlibRationales.rst
benrimmington Jul 2, 2020
3952715
[SIL] NFC: Move #include of CanTypeVisitor.h
davezarzycki Jul 2, 2020
f1bba3e
Disable a RUN line in osx-targets.swift
hyp Jul 2, 2020
0b6a21b
[SIL] NFC: Add more paranoia checks to SILType
davezarzycki Jul 2, 2020
0f036e5
Merge pull request #32653 from compnerd/hand-sanitizer-keeps-the-coro…
compnerd Jul 2, 2020
5f219cd
Front-end: disable interface file locking for the -compile-module-fro…
nkcsgexi Jul 2, 2020
ed0e628
Merge pull request #32679 from apple/disable-osx-targets-swift-run-line
hyp Jul 2, 2020
e8150f2
Merge pull request #32681 from nkcsgexi/65005528
nkcsgexi Jul 2, 2020
d87e7c8
Merge pull request #32648 from compnerd/are-we-there-yet
compnerd Jul 2, 2020
406fb23
test: `iteritems` -> `items`
compnerd Jul 2, 2020
b871528
Merge pull request #32524 from OnyekachiSamuel/fix-confusing-protocol…
hborla Jul 2, 2020
f989aa2
SR-12486: `T.self is Any.Protocol` is broken (#31662)
tbkka Jul 2, 2020
23e7974
[CS] Avoid checking RHS of one-way constraint for reactivation
hamishknight Jul 2, 2020
732698e
Fix symbol visibility test for CentOS 7
drexin Jul 2, 2020
62eab29
Merge pull request #32669 from varungandhi-apple/vg-use-os-checks-in-…
CodaFi Jul 2, 2020
e02438c
test: repair the Windows builders after #32666
compnerd Jul 2, 2020
e80b188
[build] Add LTO flag to link options (#32683)
edymtt Jul 2, 2020
4b14487
[NFC] [cxx-interop] Add SILGen tests for synthesized initializers.
zoecarver Jul 1, 2020
dd26811
Merge pull request #32689 from compnerd/iterative-improvements
compnerd Jul 2, 2020
51f92e8
Merge pull request #32691 from drexin/wip-fix-symbol-visibility-test
drexin Jul 2, 2020
f88fd50
Merge pull request #32694 from compnerd/32666
compnerd Jul 3, 2020
28fb66c
[SR-13088] Fix false positive downcast unrelated of types that cannot…
LucianoPAlmeida Jul 3, 2020
75a24ca
Merge pull request #32673 from hamishknight/one-time-activation
hamishknight Jul 3, 2020
22289b0
Merge pull request #32231 from owenv/opaque-note
owenv Jul 3, 2020
45b3aa0
Merge pull request #32668 from 3405691582/OpenBSD_MandatesStableAPI
CodaFi Jul 3, 2020
26358c4
Import member operator functions as static members (#32293)
MForster Jul 3, 2020
a443327
Add bug reference to XFAIL operator tests
MForster Jul 3, 2020
8a5ae9d
Merge pull request #32678 from davezarzycki/pr32678
davezarzycki Jul 3, 2020
5de9eff
Merge pull request #32680 from davezarzycki/pr32679
davezarzycki Jul 3, 2020
5f6f46f
Merge pull request #32699 from MForster/m/op/bug-reference
swift-ci Jul 3, 2020
1f9da38
Update README for new target names
Jumhyn Jul 3, 2020
79913b9
Don't "finalize" the empty-array singleton.
eeckstein Jul 3, 2020
bc27356
stdlib: enable runtime checking for COW support by default in assert …
eeckstein Jun 15, 2020
1a0c4d0
Reinstate "SILCombine: Constant-fold MemoryLayout<T>.offset(of: \.lit…
eeckstein Jul 3, 2020
6ebd2a7
Merge pull request #32658 from zoecarver/cxx/test/no-arg-const
swift-ci Jul 3, 2020
b85ffd3
Merge pull request #32385 from eeckstein/enable-cow-runtime-checks
eeckstein Jul 3, 2020
7332619
Remove `ninja compiler` command
Jumhyn Jul 3, 2020
0d44dad
Merge pull request #32677 from benrimmington/se-0109-remove-boolean
swift-ci Jul 3, 2020
4a49a26
Merge pull request #32703 from eeckstein/fold-kp-offset2
eeckstein Jul 4, 2020
d6deb37
Merge pull request #32701 from Jumhyn/update-readme-7320
swift-ci Jul 4, 2020
9c088df
Merge remote-tracking branch 'apple/master' into katei/merge-master-2…
kateinoigakukun Jul 4, 2020
d365616
[WASM] Add WASI OS condition for stdlib/public/Differentiation/Tgmath…
kateinoigakukun Jul 4, 2020
b445780
[WASM] Add SWIFT_CC(swift) annotation for _swift_setImmutableCOWBuffe…
kateinoigakukun Jul 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ various products. These incremental builds are a big timesaver when developing
and debugging.

cd ${SWIFT_BUILD_DIR}
ninja swift
ninja swift-frontend

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

- Select the 'swift' scheme.
- Select the 'swift-frontend' scheme.
- Pull up the scheme editor (⌘⇧<).
- Select the 'Arguments' tab and click the '+'.
- Add the command line options.
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function(_add_host_variant_c_compile_link_flags name)
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
if (_lto_flag_out)
target_compile_options(${name} PRIVATE ${_lto_flag_out})
target_link_options(${name} PRIVATE ${_lto_flag_out})
endif()
endfunction()

Expand Down
15 changes: 0 additions & 15 deletions docs/StdlibRationales.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,6 @@ call an API with a different name, say ``lazyEnumerate()`` to opt into
laziness. The problem is that the eager API, which would have a shorter and
less obscure name, would be less efficient for the common case.

Use of ``BooleanType`` in library APIs
--------------------------------------

Use ``Bool`` instead of a generic function over a ``BooleanType``, unless there
are special circumstances (for example, ``func &&`` is designed to work on all
boolean values so that ``&&`` feels like a part of the language).

``BooleanType`` is a protocol to which only ``Bool`` and ``ObjCBool`` conform.
Users don't usually interact ``ObjCBool`` instances, except when using certain
specific APIs (for example, APIs that operate on pointers to ``BOOL``). If
someone already has an ``ObjCBool`` instance for whatever strange reason, they
can just convert it to ``Bool``. We think this is the right tradeoff:
simplifying function signatures is more important than making a marginal
usecase a bit more convenient.

Possible future directions
==========================

Expand Down
8 changes: 4 additions & 4 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1801,11 +1801,11 @@ ERROR(type_cannot_conform_to_nsobject,none,

ERROR(use_of_equal_instead_of_equality,none,
"use of '=' in a boolean context, did you mean '=='?", ())

ERROR(type_cannot_conform, none,
"%select{|value of protocol }0type %1 cannot conform to %2; "
"only struct/enum/class types can conform to protocols",
(bool, Type, Type))
"%select{type %1|protocol %1 as a type}0 cannot conform to "
"%select{%3|the protocol itself}2; "
"only concrete types such as structs, enums and classes can conform to protocols",
(bool, Type, bool, Type))
NOTE(required_by_opaque_return,none,
"required by opaque return type of %0 %1", (DescriptiveDeclKind, DeclName))
NOTE(required_by_decl,none,
Expand Down
12 changes: 12 additions & 0 deletions include/swift/AST/EducationalNotes.def
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,23 @@ EDUCATIONAL_NOTES(property_wrapper_failable_init,
EDUCATIONAL_NOTES(property_wrapper_type_requirement_not_accessible,
"property-wrapper-requirements.md")

EDUCATIONAL_NOTES(opaque_type_var_no_init, "opaque-type-inference.md")
EDUCATIONAL_NOTES(opaque_type_no_underlying_type_candidates,
"opaque-type-inference.md")
EDUCATIONAL_NOTES(opaque_type_mismatched_underlying_type_candidates,
"opaque-type-inference.md")
EDUCATIONAL_NOTES(opaque_type_self_referential_underlying_type,
"opaque-type-inference.md")
EDUCATIONAL_NOTES(opaque_type_var_no_underlying_type,
"opaque-type-inference.md")


EDUCATIONAL_NOTES(missing_append_interpolation,
"string-interpolation-conformance.md")
EDUCATIONAL_NOTES(append_interpolation_static,
"string-interpolation-conformance.md")
EDUCATIONAL_NOTES(append_interpolation_void_or_discardable,
"string-interpolation-conformance.md")
EDUCATIONAL_NOTES(type_cannot_conform, "protocol-type-non-conformance.md")

#undef EDUCATIONAL_NOTES
24 changes: 5 additions & 19 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {

/// Check if this is a nominal type defined at the top level of the Swift module
bool isStdlibType();

/// Check if this is either an Array, Set or Dictionary collection type defined
/// at the top level of the Swift module
bool isKnownStdlibCollectionType();

/// If this is a class type or a bound generic class type, returns the
/// (possibly generic) class.
Expand Down Expand Up @@ -5571,25 +5575,7 @@ class ArchetypeType : public SubstitutableType,
/// find a particular nested type by name, directly, or look at the
/// protocols to which this archetype conforms.
ArrayRef<std::pair<Identifier, Type>>
getKnownNestedTypes(bool resolveTypes = true) const {
return getAllNestedTypes(/*resolveTypes=*/false);
}

/// Retrieve the nested types of this archetype.
///
/// \param resolveTypes Whether to eagerly resolve the nested types
/// (defaults to \c true). Otherwise, the nested types might be
/// null.
///
/// FIXME: This operation should go away, because it breaks recursive
/// protocol constraints.
ArrayRef<std::pair<Identifier, Type>>
getAllNestedTypes(bool resolveTypes = true) const;

/// Set the nested types to a copy of the given array of
/// archetypes.
void setNestedTypes(ASTContext &Ctx,
ArrayRef<std::pair<Identifier, Type>> Nested);
getKnownNestedTypes() const;

/// Register a nested type with the given name.
void registerNestedType(Identifier name, Type nested);
Expand Down
91 changes: 84 additions & 7 deletions include/swift/SIL/AbstractionPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,26 @@ class AbstractionPattern {
/// type. ObjCMethod is valid. OtherData is an encoded foreign
/// error index.
ObjCMethodType,
/// The uncurried imported type of a C++ method. OrigType is valid and is a
/// function type. CXXMethod is valid.
/// The uncurried imported type of a C++ non-operator non-static member
/// function. OrigType is valid and is a function type. CXXMethod is valid.
CXXMethodType,
/// The curried imported type of a C++ method. OrigType is valid and is a
/// function type. CXXMethod is valid.
/// The curried imported type of a C++ non-operator non-static member
/// function. OrigType is valid and is a function type. CXXMethod is valid.
CurriedCXXMethodType,
/// The partially-applied curried imported type of a C++ method. OrigType is
/// valid and is a function type. CXXMethod is valid.
/// The partially-applied curried imported type of a C++ non-operator
/// non-static member function. OrigType is valid and is a function type.
/// CXXMethod is valid.
PartialCurriedCXXMethodType,
/// The uncurried imported type of a C++ operator non-static member
/// function. OrigType is valid and is a function type. CXXMethod is valid.
CXXOperatorMethodType,
/// The curried imported type of a C++ operator non-static member function.
/// OrigType is valid and is a function type. CXXMethod is valid.
CurriedCXXOperatorMethodType,
/// The partially-applied curried imported type of a C++ operator non-static
/// member function. OrigType is valid and is a function type. CXXMethod is
/// valid.
PartialCurriedCXXOperatorMethodType,
/// A Swift function whose parameters and results are opaque. This is
/// like `AP::Type<T>((T) -> T)`, except that the number of parameters is
/// unspecified.
Expand Down Expand Up @@ -341,6 +352,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
return true;

default:
Expand Down Expand Up @@ -465,6 +479,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
return true;
case Kind::Invalid:
case Kind::Opaque:
Expand Down Expand Up @@ -541,6 +558,10 @@ class AbstractionPattern {
static AbstractionPattern
getCurriedCXXMethod(CanType origType, const AbstractFunctionDecl *function);

static AbstractionPattern
getCurriedCXXOperatorMethod(CanType origType,
const AbstractFunctionDecl *function);

/// Return an abstraction pattern for the uncurried type of a C++ method.
///
/// For example, if the original function is:
Expand All @@ -556,6 +577,15 @@ class AbstractionPattern {
return pattern;
}

static AbstractionPattern
getCXXOperatorMethod(CanType origType, const clang::CXXMethodDecl *method) {
assert(isa<AnyFunctionType>(origType));
AbstractionPattern pattern;
pattern.initCXXMethod(nullptr, origType, method,
Kind::CXXOperatorMethodType);
return pattern;
}

/// Return an abstraction pattern for the curried type of a C++ method.
///
/// For example, if the original function is:
Expand All @@ -572,6 +602,16 @@ class AbstractionPattern {
return pattern;
}

static AbstractionPattern
getCurriedCXXOperatorMethod(CanType origType,
const clang::CXXMethodDecl *method) {
assert(isa<AnyFunctionType>(origType));
AbstractionPattern pattern;
pattern.initCXXMethod(nullptr, origType, method,
Kind::CurriedCXXOperatorMethodType);
return pattern;
}

/// For a C-function-as-method pattern,
/// get the index of the C function parameter that was imported as the
/// `self` parameter of the imported method, or None if this is a static
Expand Down Expand Up @@ -678,6 +718,17 @@ class AbstractionPattern {
return pattern;
}

static AbstractionPattern
getPartialCurriedCXXOperatorMethod(CanGenericSignature signature,
CanType origType,
const clang::CXXMethodDecl *method) {
assert(isa<AnyFunctionType>(origType));
AbstractionPattern pattern;
pattern.initCXXMethod(signature, origType, method,
Kind::PartialCurriedCXXOperatorMethodType);
return pattern;
}

public:
/// Return an abstraction pattern for the type of an Objective-C method.
static AbstractionPattern
Expand Down Expand Up @@ -813,6 +864,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::Type:
case Kind::Discard:
return OrigType;
Expand Down Expand Up @@ -849,6 +903,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::Type:
case Kind::Discard:
assert(signature || !type->hasTypeParameter());
Expand Down Expand Up @@ -886,6 +943,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
return true;
}
llvm_unreachable("bad kind");
Expand Down Expand Up @@ -923,7 +983,9 @@ class AbstractionPattern {
/// If so, it is legal to call getCXXMethod().
bool isCXXMethod() const {
return (getKind() == Kind::CXXMethodType ||
getKind() == Kind::CurriedCXXMethodType);
getKind() == Kind::CurriedCXXMethodType ||
getKind() == Kind::CXXOperatorMethodType ||
getKind() == Kind::CurriedCXXOperatorMethodType);
}

const clang::CXXMethodDecl *getCXXMethod() const {
Expand Down Expand Up @@ -958,6 +1020,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::OpaqueFunction:
case Kind::OpaqueDerivativeFunction:
return false;
Expand Down Expand Up @@ -994,6 +1059,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::Type:
case Kind::Discard:
return dyn_cast<TYPE>(getType());
Expand Down Expand Up @@ -1022,6 +1090,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::OpaqueFunction:
case Kind::OpaqueDerivativeFunction:
// We assume that the Clang type might provide additional structure.
Expand Down Expand Up @@ -1051,6 +1122,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::OpaqueFunction:
case Kind::OpaqueDerivativeFunction:
return false;
Expand Down Expand Up @@ -1078,6 +1152,9 @@ class AbstractionPattern {
case Kind::CXXMethodType:
case Kind::CurriedCXXMethodType:
case Kind::PartialCurriedCXXMethodType:
case Kind::CXXOperatorMethodType:
case Kind::CurriedCXXOperatorMethodType:
case Kind::PartialCurriedCXXOperatorMethodType:
case Kind::OpaqueFunction:
case Kind::OpaqueDerivativeFunction:
llvm_unreachable("pattern is not a tuple");
Expand Down
10 changes: 9 additions & 1 deletion include/swift/SIL/SILType.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef SWIFT_SIL_SILTYPE_H
#define SWIFT_SIL_SILTYPE_H

#include "swift/AST/CanTypeVisitor.h"
#include "swift/AST/SILLayout.h"
#include "swift/AST/Types.h"
#include "llvm/ADT/PointerIntPair.h"
Expand Down Expand Up @@ -622,10 +621,19 @@ template<> Can##ID##Type SILType::getAs<ID##Type>() const = delete; \
template<> Can##ID##Type SILType::castTo<ID##Type>() const = delete; \
template<> bool SILType::is<ID##Type>() const = delete;
NON_SIL_TYPE(Function)
NON_SIL_TYPE(GenericFunction)
NON_SIL_TYPE(AnyFunction)
NON_SIL_TYPE(LValue)
NON_SIL_TYPE(InOut)
#undef NON_SIL_TYPE

#define TYPE(ID, PARENT)
#define UNCHECKED_TYPE(ID, PARENT) \
template<> Can##ID##Type SILType::getAs<ID##Type>() const = delete; \
template<> Can##ID##Type SILType::castTo<ID##Type>() const = delete; \
template<> bool SILType::is<ID##Type>() const = delete;
#include "swift/AST/TypeNodes.def"

inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SILType T) {
T.print(OS);
return OS;
Expand Down
Loading