[Runtime] Always fail to find a conditional conformance at runtime.

Proper evaluation of conditional conformances at runtime (e.g., as part of
dynamic casting) is too large to tackle in the Swift 4.1 timeframe. For now,
record that a conformance is conditional in the protocol conformance record,
and always return "does not conform" to such types.

Fixes rdar://problem/35761301.
This commit is contained in:
Doug Gregor
2017-12-04 16:51:52 -08:00
parent 59ee97f4af
commit 4f8edeb913
8 changed files with 77 additions and 10 deletions

View File

@@ -84,6 +84,10 @@ template<> void ProtocolConformanceRecord::dump() const {
printf("witness table accessor %s\n",
symbolName((const void *)(uintptr_t)getWitnessTableAccessor()));
break;
case ProtocolConformanceReferenceKind::ConditionalWitnessTableAccessor:
printf("conditional witness table accessor %s\n",
symbolName((const void *)(uintptr_t)getWitnessTableAccessor()));
break;
}
}
#endif
@@ -136,8 +140,12 @@ const {
return getStaticWitnessTable();
case ProtocolConformanceReferenceKind::WitnessTableAccessor:
// FIXME: this needs information about conditional conformances.
return getWitnessTableAccessor()(type, nullptr, 0);
case ProtocolConformanceReferenceKind::ConditionalWitnessTableAccessor:
// FIXME: this needs to query the conditional requirements to form the
// array of witness tables to pass along to the accessor.
return nullptr;
}
swift_runtime_unreachable(
@@ -558,6 +566,7 @@ swift::swift_conformsToProtocol(const Metadata * const type,
break;
case ProtocolConformanceReferenceKind::WitnessTableAccessor:
case ProtocolConformanceReferenceKind::ConditionalWitnessTableAccessor:
// If the record provides a dependent witness table accessor,
// cache the result for the instantiated type metadata.
C.cacheSuccess(type, P, record.getWitnessTable(type));