Skip to content

Commit 7501113

Browse files
authored
Merge pull request swiftlang#28411 from DougGregor/property-wrapper-bad-recursion-break
[Type checker] Remove an unnecessary cycle break.
2 parents f20885c + 60e501d commit 7501113

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
167167
if (!argumentParam)
168168
continue;
169169

170-
if (!argumentParam->hasInterfaceType())
171-
continue;
172-
173170
if (argumentParam->isInOut() || argumentParam->isVariadic())
174171
continue;
175172

176173
auto paramType = argumentParam->getInterfaceType();
174+
if (paramType->is<ErrorType>())
175+
continue;
176+
177177
if (argumentParam->isAutoClosure()) {
178178
if (auto *fnType = paramType->getAs<FunctionType>())
179179
paramType = fnType->getResult();

test/SILOptimizer/di_property_wrappers.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,34 @@ func testWrapperInitWithDefaultArg() {
474474
// CHECK-NEXT: Init
475475
}
476476

477+
// rdar://problem/57350503 - DI failure due to an unnecessary cycle breaker
478+
public class Test57350503 {
479+
@Synchronized
480+
public private(set) var anchor: Int
481+
482+
public init(anchor: Int) {
483+
self.anchor = anchor
484+
printMe()
485+
}
486+
487+
private func printMe() { }
488+
}
489+
490+
@propertyWrapper
491+
public final class Synchronized<Value> {
492+
private var value: Value
493+
494+
public var wrappedValue: Value {
495+
get { value }
496+
set { value = newValue }
497+
}
498+
499+
public init(wrappedValue: Value) {
500+
value = wrappedValue
501+
}
502+
}
503+
504+
477505
testIntStruct()
478506
testIntClass()
479507
testRefStruct()

0 commit comments

Comments
 (0)