Skip to content

Commit fa304a1

Browse files
committed
---
yaml --- r: 342006 b: refs/heads/rxwei-patch-1 c: bd9b18e h: refs/heads/master
1 parent ca872a5 commit fa304a1

File tree

15 files changed

+76
-206
lines changed

15 files changed

+76
-206
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: ab995ecbaae5c4fcb787f6ff60de3494506387fe
1018+
refs/heads/rxwei-patch-1: bd9b18ef65301ddaa28cf09267c096d6815a07ce
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,20 +4120,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41204120
Bits.ProtocolDecl.RequiresClass = requiresClass;
41214121
}
41224122

4123-
/// Returns the cached result of \c existentialConformsToSelf or \c None if it
4124-
/// hasn't yet been computed.
4125-
Optional<bool> getCachedExistentialConformsToSelf() const {
4126-
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4127-
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4128-
4129-
return None;
4130-
}
4131-
4132-
/// Caches the result of \c existentialConformsToSelf
4133-
void setCachedExistentialConformsToSelf(bool result) {
4134-
Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;
4135-
Bits.ProtocolDecl.ExistentialConformsToSelf = result;
4136-
}
4123+
bool existentialConformsToSelfSlow();
41374124

41384125
bool existentialTypeSupportedSlow();
41394126

@@ -4147,7 +4134,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41474134
friend class SuperclassTypeRequest;
41484135
friend class RequirementSignatureRequest;
41494136
friend class ProtocolRequiresClassRequest;
4150-
friend class ExistentialConformsToSelfRequest;
41514137
friend class TypeChecker;
41524138

41534139
public:
@@ -4218,7 +4204,13 @@ class ProtocolDecl final : public NominalTypeDecl {
42184204
/// This is only permitted if there is nothing "non-trivial" that we
42194205
/// can do with the metatype, which means the protocol must not have
42204206
/// any static methods and must be declared @objc.
4221-
bool existentialConformsToSelf() const;
4207+
bool existentialConformsToSelf() const {
4208+
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4209+
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4210+
4211+
return const_cast<ProtocolDecl *>(this)
4212+
->existentialConformsToSelfSlow();
4213+
}
42224214

42234215
/// Does this protocol require a self-conformance witness table?
42244216
bool requiresSelfConformanceWitnessTable() const;

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,9 +4523,6 @@ WARNING(property_wrapper_init_initialValue,none,
45234523
())
45244524
ERROR(property_wrapper_projection_value_missing,none,
45254525
"could not find projection value property %0", (Identifier))
4526-
ERROR(property_wrapper_missing_arg_init, none, "missing argument for parameter "
4527-
"%0 in property wrapper initializer; add 'wrappedValue' and %0 "
4528-
"arguments in '@%1(...)'", (Identifier, StringRef))
45294526

45304527
//------------------------------------------------------------------------------
45314528
// MARK: function builder diagnostics

branches/rxwei-patch-1/include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,6 @@ class ProtocolRequiresClassRequest:
201201
void cacheResult(bool value) const;
202202
};
203203

204-
/// Determine whether an existential conforming to a protocol can be matched
205-
/// with a generic type parameter constrained to that protocol.
206-
class ExistentialConformsToSelfRequest:
207-
public SimpleRequest<ExistentialConformsToSelfRequest,
208-
bool(ProtocolDecl *),
209-
CacheKind::SeparatelyCached> {
210-
public:
211-
using SimpleRequest::SimpleRequest;
212-
213-
private:
214-
friend SimpleRequest;
215-
216-
// Evaluation.
217-
llvm::Expected<bool> evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;
218-
219-
public:
220-
// Cycle handling.
221-
void diagnoseCycle(DiagnosticEngine &diags) const;
222-
void noteCycleStep(DiagnosticEngine &diags) const;
223-
224-
// Separate caching.
225-
bool isCached() const { return true; }
226-
Optional<bool> getCachedResult() const;
227-
void cacheResult(bool value) const;
228-
};
229-
230204
/// Determine whether the given declaration is 'final'.
231205
class IsFinalRequest :
232206
public SimpleRequest<IsFinalRequest,

branches/rxwei-patch-1/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ SWIFT_TYPEID(EnumRawTypeRequest)
2020
SWIFT_TYPEID(OverriddenDeclsRequest)
2121
SWIFT_TYPEID(IsObjCRequest)
2222
SWIFT_TYPEID(ProtocolRequiresClassRequest)
23-
SWIFT_TYPEID(ExistentialConformsToSelfRequest)
2423
SWIFT_TYPEID(IsFinalRequest)
2524
SWIFT_TYPEID(IsDynamicRequest)
2625
SWIFT_TYPEID(RequirementRequest)

