Skip to content

Commit 56bc6a8

Browse files
committed
remove -Xstrict-inference
"-Xstrict-inference was intended only as a coarse hacky start", says Paul at scala/bug#6680 (comment) GitHub search shows very few uses in the wild. My best is that a few people just enabled it because the name/description made it sound good/safer.
1 parent dde2c0f commit 56bc6a8

23 files changed

+3
-212
lines changed

project/ScalaOptionParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object ScalaOptionParser {
8383

8484
// TODO retrieve this data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala
8585
private def booleanSettingNames = List("-X", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xfull-lubs", "-Xfuture", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls",
86-
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xstrict-inference", "-Xverify", "-Y",
86+
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
8787
"-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
8888
"-Yide-debug", "-Yinfer-argument-types",
8989
"-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ trait ScalaSettings extends AbsScalaSettings
141141
val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.")
142142
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
143143
val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom reporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter")
144-
val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types")
145144
val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see scala/bug#8126.", initial = ScalaVersion("2.13"))
146145

147146
val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")

src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ trait PatternTypers {
179179
def eligible(tparam: Symbol) = (
180180
tparam.isTypeParameterOrSkolem
181181
&& tparam.owner.isTerm
182-
&& (settings.strictInference || !variance.isInvariant)
182+
&& !variance.isInvariant
183183
)
184184

185185
def skolems = try skolemBuffer.toList finally skolemBuffer.clear()
@@ -225,19 +225,11 @@ trait PatternTypers {
225225
*
226226
* see test/files/../t5189*.scala
227227
*/
228-
private def convertToCaseConstructor(tree: Tree, caseClass: Symbol, ptIn: Type): Tree = {
229-
// TODO scala/bug#7886 / scala/bug#5900 This is well intentioned but doesn't quite hit the nail on the head.
230-
// For now, I've put it completely behind -Xstrict-inference.
231-
val untrustworthyPt = settings.strictInference && (
232-
ptIn =:= AnyTpe
233-
|| ptIn =:= NothingTpe
234-
|| ptIn.typeSymbol != caseClass
235-
)
228+
private def convertToCaseConstructor(tree: Tree, caseClass: Symbol, pt: Type): Tree = {
236229
val variantToSkolem = new VariantToSkolemMap
237230
val caseClassType = tree.tpe.prefix memberType caseClass
238231
val caseConstructorType = caseClassType memberType caseClass.primaryConstructor
239232
val tree1 = TypeTree(caseConstructorType) setOriginal tree
240-
val pt = if (untrustworthyPt) caseClassType else ptIn
241233

242234
// have to open up the existential and put the skolems in scope
243235
// can't simply package up pt in an ExistentialType, because that takes us back to square one (List[_ <: T] == List[T] due to covariance)

src/manual/scala/man1/scalac.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ object scalac extends Command {
305305
Definition(
306306
CmdOption("Xsource-reader", Argument("classname")),
307307
"Specify a custom method for reading source files."),
308-
Definition(
309-
CmdOption("Xstrict-inference"),
310-
"Don't infer known-unsound types."),
311308
Definition(
312309
CmdOption("Xverify"),
313310
"Verify generic signatures in generated bytecode (asm backend only)."),

src/reflect/scala/reflect/internal/settings/MutableSettings.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ abstract class MutableSettings extends AbsSettings {
3939
def XfullLubs: BooleanSetting
4040
def XnoPatmatAnalysis: BooleanSetting
4141
def Xprintpos: BooleanSetting
42-
def strictInference: BooleanSetting
4342
def Yposdebug: BooleanSetting
4443
def Yrangepos: BooleanSetting
4544
def Yshowsymowners: BooleanSetting

src/reflect/scala/reflect/internal/tpe/GlbLubs.scala

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ private[internal] trait GlbLubs {
1515
import statistics._
1616

1717
private final val printLubs = System.getProperty("scalac.debug.lub") != null
18-
private final val strictInference = settings.strictInference
1918

2019
/** In case anyone wants to turn off lub verification without reverting anything. */
2120
private final val verifyLubs = true
@@ -64,26 +63,6 @@ private[internal] trait GlbLubs {
6463
}
6564
}
6665

67-
// only called when strictInference
68-
private def willViolateRecursiveBounds(tp: Type, ts: List[Type], tsElimSub: List[Type]) = {
69-
val typeSym = ts.head.typeSymbol // we're uniform, the `.head` is as good as any.
70-
def fbounds = findRecursiveBounds(ts) map (_._2)
71-
def isRecursive = typeSym.typeParams exists fbounds.contains
72-
73-
isRecursive && (transposeSafe(tsElimSub map (_.normalize.typeArgs)) match {
74-
case Some(arggsTransposed) =>
75-
val mergedTypeArgs = (tp match { case et: ExistentialType => et.underlying; case _ => tp}).typeArgs
76-
exists3(typeSym.typeParams, mergedTypeArgs, arggsTransposed) {
77-
(param, arg, lubbedArgs) =>
78-
val isExistential = arg.typeSymbol.isExistentiallyBound
79-
val isInFBound = fbounds contains param
80-
val wasLubbed = !lubbedArgs.exists(_ =:= arg)
81-
(!isExistential && isInFBound && wasLubbed)
82-
}
83-
case None => false
84-
})
85-
}
86-
8766
/** Given a matrix `tsBts` whose columns are basetype sequences (and the symbols `tsParams` that should be interpreted as type parameters in this matrix),
8867
* compute its least sorted upwards closed upper bound relative to the following ordering <= between lists of types:
8968
*
@@ -136,9 +115,6 @@ private[internal] trait GlbLubs {
136115
val ts1 = elimSub(ts0, depth) map elimHigherOrderTypeParam
137116
mergePrefixAndArgs(ts1, Covariant, depth) match {
138117
case NoType => loop(pretypes, tails)
139-
case tp if strictInference && willViolateRecursiveBounds(tp, ts0, ts1) =>
140-
log(s"Breaking recursion in lublist, advancing frontier and discarding merged prefix/args from $tp")
141-
loop(pretypes, tails)
142118
case tp =>
143119
loop(tp :: pretypes, tails)
144120
}

src/reflect/scala/reflect/runtime/Settings.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ private[reflect] class Settings extends MutableSettings {
3232

3333
val XfullLubs = new BooleanSetting(false)
3434
val XnoPatmatAnalysis = new BooleanSetting(false)
35-
val strictInference = new BooleanSetting(false)
3635
val Xprintpos = new BooleanSetting(false)
3736
val Yposdebug = new BooleanSetting(false)
3837
val Yrangepos = new BooleanSetting(false)

test/files/neg/gadts2-strict.check

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/files/neg/gadts2-strict.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/neg/gadts2-strict.scala

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/files/neg/gadts2.check

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/files/neg/gadts2.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/neg/gadts2.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/files/neg/run-gadts-strict.check

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/files/neg/run-gadts-strict.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/neg/run-gadts-strict.scala

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/files/neg/t6680a.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/t2251.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/t2251.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/t2251.scala

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/files/run/t2251b.check

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/files/run/t2251b.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/t2251b.scala

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)