Skip to content

Commit 90d60cf

Browse files
committed
tracked inference review changes
1 parent 7442d5a commit 90d60cf

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ on:
2626
- cron: '0 3 * * *' # Every day at 3 AM
2727
workflow_dispatch:
2828

29-
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
29+
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
3030
# For example it would:
3131
# - terminate previous PR CI execution after pushing more changes to the same PR branch
32-
# - terminate previous on-push CI run after merging new PR to main
32+
# - terminate previous on-push CI run after merging new PR to main
3333
concurrency:
3434
group: ${{ github.workflow }}-${{ github.ref }}
3535
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
@@ -831,7 +831,7 @@ jobs:
831831
path: .
832832
- name: Prepare MSI package
833833
shell: bash
834-
run: |
834+
run: |
835835
msiInstaller="scala3-${{ env.RELEASE_TAG }}.msi"
836836
mv scala.msi "${msiInstaller}"
837837
sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
@@ -870,7 +870,7 @@ jobs:
870870
# ${upload("tar.gz archive", s"$filename.tar.gz", "application/gzip", distribution)}
871871
# ${upload("tar.gz archive SHA", s"$filename.tar.gz.sha256", "text/plain", distribution)}
872872
# """
873-
# def uploadMSI() =
873+
# def uploadMSI() =
874874
# val distribution = "Windows x86_64 MSI"
875875
# s"""
876876
# # $distribution

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@ object SymDenotations {
27532753
def complete(denot: SymDenotation)(using Context): Unit
27542754

27552755
/** Is this a completer for an explicit type tree */
2756-
def isNonInfering: Boolean = false
2756+
def isExplicit: Boolean = false
27572757

27582758
def apply(sym: Symbol): LazyType = this
27592759
def apply(module: TermSymbol, modcls: ClassSymbol): LazyType = this

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class Namer { typer: Typer =>
278278
if rhs.isEmpty || flags.is(Opaque) then flags |= Deferred
279279
if flags.is(Param) then tree.rhs else analyzeRHS(tree.rhs)
280280

281-
def isNonInferingTree(tree: ValOrDefDef): Boolean =
281+
def hasExplicitType(tree: ValOrDefDef): Boolean =
282282
!tree.tpt.isEmpty || tree.mods.isOneOf(TermParamOrAccessor)
283283

284284
// to complete a constructor, move one context further out -- this
@@ -294,8 +294,8 @@ class Namer { typer: Typer =>
294294

295295
val completer = tree match
296296
case tree: TypeDef => TypeDefCompleter(tree)(cctx)
297-
case tree: ValOrDefDef if Feature.enabled(Feature.modularity) && isNonInferingTree(tree) =>
298-
NonInferingCompleter(tree)(cctx)
297+
case tree: ValOrDefDef if Feature.enabled(Feature.modularity) && hasExplicitType(tree) =>
298+
new Completer(tree, isExplicit = true)(cctx)
299299
case _ => Completer(tree)(cctx)
300300
val info = adjustIfModule(completer, tree)
301301
createOrRefine[Symbol](tree, name, flags, ctx.owner, _ => info,
@@ -805,7 +805,7 @@ class Namer { typer: Typer =>
805805
}
806806

807807
/** The completer of a symbol defined by a member def or import (except ClassSymbols) */
808-
class Completer(val original: Tree)(ictx: Context) extends LazyType with SymbolLoaders.SecondCompleter {
808+
class Completer(val original: Tree, override val isExplicit: Boolean = false)(ictx: Context) extends LazyType with SymbolLoaders.SecondCompleter {
809809

810810
protected def localContext(owner: Symbol): FreshContext = ctx.fresh.setOwner(owner).setTree(original)
811811

@@ -1738,10 +1738,6 @@ class Namer { typer: Typer =>
17381738
}
17391739
}
17401740

1741-
class NonInferingCompleter(original: ValOrDefDef)(ictx: Context) extends Completer(original)(ictx) {
1742-
override def isNonInfering: Boolean = true
1743-
}
1744-
17451741
/** Possible actions to perform when deciding on a forwarder for a member */
17461742
private enum CanForward:
17471743
case Yes
@@ -2030,7 +2026,7 @@ class Namer { typer: Typer =>
20302026

20312027
extension (sym: Symbol)
20322028
private def infoWithForceNonInferingCompleter(using Context): Type = sym.infoOrCompleter match
2033-
case tpe: LazyType if tpe.isNonInfering => sym.info
2029+
case tpe: LazyType if tpe.isExplicit => sym.info
20342030
case tpe if sym.isType => sym.info
20352031
case info => info
20362032

docs/_docs/reference/experimental/modularity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ ClsParam ::= {Annotation} [{Modifier | ‘tracked’} (‘val’ | ‘var’)]
116116

117117
The (soft) `tracked` modifier is only allowed for `val` parameters of classes.
118118

119-
**Tracked inference**
119+
### Tracked inference
120120

121121
In some cases `tracked` can be infered and doesn't have to be written
122122
explicitly. A common such case is when a class parameter is referenced in the
@@ -147,7 +147,7 @@ class Klass[A: {TC as tc}]
147147

148148
Here, `tc` is a context bound with an associated type `T`, so `tracked` will be inferred for `tc`.
149149

150-
**Discussion**
150+
### Discussion
151151

152152
Since `tracked` is so useful, why not assume it by default? First, `tracked` makes sense only for `val` parameters. If a class parameter is not also a field declared using `val` then there's nothing to refine in the constructor result type. One could think of at least making all `val` parameters tracked by default, but that would be a backwards incompatible change. For instance, the following code would break:
153153

0 commit comments

Comments
 (0)