Skip to content

Commit 699b165

Browse files
authored
Merge pull request #69999 from tshortli/deprecated-renamed-fixit-crash
2 parents f52769a + a92c9c0 commit 699b165

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,12 +2420,12 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
24202420
}
24212421
}
24222422
}
2423-
// Function names are the same(including context if applicable), so
2423+
// Function names are the same (including context if applicable), so
24242424
// renaming fix-it doesn't need do be produced.
2425+
auto calledValue = CE->getCalledValue(/*skipFunctionConversions=*/true);
24252426
if ((parsed.ContextName.empty() ||
24262427
parsed.ContextName == callContextName) &&
2427-
CE->getCalledValue(/*skipFunctionConversions=*/true)
2428-
->getBaseName() == parsed.BaseName) {
2428+
calledValue && calledValue->getBaseName() == parsed.BaseName) {
24292429
shouldEmitRenameFixit = false;
24302430
}
24312431
}

test/attr/attr_availability.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -module-name Test
22

33
@available(*, unavailable)
44
func unavailable_func() {}
@@ -204,6 +204,9 @@ func use_deprecated_with_renamed() {
204204
deprecated_func_with_renamed() // expected-warning{{'deprecated_func_with_renamed()' is deprecated: renamed to 'blarg'}}
205205
// expected-note@-1{{use 'blarg'}}{{3-31=blarg}}
206206

207+
Test.deprecated_func_with_renamed() // expected-warning{{'deprecated_func_with_renamed()' is deprecated: renamed to 'blarg'}}
208+
// expected-note@-1{{use 'blarg' instead}}
209+
207210
deprecated_func_with_message_renamed() //expected-warning{{'deprecated_func_with_message_renamed()' is deprecated: blarg is your friend}}
208211
// expected-note@-1{{use 'blarg'}}{{3-39=blarg}}
209212

0 commit comments

Comments
 (0)