Skip to content

Commit 42f95a5

Browse files
committed
Improve comments
1 parent b0cdc53 commit 42f95a5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ object TreePickler {
3333
}
3434

3535
/** Select tree cannot be unambiguously resolved with signature alone,
36-
* needs to be pickled using the SELECTin tag.
36+
* needs to be pickled using the SELECTin tag. This is set by Typer, if
37+
* after overloading resolution it is discovered that other alternatives
38+
* have the same signature as the one that was selected.
3739
*/
3840
val NeedsSelectIn = new Property.StickyKey[Unit]
3941
}
@@ -391,6 +393,9 @@ class TreePickler(pickler: TastyPickler) {
391393
val sig = tree.tpe.signature
392394
val needsSelectIn = tree.hasAttachment(NeedsSelectIn)
393395
if checkAmbiguousSelects then
396+
// We use needsSelectIn instead of isAmbiguous since isAmbiguous
397+
// is more expensive to compute. This matters since either criterion
398+
// is false in almost all cases.
394399
val isAmbiguous = qual.tpe.nonPrivateMember(name) match
395400
case d: MultiDenotation => d.atSignature(sig).isInstanceOf[MultiDenotation]
396401
case _ => false

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Standard-Section: "ASTs" TopLevelStat*
7575
Term = Path -- Paths represent both types and terms
7676
IDENT NameRef Type -- Used when term ident’s type is not a TermRef
7777
SELECT possiblySigned_NameRef qual_Term -- qual.name
78-
SELECTin Length possiblySigned_NameRef qual_Term owner_Type -- qual.name, referring to a symbol declared in owner that has the given signature
78+
SELECTin Length possiblySigned_NameRef qual_Term owner_Type -- qual.name, referring to a symbol declared in owner that has the given signature (see note below)
7979
QUALTHIS typeIdent_Tree -- id.this, different from THIS in that it contains a qualifier ident with position.
8080
NEW clsType_Term -- new cls
8181
THROW throwableExpr_Term -- throw throwableExpr
@@ -213,6 +213,10 @@ Standard-Section: "ASTs" TopLevelStat*
213213
214214
Annotation = ANNOTATION Length tycon_Type fullAnnotation_Term -- An annotation, given (class) type of constructor, and full application tree
215215
216+
Note: The signature of a SELECTin node is the signature of the selected symbol, not
217+
the signature of the reference. The latter undergoes an asSeenFrom but the former
218+
does not. TODO: Also use symbol signatures in TERMREFin
219+
216220
Note: Tree tags are grouped into 5 categories that determine what follows, and thus allow to compute the size of the tagged tree in a generic way.
217221
218222
Category 1 (tags 1-49) : tag

0 commit comments

Comments
 (0)