@@ -1550,7 +1550,8 @@ object Parsers {
1550
1550
/** Same as [[typ ]], but if this results in a wildcard it emits a syntax error and
1551
1551
* returns a tree for type `Any` instead.
1552
1552
*/
1553
- def toplevelTyp (intoOK : IntoOK = IntoOK .No ): Tree = rejectWildcardType(typ(intoOK))
1553
+ def toplevelTyp (intoOK : IntoOK = IntoOK .No , inContextBound : Boolean = false ): Tree =
1554
+ rejectWildcardType(typ(intoOK, inContextBound))
1554
1555
1555
1556
private def getFunction (tree : Tree ): Option [Function ] = tree match {
1556
1557
case Parens (tree1) => getFunction(tree1)
@@ -1606,7 +1607,7 @@ object Parsers {
1606
1607
* IntoTargetType ::= Type
1607
1608
* | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
1608
1609
*/
1609
- def typ (intoOK : IntoOK = IntoOK .No ): Tree =
1610
+ def typ (intoOK : IntoOK = IntoOK .No , inContextBound : Boolean = false ): Tree =
1610
1611
val start = in.offset
1611
1612
var imods = Modifiers ()
1612
1613
val erasedArgs : ListBuffer [Boolean ] = ListBuffer ()
@@ -1755,7 +1756,7 @@ object Parsers {
1755
1756
val tuple = atSpan(start):
1756
1757
makeTupleOrParens(args.mapConserve(convertToElem))
1757
1758
typeRest :
1758
- infixTypeRest :
1759
+ infixTypeRest(inContextBound) :
1759
1760
refinedTypeRest :
1760
1761
withTypeRest :
1761
1762
annotTypeRest :
@@ -1778,7 +1779,7 @@ object Parsers {
1778
1779
else if isIntoPrefix then
1779
1780
PrefixOp (typeIdent(), typ(IntoOK .Nested ))
1780
1781
else
1781
- typeRest(infixType())
1782
+ typeRest(infixType(inContextBound ))
1782
1783
end typ
1783
1784
1784
1785
private def makeKindProjectorTypeDef (name : TypeName ): TypeDef = {
@@ -1833,13 +1834,13 @@ object Parsers {
1833
1834
/** InfixType ::= RefinedType {id [nl] RefinedType}
1834
1835
* | RefinedType `^` // under capture checking
1835
1836
*/
1836
- def infixType (): Tree = infixTypeRest(refinedType())
1837
+ def infixType (inContextBound : Boolean = false ): Tree = infixTypeRest(inContextBound) (refinedType())
1837
1838
1838
- def infixTypeRest (t : Tree , operand : Location => Tree = refinedTypeFn): Tree =
1839
+ def infixTypeRest (inContextBound : Boolean = false )( t : Tree , operand : Location => Tree = refinedTypeFn): Tree =
1839
1840
infixOps(t, canStartInfixTypeTokens, operand, Location .ElseWhere , ParseKind .Type ,
1840
1841
isOperator = ! followingIsVararg()
1841
1842
&& ! isPureArrow
1842
- && ! (isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`))
1843
+ && ! (isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound )
1843
1844
&& nextCanFollowOperator(canStartInfixTypeTokens))
1844
1845
1845
1846
/** RefinedType ::= WithType {[nl] Refinement} [`^` CaptureSet]
@@ -2230,7 +2231,7 @@ object Parsers {
2230
2231
2231
2232
/** ContextBound ::= Type [`as` id] */
2232
2233
def contextBound (pname : TypeName ): Tree =
2233
- val t = toplevelTyp()
2234
+ val t = toplevelTyp(inContextBound = true )
2234
2235
val ownName =
2235
2236
if isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) then
2236
2237
in.nextToken()
@@ -4208,7 +4209,7 @@ object Parsers {
4208
4209
else constrApp() match
4209
4210
case parent : Apply => parent :: moreConstrApps()
4210
4211
case parent if in.isIdent && newSyntaxAllowed =>
4211
- infixTypeRest(parent, _ => annotType1()) :: Nil
4212
+ infixTypeRest()( parent, _ => annotType1()) :: Nil
4212
4213
case parent => parent :: moreConstrApps()
4213
4214
4214
4215
// The term parameters and parent references */
0 commit comments