Skip to content

Commit d1a9f9a

Browse files
committed
SILGen: Match up abstraction level when materializing mixed set and read/unsafeAddress properties.
Addresses part of rdar://102525437.
1 parent f3e061f commit d1a9f9a

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
@@ -3198,7 +3198,7 @@ class ArgEmitter {
31983198
return SGF.emitLValue(e->getSubExpr(), SGFAccessKind::ReadWrite);
31993199
}
32003200
}();
3201-
3201+
32023202
if (loweredSubstParamType.hasAbstractionDifference(Rep,
32033203
loweredSubstArgType)) {
32043204
lv.addSubstToOrigComponent(origType, loweredSubstParamType);

lib/SILGen/SILGenLValue.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ namespace {
18611861
}
18621862

18631863
void dump(raw_ostream &OS, unsigned indent) const override {
1864-
OS.indent(indent) << "MaterializeToTemporaryComponent";
1864+
OS.indent(indent) << "MaterializeToTemporaryComponent\n";
18651865
}
18661866

18671867
private:
@@ -1895,6 +1895,10 @@ namespace {
18951895
/*actorIsolation=*/None);
18961896
}
18971897
}
1898+
1899+
if (lv.getTypeOfRValue() != getTypeOfRValue()) {
1900+
lv.addOrigToSubstComponent(getTypeOfRValue());
1901+
}
18981902

18991903
return lv;
19001904
}
@@ -3490,6 +3494,7 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
34903494
BaseFormalType, typeData, varStorageType,
34913495
ArgListForDiagnostics, std::move(Indices),
34923496
IsOnSelfParameter);
3497+
34933498
}
34943499

34953500
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)