Skip to content

Commit e912eeb

Browse files
committed
[CS] Use the resolved type in NonOptionalUnwrapFailure::diagnoseAsError
Diagnostics can outlive the ConstraintSystem itself if we have a diagnostic transaction for e.g `typeCheckParameterDefault`, make sure we don't try to use a solver-allocated type as an argument.
1 parent 2b05212 commit e912eeb

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3880,7 +3880,8 @@ bool NonOptionalUnwrapFailure::diagnoseAsError() {
38803880
diagnostic = diag::invalid_force_unwrap;
38813881

38823882
auto range = getSourceRange();
3883-
emitDiagnostic(diagnostic, BaseType).highlight(range).fixItRemove(range.End);
3883+
emitDiagnostic(diagnostic, resolveType(BaseType))
3884+
.highlight(range).fixItRemove(range.End);
38843885
return true;
38853886
}
38863887

validation-test/compiler_crashers_2/b33dbab8ed3643.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"swift::TypeBase::computeCanonicalType()"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
func a (Int -> Int = { $0 func b( () = {}? ) func b {
4+
/ 1

0 commit comments

Comments
 (0)