File tree Expand file tree Collapse file tree 4 files changed +18
-21
lines changed
validation-test/Sema/type_checker_perf/slow Expand file tree Collapse file tree 4 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -260,13 +260,6 @@ static bool isStandardInfixLogicalOperator(Constraint *disjunction) {
260260 return false ;
261261}
262262
263- static bool isOperatorNamed (Constraint *disjunction, StringRef name) {
264- auto *choice = disjunction->getNestedConstraints ()[0 ];
265- if (auto *decl = getOverloadChoiceDecl (choice))
266- return decl->isOperator () && decl->getBaseIdentifier ().is (name);
267- return false ;
268- }
269-
270263static bool isArithmeticOperator (ValueDecl *decl) {
271264 return decl->isOperator () && decl->getBaseIdentifier ().isArithmeticOperator ();
272265}
@@ -1022,19 +1015,6 @@ static void determineBestChoicesInContext(
10221015 optionals.size ());
10231016 types.push_back ({type,
10241017 /* fromLiteral=*/ true });
1025- } else if (literal.first ==
1026- cs.getASTContext ().getProtocol (
1027- KnownProtocolKind::ExpressibleByNilLiteral) &&
1028- literal.second .IsDirectRequirement ) {
1029- // `==` and `!=` operators have special overloads that accept `nil`
1030- // as `_OptionalNilComparisonType` which is preferred over a
1031- // generic form `(T?, T?)`.
1032- if (isOperatorNamed (disjunction, " ==" ) ||
1033- isOperatorNamed (disjunction, " !=" )) {
1034- auto nilComparisonTy =
1035- cs.getASTContext ().get_OptionalNilComparisonTypeType ();
1036- types.push_back ({nilComparisonTy, /* fromLiteral=*/ true });
1037- }
10381018 }
10391019 }
10401020
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+ // Make sure that the type-checker selects an `Equatable.==` instead of one from stdlib that takes _OptionalNilComparisonType
4+
5+ struct Value : Equatable , ExpressibleByNilLiteral {
6+ init ( nilLiteral: ( ) ) {
7+ }
8+ }
9+
10+ // CHECK-LABEL: sil hidden [ossa] @$s13rdar1580631514test1vyAA5ValueV_tF : $@convention(thin) (Value) -> ()
11+ // function_ref static Value.__derived_struct_equals(_:_:)
12+ // CHECK: [[EQUALS_REF:%.*]] = function_ref @$s13rdar1580631515ValueV23__derived_struct_equalsySbAC_ACtFZ
13+ // CHECK-NEXT: apply [[EQUALS_REF]](%0, {{.*}})
14+ func test( v: Value ) {
15+ _ = v == nil
16+ }
Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ public class U {
282282}
283283
284284func == ( l: S ? , r: S ? ) -> Bool {
285- if l == nil && r == nil { return true }
285+ if l == nil && r == nil { return true } // expected-warning {{function call causes an infinite recursion}}
286286 guard let l = l, let r = r else { return false }
287287 return l === r
288288}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ let i: Int? = 1
55let j : Int ?
66let k : Int ? = 2
77
8+ // expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}}
89let _ = [ i, j, k] . reduce ( 0 as Int ? ) {
910 $0 != nil && $1 != nil ? $0! + $1! : ( $0 != nil ? $0! : ( $1 != nil ? $1! : nil ) )
1011}
You can’t perform that action at this time.
0 commit comments