Skip to content

Commit

Permalink
Merge pull request scala#5376 from milessabin/topic/clean-experimental
Browse files Browse the repository at this point in the history
Clean up of code guarded by bare -Xexperimental
  • Loading branch information
adriaanm authored Dec 1, 2016
2 parents 0339663 + 1870f1a commit 038c15e
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions bincompat-forward.whitelist.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ filter {
{
matchName="scala.sys.process.ProcessImpl#CompoundProcess.futureThread"
problemName=DirectMissingMethodProblem
},
{
matchName="scala.reflect.runtime.Settings.Yvirtpatmat"
problemName=DirectMissingMethodProblem
}
]
}
2 changes: 0 additions & 2 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
// to create it on that side. For this one my strategy is a constant def at the file
// where I need it, and then an override in Global with the setting.
override protected val etaExpandKeepsStar = settings.etaExpandKeepsStar.value
// Here comes another one...
override protected val enableTypeVarExperimentals = settings.Xexperimental.value

def getSourceFile(f: AbstractFile): BatchSourceFile = new BatchSourceFile(f, reader read f)

Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ trait ScalaSettings extends AbsScalaSettings
val inferByName = BooleanSetting ("-Yinfer-by-name", "Allow inference of by-name types. This is a temporary option to ease transition. See SI-7899.").withDeprecationMessage(removalIn212)
val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
val YpartialUnification = BooleanSetting ("-Ypartial-unification", "Enable partial unification in type constructor inference")
val Yvirtpatmat = BooleanSetting ("-Yvirtpatmat", "Enable pattern matcher virtualization")

val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method")
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper

// TODO: add fallback __match sentinel to predef
val matchStrategy: Tree =
if (!(settings.Xexperimental && context.isNameInScope(vpmName._match))) null // fast path, avoiding the next line if there's no __match to be seen
if (!(settings.Yvirtpatmat && context.isNameInScope(vpmName._match))) null // fast path, avoiding the next line if there's no __match to be seen
else newTyper(context.makeImplicit(reportAmbiguousErrors = false)).silent(_.typed(Ident(vpmName._match)), reportAmbiguousErrors = false) orElse (_ => null)

if (matchStrategy ne null) // virtualize
Expand Down
25 changes: 8 additions & 17 deletions src/reflect/scala/reflect/internal/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ trait Types
private final val propagateParameterBoundsToTypeVars = sys.props contains "scalac.debug.prop-constraints"
private final val sharperSkolems = sys.props contains "scalac.experimental.sharper-skolems"

protected val enableTypeVarExperimentals = settings.Xexperimental.value

/** Caching the most recent map has a 75-90% hit rate. */
private object substTypeMapCache {
private[this] var cached: SubstTypeMap = new SubstTypeMap(Nil, Nil)
Expand Down Expand Up @@ -3010,7 +3008,7 @@ trait Types
// EXPERIMENTAL: value will not be considered unless enableTypeVarExperimentals is true
// see SI-5729 for why this is still experimental
private var encounteredHigherLevel = false
private def shouldRepackType = enableTypeVarExperimentals && encounteredHigherLevel
private def shouldRepackType = encounteredHigherLevel

// <region name="constraint mutators + undoLog">
// invariant: before mutating constr, save old state in undoLog
Expand Down Expand Up @@ -3205,7 +3203,8 @@ trait Types
checkSubtype(tp, origin)
else if (instValid) // type var is already set
checkSubtype(tp, inst)
else isRelatable(tp) && {
else {
trackHigherLevel(tp)
unifySimple || unifyFull(tp) || (
// only look harder if our gaze is oriented toward Any
isLowerBound && (
Expand All @@ -3228,7 +3227,8 @@ trait Types

if (suspended) tp =:= origin
else if (instValid) checkIsSameType(tp)
else isRelatable(tp) && {
else {
trackHigherLevel(tp)
val newInst = wildcardToTypeVarMap(tp)
(constr isWithinBounds newInst) && {
setInst(newInst)
Expand All @@ -3251,19 +3251,10 @@ trait Types
case ts: TypeSkolem => ts.level > level
case _ => false
}
// side-effects encounteredHigherLevel
private def containsSkolemAboveLevel(tp: Type) =
(tp exists isSkolemAboveLevel) && { encounteredHigherLevel = true ; true }

/** Can this variable be related in a constraint to type `tp`?
* This is not the case if `tp` contains type skolems whose
* skolemization level is higher than the level of this variable.
*/
def isRelatable(tp: Type) = (
shouldRepackType // short circuit if we already know we've seen higher levels
|| !containsSkolemAboveLevel(tp) // side-effects tracking boolean
|| enableTypeVarExperimentals // -Xexperimental: always say we're relatable, track consequences
)
private def trackHigherLevel(tp: Type): Unit =
if(!shouldRepackType && tp.exists(isSkolemAboveLevel))
encounteredHigherLevel = true

override def normalize: Type = (
if (instValid) inst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ abstract class MutableSettings extends AbsSettings {
def uniqid: BooleanSetting
def verbose: BooleanSetting
def YpartialUnification: BooleanSetting
def Yvirtpatmat: BooleanSetting

def Yrecursion: IntSetting
def maxClassfileName: IntSetting
Expand Down
1 change: 1 addition & 0 deletions src/reflect/scala/reflect/runtime/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private[reflect] class Settings extends MutableSettings {
val uniqid = new BooleanSetting(false)
val verbose = new BooleanSetting(false)
val YpartialUnification = new BooleanSetting(false)
val Yvirtpatmat = new BooleanSetting(false)

val Yrecursion = new IntSetting(0)
val maxClassfileName = new IntSetting(255)
Expand Down
7 changes: 7 additions & 0 deletions test/files/neg/t5729.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
t5729.scala:5: error: ambiguous reference to overloaded definition,
both method join in object Test of type [S](in: Seq[T[S]])String
and method join in object Test of type (in: Seq[T[_]])Int
match argument types (Seq[T[_]])
join(null: Seq[T[_]])
^
one error found
File renamed without changes.
2 changes: 1 addition & 1 deletion test/files/run/virtpatmat_staging.flags
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-Yrangepos:false
-Xexperimental
-Yvirtpatmat

0 comments on commit 038c15e

Please sign in to comment.