Skip to content

Commit 418abf5

Browse files
authored
Merge pull request #18259 from DougGregor/skip-finalize-other-decls-on-error
2 parents 26790d0 + 40919f9 commit 418abf5

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/Sema/TypeChecker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ static void typeCheckFunctionsAndExternalDecls(SourceFile &SF, TypeChecker &TC)
572572
if (decl->isInvalid())
573573
continue;
574574

575+
// If we've already encountered an error, don't finalize declarations
576+
// from other source files.
577+
if (TC.Context.hadError() &&
578+
decl->getDeclContext()->getParentSourceFile() != &SF)
579+
continue;
580+
575581
TC.finalizeDecl(decl);
576582
}
577583

test/Sema/Inputs/availability_multi_other.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,17 @@ class OtherIntroduced10_51 {
3232
return OtherIntroduced10_52()
3333
}
3434

35-
func takes10_52(o: OtherIntroduced10_52) {
35+
func takes10_52(o: OtherIntroduced10_52) {
3636
}
37-
// expected-error@-2{{'OtherIntroduced10_52' is only available on OS X 10.52 or newer}}
38-
// expected-note@-3{{add @available attribute to enclosing instance method}}
39-
37+
4038
@available(OSX, introduced: 10.52)
4139
func takes10_52Introduced10_52(o: OtherIntroduced10_52) {
4240
}
4341

44-
// expected-error@+1{{'OtherIntroduced10_52' is only available on OS X 10.52 or newer}}
4542
var propOf10_52: OtherIntroduced10_52 =
46-
OtherIntroduced10_52()
43+
44+
45+
OtherIntroduced10_52() // We don't expect an error here because the initializer is not type checked (by design).
4746

4847
@available(OSX, introduced: 10.52)
4948
var propOf10_52Introduced10_52: OtherIntroduced10_52 = OtherIntroduced10_52()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
struct External {
2-
var member: Something // expected-error{{use of undeclared type 'Something'}}
2+
var member: Something
33
}
44

55
struct OtherExternal {}

0 commit comments

Comments
 (0)