Program: 52928
Project: 52928
Buggy source:
@Override public BuildRule createBuildRule(TargetGraph targetGraph,BuildRuleParams params,final BuildRuleResolver resolver,CellPathResolver cellRoots,SwiftLibraryDescriptionArg args) throws NoSuchBuildTargetException {
  Optional<LinkerMapMode> flavoredLinkerMapMode=LinkerMapMode.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
  params=params.withBuildTarget(LinkerMapMode.removeLinkerMapModeFlavorInTarget(params.getBuildTarget(),flavoredLinkerMapMode));
  final BuildTarget buildTarget=params.getBuildTarget();
  Optional<Map.Entry<Flavor,CxxPlatform>> platform=cxxPlatformFlavorDomain.getFlavorAndValue(buildTarget);
  final ImmutableSortedSet<Flavor> buildFlavors=buildTarget.getFlavors();
  ImmutableSortedSet<BuildRule> filteredExtraDeps=params.getExtraDeps().get().stream().filter(input -> !input.getBuildTarget().getUnflavoredBuildTarget().equals(buildTarget.getUnflavoredBuildTarget())).collect(MoreCollectors.toImmutableSortedSet());
  params=params.withExtraDeps(filteredExtraDeps);
  if (!buildFlavors.contains(SWIFT_COMPANION_FLAVOR) && platform.isPresent()) {
    final CxxPlatform cxxPlatform=platform.get().getValue();
    Optional<SwiftPlatform> swiftPlatform=swiftPlatformFlavorDomain.getValue(buildTarget);
    if (!swiftPlatform.isPresent()) {
      throw new HumanReadableException("String_Node_Str",cxxPlatform);
    }
    Optional<Map.Entry<Flavor,Type>> type=LIBRARY_TYPE.getFlavorAndValue(buildTarget);
    if (!buildFlavors.contains(SWIFT_COMPILE_FLAVOR) && type.isPresent()) {
      Set<Flavor> flavors=Sets.newHashSet(params.getBuildTarget().getFlavors());
      flavors.remove(type.get().getKey());
      BuildTarget target=BuildTarget.builder(params.getBuildTarget().getUnflavoredBuildTarget()).addAllFlavors(flavors).build();
      if (flavoredLinkerMapMode.isPresent()) {
        target=target.withAppendedFlavors(flavoredLinkerMapMode.get().getFlavor());
      }
      BuildRuleParams typeParams=params.withBuildTarget(target);
switch (type.get().getValue()) {
case SHARED:
        return createSharedLibraryBuildRule(typeParams,resolver,target,swiftPlatform.get(),cxxPlatform,args.getSoname());
case STATIC:
case MACH_O_BUNDLE:
    }
    throw new RuntimeException("String_Node_Str");
  }
  ImmutableSet<SwiftCompile> swiftCompileRules=RichStream.from(params.getBuildDeps()).filter(SwiftLibrary.class).map(input -> input.requireSwiftCompileRule(cxxPlatform.getFlavor())).toImmutableSet();
  ImmutableSet<SwiftCompile> implicitSwiftCompileRules=RichStream.from(params.getBuildDeps()).filter(CxxLibrary.class).flatMap(input -> {
    BuildTarget companionTarget=input.getBuildTarget().withAppendedFlavors(SWIFT_COMPANION_FLAVOR);
    return RichStream.from(resolver.getRuleOptional(companionTarget).map(companion -> ((SwiftLibrary)companion).requireSwiftCompileRule(cxxPlatform.getFlavor())));
  }
).toImmutableSet();
  CxxPreprocessorInput inputs=CxxPreprocessorInput.concat(CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform,params.getBuildDeps()));
  PreprocessorFlags cxxDeps=PreprocessorFlags.of(Optional.empty(),CxxToolFlags.of(),RichStream.from(inputs.getIncludes()).filter(headers -> headers.getIncludeType() != CxxPreprocessables.IncludeType.SYSTEM).toImmutableSet(),inputs.getFrameworks());
  Preprocessor preprocessor=cxxPlatform.getCpp().resolve(resolver);
  SourcePathRuleFinder ruleFinder=new SourcePathRuleFinder(resolver);
  return new SwiftCompile(cxxPlatform,swiftBuckConfig,new BuildRuleParams(params.getBuildTarget(),() -> ImmutableSortedSet.<BuildRule>naturalOrder().addAll(swiftCompileRules).addAll(implicitSwiftCompileRules).addAll(cxxDeps.getDeps(ruleFinder)).addAll(preprocessor.getDeps(ruleFinder)).build(),ImmutableSortedSet::of,ImmutableSortedSet.of(),params.getProjectFilesystem()),swiftPlatform.get().getSwiftc(),args.getFrameworks(),args.getModuleName().orElse(buildTarget.getShortName()),BuildTargets.getGenPath(params.getProjectFilesystem(),buildTarget,"String_Node_Str"),args.getSrcs(),RichStream.from(args.getCompilerFlags()).map(f -> CxxDescriptionEnhancer.toStringWithMacrosArgs(buildTarget,cellRoots,resolver,cxxPlatform,f)).toImmutableList(),args.getEnableObjcInterop(),args.getBridgingHeader(),preprocessor,cxxDeps);
}
params=params.withBuildTarget(LinkerMapMode.restoreLinkerMapModeFlavorInTarget(params.getBuildTarget(),flavoredLinkerMapMode));
return new SwiftLibrary(params,resolver,ImmutableSet.of(),swiftPlatformFlavorDomain,args.getFrameworks(),args.getLibraries(),args.getSupportedPlatformsRegex(),args.getPreferredLinkage().orElse(NativeLinkable.Linkage.ANY));
}

