@@ -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
@@ -1590,8 +1587,8 @@ object Parsers {
15901587 /** Same as [[typ ]], but if this results in a wildcard it emits a syntax error and
15911588 * returns a tree for type `Any` instead.
15921589 */
1593- def toplevelTyp (intoOK : IntoOK = IntoOK . No , inContextBound : Boolean = false ): Tree =
1594- rejectWildcardType(typ(intoOK, inContextBound))
1590+ def toplevelTyp (inContextBound : Boolean = false ): Tree =
1591+ rejectWildcardType(typ(inContextBound))
15951592
15961593 private def getFunction (tree : Tree ): Option [Function ] = tree match {
15971594 case Parens (tree1) => getFunction(tree1)
@@ -1656,21 +1653,12 @@ object Parsers {
16561653 * | `(' [ FunArgType {`,' FunArgType } ] `)'
16571654 * | '(' [ TypedFunParam {',' TypedFunParam } ')'
16581655 * MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
1659- * IntoType ::= [‘into’] IntoTargetType
1660- * | ‘( IntoType ‘)’
1661- * IntoTargetType ::= Type
1662- * | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
16631656 */
1664- def typ (intoOK : IntoOK = IntoOK . No , inContextBound : Boolean = false ): Tree =
1657+ def typ (inContextBound : Boolean = false ): Tree =
16651658 val start = in.offset
16661659 var imods = Modifiers ()
16671660 val erasedArgs : ListBuffer [Boolean ] = ListBuffer ()
16681661
1669- def nestedIntoOK (token : Int ) =
1670- if token == TLARROW then IntoOK .No
1671- else if intoOK == IntoOK .Nested then IntoOK .Yes
1672- else intoOK
1673-
16741662 def functionRest (params : List [Tree ]): Tree =
16751663 val paramSpan = Span (start, in.lastOffset)
16761664 atSpan(start, in.offset) {
@@ -1699,9 +1687,8 @@ object Parsers {
16991687 else
17001688 accept(ARROW )
17011689
1702- def resType () = typ(nestedIntoOK(token))
17031690 val resultType =
1704- if isPure then capturesAndResult(resType ) else resType ()
1691+ if isPure then capturesAndResult(typ ) else typ ()
17051692 if token == TLARROW then
17061693 for case ValDef (_, tpt, _) <- params do
17071694 if isByNameType(tpt) then
@@ -1736,12 +1723,6 @@ object Parsers {
17361723 syntaxError(ErasedTypesCanOnlyBeFunctionTypes (), implicitKwPos(start))
17371724 t
17381725
1739- def isIntoPrefix : Boolean =
1740- intoOK == IntoOK .Yes
1741- && in.isIdent(nme.into)
1742- && in.featureEnabled(Feature .into)
1743- && canStartTypeTokens.contains(in.lookahead.token)
1744-
17451726 def convertToElem (t : Tree ): Tree = t match
17461727 case ByNameTypeTree (t1) =>
17471728 syntaxError(ByNameParameterNotSupported (t), t.span)
@@ -1778,32 +1759,6 @@ object Parsers {
17781759 funArgType()
17791760 commaSeparatedRest(t, funArg)
17801761 accept(RPAREN )
1781-
1782- val intoAllowed =
1783- intoOK == IntoOK .Yes
1784- && args.lengthCompare(1 ) == 0
1785- && (! canFollowSimpleTypeTokens.contains(in.token) || followingIsVararg())
1786- val byNameAllowed = in.isArrow || isPureArrow
1787-
1788- def sanitize (arg : Tree ): Tree = arg match
1789- case ByNameTypeTree (t) if ! byNameAllowed =>
1790- syntaxError(ByNameParameterNotSupported (t), t.span)
1791- t
1792- case PrefixOp (id @ Ident (tpnme.into), t) if ! intoAllowed =>
1793- syntaxError(em " no `into` modifier allowed here " , id.span)
1794- t
1795- case Parens (t) =>
1796- cpy.Parens (arg)(sanitize(t))
1797- case arg : FunctionWithMods =>
1798- val body1 = sanitize(arg.body)
1799- if body1 eq arg.body then arg
1800- else FunctionWithMods (arg.args, body1, arg.mods, arg.erasedParams).withSpan(arg.span)
1801- case Function (args, res) if ! intoAllowed =>
1802- cpy.Function (arg)(args, sanitize(res))
1803- case arg =>
1804- arg
1805- val args1 = args.mapConserve(sanitize)
1806-
18071762 if in.isArrow || isPureArrow || erasedArgs.contains(true ) then
18081763 functionRest(args)
18091764 else
@@ -1830,8 +1785,6 @@ object Parsers {
18301785 typ()
18311786 else if in.token == INDENT then
18321787 enclosed(INDENT , typ())
1833- else if isIntoPrefix then
1834- PrefixOp (typeIdent(), typ(IntoOK .Nested ))
18351788 else
18361789 typeRest(infixType(inContextBound))
18371790 end typ
@@ -2218,9 +2171,7 @@ object Parsers {
22182171 * | `=>' Type
22192172 * | `->' [CaptureSet] Type
22202173 */
2221- val funArgType : () => Tree =
2222- () => paramTypeOf(() => typ(IntoOK .Yes ))
2223- // We allow intoOK and filter out afterwards in typ()
2174+ val funArgType : () => Tree = () => paramTypeOf(typ)
22242175
22252176 /** ParamType ::= ParamValueType
22262177 * | `=>' ParamValueType
@@ -2229,11 +2180,9 @@ object Parsers {
22292180 def paramType (): Tree = paramTypeOf(paramValueType)
22302181
22312182 /** ParamValueType ::= Type [`*']
2232- * | IntoType
2233- * | ‘(’ IntoType ‘)’ `*'
22342183 */
22352184 def paramValueType (): Tree =
2236- val t = toplevelTyp(IntoOK . Yes )
2185+ val t = toplevelTyp()
22372186 if isIdent(nme.raw.STAR ) then
22382187 if ! t.isInstanceOf [Parens ] && isInto(t) then
22392188 syntaxError(
@@ -3541,7 +3490,7 @@ object Parsers {
35413490 */
35423491 def contextTypes (paramOwner : ParamOwner , numLeadParams : Int , impliedMods : Modifiers ): List [ValDef ] =
35433492 typesToParams(
3544- commaSeparated(() => paramTypeOf(() => toplevelTyp() )),
3493+ commaSeparated(() => paramTypeOf(toplevelTyp)),
35453494 paramOwner, numLeadParams, impliedMods)
35463495
35473496 def typesToParams (tps : List [Tree ], paramOwner : ParamOwner , numLeadParams : Int , impliedMods : Modifiers ): List [ValDef ] =
0 commit comments