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) {
260
260
return false ;
261
261
}
262
262
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
-
270
263
static bool isArithmeticOperator (ValueDecl *decl) {
271
264
return decl->isOperator () && decl->getBaseIdentifier ().isArithmeticOperator ();
272
265
}
@@ -1022,19 +1015,6 @@ static void determineBestChoicesInContext(
1022
1015
optionals.size ());
1023
1016
types.push_back ({type,
1024
1017
/* 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
- }
1038
1018
}
1039
1019
}
1040
1020
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 {
282
282
}
283
283
284
284
func == ( 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}}
286
286
guard let l = l, let r = r else { return false }
287
287
return l === r
288
288
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ let i: Int? = 1
5
5
let j : Int ?
6
6
let k : Int ? = 2
7
7
8
+ // expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}}
8
9
let _ = [ i, j, k] . reduce ( 0 as Int ? ) {
9
10
$0 != nil && $1 != nil ? $0! + $1! : ( $0 != nil ? $0! : ( $1 != nil ? $1! : nil ) )
10
11
}
You can’t perform that action at this time.
0 commit comments