File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -1753,6 +1753,13 @@ Expr *CallExpr::getDirectCallee() const {
17531753 continue ;
17541754 }
17551755
1756+ // Explicit specializations are currently invalid for function calls, but
1757+ // look through them for better recovery.
1758+ if (auto *spec = dyn_cast<UnresolvedSpecializeExpr>(fn)) {
1759+ fn = spec->getSubExpr ();
1760+ continue ;
1761+ }
1762+
17561763 return fn;
17571764 }
17581765}
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift -swift-version 6
2+
3+ // rdar://145593552 - Make sure we don't crash.
4+ func foo( _ x: Int ) { } // expected-note {{'foo' declared here}}
5+ foo < Void > ( " " )
6+ // expected-error@-1 {{cannot explicitly specialize global function 'foo'}}
7+ // expected-error@-2 {{cannot convert value of type 'String' to expected argument type 'Int'}}
8+
9+ func bar( x: Int = 0 ) { } // expected-note {{'bar(x:)' declared here}}
10+ bar < Void > ( ) // expected-error {{cannot explicitly specialize global function 'bar(x:)'}}
Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ enum E {
1212 case A < UndefinedTy > ( ) : // expected-error {{cannot find type 'UndefinedTy' in scope}}
1313 // expected-note@-1 {{while parsing this '<' as a type parameter bracket}}
1414 // expected-error@-2 {{cannot specialize non-generic type 'E'}}
15- // expected-error@-3 {{cannot call value of non-function type 'E' }}
15+ // expected-error@-3 {{enum case 'A' has no associated values }}
1616 break
1717 case B < Int > ( ) : // expected-error {{cannot specialize non-generic type 'E'}}
18- // expected-error@-1 {{cannot call value of non-function type 'E' }}
18+ // expected-error@-1 {{enum case 'B' has no associated values }}
1919 break
2020 default :
2121 break ;
@@ -28,10 +28,10 @@ func testE(e: E) {
2828 case E . A < UndefinedTy > ( ) : // expected-error {{cannot find type 'UndefinedTy' in scope}}
2929 // expected-note@-1 {{while parsing this '<' as a type parameter bracket}}
3030 // expected-error@-2 {{cannot specialize non-generic type 'E'}}
31- // expected-error@-3 {{cannot call value of non-function type 'E' }}
31+ // expected-error@-3 {{enum case 'A' has no associated values }}
3232 break
3333 case E . B < Int > ( ) : // expected-error {{cannot specialize non-generic type 'E'}}
34- // expected-error@-1 {{cannot call value of non-function type 'E' }}
34+ // expected-error@-1 {{enum case 'B' has no associated values }}
3535 break
3636 case . C( ) : // expected-error {{pattern with associated values does not match enum case 'C'}}
3737 // expected-note@-1 {{remove associated values to make the pattern match}} {{10-12=}}
You can’t perform that action at this time.
0 commit comments