Merge pull request #9896 from devincoughlin/swap-fixit-weaken-assert-4.0
[Exclusivity] Weaken assert when suggesting swap() Fix-It
diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp
index 642df88..f9211dd 100644
--- a/lib/Demangling/Demangler.cpp
+++ b/lib/Demangling/Demangler.cpp
@@ -442,6 +442,10 @@
int RepeatCount = -1;
while (true) {
char c = nextChar();
+ if (c == 0) {
+ // End of text.
+ return nullptr;
+ }
if (isLowerLetter(c)) {
// It's a substitution with an index < 26.
NodePointer Nd = pushMultiSubstitutions(RepeatCount, c - 'a');
@@ -1322,7 +1326,8 @@
case FunctionSigSpecializationParamKind::ClosureProp: {
size_t FixedChildren = Param->getNumChildren();
while (NodePointer Ty = popNode(Node::Kind::Type)) {
- assert(ParamKind == FunctionSigSpecializationParamKind::ClosureProp);
+ if (ParamKind != FunctionSigSpecializationParamKind::ClosureProp)
+ return nullptr;
Param = addChild(Param, Ty);
}
NodePointer Name = popNode(Node::Kind::Identifier);
diff --git a/lib/PrintAsObjC/PrintAsObjC.cpp b/lib/PrintAsObjC/PrintAsObjC.cpp
index b311794..a95e869 100644
--- a/lib/PrintAsObjC/PrintAsObjC.cpp
+++ b/lib/PrintAsObjC/PrintAsObjC.cpp
@@ -825,7 +825,7 @@
if (!attr || !attr->isSwift3Inferred())
return;
- os << " SWIFT_DEPRECATED_MSG(\"Swift ";
+ os << " SWIFT_DEPRECATED_OBJC(\"Swift ";
if (isa<VarDecl>(VD))
os << "property";
else if (isa<SubscriptDecl>(VD))
@@ -2337,6 +2337,7 @@
out << "// Generated by " << version::getSwiftFullVersion(
M.getASTContext().LangOpts.EffectiveLanguageVersion) << "\n"
"#pragma clang diagnostic push\n"
+ "#pragma clang diagnostic ignored \"-Wgcc-compat\"\n"
"\n"
"#if !defined(__has_include)\n"
"# define __has_include(x) 0\n"
@@ -2528,6 +2529,11 @@
"#if !defined(SWIFT_DEPRECATED_MSG)\n"
"# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))\n"
"#endif\n"
+ "#if __has_feature(attribute_diagnose_if_objc)\n"
+ "# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, \"warning\")))\n"
+ "#else\n"
+ "# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)\n"
+ "#endif\n"
;
static_assert(SWIFT_MAX_IMPORTED_SIMD_ELEMENTS == 4,
"need to add SIMD typedefs here if max elements is increased");
diff --git a/stdlib/public/core/ArrayType.swift b/stdlib/public/core/ArrayType.swift
index b79e5c6..645ad3a 100644
--- a/stdlib/public/core/ArrayType.swift
+++ b/stdlib/public/core/ArrayType.swift
@@ -70,3 +70,15 @@
// For testing.
var _buffer: _Buffer { get }
}
+
+extension _ArrayProtocol {
+ // Since RangeReplaceableCollection now has a version of filter that is less
+ // efficient, we should make the default implementation coming from Sequence
+ // preferred.
+ @_inlineable
+ public func filter(
+ _ isIncluded: (Element) throws -> Bool
+ ) rethrows -> [Element] {
+ return try _filter(isIncluded)
+ }
+}
diff --git a/stdlib/public/core/Arrays.swift.gyb b/stdlib/public/core/Arrays.swift.gyb
index 4aeed18d..f2310c7 100644
--- a/stdlib/public/core/Arrays.swift.gyb
+++ b/stdlib/public/core/Arrays.swift.gyb
@@ -1574,16 +1574,6 @@
}
}
- // Since RangeReplaceableCollection now has a version of filter that is less
- // efficient, we should make the default implementation coming from Sequence
- // preferred.
- @_inlineable
- public func filter(
- _ isIncluded: (Element) throws -> Bool
- ) rethrows -> [Element] {
- return try _filter(isIncluded)
- }
-
//===--- algorithms -----------------------------------------------------===//
@_inlineable
diff --git a/test/Demangle/Inputs/manglings.txt b/test/Demangle/Inputs/manglings.txt
index 438d750..1eedde0 100644
--- a/test/Demangle/Inputs/manglings.txt
+++ b/test/Demangle/Inputs/manglings.txt
@@ -254,4 +254,6 @@
_T04test6testitSiyt_tF ---> test.testit(()) -> Swift.Int
_T0Rml ---> _T0Rml
_T0Tk ---> _T0Tk
+_T0A8 ---> _T0A8
+_T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n ---> _T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n
diff --git a/test/PrintAsObjC/swift3_deprecated_objc_inference.swift b/test/PrintAsObjC/swift3_deprecated_objc_inference.swift
index c56d5ce..38929f1 100644
--- a/test/PrintAsObjC/swift3_deprecated_objc_inference.swift
+++ b/test/PrintAsObjC/swift3_deprecated_objc_inference.swift
@@ -32,15 +32,15 @@
}
// CHECK-LABEL: @interface A2{{$}}
-// CHECK-NEXT: - (nonnull instancetype)initWithA2:(A2 * _Nonnull)a2 OBJC_DESIGNATED_INITIALIZER SWIFT_DEPRECATED_MSG("Swift initializer 'A2.init(a2:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: - (void)foo SWIFT_DEPRECATED_MSG("Swift method 'A2.foo()' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: + (void)bar SWIFT_DEPRECATED_MSG("Swift method 'A2.bar()' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: @property (nonatomic, strong) A2 * _Nullable property SWIFT_DEPRECATED_MSG("Swift property 'A2.property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: SWIFT_CLASS_PROPERTY(@property (nonatomic, class, strong) A2 * _Nullable static_property SWIFT_DEPRECATED_MSG("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");)
-// CHECK-NEXT: + (A2 * _Nullable)static_property SWIFT_WARN_UNUSED_RESULT SWIFT_DEPRECATED_MSG("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: + (void)setStatic_property:(A2 * _Nullable)value SWIFT_DEPRECATED_MSG("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: - (A2 * _Nonnull)objectAtIndexedSubscript:(NSInteger)i SWIFT_WARN_UNUSED_RESULT SWIFT_DEPRECATED_MSG("Swift subscript 'A2.subscript(_:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
-// CHECK-NEXT: - (void)setObject:(A2 * _Nonnull)newValue atIndexedSubscript:(NSInteger)i SWIFT_DEPRECATED_MSG("Swift subscript 'A2.subscript(_:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: - (nonnull instancetype)initWithA2:(A2 * _Nonnull)a2 OBJC_DESIGNATED_INITIALIZER SWIFT_DEPRECATED_OBJC("Swift initializer 'A2.init(a2:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: - (void)foo SWIFT_DEPRECATED_OBJC("Swift method 'A2.foo()' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: + (void)bar SWIFT_DEPRECATED_OBJC("Swift method 'A2.bar()' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: @property (nonatomic, strong) A2 * _Nullable property SWIFT_DEPRECATED_OBJC("Swift property 'A2.property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: SWIFT_CLASS_PROPERTY(@property (nonatomic, class, strong) A2 * _Nullable static_property SWIFT_DEPRECATED_OBJC("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");)
+// CHECK-NEXT: + (A2 * _Nullable)static_property SWIFT_WARN_UNUSED_RESULT SWIFT_DEPRECATED_OBJC("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: + (void)setStatic_property:(A2 * _Nullable)value SWIFT_DEPRECATED_OBJC("Swift property 'A2.static_property' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: - (A2 * _Nonnull)objectAtIndexedSubscript:(NSInteger)i SWIFT_WARN_UNUSED_RESULT SWIFT_DEPRECATED_OBJC("Swift subscript 'A2.subscript(_:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
+// CHECK-NEXT: - (void)setObject:(A2 * _Nonnull)newValue atIndexedSubscript:(NSInteger)i SWIFT_DEPRECATED_OBJC("Swift subscript 'A2.subscript(_:)' uses '@objc' inference deprecated in Swift 4; add '@objc' to provide an Objective-C entrypoint");
// CHECK-NEXT: @end
@objc class A2 {
diff --git a/test/stdlib/RangeReplaceableFilterCompatibility.swift b/test/stdlib/RangeReplaceableFilterCompatibility.swift
index 169654f..37ac3d1 100644
--- a/test/stdlib/RangeReplaceableFilterCompatibility.swift
+++ b/test/stdlib/RangeReplaceableFilterCompatibility.swift
@@ -35,5 +35,10 @@
expectEqualSequence("HW", filtered)
}
+tests.test("lazy.flatMap.filter ambiguity") {
+ // this expression should compile without ambiguity
+ _ = Array(0..<10).lazy.flatMap { .some($0) }.filter { _ in false }
+}
+
runAllTests()