File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -1676,7 +1676,11 @@ class Solution {
16761676 Type getContextualType (ASTNode anchor) const {
16771677 for (const auto &entry : contextualTypes) {
16781678 if (entry.first == anchor) {
1679- return simplifyType (entry.second .getType ());
1679+ // The contextual information record could contain the purpose
1680+ // without a type i.e. when the context is an optional-some or
1681+ // an invalid pattern binding.
1682+ if (auto contextualTy = entry.second .getType ())
1683+ return simplifyType (contextualTy);
16801684 }
16811685 }
16821686 return Type ();
Original file line number Diff line number Diff line change @@ -4372,7 +4372,15 @@ static bool diagnoseAmbiguityWithContextualType(
43724372 auto name = result->choices .front ().getName ();
43734373 auto contextualTy = solution.getContextualType (anchor);
43744374
4375- assert (contextualTy);
4375+ // In some situations `getContextualType` for a contextual type
4376+ // locator is going to return then empty type. This happens because
4377+ // e.g. optional-some patterns and patterns with incorrect type don't
4378+ // have a contextual type for initialization expression but use
4379+ // a conversion with contextual locator nevertheless to indicate
4380+ // the purpose. This doesn't affect non-ambiguity diagnostics
4381+ // because mismatches carry both `from` and `to` types.
4382+ if (!contextualTy)
4383+ return false ;
43764384
43774385 DE.diagnose (getLoc (anchor),
43784386 contextualTy->is <ProtocolType>()
Original file line number Diff line number Diff line change 1+ // RUN: not %target-swift-frontend %s -typecheck
2+
3+ protocol RawTokenKindSubset { }
4+
5+ struct Parser {
6+ func canRecoverTo< Subset: RawTokenKindSubset > ( anyIn subset: Subset . Type ) {
7+ if let ( kind, handle) = self . at ( anyIn: subset) {
8+ }
9+ }
10+
11+ func at( _ keyword: Int ) -> Bool { }
12+
13+ func at(
14+ < <<<<<< HEAD ( Note: diff markers are required for reproduction of the crash)
15+ ) -> Bool {
16+ =======
17+ ) -> Bool {
18+ >>>>>>> My commit message ( don't remove)
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments