Skip to content

Commit faba289

Browse files
committed
---
yaml --- r: 327664 b: refs/heads/tensorflow c: 1efa946 h: refs/heads/master
1 parent abad4b8 commit faba289

File tree

68 files changed

+649
-712
lines changed

Some content is hidden

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

68 files changed

+649
-712
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: c5ae17d5445495622cd4995ecff419b672cca9b8
819+
refs/heads/tensorflow: 1efa946caf3580bd54b1a9958a679f71adf06d56
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
| **OS** | **Architecture** | **Build** |
1616
|---|:---:|:---:|
17+
|**[Debian 9.1 (Raspberry Pi)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/armv7_debian_stretch.json)** | ARMv7 | [![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-debian-9_1/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-debian-9_1)|
18+
|**[Fedora 27](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_fedora_27.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27)|
19+
|**[Ubuntu 16.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04)|
1720
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le)|
1821
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
1922
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|

branches/tensorflow/include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ ERROR(new_decl_without_intro,none,"%0 is a new API without @available attribute"
9898

9999
ERROR(objc_name_change,none,"%0 has ObjC name change from %1 to %2", (StringRef, StringRef, StringRef))
100100

101-
ERROR(desig_init_added,none,"%0 has been added as a designated initializer to an open class", (StringRef))
102-
103101
#ifndef DIAG_NO_UNDEF
104102
# if defined(DIAG)
105103
# undef DIAG

branches/tensorflow/include/swift/AST/ImportCache.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,52 @@ class alignas(ModuleDecl::ImportedModule) ImportCache {
140140
return !getAllVisibleAccessPaths(mod, dc).empty();
141141
}
142142

143+
/// Determines if 'mod' is visible from 'dc' as a result of a scoped import.
144+
/// Note that if 'mod' was not imported from 'dc' at all, this also returns
145+
/// false.
146+
bool isScopedImport(const ModuleDecl *mod, DeclBaseName name,
147+
const DeclContext *dc) {
148+
auto accessPaths = getAllVisibleAccessPaths(mod, dc);
149+
for (auto accessPath : accessPaths) {
150+
if (accessPath.empty())
151+
continue;
152+
if (ModuleDecl::matchesAccessPath(accessPath, name))
153+
return true;
154+
}
155+
156+
return false;
157+
}
158+
143159
/// Returns all access paths in 'mod' that are visible from 'dc' if we
144160
/// subtract imports of 'other'.
145161
ArrayRef<ModuleDecl::AccessPathTy>
146162
getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
147163
const ModuleDecl *other,
148164
const DeclContext *dc);
149165

