Skip to content

Commit

Permalink
Avoid forcing whole package when using -experimental (#20409)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarter authored May 16, 2024
2 parents 177b489 + c8764ba commit 73bb2aa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,11 @@ object Checking {
def checkAndAdaptExperimentalImports(trees: List[Tree])(using Context): Unit =
def nonExperimentalTopLevelDefs(pack: Symbol): Iterator[Symbol] =
def isNonExperimentalTopLevelDefinition(sym: Symbol) =
!sym.isExperimental
sym.isDefinedInCurrentRun
&& sym.source == ctx.compilationUnit.source
&& !sym.isConstructor // not constructor of package object
&& !sym.is(Package) && !sym.name.isPackageObjectName
&& !sym.isExperimental

pack.info.decls.toList.iterator.flatMap: sym =>
if sym.isClass && (sym.is(Package) || sym.isPackageObject) then
Expand Down
2 changes: 2 additions & 0 deletions sbt-test/java-compat/moduleInfo/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Previously, we crashed trying to parse module-info.class in the empty package.
class A
5 changes: 5 additions & 0 deletions sbt-test/java-compat/moduleInfo/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scalaVersion := sys.props("plugin.scalaVersion")

scalacOptions ++= Seq(
"-experimental"
)
1 change: 1 addition & 0 deletions sbt-test/java-compat/moduleInfo/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> compile

0 comments on commit 73bb2aa

Please sign in to comment.