Skip to content

Commit a0c7361

Browse files
noti0na1odersky
authored andcommitted
Update comments for parser; remove unnecessary checks
1 parent 3224b21 commit a0c7361

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
@@ -524,7 +524,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
524524
def makeRetaining(parent: Tree, refs: List[Tree], annotName: TypeName)(using Context): Annotated =
525525
Annotated(parent, New(scalaAnnotationDot(annotName), List(refs)))
526526

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

530530
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
@@ -1559,22 +1559,20 @@ object Parsers {
15591559
case _ => None
15601560
}
15611561

1562-
/** CaptureRef ::= (ident | `this`) [`*` | `^`]
1562+
/** CaptureRef ::= SimpleRef { `.` id } [`*` | `^`]
15631563
*/
15641564
def captureRef(): Tree =
1565-
val ref = singleton()
1565+
val ref = dotSelectors(simpleRef())
15661566
if isIdent(nme.raw.STAR) then
15671567
in.nextToken()
15681568
atSpan(startOffset(ref)):
15691569
PostfixOp(ref, Ident(nme.CC_REACH))
15701570
else if isIdent(nme.UPARROW) then
15711571
in.nextToken()
1572-
def toTypeSel(r: Tree): Tree = r match
1573-
case id: Ident => cpy.Ident(id)(id.name.toTypeName)
1574-
case Select(qual, id) => Select(qual, id.toTypeName)
1575-
case _ => r
15761572
atSpan(startOffset(ref)):
1577-
makeCapsOf(toTypeSel(ref))
1573+
convertToTypeId(ref) match
1574+
case ref: RefTree => makeCapsOf(ref)
1575+
case ref => ref
15781576
else ref
15791577

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

0 commit comments

Comments
 (0)