Skip to content

Commit 8459a9d

Browse files
committed
Revert "[Type checker] Represent "initializable" let instance property references as lvalues"
This reverts commit cc4ab6a.
1 parent e976584 commit 8459a9d

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,24 +1716,10 @@ namespace {
17161716
// For properties, build member references.
17171717
if (auto *varDecl = dyn_cast<VarDecl>(member)) {
17181718
// \returns result of the given function type
1719-
bool loadImmediately = false;
1720-
auto resultType = [&loadImmediately](Type fnTy) -> Type {
1721-
Type resultTy = fnTy->castTo<FunctionType>()->getResult();
1722-
if (loadImmediately)
1723-
return LValueType::get(resultTy);
1724-
return resultTy;
1719+
auto resultType = [](Type fnTy) -> Type {
1720+
return fnTy->castTo<FunctionType>()->getResult();
17251721
};
17261722

1727-
// If we have an instance property that's treated as an rvalue
1728-
// but allows assignment (for initialization) in the current
1729-
// context, treat it as an rvalue that we immediately load.
1730-
// This is the AST that's expected by SILGen.
1731-
if (baseIsInstance && !resultType(refTy)->hasLValueType() &&
1732-
varDecl->mutability(dc, dyn_cast<DeclRefExpr>(base))
1733-
== StorageMutability::Initializable) {
1734-
loadImmediately = true;
1735-
}
1736-
17371723
if (isUnboundInstanceMember) {
17381724
assert(memberLocator.getBaseLocator() &&
17391725
cs.UnevaluatedRootExprs.count(
@@ -1779,12 +1765,6 @@ namespace {
17791765
result, conversionTy));
17801766
}
17811767
}
1782-
1783-
// If we need to load, do so now.
1784-
if (loadImmediately) {
1785-
result = cs.addImplicitLoadExpr(result);
1786-
}
1787-
17881768
return forceUnwrapIfExpected(result, memberLocator);
17891769
}
17901770

test/SILOptimizer/definite_init_value_types_diagnostics.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,3 @@ struct AddressStruct {
7878
self = AddressStruct()
7979
} // expected-error {{return from initializer without initializing all stored properties}}
8080
}
81-
82-
// Old versions of swift-syntax have this logical use-before-definition; make
83-
// sure we keep it working.
84-
struct InitLogicalUseBeforeDef {
85-
let offset: UInt16
86-
87-
init?(value: Int) {
88-
if value > type(of: self.offset).max {
89-
return nil
90-
}
91-
offset = UInt16(value)
92-
}
93-
}

0 commit comments

Comments
 (0)