File tree 3 files changed +21
-4
lines changed
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 {
1753
1753
continue ;
1754
1754
}
1755
1755
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
+
1756
1763
return fn;
1757
1764
}
1758
1765
}
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 {
12
12
case A < UndefinedTy > ( ) : // expected-error {{cannot find type 'UndefinedTy' in scope}}
13
13
// expected-note@-1 {{while parsing this '<' as a type parameter bracket}}
14
14
// 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 }}
16
16
break
17
17
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 }}
19
19
break
20
20
default :
21
21
break ;
@@ -28,10 +28,10 @@ func testE(e: E) {
28
28
case E . A < UndefinedTy > ( ) : // expected-error {{cannot find type 'UndefinedTy' in scope}}
29
29
// expected-note@-1 {{while parsing this '<' as a type parameter bracket}}
30
30
// 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 }}
32
32
break
33
33
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 }}
35
35
break
36
36
case . C( ) : // expected-error {{pattern with associated values does not match enum case 'C'}}
37
37
// 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