Skip to content

Commit aa03589

Browse files
authored
---
yaml --- r: 327665 b: refs/heads/tensorflow c: b8fb2e5 h: refs/heads/master i: 327663: abad4b8
1 parent faba289 commit aa03589

Some content is hidden

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

44 files changed

+378
-225
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: 1efa946caf3580bd54b1a9958a679f71adf06d56
819+
refs/heads/tensorflow: b8fb2e5eae295370491357e0323571984f0376f5
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: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
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)|
2017
|**[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)|
2118
|**[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)|
2219
|**[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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ 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+
101103
#ifndef DIAG_NO_UNDEF
102104
# if defined(DIAG)
103105
# undef DIAG

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -140,52 +140,13 @@ 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-
159143
/// Returns all access paths in 'mod' that are visible from 'dc' if we
160144
/// subtract imports of 'other'.
161145
ArrayRef<ModuleDecl::AccessPathTy>
162146
getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
163147
const ModuleDecl *other,
164148
const DeclContext *dc);
165149

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-
189150
/// This is a hack to cope with main file parsing and REPL parsing, where
190151
/// we can add ImportDecls after name binding.
191152
void clear() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ 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)
155156

156157
KEY_STRING_ARR(SuperclassNames, superclassNames)
157158
KEY_STRING_ARR(ToolArgs, tool_arguments)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ 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-
5450
void collectDefaultImplementationForProtocolMembers(ProtocolDecl *PD,
5551
llvm::SmallDenseMap<ValueDecl*, ValueDecl*> &DefaultMap);
5652

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

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

