Skip to content

Commit 5d22b92

Browse files
committed
[Devirtualizer] Only add substitutable types to SubstitutionMap.
Fixes rdar://problem/29289360.
1 parent a0a0a56 commit 5d22b92

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: lib/SILOptimizer/Utils/Devirtualize.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ getSubstitutionsForCallee(SILModule &M,
463463

464464
// Otherwise, record the replacement and conformances for the mapped
465465
// type.
466-
subMap.addSubstitution(canTy, sub.getReplacement());
466+
if (isa<GenericTypeParamType>(canTy))
467+
subMap.addSubstitution(canTy, sub.getReplacement());
467468
subMap.addConformances(canTy, sub.getConformances());
468469
}
469470
assert(origSubs.empty());
@@ -898,7 +899,8 @@ static void getWitnessMethodSubstitutions(
898899
// Otherwise, record the replacement and conformances for the mapped
899900
// type.
900901
auto canTy = mappedDepTy->getCanonicalType();
901-
subMap.addSubstitution(canTy, sub.getReplacement());
902+
if (isa<GenericTypeParamType>(canTy))
903+
subMap.addSubstitution(canTy, sub.getReplacement());
902904
subMap.addConformances(canTy, sub.getConformances());
903905
}
904906
assert(subs.empty() && "Did not consume all substitutions");

Diff for: test/Prototypes/PatternMatching.swift

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
14-
// REQUIRES: swift_test_mode_optimize_none
1514

1615
//===--- Niceties ---------------------------------------------------------===//
1716
typealias Element_<S: Sequence> = S.Iterator.Element

0 commit comments

Comments
 (0)