// RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
// REQUIRES: asserts
protocol P{struct X{let a={class d:a{class B<b:a{#^A^#
Add test case for crash triggered in swift::ValueDecl::setType(swift::Type)
[SourceKit] Add test case for crash triggered in swift::ValueDecl::setType(swift::Type)

Stack trace:

```
found code completion token A at offset 175
swift-ide-test: /path/to/swift/lib/AST/Decl.cpp:1730: void swift::ValueDecl::setType(swift::Type): Assertion `!hasType() && "changing type of declaration"' failed.
8  swift-ide-test  0x0000000000b3695c swift::ValueDecl::setType(swift::Type) + 92
11 swift-ide-test  0x00000000009312b7 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 151
12 swift-ide-test  0x00000000009915b7 swift::TypeChecker::addImplicitDestructor(swift::ClassDecl*) + 311
17 swift-ide-test  0x00000000009312b7 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 151
20 swift-ide-test  0x0000000000978b9a swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 218
21 swift-ide-test  0x00000000009b0cfc swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 812
22 swift-ide-test  0x00000000009169fb swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 683
23 swift-ide-test  0x0000000000917aa0 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 112
24 swift-ide-test  0x0000000000917c49 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 265
26 swift-ide-test  0x000000000092c6e4 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 3940
27 swift-ide-test  0x0000000000b750fc swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, unsigned int, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 2908
28 swift-ide-test  0x0000000000b73aec swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 2252
29 swift-ide-test  0x000000000095355b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
32 swift-ide-test  0x000000000097d43e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
34 swift-ide-test  0x000000000097d334 swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 212
35 swift-ide-test  0x0000000000929771 swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) + 4929
36 swift-ide-test  0x000000000094f7a5 swift::TypeChecker::checkGenericParamList(swift::ArchetypeBuilder*, swift::GenericParamList*, swift::DeclContext*, bool, swift::GenericTypeResolver*) + 373
37 swift-ide-test  0x000000000095106f swift::TypeChecker::validateGenericSignature(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, std::function<bool (swift::ArchetypeBuilder&)>, bool&) + 143
38 swift-ide-test  0x0000000000951424 swift::TypeChecker::validateGenericTypeSignature(swift::NominalTypeDecl*) + 116
39 swift-ide-test  0x000000000092b8e1 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 353
44 swift-ide-test  0x00000000009312b7 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 151
45 swift-ide-test  0x00000000008fe9b2 swift::typeCheckCompletionDecl(swift::Decl*) + 1122
49 swift-ide-test  0x000000000085c263 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 307
50 swift-ide-test  0x000000000076b1e4 swift::CompilerInstance::performSema() + 3316
51 swift-ide-test  0x0000000000714977 main + 33239
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While type-checking 'd' at <INPUT-FILE>:3:28
2.	While resolving type a at [<INPUT-FILE>:3:48 - line:3:48] RangeText="a"
3.	While type-checking expression at [<INPUT-FILE>:3:27 - line:3:50] RangeText="{class d:a{class B<b:a{"
4.	While type-checking 'd' at <INPUT-FILE>:3:28
5.	While type-checking 'deinit' at <INPUT-FILE>:3:44
```
