Skip to content

Commit 4992e37

Browse files
smarterWojciechMazur
authored andcommitted
Backport: Avoid forcing whole package when using -experimental
This backports #20409 which fixes a regression introduced in 3.5.0-RC1 causing compiler crashes when enabling `-experimental`.
1 parent a15fc7d commit 4992e37

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,11 @@ object Checking {
806806
def checkAndAdaptExperimentalImports(trees: List[Tree])(using Context): Unit =
807807
def nonExperimentalTopLevelDefs(pack: Symbol): Iterator[Symbol] =
808808
def isNonExperimentalTopLevelDefinition(sym: Symbol) =
809-
!sym.isExperimental
809+
sym.isDefinedInCurrentRun
810810
&& sym.source == ctx.compilationUnit.source
811811
&& !sym.isConstructor // not constructor of package object
812812
&& !sym.is(Package) && !sym.name.isPackageObjectName
813+
&& !sym.isExperimental
813814

814815
pack.info.decls.toList.iterator.flatMap: sym =>
815816
if sym.isClass && (sym.is(Package) || sym.isPackageObject) then
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Previously, we crashed trying to parse module-info.class in the empty package.
2+
class A
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
scalaVersion := sys.props("plugin.scalaVersion")
2+
3+
scalacOptions ++= Seq(
4+
"-experimental"
5+
)

sbt-test/java-compat/moduleInfo/test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> compile

0 commit comments

Comments
 (0)