Skip to content

Commit f5e363d

Browse files
committed
[Sema] Suppress deprecation warnings in synthesized code
1 parent 2fe4235 commit f5e363d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,12 @@ void TypeChecker::diagnoseIfDeprecated(SourceRange ReferenceRange,
19371937
if (!Attr)
19381938
return;
19391939

1940+
// We don't want deprecated declarations to trigger warnings
1941+
// in synthesized code.
1942+
if (ReferenceRange.isInvalid() &&
1943+
isInsideImplicitFunction(ReferenceRange, ReferenceDC)) {
1944+
return;
1945+
}
19401946
// We match the behavior of clang to not report deprecation warnings
19411947
// inside declarations that are themselves deprecated on all deployment
19421948
// targets.

test/attr/attr_availability.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,3 +1028,16 @@ struct UnavailableAccessors {
10281028
other[alsoUnavailable: 0] += 1 // expected-error {{'subscript(alsoUnavailable:)' is unavailable: bad subscript!}} {{none}}
10291029
}
10301030
}
1031+
1032+
// Should produce no warnings.
1033+
enum SR8634_Enum: Int {
1034+
case a
1035+
@available(*, deprecated, message: "I must not be raised in synthesized code")
1036+
case b
1037+
case c
1038+
}
1039+
1040+
struct SR8634_Struct: Equatable {
1041+
@available(*, deprecated, message: "I must not be raised in synthesized code", renamed: "x")
1042+
let a: Int
1043+
}

0 commit comments

Comments
 (0)