Skip to content

Commit ae9cffa

Browse files
committed
Change inContextBound to a Boolean flag
1 parent e7221c6 commit ae9cffa

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Diff for: compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+6-9
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ object Parsers {
8080
enum IntoOK:
8181
case Yes, No, Nested
8282

83-
enum InContextBound:
84-
case Yes, No
85-
8683
type StageKind = Int
8784
object StageKind {
8885
val None = 0
@@ -1553,7 +1550,7 @@ object Parsers {
15531550
/** Same as [[typ]], but if this results in a wildcard it emits a syntax error and
15541551
* returns a tree for type `Any` instead.
15551552
*/
1556-
def toplevelTyp(intoOK: IntoOK = IntoOK.No, inContextBound: InContextBound = InContextBound.No): Tree =
1553+
def toplevelTyp(intoOK: IntoOK = IntoOK.No, inContextBound: Boolean = false): Tree =
15571554
rejectWildcardType(typ(intoOK, inContextBound))
15581555

15591556
private def getFunction(tree: Tree): Option[Function] = tree match {
@@ -1609,7 +1606,7 @@ object Parsers {
16091606
* IntoTargetType ::= Type
16101607
* | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
16111608
*/
1612-
def typ(intoOK: IntoOK = IntoOK.No, inContextBound: InContextBound = InContextBound.No): Tree =
1609+
def typ(intoOK: IntoOK = IntoOK.No, inContextBound: Boolean = false): Tree =
16131610
val start = in.offset
16141611
var imods = Modifiers()
16151612
val erasedArgs: ListBuffer[Boolean] = ListBuffer()
@@ -1836,13 +1833,13 @@ object Parsers {
18361833
/** InfixType ::= RefinedType {id [nl] RefinedType}
18371834
* | RefinedType `^` // under capture checking
18381835
*/
1839-
def infixType(inContextBound: InContextBound = InContextBound.No): Tree = infixTypeRest(inContextBound)(refinedType())
1836+
def infixType(inContextBound: Boolean = false): Tree = infixTypeRest(inContextBound)(refinedType())
18401837

1841-
def infixTypeRest(inContextBound: InContextBound = InContextBound.No)(t: Tree, operand: Location => Tree = refinedTypeFn): Tree =
1838+
def infixTypeRest(inContextBound: Boolean = false)(t: Tree, operand: Location => Tree = refinedTypeFn): Tree =
18421839
infixOps(t, canStartInfixTypeTokens, operand, Location.ElseWhere, ParseKind.Type,
18431840
isOperator = !followingIsVararg()
18441841
&& !isPureArrow
1845-
&& !(isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound == InContextBound.Yes)
1842+
&& !(isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound)
18461843
&& nextCanFollowOperator(canStartInfixTypeTokens))
18471844

18481845
/** RefinedType ::= WithType {[nl] Refinement} [`^` CaptureSet]
@@ -2233,7 +2230,7 @@ object Parsers {
22332230

22342231
/** ContextBound ::= Type [`as` id] */
22352232
def contextBound(pname: TypeName): Tree =
2236-
val t = toplevelTyp(inContextBound = InContextBound.Yes)
2233+
val t = toplevelTyp(inContextBound = true)
22372234
val ownName =
22382235
if isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) then
22392236
in.nextToken()

0 commit comments

Comments
 (0)