@@ -1703,20 +1703,27 @@ object Parsers {
17031703
17041704 def refinedType () = refinedTypeRest(withType())
17051705
1706+ /** Disambiguation: a `^` is treated as a postfix operator meaning `^{any}`
1707+ * if followed by `{`, `->`, or `?->`,
1708+ * or followed by a new line (significant or not),
1709+ * or followed by a token that cannot start an infix type.
1710+ * Otherwise it is treated as an infix operator.
1711+ */
1712+ private def isTrailingUpArrow =
1713+ val ahead = in.lookahead
1714+ ahead.token == LBRACE
1715+ || ahead.isIdent(nme.PUREARROW )
1716+ || ahead.isIdent(nme.PURECTXARROW )
1717+ || ! canStartInfixTypeTokens.contains(ahead.token)
1718+ || ahead.lineOffset > 0
1719+
17061720 def refinedTypeRest (t : Tree ): Tree = {
17071721 argumentStart()
17081722 if in.isNestedStart then
17091723 refinedTypeRest(atSpan(startOffset(t)) {
17101724 RefinedTypeTree (rejectWildcardType(t), refinement(indentOK = true ))
17111725 })
1712- else if in.isIdent(nme.UPARROW )
1713- && (in.lookahead.token == LBRACE
1714- || ! canStartInfixTypeTokens.contains(in.lookahead.token)
1715- || in.lookahead.lineOffset > 0 )
1716- // Disambiguation: a `^` is treated as a postfix operator meaning `^{any}`
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.
1719- then
1726+ else if in.isIdent(nme.UPARROW ) && isTrailingUpArrow then
17201727 val upArrowStart = in.offset
17211728 in.nextToken()
17221729 def cs =
0 commit comments