Skip to content

Commit eb23607

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents c2a0359 + 7076671 commit eb23607

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
@@ -5148,39 +5148,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
51485148
}
51495149
}
51505150

5151-
// If we have an argument list (i.e., a scalar, or a non-zero-element tuple)
5152-
// then diagnose with some specificity about the arguments.
51535151
bool isInitializer = isa<TypeExpr>(fnExpr);
5154-
if (!fnType->is<AnyMetatypeType>() &&
5155-
((isa<TupleExpr>(argExpr) &&
5156-
cast<TupleExpr>(argExpr)->getNumElements() == 1) ||
5157-
(isa<ParenExpr>(argExpr) &&
5158-
!isa<LoadExpr>(cast<ParenExpr>(argExpr)->getSubExpr())))) {
5159-
if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
5160-
if (ctorRef->getName().isSimpleName(DeclBaseName::createConstructor())) {
5161-
// Diagnose 'super.init', which can only appear inside another
5162-
// initializer, specially.
5163-
if (isa<SuperRefExpr>(ctorRef->getBase())) {
5164-
diagnose(fnExpr->getLoc(),
5165-
diag::super_initializer_not_in_initializer);
5166-
calleeInfo.suggestPotentialOverloads(fnExpr->getLoc());
5167-
return true;
5168-
}
5169-
5170-
// Suggest inserting a call to 'type(of:)' to construct another object
5171-
// of the same dynamic type.
5172-
SourceRange fixItRng = ctorRef->getNameLoc().getSourceRange();
5173-
5174-
// Surround the caller in `type(of:)`.
5175-
diagnose(fnExpr->getLoc(), diag::init_not_instance_member)
5176-
.fixItInsert(fixItRng.Start, "type(of: ")
5177-
.fixItInsertAfter(fixItRng.End, ")");
5178-
calleeInfo.suggestPotentialOverloads(fnExpr->getLoc());
5179-
return true;
5180-
}
5181-
}
5182-
}
5183-
51845152
if (isa<TupleExpr>(argExpr) &&
51855153
cast<TupleExpr>(argExpr)->getNumElements() == 0) {
51865154
// 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)