File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -397,8 +397,10 @@ class FindCapturedVars : public ASTWalker {
397
397
// doesn't require its type metadata.
398
398
if (auto declRef = dyn_cast<DeclRefExpr>(E))
399
399
return (!declRef->getDecl ()->isObjC ()
400
- && !E->getType ()->hasRetainablePointerRepresentation ()
401
- && !E->getType ()->is <AnyMetatypeType>());
400
+ && !E->getType ()->getLValueOrInOutObjectType ()
401
+ ->hasRetainablePointerRepresentation ()
402
+ && !E->getType ()->getLValueOrInOutObjectType ()
403
+ ->is <AnyMetatypeType>());
402
404
403
405
// Loading classes or metatypes doesn't require their metadata.
404
406
if (isa<LoadExpr>(E))
@@ -487,6 +489,11 @@ class FindCapturedVars : public ASTWalker {
487
489
if (isa<ClassMetatypeToObjectExpr>(E)
488
490
|| isa<ExistentialMetatypeToObjectExpr>(E))
489
491
return false ;
492
+
493
+ // Assigning an object doesn't require type metadata.
494
+ if (auto assignment = dyn_cast<AssignExpr>(E))
495
+ return !assignment->getSrc ()->getType ()
496
+ ->hasRetainablePointerRepresentation ();
490
497
491
498
return true ;
492
499
}
Original file line number Diff line number Diff line change @@ -212,6 +212,17 @@ extension AnimalContainer {
212
212
y. apexPredator = x
213
213
}
214
214
215
+ func doesntUseGenericParam5( y: T ) {
216
+ var x = y
217
+ x = y
218
+ _ = x
219
+ }
220
+ func doesntUseGenericParam6( y: T ? ) {
221
+ var x = y
222
+ x = y
223
+ _ = x
224
+ }
225
+
215
226
// expected-error@+1{{extension of a generic Objective-C class cannot access the class's generic parameters}}
216
227
func usesGenericParamA( _ x: T ) {
217
228
_ = T ( noise: x) // expected-note{{used here}}
You can’t perform that action at this time.
0 commit comments