Skip to content

Commit 9765a34

Browse files
committed
---
yaml --- r: 293853 b: refs/heads/tensorflow c: 768d1c5 h: refs/heads/master i: 293851: 82cf6ab
1 parent 13a5ecc commit 9765a34

File tree

13 files changed

+226
-222
lines changed

13 files changed

+226
-222
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: ef7884434910e092c61df33cd58a36fa8036e76c
819+
refs/heads/tensorflow: 768d1c51a197b0c82a27df45e6e6a01fcfb945ee
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/include/swift/AST/ProtocolConformanceRef.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ class ProtocolConformanceRef {
109109
LookupConformanceFn conformances,
110110
SubstOptions options = None) const;
111111

112-
/// Replace opaque types in the conforming type with their underlying types,
113-
/// and resolve opaque conformances to their underlying conformances.
114-
ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypes(
115-
Type origType, ModuleDecl *modulePerformingSubstitution) const;
116-
117112
/// Given a dependent type (expressed in terms of this conformance's
118113
/// protocol), follow it from the conforming type.
119114
Type getAssociatedType(Type origType, Type dependentType,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ class SubstitutionMap {
175175
LookupConformanceFn conformances,
176176
SubstOptions options = None) const;
177177

178-
/// Replace opaque types in the replacement types in the map with their
179-
/// underlying types. Does not change keys.
180-
SubstitutionMap substOpaqueTypesWithUnderlyingTypes(
181-
ModuleDecl *modulePerformingSubstitution) const;
182-
183178
/// Create a substitution map for a protocol conformance.
184179
static SubstitutionMap
185180
getProtocolSubstitutions(ProtocolDecl *protocol,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,6 @@ class Type {
316316
/// Replace references to substitutable types with error types.
317317
Type substDependentTypesWithErrorTypes() const;
318318

319-
/// Replace opaque types with their underlying types when visible at the given
320-
/// resilience expansion.
321-
Type substOpaqueTypesWithUnderlyingTypes(
322-
ModuleDecl *modulePerformingSubstitution) const;
323-
324319
bool isPrivateStdlibType(bool treatNonBuiltinProtocolsAsPublic = true) const;
325320

326321
void dump() const;

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,26 +4821,6 @@ class OpaqueTypeArchetypeType final : public ArchetypeType,
48214821
BEGIN_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
48224822
END_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
48234823

4824-
/// A function object that can be used as a \c TypeSubstitutionFn and
4825-
/// \c LookupConformanceFn for \c Type::subst style APIs to map opaque
4826-
/// archetypes with underlying types visible at a given resilience expansion
4827-
/// to their underlying types.
4828-
class ReplaceOpaqueTypesWithUnderlyingTypes {
4829-
public:
4830-
ModuleDecl *modulePerformingSubstitution;
4831-
ReplaceOpaqueTypesWithUnderlyingTypes(
4832-
ModuleDecl *modulePerformingSubstitution)
4833-
: modulePerformingSubstitution(modulePerformingSubstitution) {}
4834-
4835-
/// TypeSubstitutionFn
4836-
Type operator()(SubstitutableType *maybeOpaqueType) const;
4837-
4838-
/// LookupConformanceFn
4839-
Optional<ProtocolConformanceRef> operator()(CanType maybeOpaqueType,
4840-
Type replacementType,
4841-
ProtocolDecl *protocol) const;
4842-
};
4843-
48444824
/// An archetype that represents the dynamic type of an opened existential.
48454825
class OpenedArchetypeType final : public ArchetypeType,
48464826
private ArchetypeTrailingObjects<OpenedArchetypeType>

branches/tensorflow/include/swift/SIL/TypeSubstCloner.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
109109

110110
assert(Subs.empty() ||
111111
SubstCalleeSILType ==
112-
Callee->getType().substGenericArgs(AI.getModule(), Subs) ||
113-
(Cloner.ReplacingOpaqueArchetypes &&
114-
SubstCalleeSILType ==
115-
Cloner.getOpType(Callee->getType().substGenericArgs(
116-
AI.getModule(), Subs))));
112+
Callee->getType().substGenericArgs(AI.getModule(), Subs));
117113
}
118114

119115
ArrayRef<SILValue> getArguments() const {
@@ -159,14 +155,12 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
159155
TypeSubstCloner(SILFunction &To,
160156
SILFunction &From,
161157
SubstitutionMap ApplySubs,
162-
bool Inlining = false,
163-
bool ReplacingOpaqueArchetypes = false)
158+
bool Inlining = false)
164159
: SILClonerWithScopes<ImplClass>(To, Inlining),
165160
SwiftMod(From.getModule().getSwiftModule()),
166161
SubsMap(ApplySubs),
167162
Original(From),
168-
Inlining(Inlining),
169-
ReplacingOpaqueArchetypes(ReplacingOpaqueArchetypes) {
163+
Inlining(Inlining) {
170164
}
171165

172166
protected:
@@ -387,8 +381,6 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
387381
SILFunction &Original;
388382
/// True, if used for inlining.
389383
bool Inlining;
390-
/// True if replacing opaque result archetypes.
391-
bool ReplacingOpaqueArchetypes;
392384
};
393385

394386
} // end namespace swift

