Skip to content

Commit

Permalink
Merge pull request #2316 from jckarter/sr-613
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-ci committed Apr 26, 2016
2 parents ad2fbec + 2eed756 commit 461c8e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/SILGen/SILGenApply.cpp
Expand Up @@ -1001,6 +1001,8 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
// Prepare the callee. This can modify both selfValue and subs.
Callee theCallee = prepareArchetypeCallee(SGF, e, constant, selfValue,
substFnType, subs);
AssumedPlusZeroSelf = selfValue.isRValue()
&& selfValue.forceAndPeekRValue(SGF).peekIsPlusZeroRValueOrTrivial();

setSelfParam(std::move(selfValue), thisCallSite);
setCallee(std::move(theCallee));
Expand Down Expand Up @@ -3718,7 +3720,16 @@ namespace {

// Grab the SILLocation and the new managed value.
SILLocation ArgLoc = ArgValue.getKnownRValueLocation();
ManagedValue ArgManagedValue = gen.emitManagedRetain(ArgLoc, ArgSILValue);
ManagedValue ArgManagedValue;
if (ArgSILValue->getType().isAddress()) {
auto result = gen.emitTemporaryAllocation(ArgLoc,
ArgSILValue->getType());
gen.B.createCopyAddr(ArgLoc, ArgSILValue, result,
IsNotTake, IsInitialization);
ArgManagedValue = gen.emitManagedBufferWithCleanup(result);
} else {
ArgManagedValue = gen.emitManagedRetain(ArgLoc, ArgSILValue);
}

// Ok now we make our transformation. First set ArgValue to a used albeit
// invalid, empty ArgumentSource.
Expand Down
13 changes: 13 additions & 0 deletions test/SILGen/partial_apply_protocol_class_refinement_method.swift
@@ -0,0 +1,13 @@
// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s

protocol P { func foo() }
protocol Q: class, P {}

// CHECK-LABEL: sil hidden @_TF46partial_apply_protocol_class_refinement_method12partialApplyFPS_1Q_FT_T_
func partialApply(_ q: Q) -> () -> () {
// CHECK: [[OPENED:%.*]] = open_existential_ref
// CHECK: store [[OPENED]] to [[TMP:%.*]] :
// CHECK: copy_addr [[TMP:%.*]] to [initialization] [[CONSUMABLE_TMP:%.*]] :
// CHECK: apply {{%.*}}<{{.*}}>([[CONSUMABLE_TMP]])
return q.foo
}

0 comments on commit 461c8e7

Please sign in to comment.