Skip to content

SILGen: Fix corner-case in emission of extension initializer #7441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SIL/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ static CanAnyFunctionType getStoredPropertyInitializerInterfaceType(
ASTContext &context) {
auto *DC = VD->getDeclContext();
CanType resultTy =
DC->mapTypeOutOfContext(VD->getParentInitializer()->getType())
DC->mapTypeOutOfContext(VD->getParentPattern()->getType())
->getCanonicalType();
GenericSignature *sig = DC->getGenericSignatureOfContext();

Expand Down
1 change: 1 addition & 0 deletions test/SILGen/Inputs/struct_with_initializer.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
struct HasInitValue {
var x = 10
var y: String = ""
}
4 changes: 2 additions & 2 deletions test/SILGen/extensions_multifile.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests -emit-silgen -primary-file %s %S/Inputs/struct_with_initializer.swift -module-name extensions_multifile | %FileCheck %s

// CHECK-LABEL: sil hidden @_T020extensions_multifile12HasInitValueVACSi1x_tcfC : $@convention(method) (Int, @thin HasInitValue.Type) -> HasInitValue {
// CHECK-LABEL: sil hidden @_T020extensions_multifile12HasInitValueVACSi1z_tcfC : $@convention(method) (Int, @thin HasInitValue.Type) -> @owned HasInitValue {
// CHECK: function_ref @_T020extensions_multifile12HasInitValueV1xSivfi : $@convention(thin) () -> Int

// CHECK-LABEL: sil hidden_external [transparent] @_T020extensions_multifile12HasInitValueV1xSivfi : $@convention(thin) () -> Int

extension HasInitValue {
init(x: Int) {}
init(z: Int) {}
}