166+
/// Returns 'true' if a declaration named 'name' defined in 'other' shadows
167+
/// defined in 'mod', because no access paths can find 'name' in 'mod' from
168+
/// 'dc' if we ignore imports of 'other'.
169+
bool isShadowedBy(const ModuleDecl *mod,
170+
const ModuleDecl *other,
171+
DeclBaseName name,
172+
const DeclContext *dc) {
173+
auto accessPaths = getAllAccessPathsNotShadowedBy(mod, other, dc);
174+
return llvm::none_of(accessPaths,
175+
[&](ModuleDecl::AccessPathTy accessPath) {
176+
return ModuleDecl::matchesAccessPath(accessPath, name);
177+
});
178+
}
179+
180+
/// Qualified lookup into types uses a slightly different check that does not
181+
/// take access paths into account.
182+
bool isShadowedBy(const ModuleDecl *mod,
183+
const ModuleDecl *other,
184+
const DeclContext *dc) {
185+
auto accessPaths = getAllAccessPathsNotShadowedBy(mod, other, dc);
186+
return accessPaths.empty();
187+
}
188+
150189
/// This is a hack to cope with main file parsing and REPL parsing, where
151190
/// we can add ImportDecls after name binding.
152191
void clear() {

branches/tensorflow/include/swift/IDE/DigesterEnums.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ KEY_STRING(IntrotvOS, intro_tvOS)
152152
KEY_STRING(IntrowatchOS, intro_watchOS)
153153
KEY_STRING(Introswift, intro_swift)
154154
KEY_STRING(ObjCName, objc_name)
155-
KEY_STRING(InitKind, init_kind)
156155

157156
KEY_STRING_ARR(SuperclassNames, superclassNames)
158157
KEY_STRING_ARR(ToolArgs, tool_arguments)

branches/tensorflow/include/swift/Runtime/ObjCBridge.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ namespace swift {
7979
SWIFT_RUNTIME_EXPORT
8080
void swift_rootObjCDealloc(HeapObject *self);
8181

82+
// Uses Swift bridging to box a C string into an NSString without introducing
83+
// a link-time dependency on NSString.
84+
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
85+
id swift_stdlib_NSStringFromUTF8(const char *cstr, int len);
86+
8287
}
8388

8489
#endif // SWIFT_OBJC_INTEROP

branches/tensorflow/include/swift/Sema/IDETypeChecking.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace swift {
4747
/// \returns true on convertible, false on not.
4848
bool isConvertibleTo(Type T1, Type T2, bool openArchetypes, DeclContext &DC);
4949

50+
bool isEqual(Type T1, Type T2, DeclContext &DC);
51+
52+
bool canPossiblyEqual(Type T1, Type T2, DeclContext &DC);
53+
5054
void collectDefaultImplementationForProtocolMembers(ProtocolDecl *PD,
5155
llvm::SmallDenseMap<ValueDecl*, ValueDecl*> &DefaultMap);
5256

branches/tensorflow/include/swift/Sema/IDETypeCheckingRequests.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class IsDeclApplicableRequest:
8787
// Type relation checking
8888
//----------------------------------------------------------------------------//
8989
enum class TypeRelation: uint8_t {
90+
EqualTo,
91+
PossiblyEqualTo,
9092
ConvertTo,
9193
};
9294

@@ -156,6 +158,8 @@ struct TypeRelationCheckInput {
156158
out << " is ";
157159
switch(owner.Relation) {
158160
#define CASE(NAME) case TypeRelation::NAME: out << #NAME << " "; break;
161+
CASE(EqualTo)
162+
CASE(PossiblyEqualTo)
159163
CASE(ConvertTo)
160164
#undef CASE
161165
}

branches/tensorflow/lib/AST/NameLookup.cpp

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -193,27 +193,6 @@ static void recordShadowedDeclsAfterSignatureMatch(
193193
auto firstDecl = decls[firstIdx];
194194
auto firstModule = firstDecl->getModuleContext();
195195
auto name = firstDecl->getBaseName();
196-
197-
auto isShadowed = [&](ArrayRef<ModuleDecl::AccessPathTy> paths) {
198-
for (auto path : paths) {
199-
if (ModuleDecl::matchesAccessPath(path, name))
200-
return false;
201-
}
202-
203-
return true;
204-
};
205-
206-
auto isScopedImport = [&](ArrayRef<ModuleDecl::AccessPathTy> paths) {
207-
for (auto path : paths) {
208-
if (path.empty())
209-
continue;
210-
if (ModuleDecl::matchesAccessPath(path, name))
211-
return true;
212-
}
213-
214-
return false;
215-
};
216-
217196
for (unsigned secondIdx : range(firstIdx + 1, decls.size())) {
218197
// Determine whether one module takes precedence over another.
219198
auto secondDecl = decls[secondIdx];
@@ -227,28 +206,22 @@ static void recordShadowedDeclsAfterSignatureMatch(
227206
if (firstModule != secondModule &&
228207
firstDecl->getDeclContext()->isModuleScopeContext() &&
229208
secondDecl->getDeclContext()->isModuleScopeContext()) {
230-
auto firstPaths = imports.getAllAccessPathsNotShadowedBy(
231-
firstModule, secondModule, dc);
232-
auto secondPaths = imports.getAllAccessPathsNotShadowedBy(
233-
secondModule, firstModule, dc);
234-
235-
// Check if one module shadows the other.
236-
if (isShadowed(firstPaths)) {
209+
// First, scoped imports shadow unscoped imports.
210+
bool firstScoped = imports.isScopedImport(firstModule, name, dc);
211+
bool secondScoped = imports.isScopedImport(secondModule, name, dc);
212+
if (!firstScoped && secondScoped) {
237213
shadowed.insert(firstDecl);
238214
break;
239-
} else if (isShadowed(secondPaths)) {
215+
} else if (firstScoped && !secondScoped) {
240216
shadowed.insert(secondDecl);
241217
continue;
242218
}
243219

244-
// We might be in a situation where neither module shadows the
245-
// other, but one declaration is visible via a scoped import.
246-
bool firstScoped = isScopedImport(firstPaths);
247-
bool secondScoped = isScopedImport(secondPaths);
248-
if (!firstScoped && secondScoped) {
220+
// Now check if one module shadows the other.
221+
if (imports.isShadowedBy(firstModule, secondModule, name, dc)) {
249222
shadowed.insert(firstDecl);
250223
break;
251-
} else if (firstScoped && !secondScoped) {
224+
} else if (imports.isShadowedBy(secondModule, firstModule, name, dc)) {
252225
shadowed.insert(secondDecl);
253226
continue;
254227
}
@@ -305,16 +278,10 @@ static void recordShadowedDeclsAfterSignatureMatch(
305278
if (firstModule != secondModule &&
306279
!firstDecl->getDeclContext()->isModuleScopeContext() &&
307280
!secondDecl->getDeclContext()->isModuleScopeContext()) {
308-
auto firstPaths = imports.getAllAccessPathsNotShadowedBy(
309-
firstModule, secondModule, dc);
310-
auto secondPaths = imports.getAllAccessPathsNotShadowedBy(
311-
secondModule, firstModule, dc);
312-
313-
// Check if one module shadows the other.
314-
if (isShadowed(firstPaths)) {
281+
if (imports.isShadowedBy(firstModule, secondModule, dc)) {
315282
shadowed.insert(firstDecl);
316283
break;
317-
} else if (isShadowed(secondPaths)) {
284+
} else if (imports.isShadowedBy(secondModule, firstModule, dc)) {
318285
shadowed.insert(secondDecl);
319286
continue;
320287
}

branches/tensorflow/lib/AST/Type.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,11 +1479,7 @@ bool TypeBase::isExactSuperclassOf(Type ty) {
14791479
ty->getSuperclass()->getAnyNominal()->hasClangNode())))
14801480
return false;
14811481

1482-
SmallPtrSet<ClassDecl *, 8> seen;
14831482
do {
1484-
if (auto *classDecl = ty->getClassOrBoundGenericClass())
1485-
if (!seen.insert(classDecl).second)
1486-
return false;
14871483
if (ty->isEqual(this))
14881484
return true;
14891485
} while ((ty = ty->getSuperclass()));
@@ -1514,10 +1510,6 @@ bool TypeBase::isBindableTo(Type b) {
15141510
if (orig->requiresClass() && !subst->satisfiesClassConstraint())
15151511
return false;
15161512

1517-
if (auto superclass = orig->getSuperclass())
1518-
if (!superclass->isBindableToSuperclassOf(subst))
1519-
return false;
1520-
15211513
// TODO: If the archetype has a superclass constraint, check that the
15221514
// substitution is a subclass.
15231515

@@ -1536,7 +1528,7 @@ bool TypeBase::isBindableTo(Type b) {
15361528
if (CanType(orig) == subst)
15371529
return true;
15381530

1539-
return false;
1531+
llvm_unreachable("not a valid canonical type substitution");
15401532
}
15411533

15421534
bool visitNominalType(NominalType *nom, CanType subst) {
@@ -1588,20 +1580,17 @@ bool TypeBase::isBindableTo(Type b) {
15881580
}
15891581

15901582
bool visitDependentMemberType(DependentMemberType *dt, CanType subst) {
1591-
return true;
1583+
llvm_unreachable("can't visit dependent types");
15921584
}
15931585
bool visitGenericTypeParamType(GenericTypeParamType *dt, CanType subst) {
1594-
return true;
1586+
llvm_unreachable("can't visit dependent types");
15951587
}
15961588

15971589
bool visitFunctionType(FunctionType *func, CanType subst) {
15981590
if (auto substFunc = dyn_cast<FunctionType>(subst)) {
15991591
if (func->getExtInfo() != substFunc->getExtInfo())
16001592
return false;
16011593

1602-
if (func->getParams().size() != substFunc->getParams().size())
1603-
return false;
1604-
16051594
for (unsigned i : indices(func->getParams())) {
16061595
if (!visit(func->getParams()[i].getOldType(),
16071596
substFunc.getParams()[i].getOldType()))
@@ -1719,13 +1708,20 @@ bool TypeBase::isBindableToSuperclassOf(Type ty) {
17191708
if (!ty->mayHaveSuperclass())
17201709
return false;
17211710

1722-
SmallPtrSet<ClassDecl *, 8> seen;
1711+
// If the type is itself an archetype, we could always potentially bind it
1712+
// to the superclass (via external retroactive conformance, even if the
1713+
// type isn't statically known to conform).
1714+
//
1715+
// We could theoretically reject cases where the set of conformances is known
1716+
// (say the protocol or classes are private or internal).
1717+
if (is<ArchetypeType>())
1718+
return true;
1719+
17231720
do {
1724-
if (auto *classDecl = ty->getClassOrBoundGenericClass())
1725-
if (!seen.insert(classDecl).second)
1726-
return false;
17271721
if (isBindableTo(ty))
17281722
return true;
1723+
if (ty->getAnyNominal() && ty->getAnyNominal()->isInvalid())
1724+
return false;
17291725
} while ((ty = ty->getSuperclass()));
17301726
return false;
17311727
}

branches/tensorflow/lib/FrontendTool/FrontendTool.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,10 @@ static bool performCompile(CompilerInstance &Instance,
11221122
if (Action == FrontendOptions::ActionType::Typecheck) {
11231123
if (emitIndexData(Invocation, Instance))
11241124
return true;
1125-
if (opts.InputsAndOutputs.isWholeModule()) {
1126-
if (emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance,
1127-
Invocation,
1128-
moduleIsPublic)) {
1129-
return true;
1130-
}
1125+
if (emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance,
1126+
Invocation,
1127+
moduleIsPublic)) {
1128+
return true;
11311129
}
11321130
return false;
11331131
}

branches/tensorflow/lib/IDE/IDETypeChecking.cpp

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ PrintOptions PrintOptions::printDocInterface() {
8888
return result;
8989
}
9090

91+
/// Erase any associated types within dependent member types, so we'll resolve
92+
/// them again.
93+
static Type eraseAssociatedTypes(Type type) {
94+
if (!type->hasTypeParameter()) return type;
95+
96+
return type.transformRec([](TypeBase *type) -> Optional<Type> {
97+
if (auto depMemType = dyn_cast<DependentMemberType>(type)) {
98+
auto newBase = eraseAssociatedTypes(depMemType->getBase());
99+
if (newBase.getPointer() == depMemType->getBase().getPointer() &&
100+
!depMemType->getAssocType())
101+
return None;
102+
103+
return Type(DependentMemberType::get(newBase, depMemType->getName()));
104+
}
105+
106+
return None;
107+
});
108+
}
109+
91110
struct SynthesizedExtensionAnalyzer::Implementation {
92111
static bool isMemberFavored(const NominalTypeDecl* Target, const Decl* D) {
93112
DeclContext* DC = Target->getInnermostDeclContext();
@@ -167,9 +186,11 @@ struct SynthesizedExtensionAnalyzer::Implementation {
167186
std::set<Requirement> Requirements;
168187
void addRequirement(GenericSignature *GenericSig,
169188
Type First, Type Second, RequirementKind Kind) {
170-
CanType CanFirst = GenericSig->getCanonicalTypeInContext(First);
189+
CanType CanFirst =
190+
GenericSig->getCanonicalTypeInContext(eraseAssociatedTypes(First));
171191
CanType CanSecond;
172-
if (Second) CanSecond = GenericSig->getCanonicalTypeInContext(Second);
192+
if (Second) CanSecond =
193+
GenericSig->getCanonicalTypeInContext(eraseAssociatedTypes(Second));
173194

174195
Requirements.insert({First, Second, Kind, CanFirst, CanSecond});
175196
}
@@ -304,6 +325,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
304325

305326
switch (Kind) {
306327
case RequirementKind::Conformance:
328+
case RequirementKind::Superclass:
307329
// FIXME: This could be more accurate; check
308330
// conformance instead of subtyping
309331
if (!isConvertibleTo(First, Second, /*openArchetypes=*/true, *DC))
@@ -313,17 +335,8 @@ struct SynthesizedExtensionAnalyzer::Implementation {
313335
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
314336
break;
315337

316-
case RequirementKind::Superclass:
317-
if (!Second->isBindableToSuperclassOf(First)) {
318-
return true;
319-
} else if (!Second->isExactSuperclassOf(Second)) {
320-
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
321-
}
322-
break;
323-
324338
case RequirementKind::SameType:
325-
if (!First->isBindableTo(Second) &&
326-
!Second->isBindableTo(First)) {
339+
if (!canPossiblyEqual(First, Second, *DC)) {
327340
return true;
328341
} else if (!First->isEqual(Second)) {
329342
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
@@ -740,6 +753,19 @@ bool swift::isMemberDeclApplied(const DeclContext *DC, Type BaseTy,
740753
IsDeclApplicableRequest(DeclApplicabilityOwner(DC, BaseTy, VD)), false);
741754
}
742755

756+
bool swift::canPossiblyEqual(Type T1, Type T2, DeclContext &DC) {
757+
return evaluateOrDefault(DC.getASTContext().evaluator,
758+
TypeRelationCheckRequest(TypeRelationCheckInput(&DC, T1, T2,
759+
TypeRelation::PossiblyEqualTo, true)), false);
760+
}
761+
762+
763+
bool swift::isEqual(Type T1, Type T2, DeclContext &DC) {
764+
return evaluateOrDefault(DC.getASTContext().evaluator,
765+
TypeRelationCheckRequest(TypeRelationCheckInput(&DC, T1, T2,
766+
TypeRelation::EqualTo, true)), false);
767+
}
768+
743769
bool swift::isConvertibleTo(Type T1, Type T2, bool openArchetypes,
744770
DeclContext &DC) {
745771
return evaluateOrDefault(DC.getASTContext().evaluator,

0 commit comments

Comments
 (0)