1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
|
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only > %t/cpp-parser.ast.raw
// Filter out any addresses in the dump, since they can differ.
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -enable-experimental-feature SwiftParser -enable-experimental-feature ParserASTGen)
// REQUIRES: executable_test
// REQUIRES: swift_swift_parser
// -enable-experimental-feature requires an asserts build
// REQUIRES: asserts
// rdar://116686158
// UNSUPPORTED: asan
// NB: Ridiculous formatting to test that we do not include leading trivia in locations.
import
Swift
import typealias Swift.Codable
import enum Swift.Optional
import struct Swift.Array
import class Swift.KeyPath
import protocol Swift.Sequence
import func Swift.max
import var Swift._playgroundPrintHook
func
test1
(
y
x: Int, fn: (Int) -> Int
)
async
throws
->
Int {
return 0
}
func test2(y: Int = 0, oi: Int? = nil) -> Int {
let x =
y
return x
}
func test3(_ b: inout Bool) {
// b = true
}
func test4(_ i: _const Int) {
}
func test5(_ value: Any) { }
func test6<T>(t: T) where T: Proto1 {}
func test7() {
var binding1 = 0, binding2 = ""
}
func test8(_: Int) {}
func test9() -> Int { 0 }
func testVars() {
var a = 0
var b: Int = 0
var c, d: Int
var e, f: Int, g, h, i: String
let j: Int = 0, k: String = ""
var l: Int { 0 }
var m: Int { get { 0 } }
var n: Int {
get { return m }
set {}
}
var o: Int = 0 {
willSet {
n = newValue
}
}
var p: Int {
get { return 0 }
set(foo) {
o = foo
}
}
var q: Int = 0 {
didSet(old) {
p = old
}
}
var r: Int {
_read { yield q }
_modify { yield &q }
}
var s: Int {
get async throws { return 0 }
}
}
struct TestVars {
var a = 0
var b: Int = 0
var c, d: Int
var e, f: Int, g, h, i: String
let j: Int = 0, k: String = ""
var l: Int { 0 }
var m: Int { get { 0 } }
var n: Int {
get { return m }
set {}
}
var o: Int = 0 {
willSet {
n = newValue
}
}
var p: Int {
get { return 0 }
set(foo) {
o = foo
}
}
var q: Int = 0 {
didSet(old) {
p = old
}
}
var r: Int {
_read { yield q }
_modify { yield &q }
}
var s: Int {
get async throws { return 0 }
}
}
extension TestVars {
var inExt: Int { return 0 }
}
struct TestSubscripts {
subscript(x: Int) -> Int {
0
}
subscript(y x: Int) -> Int {
get {
return 0
}
set(x) {}
}
}
protocol Proto1 {}
protocol Proto2 {}
protocol
Proto3
<
A,
B
>: Proto1 where Self: Proto2 {
associatedtype
A where B: Proto1
associatedtype B: Equatable
=
Int
func method(_ b: Bool)
}
typealias
Alias<T>
=
String where T: Proto1
enum
Enum<T>: Int, Proto1 where T: Proto1 {
case
a
=
1
case b = 2,
c
func method(_ b: Bool) {}
}
enum WithPayload {
case a(
b: Int
), c(
d: Bool = false
)
}
struct
Struct
<
T1:
Proto1,
T2:
Proto2
>
:
Proto1, Proto2, @unchecked Sendable
where
T1
:
Proto3,
T1.A
==
Int
{
/*static*/ func method(_ b: Bool) {}
}
class
Class<T>: Proto1 where T: Proto3 {
func method(_ b: Bool) {}
deinit {
if true {}
}
init?<U>(_ u: U) where U: Proto1 {
if true {}
}
init!(i: Int) {}
}
actor
Actor<T>: Proto1 where T: Proto1 {
func method(_ b: Bool) {}
}
extension
Class: Proto2 where T: Proto1 {
func method2(_ b: Bool) {}
}
prefix
operator ⎭^-^⎭
infix
operator
~^-^~
:
AdditionPrecedence
postfix
operator ⎩^-^⎩
precedencegroup Precedence1 {
}
precedencegroup Precedence2 {
lowerThan: BitwiseShiftPrecedence, MultiplicationPrecedence
higherThan: Precedence1, AdditionPrecedence
associativity: left
assignment: true
}
struct TestStruct {
func method(arg: Int, _ c: Int) {}
// FIXME: Compute 'static' location
// static var shared = TestStruct()
// func testUnresolvedMember1() -> Self {
// return .shared
// }
//
// FIXME: Compute 'static' location
// static func instance(arg: Int) -> TestStruct { return TestStruct() }
}
|