Skip to content

Commit f53e113

Browse files
committed
Infer tracked for explicit type class witnesses
1 parent c148b75 commit f53e113

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1935,9 +1935,9 @@ class Namer { typer: Typer =>
19351935
for params <- ddef.termParamss; param <- params do
19361936
val psym = symbolOfTree(param)
19371937
if needsTracked(psym, param, owningSym) then
1938-
psym.setFlag(Tracked)
19391938
for acc <- sym.maybeOwner.infoOrCompleter.decls.lookupAll(psym.name) if acc.is(ParamAccessor) do
19401939
acc.resetFlag(PrivateLocal)
1940+
psym.setFlag(Tracked)
19411941
acc.setFlag(Tracked)
19421942

19431943
if Feature.enabled(modularity) then addTrackedIfNeeded(ddef, sym.maybeOwner)
@@ -2019,7 +2019,7 @@ class Namer { typer: Typer =>
20192019
*/
20202020
def isContextBoundWitnessWithAbstractMembers(psym: Symbol, param: ValDef, owningSym: Symbol)(using Context): Boolean =
20212021
(owningSym.isClass || owningSym.isAllOf(Given | Method))
2022-
&& param.hasAttachment(ContextBoundParam)
2022+
&& (param.hasAttachment(ContextBoundParam) || psym.isOneOf(GivenOrImplicit))
20232023
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
20242024

20252025
extension (sym: Symbol)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.language.experimental.modularity
2+
3+
trait T:
4+
type Self
5+
type X
6+
def foo: Self
7+
8+
class D[C](using val wd: C is T)
9+
class E(using val we: Int is T)
10+
11+
def Test =
12+
given w: Int is T:
13+
def foo: Int = 42
14+
type X = Long
15+
val d = D(using w)
16+
summon[d.wd.X =:= Long]
17+
val e = E(using w)
18+
summon[e.we.X =:= Long]

0 commit comments

Comments
 (0)