Skip to content

Commit

Permalink
allow instantiation of _nil actuals for nilable class formals
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Rezaii <[email protected]>
  • Loading branch information
arezaii committed Sep 24, 2024
1 parent ec610d3 commit 7c56cc8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/lib/resolution/can-pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,18 @@ CanPassResult CanPassResult::canInstantiate(Context* context,
return instantiate();
}

// TODO: Should we move this to the section below and have it call canPassSubtypeOrBorrowing?
// TODO: There may be cases for nilType that are not covered
// this is to allow instantiating 'class?' type with nil
if (auto cls = formalT->toClassType()) {
if (auto mt = cls->manageableType()) {
if (mt->isAnyClassType()) {
if (cls->decorator().isNilable() && actualT->isNilType())
return instantiate();
}
}
}

// TODO: check for constrained generic types

if (auto actualCt = actualT->toClassType()) {
Expand Down

0 comments on commit 7c56cc8

Please sign in to comment.