-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Added unimplemented expression cases in the ASTPrinter #64667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// RUN: %target-swift-frontend -print-ast -disable-availability-checking %s 2>&1 | %FileCheck %s | ||
|
||
func fetch() async throws -> String { | ||
} | ||
// CHECK: internal func fetch() async throws -> String { | ||
// CHECK: } | ||
|
||
let fn = { (x: Int) in | ||
} | ||
// CHECK: @_hasInitialValue internal let fn: (_ x: Int) -> () = { (x: Int) in | ||
// CHECK: } | ||
|
||
let fn1 = {} | ||
// CHECK: @_hasInitialValue internal let fn1: () -> () = { () in | ||
// CHECK: } | ||
|
||
let fn2: (Int) -> Void = { x in } | ||
// CHECK: @_hasInitialValue internal let fn2: (Int) -> Void = { (x: Int) in | ||
// CHECK: } | ||
|
||
let fn3: (Int, Int) -> Void = { x, y in } | ||
// CHECK: @_hasInitialValue internal let fn3: (Int, Int) -> Void = { (x: Int, y: Int) in | ||
// CHECK: } | ||
|
||
let fn4: (Int, Int) -> Void = { (x, y) in } | ||
// CHECK: @_hasInitialValue internal let fn4: (Int, Int) -> Void = { (x: Int, y: Int) in | ||
// CHECK: } | ||
|
||
let fn5 = { (x: String, y: Int) in } | ||
// CHECK: @_hasInitialValue internal let fn5: (_ x: String, _ y: Int) -> () = { (x: String, y: Int) in | ||
// CHECK: } | ||
|
||
let fn6: (Int) -> Int = { x -> Int in x } | ||
// CHECK: @_hasInitialValue internal let fn6: (Int) -> Int = { (x: Int) -> Int in | ||
// CHECK: return x | ||
// CHECK: } | ||
|
||
let fn7: (Int, Int) -> Int = { (x, y) -> Int in x + y } | ||
// CHECK: @_hasInitialValue internal let fn7: (Int, Int) -> Int = { (x: Int, y: Int) -> Int in | ||
// CHECK: return x + y | ||
// CHECK: } | ||
|
||
let fn8 = { (x: Int, y: Int) -> Int in x + y } | ||
// CHECK: @_hasInitialValue internal let fn8: (_ x: Int, _ y: Int) -> Int = { (x: Int, y: Int) -> Int in | ||
// CHECK: return x + y | ||
// CHECK: } | ||
|
||
let fn9 = { () -> Int in 0 } | ||
// CHECK: @_hasInitialValue internal let fn9: () -> Int = { () -> Int in | ||
// CHECK: return 0 | ||
// CHECK: } | ||
|
||
let fn10 = { () in } | ||
// CHECK: @_hasInitialValue internal let fn10: () -> () = { () in | ||
// CHECK: } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// RUN: %target-swift-frontend -print-ast -disable-objc-attr-requires-foundation-module -enable-objc-interop %s 2>&1 | %FileCheck %s | ||
|
||
var x = 0.0 | ||
|
||
type(of: x) | ||
// CHECK: type(of: x) | ||
|
||
class A { | ||
var x: Int = 3 | ||
init() { | ||
} | ||
} | ||
|
||
class B: A { | ||
override init() { | ||
super.init() | ||
super.x = 2; | ||
} | ||
} | ||
// CHECK: @_inheritsConvenienceInitializers internal class B : A { | ||
// CHECK: override internal init() { | ||
// CHECK: super.init() | ||
// CHECK: super.x = 2 | ||
// CHECK: } | ||
// CHECK: @objc deinit { | ||
// CHECK: } | ||
// CHECK: } | ||
|
||
var a: [Int] = [1, 3, 2]; | ||
|
||
for i in 0...2 { | ||
a[i] = i; | ||
} | ||
// CHECK: for i in 0 ... 2 { | ||
// CHECK: a[i] = i | ||
// CHECK: } | ||
|
||
let y: Double = 0 as Double | ||
// CHECK: @_hasInitialValue internal let y: Double = 0 as Double | ||
|
||
var stringToInt: Int? = Int("1"); | ||
|
||
var forceInt: Int = stringToInt! | ||
// CHECK: @_hasInitialValue internal var forceInt: Int = stringToInt! | ||
|
||
var prefixUnaryExpr: Int = -a[1]; | ||
// CHECK: @_hasInitialValue internal var prefixUnaryExpr: Int = -a[1] | ||
var postfixUnaryExpr: Int = stringToInt! | ||
// CHECK: @_hasInitialValue internal var postfixUnaryExpr: Int = stringToInt! | ||
|
||
class MyID { | ||
var num = 1 | ||
} | ||
|
||
class SomeJSON { | ||
var id: MyID? | ||
} | ||
|
||
let cnt = SomeJSON().id?.num | ||
// CHECK: @_hasInitialValue internal let cnt: Int? = SomeJSON().id?.num | ||
|
||
struct User { | ||
let name: String | ||
let email: String | ||
let address: Address? | ||
let role: Role | ||
} | ||
|
||
struct Address { | ||
let street: String | ||
} | ||
|
||
enum Role { | ||
case admin | ||
case member | ||
case guest | ||
|
||
var permissions: [Permission] { | ||
switch self { | ||
case .admin: | ||
return [.create, .read, .update, .delete] | ||
case .member: | ||
return [.create, .read] | ||
case .guest: | ||
return [.read] | ||
} | ||
} | ||
} | ||
|
||
enum Permission { | ||
case create | ||
case read | ||
case update | ||
case delete | ||
} | ||
|
||
var user = User( | ||
name: "Swift", | ||
email: "http://www.swift.org", | ||
address: nil, | ||
role: .admin | ||
) | ||
|
||
|
||
let userRoleKeyPath = \User.role | ||
// CHECK: @_hasInitialValue internal let userRoleKeyPath: KeyPath<User, Role> = \User | ||
Comment on lines
+105
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be checking for Some other key path tests you could add are e.g: // Multiple members
\X.y.z
// Optional chaining
\X.y?.z
// Optional force
\X.y!
\X.y!.z
// Dot self
\X.self
// Subscript
\X[0]
\X.[0]
\X.y[0]
// Tuple
\(Int, Int).0
\(x: Int, y: Int).x |
||
|
||
let role = user[keyPath: userRoleKeyPath] | ||
// CHECK: @_hasInitialValue internal let role: Role = user[keyPath: userRoleKeyPath] | ||
|
||
struct FakeColor: _ExpressibleByColorLiteral { | ||
init(_colorLiteralRed: Float, green: Float, blue: Float, alpha: Float) {} | ||
} | ||
typealias _ColorLiteralType = FakeColor | ||
|
||
let myColor = #colorLiteral(red: 0.292, green: 0.081, blue: 0.6, alpha: 255) | ||
// CHECK: @_hasInitialValue internal let myColor: FakeColor = #colorLiteral(red: 0.292, green: 0.081, blue: 0.6, alpha: 255) | ||
|
||
enum FileNames { | ||
static let main = FileNames.file(#file) | ||
// CHECK: @_hasInitialValue internal static let main: FileNames = FileNames.file(#file) | ||
case file(String) | ||
} | ||
|
||
class C { | ||
@objc | ||
var foo = 0 | ||
} | ||
|
||
func foo(_ x: AnyObject) { | ||
let y = x.foo | ||
} | ||
// CHECK: internal func foo(_ x: AnyObject) { | ||
// CHECK: @_hasInitialValue let y: Int? = x.foo | ||
// CHECK: } | ||
|
||
struct S { | ||
func foo() {} | ||
} | ||
let fn = S.foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.