Skip to content

Commit

Permalink
Try potential fixes for some of the cyclic referenc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperFKorban committed Sep 26, 2024
1 parent 9468366 commit 553971b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import config.Feature.{sourceVersion, modularity}
import config.SourceVersion.*

import scala.compiletime.uninitialized
import dotty.tools.dotc.transform.init.Util.tree

/** This class creates symbols from definitions and imports and gives them
* lazy types.
Expand Down Expand Up @@ -1699,7 +1698,6 @@ class Namer { typer: Typer =>
end addUsingTraits

completeConstructor(denot)
val constrSym = symbolOfTree(constr)
denot.info = tempInfo.nn

val parentTypes = defn.adjustForTuple(cls, cls.typeParams,
Expand Down Expand Up @@ -1995,7 +1993,11 @@ class Namer { typer: Typer =>
*/
def needsTracked(sym: Symbol, param: ValDef)(using Context) =
!sym.is(Tracked)
&& sym.maybeOwner.isConstructor
&& sym.isTerm
&& sym.maybeOwner.isPrimaryConstructor
// && !sym.flags.is(Synthetic)
// && !sym.maybeOwner.flags.is(Synthetic)
&& !sym.maybeOwner.maybeOwner.flags.is(Synthetic)
&& (
isContextBoundWitnessWithAbstractMembers(sym, param)
|| isReferencedInPublicSignatures(sym)
Expand All @@ -2018,7 +2020,7 @@ class Namer { typer: Typer =>
def checkOwnerMemberSignatures(owner: Symbol): Boolean =
owner.infoOrCompleter match
case info: ClassInfo =>
info.decls.filter(_.isTerm)
info.decls.filter(_.isTerm).filter(_.isPublic)
.filter(_ != sym.maybeOwner)
.exists(d => tpeContainsSymbolRef(d.info, accessorSyms))
case _ => false
Expand All @@ -2039,8 +2041,9 @@ class Namer { typer: Typer =>
case _ => false

private def tpeContainsSymbolRef(tpe0: Type, syms: List[Symbol])(using Context): Boolean =
val tpe = tpe0.dropAlias.widenExpr.dealias
val tpe = tpe0.dropAlias.safeDealias
tpe match
case ExprType(resType) => tpeContainsSymbolRef(resType, syms)
case m : MethodOrPoly =>
m.paramInfos.exists(tpeContainsSymbolRef(_, syms))
|| tpeContainsSymbolRef(m.resultType, syms)
Expand Down
5 changes: 3 additions & 2 deletions tests/pos/infer-tracked-parsercombinators-givens.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ given apply[C, E]: Combinator[Apply[C, E]] with {
}
}

// TODO(kπ) infer tracked correctly here
given combine[A, B](using
val f: Combinator[A],
val s: Combinator[B] { type Context = f.Context }
tracked val f: Combinator[A],
tracked val s: Combinator[B] { type Context = f.Context }
): Combinator[Combine[A, B]] with {
type Context = f.Context
type Element = (f.Element, s.Element)
Expand Down

0 comments on commit 553971b

Please sign in to comment.