Skip to content

Commit d674617

Browse files
authored
Merge pull request swiftlang#36717 from eeckstein/main
2 parents d3d2d75 + f3d1c34 commit d674617

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/SILOptimizer/Transforms/StringOptimization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ bool StringOptimization::optimizeTypeName(ApplyInst *typeNameCall) {
300300

301301
auto metatype = metatypeInst->getType().getAs<MetatypeType>();
302302
Type ty = metatype->getInstanceType();
303-
if (ty->hasArchetype())
303+
if (ty->hasArchetype() || ty->hasDynamicSelfType())
304304
return false;
305305

306306
// Usually the "qualified" parameter of _typeName() is a constant boolean.

test/SILOptimizer/string_optimization.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ struct Outer {
2222
static let staticString = "static"
2323
}
2424

25+
class C {
26+
@inline(never)
27+
func f() -> String {
28+
return "\(Self.self)"
29+
}
30+
}
31+
2532
// More types are tested in test/stdlib/TypeName.swift and
2633
// test/stdlib/TypeNameInterpolation.swift
2734

@@ -149,6 +156,9 @@ printEmbeeded(testQualifiedLocalType())
149156
// CHECK-OUTPUT: <test.Outer.InnerClass>
150157
printEmbeeded(testInnerClass())
151158

159+
// CHECK-OUTPUT: <C>
160+
printEmbeeded(C().f())
161+
152162
#if _runtime(_ObjC)
153163

154164
// Can't use check-output here, because for non ObjC runtimes it would not match.

0 commit comments

Comments
 (0)