// RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts

// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing

protocol a:b
protocol b:Range<b>

Add test case for crash triggered in swift::ProtocolDecl::requiresClassSlow()
[swiftc] Add test case for crash triggered in swift::ProtocolDecl::requiresClassSlow()

Stack trace:

```
swift: /path/to/swift/lib/AST/Decl.cpp:2492: bool swift::ProtocolDecl::requiresClassSlow(): Assertion `isInheritedProtocolsValid() || isBeingTypeChecked()' failed.
8  swift           0x0000000000fd6c73 swift::ProtocolDecl::requiresClassSlow() + 403
9  swift           0x0000000000e61448 swift::TypeChecker::containsProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*, swift::OptionSet<swift::ConformanceCheckFlags, unsigned int>, swift::ProtocolConformance**, swift::SourceLoc) + 168
10 swift           0x0000000000ef37bc swift::constraints::ConstraintSystem::simplifyConformsToConstraint(swift::Type, swift::ProtocolDecl*, swift::constraints::ConstraintKind, swift::constraints::ConstraintLocatorBuilder, unsigned int) + 172
11 swift           0x0000000000ef3613 swift::constraints::ConstraintSystem::matchExistentialTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 211
12 swift           0x0000000000ef46e7 swift::constraints::ConstraintSystem::simplifyRestrictedConstraint(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::TypeMatchKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 2375
13 swift           0x0000000000ef149c swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::TypeMatchKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 9932
14 swift           0x0000000000efb39f swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 639
15 swift           0x0000000000e9c6c7 swift::constraints::ConstraintSystem::addConstraint(swift::constraints::Constraint*, bool, bool) + 23
16 swift           0x0000000000e1f8d3 swift::TypeChecker::typesSatisfyConstraint(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::DeclContext*) + 131
18 swift           0x0000000000e61595 swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*, swift::OptionSet<swift::ConformanceCheckFlags, unsigned int>, swift::ProtocolConformance**, swift::SourceLoc) + 133
19 swift           0x0000000000e577e1 swift::TypeChecker::checkGenericArguments(swift::DeclContext*, swift::SourceLoc, swift::SourceLoc, swift::Type, swift::GenericSignature*, llvm::ArrayRef<swift::Type>) + 625
20 swift           0x0000000000e82cad swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType*, swift::SourceLoc, swift::DeclContext*, llvm::MutableArrayRef<swift::TypeLoc>, bool, swift::GenericTypeResolver*) + 589
21 swift           0x0000000000e82910 swift::TypeChecker::applyGenericArguments(swift::Type, swift::SourceLoc, swift::DeclContext*, swift::GenericIdentTypeRepr*, bool, swift::GenericTypeResolver*) + 448
25 swift           0x0000000000e82e6e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
27 swift           0x0000000000e83dd4 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
28 swift           0x0000000000e82d7a swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 42
29 swift           0x0000000000f11292 swift::IterativeTypeChecker::processResolveInheritedClauseEntry(std::pair<llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>, unsigned int>, llvm::function_ref<bool (swift::TypeCheckRequest)>) + 146
30 swift           0x0000000000f1051d swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 493
31 swift           0x0000000000f106a9 swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 889
32 swift           0x0000000000e2f340 swift::TypeChecker::resolveInheritedProtocols(swift::ProtocolDecl*) + 64
33 swift           0x0000000000f2e4a1 swift::ArchetypeBuilder::addConformanceRequirement(swift::ArchetypeBuilder::PotentialArchetype*, swift::ProtocolDecl*, swift::RequirementSource, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>&) + 225
36 swift           0x0000000000f2fdbf swift::ArchetypeBuilder::visitInherited(llvm::ArrayRef<swift::TypeLoc>, llvm::function_ref<bool (swift::Type, swift::SourceLoc)>) + 175
37 swift           0x0000000000f2e20b swift::ArchetypeBuilder::addAbstractTypeParamRequirements(swift::AbstractTypeParamDecl*, swift::ArchetypeBuilder::PotentialArchetype*, swift::RequirementSource::Kind, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>&) + 603
38 swift           0x0000000000f2df8c swift::ArchetypeBuilder::addGenericParameterRequirements(swift::GenericTypeParamDecl*) + 172
39 swift           0x0000000000e55907 swift::TypeChecker::checkGenericParamList(swift::ArchetypeBuilder*, swift::GenericParamList*, swift::DeclContext*, bool, swift::GenericTypeResolver*) + 391
40 swift           0x0000000000e5713f swift::TypeChecker::validateGenericSignature(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, std::function<bool (swift::ArchetypeBuilder&)>, bool&) + 143
41 swift           0x0000000000e574f4 swift::TypeChecker::validateGenericTypeSignature(swift::NominalTypeDecl*) + 116
42 swift           0x0000000000e32a60 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 1248
46 swift           0x0000000000e82e6e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
48 swift           0x0000000000e83dd4 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
49 swift           0x0000000000e82d7a swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 42
50 swift           0x0000000000f11292 swift::IterativeTypeChecker::processResolveInheritedClauseEntry(std::pair<llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>, unsigned int>, llvm::function_ref<bool (swift::TypeCheckRequest)>) + 146
51 swift           0x0000000000f1051d swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 493
52 swift           0x0000000000f106a9 swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 889
53 swift           0x0000000000e2f340 swift::TypeChecker::resolveInheritedProtocols(swift::ProtocolDecl*) + 64
54 swift           0x0000000000f2e4a1 swift::ArchetypeBuilder::addConformanceRequirement(swift::ArchetypeBuilder::PotentialArchetype*, swift::ProtocolDecl*, swift::RequirementSource, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>&) + 225
57 swift           0x0000000000f2fdbf swift::ArchetypeBuilder::visitInherited(llvm::ArrayRef<swift::TypeLoc>, llvm::function_ref<bool (swift::Type, swift::SourceLoc)>) + 175
58 swift           0x0000000000f2e20b swift::ArchetypeBuilder::addAbstractTypeParamRequirements(swift::AbstractTypeParamDecl*, swift::ArchetypeBuilder::PotentialArchetype*, swift::RequirementSource::Kind, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>&) + 603
59 swift           0x0000000000f2df8c swift::ArchetypeBuilder::addGenericParameterRequirements(swift::GenericTypeParamDecl*) + 172
60 swift           0x0000000000e55907 swift::TypeChecker::checkGenericParamList(swift::ArchetypeBuilder*, swift::GenericParamList*, swift::DeclContext*, bool, swift::GenericTypeResolver*) + 391
61 swift           0x0000000000e5713f swift::TypeChecker::validateGenericSignature(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, std::function<bool (swift::ArchetypeBuilder&)>, bool&) + 143
62 swift           0x0000000000e574f4 swift::TypeChecker::validateGenericTypeSignature(swift::NominalTypeDecl*) + 116
63 swift           0x0000000000e32a60 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 1248
66 swift           0x0000000000e37dc6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
67 swift           0x0000000000e04612 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1474
68 swift           0x0000000000caf3af swift::CompilerInstance::performSema() + 2975
70 swift           0x0000000000775047 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2487
71 swift           0x000000000076fc35 main + 2773
Stack dump:
0.	Program arguments: /path/to/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28209-swift-protocoldecl-requiresclassslow.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28209-swift-protocoldecl-requiresclassslow-9be302.o
1.	While type-checking 'a' at validation-test/compiler_crashers/28209-swift-protocoldecl-requiresclassslow.swift:8:1
2.	While resolving type b at [validation-test/compiler_crashers/28209-swift-protocoldecl-requiresclassslow.swift:8:12 - line:8:12] RangeText="b"
3.	While resolving type Range<b> at [validation-test/compiler_crashers/28209-swift-protocoldecl-requiresclassslow.swift:9:12 - line:9:19] RangeText="Range<b>"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
