Skip to content

Commit d9c4bed

Browse files
authored
Merge pull request #62312 from jckarter/mix-read-or-address-with-setter-reabstraction
SILGen: Match up abstraction level when materializing mixed set and read/unsafeAddress properties.
2 parents a0ffb8c + d1a9f9a commit d9c4bed

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3256,7 +3256,7 @@ class ArgEmitter {
32563256
return SGF.emitLValue(e->getSubExpr(), SGFAccessKind::ReadWrite);
32573257
}
32583258
}();
3259-
3259+
32603260
if (loweredSubstParamType.hasAbstractionDifference(Rep,
32613261
loweredSubstArgType)) {
32623262
lv.addSubstToOrigComponent(origType, loweredSubstParamType);

lib/SILGen/SILGenLValue.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ namespace {
18711871
}
18721872

18731873
void dump(raw_ostream &OS, unsigned indent) const override {
1874-
OS.indent(indent) << "MaterializeToTemporaryComponent";
1874+
OS.indent(indent) << "MaterializeToTemporaryComponent\n";
18751875
}
18761876

18771877
private:
@@ -1905,6 +1905,10 @@ namespace {
19051905
/*actorIsolation=*/None);
19061906
}
19071907
}
1908+
1909+
if (lv.getTypeOfRValue() != getTypeOfRValue()) {
1910+
lv.addOrigToSubstComponent(getTypeOfRValue());
1911+
}
19081912

19091913
return lv;
19101914
}
@@ -3500,6 +3504,7 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
35003504
BaseFormalType, typeData, varStorageType,
35013505
ArgListForDiagnostics, std::move(Indices),
35023506
IsOnSelfParameter);
3507+
35033508
}
35043509

35053510
void emitUsingCoroutineAccessor(SILDeclRef accessor, bool isDirect,

test/SILGen/mix-setter-and-read.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-emit-silgen -verify %s
2+
3+
struct Attributt<T> {
4+
public var read_and_set: T {
5+
_read {
6+
yield UnsafePointer<T>(bitPattern: 17)!.pointee
7+
}
8+
nonmutating set {
9+
}
10+
}
11+
public var address_and_set: T {
12+
unsafeAddress {
13+
return UnsafePointer<T>(bitPattern: 38)!
14+
}
15+
nonmutating set {
16+
}
17+
}
18+
}
19+
20+
func foo(x: inout (Int) -> Int) { }
21+
22+
func bar(x: Attributt<(Int) -> Int>) {
23+
foo(x: &x.read_and_set)
24+
foo(x: &x.address_and_set)
25+
}
26+

0 commit comments

Comments
 (0)