Skip to content

Commit 3ba8325

Browse files
authored
Merge pull request swiftlang#18691 from xedin/fix-missing-conformance-diags-to-skip-all-operators
[Diagnostics] Don't try to diagnose missing conformance for any type …
2 parents 12d23a2 + 3c7d778 commit 3ba8325

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ bool MissingConformanceFailure::diagnose() {
144144
// If this is a static, initializer or operator call,
145145
// let's not try to diagnose it here, but refer to expression
146146
// diagnostics.
147-
if (isa<BinaryExpr>(applyExpr) || isa<TypeExpr>(anchor))
147+
if (isa<PrefixUnaryExpr>(applyExpr) || isa<PostfixUnaryExpr>(applyExpr) ||
148+
isa<BinaryExpr>(applyExpr) || isa<TypeExpr>(anchor))
148149
return false;
149150

150151
if (auto *fnType = ownerType->getAs<AnyFunctionType>()) {

test/Constraints/diagnostics.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ example21890157.property = "confusing" // expected-error {{value of optional ty
657657

658658
struct UnaryOp {}
659659

660-
_ = -UnaryOp() // expected-error {{argument type 'UnaryOp' does not conform to expected type 'SignedNumeric'}}
660+
_ = -UnaryOp() // expected-error {{unary operator '-' cannot be applied to an operand of type 'UnaryOp'}}
661+
// expected-note@-1 {{overloads for '-' exist with these partially matching parameter lists: (Float), (Double), (Float80)}}
661662

662663

663664
// <rdar://problem/23433271> Swift compiler segfault in failure diagnosis

validation-test/stdlib/FixedPointDiagnostics.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// RUN: %line-directive %t/main.swift -- %target-swift-frontend -typecheck -verify -swift-version 3 %t/main.swift
44

55
func testUnaryMinusInUnsigned() {
6-
var a: UInt8 = -(1) // expected-error {{argument type 'UInt8' does not conform to expected type 'SignedNumeric'}} expected-note * {{}} expected-warning * {{}}
6+
var a: UInt8 = -(1) // expected-error {{cannot convert value of type 'Int' to specified type 'UInt8'}} expected-note * {{}} expected-warning * {{}}
77

8-
var b: UInt16 = -(1) // expected-error {{argument type 'UInt16' does not conform to expected type 'SignedNumeric'}} expected-note * {{}} expected-warning * {{}}
8+
var b: UInt16 = -(1) // expected-error {{cannot convert value of type 'Int' to specified type 'UInt16'}} expected-note * {{}} expected-warning * {{}}
99

10-
var c: UInt32 = -(1) // expected-error {{argument type 'UInt32' does not conform to expected type 'SignedNumeric'}} expected-note * {{}} expected-warning * {{}}
10+
var c: UInt32 = -(1) // expected-error {{cannot convert value of type 'Int' to specified type 'UInt32'}} expected-note * {{}} expected-warning * {{}}
1111

12-
var d: UInt64 = -(1) // expected-error {{argument type 'UInt64' does not conform to expected type 'SignedNumeric'}} expected-note * {{}} expected-warning * {{}}
12+
var d: UInt64 = -(1) // expected-error {{cannot convert value of type 'Int' to specified type 'UInt64'}} expected-note * {{}} expected-warning * {{}}
1313
}
1414

1515
// Int and UInt are not identical to any fixed-size integer type

0 commit comments

Comments
 (0)