Swift: Add test containing local declarations.

This commit is contained in:
Mathias Vorreiter Pedersen 2022-05-26 09:06:13 +01:00
Родитель da90440ea3
Коммит b715a6b63b
2 изменённых файлов: 133 добавлений и 0 удалений

Просмотреть файл

@ -4785,3 +4785,99 @@ cfg.swift:
# 405| DeclRefExpr
#-----| -> TupleExpr
# 410| TBD (YieldStmt)
#-----| -> exit AccessorDecl (normal)
# 410| enter AccessorDecl
# 410| enter AccessorDecl
# 410| enter AccessorDecl
#-----| -> TBD (YieldStmt)
# 410| exit AccessorDecl
# 410| exit AccessorDecl
# 410| exit AccessorDecl
# 410| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 410| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 410| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 411| enter ConstructorDecl
#-----| -> DeclRefExpr
# 411| exit ConstructorDecl
# 411| exit ConstructorDecl (normal)
#-----| -> exit ConstructorDecl
# 412| DeclRefExpr
#-----| -> MemberRefExpr
# 412| MemberRefExpr
#-----| -> IntegerLiteralExpr
# 412| AssignExpr
#-----| -> ReturnStmt
# 412| IntegerLiteralExpr
#-----| -> AssignExpr
# 413| ReturnStmt
#-----| return -> exit ConstructorDecl (normal)
# 417| TBD (YieldStmt)
#-----| -> exit AccessorDecl (normal)
# 417| enter AccessorDecl
# 417| enter AccessorDecl
# 417| enter AccessorDecl
#-----| -> TBD (YieldStmt)
# 417| exit AccessorDecl
# 417| exit AccessorDecl
# 417| exit AccessorDecl
# 417| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 417| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 417| exit AccessorDecl (normal)
#-----| -> exit AccessorDecl
# 418| enter ConstructorDecl
#-----| -> DeclRefExpr
# 418| exit ConstructorDecl
# 418| exit ConstructorDecl (normal)
#-----| -> exit ConstructorDecl
# 419| DeclRefExpr
#-----| -> MemberRefExpr
# 419| MemberRefExpr
#-----| -> IntegerLiteralExpr
# 419| AssignExpr
#-----| -> ReturnStmt
# 419| IntegerLiteralExpr
#-----| -> AssignExpr
# 420| ReturnStmt
#-----| return -> exit ConstructorDecl (normal)

Просмотреть файл

@ -403,4 +403,41 @@ class Structors {
func dictionaryLiteral(x: Int, y: Int) -> [String: Int] {
return ["x": x, "y": y]
}
func localDeclarations() -> Int {
class MyLocalClass {
var x: Int
init() {
x = 10
}
}
struct MyLocalStruct {
var x: Int
init() {
x = 10
}
}
enum MyLocalEnum {
case A
case B
}
var myLocalVar : Int;
// Error: declaration is only valid at file scope
// extension Int {
// func myExtensionMethod() -> Int {
// return self
// }
// }
// protocol 'MyProtocol' cannot be nested inside another declaration
// protocol MyProtocol {
// func myMethod()
// }
return 0
}