Skip to content

Commit 7a8a50a

Browse files
committed
Swift SIL: add Type.hasValidSignatureForEmbedded
1 parent f7d81f7 commit 7a8a50a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

SwiftCompilerSources/Sources/SIL/Type.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
110110
bridged.getFunctionTypeWithNoEscape(withNoEscape).type
111111
}
112112

113+
/// True if a function with this type can be code-generated in Embedded Swift.
114+
/// These are basically all non-generic functions. But also certain generic functions are supported:
115+
/// Generic function arguments which have a class-bound type are valid in Embedded Swift, because for
116+
/// such arguments, no metadata is needed, except the isa-pointer of the class.
117+
public var hasValidSignatureForEmbedded: Bool {
118+
let genericSignature = invocationGenericSignatureOfFunction
119+
for genParam in genericSignature.genericParameters {
120+
let mappedParam = genericSignature.mapTypeIntoContext(genParam)
121+
if mappedParam.isArchetype && !mappedParam.archetypeRequiresClass {
122+
return false
123+
}
124+
}
125+
return true
126+
}
127+
113128
//===--------------------------------------------------------------------===//
114129
// Aggregates
115130
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)