Skip to content

Commit 057bd73

Browse files
committed
Change to new syntax in run-custom-args
And fine tune distinction of ^ as postfix or infix operator
1 parent d5cee7c commit 057bd73

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,10 +1711,11 @@ object Parsers {
17111711
})
17121712
else if in.isIdent(nme.UPARROW)
17131713
&& (in.lookahead.token == LBRACE
1714-
|| !canStartInfixTypeTokens.contains(in.lookahead.token))
1714+
|| !canStartInfixTypeTokens.contains(in.lookahead.token)
1715+
|| in.lookahead.lineOffset > 0)
17151716
// Disambiguation: a `^` is treated as a postfix operator meaning `^{any}`
1716-
// if followed by `{` or newline, or any other token that cannot start
1717-
// an infix type. Otherwise it is treated as an infix operator.
1717+
// if followed by `{` or a new line (significant or not), or a token that
1718+
// cannot start an infix type. Otherwise it is treated as an infix operator.
17181719
then
17191720
val upArrowStart = in.offset
17201721
in.nextToken()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test:
2+
var x = 0
3+
type FreshContext = String^
4+
x += 1
5+
6+
inline def ctx(using c: String) = c

tests/run-custom-args/captures/minicheck.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ abstract class Ctx:
8383
def run: Run
8484
def detached: DetachedContext
8585

86-
type Context = {*} Ctx
86+
type Context = Ctx^
8787

8888
abstract class DetachedContext extends Ctx:
8989
def outer: DetachedContext
@@ -110,9 +110,9 @@ object NoContext extends FreshCtx(-1):
110110
owner = NoSymbol
111111
scope = EmptyScope
112112

113-
type FreshContext = {*} FreshCtx
113+
type FreshContext = FreshCtx^
114114

115-
inline def ctx(using c: Context): {c} Ctx = c
115+
inline def ctx(using c: Context): Ctx^{c} = c
116116

117117
// !cc! it does not work if ctxStack is an Array[FreshContext] instead.
118118
var ctxStack = Array.tabulate(16)(new FreshCtx(_))

0 commit comments

Comments
 (0)