@@ -78,9 +78,6 @@ object Parsers {
7878 enum ParseKind :
7979 case Expr , Type , Pattern
8080
81- enum IntoOK :
82- case Yes , No , Nested
83-
8481 type StageKind = Int
8582 object StageKind {
8683 val None = 0
@@ -1582,8 +1579,8 @@ object Parsers {
15821579 /** Same as [[typ ]], but if this results in a wildcard it emits a syntax error and
15831580 * returns a tree for type `Any` instead.
15841581 */
1585- def toplevelTyp (intoOK : IntoOK = IntoOK . No , inContextBound : Boolean = false ): Tree =
1586- rejectWildcardType(typ(intoOK, inContextBound))
1582+ def toplevelTyp (inContextBound : Boolean = false ): Tree =
1583+ rejectWildcardType(typ(inContextBound))
15871584
15881585 private def getFunction (tree : Tree ): Option [Function ] = tree match {
15891586 case Parens (tree1) => getFunction(tree1)
@@ -1642,21 +1639,12 @@ object Parsers {
16421639 * | `(' [ FunArgType {`,' FunArgType } ] `)'
16431640 * | '(' [ TypedFunParam {',' TypedFunParam } ')'
16441641 * MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
1645- * IntoType ::= [‘into’] IntoTargetType
1646- * | ‘( IntoType ‘)’
1647- * IntoTargetType ::= Type
1648- * | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
16491642 */
1650- def typ (intoOK : IntoOK = IntoOK . No , inContextBound : Boolean = false ): Tree =
1643+ def typ (inContextBound : Boolean = false ): Tree =
16511644 val start = in.offset
16521645 var imods = Modifiers ()
16531646 val erasedArgs : ListBuffer [Boolean ] = ListBuffer ()
16541647
1655- def nestedIntoOK (token : Int ) =
1656- if token == TLARROW then IntoOK .No
1657- else if intoOK == IntoOK .Nested then IntoOK .Yes
1658- else intoOK
1659-
16601648 def functionRest (params : List [Tree ]): Tree =
16611649 val paramSpan = Span (start, in.lastOffset)
16621650 atSpan(start, in.offset) {
@@ -1685,9 +1673,8 @@ object Parsers {
16851673 else
16861674 accept(ARROW )
16871675
1688- def resType () = typ(nestedIntoOK(token))
16891676 val resultType =
1690- if isPure then capturesAndResult(resType ) else resType ()
1677+ if isPure then capturesAndResult(typ ) else typ ()
16911678 if token == TLARROW then
16921679 for case ValDef (_, tpt, _) <- params do
16931680 if isByNameType(tpt) then
@@ -1722,12 +1709,6 @@ object Parsers {
17221709 syntaxError(ErasedTypesCanOnlyBeFunctionTypes (), implicitKwPos(start))
17231710 t
17241711
1725- def isIntoPrefix : Boolean =
1726- intoOK == IntoOK .Yes
1727- && in.isIdent(nme.into)
1728- && in.featureEnabled(Feature .into)
1729- && canStartTypeTokens.contains(in.lookahead.token)
1730-
17311712 def convertToElem (t : Tree ): Tree = t match
17321713 case ByNameTypeTree (t1) =>
17331714 syntaxError(ByNameParameterNotSupported (t), t.span)
@@ -1764,32 +1745,6 @@ object Parsers {
17641745 funArgType()
17651746 commaSeparatedRest(t, funArg)
17661747 accept(RPAREN )
1767-
1768- val intoAllowed =
1769- intoOK == IntoOK .Yes
1770- && args.lengthCompare(1 ) == 0
1771- && (! canFollowSimpleTypeTokens.contains(in.token) || followingIsVararg())
1772- val byNameAllowed = in.isArrow || isPureArrow
1773-
1774- def sanitize (arg : Tree ): Tree = arg match
1775- case ByNameTypeTree (t) if ! byNameAllowed =>
1776- syntaxError(ByNameParameterNotSupported (t), t.span)
1777- t
1778- case PrefixOp (id @ Ident (tpnme.into), t) if ! intoAllowed =>
1779- syntaxError(em " no `into` modifier allowed here " , id.span)
1780- t
1781- case Parens (t) =>
1782- cpy.Parens (arg)(sanitize(t))
1783- case arg : FunctionWithMods =>
1784- val body1 = sanitize(arg.body)
1785- if body1 eq arg.body then arg
1786- else FunctionWithMods (arg.args, body1, arg.mods, arg.erasedParams).withSpan(arg.span)
1787- case Function (args, res) if ! intoAllowed =>
1788- cpy.Function (arg)(args, sanitize(res))
1789- case arg =>
1790- arg
1791- val args1 = args.mapConserve(sanitize)
1792-
17931748 if in.isArrow || isPureArrow || erasedArgs.contains(true ) then
17941749 functionRest(args)
17951750 else
@@ -1817,8 +1772,6 @@ object Parsers {
18171772 typ()
18181773 else if in.token == INDENT then
18191774 enclosed(INDENT , typ())
1820- else if isIntoPrefix then
1821- PrefixOp (typeIdent(), typ(IntoOK .Nested ))
18221775 else
18231776 typeRest(infixType(inContextBound))
18241777 end typ
@@ -2228,9 +2181,7 @@ object Parsers {
22282181 * | `=>' Type
22292182 * | `->' [CaptureSet] Type
22302183 */
2231- val funArgType : () => Tree =
2232- () => paramTypeOf(() => typ(IntoOK .Yes ))
2233- // We allow intoOK and filter out afterwards in typ()
2184+ val funArgType : () => Tree = () => paramTypeOf(typ)
22342185
22352186 /** ParamType ::= ParamValueType
22362187 * | `=>' ParamValueType
@@ -2239,11 +2190,9 @@ object Parsers {
22392190 def paramType (): Tree = paramTypeOf(paramValueType)
22402191
22412192 /** ParamValueType ::= Type [`*']
2242- * | IntoType
2243- * | ‘(’ IntoType ‘)’ `*'
22442193 */
22452194 def paramValueType (): Tree =
2246- val t = toplevelTyp(IntoOK . Yes )
2195+ val t = toplevelTyp()
22472196 if isIdent(nme.raw.STAR ) then
22482197 if ! t.isInstanceOf [Parens ] && isInto(t) then
22492198 syntaxError(
@@ -3573,7 +3522,7 @@ object Parsers {
35733522 */
35743523 def contextTypes (paramOwner : ParamOwner , numLeadParams : Int , impliedMods : Modifiers ): List [ValDef ] =
35753524 typesToParams(
3576- commaSeparated(() => paramTypeOf(() => toplevelTyp() )),
3525+ commaSeparated(() => paramTypeOf(toplevelTyp)),
35773526 paramOwner, numLeadParams, impliedMods)
35783527
35793528 def typesToParams (tps : List [Tree ], paramOwner : ParamOwner , numLeadParams : Int , impliedMods : Modifiers ): List [ValDef ] =
0 commit comments