Skip to content

Commit

Permalink
Follow Scala 2 when generating trait constructors under `-Ycompile-sc…
Browse files Browse the repository at this point in the history
…ala2-library` (#22529)

Closes #22496
  • Loading branch information
hamzaremmal authored Feb 6, 2025
2 parents e652109 + ffa251d commit 4cb43b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
*/
private def defKind(tree: Tree)(using Context): FlagSet = unsplice(tree) match {
case EmptyTree | _: Import => NoInitsInterface
case tree: TypeDef if ctx.settings.YcompileScala2Library.value =>
if (tree.isClassDef) EmptyFlags else NoInitsInterface
case tree: TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
case tree: DefDef =>
if tree.unforcedRhs == EmptyTree
Expand All @@ -477,6 +479,8 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
NoInitsInterface
else if tree.mods.is(Given) && tree.paramss.isEmpty then
EmptyFlags // might become a lazy val: TODO: check whether we need to suppress NoInits once we have new lazy val impl
else if ctx.settings.YcompileScala2Library.value then
EmptyFlags
else
NoInits
case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags
Expand Down
3 changes: 0 additions & 3 deletions project/Scala2LibraryBootstrappedMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ object Scala2LibraryBootstrappedMiMaFilters {
ProblemFilters.exclude[FinalClassProblem]("scala.language$experimental$"),
ProblemFilters.exclude[FinalClassProblem]("scala.languageFeature$*$"),

// trait $init$
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*.$init$"),

// Value class extension methods
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*$extension"),

Expand Down

0 comments on commit 4cb43b6

Please sign in to comment.