File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -197,10 +197,22 @@ class TypeVariableRefFinder : public ASTWalker {
197
197
return ;
198
198
}
199
199
200
+ // Don't walk into the opaque archetypes because they are not
201
+ // transparent in this context - `some P` could reference a
202
+ // type variables as substitutions which are visible only to
203
+ // the outer context.
204
+ if (type->is <OpaqueTypeArchetypeType>())
205
+ return ;
206
+
200
207
if (type->hasTypeVariable ()) {
201
208
SmallPtrSet<TypeVariableType *, 4 > typeVars;
202
209
type->getTypeVariables (typeVars);
203
- ReferencedVars.insert (typeVars.begin (), typeVars.end ());
210
+
211
+ // Some of the type variables could be non-representative, so
212
+ // we need to recurse into `inferTypeVariables` to property
213
+ // handle them.
214
+ for (auto *typeVar : typeVars)
215
+ inferVariables (typeVar);
204
216
}
205
217
}
206
218
};
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ struct Description : Hashable {
4
+ let name : String
5
+ let id : Int
6
+ }
7
+
8
+ struct Value {
9
+ let ID : Int ?
10
+ }
11
+
12
+ func test( allValues: [ Value ] ) {
13
+ // Type for `return nil` cannot be inferred at the moment because there is no join for result expressions.
14
+ let owners = Set ( allValues. compactMap { // expected-error {{generic parameter 'Element' could not be inferred}}
15
+ // expected-note@-1 {{explicitly specify the generic arguments to fix this issue}}
16
+ guard let id = $0. ID else { return nil }
17
+ return Description ( name: " " , id: id)
18
+ } )
19
+ }
You can’t perform that action at this time.
0 commit comments