Skip to content

Commit d10f353

Browse files
authored
Merge pull request #2341 from swiftwasm/main
[pull] swiftwasm from main
2 parents 0de36ba + c9ef005 commit d10f353

19 files changed

+124
-1596
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
19891989
doSomething(x: 0, y: 0) // argument labels are required
19901990
```
19911991

1992-
Unapplied references to functions or initializers no longer carry argument labels. For example:
1992+
Unapplied references to functions or initializers no longer carry argument labels. For example:
19931993

19941994
```swift
19951995
let f = doSomething(x:y:) // inferred type is now (Int, Int) -> Void

lib/IDE/CodeCompletion.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5737,11 +5737,15 @@ static void addObserverKeywords(CodeCompletionResultSink &Sink) {
57375737
addKeyword(Sink, "didSet", CodeCompletionKeywordKind::None);
57385738
}
57395739

5740-
static void addExprKeywords(CodeCompletionResultSink &Sink) {
5740+
static void addExprKeywords(CodeCompletionResultSink &Sink,
5741+
bool IsConcurrencyEnabled) {
57415742
// Expr keywords.
57425743
addKeyword(Sink, "try", CodeCompletionKeywordKind::kw_try);
57435744
addKeyword(Sink, "try!", CodeCompletionKeywordKind::kw_try);
57445745
addKeyword(Sink, "try?", CodeCompletionKeywordKind::kw_try);
5746+
if (IsConcurrencyEnabled) {
5747+
addKeyword(Sink, "await", CodeCompletionKeywordKind::None);
5748+
}
57455749
}
57465750

57475751
static void addOpaqueTypeKeyword(CodeCompletionResultSink &Sink) {
@@ -5808,7 +5812,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
58085812
case CompletionKind::ForEachSequence:
58095813
addSuperKeyword(Sink);
58105814
addLetVarKeywords(Sink);
5811-
addExprKeywords(Sink);
5815+
addExprKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency);
58125816
addAnyTypeKeyword(Sink, CurDeclContext->getASTContext().TheAnyType);
58135817
break;
58145818

@@ -6635,7 +6639,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
66356639
addStmtKeywords(Sink, MaybeFuncBody);
66366640
addSuperKeyword(Sink);
66376641
addLetVarKeywords(Sink);
6638-
addExprKeywords(Sink);
6642+
addExprKeywords(Sink, Context.LangOpts.EnableExperimentalConcurrency);
66396643
addAnyTypeKeyword(Sink, Context.TheAnyType);
66406644
DoPostfixExprBeginning();
66416645
}

lib/Sema/CSDiagnostics.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,9 @@ bool ContextualFailure::diagnoseAsError() {
21202120
}
21212121

21222122
if (isExpr<AssignExpr>(anchor)) {
2123-
emitDiagnostic(diag::cannot_convert_assign, getFromType(), getToType());
2123+
auto diagnostic = emitDiagnostic(diag::cannot_convert_assign,
2124+
getFromType(), getToType());
2125+
tryIntegerCastFixIts(diagnostic);
21242126
return true;
21252127
}
21262128

