Skip to content

Commit 07583a1

Browse files
KacperFKorbanWojciechMazur
authored andcommitted
Change inContextBound to a Boolean flag
[Cherry-picked ae9cffa]
1 parent dac7f7e commit 07583a1

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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
@@ -1537,7 +1534,7 @@ object Parsers {
15371534
/** Same as [[typ]], but if this results in a wildcard it emits a syntax error and
15381535
* returns a tree for type `Any` instead.
15391536
*/
1540-
def toplevelTyp(intoOK: IntoOK = IntoOK.No, inContextBound: InContextBound = InContextBound.No): Tree =
1537+
def toplevelTyp(intoOK: IntoOK = IntoOK.No, inContextBound: Boolean = false): Tree =
15411538
rejectWildcardType(typ(intoOK, inContextBound))
15421539

15431540
private def getFunction(tree: Tree): Option[Function] = tree match {
@@ -1598,7 +1595,7 @@ object Parsers {
15981595
* IntoTargetType ::= Type
15991596
* | FunTypeArgs (‘=>’ | ‘?=>’) IntoType
16001597
*/
1601-
def typ(intoOK: IntoOK = IntoOK.No, inContextBound: InContextBound = InContextBound.No): Tree =
1598+
def typ(intoOK: IntoOK = IntoOK.No, inContextBound: Boolean = false): Tree =
16021599
val start = in.offset
16031600
var imods = Modifiers()
16041601
val erasedArgs: ListBuffer[Boolean] = ListBuffer()
@@ -1831,13 +1828,13 @@ object Parsers {
18311828
/** InfixType ::= RefinedType {id [nl] RefinedType}
18321829
* | RefinedType `^` // under capture checking
18331830
*/
1834-
def infixType(inContextBound: InContextBound = InContextBound.No): Tree = infixTypeRest(inContextBound)(refinedType())
1831+
def infixType(inContextBound: Boolean = false): Tree = infixTypeRest(inContextBound)(refinedType())
18351832

1836-
def infixTypeRest(inContextBound: InContextBound = InContextBound.No)(t: Tree, operand: Location => Tree = refinedTypeFn): Tree =
1833+
def infixTypeRest(inContextBound: Boolean = false)(t: Tree, operand: Location => Tree = refinedTypeFn): Tree =
18371834
infixOps(t, canStartInfixTypeTokens, operand, Location.ElseWhere, ParseKind.Type,
18381835
isOperator = !followingIsVararg()
18391836
&& !isPureArrow
1840-
&& !(isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound == InContextBound.Yes)
1837+
&& !(isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound)
18411838
&& nextCanFollowOperator(canStartInfixTypeTokens))
18421839

18431840
/** RefinedType ::= WithType {[nl] Refinement} [`^` CaptureSet]
@@ -2228,7 +2225,7 @@ object Parsers {
22282225

22292226
/** ContextBound ::= Type [`as` id] */
22302227
def contextBound(pname: TypeName): Tree =
2231-
val t = toplevelTyp(inContextBound = InContextBound.Yes)
2228+
val t = toplevelTyp(inContextBound = true)
22322229
val ownName =
22332230
if isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) then
22342231
in.nextToken()

0 commit comments

Comments
 (0)