mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
NCGenerics: break cycle with SuperclassTypeRequest
With NoncopyableGenerics, we get a cycle involving
`SuperclassTypeRequest` with this program:
public struct RawMarkupHeader {}
final class RawMarkup: ManagedBuffer<RawMarkupHeader, RawMarkup> { }
Because we generally don't support the following kind of relationship:
class Base<T: P>: P {}
class Derived: Base<Derived> {}
This commit works around the root-cause, which is that Derived's
synthesized conformance to Copyable gets superceded by the inherited one
from Base. Instead of recording conformances in the ConformanceLookup
table at all, create builtin conformances on the fly, since classes
cannot be conditionally Copyable or Escapable.
This commit is contained in:
@@ -1157,6 +1157,19 @@ public:
|
||||
return getBuiltinConformanceKind() == BuiltinConformanceKind::Missing;
|
||||
}
|
||||
|
||||
bool isInvalid() const {
|
||||
switch (getBuiltinConformanceKind()) {
|
||||
case BuiltinConformanceKind::Synthesized:
|
||||
return false;
|
||||
case BuiltinConformanceKind::Missing:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
SourceLoc getLoc() const {
|
||||
return SourceLoc();
|
||||
}
|
||||
|
||||
/// Get any requirements that must be satisfied for this conformance to apply.
|
||||
llvm::Optional<ArrayRef<Requirement>>
|
||||
getConditionalRequirementsIfAvailable() const {
|
||||
@@ -1191,6 +1204,10 @@ public:
|
||||
llvm_unreachable("builtin-conformances never have associated types");
|
||||
}
|
||||
|
||||
bool hasWitness(ValueDecl *requirement) const {
|
||||
llvm_unreachable("builtin-conformances never have requirement witnesses");
|
||||
}
|
||||
|
||||
/// Retrieve the type witness and type decl (if one exists)
|
||||
/// for the given associated type.
|
||||
TypeWitnessAndDecl
|
||||
@@ -1199,6 +1216,10 @@ public:
|
||||
llvm_unreachable("builtin-conformances never have associated types");
|
||||
}
|
||||
|
||||
Witness getWitness(ValueDecl *requirement) const {
|
||||
llvm_unreachable("builtin-conformances never have requirement witnesses");
|
||||
}
|
||||
|
||||
/// Given that the requirement signature of the protocol directly states
|
||||
/// that the given dependent type must conform to the given protocol,
|
||||
/// return its associated conformance.
|
||||
|
||||
Reference in New Issue
Block a user