File tree Expand file tree Collapse file tree 4 files changed +60
-12
lines changed Expand file tree Collapse file tree 4 files changed +60
-12
lines changed Original file line number Diff line number Diff line change @@ -8468,6 +8468,11 @@ Solution::convertBooleanTypeToBuiltinI1(Expr *expr,
8468
8468
8469
8469
auto type = cs.getType (expr);
8470
8470
8471
+ // We allow UnresolvedType <c $T for all $T, so we might end up here
8472
+ // in diagnostics. Just bail out.
8473
+ if (type->is <UnresolvedType>())
8474
+ return expr;
8475
+
8471
8476
// Look for the builtin name. If we don't have it, we need to call the
8472
8477
// general name via the witness table.
8473
8478
NameLookupOptions lookupOptions = defaultMemberLookupOptions;
Original file line number Diff line number Diff line change @@ -6532,18 +6532,18 @@ bool FailureDiagnosis::diagnoseClosureExpr(
6532
6532
}
6533
6533
6534
6534
expectedResultType = fnType->getResult ();
6535
- } else {
6536
- // Defend against type variables from our constraint system leaking into
6537
- // recursive constraints systems formed when checking the body of the
6538
- // closure. These typevars come into them when the body does name
6539
- // lookups against the parameter decls.
6540
- //
6541
- // Handle this by rewriting the arguments to UnresolvedType().
6542
- for ( auto VD : *CE-> getParameters ()) {
6543
- if (VD-> getType ()-> hasTypeVariable () || VD-> getType ()-> hasError ()) {
6544
- VD->setType (CS. getASTContext (). TheUnresolvedType );
6545
- VD->setInterfaceType (VD-> getType ()-> getInOutObjectType () );
6546
- }
6535
+ }
6536
+
6537
+ // Defend against type variables from our constraint system leaking into
6538
+ // recursive constraints systems formed when checking the body of the
6539
+ // closure. These typevars come into them when the body does name
6540
+ // lookups against the parameter decls.
6541
+ //
6542
+ // Handle this by rewriting the arguments to UnresolvedType().
6543
+ for ( auto VD : *CE-> getParameters ()) {
6544
+ if (VD-> getType ()-> hasTypeVariable () || VD->getType ()-> hasError ()) {
6545
+ VD->setType (CS. getASTContext (). TheUnresolvedType );
6546
+ VD-> setInterfaceType (VD-> getType ()-> getInOutObjectType ());
6547
6547
}
6548
6548
}
6549
6549
Original file line number Diff line number Diff line change @@ -690,3 +690,24 @@ func rdar37790062() {
690
690
_ = S ( { bzz ( C1 ( ) ) } , { bar ( ) } ) // expected-warning {{result of call to 'bzz' is unused}}
691
691
_ = S ( { faz ( C2 ( ) ) } , { bar ( ) } ) // expected-warning {{result of call to 'faz' is unused}}
692
692
}
693
+
694
+ // <rdar://problem/39489003>
695
+ typealias KeyedItem < K, T> = ( key: K , value: T )
696
+
697
+ protocol Node {
698
+ associatedtype T
699
+ associatedtype E
700
+ associatedtype K
701
+ var item : E { get set }
702
+ var children : [ ( key: K , value: T ) ] { get set }
703
+ }
704
+
705
+ extension Node {
706
+ func getChild( for key: K ) -> ( key: K , value: T ) {
707
+ return children. first ( where: { ( item: KeyedItem ) -> Bool in
708
+ return item. key == key
709
+ // expected-error@-1 {{binary operator '==' cannot be applied to operands of type '_' and 'Self.K'}}
710
+ // expected-note@-2 {{overloads for '==' exist with these partially matching parameter lists:}}
711
+ } )
712
+ }
713
+ }
Original file line number Diff line number Diff line change @@ -63,3 +63,25 @@ let ib: Bool! = false
63
63
let eb : Bool ? = . some( false )
64
64
let conditional = ib ? " Broken " : " Heart " // should infer Bool!
65
65
let conditional = eb ? " Broken " : " Heart " // expected-error {{value of optional type 'Bool?' not unwrapped; did you mean to use '!' or '?'?}}
66
+
67
+ // <rdar://problem/39586166> - crash when IfExpr has UnresolvedType in condition
68
+ struct Delegate {
69
+ var shellTasks : [ ShellTask ]
70
+ }
71
+
72
+ extension Array {
73
+ subscript( safe safe: Int ) -> Element ? { // expected-note {{found this candidate}}
74
+ get { }
75
+ set { }
76
+ }
77
+ }
78
+
79
+ struct ShellTask {
80
+ var commandLine : [ String ]
81
+ }
82
+
83
+ let delegate = Delegate ( shellTasks: [ ] )
84
+ _ = delegate. shellTasks [ safe: 0 ] ? . commandLine. compactMap ( { $0. asString. hasPrefix ( " " ) ? $0 : nil } ) . count ?? 0
85
+ // expected-error@-1 {{ambiguous reference to member 'subscript'}}
86
+
87
+ // FIXME: Horrible diagnostic, but at least we no longer crash
You can’t perform that action at this time.
0 commit comments