8000 Merge pull request #2562 from som-snytt/issue/double-plugin · sjrd/scala@2da0576 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2da0576

Browse files
committed
Merge pull request scala#2562 from som-snytt/issue/double-plugin
SI-7494 Each plugin must only be instantiated once.
2 parents 28f26fc + 4ab66d1 commit 2da0576

File tree

64 files changed

+137
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+137
-150
lines changed

src/compiler/scala/tools/nsc/plugins/Plugin.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,13 @@ object Plugin {
9393
type AnyClass = Class[_]
9494

9595
/** Use a class loader to load the plugin class.
96-
*
97-
* @return `None` on failure
9896
*/
99-
def load(pd: PluginDescription, loader: ClassLoader): Try[AnyClass] = {
97+
def load(classname: String, loader: ClassLoader): Try[AnyClass] = {
10098
Try[AnyClass] {
101-
loader loadClass pd.classname
99+
loader loadClass classname
102100
} recoverWith {
103101
case _: Exception =>
104-
Failure(new RuntimeException(s"Warning: class not found: ${pd.classname}"))
102+
Failure(new RuntimeException(s"Warning: class not found: ${classname}"))
105103
}
106104
}
107105

@@ -137,9 +135,8 @@ object Plugin {
137135
case _ => false
138136
}
139137
val (locs, pds) = ((explicit ::: exploded ::: included) filterNot ignored).unzip
140-
141138
val loader = loaderFor(locs.distinct)
142-
pds filter (_.isSuccess) map (_.get) map (Plugin load (_, loader))
139+
(pds filter (_.isSuccess) map (_.get.classname)).distinct map (Plugin load (_, loader))
143140
}
144141

145142
/** Instantiate a plugin class, given the class and

src/partest/scala/tools/partest/nest/Runner.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit.NANOSECONDS
1313
import scala.collection.mutable.ListBuffer
1414
import scala.concurrent.duration.Duration
1515
import scala.io.Codec
16+
import scala.reflect.internal.FatalError
1617
import scala.sys.process.Process
1718
import scala.tools.nsc.Properties.{ envOrElse, isWin, jdkHome, javaHome, propOrElse, propOrEmpty, setProp }
1819
import scala.tools.nsc.{ Settings, CompilerCommand, Global }
@@ -451,9 +452,10 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te
451452
val failing = rounds find (x => nextTestActionExpectTrue("compilation failed", x.isOk) == false)
452453

453454
// which means passing if it checks and didn't crash the compiler
455+
// or, OK, we'll let you crash the compiler with a FatalError if you supply a check file
454456
def checked(r: CompileRound) = r.result match {
455-
case f: Crash => false
456-
case f => normalizeLog(); diffIsOk
457+
case Crash(_, t, _) if !checkFile.canRead || !t.isInstanceOf[FatalError] => false
458+
case _ => normalizeLog(); diffIsOk
457459
}
458460

459461
failing map (checked) getOrElse nextTestActionFailing("expected compilation failure")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xplugin:. -Xplugin-require:afterterminal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
package sample
3+
4+
// just a sample that is compiled with the sample plugin enabled
5+
object Sample extends App {
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<plugin>
2-
<name>beforeparser</name>
2+
<name>ignored</name>
33
<classname>scala.test.plugins.ThePlugin</classname>
44
</plugin>
55

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xplugin:. -Xplugin-require:beforeparser

0 commit comments

Comments
 (0)
0