Skip to content

Commit

Permalink
Add some test cases with current limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperFKorban committed Nov 18, 2024
1 parent 734f7a2 commit 1c1e7c0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 66 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ object desugar {
// we can reuse the constructor parameters; no derived params are needed.
DefDef(
className.toTermName, joinParams(constrTparams, defParamss), classTypeRef, creatorExpr
) .withMods(companionMods | mods.flags.toTermFlags & (GivenOrImplicit | Inline) | finalFlag)
.withSpan(cdef.span) :: Nil
).withMods(companionMods | mods.flags.toTermFlags & (GivenOrImplicit | Inline) | finalFlag)
.withSpan(cdef.span) :: Nil
}

val self1 = {
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1935,10 +1935,10 @@ class Namer { typer: Typer =>
for params <- ddef.termParamss; param <- params do
val psym = symbolOfTree(param)
if needsTracked(psym, param, owningSym) then
psym.setFlag(Tracked)
for acc <- sym.maybeOwner.infoOrCompleter.decls.lookupAll(psym.name) if acc.is(ParamAccessor) do
acc.resetFlag(PrivateLocal)
acc.setFlag(Tracked)
psym.setFlag(Tracked)

if Feature.enabled(modularity) then addTrackedIfNeeded(ddef, sym.maybeOwner)

Expand Down Expand Up @@ -2078,12 +2078,12 @@ class Namer { typer: Typer =>
case _ =>

def inferredResultType(
mdef: ValOrDefDef,
sym: Symbol,
paramss: List[List[Symbol]],
paramFn: Type => Type,
fallbackProto: Type
)(using Context): Type =
mdef: ValOrDefDef,
sym: Symbol,
paramss: List[List[Symbol]],
paramFn: Type => Type,
fallbackProto: Type
)(using Context): Type =

/** A type for this definition that might be inherited from elsewhere:
* If this is a setter parameter, the corresponding getter type.
Expand Down
1 change: 0 additions & 1 deletion compiler/test/dotc/pos-test-pickling.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ parsercombinators-new-syntax.scala
hylolib-deferred-given
hylolib-cb
hylolib
infer-tracked-parsercombinators-givens.scala

# typecheckErrors method unpickling
i21415.scala
54 changes: 0 additions & 54 deletions tests/pos/infer-tracked-parsercombinators-givens.scala

This file was deleted.

11 changes: 9 additions & 2 deletions tests/pos/infer-tracked.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ case class K(c: C):
case class L(c: C):
type T = c.T

class M

given mInst: (c: C) => M:
def foo: c.T = c.foo

def Test =
val c = new C:
type T = Int
Expand All @@ -33,8 +38,7 @@ def Test =
val f = new F(c)
val _: Int = f.result

// Not really possible to work with inference in Namer, should emit a lint
// val g = new G(c)
// val g = new G(c) // current limitation of infering in Namer, should emit a lint
// val _: Int = g.result

val h = new H(c)
Expand All @@ -51,3 +55,6 @@ def Test =

val l = L(c)
summon[l.T =:= Int]

// val m = mInst(using c) // current limitation, we infer tracked after this desugaring
// val _: Int = m.foo

0 comments on commit 1c1e7c0

Please sign in to comment.