Skip to content
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
12 changes: 5 additions & 7 deletions lib/IRGen/GenKeyPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ irgen::bindPolymorphicArgumentsFromComponentIndices(IRGenFunction &IGF,
// The generic environment is marshaled into the end of the component
// argument area inside the instance. Bind the generic information out of
// the buffer.
if (hasSubscriptIndices) {
auto genericArgsSize = llvm::ConstantInt::get(IGF.IGM.SizeTy,
requirements.size() * IGF.IGM.getPointerSize().getValue());
auto genericArgsSize = llvm::ConstantInt::get(IGF.IGM.SizeTy,
requirements.size() * IGF.IGM.getPointerSize().getValue());

auto genericArgsOffset = IGF.Builder.CreateSub(size, genericArgsSize);
args =
IGF.Builder.CreateInBoundsGEP(IGF.IGM.Int8Ty, args, genericArgsOffset);
}
auto genericArgsOffset = IGF.Builder.CreateSub(size, genericArgsSize);
args =
IGF.Builder.CreateInBoundsGEP(IGF.IGM.Int8Ty, args, genericArgsOffset);

bindFromGenericRequirementsBuffer(
IGF, requirements,
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/KeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2787,7 +2787,6 @@ internal func _getTypeByMangledNameInEnvironmentOrContext(
genericEnvironmentOrContext: UnsafeRawPointer?,
genericArguments: UnsafeRawPointer?)
-> Any.Type? {

let taggedPointer = UInt(bitPattern: genericEnvironmentOrContext)
if taggedPointer & 1 == 0 {
return _getTypeByMangledNameInEnvironment(name, nameLength,
Expand Down
13 changes: 13 additions & 0 deletions test/stdlib/Inputs/KeyPathMultiModule_b.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import StdlibUnittest

// rdar://125886333
public struct GenericExternalKeyPathTest<E> {
public private(set) var property: String {
get {
return "\(E.self)"
}
set {
}
}

public init() {}
}

public struct A {
public var x: Int { return 0 }

Expand Down
14 changes: 14 additions & 0 deletions test/stdlib/KeyPathMultiModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,18 @@ keyPathMultiModule.test("identity across multiple modules") {
}
}

@inline(never) @_optimize(none)
func testGenericExternalPropertyKeyPath<A, B, C>(
a: A, b: B, c: C
) -> KeyPath<GenericExternalKeyPathTest<C>, String> {
return \GenericExternalKeyPathTest<C>.property
}

keyPathMultiModule.test("external generic property keypath accessed from different generic context") {
let kp = testGenericExternalPropertyKeyPath(a: 1, b: 1.0, c: "one")

expectEqual(GenericExternalKeyPathTest<String>()[keyPath: kp],
"\(String.self)")
}

runAllTests()