// This source file is part of the Swift.org open source project
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -parse
struct A{struct B<T:A
class B:A
class A:B{
init()

Add 💥 (😢 → 57, 😀 → 5099) in swift::TypeBase::getDesugaredType(…)
Add 💥 (😢 → 57, 😀 → 5099) in swift::TypeBase::getDesugaredType(…)

Add test case for crash triggered in `swift::TypeBase::getDesugaredType(…)`.

<details>
<summary>Stack trace:</summary>
```
4  swift           0x0000000001120000 swift::TypeBase::getDesugaredType() + 32
6  swift           0x0000000000eb7f0b swift::TypeChecker::addImplicitConstructors(swift::NominalTypeDecl*) + 635
7  swift           0x0000000000eabd2e swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) + 5854
8  swift           0x0000000000ead058 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 376
9  swift           0x000000000110b61b swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 2667
10 swift           0x0000000001109ebb swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 2491
11 swift           0x0000000000eeea4b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
14 swift           0x0000000000f1ff6e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
16 swift           0x0000000000f20ec4 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
17 swift           0x0000000000f1fe60 swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 192
18 swift           0x0000000000eaba5a swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) + 5130
19 swift           0x0000000000ead058 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 376
20 swift           0x000000000110b61b swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 2667
21 swift           0x0000000001109ebb swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 2491
22 swift           0x0000000000eeea4b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
25 swift           0x0000000000f1ff6e 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           0x0000000000f20ec4 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
28 swift           0x0000000000f1fe60 swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 192
29 swift           0x0000000000eaba5a swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) + 5130
30 swift           0x0000000000eea415 swift::TypeChecker::checkGenericParamList(swift::ArchetypeBuilder*, swift::GenericParamList*, swift::GenericSignature*, bool, swift::GenericTypeResolver*) + 389
31 swift           0x0000000000eebc77 swift::TypeChecker::validateGenericSignature(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, std::function<bool (swift::ArchetypeBuilder&)>, bool&) + 135
32 swift           0x0000000000eec7df swift::TypeChecker::validateGenericTypeSignature(swift::GenericTypeDecl*) + 111
33 swift           0x0000000000ead04b swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 363
38 swift           0x0000000000eb2686 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
39 swift           0x0000000000ed47e2 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026
40 swift           0x0000000000c616a9 swift::CompilerInstance::performSema() + 3289
42 swift           0x00000000007d8419 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2857
43 swift           0x00000000007a4448 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28346-swift-typebase-getdesugaredtype.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28346-swift-typebase-getdesugaredtype-cd880b.o
1.	While type-checking 'A' at validation-test/compiler_crashers/28346-swift-typebase-getdesugaredtype.swift:9:1
2.	While resolving type A at [validation-test/compiler_crashers/28346-swift-typebase-getdesugaredtype.swift:9:21 - line:9:21] RangeText="A"
3.	While resolving type B at [validation-test/compiler_crashers/28346-swift-typebase-getdesugaredtype.swift:11:9 - line:11:9] RangeText="B"
<unknown>:0: error: unable to execute command: Segmentation fault
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
</details>
