Skip to content

Commit 8464afd

Browse files
committed
Sema: Remove SourceFile::SynthesizedDecls
1 parent 82f8db2 commit 8464afd

File tree

5 files changed

+14
-37
lines changed

5 files changed

+14
-37
lines changed

include/swift/AST/SourceFile.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,6 @@ class SourceFile final : public FileUnit {
217217
/// The list of local type declarations in the source file.
218218
llvm::SetVector<TypeDecl *> LocalTypeDecls;
219219

220-
/// A set of synthesized declarations that need to be type checked.
221-
llvm::SmallVector<Decl *, 8> SynthesizedDecls;
222-
223220
/// The list of functions defined in this file whose bodies have yet to be
224221
/// typechecked. They must be held in this list instead of eagerly validated
225222
/// because their bodies may force us to perform semantic checks of arbitrary
@@ -228,11 +225,6 @@ class SourceFile final : public FileUnit {
228225
/// unless the entire conformance has been evaluated.
229226
std::vector<AbstractFunctionDecl *> DelayedFunctions;
230227

231-
/// We might perform type checking on the same source file more than once,
232-
/// if its the main file or a REPL instance, so keep track of the last
233-
/// checked synthesized declaration to avoid duplicating work.
234-
unsigned LastCheckedSynthesizedDecl = 0;
235-
236228
/// A mapping from Objective-C selectors to the methods that have
237229
/// those selectors.
238230
llvm::DenseMap<ObjCSelector, llvm::TinyPtrVector<AbstractFunctionDecl *>>

lib/Sema/DerivedConformances.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ DeclContext *DerivedConformance::getConformanceContext() const {
4343
void DerivedConformance::addMembersToConformanceContext(
4444
ArrayRef<Decl *> children) {
4545
auto IDC = cast<IterableDeclContext>(ConformanceDecl);
46-
auto *SF = ConformanceDecl->getDeclContext()->getParentSourceFile();
47-
for (auto child : children) {
46+
for (auto child : children)
4847
IDC->addMember(child);
49-
if (SF)
50-
SF->SynthesizedDecls.push_back(child);
51-
}
5248
}
5349

5450
Type DerivedConformance::getProtocolType() const {

lib/Sema/TypeChecker.cpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,28 +247,13 @@ void swift::bindExtensions(ModuleDecl &mod) {
247247

248248
static void typeCheckDelayedFunctions(SourceFile &SF) {
249249
unsigned currentFunctionIdx = 0;
250-
unsigned currentSynthesizedDecl = SF.LastCheckedSynthesizedDecl;
251-
do {
252-
// Type check the body of each of the function in turn. Note that outside
253-
// functions must be visited before nested functions for type-checking to
254-
// work correctly.
255-
for (unsigned n = SF.DelayedFunctions.size(); currentFunctionIdx != n;
256-
++currentFunctionIdx) {
257-
auto *AFD = SF.DelayedFunctions[currentFunctionIdx];
258-
assert(!AFD->getDeclContext()->isLocalContext());
259-
(void)AFD->getTypecheckedBody();
260-
}
261250

262-
// Type check synthesized functions and their bodies.
263-
for (unsigned n = SF.SynthesizedDecls.size();
264-
currentSynthesizedDecl != n;
265-
++currentSynthesizedDecl) {
266-
auto decl = SF.SynthesizedDecls[currentSynthesizedDecl];
267-
TypeChecker::typeCheckDecl(decl);
268-
}
269-
270-
} while (currentFunctionIdx < SF.DelayedFunctions.size() ||
271-
currentSynthesizedDecl < SF.SynthesizedDecls.size());
251+
while (currentFunctionIdx < SF.DelayedFunctions.size()) {
252+
auto *AFD = SF.DelayedFunctions[currentFunctionIdx];
253+
assert(!AFD->getDeclContext()->isLocalContext());
254+
(void) AFD->getTypecheckedBody();
255+
++currentFunctionIdx;
256+
}
272257

273258
SF.DelayedFunctions.clear();
274259
}

test/Sema/enum_conformance_synthesis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func customHashable() {
6161
enum InvalidCustomHashable {
6262
case A, B
6363

64-
var hashValue: String { return "" } // expected-error {{invalid redeclaration of synthesized implementation for protocol requirement 'hashValue'}}
64+
var hashValue: String { return "" }
6565
}
6666
func ==(x: InvalidCustomHashable, y: InvalidCustomHashable) -> String {
6767
return ""

test/Sema/enum_raw_representable.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ enum Color : Int {
5656
return nil
5757
}
5858

59-
var rawValue: Double {
60-
// expected-error@-1 {{invalid redeclaration of synthesized implementation for protocol requirement 'rawValue'}}
59+
var rawValue: Double { // expected-note {{found this candidate}}
6160
return 1.0
6261
}
6362
}
6463

64+
func useRawValue(of color: Color) {
65+
_ = color.rawValue
66+
// expected-error@-1 {{ambiguous use of 'rawValue'}}
67+
}
68+
6569
var colorRaw: Color.RawValue = 7.5
6670
// expected-error@-1 {{cannot convert value of type 'Double' to specified type 'Color.RawValue' (aka 'Int')}}
6771

0 commit comments

Comments
 (0)