Skip to content

Commit 99af3f5

Browse files
KacperFKorbanodersky
authored andcommitted
WIP notes and stuff
1 parent d955020 commit 99af3f5

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
@@ -2035,65 +2035,24 @@ class Namer { typer: Typer =>
20352035
* abstract type member
20362036
*/
20372037
def needsTracked(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context) =
2038-
lazy val abstractContextBound = isContextBoundWitnessWithAbstractMembers(psym, param, owningSym)
2039-
lazy val isRefInSignatures =
2040-
psym.maybeOwner.isPrimaryConstructor
2041-
&& isReferencedInPublicSignatures(psym)
20422038
lazy val needsTrackedSimp = needsTrackedSimple(psym, param, owningSym)
20432039
!psym.is(Tracked)
2044-
&& psym.isTerm
2045-
&& needsTrackedSimp
2046-
2047-
/** Under x.modularity, we add `tracked` to context bound witnesses and
2048-
* explicit evidence parameters that have abstract type members
2049-
*/
2050-
private def isContextBoundWitnessWithAbstractMembers(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context): Boolean =
2051-
val accessorSyms = maybeParamAccessors(owningSym, psym)
2052-
(owningSym.isClass || owningSym.isAllOf(Given | Method))
2053-
&& (param.hasAttachment(ContextBoundParam) || (psym.isOneOf(GivenOrImplicit) && !accessorSyms.forall(_.isOneOf(PrivateLocal))))
2054-
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2040+
&& psym.isTerm
2041+
&& needsTrackedSimp
20552042

20562043
private def needsTrackedSimple(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context): Boolean =
20572044
val accessorSyms = maybeParamAccessors(owningSym, psym)
20582045
(owningSym.isClass || owningSym.isAllOf(Given | Method))
2059-
&& !accessorSyms.exists(_.is(Mutable))
2060-
&& (param.hasAttachment(ContextBoundParam) || !accessorSyms.forall(_.isOneOf(PrivateLocal)))
2061-
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2046+
&& !accessorSyms.exists(_.is(Mutable))
2047+
&& (param.hasAttachment(ContextBoundParam) || accessorSyms.exists(!_.isOneOf(PrivateLocal)))
2048+
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
20622049

20632050
extension (sym: Symbol)
20642051
private def infoWithForceNonInferingCompleter(using Context): Type = sym.infoOrCompleter match
20652052
case tpe: LazyType if tpe.isExplicit => sym.info
20662053
case tpe if sym.isType => sym.info
20672054
case info => info
20682055

2069-
/** Under x.modularity, we add `tracked` to term parameters whose types are
2070-
* referenced in public signatures of the defining class
2071-
*/
2072-
private def isReferencedInPublicSignatures(sym: Symbol)(using Context): Boolean =
2073-
val owner = sym.maybeOwner.maybeOwner
2074-
val accessorSyms = maybeParamAccessors(owner, sym)
2075-
def checkOwnerMemberSignatures(owner: Symbol): Boolean =
2076-
owner.infoOrCompleter match
2077-
case info: ClassInfo =>
2078-
info.decls.filter(_.isPublic)
2079-
.filter(_ != sym.maybeOwner)
2080-
.exists { decl =>
2081-
tpeContainsSymbolRef(decl.infoWithForceNonInferingCompleter, accessorSyms)
2082-
}
2083-
case _ => false
2084-
checkOwnerMemberSignatures(owner)
2085-
2086-
/** Check if any of syms are referenced in tpe */
2087-
private def tpeContainsSymbolRef(tpe: Type, syms: List[Symbol])(using Context): Boolean =
2088-
val acc = new ExistsAccumulator(
2089-
{ tpe => tpe.termSymbol.exists && syms.contains(tpe.termSymbol) },
2090-
StopAt.Static,
2091-
forceLazy = false
2092-
) {
2093-
override def apply(acc: Boolean, tpe: Type): Boolean = super.apply(acc, tpe.safeDealias)
2094-
}
2095-
acc(false, tpe)
2096-
20972056
private def maybeParamAccessors(owner: Symbol, sym: Symbol)(using Context): List[Symbol] = owner.infoOrCompleter match
20982057
case info: ClassInfo =>
20992058
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
@@ -953,6 +953,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
953953
case _ =>
954954
notAMemberErrorType(tree, qual, pt))
955955

956+
println(i"typedSelectWithAdapt $tree, $pt, $qual")
956957
tryType(tree, qual, rawType)
957958
.orElse(trySimplifyApply())
958959
.orElse(tryInstantiateTypeVar())

0 commit comments

Comments
 (0)