Fixed version (ground truth):
@Override public BuildRule createBuildRule(TargetGraph targetGraph,BuildRuleParams params,final BuildRuleResolver resolver,CellPathResolver cellRoots,SwiftLibraryDescriptionArg args) throws NoSuchBuildTargetException {
  Optional<LinkerMapMode> flavoredLinkerMapMode=LinkerMapMode.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
  params=params.withBuildTarget(LinkerMapMode.removeLinkerMapModeFlavorInTarget(params.getBuildTarget(),flavoredLinkerMapMode));
  final BuildTarget buildTarget=params.getBuildTarget();
  Optional<Map.Entry<Flavor,CxxPlatform>> platform=cxxPlatformFlavorDomain.getFlavorAndValue(buildTarget);
  final ImmutableSortedSet<Flavor> buildFlavors=buildTarget.getFlavors();
  ImmutableSortedSet<BuildRule> filteredExtraDeps=params.getExtraDeps().get().stream().filter(input -> !input.getBuildTarget().getUnflavoredBuildTarget().equals(buildTarget.getUnflavoredBuildTarget())).collect(MoreCollectors.toImmutableSortedSet());
  params=params.withExtraDeps(filteredExtraDeps);
  if (!buildFlavors.contains(SWIFT_COMPANION_FLAVOR) && platform.isPresent()) {
    final CxxPlatform cxxPlatform=platform.get().getValue();
    Optional<SwiftPlatform> swiftPlatform=swiftPlatformFlavorDomain.getValue(buildTarget);
    if (!swiftPlatform.isPresent()) {
      throw new HumanReadableException("String_Node_Str",cxxPlatform);
    }
    Optional<Map.Entry<Flavor,Type>> type=LIBRARY_TYPE.getFlavorAndValue(buildTarget);
    if (!buildFlavors.contains(SWIFT_COMPILE_FLAVOR) && type.isPresent()) {
      Set<Flavor> flavors=Sets.newHashSet(params.getBuildTarget().getFlavors());
      flavors.remove(type.get().getKey());
      BuildTarget target=BuildTarget.builder(params.getBuildTarget().getUnflavoredBuildTarget()).addAllFlavors(flavors).build();
      if (flavoredLinkerMapMode.isPresent()) {
        target=target.withAppendedFlavors(flavoredLinkerMapMode.get().getFlavor());
      }
      BuildRuleParams typeParams=params.withBuildTarget(target);
switch (type.get().getValue()) {
case SHARED:
        return createSharedLibraryBuildRule(typeParams,resolver,target,swiftPlatform.get(),cxxPlatform,args.getSoname());
case STATIC:
case MACH_O_BUNDLE:
    }
    throw new RuntimeException("String_Node_Str");
  }
  ImmutableSet<SwiftCompile> swiftCompileRules=RichStream.from(params.getBuildDeps()).filter(SwiftLibrary.class).map(input -> input.requireSwiftCompileRule(cxxPlatform.getFlavor())).toImmutableSet();
  ImmutableSet<SwiftCompile> implicitSwiftCompileRules=RichStream.from(params.getBuildDeps()).filter(CxxLibrary.class).flatMap(input -> {
    BuildTarget companionTarget=input.getBuildTarget().withAppendedFlavors(SWIFT_COMPANION_FLAVOR);
    return RichStream.from(resolver.getRuleOptional(companionTarget).map(companion -> ((SwiftLibrary)companion).requireSwiftCompileRule(cxxPlatform.getFlavor())));
  }
).toImmutableSet();
  CxxPreprocessorInput inputs=CxxPreprocessorInput.concat(CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform,params.getBuildDeps()));
  PreprocessorFlags cxxDeps=PreprocessorFlags.of(Optional.empty(),CxxToolFlags.of(),RichStream.from(inputs.getIncludes()).filter(headers -> headers.getIncludeType() != CxxPreprocessables.IncludeType.SYSTEM).toImmutableSet(),inputs.getFrameworks());
  Preprocessor preprocessor=cxxPlatform.getCpp().resolve(resolver);
  SourcePathRuleFinder ruleFinder=new SourcePathRuleFinder(resolver);
  return new SwiftCompile(cxxPlatform,swiftBuckConfig,params.copyAppendingExtraDeps(() -> ImmutableSet.<BuildRule>builder().addAll(swiftCompileRules).addAll(implicitSwiftCompileRules).addAll(cxxDeps.getDeps(ruleFinder)).addAll(preprocessor.getDeps(ruleFinder)).build()),swiftPlatform.get().getSwiftc(),args.getFrameworks(),args.getModuleName().orElse(buildTarget.getShortName()),BuildTargets.getGenPath(params.getProjectFilesystem(),buildTarget,"String_Node_Str"),args.getSrcs(),RichStream.from(args.getCompilerFlags()).map(f -> CxxDescriptionEnhancer.toStringWithMacrosArgs(buildTarget,cellRoots,resolver,cxxPlatform,f)).toImmutableList(),args.getEnableObjcInterop(),args.getBridgingHeader(),preprocessor,cxxDeps);
}
params=params.withBuildTarget(LinkerMapMode.restoreLinkerMapModeFlavorInTarget(params.getBuildTarget(),flavoredLinkerMapMode));
return new SwiftLibrary(params,resolver,ImmutableSet.of(),swiftPlatformFlavorDomain,args.getFrameworks(),args.getLibraries(),args.getSupportedPlatformsRegex(),args.getPreferredLinkage().orElse(NativeLinkable.Linkage.ANY));
}