@@ -970,29 +970,6 @@ object Parsers {
970970 isArrowIndent()
971971 else false
972972
973- /** Under captureChecking language import: is the following token sequence a
974- * capture set `{ref1, ..., refN}` followed by a token that can start a type?
975- */
976- def followingIsCaptureSet (): Boolean =
977- Feature .ccEnabled && {
978- val lookahead = in.LookaheadScanner ()
979- def followingIsTypeStart () =
980- lookahead.nextToken()
981- canStartInfixTypeTokens.contains(lookahead.token)
982- || lookahead.token == LBRACKET
983- def recur (): Boolean =
984- (lookahead.isIdent || lookahead.token == THIS ) && {
985- lookahead.nextToken()
986- if lookahead.token == COMMA then
987- lookahead.nextToken()
988- recur()
989- else
990- lookahead.token == RBRACE && followingIsTypeStart()
991- }
992- lookahead.nextToken()
993- if lookahead.token == RBRACE then followingIsTypeStart() else recur()
994- }
995-
996973 /* --------- OPERAND/OPERATOR STACK --------------------------------------- */
997974
998975 var opStack : List [OpInfo ] = Nil
@@ -1504,9 +1481,12 @@ object Parsers {
15041481 val paramSpan = Span (start, in.lastOffset)
15051482 atSpan(start, in.offset) {
15061483 var token = in.token
1484+ var isPure = false
15071485 if isPureArrow(nme.PUREARROW ) then
1486+ isPure = true
15081487 token = ARROW
15091488 else if isPureArrow(nme.PURECTXARROW ) then
1489+ isPure = true
15101490 token = CTXARROW
15111491 else if token == TLARROW then
15121492 if ! imods.flags.isEmpty || params.isEmpty then
@@ -1525,7 +1505,7 @@ object Parsers {
15251505 else
15261506 accept(ARROW )
15271507
1528- val resultType = capturesAndResult(typ)
1508+ val resultType = if isPure then capturesAndResult(typ) else typ( )
15291509 if token == TLARROW then
15301510 for case ValDef (_, tpt, _) <- params do
15311511 if isByNameType(tpt) then
@@ -1618,8 +1598,6 @@ object Parsers {
16181598 }
16191599 else { accept(TLARROW ); typ() }
16201600 }
1621- else if in.token == LBRACE && followingIsCaptureSet() then
1622- CapturingTypeTree (captureSet(), typ())
16231601 else if (in.token == INDENT ) enclosed(INDENT , typ())
16241602 else infixType()
16251603
@@ -1958,31 +1936,9 @@ object Parsers {
19581936 def paramTypeOf (core : () => Tree ): Tree =
19591937 if in.token == ARROW || isPureArrow(nme.PUREARROW ) then
19601938 val isImpure = in.token == ARROW
1961- val tp = atSpan(in.skipToken()) { ByNameTypeTree (capturesAndResult(core)) }
1939+ val tp = atSpan(in.skipToken()):
1940+ ByNameTypeTree (if isImpure then core() else capturesAndResult(core))
19621941 if isImpure && Feature .pureFunsEnabled then ImpureByNameTypeTree (tp) else tp
1963- else if in.token == LBRACE && followingIsCaptureSet() then
1964- val start = in.offset
1965- val cs = captureSet()
1966- val endCsOffset = in.lastOffset
1967- val startTpOffset = in.offset
1968- val tp = paramTypeOf(core)
1969- val tp1 = tp match
1970- case ImpureByNameTypeTree (tp1) =>
1971- syntaxError(em " explicit captureSet is superfluous for impure call-by-name type " , start)
1972- tp1
1973- case CapturingTypeTree (_, tp1 : ByNameTypeTree ) =>
1974- syntaxError(em " only one captureSet is allowed here " , start)
1975- tp1
1976- case _ : ByNameTypeTree if startTpOffset > endCsOffset =>
1977- report.warning(
1978- i """ Style: by-name `->` should immediately follow closing `}` of capture set
1979- |to avoid confusion with function type.
1980- |That is, `{c}-> T` instead of `{c} -> T`. """ ,
1981- source.atSpan(Span (startTpOffset, startTpOffset)))
1982- tp
1983- case _ =>
1984- tp
1985- CapturingTypeTree (cs, tp1)
19861942 else
19871943 core()
19881944
@@ -2069,8 +2025,6 @@ object Parsers {
20692025 def typeDependingOn (location : Location ): Tree =
20702026 if location.inParens then typ()
20712027 else if location.inPattern then rejectWildcardType(refinedType())
2072- else if in.token == LBRACE && followingIsCaptureSet() then
2073- CapturingTypeTree (captureSet(), infixType())
20742028 else infixType()
20752029
20762030/* ----------- EXPRESSIONS ------------------------------------------------ */
@@ -4218,10 +4172,7 @@ object Parsers {
42184172 val selfTpt =
42194173 if in.isColon then
42204174 in.nextToken()
4221- if in.token == LBRACE && followingIsCaptureSet() then
4222- CapturingTypeTree (captureSet(), infixType())
4223- else
4224- infixType()
4175+ infixType()
42254176 else
42264177 if selfName == nme.WILDCARD then accept(COLONfollow )
42274178 TypeTree ()
0 commit comments