Skip to content

Commit 7d01268

Browse files
authored
Merge pull request #4231 from dotty-staging/fix-4194
Fix #4194: only enable research plugins on experimental compiler versions
2 parents a74cc99 + aa7965a commit 7d01268

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

compiler/src/dotty/tools/dotc/config/Properties.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ trait PropertiesTrait {
5656
def scalaPropOrElse(name: String, alt: String): String = scalaProps.getProperty(name, alt)
5757
def scalaPropOrEmpty(name: String): String = scalaPropOrElse(name, "")
5858
def scalaPropOrNone(name: String): Option[String] = Option(scalaProps.getProperty(name))
59-
59+
6060
/** Either the development or release version if known, otherwise
6161
* the empty string.
6262
*/
@@ -73,7 +73,15 @@ trait PropertiesTrait {
7373
} else ""
7474
}
7575
}
76-
76+
77+
/** Whether the current version of compiler is experimental
78+
*
79+
* 1. Snapshot and nightly releases are experimental.
80+
* 2. Features supported by experimental versions of the compiler:
81+
* - research plugins
82+
*/
83+
val experimental = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY")
84+
7785
val copyrightString = scalaPropOrElse("copyright.string", "(c) 2002-2017 LAMP/EPFL")
7886

7987
/** This is the encoding to use reading in source files, overridden with -encoding

compiler/src/dotty/tools/dotc/plugins/Plugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sealed trait Plugin {
2929
* Research plugin receives a phase plan and return a new phase plan, while
3030
* non-research plugin returns a list of phases to be inserted.
3131
*/
32-
def research: Boolean = isInstanceOf[ResearchPlugin]
32+
def isResearch: Boolean = isInstanceOf[ResearchPlugin]
3333

3434
/** A description of this plugin's options, suitable as a response
3535
* to the -help command-line option. Conventionally, the options

compiler/src/dotty/tools/dotc/plugins/Plugins.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package plugins
33

44
import core._
55
import Contexts._
6-
import config.PathResolver
6+
import config.{ PathResolver, Properties }
77
import dotty.tools.io._
88
import Phases._
99
import config.Printers.plugins.{ println => debug }
@@ -128,7 +128,12 @@ trait Plugins {
128128
val updatedPlan = Plugins.schedule(plan, pluginPhases)
129129

130130
// add research plugins
131-
plugins.collect { case p: ResearchPlugin => p }.foldRight(updatedPlan) { (plug, plan) => plug.init(options(plug), plan) }
131+
if (Properties.experimental)
132+
plugins.collect { case p: ResearchPlugin => p }.foldRight(updatedPlan) {
133+
(plug, plan) => plug.init(options(plug), plan)
134+
}
135+
else
136+
updatedPlan
132137
}
133138
}
134139

0 commit comments

Comments
 (0)