File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -1233,16 +1233,23 @@ CanType TypeBase::getCanonicalType(GenericSignature *sig) {
1233
1233
}
1234
1234
1235
1235
TypeBase *TypeBase::reconstituteSugar (bool Recursive) {
1236
- auto Func = [](Type Ty) -> Type {
1236
+ auto Func = [Recursive ](Type Ty) -> Type {
1237
1237
if (auto boundGeneric = dyn_cast<BoundGenericType>(Ty.getPointer ())) {
1238
+
1239
+ auto getGenericArg = [&](unsigned i) -> Type {
1240
+ auto arg = boundGeneric->getGenericArgs ()[i];
1241
+ if (Recursive)
1242
+ arg = arg->reconstituteSugar (Recursive);
1243
+ return arg;
1244
+ };
1245
+
1238
1246
auto &ctx = boundGeneric->getASTContext ();
1239
1247
if (boundGeneric->getDecl () == ctx.getArrayDecl ())
1240
- return ArraySliceType::get (boundGeneric-> getGenericArgs ()[ 0 ] );
1248
+ return ArraySliceType::get (getGenericArg ( 0 ) );
1241
1249
if (boundGeneric->getDecl () == ctx.getDictionaryDecl ())
1242
- return DictionaryType::get (boundGeneric->getGenericArgs ()[0 ],
1243
- boundGeneric->getGenericArgs ()[1 ]);
1250
+ return DictionaryType::get (getGenericArg (0 ), getGenericArg (1 ));
1244
1251
if (boundGeneric->getDecl () == ctx.getOptionalDecl ())
1245
- return OptionalType::get (boundGeneric-> getGenericArgs ()[ 0 ] );
1252
+ return OptionalType::get (getGenericArg ( 0 ) );
1246
1253
}
1247
1254
return Ty;
1248
1255
};
Original file line number Diff line number Diff line change @@ -261,6 +261,8 @@ struct FooStruct {
261
261
}
262
262
263
263
let e : BarStruct ? = BarStruct ( )
264
+
265
+ func f( ) -> Optional < Optional < Int > > { return 29 }
264
266
}
265
267
266
268
struct BarStruct {
@@ -290,6 +292,9 @@ let _: Int = thing?.e?.a() // expected-error {{value of optional type 'Int?' mus
290
292
let _: Int ? = thing? . e? . b // expected-error {{value of optional type 'Int??' must be unwrapped to a value of type 'Int?'}}
291
293
// expected-note@-1{{coalesce}}
292
294
// expected-note@-2{{force-unwrap}}
295
+ let _: Int ? = thing? . f ( ) // expected-error {{value of optional type 'Int??' must be unwrapped to a value of type 'Int?'}}
296
+ // expected-note@-1{{coalesce}}
297
+ // expected-note@-2{{force-unwrap}}
293
298
294
299
// SR-9851 - https://bugs.swift.org/browse/SR-9851
295
300
func coalesceWithParensRootExprFix( ) {
You can’t perform that action at this time.
0 commit comments