Skip to content

Commit

Permalink
Stress test for add-class-deps
Browse files Browse the repository at this point in the history
This commit makes all explicitly declared vals tracked. It causes many test failures, which
makes it unlikely that we will be able to do this in the end. But it's an excellent basis
for stress testing the implementation of dependent classes.

The idea is to

 - look at the test failures in this test
 - convert failing tests into tests witih explicit tracked annotations
 - if the test still fails (it probably will), try to fix the root cause
   or determine that the pattern should not be supported.
  • Loading branch information
odersky committed Nov 21, 2023
1 parent ac09b4c commit fab596a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ object Parsers {
enum ParamOwner:
case Class // class or trait or enum
case CaseClass // case class or enum case
case ImplicitClass // implicit class
case Type // type alias or abstract type
case TypeParam // type parameter
case Def // method
case Given // given definition
case ExtensionPrefix // extension clause, up to and including extension parameter
case ExtensionFollow // extension clause, following extension parameter

def isClass = // owner is a class
this == Class || this == CaseClass || this == Given
def isClass = this match // owner is a class
case Class | CaseClass | ImplicitClass | Given => true
case _ => false
def takesOnlyUsingClauses = // only using clauses allowed for this owner
this == Given || this == ExtensionFollow
def acceptsVariance =
Expand Down Expand Up @@ -3361,6 +3363,8 @@ object Parsers {
mods = addFlag(modifiers(start = mods), ParamAccessor)
mods =
if in.token == VAL then
if !mods.is(Private) && paramOwner != ParamOwner.ImplicitClass then
mods |= Tracked
in.nextToken()
mods
else if in.token == VAR then
Expand Down Expand Up @@ -3898,7 +3902,10 @@ object Parsers {
}

def classDefRest(start: Offset, mods: Modifiers, name: TypeName): TypeDef =
val constr = classConstr(if mods.is(Case) then ParamOwner.CaseClass else ParamOwner.Class)
val constr = classConstr(
if mods.is(Case) then ParamOwner.CaseClass
else if mods.is(Implicit) then ParamOwner.ImplicitClass
else ParamOwner.Class)
val templ = templateOpt(constr)
finalizeDef(TypeDef(name, templ), mods, start)

Expand Down

0 comments on commit fab596a

Please sign in to comment.