[swiftc (35 vs. 5431)] Add crasher in swift::constraints::ConstraintSystem::getType
Add test case for crash triggered in `swift::constraints::ConstraintSystem::getType`.
Current number of unresolved compiler crashers: 35 (5431 resolved)
/cc @rudkx - just wanted to let you know that this crasher caused an assertion failure for the assertion `hasType(E) && "Expected type to have been set!"` added on 2016-12-11 by you in commit 1139f872 :-)
Assertion failure in [`lib/Sema/ConstraintSystem.h (line 1464)`](https://github.com/apple/swift/blob/229e2c339a60f46b6de2d35e532fc1f0c8d30371/lib/Sema/ConstraintSystem.h#L1464):
```
Assertion `hasType(E) && "Expected type to have been set!"' failed.
When executing: swift::Type swift::constraints::ConstraintSystem::getType(const swift::Expr *) const
```
Assertion context:
```c++
E->getType()->isEqual(ExprTypes.find(E)->second)) &&
"Mismatched types!");
return ExprTypes.find(E)->second;
}
/// Cache the type of the expression argument and return that same
/// argument.
template <typename T>
T *cacheType(T *E) {
assert(E->getType() && "Expected a type!");
setType(E, E->getType());
```
Stack trace:
```
0 0x0000000003896a88 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/path/to/swift/bin/swift+0x3896a88)
1 0x00000000038971c6 SignalHandler(int) (/path/to/swift/bin/swift+0x38971c6)
2 0x00007fce42f3c3e0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x113e0)
3 0x00007fce418a2428 gsignal /build/glibc-Qz8a69/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
4 0x00007fce418a402a abort /build/glibc-Qz8a69/glibc-2.23/stdlib/abort.c:91:0
5 0x00007fce4189abd7 __assert_fail_base /build/glibc-Qz8a69/glibc-2.23/assert/assert.c:92:0
6 0x00007fce4189ac82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
7 0x00000000011b3921 swift::constraints::ConstraintSystem::getType(swift::Expr const*) const (/path/to/swift/bin/swift+0x11b3921)
8 0x00000000012fb254 (anonymous namespace)::ConstraintOptimizer::walkToExprPre(swift::Expr*) (/path/to/swift/bin/swift+0x12fb254)
9 0x00000000013a5568 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) (/path/to/swift/bin/swift+0x13a5568)
10 0x00000000013a42bb swift::Expr::walk(swift::ASTWalker&) (/path/to/swift/bin/swift+0x13a42bb)
11 0x00000000012f3140 swift::constraints::ConstraintSystem::optimizeConstraints(swift::Expr*) (/path/to/swift/bin/swift+0x12f3140)
12 0x0000000001216747 swift::constraints::ConstraintSystem::performMemberLookup(swift::constraints::ConstraintKind, swift::DeclName, swift::Type, swift::FunctionRefKind, swift::constraints::ConstraintLocator*, bool) (/path/to/swift/bin/swift+0x1216747)
13 0x00000000011da783 (anonymous namespace)::FailureDiagnosis::diagnoseConstraintFailure() (/path/to/swift/bin/swift+0x11da783)
14 0x00000000011d7396 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) (/path/to/swift/bin/swift+0x11d7396)
15 0x00000000011de0bd swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) (/path/to/swift/bin/swift+0x11de0bd)
16 0x000000000127f058 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) (/path/to/swift/bin/swift+0x127f058)
17 0x0000000001282686 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) (/path/to/swift/bin/swift+0x1282686)
18 0x0000000001199c5e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) (/path/to/swift/bin/swift+0x1199c5e)
19 0x0000000001199476 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) (/path/to/swift/bin/swift+0x1199476)
20 0x00000000011af320 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) (/path/to/swift/bin/swift+0x11af320)
21 0x0000000000f0b076 swift::CompilerInstance::performSema() (/path/to/swift/bin/swift+0xf0b076)
22 0x00000000004a4606 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/path/to/swift/bin/swift+0x4a4606)
23 0x00000000004638c7 main (/path/to/swift/bin/swift+0x4638c7)
24 0x00007fce4188d830 __libc_start_main /build/glibc-Qz8a69/glibc-2.23/csu/../csu/libc-start.c:325:0
25 0x0000000000460f69 _start (/path/to/swift/bin/swift+0x460f69)
```