From 01535229108bba2a4c75f70b936e8e9a9a4431db Mon Sep 17 00:00:00 2001 From: Lars Hupel Date: Mon, 28 Nov 2016 14:49:17 +0100 Subject: remove deprecated compiler flag "-Yeta-expand-keeps-star" This was slated for removal in 2.12. --- project/ScalaOptionParser.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 6 ------ src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 1 - src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala | 2 +- src/reflect/scala/reflect/internal/tpe/TypeMaps.scala | 10 +--------- test/files/neg/eta-expand-star-deprecation.check | 4 ---- test/files/neg/eta-expand-star-deprecation.flags | 1 - test/files/neg/eta-expand-star-deprecation.scala | 8 -------- test/files/run/eta-expand-star2.check | 2 -- test/files/run/eta-expand-star2.flags | 1 - test/files/run/eta-expand-star2.scala | 8 -------- 11 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 test/files/neg/eta-expand-star-deprecation.check delete mode 100644 test/files/neg/eta-expand-star-deprecation.flags delete mode 100644 test/files/neg/eta-expand-star-deprecation.scala delete mode 100644 test/files/run/eta-expand-star2.check delete mode 100644 test/files/run/eta-expand-star2.flags delete mode 100644 test/files/run/eta-expand-star2.scala diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala index af82f8fce5..bcc561cb0d 100644 --- a/project/ScalaOptionParser.scala +++ b/project/ScalaOptionParser.scala @@ -83,7 +83,7 @@ object ScalaOptionParser { 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", "-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xstrict-inference", "-Xverify", "-Y", "-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug", - "-Yeta-expand-keeps-star", "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", + "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand", "-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef", "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypartial-unification", "-Ypos-debug", "-Ypresentation-debug", diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 464fa1ad18..873a5947ed 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -341,12 +341,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) s"[search path for class files: ${classPath.asClassPathString}]" ) - // The current division between scala.reflect.* and scala.tools.nsc.* is pretty - // clunky. It is often difficult to have a setting influence something without having - // 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 - def getSourceFile(f: AbstractFile): BatchSourceFile = new BatchSourceFile(f, reader read f) def getSourceFile(name: String): SourceFile = { diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index a3b9df1518..4e69c35f96 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -211,7 +211,6 @@ trait ScalaSettings extends AbsScalaSettings val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects") val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "") val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overridden methods.") - val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.").withDeprecationMessage(removalIn212) 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") diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 97de2b6c85..5f4fa499b6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -105,7 +105,7 @@ trait EtaExpansion { self: Analyzer => val origTpe = sym.tpe val isRepeated = definitions.isRepeatedParamType(origTpe) // SI-4176 Don't leak A* in eta-expanded function types. See t4176b.scala - val droppedStarTpe = if (settings.etaExpandKeepsStar) origTpe else dropIllegalStarTypes(origTpe) + val droppedStarTpe = dropIllegalStarTypes(origTpe) val valDef = ValDef(Modifiers(SYNTHETIC | PARAM), sym.name.toTermName, TypeTree(droppedStarTpe), EmptyTree) (valDef, isRepeated) } diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index 08219c0634..de065d0b5d 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -53,14 +53,6 @@ private[internal] trait TypeMaps { } } - // Set to true for A* => Seq[A] - // (And it will only rewrite A* in method result types.) - // This is the pre-existing behavior. - // Or false for Seq[A] => Seq[A] - // (It will rewrite A* everywhere but method parameters.) - // This is the specified behavior. - protected def etaExpandKeepsStar = false - /** Turn any T* types into Seq[T] except when * in method parameter position. */ @@ -74,7 +66,7 @@ private[internal] trait TypeMaps { case TypeRef(_, RepeatedParamClass, arg :: Nil) => seqType(arg) case _ => - if (etaExpandKeepsStar) tp else mapOver(tp) + mapOver(tp) } } diff --git a/test/files/neg/eta-expand-star-deprecation.check b/test/files/neg/eta-expand-star-deprecation.check deleted file mode 100644 index a79f0df76c..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.check +++ /dev/null @@ -1,4 +0,0 @@ -warning: -Yeta-expand-keeps-star is deprecated: This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug. -error: No warnings can be incurred under -Xfatal-warnings. -one warning found -one error found diff --git a/test/files/neg/eta-expand-star-deprecation.flags b/test/files/neg/eta-expand-star-deprecation.flags deleted file mode 100644 index 5ac8b638e4..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.flags +++ /dev/null @@ -1 +0,0 @@ --Yeta-expand-keeps-star -deprecation -Xfatal-warnings diff --git a/test/files/neg/eta-expand-star-deprecation.scala b/test/files/neg/eta-expand-star-deprecation.scala deleted file mode 100644 index 5749692522..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def f[T](xs: T*): Unit = () - def g[T] = f[T] _ - - def main(args: Array[String]): Unit = { - g(1, 2) - } -} diff --git a/test/files/run/eta-expand-star2.check b/test/files/run/eta-expand-star2.check deleted file mode 100644 index d6929e4969..0000000000 --- a/test/files/run/eta-expand-star2.check +++ /dev/null @@ -1,2 +0,0 @@ -warning: there was one deprecation warning; re-run with -deprecation for details -hello diff --git a/test/files/run/eta-expand-star2.flags b/test/files/run/eta-expand-star2.flags deleted file mode 100644 index 0402fe55a4..0000000000 --- a/test/files/run/eta-expand-star2.flags +++ /dev/null @@ -1 +0,0 @@ --Yeta-expand-keeps-star \ No newline at end of file diff --git a/test/files/run/eta-expand-star2.scala b/test/files/run/eta-expand-star2.scala deleted file mode 100644 index eb650788d0..0000000000 --- a/test/files/run/eta-expand-star2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def f[T](xs: T*): T = xs.head - def g[T] = f[T] _ - - def main(args: Array[String]): Unit = { - println(g("hello")) - } -} -- cgit v1.2.3 From c7b818fdd7776d1e0230af025eb81ebc0d6aebe0 Mon Sep 17 00:00:00 2001 From: Lars Hupel Date: Mon, 28 Nov 2016 14:57:39 +0100 Subject: remove deprecated compiler flag "-Yinfer-by-name" This was slated for removal in 2.12. --- project/ScalaOptionParser.scala | 2 +- .../scala/tools/nsc/settings/ScalaSettings.scala | 1 - .../scala/tools/nsc/typechecker/Infer.scala | 6 ++---- test/files/run/t7899-regression.check | 1 - test/files/run/t7899-regression.flags | 1 - test/files/run/t7899-regression.scala | 24 ---------------------- 6 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 test/files/run/t7899-regression.check delete mode 100644 test/files/run/t7899-regression.flags delete mode 100644 test/files/run/t7899-regression.scala diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala index bcc561cb0d..dfc9d481a9 100644 --- a/project/ScalaOptionParser.scala +++ b/project/ScalaOptionParser.scala @@ -83,7 +83,7 @@ object ScalaOptionParser { 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", "-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xstrict-inference", "-Xverify", "-Y", "-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug", - "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", + "-Yide-debug", "-Yinfer-argument-types", "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand", "-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef", "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypartial-unification", "-Ypos-debug", "-Ypresentation-debug", diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 4e69c35f96..9ec2db6d06 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -211,7 +211,6 @@ trait ScalaSettings extends AbsScalaSettings val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects") val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "") val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overridden methods.") - 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") diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 0071d66eb9..e8147dbf3a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -936,10 +936,8 @@ trait Infer extends Checkable { def infer_s = map3(tparams, tvars, targs)((tparam, tvar, targ) => s"$tparam=$tvar/$targ") mkString "," printTyping(tree, s"infer expr instance from pt=$pt, $infer_s") - // SI-7899 inferring by-name types is unsound. The correct behaviour is conditional because the hole is - // exploited in Scalaz (Free.scala), as seen in: run/t7899-regression. - def dropByNameIfStrict(tp: Type): Type = if (settings.inferByName) tp else dropByName(tp) - def targsStrict = if (targs eq null) null else targs mapConserve dropByNameIfStrict + // SI-7899 inferring by-name types is unsound + def targsStrict = if (targs eq null) null else targs mapConserve dropByName if (keepNothings || (targs eq null)) { //@M: adjustTypeArgs fails if targs==null, neg/t0226 substExpr(tree, tparams, targsStrict, pt) diff --git a/test/files/run/t7899-regression.check b/test/files/run/t7899-regression.check deleted file mode 100644 index 602b03a1d1..0000000000 --- a/test/files/run/t7899-regression.check +++ /dev/null @@ -1 +0,0 @@ -warning: -Yinfer-by-name is deprecated: This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug. diff --git a/test/files/run/t7899-regression.flags b/test/files/run/t7899-regression.flags deleted file mode 100644 index 553a27eafd..0000000000 --- a/test/files/run/t7899-regression.flags +++ /dev/null @@ -1 +0,0 @@ --Yinfer-by-name -deprecation diff --git a/test/files/run/t7899-regression.scala b/test/files/run/t7899-regression.scala deleted file mode 100644 index 67d38cdd1d..0000000000 --- a/test/files/run/t7899-regression.scala +++ /dev/null @@ -1,24 +0,0 @@ -import language.higherKinds - -object Test { - trait Monad[M[_]] { - def foo[A](ma: M[A])(f: M[A] => Any) = f(ma) - } - implicit def function1Covariant[T]: Monad[({type l[a] = (T => a)})#l] = - new Monad[({type l[a] = (T => a)})#l] {} - - def main(args: Array[String]) { - // inference of T = (=> Any) here was outlawed by SI-7899 / 8ed7099 - // but this pattern is used in Scalaz in just a few places and caused - // a regression. - // - // Inference of a by-name type doesn't *always* lead to a ClassCastException, - // it only gets there if a method in generic code accepts a parameter of - // that type. - // - // We need to introduce the stricter inference rules gradually, probably - // with a warning. - val m = implicitly[Monad[({type f[+x] = (=> Any) => x})#f]] - assert(m.foo[Int]((x => 0))(f => f(???)) == 0) - } -} -- cgit v1.2.3 From ae9a194b3a4d45f70b4fd9569833e036e9d31eda Mon Sep 17 00:00:00 2001 From: Lars Hupel Date: Mon, 28 Nov 2016 17:12:32 +0100 Subject: delete dead code --- src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 9ec2db6d06..5455111674 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -319,8 +319,6 @@ trait ScalaSettings extends AbsScalaSettings val YoptLogInline = StringSetting("-Yopt-log-inline", "package/Class.method", "Print a summary of inliner activity; `_` to print all, prefix match to select.", "") - private def removalIn212 = "This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug." - object YstatisticsPhases extends MultiChoiceEnumeration { val parser, typer, patmat, erasure, cleanup, jvm = Value } val Ystatistics = { val description = "Print compiler statistics for specific phases" -- cgit v1.2.3