Skip to content

Commit 7c2ccd9

Browse files
committed
WIP notes and stuff
1 parent 8ba380a commit 7c2ccd9

File tree

8 files changed

+1568
-51
lines changed

8 files changed

+1568
-51
lines changed

after-printing.txt

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
Header:
2+
version: <elided>
3+
tooling: <elided>
4+
UUID: <elided>
5+
6+
Names (351 bytes, starting from <elided base index>):
7+
0: ASTs
8+
1: <empty>
9+
2: scala
10+
3: reflect
11+
4: scala[Qualified . reflect]
12+
5: ClassTag
13+
6: Foo
14+
7: <init>
15+
8: java
16+
9: lang
17+
10: java[Qualified . lang]
18+
11: Object
19+
12: java[Qualified . lang][Qualified . Object]
20+
13: <init>[Signed Signature(List(),java.lang.Object) @<init>]
21+
14: Unit
22+
15: mkArray
23+
16: T
24+
17: Nothing
25+
18: Any
26+
19: WitnessNames
27+
20: annotation
28+
21: scala[Qualified . annotation]
29+
22: internal
30+
23: scala[Qualified . annotation][Qualified . internal]
31+
24: scala[Qualified . annotation][Qualified . internal][Qualified . WitnessNames]
32+
25: collection
33+
26: scala[Qualified . collection]
34+
27: immutable
35+
28: scala[Qualified . collection][Qualified . immutable]
36+
29: Seq
37+
30: scala[Qualified . collection][Qualified . immutable][Qualified . Seq]
38+
31: <init>[Signed Signature(List(scala.collection.immutable.Seq),scala.annotation.internal.WitnessNames) @<init>]
39+
32: String
40+
33: evidence$1
41+
34: evidence$
42+
35: [Unique evidence$ 1]
43+
36: ???
44+
37: Predef
45+
38: SourceFile
46+
39: scala[Qualified . annotation][Qualified . internal][Qualified . SourceFile]
47+
40: java[Qualified . lang][Qualified . String]
48+
41: <init>[Signed Signature(List(java.lang.String),scala.annotation.internal.SourceFile) @<init>]
49+
42: <elided source file name>
50+
43: Positions
51+
44: Comments
52+
45: Attributes
53+
54+
Trees (122 bytes, starting from <elided base index>):
55+
0: PACKAGE(120)
56+
2: TERMREFpkg 1 [<empty>]
57+
4: IMPORT(4)
58+
6: TERMREFpkg 4 [scala[Qualified . reflect]]
59+
8: IMPORTED 5 [ClassTag]
60+
10: TYPEDEF(110) 6 [Foo]
61+
13: TEMPLATE(89)
62+
15: APPLY(10)
63+
17: SELECTin(8) 13 [<init>[Signed Signature(List(),java.lang.Object) @<init>]]
64+
20: NEW
65+
21: TYPEREF 11 [Object]
66+
23: TERMREFpkg 10 [java[Qualified . lang]]
67+
25: SHAREDtype 21
68+
27: DEFDEF(7) 7 [<init>]
69+
30: EMPTYCLAUSE
70+
31: TYPEREF 14 [Unit]
71+
33: TERMREFpkg 2 [scala]
72+
35: STABLE
73+
36: DEFDEF(66) 15 [mkArray]
74+
39: TYPEPARAM(35) 16 [T]
75+
42: TYPEBOUNDStpt(8)
76+
44: TYPEREF 17 [Nothing]
77+
46: SHAREDtype 33
78+
48: TYPEREF 18 [Any]
79+
50: SHAREDtype 33
80+
52: ANNOTATION(22)
81+
54: TYPEREF 19 [WitnessNames]
82+
56: TERMREFpkg 23 [scala[Qualified . annotation][Qualified . internal]]
83+
58: APPLY(16)
84+
60: SELECTin(6) 31 [<init>[Signed Signature(List(scala.collection.immutable.Seq),scala.annotation.internal.WitnessNames) @<init>]]
85+
63: NEW
86+
64: SHAREDtype 54
87+
66: SHAREDtype 54
88+
68: REPEATED(6)
89+
70: TYPEREF 32 [String]
90+
72: SHAREDtype 23
91+
74: STRINGconst 33 [evidence$1]
92+
76: PARAM(14) 35 [[Unique evidence$ 1]]
93+
79: APPLIEDtpt(10)
94+
81: IDENTtpt 5 [ClassTag]
95+
83: TYPEREF 5 [ClassTag]
96+
85: SHAREDtype 6
97+
87: IDENTtpt 16 [T]
98+
89: TYPEREFdirect 39
99+
91: GIVEN
100+
92: IDENTtpt 17 [Nothing]
101+
94: TYPEREF 17 [Nothing]
102+
96: TERMREFpkg 2 [scala]
103+
98: TERMREF 36 [???]
104+
100: TERMREF 37 [Predef]
105+
102: SHAREDtype 33
106+
104: ANNOTATION(16)
107+
106: TYPEREF 38 [SourceFile]
108+
108: SHAREDtype 56
109+
110: APPLY(10)
110+
112: SELECTin(6) 41 [<init>[Signed Signature(List(java.lang.String),scala.annotation.internal.SourceFile) @<init>]]
111+
115: NEW
112+
116: SHAREDtype 106
113+
118: SHAREDtype 106
114+
120: STRINGconst 42 [<elided source file name>]
115+
122:
116+
117+
Positions (83 bytes, starting from <elided base index>):
118+
lines: 7
119+
line sizes:
120+
38, 0, 23, 0, 10, 41, 0
121+
positions:
122+
0: 40 .. 117
123+
4: 40 .. 63
124+
6: 47 .. 54
125+
8: 55 .. 63
126+
10: 65 .. 117
127+
13: 78 .. 117
128+
21: 71 .. 71
129+
27: 78 .. 78
130+
31: 78 .. 78
131+
36: 78 .. 117
132+
39: 90 .. 101
133+
44: 93 .. 93
134+
48: 93 .. 93
135+
64: 90 .. 90
136+
70: 90 .. 90
137+
74: 90 .. 90
138+
76: 93 .. 101
139+
81: 93 .. 101
140+
87: 93 .. 101
141+
92: 104 .. 111
142+
98: 114 .. 117
143+
110: 65 .. 117
144+
116: 65 .. 65
145+
120: 65 .. 65
146+
147+
source paths:
148+
0: 42 [<elided source file name>]
149+
150+
Attributes (2 bytes, starting from <elided base index>):
151+
SOURCEFILEattr 42 [<elided source file name>]

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,65 +2030,24 @@ class Namer { typer: Typer =>
20302030
* abstract type member
20312031
*/
20322032
def needsTracked(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context) =
2033-
lazy val abstractContextBound = isContextBoundWitnessWithAbstractMembers(psym, param, owningSym)
2034-
lazy val isRefInSignatures =
2035-
psym.maybeOwner.isPrimaryConstructor
2036-
&& isReferencedInPublicSignatures(psym)
20372033
lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
20382034
!psym.is(Tracked)
2039-
&& psym.isTerm
2040-
&& needsTrackedSimp
2041-
2042-
/** Under x.modularity, we add `tracked` to context bound witnesses and
2043-
* explicit evidence parameters that have abstract type members
2044-
*/
2045-
private def isContextBoundWitnessWithAbstractMembers(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context): Boolean =
2046-
val accessorSyms = maybeParamAccessors(owningSym, psym)
2047-
(owningSym.isClass || owningSym.isAllOf(Given | Method))
2048-
&& (param.hasAttachment(ContextBoundParam) || (psym.isOneOf(GivenOrImplicit) && !accessorSyms.forall(_.isOneOf(PrivateLocal))))
2049-
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2035+
&& psym.isTerm
2036+
&& needsTrackedSimp
20502037

20512038
private def needsTrackedSimple(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context): Boolean =
20522039
val accessorSyms = maybeParamAccessors(owningSym, psym)
20532040
(owningSym.isClass || owningSym.isAllOf(Given | Method))
2054-
&& !accessorSyms.exists(_.is(Mutable))
2055-
&& (param.hasAttachment(ContextBoundParam) || !accessorSyms.forall(_.isOneOf(PrivateLocal)))
2056-
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2041+
&& !accessorSyms.exists(_.is(Mutable))
2042+
&& (param.hasAttachment(ContextBoundParam) || accessorSyms.exists(!_.isOneOf(PrivateLocal)))
2043+
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
20572044

20582045
extension (sym: Symbol)
20592046
private def infoWithForceNonInferingCompleter(using Context): Type = sym.infoOrCompleter match
20602047
case tpe: LazyType if tpe.isExplicit => sym.info
20612048
case tpe if sym.isType => sym.info
20622049
case info => info
20632050

2064-
/** Under x.modularity, we add `tracked` to term parameters whose types are
2065-
* referenced in public signatures of the defining class
2066-
*/
2067-
private def isReferencedInPublicSignatures(sym: Symbol)(using Context): Boolean =
2068-
val owner = sym.maybeOwner.maybeOwner
2069-
val accessorSyms = maybeParamAccessors(owner, sym)
2070-
def checkOwnerMemberSignatures(owner: Symbol): Boolean =
2071-
owner.infoOrCompleter match
2072-
case info: ClassInfo =>
2073-
info.decls.filter(_.isPublic)
2074-
.filter(_ != sym.maybeOwner)
2075-
.exists { decl =>
2076-
tpeContainsSymbolRef(decl.infoWithForceNonInferingCompleter, accessorSyms)
2077-
}
2078-
case _ => false
2079-
checkOwnerMemberSignatures(owner)
2080-
2081-
/** Check if any of syms are referenced in tpe */
2082-
private def tpeContainsSymbolRef(tpe: Type, syms: List[Symbol])(using Context): Boolean =
2083-
val acc = new ExistsAccumulator(
2084-
{ tpe => tpe.termSymbol.exists && syms.contains(tpe.termSymbol) },
2085-
StopAt.Static,
2086-
forceLazy = false
2087-
) {
2088-
override def apply(acc: Boolean, tpe: Type): Boolean = super.apply(acc, tpe.safeDealias)
2089-
}
2090-
acc(false, tpe)
2091-
20922051
private def maybeParamAccessors(owner: Symbol, sym: Symbol)(using Context): List[Symbol] = owner.infoOrCompleter match
20932052
case info: ClassInfo =>
20942053
info.decls.lookupAll(sym.name).filter(d => d.is(ParamAccessor)).toList

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
945945
case _ =>
946946
notAMemberErrorType(tree, qual, pt))
947947

948+
println(i"typedSelectWithAdapt $tree, $pt, $qual")
948949
tryType(tree, qual, rawType)
949950
.orElse(trySimplifyApply())
950951
.orElse(tryInstantiateTypeVar())

0 commit comments

Comments
 (0)