diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-11-30 16:28:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 16:28:02 -0800 |
commit | 038c15e405b9498863a2236707686a7933748c60 (patch) | |
tree | c5caba00c846b65f06b1232e7ad19666aa83ebb6 | |
parent | 0339663cbbd4d22b0758257f2ce078b5a007f316 (diff) | |
parent | 1870f1af7e81bbe46ea653d6c5ee5bfe476d277b (diff) | |
download | scala-038c15e405b9498863a2236707686a7933748c60.tar.gz scala-038c15e405b9498863a2236707686a7933748c60.tar.bz2 scala-038c15e405b9498863a2236707686a7933748c60.zip |
Merge pull request #5376 from milessabin/topic/clean-experimental
Clean up of code guarded by bare -Xexperimental
-rw-r--r-- | bincompat-forward.whitelist.conf | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 25 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/settings/MutableSettings.scala | 1 | ||||
-rw-r--r-- | src/reflect/scala/reflect/runtime/Settings.scala | 1 | ||||
-rw-r--r-- | test/files/neg/t5729.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5729.scala (renamed from test/files/pos/t5729.scala) | 0 | ||||
-rw-r--r-- | test/files/run/virtpatmat_staging.flags | 2 |
10 files changed, 24 insertions, 21 deletions
diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 541268e50e..aebd2c8d1b 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -20,6 +20,10 @@ filter { { matchName="scala.sys.process.ProcessImpl#CompoundProcess.futureThread" problemName=DirectMissingMethodProblem + }, + { + matchName="scala.reflect.runtime.Settings.Yvirtpatmat" + problemName=DirectMissingMethodProblem } ] } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index e58d2d3b43..9c9be4eb4d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -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) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 5eb99e0d98..a3b9df1518 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -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") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 78533bdfc5..de72d9feed 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -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 diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 5e1bf37b80..dc35053835 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -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) @@ -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 @@ -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 && ( @@ -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) @@ -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 diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala index 5a2c802476..ab933ae617 100644 --- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala @@ -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 diff --git a/src/reflect/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala index 3b33f089e1..2d8bacd3b2 100644 --- a/src/reflect/scala/reflect/runtime/Settings.scala +++ b/src/reflect/scala/reflect/runtime/Settings.scala @@ -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) diff --git a/test/files/neg/t5729.check b/test/files/neg/t5729.check new file mode 100644 index 0000000000..10c13db8b6 --- /dev/null +++ b/test/files/neg/t5729.check @@ -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 diff --git a/test/files/pos/t5729.scala b/test/files/neg/t5729.scala index 9fd9c9ffbb..9fd9c9ffbb 100644 --- a/test/files/pos/t5729.scala +++ b/test/files/neg/t5729.scala diff --git a/test/files/run/virtpatmat_staging.flags b/test/files/run/virtpatmat_staging.flags index 0a22f7c729..bec3aa96e9 100644 --- a/test/files/run/virtpatmat_staging.flags +++ b/test/files/run/virtpatmat_staging.flags @@ -1,2 +1,2 @@ -Yrangepos:false --Xexperimental +-Yvirtpatmat |