File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -6310,12 +6310,23 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
6310
6310
auto requirement = signature->getRequirements ()[req->getIndex ()];
6311
6311
6312
6312
auto *memberLoc = getConstraintLocator (anchor, path.front ());
6313
- auto *memberRef = findResolvedMemberRef (memberLoc);
6313
+ auto overload = findSelectedOverloadFor (memberLoc);
6314
6314
6315
6315
// To figure out what is going on here we need to wait until
6316
6316
// member overload is set in the constraint system.
6317
- if (!memberRef)
6317
+ if (!overload) {
6318
+ // If it's not allowed to generate new constraints
6319
+ // there is no way to control re-activation, so this
6320
+ // check has to fail.
6321
+ if (!flags.contains (TMF_GenerateConstraints))
6322
+ return SolutionKind::Error;
6323
+
6318
6324
return formUnsolved (/* activate=*/ true );
6325
+ }
6326
+
6327
+ auto *memberRef = overload->choice .getDeclOrNull ();
6328
+ if (!memberRef)
6329
+ return SolutionKind::Error;
6319
6330
6320
6331
// If this is a `Self` conformance requirement from a static member
6321
6332
// reference on a protocol metatype, let's produce a tailored diagnostic.
Original file line number Diff line number Diff line change
1
+ // RUN: not %target-swift-frontend %s -typecheck
2
+
3
+ struct Result {
4
+ }
5
+
6
+ func wrapper( _: Result ? ) {
7
+ }
8
+
9
+ extension Optional where Wrapped == Result {
10
+ static func test( _: String ) -> Result { Result ( ) }
11
+ }
12
+
13
+ extension Result {
14
+ static func test< R: RangeExpression > ( _: R ) -> Result where R. Bound == Int {
15
+ Result ( )
16
+ }
17
+ }
18
+
19
+ protocol P { }
20
+
21
+ struct Value : P {
22
+ init ( ) { }
23
+ init < R> ( _: R ) { }
24
+ }
25
+
26
+ func example< T1: P , T2: P > ( _: T1 , _: T2 ) {
27
+ }
28
+
29
+ example ( Value ( ) , Value ( wrapper ( . test( 0 ) ) ) )
You can’t perform that action at this time.
0 commit comments