Skip to content

Commit c48b593

Browse files
committed
[Diagnostics] Remove the warning for 'any Any' and 'any AnyObject'.
1 parent 6060de6 commit c48b593

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,8 +4648,6 @@ ERROR(unchecked_not_inheritance_clause,none,
46484648
ERROR(unchecked_not_existential,none,
46494649
"'unchecked' attribute cannot apply to non-protocol type %0", (Type))
46504650

4651-
WARNING(unnecessary_any,none,
4652-
"'any' is redundant on type %0", (Type))
46534651
ERROR(any_not_existential,none,
46544652
"'any' has no effect on %select{concrete type|type parameter}0 %1",
46554653
(bool, Type))

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,13 +3862,6 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
38623862
return constraintType;
38633863
}
38643864

3865-
// Warn about `any Any` and `any AnyObject`.
3866-
if (constraintType->isAny() || constraintType->isAnyObject()) {
3867-
diagnose(repr->getLoc(), diag::unnecessary_any,
3868-
constraintType)
3869-
.fixItRemove({anyStart, anyEnd});
3870-
}
3871-
38723865
return ExistentialType::get(constraintType);
38733866
}
38743867

test/type/explicit_existential.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ func testInvalidAny() {
149149
let _: any ((S) -> Void) = generic // expected-error{{'any' has no effect on concrete type '(S) -> Void'}}
150150
}
151151

152-
func testRedundantAnyWarning() {
153-
let _: any Any // expected-warning {{'any' is redundant on type 'Any'}}
154-
let _: any AnyObject // expected-warning {{'any' is redundant on type 'AnyObject'}}
152+
func anyAny() {
153+
let _: any Any
154+
let _: any AnyObject
155155
}
156156

157157
protocol P1 {}

0 commit comments

Comments
 (0)