branches/tensorflow/lib/AST/ProtocolConformance.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ ProtocolConformanceRef::subst(Type origType,
141141
llvm_unreachable("Invalid conformance substitution");
142142
}
143143

144-
ProtocolConformanceRef
145-
ProtocolConformanceRef::substOpaqueTypesWithUnderlyingTypes(
146-
Type origType, ModuleDecl *modulePerformingSubstitution) const {
147-
ReplaceOpaqueTypesWithUnderlyingTypes replacer(modulePerformingSubstitution);
148-
return subst(origType, replacer, replacer,
149-
SubstFlags::SubstituteOpaqueArchetypes);
150-
}
151-
152144
Type
153145
ProtocolConformanceRef::getTypeWitnessByName(Type type,
154146
ProtocolConformanceRef conformance,

branches/tensorflow/lib/AST/SubstitutionMap.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,6 @@ SubstitutionMap SubstitutionMap::subst(TypeSubstitutionFn subs,
492492
return SubstitutionMap(genericSig, newSubs, newConformances);
493493
}
494494

495-
SubstitutionMap SubstitutionMap::substOpaqueTypesWithUnderlyingTypes(
496-
ModuleDecl *modulePerformingSubstitution) const {
497-
ReplaceOpaqueTypesWithUnderlyingTypes replacer(modulePerformingSubstitution);
498-
return subst(replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes);
499-
}
500-
501495
SubstitutionMap
502496
SubstitutionMap::getProtocolSubstitutions(ProtocolDecl *protocol,
503497
Type selfType,

branches/tensorflow/lib/AST/Type.cpp

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,117 +2460,6 @@ GenericSignature *OpaqueTypeArchetypeType::getBoundSignature() const {
24602460
return Environment->getGenericSignature();
24612461
}
24622462

2463-
static Optional<std::pair<ArchetypeType *, OpaqueTypeArchetypeType*>>
2464-
getArchetypeAndRootOpaqueArchetype(Type maybeOpaqueType) {
2465-
auto archetype = dyn_cast<ArchetypeType>(maybeOpaqueType.getPointer());
2466-
if (!archetype)
2467-
return None;
2468-
auto opaqueRoot = dyn_cast<OpaqueTypeArchetypeType>(archetype->getRoot());
2469-
if (!opaqueRoot)
2470-
return None;
2471-
2472-
return std::make_pair(archetype, opaqueRoot);
2473-
}
2474-
2475-
Type ReplaceOpaqueTypesWithUnderlyingTypes::operator()(
2476-
SubstitutableType *maybeOpaqueType) const {
2477-
auto archetypeAndRoot = getArchetypeAndRootOpaqueArchetype(maybeOpaqueType);
2478-
if (!archetypeAndRoot)
2479-
return maybeOpaqueType;
2480-
2481-
auto archetype = archetypeAndRoot->first;
2482-
auto opaqueRoot = archetypeAndRoot->second;
2483-
2484-
// Don't replace opaque types from resilient modules.
2485-
auto namingDecl = opaqueRoot->getDecl()->getNamingDecl();
2486-
auto module = namingDecl->getModuleContext();
2487-
if (module->isResilient() && module != modulePerformingSubstitution &&
2488-
!namingDecl->getAttrs().hasAttribute<InlinableAttr>()) {
2489-
return maybeOpaqueType;
2490-
}
2491-
2492-
auto subs = opaqueRoot->getDecl()->getUnderlyingTypeSubstitutions();
2493-
// TODO: Check the resilience expansion, and handle opaque types with
2494-
// unknown underlying types. For now, all opaque types are always
2495-
// fragile.
2496-
assert(subs.hasValue() && "resilient opaque types not yet supported");
2497-
2498-
// Apply the underlying type substitutions to the interface type of the
2499-
// archetype in question. This will map the inner generic signature of the
2500-
// opaque type to its outer signature.
2501-
auto partialSubstTy = archetype->getInterfaceType().subst(*subs);
2502-
// Then apply the substitutions from the root opaque archetype, to specialize
2503-
// for its type arguments.
2504-
auto substTy = partialSubstTy.subst(opaqueRoot->getSubstitutions());
2505-
2506-
// If the type still contains opaque types, recur.
2507-
if (substTy->hasOpaqueArchetype()) {
2508-
return substTy.substOpaqueTypesWithUnderlyingTypes(
2509-
modulePerformingSubstitution);
2510-
}
2511-
return substTy;
2512-
}
2513-
2514-
Optional<ProtocolConformanceRef>
2515-
ReplaceOpaqueTypesWithUnderlyingTypes::operator()(CanType maybeOpaqueType,
2516-
Type replacementType,
2517-
ProtocolDecl *protocol) const {
2518-
auto abstractRef = ProtocolConformanceRef(protocol);
2519-
2520-
auto archetypeAndRoot = getArchetypeAndRootOpaqueArchetype(maybeOpaqueType);
2521-
if (!archetypeAndRoot) {
2522-
assert(maybeOpaqueType->isTypeParameter()
2523-
|| maybeOpaqueType->is<ArchetypeType>());
2524-
return abstractRef;
2525-
}
2526-
2527-
auto archetype = archetypeAndRoot->first;
2528-
auto opaqueRoot = archetypeAndRoot->second;
2529-
2530-
// Don't replace opaque types from resilient modules.
2531-
auto namingDecl = opaqueRoot->getDecl()->getNamingDecl();
2532-
auto module = namingDecl->getModuleContext();
2533-
if (module->isResilient() && module != modulePerformingSubstitution &&
2534-
!namingDecl->getAttrs().hasAttribute<InlinableAttr>()) {
2535-
return abstractRef;
2536-
}
2537-
2538-
auto subs = opaqueRoot->getDecl()->getUnderlyingTypeSubstitutions();
2539-
assert(subs.hasValue());
2540-
2541-
// Apply the underlying type substitutions to the interface type of the
2542-
// archetype in question. This will map the inner generic signature of the
2543-
// opaque type to its outer signature.
2544-
auto partialSubstTy = archetype->getInterfaceType().subst(*subs);
2545-
auto partialSubstRef = abstractRef.subst(archetype->getInterfaceType(),
2546-
*subs);
2547-
2548-
// Then apply the substitutions from the root opaque archetype, to specialize
2549-
// for its type arguments.
2550-
auto substTy = partialSubstTy.subst(opaqueRoot->getSubstitutions());
2551-
auto substRef = partialSubstRef.subst(partialSubstTy,
2552-
opaqueRoot->getSubstitutions());
2553-
2554-
// If the type still contains opaque types, recur.
2555-
if (substTy->hasOpaqueArchetype()) {
2556-
return substRef.substOpaqueTypesWithUnderlyingTypes(
2557-
substTy, modulePerformingSubstitution);
2558-
}
2559-
return substRef;
2560-
}
2561-
2562-
Type Type::substOpaqueTypesWithUnderlyingTypes(
2563-
ModuleDecl *modulePerformingSubstitution) const {
2564-
ReplaceOpaqueTypesWithUnderlyingTypes replacer(modulePerformingSubstitution);
2565-
return subst(replacer, replacer,
2566-
SubstFlags::SubstituteOpaqueArchetypes
2567-
// TODO(opaque): Currently lowered types always get opaque types
2568-
// substituted out of them. When we support opaque type resilience
2569-
// this won't be true anymore and we'll need to handle
2570-
// opaque type substitution in SILType::subst.
2571-
| SubstFlags::AllowLoweredTypes);
2572-
}
2573-
25742463
CanNestedArchetypeType NestedArchetypeType::getNew(
25752464
const ASTContext &Ctx,
25762465
ArchetypeType *Parent,

branches/tensorflow/lib/SIL/SILFunctionType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,8 @@ SILFunctionType::substGenericArgs(SILModule &silModule,
24982498
LookupConformanceFn conformances) {
24992499
if (!isPolymorphic()) return CanSILFunctionType(this);
25002500
SILTypeSubstituter substituter(silModule, subs, conformances,
2501-
getGenericSignature(), false);
2501+
getGenericSignature(),
2502+
/*shouldSubstituteOpaqueTypes*/ false);
25022503
return substituter.substSILFunctionType(CanSILFunctionType(this));
25032504
}
25042505

0 commit comments

Comments
 (0)