Skip to content

Commit e1e6f0e

Browse files
committed
SIL: Refactor type lowering computation of the effective generic signature
This also fixes a long-standing bug with default argument expressions capturing generic parameters.
1 parent 67c6682 commit e1e6f0e

File tree

5 files changed

+142
-135
lines changed

5 files changed

+142
-135
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -844,10 +844,13 @@ class TypeConverter {
844844
/// Returns the formal type, lowered AST type, and SILFunctionType
845845
/// for a constant reference.
846846
const SILConstantInfo &getConstantInfo(SILDeclRef constant);
847-
847+
848+
/// Get the generic environment for a constant.
849+
GenericSignature *getConstantGenericSignature(SILDeclRef constant);
850+
848851
/// Get the generic environment for a constant.
849852
GenericEnvironment *getConstantGenericEnvironment(SILDeclRef constant);
850-
853+
851854
/// Returns the SIL type of a constant reference.
852855
SILType getConstantType(SILDeclRef constant) {
853856
return getConstantInfo(constant).getSILType();
@@ -944,17 +947,6 @@ class TypeConverter {
944947
SILType getSubstitutedStorageType(AbstractStorageDecl *value,
945948
Type lvalueType);
946949

947-
/// Retrieve the set of archetypes closed over by the given function.
948-
GenericEnvironment *getEffectiveGenericEnvironment(AnyFunctionRef fn,
949-
CaptureInfo captureInfo);
950-
951-
/// Retrieve the set of generic parameters closed over by the given function.
952-
CanGenericSignature getEffectiveGenericSignature(AnyFunctionRef fn,
953-
CaptureInfo captureInfo);
954-
955-
/// Retrieve the set of generic parameters closed over by the context.
956-
CanGenericSignature getEffectiveGenericSignature(DeclContext *dc);
957-
958950
/// Push a generic function context. See GenericContextScope for an RAII
959951
/// interface to this function.
960952
///

lib/AST/ASTDumper.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,17 @@ namespace {
988988
if (P->isAutoClosure())
989989
OS << " autoclosure";
990990

991-
if (P->getDefaultArgumentKind() != DefaultArgumentKind::None)
991+
if (P->getDefaultArgumentKind() != DefaultArgumentKind::None) {
992992
printField("default_arg",
993993
getDefaultArgumentKindString(P->getDefaultArgumentKind()));
994+
}
995+
996+
if (P->getDefaultValue() &&
997+
!P->getDefaultArgumentCaptureInfo().isTrivial()) {
998+
OS << " ";
999+
P->getDefaultArgumentCaptureInfo().print(
1000+
PrintWithColorRAII(OS, CapturesColor).getOS());
1001+
}
9941002

9951003
if (auto init = P->getDefaultValue()) {
9961004
OS << " expression=\n";

0 commit comments

Comments
 (0)