@@ -158,8 +156,6 @@ struct TypeRelationCheckInput {
158156
out << " is ";
159157
switch(owner.Relation) {
160158
#define CASE(NAME) case TypeRelation::NAME: out << #NAME << " "; break;
161-
CASE(EqualTo)
162-
CASE(PossiblyEqualTo)
163159
CASE(ConvertTo)
164160
#undef CASE
165161
}

branches/tensorflow/lib/AST/NameLookup.cpp

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,27 @@ 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+
196217
for (unsigned secondIdx : range(firstIdx + 1, decls.size())) {
197218
// Determine whether one module takes precedence over another.
198219
auto secondDecl = decls[secondIdx];
@@ -206,22 +227,28 @@ static void recordShadowedDeclsAfterSignatureMatch(
206227
if (firstModule != secondModule &&
207228
firstDecl->getDeclContext()->isModuleScopeContext() &&
208229
secondDecl->getDeclContext()->isModuleScopeContext()) {
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) {
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)) {
213237
shadowed.insert(firstDecl);
214238
break;
215-
} else if (firstScoped && !secondScoped) {
239+
} else if (isShadowed(secondPaths)) {
216240
shadowed.insert(secondDecl);
217241
continue;
218242
}
219243

220-
// Now check if one module shadows the other.
221-
if (imports.isShadowedBy(firstModule, secondModule, name, dc)) {
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) {
222249
shadowed.insert(firstDecl);
223250
break;
224-
} else if (imports.isShadowedBy(secondModule, firstModule, name, dc)) {
251+
} else if (firstScoped && !secondScoped) {
225252
shadowed.insert(secondDecl);
226253
continue;
227254
}
@@ -278,10 +305,16 @@ static void recordShadowedDeclsAfterSignatureMatch(
278305
if (firstModule != secondModule &&
279306
!firstDecl->getDeclContext()->isModuleScopeContext() &&
280307
!secondDecl->getDeclContext()->isModuleScopeContext()) {
281-
if (imports.isShadowedBy(firstModule, secondModule, dc)) {
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)) {
282315
shadowed.insert(firstDecl);
283316
break;
284-
} else if (imports.isShadowedBy(secondModule, firstModule, dc)) {
317+
} else if (isShadowed(secondPaths)) {
285318
shadowed.insert(secondDecl);
286319
continue;
287320
}

branches/tensorflow/lib/AST/Type.cpp

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

1482+
SmallPtrSet<ClassDecl *, 8> seen;
14821483
do {
1484+
if (auto *classDecl = ty->getClassOrBoundGenericClass())
1485+
if (!seen.insert(classDecl).second)
1486+
return false;
14831487
if (ty->isEqual(this))
14841488
return true;
14851489
} while ((ty = ty->getSuperclass()));
@@ -1510,6 +1514,10 @@ bool TypeBase::isBindableTo(Type b) {
15101514
if (orig->requiresClass() && !subst->satisfiesClassConstraint())
15111515
return false;
15121516

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

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

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

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

15821590
bool visitDependentMemberType(DependentMemberType *dt, CanType subst) {
1583-
llvm_unreachable("can't visit dependent types");
1591+
return true;
15841592
}
15851593
bool visitGenericTypeParamType(GenericTypeParamType *dt, CanType subst) {
1586-
llvm_unreachable("can't visit dependent types");
1594+
return true;
15871595
}
15881596

15891597
bool visitFunctionType(FunctionType *func, CanType subst) {
15901598
if (auto substFunc = dyn_cast<FunctionType>(subst)) {
15911599
if (func->getExtInfo() != substFunc->getExtInfo())
15921600
return false;
15931601

1602+
if (func->getParams().size() != substFunc->getParams().size())
1603+
return false;
1604+
15941605
for (unsigned i : indices(func->getParams())) {
15951606
if (!visit(func->getParams()[i].getOldType(),
15961607
substFunc.getParams()[i].getOldType()))
@@ -1708,20 +1719,13 @@ bool TypeBase::isBindableToSuperclassOf(Type ty) {
17081719
if (!ty->mayHaveSuperclass())
17091720
return false;
17101721

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-
1722+
SmallPtrSet<ClassDecl *, 8> seen;
17201723
do {
1724+
if (auto *classDecl = ty->getClassOrBoundGenericClass())
1725+
if (!seen.insert(classDecl).second)
1726+
return false;
17211727
if (isBindableTo(ty))
17221728
return true;
1723-
if (ty->getAnyNominal() && ty->getAnyNominal()->isInvalid())
1724-
return false;
17251729
} while ((ty = ty->getSuperclass()));
17261730
return false;
17271731
}

branches/tensorflow/lib/FrontendTool/FrontendTool.cpp

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

branches/tensorflow/lib/IDE/IDETypeChecking.cpp

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,6 @@ 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-
11091
struct SynthesizedExtensionAnalyzer::Implementation {
11192
static bool isMemberFavored(const NominalTypeDecl* Target, const Decl* D) {
11293
DeclContext* DC = Target->getInnermostDeclContext();
@@ -186,11 +167,9 @@ struct SynthesizedExtensionAnalyzer::Implementation {
186167
std::set<Requirement> Requirements;
187168
void addRequirement(GenericSignature *GenericSig,
188169
Type First, Type Second, RequirementKind Kind) {
189-
CanType CanFirst =
190-
GenericSig->getCanonicalTypeInContext(eraseAssociatedTypes(First));
170+
CanType CanFirst = GenericSig->getCanonicalTypeInContext(First);
191171
CanType CanSecond;
192-
if (Second) CanSecond =
193-
GenericSig->getCanonicalTypeInContext(eraseAssociatedTypes(Second));
172+
if (Second) CanSecond = GenericSig->getCanonicalTypeInContext(Second);
194173

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

326305
switch (Kind) {
327306
case RequirementKind::Conformance:
328-
case RequirementKind::Superclass:
329307
// FIXME: This could be more accurate; check
330308
// conformance instead of subtyping
331309
if (!isConvertibleTo(First, Second, /*openArchetypes=*/true, *DC))
@@ -335,8 +313,17 @@ struct SynthesizedExtensionAnalyzer::Implementation {
335313
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
336314
break;
337315

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+
338324
case RequirementKind::SameType:
339-
if (!canPossiblyEqual(First, Second, *DC)) {
325+
if (!First->isBindableTo(Second) &&
326+
!Second->isBindableTo(First)) {
340327
return true;
341328
} else if (!First->isEqual(Second)) {
342329
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
@@ -753,19 +740,6 @@ bool swift::isMemberDeclApplied(const DeclContext *DC, Type BaseTy,
753740
IsDeclApplicableRequest(DeclApplicabilityOwner(DC, BaseTy, VD)), false);
754741
}
755742

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-
769743
bool swift::isConvertibleTo(Type T1, Type T2, bool openArchetypes,
770744
DeclContext &DC) {
771745
return evaluateOrDefault(DC.getASTContext().evaluator,

0 commit comments

Comments
 (0)