@@ -546,7 +546,7 @@ public final class PackageBuilder {
546546
547547 let path = packagePath. appending ( relativeSubPath)
548548 // Make sure the target is inside the package root.
549- guard path. contains ( packagePath) else {
549+ guard path. isDescendantOfOrEqual ( to : packagePath) else {
550550 throw ModuleError . targetOutsidePackage ( package : self . manifest. name, target: target. name)
551551 }
552552 if fileSystem. isDirectory ( path) {
@@ -797,7 +797,7 @@ public final class PackageBuilder {
797797 // Compute the path to public headers directory.
798798 let publicHeaderComponent = manifestTarget. publicHeadersPath ?? ClangTarget . defaultPublicHeadersComponent
799799 let publicHeadersPath = potentialModule. path. appending ( try RelativePath ( validating: publicHeaderComponent) )
800- guard publicHeadersPath. contains ( potentialModule. path) else {
800+ guard publicHeadersPath. isDescendantOfOrEqual ( to : potentialModule. path) else {
801801 throw ModuleError . invalidPublicHeadersDirectory ( potentialModule. name)
802802 }
803803
@@ -937,7 +937,7 @@ public final class PackageBuilder {
937937
938938 // Ensure that the search path is contained within the package.
939939 let subpath = try RelativePath ( validating: setting. value [ 0 ] )
940- guard targetRoot. appending ( subpath) . contains ( packagePath) else {
940+ guard targetRoot. appending ( subpath) . isDescendantOfOrEqual ( to : packagePath) else {
941941 throw ModuleError . invalidHeaderSearchPath ( subpath. pathString)
942942 }
943943
@@ -1127,12 +1127,12 @@ public final class PackageBuilder {
11271127 // If the target root's parent directory is inside the package, start
11281128 // search there. Otherwise, we start search from the target root.
11291129 var searchPath = target. sources. root. parentDirectory
1130- if !searchPath. contains ( packagePath) {
1130+ if !searchPath. isDescendantOfOrEqual ( to : packagePath) {
11311131 searchPath = target. sources. root
11321132 }
11331133
11341134 while true {
1135- assert ( searchPath. contains ( packagePath) , " search path \( searchPath) is outside the package \( packagePath) " )
1135+ assert ( searchPath. isDescendantOfOrEqual ( to : packagePath) , " search path \( searchPath) is outside the package \( packagePath) " )
11361136 // If we have already searched this path, skip.
11371137 if !pathsSearched. contains ( searchPath) {
11381138 SwiftTarget . testManifestNames. forEach { name in
0 commit comments