@@ -1534,7 +1534,8 @@ object Parsers {
1534
1534
/** Same as [[typ ]], but if this results in a wildcard it emits a syntax error and
1535
1535
* returns a tree for type `Any` instead.
1536
1536
*/
1537
- def toplevelTyp (intoOK : IntoOK = IntoOK .No ): Tree = rejectWildcardType(typ(intoOK))
1537
+ def toplevelTyp (intoOK : IntoOK = IntoOK .No , inContextBound : Boolean = false ): Tree =
1538
+ rejectWildcardType(typ(intoOK, inContextBound))
1538
1539
1539
1540
private def getFunction (tree : Tree ): Option [Function ] = tree match {
1540
1541
case Parens (tree1) => getFunction(tree1)
@@ -1594,7 +1595,7 @@ object Parsers {
1594
1595
* IntoTargetType ::= Type
1595
1596
* | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
1596
1597
*/
1597
- def typ (intoOK : IntoOK = IntoOK .No ): Tree =
1598
+ def typ (intoOK : IntoOK = IntoOK .No , inContextBound : Boolean = false ): Tree =
1598
1599
val start = in.offset
1599
1600
var imods = Modifiers ()
1600
1601
val erasedArgs : ListBuffer [Boolean ] = ListBuffer ()
@@ -1743,7 +1744,7 @@ object Parsers {
1743
1744
val tuple = atSpan(start):
1744
1745
makeTupleOrParens(args.mapConserve(convertToElem))
1745
1746
typeRest :
1746
- infixTypeRest :
1747
+ infixTypeRest(inContextBound) :
1747
1748
refinedTypeRest :
1748
1749
withTypeRest :
1749
1750
annotTypeRest :
@@ -1772,7 +1773,7 @@ object Parsers {
1772
1773
else if isIntoPrefix then
1773
1774
PrefixOp (typeIdent(), typ(IntoOK .Nested ))
1774
1775
else
1775
- typeRest(infixType())
1776
+ typeRest(infixType(inContextBound ))
1776
1777
end typ
1777
1778
1778
1779
private def makeKindProjectorTypeDef (name : TypeName ): TypeDef = {
@@ -1827,13 +1828,13 @@ object Parsers {
1827
1828
/** InfixType ::= RefinedType {id [nl] RefinedType}
1828
1829
* | RefinedType `^` // under capture checking
1829
1830
*/
1830
- def infixType (): Tree = infixTypeRest(refinedType())
1831
+ def infixType (inContextBound : Boolean = false ): Tree = infixTypeRest(inContextBound) (refinedType())
1831
1832
1832
- def infixTypeRest (t : Tree , operand : Location => Tree = refinedTypeFn): Tree =
1833
+ def infixTypeRest (inContextBound : Boolean = false )( t : Tree , operand : Location => Tree = refinedTypeFn): Tree =
1833
1834
infixOps(t, canStartInfixTypeTokens, operand, Location .ElseWhere , ParseKind .Type ,
1834
1835
isOperator = ! followingIsVararg()
1835
1836
&& ! isPureArrow
1836
- && ! (isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`))
1837
+ && ! (isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound )
1837
1838
&& nextCanFollowOperator(canStartInfixTypeTokens))
1838
1839
1839
1840
/** RefinedType ::= WithType {[nl] Refinement} [`^` CaptureSet]
@@ -2224,7 +2225,7 @@ object Parsers {
2224
2225
2225
2226
/** ContextBound ::= Type [`as` id] */
2226
2227
def contextBound (pname : TypeName ): Tree =
2227
- val t = toplevelTyp()
2228
+ val t = toplevelTyp(inContextBound = true )
2228
2229
val ownName =
2229
2230
if isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) then
2230
2231
in.nextToken()
@@ -4209,7 +4210,7 @@ object Parsers {
4209
4210
else constrApp() match
4210
4211
case parent : Apply => parent :: moreConstrApps()
4211
4212
case parent if in.isIdent && newSyntaxAllowed =>
4212
- infixTypeRest(parent, _ => annotType1()) :: Nil
4213
+ infixTypeRest()( parent, _ => annotType1()) :: Nil
4213
4214
case parent => parent :: moreConstrApps()
4214
4215
4215
4216
// The term parameters and parent references */
0 commit comments