@@ -63,3 +63,65 @@ func overload() -> String { "" }
63
63
64
64
let _: _ ? = overload ( )
65
65
let _ = overload ( ) as _ ?
66
+
67
+ struct Bar < T, U>
68
+ where T: ExpressibleByIntegerLiteral , U: ExpressibleByIntegerLiteral {
69
+ var t : T
70
+ var u : U
71
+ func frobnicate( ) -> Bar {
72
+ return Bar ( t: 42 , u: 42 )
73
+ }
74
+ }
75
+
76
+ extension Bar {
77
+ func frobnicate2( ) -> Bar < _ , _ > { // expected-error {{placeholder type not allowed here}}
78
+ return Bar ( t: 42 , u: 42 )
79
+ }
80
+ func frobnicate3( ) -> Bar {
81
+ return Bar < _ , _ > ( t: 42 , u: 42 )
82
+ }
83
+ func frobnicate4( ) -> Bar < _ , _ > { // expected-error {{placeholder type not allowed here}}
84
+ return Bar < _ , _ > ( t: 42 , u: 42 )
85
+ }
86
+ func frobnicate5( ) -> Bar < _ , U > { // expected-error {{placeholder type not allowed here}}
87
+ return Bar ( t: 42 , u: 42 )
88
+ }
89
+ func frobnicate6( ) -> Bar {
90
+ return Bar < _ , U > ( t: 42 , u: 42 )
91
+ }
92
+ func frobnicate7( ) -> Bar < _ , _ > { // expected-error {{placeholder type not allowed here}}
93
+ return Bar < _ , U > ( t: 42 , u: 42 )
94
+ }
95
+ func frobnicate8( ) -> Bar < _ , U > { // expected-error {{placeholder type not allowed here}}
96
+ return Bar < _ , _ > ( t: 42 , u: 42 )
97
+ }
98
+ }
99
+
100
+ protocol P { }
101
+ struct ConformsToP : P { }
102
+
103
+ func somePlaceholder( ) -> some _ { ConformsToP ( ) } // expected-error {{placeholder type not allowed here}}
104
+
105
+ // FIXME: We should probably have better diagnostics for these situations--the user probably meant to use implicit member syntax
106
+ let _: Int = _ ( ) // expected-error {{type of expression is ambiguous without more context}}
107
+ let _: ( ) -> Int = { _ ( ) } // expected-error {{unable to infer closure type in the current context}}
108
+ let _: Int = _. init ( ) // expected-error {{could not infer type for placeholder}}
109
+ let _: ( ) -> Int = { _. init ( ) } // expected-error {{could not infer type for placeholder}}
110
+
111
+ func returnsInt( ) -> Int { _ ( ) } // expected-error {{type of expression is ambiguous without more context}}
112
+ func returnsIntClosure( ) -> ( ) -> Int { { _ ( ) } } // expected-error {{unable to infer closure type in the current context}}
113
+ func returnsInt2( ) -> Int { _. init ( ) } // expected-error {{could not infer type for placeholder}}
114
+ func returnsIntClosure2( ) -> ( ) -> Int { { _. init ( ) } } // expected-error {{could not infer type for placeholder}}
115
+
116
+ let _: Int . Type = _ // expected-error {{'_' can only appear in a pattern or on the left side of an assignment}}
117
+ let _: Int . Type = _. self
118
+
119
+ struct SomeSuperLongAndComplexType { }
120
+ func getSomething( ) -> SomeSuperLongAndComplexType ? { . init( ) }
121
+ let something : _ ! = getSomething ( )
122
+
123
+ extension Array where Element == Int {
124
+ static var staticMember : Self { [ ] }
125
+ }
126
+
127
+ let _ = [ _ ] . staticMember
0 commit comments