Skip to content

Commit 07c7f1d

Browse files
committed
---
yaml --- r: 348644 b: refs/heads/master c: cfc872f h: refs/heads/master
1 parent c2257f7 commit 07c7f1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+425
-208
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 264c8fe752cd99b1db2ebf148128128a38721732
2+
refs/heads/master: cfc872f8bf8987f2c0168d564e70b128b58add69
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/Remote/MetadataReader.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ class RemoteRef {
9595
uint64_t resolveRelativeAddressData() const {
9696
int32_t offset;
9797
memcpy(&offset, LocalBuffer, sizeof(int32_t));
98-
if (offset == 0)
99-
return 0;
10098
return Address + (int64_t)offset;
10199
}
102100

trunk/lib/AST/ASTContext.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@ static FuncDecl *findLibraryIntrinsic(const ASTContext &ctx,
922922
ctx.lookupInSwiftModule(name, results);
923923
if (results.size() == 1) {
924924
if (auto FD = dyn_cast<FuncDecl>(results.front())) {
925-
// FIXME(InterfaceTypeRequest): Remove this.
926-
(void)FD->getInterfaceType();
925+
if (auto *resolver = ctx.getLazyResolver())
926+
resolver->resolveDeclSignature(FD);
927927
return FD;
928928
}
929929
}
@@ -987,6 +987,9 @@ lookupOperatorFunc(const ASTContext &ctx, StringRef oper, Type contextType,
987987
if (!contextTy->isEqual(contextType)) continue;
988988
}
989989

990+
if (auto resolver = ctx.getLazyResolver())
991+
resolver->resolveDeclSignature(fnDecl);
992+
990993
auto *funcTy = getIntrinsicCandidateType(fnDecl, /*allowTypeMembers=*/true);
991994
if (!funcTy)
992995
continue;
@@ -3966,6 +3969,8 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx,
39663969

39673970
// Look through typealiases.
39683971
if (auto typealias = dyn_cast<TypeAliasDecl>(result)) {
3972+
if (auto resolver = ctx.getLazyResolver())
3973+
resolver->resolveDeclSignature(typealias);
39693974
return typealias->getDeclaredInterfaceType()->getAnyNominal();
39703975
}
39713976
}

trunk/lib/AST/ASTMangler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,13 @@ CanType ASTMangler::getDeclTypeForMangling(
23432343
parentGenericSig = nullptr;
23442344

23452345
auto &C = decl->getASTContext();
2346-
if (!decl->getInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
2346+
if (!decl->hasInterfaceType() && !decl->getDeclContext()->isLocalContext()) {
2347+
if (auto *resolver = C.getLazyResolver()) {
2348+
resolver->resolveDeclSignature(const_cast<ValueDecl *>(decl));
2349+
}
2350+
}
2351+
2352+
if (!decl->hasInterfaceType() || decl->getInterfaceType()->is<ErrorType>()) {
23472353
if (isa<AbstractFunctionDecl>(decl))
23482354
return CanFunctionType::get({AnyFunctionType::Param(C.TheErrorType)},
23492355
C.TheErrorType);

trunk/lib/AST/Decl.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,13 +2697,7 @@ bool ValueDecl::hasInterfaceType() const {
26972697
}
26982698

26992699
Type ValueDecl::getInterfaceType() const {
2700-
if (!hasInterfaceType()) {
2701-
// Our clients that don't register the lazy resolver are relying on the
2702-
// fact that they can't pull an interface type out to avoid doing work.
2703-
// This is a necessary evil until we can wean them off.
2704-
if (auto resolver = getASTContext().getLazyResolver())
2705-
resolver->resolveDeclSignature(const_cast<ValueDecl *>(this));
2706-
}
2700+
assert(hasInterfaceType() && "No interface type was set");
27072701
return TypeAndAccess.getPointer();
27082702
}
27092703

@@ -3247,7 +3241,7 @@ Type TypeDecl::getDeclaredInterfaceType() const {
32473241
selfTy, const_cast<AssociatedTypeDecl *>(ATD));
32483242
}
32493243

3250-
Type interfaceType = getInterfaceType();
3244+
Type interfaceType = hasInterfaceType() ? getInterfaceType() : nullptr;
32513245
if (interfaceType.isNull() || interfaceType->is<ErrorType>())
32523246
return interfaceType;
32533247

@@ -6555,6 +6549,17 @@ static bool requiresNewVTableEntry(const AbstractFunctionDecl *decl) {
65556549
if (decl->isEffectiveLinkageMoreVisibleThan(base))
65566550
return true;
65576551

6552+
// FIXME: Remove this once getInterfaceType() has been request-ified.
6553+
if (!decl->hasInterfaceType()) {
6554+
ctx.getLazyResolver()->resolveDeclSignature(
6555+
const_cast<AbstractFunctionDecl *>(decl));
6556+
}
6557+
6558+
if (!base->hasInterfaceType()) {
6559+
ctx.getLazyResolver()->resolveDeclSignature(
6560+
const_cast<AbstractFunctionDecl *>(base));
6561+
}
6562+
65586563
// If the method overrides something, we only need a new entry if the
65596564
// override has a more general AST type. However an abstraction
65606565
// change is OK; we don't want to add a whole new vtable entry just

trunk/lib/AST/Module.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,15 +1817,14 @@ SourceFile::lookupOpaqueResultType(StringRef MangledName,
18171817
auto found = ValidatedOpaqueReturnTypes.find(MangledName);
18181818
if (found != ValidatedOpaqueReturnTypes.end())
18191819
return found->second;
1820-
1820+
18211821
// If there are unvalidated decls with opaque types, go through and validate
18221822
// them now.
18231823
if (resolver && !UnvalidatedDeclsWithOpaqueReturnTypes.empty()) {
18241824
while (!UnvalidatedDeclsWithOpaqueReturnTypes.empty()) {
18251825
ValueDecl *decl = *UnvalidatedDeclsWithOpaqueReturnTypes.begin();
18261826
UnvalidatedDeclsWithOpaqueReturnTypes.erase(decl);
1827-
// FIXME(InterfaceTypeRequest): Remove this.
1828-
(void)decl->getInterfaceType();
1827+
resolver->resolveDeclSignature(decl);
18291828
}
18301829

18311830
found = ValidatedOpaqueReturnTypes.find(MangledName);

trunk/lib/AST/NameLookup.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
434434
if (decls.size() < 2)
435435
return;
436436

437+
auto typeResolver = decls[0]->getASTContext().getLazyResolver();
438+
437439
// Categorize all of the declarations based on their overload signatures.
438440
llvm::SmallDenseMap<CanType, llvm::TinyPtrVector<ValueDecl *>> collisions;
439441
llvm::SmallVector<CanType, 2> collisionTypes;
@@ -461,16 +463,19 @@ static void recordShadowedDecls(ArrayRef<ValueDecl *> decls,
461463
CanType signature;
462464

463465
if (!isa<TypeDecl>(decl)) {
466+
// We need an interface type here.
467+
if (typeResolver)
468+
typeResolver->resolveDeclSignature(decl);
469+
464470
// If the decl is currently being validated, this is likely a recursive
465471
// reference and we'll want to skip ahead so as to avoid having its type
466472
// attempt to desugar itself.
467-
auto ifaceType = decl->getInterfaceType();
468-
if (!ifaceType)
473+
if (!decl->hasInterfaceType())
469474
continue;
470475

471476
// FIXME: the canonical type makes a poor signature, because we don't
472477
// canonicalize away default arguments.
473-
signature = ifaceType->getCanonicalType();
478+
signature = decl->getInterfaceType()->getCanonicalType();
474479

475480
// FIXME: The type of a variable or subscript doesn't include
476481
// enough context to distinguish entities from different

trunk/lib/AST/USRGeneration.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,11 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator,
241241
}
242242
}
243243

244-
auto declIFaceTy = D->getInterfaceType();
245-
if (!declIFaceTy)
244+
if (!D->hasInterfaceType())
246245
return std::string();
247246

248247
// Invalid code.
249-
if (declIFaceTy.findIf([](Type t) -> bool {
248+
if (D->getInterfaceType().findIf([](Type t) -> bool {
250249
return t->is<ModuleType>();
251250
}))
252251
return std::string();

trunk/lib/ClangImporter/ImportType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,9 @@ Type ClangImporter::Implementation::getNamedSwiftType(ModuleDecl *module,
23142314

23152315
assert(!decl->hasClangNode() && "picked up the original type?");
23162316

2317+
if (auto *lazyResolver = SwiftContext.getLazyResolver())
2318+
lazyResolver->resolveDeclSignature(decl);
2319+
23172320
if (auto *nominalDecl = dyn_cast<NominalTypeDecl>(decl))
23182321
return nominalDecl->getDeclaredType();
23192322
return decl->getDeclaredInterfaceType();

trunk/lib/IDE/CodeCompletion.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,8 +2046,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
20462046
auto *GenericSig = VD->getInnermostDeclContext()
20472047
->getGenericSignatureOfContext();
20482048

2049+
assert(VD->hasInterfaceType());
20492050
Type T = VD->getInterfaceType();
2050-
assert(!T.isNull());
20512051

20522052
if (ExprType) {
20532053
Type ContextTy = VD->getDeclContext()->getDeclaredInterfaceType();
@@ -2984,9 +2984,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
29842984

29852985
if (IsSwiftKeyPathExpr && !SwiftKeyPathFilter(D, Reason))
29862986
return;
2987-
2988-
// FIXME(InterfaceTypeRequest): Remove this.
2989-
(void)D->getInterfaceType();
2987+
2988+
if (!D->hasInterfaceType())
2989+
D->getASTContext().getLazyResolver()->resolveDeclSignature(D);
2990+
29902991
switch (Kind) {
29912992
case LookupKind::ValueExpr:
29922993
if (auto *CD = dyn_cast<ConstructorDecl>(D)) {
@@ -3143,9 +3144,9 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31433144

31443145
bool handleEnumElement(ValueDecl *D, DeclVisibilityKind Reason,
31453146
DynamicLookupInfo dynamicLookupInfo) {
3146-
// FIXME(InterfaceTypeRequest): Remove this.
3147-
(void)D->getInterfaceType();
3148-
3147+
if (!D->hasInterfaceType())
3148+
D->getASTContext().getLazyResolver()->resolveDeclSignature(D);
3149+
31493150
if (auto *EED = dyn_cast<EnumElementDecl>(D)) {
31503151
addEnumElementRef(EED, Reason, dynamicLookupInfo,
31513152
/*HasTypeContext=*/true);
@@ -3154,8 +3155,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31543155
llvm::DenseSet<EnumElementDecl *> Elements;
31553156
ED->getAllElements(Elements);
31563157
for (auto *Ele : Elements) {
3157-
// FIXME(InterfaceTypeRequest): Remove this.
3158-
(void)Ele->getInterfaceType();
3158+
if (!Ele->hasInterfaceType())
3159+
D->getASTContext().getLazyResolver()->resolveDeclSignature(Ele);
31593160
addEnumElementRef(Ele, Reason, dynamicLookupInfo,
31603161
/*HasTypeContext=*/true);
31613162
}
@@ -4329,8 +4330,8 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
43294330
(D->isStatic() && D->getAttrs().hasAttribute<HasInitialValueAttr>()))
43304331
return;
43314332

4332-
// FIXME(InterfaceTypeRequest): Remove this.
4333-
(void)D->getInterfaceType();
4333+
if (!D->hasInterfaceType())
4334+
D->getASTContext().getLazyResolver()->resolveDeclSignature(D);
43344335

43354336
bool hasIntroducer = hasFuncIntroducer ||
43364337
hasVarIntroducer ||

trunk/lib/IDE/ExprContextAnalysis.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,12 @@ static void collectPossibleCalleesByQualifiedLookup(
284284
continue;
285285
if (!isMemberDeclApplied(&DC, baseTy->getMetatypeInstanceType(), VD))
286286
continue;
287-
Type declaredMemberType = VD->getInterfaceType();
288-
if (!declaredMemberType) {
289-
continue;
287+
if (!VD->hasInterfaceType()) {
288+
VD->getASTContext().getLazyResolver()->resolveDeclSignature(VD);
289+
if (!VD->hasInterfaceType())
290+
continue;
290291
}
292+
Type declaredMemberType = VD->getInterfaceType();
291293
if (!declaredMemberType->is<AnyFunctionType>())
292294
continue;
293295
if (VD->getDeclContext()->isTypeContext()) {
@@ -897,7 +899,7 @@ bool swift::ide::isReferenceableByImplicitMemberExpr(
897899
if (VD->isOperator())
898900
return false;
899901

900-
if (!VD->getInterfaceType())
902+
if (!VD->hasInterfaceType())
901903
return false;
902904

903905
if (T->getOptionalObjectType() &&

trunk/lib/IDE/TypeContextInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ void ContextInfoCallbacks::getImplicitMembers(
139139
if (VD->isOperator())
140140
return false;
141141

142-
if (!VD->getInterfaceType()) {
143-
return false;
142+
if (!VD->hasInterfaceType()) {
143+
TypeResolver->resolveDeclSignature(VD);
144+
if (!VD->hasInterfaceType())
145+
return false;
144146
}
145147

146148
// Enum element decls can always be referenced by implicit member

trunk/lib/IRGen/GenEnum.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5777,7 +5777,10 @@ EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
57775777
elementsWithPayload.push_back({elt, nativeTI, nativeTI});
57785778
continue;
57795779
}
5780-
5780+
5781+
if (!elt->hasInterfaceType())
5782+
TC.IGM.Context.getLazyResolver()->resolveDeclSignature(elt);
5783+
57815784
// Compute whether this gives us an apparent payload or dynamic layout.
57825785
// Note that we do *not* apply substitutions from a bound generic instance
57835786
// yet. We want all instances of a generic enum to share an implementation

trunk/lib/IRGen/GenType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,9 @@ namespace {
19201920
return true;
19211921

19221922
for (auto field : decl->getStoredProperties()) {
1923+
if (!field->hasInterfaceType())
1924+
IGM.Context.getLazyResolver()->resolveDeclSignature(field);
1925+
19231926
if (visit(field->getInterfaceType()->getCanonicalType()))
19241927
return true;
19251928
}
@@ -1944,6 +1947,9 @@ namespace {
19441947
if (!elt->hasAssociatedValues() || elt->isIndirect())
19451948
continue;
19461949

1950+
if (!elt->hasInterfaceType())
1951+
IGM.Context.getLazyResolver()->resolveDeclSignature(elt);
1952+
19471953
if (visit(elt->getArgumentInterfaceType()->getCanonicalType()))
19481954
return true;
19491955
}

trunk/lib/SIL/SILType.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,18 @@ bool SILType::canRefCast(SILType operTy, SILType resultTy, SILModule &M) {
139139

140140
SILType SILType::getFieldType(VarDecl *field,
141141
TypeConverter &TC) const {
142+
auto baseTy = getASTType();
143+
144+
if (!field->hasInterfaceType())
145+
TC.Context.getLazyResolver()->resolveDeclSignature(field);
146+
142147
AbstractionPattern origFieldTy = TC.getAbstractionPattern(field);
143148
CanType substFieldTy;
144149
if (field->hasClangNode()) {
145150
substFieldTy = origFieldTy.getType();
146151
} else {
147152
substFieldTy =
148-
getASTType()->getTypeOfMember(&TC.M, field, nullptr)->getCanonicalType();
153+
baseTy->getTypeOfMember(&TC.M, field, nullptr)->getCanonicalType();
149154
}
150155

151156
auto loweredTy = TC.getLoweredRValueType(origFieldTy, substFieldTy);
@@ -170,6 +175,9 @@ SILType SILType::getEnumElementType(EnumElementDecl *elt,
170175
return SILType(objectType, getCategory());
171176
}
172177

178+
if (!elt->hasInterfaceType())
179+
TC.Context.getLazyResolver()->resolveDeclSignature(elt);
180+
173181
// If the case is indirect, then the payload is boxed.
174182
if (elt->isIndirect() || elt->getParentEnum()->isIndirect()) {
175183
auto box = TC.getBoxTypeForEnumElement(*this, elt);

trunk/lib/SIL/TypeLowering.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,10 @@ namespace {
12671267

12681268
// Classify the type according to its stored properties.
12691269
for (auto field : D->getStoredProperties()) {
1270+
// FIXME: Remove this once getInterfaceType() is a request.
1271+
if (!field->hasInterfaceType())
1272+
TC.Context.getLazyResolver()->resolveDeclSignature(field);
1273+
12701274
auto substFieldType =
12711275
field->getInterfaceType().subst(subMap)->getCanonicalType();
12721276

@@ -1309,7 +1313,11 @@ namespace {
13091313
properties.setNonTrivial();
13101314
continue;
13111315
}
1312-
1316+
1317+
// FIXME: Remove this once getInterfaceType() is a request.
1318+
if (!elt->hasInterfaceType())
1319+
TC.Context.getLazyResolver()->resolveDeclSignature(elt);
1320+
13131321
auto substEltType =
13141322
elt->getArgumentInterfaceType().subst(subMap)->getCanonicalType();
13151323

@@ -1887,6 +1895,11 @@ getFunctionInterfaceTypeWithCaptures(TypeConverter &TC,
18871895

18881896
CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) {
18891897
auto *vd = c.loc.dyn_cast<ValueDecl *>();
1898+
1899+
if (vd && !vd->hasInterfaceType()) {
1900+
Context.getLazyResolver()->resolveDeclSignature(vd);
1901+
}
1902+
18901903
switch (c.kind) {
18911904
case SILDeclRef::Kind::Func: {
18921905
CanAnyFunctionType funcTy;
@@ -2599,6 +2612,11 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(SILType enumType,
25992612
assert(elt->isIndirect() || elt->getParentEnum()->isIndirect());
26002613

26012614
auto &C = M.getASTContext();
2615+
2616+
// FIXME: Remove this once getInterfaceType() is a request.
2617+
if (!elt->hasInterfaceType())
2618+
Context.getLazyResolver()->resolveDeclSignature(elt);
2619+
26022620
auto boxSignature = getCanonicalSignatureOrNull(
26032621
enumDecl->getGenericSignature());
26042622

@@ -2670,6 +2688,9 @@ static void countNumberOfInnerFields(unsigned &fieldsCount, TypeConverter &TC,
26702688
if (elt->isIndirect())
26712689
continue;
26722690

2691+
if (!elt->hasInterfaceType())
2692+
TC.Context.getLazyResolver()->resolveDeclSignature(elt);
2693+
26732694
// Although one might assume enums have a fields count of 1
26742695
// Which holds true for current uses of this code
26752696
// (we shouldn't expand enums)

0 commit comments

Comments
 (0)