branches/rxwei-patch-1/lib/AST/Decl.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,9 +4329,43 @@ bool ProtocolDecl::requiresSelfConformanceWitnessTable() const {
43294329
return isSpecificProtocol(KnownProtocolKind::Error);
43304330
}
43314331

4332-
bool ProtocolDecl::existentialConformsToSelf() const {
4333-
return evaluateOrDefault(getASTContext().evaluator,
4334-
ExistentialConformsToSelfRequest{const_cast<ProtocolDecl *>(this)}, true);
4332+
bool ProtocolDecl::existentialConformsToSelfSlow() {
4333+
// Assume for now that the existential conforms to itself; this
4334+
// prevents circularity issues.
4335+
Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;
4336+
Bits.ProtocolDecl.ExistentialConformsToSelf = true;
4337+
4338+
// If it's not @objc, it conforms to itself only if it has a
4339+
// self-conformance witness table.
4340+
if (!isObjC()) {
4341+
bool hasSelfConformance = requiresSelfConformanceWitnessTable();
4342+
Bits.ProtocolDecl.ExistentialConformsToSelf = hasSelfConformance;
4343+
return hasSelfConformance;
4344+
}
4345+
4346+
// Check whether this protocol conforms to itself.
4347+
for (auto member : getMembers()) {
4348+
if (member->isInvalid())
4349+
continue;
4350+
4351+
if (auto vd = dyn_cast<ValueDecl>(member)) {
4352+
if (!vd->isInstanceMember()) {
4353+
// A protocol cannot conform to itself if it has static members.
4354+
Bits.ProtocolDecl.ExistentialConformsToSelf = false;
4355+
return false;
4356+
}
4357+
}
4358+
}
4359+
4360+
// Check whether any of the inherited protocols fail to conform to
4361+
// themselves.
4362+
for (auto proto : getInheritedProtocols()) {
4363+
if (!proto->existentialConformsToSelf()) {
4364+
Bits.ProtocolDecl.ExistentialConformsToSelf = false;
4365+
return false;
4366+
}
4367+
}
4368+
return true;
43354369
}
43364370

43374371
/// Classify usages of Self in the given type.

branches/rxwei-patch-1/lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -211,31 +211,6 @@ void ProtocolRequiresClassRequest::cacheResult(bool value) const {
211211
decl->setCachedRequiresClass(value);
212212
}
213213

214-
//----------------------------------------------------------------------------//
215-
// existentialConformsToSelf computation.
216-
//----------------------------------------------------------------------------//
217-
218-
void ExistentialConformsToSelfRequest::diagnoseCycle(DiagnosticEngine &diags) const {
219-
auto decl = std::get<0>(getStorage());
220-
diags.diagnose(decl, diag::circular_protocol_def, decl->getName());
221-
}
222-
223-
void ExistentialConformsToSelfRequest::noteCycleStep(DiagnosticEngine &diags) const {
224-
auto requirement = std::get<0>(getStorage());
225-
diags.diagnose(requirement, diag::kind_declname_declared_here,
226-
DescriptiveDeclKind::Protocol, requirement->getName());
227-
}
228-
229-
Optional<bool> ExistentialConformsToSelfRequest::getCachedResult() const {
230-
auto decl = std::get<0>(getStorage());
231-
return decl->getCachedExistentialConformsToSelf();
232-
}
233-
234-
void ExistentialConformsToSelfRequest::cacheResult(bool value) const {
235-
auto decl = std::get<0>(getStorage());
236-
decl->setCachedExistentialConformsToSelf(value);
237-
}
238-
239214
//----------------------------------------------------------------------------//
240215
// isFinal computation.
241216
//----------------------------------------------------------------------------//

branches/rxwei-patch-1/lib/IDE/ExprContextAnalysis.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,6 @@ class ExprContextAnalyzer {
583583
case ExprKind::Array: {
584584
if (auto type = ParsedExpr->getType()) {
585585
recordPossibleType(type);
586-
break;
587-
}
588-
589-
// Check context types of the array literal expression.
590-
ExprContextInfo arrayCtxtInfo(DC, Parent);
591-
for (auto arrayT : arrayCtxtInfo.getPossibleTypes()) {
592-
if (auto boundGenericT = arrayT->getAs<BoundGenericType>())
593-
if (boundGenericT->getDecl() == Context.getArrayDecl())
594-
recordPossibleType(boundGenericT->getGenericArgs()[0]);
595586
}
596587
break;
597588
}

branches/rxwei-patch-1/lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,20 +3219,13 @@ class ArgumentMatcher : public MatchCallArgumentListener {
32193219

32203220
assert(insertLoc.isValid() && "missing argument after trailing closure?");
32213221

3222-
if (name.empty()) {
3222+
if (name.empty())
32233223
TC.diagnose(insertLoc, diag::missing_argument_positional,
32243224
missingParamIdx + 1)
32253225
.fixItInsert(insertLoc, insertText.str());
3226-
} else {
3227-
if (isPropertyWrapperImplicitInit()) {
3228-
auto TE = cast<TypeExpr>(FnExpr);
3229-
TC.diagnose(TE->getLoc(), diag::property_wrapper_missing_arg_init, name,
3230-
TE->getInstanceType()->getString());
3231-
} else {
3232-
TC.diagnose(insertLoc, diag::missing_argument_named, name)
3233-
.fixItInsert(insertLoc, insertText.str());
3234-
}
3235-
}
3226+
else
3227+
TC.diagnose(insertLoc, diag::missing_argument_named, name)
3228+
.fixItInsert(insertLoc, insertText.str());
32363229

32373230
auto candidate = CandidateInfo[0];
32383231
if (candidate.getDecl())
@@ -3242,27 +3235,6 @@ class ArgumentMatcher : public MatchCallArgumentListener {
32423235
Diagnosed = true;
32433236
}
32443237

3245-
bool isPropertyWrapperImplicitInit() {
3246-
auto TE = dyn_cast<TypeExpr>(FnExpr);
3247-
if (!TE)
3248-
return false;
3249-
3250-
auto instanceTy = TE->getInstanceType();
3251-
if (!instanceTy)
3252-
return false;
3253-
3254-
auto nominalDecl = instanceTy->getAnyNominal();
3255-
if (!(nominalDecl &&
3256-
nominalDecl->getAttrs().hasAttribute<PropertyWrapperAttr>()))
3257-
return false;
3258-
3259-
if (auto *parentExpr = CandidateInfo.CS.getParentExpr(FnExpr)) {
3260-
return parentExpr->isImplicit() && isa<CallExpr>(parentExpr);
3261-
}
3262-
3263-
return false;
3264-
}
3265-
32663238
bool missingLabel(unsigned paramIdx) override {
32673239
return false;
32683240
}

branches/rxwei-patch-1/lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,34 +1269,6 @@ ProtocolRequiresClassRequest::evaluate(Evaluator &evaluator,
12691269
return false;
12701270
}
12711271

1272-
llvm::Expected<bool>
1273-
ExistentialConformsToSelfRequest::evaluate(Evaluator &evaluator,
1274-
ProtocolDecl *decl) const {
1275-
// If it's not @objc, it conforms to itself only if it has a self-conformance
1276-
// witness table.
1277-
if (!decl->isObjC())
1278-
return decl->requiresSelfConformanceWitnessTable();
1279-
1280-
// Check whether this protocol conforms to itself.
1281-
for (auto member : decl->getMembers()) {
1282-
if (member->isInvalid()) continue;
1283-
1284-
if (auto vd = dyn_cast<ValueDecl>(member)) {
1285-
// A protocol cannot conform to itself if it has static members.
1286-
if (!vd->isInstanceMember())
1287-
return false;
1288-
}
1289-
}
1290-
1291-
// Check whether any of the inherited protocols fail to conform to themselves.
1292-
for (auto proto : decl->getInheritedProtocols()) {
1293-
if (!proto->existentialConformsToSelf())
1294-
return false;
1295-
}
1296-
1297-
return true;
1298-
}
1299-
13001272
llvm::Expected<bool>
13011273
IsFinalRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
13021274
if (isa<ClassDecl>(decl))

branches/rxwei-patch-1/test/IDE/complete_call_arg.swift

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@
8282
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_AFTERPAREN_2 | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_AFTERPAREN_2
8383
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_SECOND | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SECOND
8484
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_SKIPPED | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SKIPPED
85-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_1_AFTERPAREN_1 | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_AFTERPAREN_1
86-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_1_AFTERPAREN_2 | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_AFTERPAREN_2
87-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_1_SECOND | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SECOND
88-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_1_SKIPPED | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SKIPPED
89-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_2_AFTERPAREN_1 | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_AFTERPAREN_1
90-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_2_AFTERPAREN_2 | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_AFTERPAREN_2
91-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_2_SECOND | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SECOND
92-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_ARRAY_2_SKIPPED | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SKIPPED
9385

9486
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARCHETYPE_GENERIC_1 | %FileCheck %s -check-prefix=ARCHETYPE_GENERIC_1
9587

@@ -696,39 +688,6 @@ func testImplicitMember() {
696688
// IMPLICIT_MEMBER_SKIPPED: Keyword/ExprSpecific: arg4: [#Argument name#];
697689
// IMPLICIT_MEMBER_SKIPPED: End completions
698690
}
699-
func testImplicitMemberInArrayLiteral() {
700-
struct Receiver {
701-
init(_: [TestStaticMemberCall]) {}
702-
init(arg1: Int, arg2: [TestStaticMemberCall]) {}
703-
}
704-
705-
Receiver([
706-
.create1(x: 1),
707-
.create1(#^IMPLICIT_MEMBER_ARRAY_1_AFTERPAREN_1^#),
708-
// Same as IMPLICIT_MEMBER_AFTERPAREN_1.
709-
])
710-
Receiver([
711-
.create2(#^IMPLICIT_MEMBER_ARRAY_1_AFTERPAREN_2^#),
712-
// Same as IMPLICIT_MEMBER_AFTERPAREN_2.
713-
.create2(1, #^IMPLICIT_MEMBER_ARRAY_1_SECOND^#
714-
// Same as IMPLICIT_MEMBER_SECOND.
715-
])
716-
Receiver(arg1: 12, arg2: [
717-
.create2(1, arg3: 2, #^IMPLICIT_MEMBER_ARRAY_1_SKIPPED^#
718-
// Same as IMPLICIT_MEMBER_SKIPPED.
719-
.create1(x: 12)
720-
])
721-
let _: [TestStaticMemberCall] = [
722-
.create1(#^IMPLICIT_MEMBER_ARRAY_2_AFTERPAREN_1^#),
723-
// Same as STATIC_METHOD_AFTERPAREN_1.
724-
.create2(#^IMPLICIT_MEMBER_ARRAY_2_AFTERPAREN_2^#),
725-
// Same as STATIC_METHOD_AFTERPAREN_2.
726-
.create2(1, #^IMPLICIT_MEMBER_ARRAY_2_SECOND^#),
727-
// Same as STATIC_METHOD_SECOND.
728-
.create2(1, arg3: 2, #^IMPLICIT_MEMBER_ARRAY_2_SKIPPED^#),
729-
// Same as STATIC_METHOD_SKIPPED.
730-
]
731-
}
732691

733692
struct Wrap<T> {
734693
func method<U>(_ fn: (T) -> U) -> Wrap<U> {}

branches/rxwei-patch-1/test/decl/protocol/conforms/redundant_conformance.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,24 @@ extension OtherGenericConditionalConformsToP: P1 {
6565
typealias A = Double
6666
func f() -> Double { return 0.0 }
6767
}
68+
69+
// FB6114209: spurious ambiguity errors
70+
protocol MyUsefulProtocol {
71+
var someInt: Int { get }
72+
}
73+
74+
class Class1 {
75+
typealias ProviderOne = MyUsefulProtocol
76+
}
77+
78+
class Class2 {
79+
typealias ProviderTwo = MyUsefulProtocol
80+
}
81+
82+
class Class3 {
83+
typealias ProviderThree = Class1.ProviderOne & Class2.ProviderTwo
84+
}
85+
86+
class SomeMockClass: Class3.ProviderThree { // okay
87+
var someInt: Int = 5
88+
}

branches/rxwei-patch-1/test/decl/var/property_wrappers.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,19 +1091,3 @@ struct InvalidPropertyDelegateUse {
10911091
self.x.foo() // expected-error {{value of type 'Int' has no member 'foo'}}
10921092
}
10931093
}
1094-
1095-
// SR-11060
1096-
1097-
class SR_11060_Class {
1098-
@SR_11060_Wrapper var property: Int = 1234 // expected-error {{missing argument for parameter 'string' in property wrapper initializer; add 'wrappedValue' and 'string' arguments in '@SR_11060_Wrapper(...)'}}
1099-
}
1100-
1101-
@propertyWrapper
1102-
struct SR_11060_Wrapper {
1103-
var wrappedValue: Int
1104-
1105-
init(wrappedValue: Int, string: String) { // expected-note {{'init(wrappedValue:string:)' declared here}}
1106-
self.wrappedValue = wrappedValue
1107-
}
1108-
}
1109-

branches/rxwei-patch-1/unittests/Basic/CacheTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ TEST(Cache, sameKeyValue) {
153153
}
154154

155155
TEST(Cache, sameKeyValueDestroysKey) {
156+
swift::sys::Cache<KeyCounter, Counter> cache(__func__);
156157
KeyCounter k1, k2;
157158
Counter c;
158-
swift::sys::Cache<KeyCounter, Counter> cache(__func__);
159159
cache.set(k1, c);
160160
cache.set(k2, c);
161161
EXPECT_EQ(1, k1.enter);

0 commit comments

Comments
 (0)