Skip to content

Commit c20ae8f

Browse files
committed
Update comments for parser; remove unnecessary checks
1 parent 152710b commit c20ae8f

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
525525
def makeRetaining(parent: Tree, refs: List[Tree], annotName: TypeName)(using Context): Annotated =
526526
Annotated(parent, New(scalaAnnotationDot(annotName), List(refs)))
527527

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

531531
def makeCapsBound()(using Context): Tree =

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ extension (tp: Type)
194194
true
195195
case tp: TermRef =>
196196
((tp.prefix eq NoPrefix)
197-
|| tp.symbol.isField && !tp.symbol.isStatic && (
198-
tp.prefix.isThisTypeOf(tp.symbol.owner) || tp.prefix.isTrackableRef)
197+
|| tp.symbol.isField && !tp.symbol.isStatic && tp.prefix.isTrackableRef
199198
|| tp.isRootCapability
200199
) && !tp.symbol.isOneOf(UnstableValueFlags)
201200
case tp: TypeRef =>

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,22 +1548,20 @@ object Parsers {
15481548
case _ => None
15491549
}
15501550

1551-
/** CaptureRef ::= (ident | `this`) [`*` | `^`]
1551+
/** CaptureRef ::= SimpleRef { `.` id } [`*` | `^`]
15521552
*/
15531553
def captureRef(): Tree =
1554-
val ref = singleton()
1554+
val ref = dotSelectors(simpleRef())
15551555
if isIdent(nme.raw.STAR) then
15561556
in.nextToken()
15571557
atSpan(startOffset(ref)):
15581558
PostfixOp(ref, Ident(nme.CC_REACH))
15591559
else if isIdent(nme.UPARROW) then
15601560
in.nextToken()
1561-
def toTypeSel(r: Tree): Tree = r match
1562-
case id: Ident => cpy.Ident(id)(id.name.toTypeName)
1563-
case Select(qual, id) => Select(qual, id.toTypeName)
1564-
case _ => r
15651561
atSpan(startOffset(ref)):
1566-
makeCapsOf(toTypeSel(ref))
1562+
convertToTypeId(ref) match
1563+
case ref: RefTree => makeCapsOf(ref)
1564+
case ref => ref
15671565
else ref
15681566

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

0 commit comments

Comments
 (0)