Skip to content

Commit d4192d5

Browse files
committed
SwiftCompilerSources: add Type.subst(with substitutionMap: SubstitutionMap) -> Type API
1 parent b0dd1ab commit d4192d5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

SwiftCompilerSources/Sources/AST/Type.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public struct Type: CustomStringConvertible, NoReflectionChildren {
3737
public var isEscapable: Bool { bridged.isEscapable() }
3838
public var isNoEscape: Bool { bridged.isNoEscape() }
3939
public var isInteger: Bool { bridged.isInteger() }
40+
41+
public func subst(with substitutionMap: SubstitutionMap) -> Type {
42+
return Type(bridged: bridged.subst(substitutionMap.bridged))
43+
}
4044
}
4145

4246
/// A Type that is statically known to be canonical.
@@ -55,4 +59,8 @@ public struct CanonicalType: CustomStringConvertible, NoReflectionChildren {
5559
public var isEscapable: Bool { type.isEscapable }
5660
public var isNoEscape: Bool { type.isNoEscape }
5761
public var isInteger: Bool { type.isInteger }
62+
63+
public func subst(with substitutionMap: SubstitutionMap) -> CanonicalType {
64+
return type.subst(with: substitutionMap).canonical
65+
}
5866
}

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,7 @@ struct BridgedASTType {
20142014
BRIDGED_INLINE bool isEscapable() const;
20152015
BRIDGED_INLINE bool isNoEscape() const;
20162016
BRIDGED_INLINE bool isInteger() const;
2017+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType subst(BridgedSubstitutionMap substMap) const;
20172018
};
20182019

20192020
class BridgedCanType {

include/swift/AST/ASTBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ bool BridgedASTType::isInteger() const {
126126
return unbridged()->is<swift::IntegerType>();
127127
}
128128

129+
BridgedASTType BridgedASTType::subst(BridgedSubstitutionMap substMap) const {
130+
return {unbridged().subst(substMap.unbridged()).getPointer()};
131+
}
132+
129133
//===----------------------------------------------------------------------===//
130134
// MARK: BridgedCanType
131135
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)