Skip to content

Commit

Permalink
fix: Handle exceptions when reporting warnings in Scala 3 compiler pl…
Browse files Browse the repository at this point in the history
…ugin (#3872)

* Handle exceptions when reporting warnings in ScalaNativePlugin when using incomplete Context

* Disable fatal warning when testing deprecated plugin settings
  • Loading branch information
WojciechMazur committed Apr 15, 2024
1 parent d83e5fa commit 74f06ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package scala.scalanative.nscplugin

import dotty.tools.dotc.plugins._
import dotty.tools.dotc.report
import dotty.tools.dotc.core.Contexts.NoContext
import dotty.tools.dotc.core.Contexts.ContextBase
import java.net.URI
import java.net.URISyntaxException
import dotty.tools.dotc.core.Contexts.Context
Expand Down Expand Up @@ -45,7 +45,7 @@ class ScalaNativePlugin extends StandardPlugin:
.filter(_.isAbsolute())).distinct.sortBy(-_.getNameCount())
)
case (config, s"mapSourceURI:${mapping}") =>
given Context = NoContext
given Context = ContextBase().initialCtx
report.warning("'mapSourceURI' is deprecated, it's ignored.")
config
case (config, _) => config
Expand Down
3 changes: 3 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ object Build {
.enablePlugins(MyScalaNativePlugin)
.settings(noPublishSettings)
.settings(
// Setting only used to ensure that compiler does not crash when reporting deprecated options
scalacOptions += "-P:scalanative:mapSourceURI:path->unused",
scalacOptions -= "-Xfatal-warnings",
nativeConfig ~= {
_.withLinkStubs(true)
},
Expand Down

0 comments on commit 74f06ec

Please sign in to comment.