File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2364,7 +2364,12 @@ ConstraintSystem::simplifyConstructionConstraint(
2364
2364
NameLookupOptions lookupOptions = defaultConstructorLookupOptions;
2365
2365
if (isa<AbstractFunctionDecl>(useDC))
2366
2366
lookupOptions |= NameLookupFlags::KnownPrivate;
2367
- auto ctors = TC.lookupConstructors (useDC, valueType, lookupOptions);
2367
+
2368
+ auto instanceType = valueType;
2369
+ if (auto *selfType = instanceType->getAs <DynamicSelfType>())
2370
+ instanceType = selfType->getSelfType ();
2371
+
2372
+ auto ctors = TC.lookupConstructors (useDC, instanceType, lookupOptions);
2368
2373
if (!ctors)
2369
2374
return SolutionKind::Error;
2370
2375
Original file line number Diff line number Diff line change @@ -91,6 +91,13 @@ class C1 {
91
91
92
92
return Self ( ) // expected-error{{use of unresolved identifier 'Self'}} expected-note {{did you mean 'self'?}}
93
93
}
94
+
95
+ // This used to crash because metatype construction went down a
96
+ // different code path that didn't handle DynamicSelfType.
97
+ class func badFactory( ) -> Self {
98
+ return self ( int: 0 )
99
+ // expected-error@-1 {{initializing from a metatype value must reference 'init' explicitly}}
100
+ }
94
101
}
95
102
96
103
// ----------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments