diff options
author | Miles Sabin <miles@milessabin.com> | 2016-11-28 13:59:28 +0000 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2016-11-28 13:59:28 +0000 |
commit | 1870f1af7e81bbe46ea653d6c5ee5bfe476d277b (patch) | |
tree | 63d3b877ffa9c0c0f961eb274f628a6ae9f29a6c | |
parent | 6ec56abd80cb8f4c4f2c4a8b4788d2e17ce84942 (diff) | |
download | scala-1870f1af7e81bbe46ea653d6c5ee5bfe476d277b.tar.gz scala-1870f1af7e81bbe46ea653d6c5ee5bfe476d277b.tar.bz2 scala-1870f1af7e81bbe46ea653d6c5ee5bfe476d277b.zip |
Typevar experimentals now default; t5729 pos -> neg.
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 25 | ||||
-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 |
4 files changed, 15 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index a7880c72d7..d651d523a8 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -330,8 +330,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/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index f8679616d1..aa30c4a4c8 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/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 |