Skip to content

Commit fd9a3c9

Browse files
authored
Merge pull request #75486 from xedin/fix-unsed-decl-in-generic-spec-diagnostic
[Diagnostics] Add a note to invalid generic function specialization d…
2 parents 8d9c5e1 + 794ccee commit fd9a3c9

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9370,6 +9370,7 @@ bool ConcreteTypeSpecialization::diagnoseAsError() {
93709370

93719371
bool GenericFunctionSpecialization::diagnoseAsError() {
93729372
emitDiagnostic(diag::cannot_explicitly_specialize_generic_function);
9373+
emitDiagnosticAt(Decl, diag::decl_declared_here, Decl);
93739374
return true;
93749375
}
93759376

test/Parse/generic_disambiguation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protocol Fungible {}
1919
func meta<T>(_ m: T.Type) {}
2020
func meta2<T>(_ m: T.Type, _ x: Int) {}
2121

22-
func generic<T>(_ x: T) {}
22+
func generic<T>(_ x: T) {} // expected-note {{'generic' declared here}}
2323

2424
var a, b, c, d : Int
2525

test/Sema/generic-arg-list.swift renamed to test/Sema/generic_specialization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension Int {
99
func baz() -> Int {}
1010
func baz(_ x: Int = 0) -> Int {}
1111

12-
func gen<T>() -> T {} // expected-note 2 {{in call to function 'gen()'}}
12+
func gen<T>() -> T {} // expected-note 2 {{in call to function 'gen()'}} expected-note 2 {{'gen()' declared here}}
1313
}
1414

1515
// https://github.com/swiftlang/swift/issues/74857
@@ -28,7 +28,7 @@ func test(i: Int) {
2828
}
2929

3030
extension Bool {
31-
func foo<T>() -> T {}
31+
func foo<T>() -> T {} // expected-note {{'foo()' declared here}}
3232
}
3333

3434
let _: () -> Bool = false.foo<Int> // expected-error {{cannot explicitly specialize a generic function}}

0 commit comments

Comments
 (0)