@@ -1702,20 +1702,27 @@ object Parsers {
1702
1702
1703
1703
def refinedType () = refinedTypeRest(withType())
1704
1704
1705
+ /** Disambiguation: a `^` is treated as a postfix operator meaning `^{any}`
1706
+ * if followed by `{`, `->`, or `?->`,
1707
+ * or followed by a new line (significant or not),
1708
+ * or followed by a token that cannot start an infix type.
1709
+ * Otherwise it is treated as an infix operator.
1710
+ */
1711
+ private def isTrailingUpArrow =
1712
+ val ahead = in.lookahead
1713
+ ahead.token == LBRACE
1714
+ || ahead.isIdent(nme.PUREARROW )
1715
+ || ahead.isIdent(nme.PURECTXARROW )
1716
+ || ! canStartInfixTypeTokens.contains(ahead.token)
1717
+ || ahead.lineOffset > 0
1718
+
1705
1719
def refinedTypeRest (t : Tree ): Tree = {
1706
1720
argumentStart()
1707
1721
if in.isNestedStart then
1708
1722
refinedTypeRest(atSpan(startOffset(t)) {
1709
1723
RefinedTypeTree (rejectWildcardType(t), refinement(indentOK = true ))
1710
1724
})
1711
- else if in.isIdent(nme.UPARROW )
1712
- && (in.lookahead.token == LBRACE
1713
- || ! canStartInfixTypeTokens.contains(in.lookahead.token)
1714
- || in.lookahead.lineOffset > 0 )
1715
- // Disambiguation: a `^` is treated as a postfix operator meaning `^{any}`
1716
- // if followed by `{` or a new line (significant or not), or a token that
1717
- // cannot start an infix type. Otherwise it is treated as an infix operator.
1718
- then
1725
+ else if in.isIdent(nme.UPARROW ) && isTrailingUpArrow then
1719
1726
val upArrowStart = in.offset
1720
1727
in.nextToken()
1721
1728
def cs =
0 commit comments