@@ -2729,6 +2731,15 @@ bool ContextualFailure::tryIntegerCastFixIts(
27292731
auto fromType = getFromType();
27302732
auto toType = getToType();
27312733

2734+
auto anchor = getAnchor();
2735+
auto exprRange = getSourceRange();
2736+
2737+
if (auto *assignment = getAsExpr<AssignExpr>(anchor)) {
2738+
toType = toType->lookThroughAllOptionalTypes();
2739+
anchor = assignment->getSrc();
2740+
exprRange = assignment->getSrc()->getSourceRange();
2741+
}
2742+
27322743
if (!isIntegerType(fromType) || !isIntegerType(toType))
27332744
return false;
27342745

@@ -2747,8 +2758,8 @@ bool ContextualFailure::tryIntegerCastFixIts(
27472758
return parenE->getSubExpr();
27482759
};
27492760

2750-
if (auto *anchor = getAsExpr(getAnchor())) {
2751-
if (Expr *innerE = getInnerCastedExpr(anchor)) {
2761+
if (auto *expr = getAsExpr(anchor)) {
2762+
if (Expr *innerE = getInnerCastedExpr(expr)) {
27522763
Type innerTy = getType(innerE);
27532764
if (TypeChecker::isConvertibleTo(innerTy, toType, getDC())) {
27542765
// Remove the unnecessary cast.
@@ -2763,7 +2774,6 @@ bool ContextualFailure::tryIntegerCastFixIts(
27632774
std::string convWrapBefore = toType.getString();
27642775
convWrapBefore += "(";
27652776
std::string convWrapAfter = ")";
2766-
SourceRange exprRange = getSourceRange();
27672777
diagnostic.fixItInsert(exprRange.Start, convWrapBefore);
27682778
diagnostic.fixItInsertAfter(exprRange.End, convWrapAfter);
27692779
return true;

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,14 +3722,15 @@ bool ConstraintSystem::repairFailures(
37223722
if (lhs->is<FunctionType>() && rhs->is<FunctionType>())
37233723
return false;
37243724

3725-
// If either object type is a bound generic or existential it means
3726-
// that follow-up to value-to-optional is going to be:
3725+
// If either object type is a generic, nominal or existential type
3726+
// it means that follow-up to value-to-optional is going to be:
37273727
//
37283728
// 1. "deep equality" check, which is handled by generic argument(s)
3729-
// mismatch fix, or
3729+
// or contextual mismatch fix, or
37303730
// 2. "existential" check, which is handled by a missing conformance
37313731
// fix.
37323732
if ((lhs->is<BoundGenericType>() && rhs->is<BoundGenericType>()) ||
3733+
(lhs->is<NominalType>() && rhs->is<NominalType>()) ||
37333734
rhs->isAnyExistentialType())
37343735
return false;
37353736
}

stdlib/public/core/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,11 @@ set(SWIFTLIB_SOURCES
209209
Availability.swift
210210
CollectionDifference.swift
211211
CollectionOfOne.swift
212-
DiscontiguousSlice.swift
213212
Diffing.swift
214213
FloatingPointRandom.swift
215214
Mirror.swift
216215
PlaygroundDisplay.swift
217216
CommandLine.swift
218-
RangeSet.swift
219-
RangeSetStorage.swift
220217
SliceBuffer.swift
221218
SIMDVector.swift
222219
UnfoldSequence.swift

stdlib/public/core/CollectionAlgorithms.swift

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -209,70 +209,6 @@ extension BidirectionalCollection where Element: Equatable {
209209
}
210210
}
211211

212-
//===----------------------------------------------------------------------===//
213-
// subranges(where:) / subranges(of:)
214-
//===----------------------------------------------------------------------===//
215-
216-
extension Collection {
217-
/// Returns the indices of all the elements that match the given predicate.
218-
///
219-
/// For example, you can use this method to find all the places that a
220-
/// vowel occurs in a string.
221-
///
222-
/// let str = "Fresh cheese in a breeze"
223-
/// let vowels: Set<Character> = ["a", "e", "i", "o", "u"]
224-
/// let allTheVowels = str.subranges(where: { vowels.contains($0) })
225-
/// // str[allTheVowels].count == 9
226-
///
227-
/// - Parameter predicate: A closure that takes an element as its argument
228-
/// and returns a Boolean value that indicates whether the passed element
229-
/// represents a match.
230-
/// - Returns: A set of the indices of the elements for which `predicate`
231-
/// returns `true`.
232-
///
233-
/// - Complexity: O(*n*), where *n* is the length of the collection.
234-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
235-
public func subranges(where predicate: (Element) throws -> Bool) rethrows
236-
-> RangeSet<Index>
237-
{
238-
if isEmpty { return RangeSet() }
239-
240-
var result = RangeSet<Index>()
241-
var i = startIndex
242-
while i != endIndex {
243-
let next = index(after: i)
244-
if try predicate(self[i]) {
245-
result._append(i..<next)
246-
}
247-
i = next
248-
}
249-
250-
return result
251-
}
252-
}
253-
254-
extension Collection where Element: Equatable {
255-
/// Returns the indices of all the elements that are equal to the given
256-
/// element.
257-
///
258-
/// For example, you can use this method to find all the places that a
259-
/// particular letter occurs in a string.
260-
///
261-
/// let str = "Fresh cheese in a breeze"
262-
/// let allTheEs = str.subranges(of: "e")
263-
/// // str[allTheEs].count == 7
264-
///
265-
/// - Parameter element: An element to look for in the collection.
266-
/// - Returns: A set of the indices of the elements that are equal to
267-
/// `element`.
268-
///
269-
/// - Complexity: O(*n*), where *n* is the length of the collection.
270-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
271-
public func subranges(of element: Element) -> RangeSet<Index> {
272-
subranges(where: { $0 == element })
273-
}
274-
}
275-
276212
//===----------------------------------------------------------------------===//
277213
// partition(by:)
278214
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)