Skip to content

Commit 3c50584

Browse files
author
Nathan Hawes
authored
---
yaml --- r: 326137 b: refs/heads/master-next c: 4dac0d1 h: refs/heads/master i: 326135: f6045cd
1 parent e7c7642 commit 3c50584

File tree

537 files changed

+8120
-5435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

537 files changed

+8120
-5435
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e052da7d8886fa0439677852e8f7830b20c2e1da
3-
refs/heads/master-next: 54defbc7f747cf9dd7396ec18cc1f93242bd2d5e
3+
refs/heads/master-next: 4dac0d1e8bffee79728f04784961b3bc26ed9dbc
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/CHANGELOG.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,63 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SR-11298][]:
30+
31+
A class-constrained protocol extension, where the extended protocol does
32+
not impose a class constraint, will now infer the constraint implicitly.
33+
34+
```swift
35+
protocol Foo {}
36+
class Bar: Foo {
37+
var someProperty: Int = 0
38+
}
39+
40+
// Even though 'Foo' does not impose a class constraint, it is automatically
41+
// inferred due to the Self: Bar constraint.
42+
extension Foo where Self: Bar {
43+
var anotherProperty: Int {
44+
get { return someProperty }
45+
// As a result, the setter is now implicitly nonmutating, just like it would
46+
// be if 'Foo' had a class constraint.
47+
set { someProperty = newValue }
48+
}
49+
}
50+
```
51+
52+
As a result, this could lead to code that currently compiles today to throw an error.
53+
54+
```swift
55+
protocol Foo {
56+
var someProperty: Int { get set }
57+
}
58+
59+
class Bar: Foo {
60+
var someProperty = 0
61+
}
62+
63+
extension Foo where Self: Bar {
64+
var anotherProperty1: Int {
65+
get { return someProperty }
66+
// This will now error, because the protocol requirement
67+
// is implicitly mutating and the setter is implicitly
68+
// nonmutating.
69+
set { someProperty = newValue } // Error
70+
}
71+
}
72+
```
73+
74+
**Workaround**: Define a new mutable variable inside the setter that has a reference to `self`:
75+
76+
```swift
77+
var anotherProperty1: Int {
78+
get { return someProperty }
79+
set {
80+
var mutableSelf = self
81+
mutableSelf.someProperty = newValue // Okay
82+
}
83+
}
84+
```
85+
2986
* [SE-0253][]:
3087

3188
Values of types that declare `func callAsFunction` methods can be called
@@ -51,7 +108,7 @@ Swift Next
51108

52109
* [SR-4206][]:
53110

54-
A method override is no longer allowed to have a generic signature with
111+
A method override is no longer allowed to have a generic signature with
55112
requirements not imposed by the base method. For example:
56113

57114
```
@@ -7765,3 +7822,4 @@ Swift 1.0
77657822
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
77667823
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
77677824
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7825+
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>

branches/master-next/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
219219
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
220220
"Path to the directory that contains Swift tools that are executable on the build machine")
221221

222-
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
222+
option(SWIFT_ENABLE_MODULE_INTERFACES
223223
"Generate .swiftinterface files alongside .swiftmodule files"
224224
TRUE)
225225

branches/master-next/cmake/modules/StandaloneOverlay.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
5858
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
5959
"Path to Swift tools that are executable on the build machine.")
6060

61-
option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
61+
option(SWIFT_ENABLE_MODULE_INTERFACES
6262
"Generate .swiftinterface files alongside .swiftmodule files."
6363
TRUE)
6464

branches/master-next/cmake/modules/SwiftSource.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ function(_compile_swift_files
323323
set(sibopt_file "${module_base}.O.sib")
324324
set(sibgen_file "${module_base}.sibgen")
325325

326-
if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
326+
if(SWIFT_ENABLE_MODULE_INTERFACES)
327327
set(interface_file "${module_base}.swiftinterface")
328328
list(APPEND swift_module_flags
329-
"-emit-parseable-module-interface-path" "${interface_file}")
329+
"-emit-module-interface-path" "${interface_file}")
330330
endif()
331331

332332
# If we have extra regexp flags, check if we match any of the regexps. If so

branches/master-next/include/swift/AST/ASTScope.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ class ASTScopeImpl {
215215

216216
bool checkSourceRangeOfThisASTNode() const;
217217

218+
/// For debugging
219+
bool doesRangeMatch(unsigned start, unsigned end, StringRef file = "",
220+
StringRef className = "");
221+
218222
private:
219223
SourceRange computeSourceRangeOfScope(bool omitAssertions = false) const;
220224
SourceRange
@@ -264,7 +268,7 @@ class ASTScopeImpl {
264268
getSourceRangeOfEnclosedParamsOfASTNode(bool omitAssertions) const;
265269

266270
private:
267-
bool checkSourceRangeAfterExpansion() const;
271+
bool checkSourceRangeAfterExpansion(const ASTContext &) const;
268272

269273
#pragma mark common queries
270274
public:
@@ -318,9 +322,9 @@ class ASTScopeImpl {
318322
private:
319323
/// Compare the pre-expasion range with the post-expansion range and return
320324
/// false if lazyiness couild miss lookups.
321-
bool checkLazySourceRange() const;
325+
bool checkLazySourceRange(const ASTContext &) const;
322326

323-
protected:
327+
public:
324328
/// Some scopes can be expanded lazily.
325329
/// Such scopes must: not change their source ranges after expansion, and
326330
/// their expansion must return an insertion point outside themselves.
@@ -517,6 +521,7 @@ class ASTSourceFileScope final : public ASTScopeImpl {
517521
NullablePtr<DeclContext> getDeclContext() const override;
518522

519523
void addNewDeclsToScopeTree();
524+
void buildScopeTreeEagerly();
520525

521526
const SourceFile *getSourceFile() const override;
522527
NullablePtr<const void> addressForPrinting() const override { return SF; }
@@ -1002,6 +1007,10 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
10021007
DeclConsumer) const override;
10031008
Optional<bool>
10041009
resolveIsCascadingUseForThisScope(Optional<bool>) const override;
1010+
1011+
public:
1012+
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
1013+
SourceRange sourceRangeForDeferredExpansion() const override;
10051014
};
10061015

10071016
/// Body of methods, functions in types.

0 commit comments

Comments
 (0)