Skip to content

Commit 0b8ed95

Browse files
committed
[Diagnostics] Remove the warning for 'any Any' and 'any AnyObject'.
1 parent ea8171b commit 0b8ed95

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
@@ -4643,8 +4643,6 @@ ERROR(unchecked_not_inheritance_clause,none,
46434643
ERROR(unchecked_not_existential,none,
46444644
"'unchecked' attribute cannot apply to non-protocol type %0", (Type))
46454645

4646-
WARNING(unnecessary_any,none,
4647-
"'any' is redundant on type %0", (Type))
46484646
ERROR(any_not_existential,none,
46494647
"'any' has no effect on %select{concrete type|type parameter}0 %1",
46504648
(bool, Type))

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3783,13 +3783,6 @@ TypeResolver::resolveExistentialType(ExistentialTypeRepr *repr,
37833783
return constraintType;
37843784
}
37853785

3786-
// Warn about `any Any` and `any AnyObject`.
3787-
if (constraintType->isAny() || constraintType->isAnyObject()) {
3788-
diagnose(repr->getLoc(), diag::unnecessary_any,
3789-
constraintType)
3790-
.fixItRemove({anyStart, anyEnd});
3791-
}
3792-
37933786
return ExistentialType::get(constraintType);
37943787
}
37953788

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)