File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -654,7 +654,7 @@ extension Parser {
654654 throwsKeyword = throwsKw
655655 }
656656
657- if throwsKeyword != nil && self . at ( . leftParen) {
657+ if throwsKeyword != nil && self . at ( . leftParen) && experimentalFeatures . contains ( . typedThrows ) {
658658 thrownType = parseThrownType ( )
659659 }
660660
Original file line number Diff line number Diff line change @@ -29,4 +29,7 @@ extension Parser.ExperimentalFeatures {
2929
3030 /// Whether to enable the parsing of 'then' statements.
3131 public static let thenStatements = Self ( rawValue: 1 << 1 )
32+
33+ /// Whether to enable the parsing of typed throws.
34+ public static let typedThrows = Self ( rawValue: 1 << 2 )
3235}
Original file line number Diff line number Diff line change @@ -893,15 +893,17 @@ final class DeclarationTests: ParserTestCase {
893893
894894 func testTypedThrows( ) {
895895 assertParse (
896- " func test() throws(any Error) -> Int { } "
896+ " func test() throws(any Error) -> Int { } " ,
897+ experimentalFeatures: [ . typedThrows]
897898 )
898899
899900 assertParse (
900901 """
901902 struct X {
902903 init() throws(any Error) { }
903904 }
904- """
905+ """ ,
906+ experimentalFeatures: [ . typedThrows]
905907 )
906908 }
907909
Original file line number Diff line number Diff line change 1010//
1111//===----------------------------------------------------------------------===//
1212
13- @_spi ( RawSyntax) import SwiftParser
13+ @_spi ( RawSyntax) @ _spi ( ExperimentalLanguageFeatures ) import SwiftParser
1414@_spi ( RawSyntax) import SwiftSyntax
1515import XCTest
1616
@@ -309,11 +309,18 @@ final class TypeTests: ParserTestCase {
309309 assertParse (
310310 """
311311 { () throws(PosixError) -> Void in }
312- """
312+ """ ,
313+ experimentalFeatures: [ . typedThrows]
313314 )
314315
315- assertParse ( " typealias T = () throws(PosixError) -> Void " )
316+ assertParse (
317+ " typealias T = () throws(PosixError) -> Void " ,
318+ experimentalFeatures: [ . typedThrows]
319+ )
316320
317- assertParse ( " [() throws(PosixError) -> Void]() " )
321+ assertParse (
322+ " [() throws(PosixError) -> Void]() " ,
323+ experimentalFeatures: [ . typedThrows]
324+ )
318325 }
319326}
You can’t perform that action at this time.
0 commit comments