Merge pull request #22614 from linux-on-ibm-z/s390x-smallstring-5.0-backport
[5.0] [string] Fix string implementation for big endian platforms
diff --git a/lib/AST/GenericSignatureBuilder.cpp b/lib/AST/GenericSignatureBuilder.cpp
index 60205de..89826ad 100644
--- a/lib/AST/GenericSignatureBuilder.cpp
+++ b/lib/AST/GenericSignatureBuilder.cpp
@@ -2100,7 +2100,9 @@
// Infer same-type constraints among same-named associated type anchors.
if (assocTypeAnchors.size() > 1) {
auto anchorType = getAnchor(builder, builder.getGenericParams());
- auto inferredSource = FloatingRequirementSource::forInferred(nullptr);
+ auto inferredSource =
+ FloatingRequirementSource::forNestedTypeNameMatch(
+ assocTypeAnchors.front()->getName());
for (auto assocType : assocTypeAnchors) {
if (assocType == bestAssocType) continue;
@@ -4732,7 +4734,8 @@
if (allNested.size() > 1) {
auto firstPA = allNested.front();
auto inferredSource =
- FloatingRequirementSource::forInferred(nullptr);
+ FloatingRequirementSource::forNestedTypeNameMatch(
+ nestedPA->getNestedName());
addSameTypeRequirement(firstPA, nestedPA, inferredSource,
UnresolvedHandlingKind::GenerateConstraints);
diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp
index ef8f0bf..815be1d 100644
--- a/lib/Migrator/APIDiffMigratorPass.cpp
+++ b/lib/Migrator/APIDiffMigratorPass.cpp
@@ -1102,6 +1102,25 @@
}
}
+ // If a property has changed from nonnull to nullable, we should add ! to the
+ // reference of the property.
+ bool handlePropertyTypeChange(Expr *E) {
+ if (auto MRE = dyn_cast<MemberRefExpr>(E)) {
+ if (auto *VD = MRE->getReferencedDecl().getDecl()) {
+ for (auto *I: getRelatedDiffItems(VD)) {
+ if (auto *Item = dyn_cast<CommonDiffItem>(I)) {
+ if (Item->DiffKind == NodeAnnotation::WrapOptional &&
+ Item->NodeKind == SDKNodeKind::DeclVar) {
+ Editor.insertAfterToken(E->getEndLoc(), "!");
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
bool walkToExprPre(Expr *E) override {
if (E->getSourceRange().isInvalid())
return false;
@@ -1115,6 +1134,8 @@
return false;
if (handleAttributeReference(E))
return false;
+ if (handlePropertyTypeChange(E))
+ return false;
if (auto *CE = dyn_cast<CallExpr>(E)) {
auto Fn = CE->getFn();
auto Args = CE->getArg();
diff --git a/lib/Parse/Lexer.cpp b/lib/Parse/Lexer.cpp
index a5acee6..076358c 100644
--- a/lib/Parse/Lexer.cpp
+++ b/lib/Parse/Lexer.cpp
@@ -953,8 +953,6 @@
// independent of language mode.
return formToken(tok::identifier, tokStart);
} else {
- if (LangOpts.EnableDollarIdentifiers && !LangOpts.Playground)
- return formToken(tok::identifier, tokStart);
return formToken(tok::dollarident, tokStart);
}
}
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index ef443cf..5a82953 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -2915,6 +2915,12 @@
auto closure = dyn_cast_or_null<ClosureExpr>(
dyn_cast<AbstractClosureExpr>(CurDeclContext));
if (!closure) {
+ if (Context.LangOpts.DebuggerSupport) {
+ auto refKind = DeclRefKind::Ordinary;
+ auto identifier = Context.getIdentifier(Name);
+ return new (Context) UnresolvedDeclRefExpr(DeclName(identifier), refKind,
+ DeclNameLoc(Loc));
+ }
diagnose(Loc, diag::anon_closure_arg_not_in_closure);
return new (Context) ErrorExpr(Loc);
}
diff --git a/test/Generics/Inputs/rdar48049725_other.swift b/test/Generics/Inputs/rdar48049725_other.swift
new file mode 100644
index 0000000..328f7b7
--- /dev/null
+++ b/test/Generics/Inputs/rdar48049725_other.swift
@@ -0,0 +1,17 @@
+public protocol P1 {
+ associatedtype A1: SomeClass
+}
+
+public protocol P4: P2 where A2: P1 {}
+
+
+public class SomeClass { }
+
+protocol P5 {
+ associatedtype A3: P4
+}
+
+struct Foo {
+ static func f<T: P5>(_: T) {
+ }
+}
diff --git a/test/Generics/rdar48049725.swift b/test/Generics/rdar48049725.swift
new file mode 100644
index 0000000..7364ffb
--- /dev/null
+++ b/test/Generics/rdar48049725.swift
@@ -0,0 +1,16 @@
+// RUN: %target-swift-frontend -primary-file %s -emit-ir %S/Inputs/rdar48049725_other.swift | %FileCheck %s
+public protocol P3 {
+ associatedtype A1: SomeClass
+}
+
+
+public protocol P2 {
+ associatedtype A2: P3
+}
+
+
+func test<T: P5>(value: T) {
+ // Ensure that we get the right generic signature for Foo.f
+ // CHECK: call swiftcc void @"$s12rdar480497253FooV1fyyxAA2P5RzlFZ"
+ Foo.f(value)
+}
diff --git a/test/Generics/requirement_inference.swift b/test/Generics/requirement_inference.swift
index 02cd9c0..3dc7b4a 100644
--- a/test/Generics/requirement_inference.swift
+++ b/test/Generics/requirement_inference.swift
@@ -154,12 +154,11 @@
}
// CHECK-LABEL: sameTypeConcrete1@
-// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : P10, τ_0_0 : P9, τ_0_0.A == X3, τ_0_0.A == X3, τ_0_0.B == Int, τ_0_0.C == Int>
+// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : P10, τ_0_0 : P9, τ_0_0.A == X3, τ_0_0.B == Int, τ_0_0.C == Int>
func sameTypeConcrete1<T : P9 & P10>(_: T) where T.A == X3, T.C == T.B, T.C == Int { }
// CHECK-LABEL: sameTypeConcrete2@
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : P10, τ_0_0 : P9, τ_0_0.B == X3, τ_0_0.C == X3>
-// FIXME: Should have τ_0_0.A == τ_0_0.A
func sameTypeConcrete2<T : P9 & P10>(_: T) where T.B : X3, T.C == T.B, T.C == X3 { }
// expected-warning@-1{{redundant superclass constraint 'T.B' : 'X3'}}
// expected-note@-2{{same-type constraint 'T.C' == 'X3' written here}}
@@ -402,7 +401,7 @@
protocol P31 { }
// CHECK-LABEL: .sameTypeNameMatch1@
-// CHECK: Generic signature: <T where T : P29, T : P30, T.X : P31, T.X == T.X>
+// CHECK: Generic signature: <T where T : P29, T : P30, T.X : P31>
func sameTypeNameMatch1<T: P29 & P30>(_: T) where T.X: P31 { }
// ----------------------------------------------------------------------------
diff --git a/test/Migrator/Inputs/CallExpr.json b/test/Migrator/Inputs/CallExpr.json
index ec11dd5..431f4cd 100644
--- a/test/Migrator/Inputs/CallExpr.json
+++ b/test/Migrator/Inputs/CallExpr.json
@@ -20,5 +20,16 @@
"RightUsr": "",
"RightComment": "",
"ModuleName": "Cities"
+ },
+ {
+ "DiffItemKind": "CommonDiffItem",
+ "NodeKind": "Var",
+ "NodeAnnotation": "WrapOptional",
+ "ChildIndex": "0",
+ "LeftUsr": "s:6CitiesAAC4nameSSvp",
+ "LeftComment": "",
+ "RightUsr": "",
+ "RightComment": "",
+ "ModuleName": "Cities"
}
]
diff --git a/test/Migrator/Inputs/Cities.swift b/test/Migrator/Inputs/Cities.swift
index 5cb7320..dc04453 100644
--- a/test/Migrator/Inputs/Cities.swift
+++ b/test/Migrator/Inputs/Cities.swift
@@ -1,5 +1,6 @@
open class Cities {
var x: Int
+ public var name: String = ""
public init(x: Int) { self.x = x }
public init!(y: Int) { self.x = y }
open func mooloolaba(x: Cities, y: Cities?) {}
diff --git a/test/Migrator/call_expr_result.swift b/test/Migrator/call_expr_result.swift
index 01f1c8b..55dfcc5 100644
--- a/test/Migrator/call_expr_result.swift
+++ b/test/Migrator/call_expr_result.swift
@@ -10,4 +10,8 @@
let c1 = Cities(x: 3)
_ = Cities.init(x: 3)
_ = c1.noosa()
-}
\ No newline at end of file
+ _ = c1.name
+ bar(c1.name)
+}
+
+func bar(_ n: String) {}
diff --git a/test/Migrator/call_expr_result.swift.expected b/test/Migrator/call_expr_result.swift.expected
index 4210d21..1a211b0 100644
--- a/test/Migrator/call_expr_result.swift.expected
+++ b/test/Migrator/call_expr_result.swift.expected
@@ -10,4 +10,8 @@
let c1 = Cities(x: 3)!
_ = Cities.init(x: 3)!
_ = c1.noosa()!
-}
\ No newline at end of file
+ _ = c1.name!
+ bar(c1.name!)
+}
+
+func bar(_ n: String) {}
diff --git a/test/Parse/closure-debugger.swift b/test/Parse/closure-debugger.swift
new file mode 100644
index 0000000..4f74e62
--- /dev/null
+++ b/test/Parse/closure-debugger.swift
@@ -0,0 +1,6 @@
+// RUN: not %target-swift-frontend %s -typecheck -debugger-support 2>&1 | %FileCheck %s --check-prefix=DEBUG
+// RUN: not %target-swift-frontend %s -typecheck 2>&1 | %FileCheck %s --check-prefix=NODEBUG
+
+// DEBUG: error: use of unresolved identifier '$0'
+// NODEBUG: error: anonymous closure argument not contained in a closure
+$0
diff --git a/test/ParseableInterface/stored-properties-client.swift b/test/ParseableInterface/stored-properties-client.swift
index 914815b..1c17600 100644
--- a/test/ParseableInterface/stored-properties-client.swift
+++ b/test/ParseableInterface/stored-properties-client.swift
@@ -6,6 +6,8 @@
// RUN: %target-swift-frontend -typecheck %S/stored-properties.swift -enable-resilience -module-name StoredProperties -emit-parseable-module-interface-path %t/StoredProperties.swiftinterface
// RUN: %target-swift-frontend -emit-ir %s -I %t -enable-parseable-module-interface | %FileCheck %s -check-prefix RESILIENT -check-prefix COMMON
+// REQUIRES: rdar_48061099
+
import StoredProperties
/// This test makes sure clients of a parseable interface see correct type
diff --git a/utils/build-presets.ini b/utils/build-presets.ini
index a00f122..bffca2a 100644
--- a/utils/build-presets.ini
+++ b/utils/build-presets.ini
@@ -1129,6 +1129,23 @@
lto
+[preset: buildbot_osx_package,no_assertions,no_test]
+mixin-preset=
+ buildbot_osx_package,no_assertions
+
+dash-dash
+
+skip-test-swift
+skip-test-swiftpm
+skip-test-llbuild
+skip-test-lldb
+skip-test-cmark
+skip-test-playgroundsupport
+skip-test-swiftsyntax
+skip-test-skstresstester
+skip-test-swiftevolve
+
+
# Debug version of the compilers, release version of the stdlib.
[preset: buildbot_osx_package,tools=DA,stdlib=R]
mixin-preset=buildbot_osx_package
diff --git a/validation-test/Sema/type_checker_perf/fast/rdar21398466.swift b/validation-test/Sema/type_checker_perf/fast/rdar21398466.swift
index 78bfb31..635c028 100644
--- a/validation-test/Sema/type_checker_perf/fast/rdar21398466.swift
+++ b/validation-test/Sema/type_checker_perf/fast/rdar21398466.swift
@@ -1,5 +1,7 @@
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 5 -solver-disable-shrink -disable-constraint-solver-performance-hacks -solver-enable-operator-designated-types
-// REQUIRES: tools-release,no_asserts
+// REQUIRES: OS=macosx
+// REQUIRES: asserts
+// REQUIRES: rdar48061151
// This problem is related to renaming,
// as soon as `init(truncatingBitPattern:)` is changed