Skip to content

Commit 0d5420b

Browse files
committed
In CSDiag, diagnose callee inaccessibility before digging into args.
Fixes QoI rdar://problem/27982012
1 parent 4866403 commit 0d5420b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,6 +5278,10 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
52785278
argLabels))
52795279
return true;
52805280

5281+
// Diagnose some simple and common errors.
5282+
if (calleeInfo.diagnoseSimpleErrors(callExpr))
5283+
return true;
5284+
52815285
// Force recheck of the arg expression because we allowed unresolved types
52825286
// before, and that turned out not to help, and now we want any diagnoses
52835287
// from disallowing them.
@@ -5286,10 +5290,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
52865290
if (!argExpr)
52875291
return true; // already diagnosed.
52885292

5289-
// Diagnose some simple and common errors.
5290-
if (calleeInfo.diagnoseSimpleErrors(callExpr))
5291-
return true;
5292-
52935293
// A common error is to apply an operator that only has inout forms (e.g. +=)
52945294
// to non-lvalues (e.g. a local let). Produce a nice diagnostic for this
52955295
// case.

test/NameBinding/accessibility.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ _ = Foo() // expected-error {{'Foo' initializer is inaccessible due to 'internal
5454
// <rdar://problem/27982012> QoI: Poor diagnostic for inaccessible initializer
5555
struct rdar27982012 {
5656
var x: Int
57-
private init(_ x: Int) { self.x = x }
57+
private init(_ x: Int) { self.x = x } // expected-note {{'init' declared here}}
5858
}
5959

60-
_ = { rdar27982012($0.0) }((1, 2)) // expected-error {{type of expression is ambiguous without more context}}
60+
_ = { rdar27982012($0.0) }((1, 2)) // expected-error {{initializer is inaccessible due to 'private' protection level}}
6161

6262
// TESTABLE-NOT: :[[@LINE-1]]:{{[^:]+}}:
6363
_ = PrivateInit() // expected-error {{'PrivateInit' initializer is inaccessible due to 'private' protection level}}

0 commit comments

Comments
 (0)