Skip to content

Commit

Permalink
Optimize nonExperimentalTopLevelDefs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Apr 30, 2024
1 parent df85c6e commit 803603b
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ object Checking {
tree

/** Check that experimental language imports in `trees`
* are done only in experimental scopes. For for top-level
* are done only in experimental scopes. For top-level
* experimental imports, all top-level definitions are transformed
* to @experimental definitions.
*
Expand All @@ -809,19 +809,14 @@ object Checking {
!sym.isExperimental
&& sym.source == ctx.compilationUnit.source
&& !sym.isConstructor // not constructor of package object
&& !sym.is(Package) && !sym.isPackageObject && !sym.name.endsWith(str.TOPLEVEL_SUFFIX)

val packageMembers =
pack.info.decls
.toList.iterator
.filter(isNonExperimentalTopLevelDefinition)
val packageObjectMembers =
pack.info.decls
.toList.iterator
.filter(sym => sym.isClass && (sym.is(Package) || sym.isPackageObject))
.flatMap(nonExperimentalTopLevelDefs)

packageMembers ++ packageObjectMembers
&& !sym.is(Package) && !sym.name.isPackageObjectName

pack.info.decls.toList.iterator.flatMap: sym =>
if sym.isClass && (sym.is(Package) || sym.isPackageObject) then
nonExperimentalTopLevelDefs(sym)
else if isNonExperimentalTopLevelDefinition(sym) then
sym :: Nil
else Nil

def unitExperimentalLanguageImports =
def isAllowedImport(sel: untpd.ImportSelector) =
Expand Down

0 comments on commit 803603b

Please sign in to comment.