Skip to content

Commit 7a79b35

Browse files
authored
Merge pull request #2020 from swiftwasm/main
[pull] swiftwasm from main
2 parents 691bef6 + 2ae0c80 commit 7a79b35

File tree

8 files changed

+71
-14
lines changed

8 files changed

+71
-14
lines changed

docs/HowToGuides/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ built compiler to compile both packages and Xcode projects.
4242
Create a build setting `SWIFT_EXEC` with the value set to `/path/to/swiftc`.
4343
If you now do a clean build, your locally built compiler will be used.
4444

45-
At the time of writing, in the latest Xcode 12 beta, `SWIFT_EXEC` does not
45+
At the time of writing, in the latest Xcode 12.2 beta 3, `SWIFT_EXEC` does not
4646
work for SwiftPM integration inside Xcode, so this will not work for Xcode
4747
projects that depend on SwiftPM packages.
4848

docs/HowToGuides/GettingStarted.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Double-check that running `pwd` prints a path ending with `swift`.
126126
127127
### macOS
128128
129-
1. Install [Xcode 12 beta 3][Xcode] or newer:
129+
1. Install [Xcode 12.2 beta 3][Xcode] or newer:
130130
The required version of Xcode changes frequently and is often a beta release.
131131
Check this document or the host information on <https://ci.swift.org> for the
132132
current required version.

include/swift/Sema/ConstraintSystem.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -3160,8 +3160,7 @@ class ConstraintSystem {
31603160
/// subsequent solution would be worse than the best known solution.
31613161
bool recordFix(ConstraintFix *fix, unsigned impact = 1);
31623162

3163-
void recordPotentialHole(TypeVariableType *typeVar);
3164-
void recordPotentialHole(FunctionType *fnType);
3163+
void recordPotentialHole(Type type);
31653164

31663165
void recordTrailingClosureMatch(
31673166
ConstraintLocator *locator,

lib/Sema/CSSimplify.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -9913,16 +9913,11 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix, unsigned impact) {
99139913
return false;
99149914
}
99159915

9916-
void ConstraintSystem::recordPotentialHole(TypeVariableType *typeVar) {
9917-
assert(typeVar);
9918-
typeVar->getImpl().enableCanBindToHole(getSavedBindings());
9919-
}
9920-
9921-
void ConstraintSystem::recordPotentialHole(FunctionType *fnType) {
9922-
assert(fnType);
9923-
Type(fnType).visit([&](Type type) {
9916+
void ConstraintSystem::recordPotentialHole(Type type) {
9917+
assert(type->hasTypeVariable());
9918+
type.visit([&](Type type) {
99249919
if (auto *typeVar = type->getAs<TypeVariableType>())
9925-
recordPotentialHole(typeVar);
9920+
typeVar->getImpl().enableCanBindToHole(getSavedBindings());
99269921
});
99279922
}
99289923

@@ -10024,7 +10019,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1002410019
newTupleTypes.push_back(smallerElt);
1002510020
} else {
1002610021
if (largerElt.getType()->isTypeVariableOrMember())
10027-
recordPotentialHole(largerElt.getType()->getAs<TypeVariableType>());
10022+
recordPotentialHole(largerElt.getType());
1002810023
}
1002910024
}
1003010025
auto matchingType =

lib/Sema/TypeCheckEffects.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,13 @@ class Context {
878878
HandlesErrors(handlesErrors), HandlesAsync(handlesAsync) { }
879879

880880
public:
881+
bool shouldDiagnoseErrorOnTry() const {
882+
return DiagnoseErrorOnTry;
883+
}
884+
void setDiagnoseErrorOnTry(bool b) {
885+
DiagnoseErrorOnTry = b;
886+
}
887+
881888
/// Whether this is a function that rethrows.
882889
bool isRethrows() const {
883890
if (!HandlesErrors)
@@ -1375,6 +1382,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
13751382
DeclContext *OldRethrowsDC;
13761383
ContextFlags OldFlags;
13771384
ThrowingKind OldMaxThrowingKind;
1385+
13781386
public:
13791387
ContextScope(CheckEffectsCoverage &self, Optional<Context> newContext)
13801388
: Self(self), OldContext(self.CurContext),
@@ -1468,7 +1476,15 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
14681476
}
14691477

14701478
~ContextScope() {
1479+
// The "DiagnoseErrorOnTry" flag is a bit of mutable state
1480+
// in the Context itself, used to postpone diagnostic emission
1481+
// to a parent "try" expression. If something was diagnosed
1482+
// during this ContextScope, the flag may have been set, and
1483+
// we need to preseve its value when restoring the old Context.
1484+
bool DiagnoseErrorOnTry = Self.CurContext.shouldDiagnoseErrorOnTry();
14711485
Self.CurContext = OldContext;
1486+
Self.CurContext.setDiagnoseErrorOnTry(DiagnoseErrorOnTry);
1487+
14721488
Self.RethrowsDC = OldRethrowsDC;
14731489
Self.Flags = OldFlags;
14741490
Self.MaxThrowingKind = OldMaxThrowingKind;

test/Constraints/lvalues.swift

+25
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,28 @@ func wump<T>(to: T, _ body: (G<T>) -> ()) {}
241241

242242
wump(to: 0, { $0[] = 0 })
243243
// expected-error@-1 {{missing argument for parameter #1 in call}}
244+
245+
// SR-13732
246+
extension MutableCollection {
247+
public mutating func writePrefix<I: IteratorProtocol>(from source: inout I)
248+
-> (writtenCount: Int, afterLastWritten: Index)
249+
where I.Element == Element
250+
{
251+
fatalError()
252+
}
253+
254+
public mutating func writePrefix<Source: Collection>(from source: Source)
255+
-> (writtenCount: Int, afterLastWritten: Index, afterLastRead: Source.Index)
256+
where Source.Element == Element
257+
{
258+
fatalError()
259+
}
260+
261+
}
262+
263+
func testWritePrefixIterator() {
264+
var a = Array(0..<10)
265+
266+
var underflow = (1..<10).makeIterator()
267+
var (writtenCount, afterLastWritten) = a.writePrefix(from: underflow) // expected-error {{passing value of type 'IndexingIterator<(Range<Int>)>' to an inout parameter requires explicit '&'}} {{62-62=&}}
268+
}

test/expr/unary/async_await.swift

+9
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,12 @@ func testStringInterpolation() async throws {
133133
_ = "Eventually produces \(await getInt())"
134134
_ = await "Eventually produces \(getInt())"
135135
}
136+
137+
// Make sure try await works too
138+
func invalidAsyncFunction() async {
139+
_ = try await throwingAndAsync() // expected-error {{errors thrown from here are not handled}}
140+
}
141+
142+
func validAsyncFunction() async throws {
143+
_ = try await throwingAndAsync()
144+
}

test/stmt/errors.swift

+13
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,16 @@ func sr_11402_func2(_ x: SR_11402_P) {
251251
print(y)
252252
}
253253
}
254+
255+
// https://bugs.swift.org/browse/SR-13654
256+
257+
func sr_13654_func() throws -> String {}
258+
259+
func sr_13654_invalid_interpolation() {
260+
_ = try "\(sr_13654_func())" // expected-error {{errors thrown from here are not handled}}
261+
_ = "\(try sr_13654_func())" // expected-error {{errors thrown from here are not handled}}
262+
}
263+
func sr_13654_valid_interpolation() throws {
264+
_ = try "\(sr_13654_func())"
265+
_ = "\(try sr_13654_func())"
266+
}

0 commit comments

Comments
 (0)