Skip to content

Make TypeBuildable expressible as TypeAnnotation #547

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 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public extension ExpressibleAsSyntaxBuildable {
return SwitchCaseList([self])
}
}
public protocol ExpressibleAsTypeBuildable: ExpressibleAsReturnClause, ExpressibleAsTypeInitializerClause {
public protocol ExpressibleAsTypeBuildable: ExpressibleAsReturnClause, ExpressibleAsTypeInitializerClause, ExpressibleAsTypeAnnotation {
func createTypeBuildable() -> TypeBuildable
}
public extension ExpressibleAsTypeBuildable {
Expand All @@ -97,6 +97,10 @@ public extension ExpressibleAsTypeBuildable {
func createTypeInitializerClause() -> TypeInitializerClause {
return TypeInitializerClause(value: self)
}
/// Conformance to ExpressibleAsTypeAnnotation
func createTypeAnnotation() -> TypeAnnotation {
return TypeAnnotation(type: self)
}
}
public protocol ExpressibleAsCodeBlockItem: ExpressibleAsCodeBlockItemList {
func createCodeBlockItem() -> CodeBlockItem
Expand Down Expand Up @@ -1737,14 +1741,10 @@ public extension ExpressibleAsPrimaryAssociatedTypeClause {
return createPrimaryAssociatedTypeClause()
}
}
public protocol ExpressibleAsSimpleTypeIdentifier: ExpressibleAsTypeAnnotation, ExpressibleAsTypeExpr, ExpressibleAsTypeBuildable {
public protocol ExpressibleAsSimpleTypeIdentifier: ExpressibleAsTypeExpr, ExpressibleAsTypeBuildable {
func createSimpleTypeIdentifier() -> SimpleTypeIdentifier
}
public extension ExpressibleAsSimpleTypeIdentifier {
/// Conformance to ExpressibleAsTypeAnnotation
func createTypeAnnotation() -> TypeAnnotation {
return TypeAnnotation(type: self)
}
/// Conformance to ExpressibleAsTypeExpr
func createTypeExpr() -> TypeExpr {
return TypeExpr(type: self)
Expand All @@ -1769,26 +1769,18 @@ public extension ExpressibleAsClassRestrictionType {
return createClassRestrictionType()
}
}
public protocol ExpressibleAsArrayType: ExpressibleAsTypeAnnotation, ExpressibleAsTypeBuildable {
public protocol ExpressibleAsArrayType: ExpressibleAsTypeBuildable {
func createArrayType() -> ArrayType
}
public extension ExpressibleAsArrayType {
/// Conformance to ExpressibleAsTypeAnnotation
func createTypeAnnotation() -> TypeAnnotation {
return TypeAnnotation(type: self)
}
func createTypeBuildable() -> TypeBuildable {
return createArrayType()
}
}
public protocol ExpressibleAsDictionaryType: ExpressibleAsTypeAnnotation, ExpressibleAsTypeBuildable {
public protocol ExpressibleAsDictionaryType: ExpressibleAsTypeBuildable {
func createDictionaryType() -> DictionaryType
}
public extension ExpressibleAsDictionaryType {
/// Conformance to ExpressibleAsTypeAnnotation
func createTypeAnnotation() -> TypeAnnotation {
return TypeAnnotation(type: self)
}
func createTypeBuildable() -> TypeBuildable {
return createDictionaryType()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
'ArrayElementList': [
'ArrayExpr'
],
'ArrayType': [
'TypeAnnotation'
],
'CodeBlockItemList': [
'CodeBlock'
],
'DeclBuildable': [
'CodeBlockItem',
'MemberDeclListItem'
],
'DictionaryType': [
'TypeAnnotation'
],
'ExprBuildable': [
'CodeBlockItem',
'InitializerClause'
Expand All @@ -39,7 +33,6 @@
'TupleExprElement'
],
'SimpleTypeIdentifier': [
'TypeAnnotation',
'TypeExpr'
],
'StmtBuildable': [
Expand All @@ -52,7 +45,8 @@
],
'TypeBuildable': [
'ReturnClause',
'TypeInitializerClause'
'TypeInitializerClause',
'TypeAnnotation'
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Child {
SequenceExpr {
MemberAccessExpr(base: varName, name: "leadingTrivia")
BinaryOperatorExpr("??")
ArrayExpr(elements: [])
ArrayExpr {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ let SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES: [String: [String]] = [
"ArrayElementList": [
"ArrayExpr",
],
"ArrayType": [
"TypeAnnotation",
],
"CodeBlockItemList": [
"CodeBlock",
],
"DeclBuildable": [
"CodeBlockItem",
"MemberDeclListItem",
],
"DictionaryType": [
"TypeAnnotation",
],
"ExprBuildable": [
"CodeBlockItem",
"InitializerClause",
Expand All @@ -53,7 +47,6 @@ let SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES: [String: [String]] = [
"TupleExprElement",
],
"SimpleTypeIdentifier": [
"TypeAnnotation",
"TypeExpr",
],
"StmtBuildable": [
Expand All @@ -67,5 +60,6 @@ let SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES: [String: [String]] = [
"TypeBuildable": [
"ReturnClause",
"TypeInitializerClause",
"TypeAnnotation",
],
]