Open
Description
Description
While tinkering with swift-syntax
I have changed the signature of the following method:
private func visitImpl<NodeType: SyntaxProtocol>(
_ node: Syntax,
_ nodeType: NodeType.Type,
_ visit: (NodeType) -> SyntaxVisitorContinueKind,
_ visitPost: (NodeType) -> Void
) {
let node = node.cast(NodeType.self)
let needsChildren = (visit(node) == .visitChildren)
// Avoid calling into visitChildren if possible.
if needsChildren && !node.raw.layoutView!.children.isEmpty {
visitChildren(node)
}
visitPost(node)
}
to variant without generics:
private func visitImpl(
_ node: Syntax,
_ nodeType: SyntaxProtocol.Type,
_ visit: (SyntaxProtocol) -> SyntaxVisitorContinueKind,
_ visitPost: (SyntaxProtocol) -> Void
) {
let node = node.cast(nodeType)
let needsChildren = (visit(node) == .visitChildren)
// Avoid calling into visitChildren if possible.
if needsChildren && !node.raw.layoutView!.children.isEmpty {
visitChildren(node)
}
visitPost(node)
}
I then immediately receive "error: fatalError" with "The compiler is unable to type-check this expression in reasonable time"
Steps to reproduce
- clone https://github.com/art-divin/swift-syntax/ and checkout branch "resolve-compilation-time-issues" with commit
16c35c5ffb529185adf1af8f0d3fe38c96b89ecb
- cd into cloned directory
- swift build to see
error: fatalError
or use Xcode to seeThe compiler is unable to type-check this expression in reasonable time
Expected behavior
Code should compile
Environment
- Swift compiler version info swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
- Xcode version info Xcode 15.0.1 (Build version 15A507)
- Deployment target: Target: arm64-apple-macosx14.0