Skip to content

Commit

Permalink
Update comments for parser; remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Oct 9, 2024
1 parent 152710b commit c20ae8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
def makeRetaining(parent: Tree, refs: List[Tree], annotName: TypeName)(using Context): Annotated =
Annotated(parent, New(scalaAnnotationDot(annotName), List(refs)))

def makeCapsOf(tp: Tree)(using Context): Tree =
def makeCapsOf(tp: RefTree)(using Context): Tree =
TypeApply(Select(scalaDot(nme.caps), nme.capsOf), tp :: Nil)

def makeCapsBound()(using Context): Tree =
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/cc/CaptureOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ extension (tp: Type)
true
case tp: TermRef =>
((tp.prefix eq NoPrefix)
|| tp.symbol.isField && !tp.symbol.isStatic && (
tp.prefix.isThisTypeOf(tp.symbol.owner) || tp.prefix.isTrackableRef)
|| tp.symbol.isField && !tp.symbol.isStatic && tp.prefix.isTrackableRef
|| tp.isRootCapability
) && !tp.symbol.isOneOf(UnstableValueFlags)
case tp: TypeRef =>
Expand Down
12 changes: 5 additions & 7 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1548,22 +1548,20 @@ object Parsers {
case _ => None
}

/** CaptureRef ::= (ident | `this`) [`*` | `^`]
/** CaptureRef ::= SimpleRef { `.` id } [`*` | `^`]
*/
def captureRef(): Tree =
val ref = singleton()
val ref = dotSelectors(simpleRef())
if isIdent(nme.raw.STAR) then
in.nextToken()
atSpan(startOffset(ref)):
PostfixOp(ref, Ident(nme.CC_REACH))
else if isIdent(nme.UPARROW) then
in.nextToken()
def toTypeSel(r: Tree): Tree = r match
case id: Ident => cpy.Ident(id)(id.name.toTypeName)
case Select(qual, id) => Select(qual, id.toTypeName)
case _ => r
atSpan(startOffset(ref)):
makeCapsOf(toTypeSel(ref))
convertToTypeId(ref) match
case ref: RefTree => makeCapsOf(ref)
case ref => ref
else ref

/** CaptureSet ::= `{` CaptureRef {`,` CaptureRef} `}` -- under captureChecking
Expand Down

0 comments on commit c20ae8f

Please sign in to comment.