Skip to content

Commit a861f3e

Browse files
committed
Fixes #function when called lazily
1 parent 4b2f008 commit a861f3e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/SILGen/SILGenGlobalVariable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ void SILGenModule::emitGlobalInitialization(PatternBindingDecl *pd,
242242

243243
void SILGenFunction::emitLazyGlobalInitializer(PatternBindingDecl *binding,
244244
unsigned pbdEntry) {
245+
MagicFunctionName = SILGenModule::getMagicFunctionName(binding->getDeclContext());
246+
245247
{
246248
Scope scope(Cleanups, binding);
247249

test/SILGen/default_arguments.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Foo {
116116

117117
// CHECK-LABEL: sil hidden @_T017default_arguments3FooCACSi3int_SS6stringtcfc : $@convention(method) (Int, @owned String, @owned Foo) -> @owned Foo
118118
// CHECK: string_literal utf16 "init(int:string:)"
119-
init(int: Int, string: String) {
119+
init(int: Int, string: String = #function) {
120120
testMagicLiterals()
121121
closure { testMagicLiterals() }
122122
autoclosure(testMagicLiterals())
@@ -138,6 +138,9 @@ class Foo {
138138
autoclosure(testMagicLiterals())
139139
return x
140140
}
141+
142+
static let x = Foo(int:0)
143+
141144
}
142145

143146
// Test at top level.

0 commit comments

Comments
 (0)