Skip to content

SILGen: Match up abstraction level when materializing mixed set and read/unsafeAddress properties. #62312

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
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/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3198,7 +3198,7 @@ class ArgEmitter {
return SGF.emitLValue(e->getSubExpr(), SGFAccessKind::ReadWrite);
}
}();

if (loweredSubstParamType.hasAbstractionDifference(Rep,
loweredSubstArgType)) {
lv.addSubstToOrigComponent(origType, loweredSubstParamType);
Expand Down
7 changes: 6 additions & 1 deletion lib/SILGen/SILGenLValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ namespace {
}

void dump(raw_ostream &OS, unsigned indent) const override {
OS.indent(indent) << "MaterializeToTemporaryComponent";
OS.indent(indent) << "MaterializeToTemporaryComponent\n";
}

private:
Expand Down Expand Up @@ -1895,6 +1895,10 @@ namespace {
/*actorIsolation=*/None);
}
}

if (lv.getTypeOfRValue() != getTypeOfRValue()) {
lv.addOrigToSubstComponent(getTypeOfRValue());
}

return lv;
}
Expand Down Expand Up @@ -3490,6 +3494,7 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
BaseFormalType, typeData, varStorageType,
ArgListForDiagnostics, std::move(Indices),
IsOnSelfParameter);

}

void emitUsingCoroutineAccessor(SILDeclRef accessor, bool isDirect,
Expand Down
26 changes: 26 additions & 0 deletions test/SILGen/mix-setter-and-read.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %target-swift-emit-silgen -verify %s

struct Attributt<T> {
public var read_and_set: T {
_read {
yield UnsafePointer<T>(bitPattern: 17)!.pointee
}
nonmutating set {
}
}
public var address_and_set: T {
unsafeAddress {
return UnsafePointer<T>(bitPattern: 38)!
}
nonmutating set {
}
}
}

func foo(x: inout (Int) -> Int) { }

func bar(x: Attributt<(Int) -> Int>) {
foo(x: &x.read_and_set)
foo(x: &x.address_and_set)
}