Skip to content

Commit 921d1d7

Browse files
committed
Remove dead code: All the correct instances of these diagnostics are now handled by AllowTypeOrInstanceMemberFailure, leaving incorrect handling for init's with inout args, because the arg contains a LoadExpr.
1 parent facd80f commit 921d1d7

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5262,39 +5262,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
52625262
}
52635263
}
52645264

5265-
// If we have an argument list (i.e., a scalar, or a non-zero-element tuple)
5266-
// then diagnose with some specificity about the arguments.
52675265
bool isInitializer = isa<TypeExpr>(fnExpr);
5268-
if (!fnType->is<AnyMetatypeType>() &&
5269-
((isa<TupleExpr>(argExpr) &&
5270-
cast<TupleExpr>(argExpr)->getNumElements() == 1) ||
5271-
(isa<ParenExpr>(argExpr) &&
5272-
!isa<LoadExpr>(cast<ParenExpr>(argExpr)->getSubExpr())))) {
5273-
if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
5274-
if (ctorRef->getName().isSimpleName(DeclBaseName::createConstructor())) {
5275-
// Diagnose 'super.init', which can only appear inside another
5276-
// initializer, specially.
5277-
if (isa<SuperRefExpr>(ctorRef->getBase())) {
5278-
diagnose(fnExpr->getLoc(),
5279-
diag::super_initializer_not_in_initializer);
5280-
calleeInfo.suggestPotentialOverloads(fnExpr->getLoc());
5281-
return true;
5282-
}
5283-
5284-
// Suggest inserting a call to 'type(of:)' to construct another object
5285-
// of the same dynamic type.
5286-
SourceRange fixItRng = ctorRef->getNameLoc().getSourceRange();
5287-
5288-
// Surround the caller in `type(of:)`.
5289-
diagnose(fnExpr->getLoc(), diag::init_not_instance_member)
5290-
.fixItInsert(fixItRng.Start, "type(of: ")
5291-
.fixItInsertAfter(fixItRng.End, ")");
5292-
calleeInfo.suggestPotentialOverloads(fnExpr->getLoc());
5293-
return true;
5294-
}
5295-
}
5296-
}
5297-
52985266
if (isa<TupleExpr>(argExpr) &&
52995267
cast<TupleExpr>(argExpr)->getNumElements() == 0) {
53005268
// Emit diagnostics that say "no arguments".

test/expr/postfix/dot/init_ref_delegation.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,13 @@ struct MultipleMemberAccesses {
547547
y2.x2.init() // expected-error {{'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type}} {{5-5=type(of: }} {{10-10=)}}
548548
}
549549
}
550+
551+
func sr10670() {
552+
struct S {
553+
init(_ x: inout String) {}
554+
init(_ x: inout [Int]) {}
555+
}
556+
var a = 0
557+
S.init(&a) // expected-error {{cannot invoke 'S.Type.init' with an argument list of type '(inout Int)'}}
558+
// expected-note@-1 {{overloads for 'S.Type.init' exist with these partially matching parameter lists: (inout String), (inout [Int])}}
559+
}

0 commit comments

Comments
 (0)