Skip to content

Commit 6142a44

Browse files
committed
making improvements requested in code review
1 parent d68eb6b commit 6142a44

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,7 @@ NOTE(single_confusable_character,none,
10581058
ERROR(cannot_find_type_in_scope,none,
10591059
"cannot find type %0 in scope", (DeclNameRef))
10601060
ERROR(cannot_find_type_in_cast_expression,none,
1061-
"type-casting operator expects a type on its right-hand side (got: %0)", (const ValueDecl *))
1062-
NOTE(note_declared_here,none,
1063-
"declared here",())
1061+
"type-casting operator expects a type on its right-hand side (got: %kind0)", (const ValueDecl *))
10641062
ERROR(cannot_find_type_in_scope_did_you_mean,none,
10651063
"cannot find type %0 in scope; did you mean to use '%1'?", (DeclNameRef, StringRef))
10661064
NOTE(note_typo_candidate_implicit_member,none,

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ static Type diagnoseUnknownType(TypeResolution resolution,
13911391
auto first = lookupResult.front().getValueDecl();
13921392
diags.diagnose(L, diag::cannot_find_type_in_cast_expression, first)
13931393
.highlight(R);
1394-
diags.diagnose(first->getNameLoc(), diag::note_declared_here);
1394+
diags.diagnose(first, diag::decl_declared_here, first);
13951395
return ErrorType::get(ctx);
13961396
}
13971397
}

test/Constraints/casts.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,11 @@ do {
746746
do {
747747
func x(a: Any) {
748748
_ = a is a
749-
// expected-error@-1 {{type-casting operator expects a type on its right-hand side (got: 'a')}}
750-
// expected-note@-3 {{declared here}}
749+
// expected-error@-1 {{type-casting operator expects a type on its right-hand side (got: parameter 'a')}}
750+
// expected-note@-3 {{'a' declared here}}
751751
_ = a as a
752-
// expected-error@-1 {{type-casting operator expects a type on its right-hand side (got: 'a')}}
753-
// expected-note@-6 {{declared here}}
752+
// expected-error@-1 {{type-casting operator expects a type on its right-hand side (got: parameter 'a')}}
753+
// expected-note@-6 {{'a' declared here}}
754754
_ = a is Issue68825 // expected-error {{cannot find type 'Issue68825' in scope}}
755755
_ = a is String // OK
756756
}

test/Parse/omit_return.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,8 @@ class CImplicitIdentityExpr { func gimme() -> CImplicitIdentityExpr { self } }
17101710
class CImplicitDotSelfExpr { func gimme() -> CImplicitDotSelfExpr { self.self } }
17111711

17121712
func badIs<T>(_ value: Any, anInstanceOf type: T.Type) -> Bool {
1713-
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: 'type')}}
1714-
// expected-note@-2 {{declared here}}
1713+
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: parameter 'type')}}
1714+
// expected-note@-2 {{'type' declared here}}
17151715
}
17161716

17171717

test/Parse/omit_return_fail.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %target-swift-frontend %s -typecheck -verify
22

33
func badIs<T>(_ value: Any, anInstanceOf type: T.Type) -> Bool {
4-
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: 'type')}}
5-
// expected-note@-2 {{declared here}}
4+
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: parameter 'type')}}
5+
// expected-note@-2 {{'type' declared here}}
66
}
77

88
func foo() -> Int {
@@ -11,8 +11,8 @@ func foo() -> Int {
1111

1212
func badIs_ifdecl<T>(_ value: Any, anInstanceOf type: T.Type) -> Bool {
1313
#if true
14-
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: 'type')}}
15-
// expected-note@-3 {{declared here}}
14+
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: parameter 'type')}}
15+
// expected-note@-3 {{'type' declared here}}
1616
#endif
1717
}
1818

test/Parse/omit_return_ifdecl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,8 +2432,8 @@ class CImplicitDotSelfExpr { func gimme() -> CImplicitDotSelfExpr { self.self }
24322432

24332433
func badIs<T>(_ value: Any, anInstanceOf type: T.Type) -> Bool {
24342434
#if true
2435-
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: 'type')}}
2436-
// expected-note@-3 {{declared here}}
2435+
value is type // expected-error {{type-casting operator expects a type on its right-hand side (got: parameter 'type')}}
2436+
// expected-note@-3 {{'type' declared here}}
24372437
#endif
24382438
}
24392439

0 commit comments

Comments
 (0)