From 7d5e0b01c7f645e4f727f704a18f93ce5c69a9dd Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Mon, 15 Jan 2018 16:02:14 +0000 Subject: [PATCH] Partial unification unconditional; deprecate -Xexperimental Partial unification is now enabled unless -Xsource:2.12 is specified. The -Ypartial-unification flag has been removed and the -Xexperimental option, which is now redundant, has been deprecated. --- project/ScalaOptionParser.scala | 2 +- .../tools/nsc/settings/ScalaSettings.scala | 7 ++--- .../transform/patmat/MatchTranslation.scala | 2 +- .../scala/tools/nsc/typechecker/Typers.scala | 2 +- src/manual/scala/man1/scalac.scala | 3 -- .../scala/reflect/internal/Definitions.scala | 2 +- .../scala/reflect/internal/Types.scala | 2 +- .../internal/settings/MutableSettings.scala | 2 -- .../scala/reflect/runtime/Settings.scala | 2 -- test/files/neg/deprecated-experimental.check | 6 ++++ test/files/neg/deprecated-experimental.flags | 1 + test/files/neg/deprecated-experimental.scala | 1 + test/files/neg/names-defaults-neg-pu.flags | 2 +- test/files/neg/sealed-java-enums.flags | 2 +- test/files/neg/t2712-1.check | 4 +-- test/files/neg/t2712-1.flags | 1 + test/files/neg/t2712-1.scala | 2 +- test/files/neg/t2712-2.check | 4 +-- test/files/neg/t2712-2.flags | 1 - test/files/neg/t2712-2.scala | 4 +-- test/files/neg/t2712-3.check | 2 +- test/files/neg/t2712-3.flags | 1 + test/files/neg/t2712-3.scala | 4 +-- test/files/neg/t2712-8.flags | 1 - test/files/neg/t5683.flags | 1 + test/files/neg/t8237-default-212.check | 13 +++++++++ test/files/neg/t8237-default-212.flags | 1 + test/files/neg/t8237-default-212.scala | 29 +++++++++++++++++++ test/files/neg/t8237-default-pu.flags | 1 - test/files/pos/infersingle.flags | 1 - test/files/pos/t2712-1.flags | 1 - test/files/pos/t2712-2.flags | 2 -- test/files/pos/t2712-3.flags | 2 -- test/files/pos/t2712-4.flags | 2 -- test/files/pos/t2712-5.flags | 1 - test/files/pos/t2712-6.flags | 1 - test/files/pos/t2712-7.flags | 1 - test/files/pos/t5683.flags | 1 - test/files/pos/t9178b.flags | 1 - test/files/pos/virtpatmat_alts_subst.flags | 1 - test/files/pos/virtpatmat_binding_opt.flags | 1 - test/files/pos/virtpatmat_castbinder.flags | 1 - test/files/pos/virtpatmat_exist1.flags | 1 - test/files/pos/virtpatmat_exist2.flags | 1 - test/files/pos/virtpatmat_exist3.flags | 1 - test/files/pos/virtpatmat_gadt_array.flags | 1 - .../files/pos/virtpatmat_infer_single_1.flags | 1 - .../pos/virtpatmat_instof_valuetype.flags | 1 - test/files/pos/virtpatmat_obj_in_case.flags | 1 - test/files/run/checked.scala | 2 +- test/files/run/constrained-types.scala | 1 - .../run/inferred-type-constructors-hou.flags | 1 - .../run/inferred-type-constructors.check | 1 + .../run/inferred-type-constructors.scala | 1 + test/files/run/sammy_java8.scala | 2 -- test/files/run/t9178a.flags | 1 - test/files/run/t9489.flags | 1 - test/files/run/virtpatmat_apply.flags | 1 - test/files/run/virtpatmat_casting.flags | 1 - test/files/run/virtpatmat_literal.flags | 1 - test/files/run/virtpatmat_npe.flags | 1 - test/files/run/virtpatmat_partial.flags | 1 - test/files/run/virtpatmat_stringinterp.flags | 1 - test/files/run/virtpatmat_switch.flags | 1 - .../virtpatmat_tailcalls_verifyerror.flags | 1 - test/files/run/virtpatmat_try.flags | 1 - test/files/run/virtpatmat_typed.flags | 1 - test/files/run/virtpatmat_unapply.flags | 1 - test/files/run/virtpatmat_unapplyprod.flags | 1 - test/files/run/virtpatmat_unapplyseq.flags | 1 - .../tools/nsc/settings/SettingsTest.scala | 12 -------- 71 files changed, 76 insertions(+), 87 deletions(-) create mode 100644 test/files/neg/deprecated-experimental.check create mode 100644 test/files/neg/deprecated-experimental.flags create mode 100644 test/files/neg/deprecated-experimental.scala create mode 100644 test/files/neg/t2712-1.flags delete mode 100644 test/files/neg/t2712-2.flags create mode 100644 test/files/neg/t2712-3.flags delete mode 100644 test/files/neg/t2712-8.flags create mode 100644 test/files/neg/t5683.flags create mode 100644 test/files/neg/t8237-default-212.check create mode 100644 test/files/neg/t8237-default-212.flags create mode 100644 test/files/neg/t8237-default-212.scala delete mode 100644 test/files/neg/t8237-default-pu.flags delete mode 100644 test/files/pos/infersingle.flags delete mode 100644 test/files/pos/t2712-1.flags delete mode 100644 test/files/pos/t2712-2.flags delete mode 100644 test/files/pos/t2712-3.flags delete mode 100644 test/files/pos/t2712-4.flags delete mode 100644 test/files/pos/t2712-5.flags delete mode 100644 test/files/pos/t2712-6.flags delete mode 100644 test/files/pos/t2712-7.flags delete mode 100644 test/files/pos/t5683.flags delete mode 100644 test/files/pos/t9178b.flags delete mode 100644 test/files/pos/virtpatmat_alts_subst.flags delete mode 100644 test/files/pos/virtpatmat_binding_opt.flags delete mode 100644 test/files/pos/virtpatmat_castbinder.flags delete mode 100644 test/files/pos/virtpatmat_exist1.flags delete mode 100644 test/files/pos/virtpatmat_exist2.flags delete mode 100644 test/files/pos/virtpatmat_exist3.flags delete mode 100644 test/files/pos/virtpatmat_gadt_array.flags delete mode 100644 test/files/pos/virtpatmat_infer_single_1.flags delete mode 100644 test/files/pos/virtpatmat_instof_valuetype.flags delete mode 100644 test/files/pos/virtpatmat_obj_in_case.flags delete mode 100644 test/files/run/inferred-type-constructors-hou.flags delete mode 100644 test/files/run/t9178a.flags delete mode 100644 test/files/run/t9489.flags delete mode 100644 test/files/run/virtpatmat_apply.flags delete mode 100644 test/files/run/virtpatmat_casting.flags delete mode 100644 test/files/run/virtpatmat_literal.flags delete mode 100644 test/files/run/virtpatmat_npe.flags delete mode 100644 test/files/run/virtpatmat_partial.flags delete mode 100644 test/files/run/virtpatmat_stringinterp.flags delete mode 100644 test/files/run/virtpatmat_switch.flags delete mode 100644 test/files/run/virtpatmat_tailcalls_verifyerror.flags delete mode 100644 test/files/run/virtpatmat_try.flags delete mode 100644 test/files/run/virtpatmat_typed.flags delete mode 100644 test/files/run/virtpatmat_unapply.flags delete mode 100644 test/files/run/virtpatmat_unapplyprod.flags delete mode 100644 test/files/run/virtpatmat_unapplyseq.flags diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala index 0715a27ae19e..c0d25839dcaf 100644 --- a/project/ScalaOptionParser.scala +++ b/project/ScalaOptionParser.scala @@ -88,7 +88,7 @@ object ScalaOptionParser { "-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", + "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug", "-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based", "-Yrepl-sync", "-Yshow-member-pos", "-Yshow-symkinds", "-Yshow-symowners", "-Yshow-syms", "-Yshow-trees", "-Yshow-trees-compact", "-Yshow-trees-stringified", "-Ytyper-debug", "-Ywarn-adapted-args", "-Ywarn-dead-code", "-Ywarn-inaccessible", "-Ywarn-infer-any", "-Ywarn-nullary-override", "-Ywarn-nullary-unit", "-Ywarn-numeric-widen", "-Ywarn-unused-import", "-Ywarn-value-discard", diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 3d72f369e5fe..cf7b87eabd4e 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -30,9 +30,6 @@ trait ScalaSettings extends AbsScalaSettings */ protected def defaultClasspath = Option(System.getenv("CLASSPATH")).getOrElse(".") - /** Enabled under -Xexperimental. */ - protected def experimentalSettings = List[BooleanSetting](YpartialUnification) - /** Enabled under -Xfuture. */ protected def futureSettings = List[BooleanSetting]() @@ -233,7 +230,6 @@ trait ScalaSettings extends AbsScalaSettings val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.") val YcachePluginClassLoader = CachePolicy.setting("plugin", "compiler plugins") val YcacheMacroClassLoader = CachePolicy.setting("macro", "macros") - 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() @@ -441,7 +437,8 @@ trait ScalaSettings extends AbsScalaSettings opt.enable(optChoices.lInline) optInlineFrom.value = List("**") }) - val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enablingIfNotSetByUser experimentalSettings + val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions in Scala 2.12 and earlier.") + .withDeprecationMessage(s"In 2.13 all options previously enabled by -Xexperimental are enabled by default or removed.") // Feature extensions val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.") diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 7a84f14942f8..5c16714fe52e 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -223,7 +223,7 @@ trait MatchTranslation { // val packedPt = repeatedToSeq(typer.packedType(match_, context.owner)) val selectorSym = freshSym(selector.pos, pureType(selectorTp)) setFlag treeInfo.SYNTH_CASE_FLAGS - // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental + // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala val combined = combineCases(selector, selectorSym, nonSyntheticCases map translateCase(selectorSym, pt), pt, matchOwner, defaultOverride) if (StatisticsStatics.areSomeColdStatsEnabled) statistics.stopTimer(statistics.patmatNanos, start) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 101eff38b4c6..94fd80ca5923 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2966,7 +2966,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper * * Based on the expected type pt, potentially synthesize an instance of * - PartialFunction, - * - a type with a Single Abstract Method (under -Xexperimental for now). + * - a type with a Single Abstract Method. */ private def typedFunction(fun: Function, mode: Mode, pt: Type): Tree = { val vparams = fun.vparams diff --git a/src/manual/scala/man1/scalac.scala b/src/manual/scala/man1/scalac.scala index c5046416abea..8d533a122f9d 100644 --- a/src/manual/scala/man1/scalac.scala +++ b/src/manual/scala/man1/scalac.scala @@ -199,9 +199,6 @@ object scalac extends Command { CmdOption("Xelide-below", Argument("n")), "Calls to " & MItalic("@elidable") & " methods are omitted if method priority is lower than argument."), - Definition( - CmdOption("Xexperimental"), - "Enable experimental extensions"), Definition( CmdOption("Xfatal-warnings"), "Fail the compilation if there are any warnings."), diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 2baf42a1da33..6b1ace7d33cc 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -839,7 +839,7 @@ trait Definitions extends api.StandardDefinitions { (sym eq PartialFunctionClass) || (sym eq AbstractPartialFunctionClass) } - private[this] val doSam = settings.isScala212 || (settings.isScala211 && settings.Xexperimental) + private[this] val doSam = settings.isScala212 /** The single abstract method declared by type `tp` (or `NoSymbol` if it cannot be found). * diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index a3173f87f678..01559063c816 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3333,7 +3333,7 @@ trait Types // This is a higher-kinded type var with same arity as tp. // If so (see scala/bug#7517), side effect: adds the type constructor itself as a bound. isSubArgs(lhs, rhs, params, AnyDepth) && {addBound(tp.typeConstructor); true} - } else if (settings.YpartialUnification && numCaptured > 0) { + } else if (settings.isScala213 && numCaptured > 0) { // Simple algorithm as suggested by Paul Chiusano in the comments on scala/bug#2712 // // https://github.com/scala/bug/issues/2712#issuecomment-292374655 diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala index 5ef0de9022ba..46def7ef9524 100644 --- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala @@ -36,7 +36,6 @@ abstract class MutableSettings extends AbsSettings { def valueSetByUser: Option[T] = if (isSetByUser) Some(value) else None } - def Xexperimental: BooleanSetting def XfullLubs: BooleanSetting def XnoPatmatAnalysis: BooleanSetting def Xprintpos: BooleanSetting @@ -53,7 +52,6 @@ abstract class MutableSettings extends AbsSettings { def printtypes: BooleanSetting def uniqid: BooleanSetting def verbose: BooleanSetting - def YpartialUnification: BooleanSetting def Yvirtpatmat: BooleanSetting // Define them returning a `Boolean` to avoid breaking bincompat change diff --git a/src/reflect/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala index 6b129f6ec51a..7d6877c25ae7 100644 --- a/src/reflect/scala/reflect/runtime/Settings.scala +++ b/src/reflect/scala/reflect/runtime/Settings.scala @@ -30,7 +30,6 @@ private[reflect] class Settings extends MutableSettings { override def value: List[String] = v } - val Xexperimental = new BooleanSetting(false) val XfullLubs = new BooleanSetting(false) val XnoPatmatAnalysis = new BooleanSetting(false) val strictInference = new BooleanSetting(false) @@ -47,7 +46,6 @@ private[reflect] class Settings extends MutableSettings { val printtypes = new BooleanSetting(false) 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) diff --git a/test/files/neg/deprecated-experimental.check b/test/files/neg/deprecated-experimental.check new file mode 100644 index 000000000000..1af5ff3c5272 --- /dev/null +++ b/test/files/neg/deprecated-experimental.check @@ -0,0 +1,6 @@ +warning: -Xexperimental is deprecated: In 2.13 all options previously enabled by -Xexperimental are enabled by default or removed. +deprecated-experimental.scala:1: error: expected class or object definition +wibble +^ +one warning found +one error found diff --git a/test/files/neg/deprecated-experimental.flags b/test/files/neg/deprecated-experimental.flags new file mode 100644 index 000000000000..52273c272f20 --- /dev/null +++ b/test/files/neg/deprecated-experimental.flags @@ -0,0 +1 @@ +-deprecation -Xexperimental diff --git a/test/files/neg/deprecated-experimental.scala b/test/files/neg/deprecated-experimental.scala new file mode 100644 index 000000000000..15363c985e90 --- /dev/null +++ b/test/files/neg/deprecated-experimental.scala @@ -0,0 +1 @@ +wibble diff --git a/test/files/neg/names-defaults-neg-pu.flags b/test/files/neg/names-defaults-neg-pu.flags index 6840a7a6ed2e..dcc59ebe32ef 100644 --- a/test/files/neg/names-defaults-neg-pu.flags +++ b/test/files/neg/names-defaults-neg-pu.flags @@ -1 +1 @@ --deprecation -Ypartial-unification +-deprecation diff --git a/test/files/neg/sealed-java-enums.flags b/test/files/neg/sealed-java-enums.flags index e709c6591866..85d8eb2ba295 100644 --- a/test/files/neg/sealed-java-enums.flags +++ b/test/files/neg/sealed-java-enums.flags @@ -1 +1 @@ --Xexperimental -Xfatal-warnings +-Xfatal-warnings diff --git a/test/files/neg/t2712-1.check b/test/files/neg/t2712-1.check index 61e4b6b1499c..b2485d3d5713 100644 --- a/test/files/neg/t2712-1.check +++ b/test/files/neg/t2712-1.check @@ -3,11 +3,11 @@ t2712-1.scala:7: error: no type parameters for method foo: (m: M[A])Unit exist s argument expression's type is not compatible with formal parameter type; found : test.Two[Int,String] required: ?M[?A] - def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled* + def test(ma: Two[Int, String]) = foo(ma) // should fail with -Xsource:2.12 ^ t2712-1.scala:7: error: type mismatch; found : test.Two[Int,String] required: M[A] - def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled* + def test(ma: Two[Int, String]) = foo(ma) // should fail with -Xsource:2.12 ^ two errors found diff --git a/test/files/neg/t2712-1.flags b/test/files/neg/t2712-1.flags new file mode 100644 index 000000000000..0acce1e7ce9c --- /dev/null +++ b/test/files/neg/t2712-1.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/neg/t2712-1.scala b/test/files/neg/t2712-1.scala index f7967d71b689..a1402ee5a8d5 100644 --- a/test/files/neg/t2712-1.scala +++ b/test/files/neg/t2712-1.scala @@ -4,5 +4,5 @@ trait Two[A, B] object Test { def foo[M[_], A](m: M[A]) = () - def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled* + def test(ma: Two[Int, String]) = foo(ma) // should fail with -Xsource:2.12 } diff --git a/test/files/neg/t2712-2.check b/test/files/neg/t2712-2.check index ea19e33e2c55..f19a4ba54c30 100644 --- a/test/files/neg/t2712-2.check +++ b/test/files/neg/t2712-2.check @@ -3,11 +3,11 @@ t2712-2.scala:16: error: type mismatch; required: test.Two[test.X1,Object] Note: test.X2 <: Object (and test.Foo <: test.Two[test.X1,test.X2]), but trait Two is invariant in type B. You may wish to define B as +B instead. (SLS 4.5) - test1(foo): One[X3] // fails with -Ypartial-unification enabled + test1(foo): One[X3] // fails without -Xsource:2.12 ^ t2712-2.scala:16: error: type mismatch; found : test.Two[test.X1,Object] required: test.One[test.X3] - test1(foo): One[X3] // fails with -Ypartial-unification enabled + test1(foo): One[X3] // fails without -Xsource:2.12 ^ two errors found diff --git a/test/files/neg/t2712-2.flags b/test/files/neg/t2712-2.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/neg/t2712-2.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/neg/t2712-2.scala b/test/files/neg/t2712-2.scala index 85ed52348903..cfa37c7c49d5 100644 --- a/test/files/neg/t2712-2.scala +++ b/test/files/neg/t2712-2.scala @@ -13,6 +13,6 @@ object Test { val foo = new Foo - test1(foo): One[X3] // fails with -Ypartial-unification enabled - test1(foo): Two[X1, X2] // fails without -Ypartial-unification + test1(foo): One[X3] // fails without -Xsource:2.12 + test1(foo): Two[X1, X2] // fails with -Xsource:2.12 } diff --git a/test/files/neg/t2712-3.check b/test/files/neg/t2712-3.check index a84d96bf09c9..1a479eed1233 100644 --- a/test/files/neg/t2712-3.check +++ b/test/files/neg/t2712-3.check @@ -1,6 +1,6 @@ t2712-3.scala:17: error: type mismatch; found : test.One[test.X3] required: test.Two[test.X1,test.X2] - test1(foo): Two[X1, X2] // fails without -Ypartial-unification + test1(foo): Two[X1, X2] // fails with -Xsource:2.12 ^ one error found diff --git a/test/files/neg/t2712-3.flags b/test/files/neg/t2712-3.flags new file mode 100644 index 000000000000..0acce1e7ce9c --- /dev/null +++ b/test/files/neg/t2712-3.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/neg/t2712-3.scala b/test/files/neg/t2712-3.scala index 85ed52348903..cfa37c7c49d5 100644 --- a/test/files/neg/t2712-3.scala +++ b/test/files/neg/t2712-3.scala @@ -13,6 +13,6 @@ object Test { val foo = new Foo - test1(foo): One[X3] // fails with -Ypartial-unification enabled - test1(foo): Two[X1, X2] // fails without -Ypartial-unification + test1(foo): One[X3] // fails without -Xsource:2.12 + test1(foo): Two[X1, X2] // fails with -Xsource:2.12 } diff --git a/test/files/neg/t2712-8.flags b/test/files/neg/t2712-8.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/neg/t2712-8.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/neg/t5683.flags b/test/files/neg/t5683.flags new file mode 100644 index 000000000000..0acce1e7ce9c --- /dev/null +++ b/test/files/neg/t5683.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/neg/t8237-default-212.check b/test/files/neg/t8237-default-212.check new file mode 100644 index 000000000000..a48501a5d110 --- /dev/null +++ b/test/files/neg/t8237-default-212.check @@ -0,0 +1,13 @@ +t8237-default-212.scala:5: error: no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])Nothing exist so that it can be applied to arguments (List[Int]) + --- because --- +argument expression's type is not compatible with formal parameter type; + found : List[Int] + required: ?T[?T[List[?T[X forSome { type X }]]]] + test4(test4$default$1) + ^ +t8237-default-212.scala:5: error: type mismatch; + found : List[Int] + required: T[T[List[T[X forSome { type X }]]]] + test4(test4$default$1) + ^ +two errors found diff --git a/test/files/neg/t8237-default-212.flags b/test/files/neg/t8237-default-212.flags new file mode 100644 index 000000000000..0acce1e7ce9c --- /dev/null +++ b/test/files/neg/t8237-default-212.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/neg/t8237-default-212.scala b/test/files/neg/t8237-default-212.scala new file mode 100644 index 000000000000..a4370046bd67 --- /dev/null +++ b/test/files/neg/t8237-default-212.scala @@ -0,0 +1,29 @@ +// This test case was extracted from `names-defaults-neg.scala` +// It pinpoints an improvement an error message that results from +// a type inference failure +object Test extends App { + test4(test4$default$1) + + def test4[T[P]](x: T[T[List[T[X forSome { type X }]]]]) = ??? + def test4$default$1[T[P]]: List[Int] = ??? +} + +/* +OLD: + no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])Nothing exist so that it can be applied to arguments (List[Int]) + --- because --- +argument expression's type is not compatible with formal parameter type; + found : List[Int] + required: ?T + test4(test4$default$1) + ^ + +NEW: + +no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])Nothing exist so that it can be applied to arguments (List[Int]) + --- because --- +argument expression's type is not compatible with formal parameter type; + found : List[Int] + required: ?T[?T[List[?T[X forSome { type X }]]] + test4(test4$default$1) +*/ diff --git a/test/files/neg/t8237-default-pu.flags b/test/files/neg/t8237-default-pu.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/neg/t8237-default-pu.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/infersingle.flags b/test/files/pos/infersingle.flags deleted file mode 100644 index e1b37447c953..000000000000 --- a/test/files/pos/infersingle.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental \ No newline at end of file diff --git a/test/files/pos/t2712-1.flags b/test/files/pos/t2712-1.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/pos/t2712-1.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/t2712-2.flags b/test/files/pos/t2712-2.flags deleted file mode 100644 index 7d49efbb8e6c..000000000000 --- a/test/files/pos/t2712-2.flags +++ /dev/null @@ -1,2 +0,0 @@ --Ypartial-unification - diff --git a/test/files/pos/t2712-3.flags b/test/files/pos/t2712-3.flags deleted file mode 100644 index 7d49efbb8e6c..000000000000 --- a/test/files/pos/t2712-3.flags +++ /dev/null @@ -1,2 +0,0 @@ --Ypartial-unification - diff --git a/test/files/pos/t2712-4.flags b/test/files/pos/t2712-4.flags deleted file mode 100644 index 7d49efbb8e6c..000000000000 --- a/test/files/pos/t2712-4.flags +++ /dev/null @@ -1,2 +0,0 @@ --Ypartial-unification - diff --git a/test/files/pos/t2712-5.flags b/test/files/pos/t2712-5.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/pos/t2712-5.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/t2712-6.flags b/test/files/pos/t2712-6.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/pos/t2712-6.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/t2712-7.flags b/test/files/pos/t2712-7.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/pos/t2712-7.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/t5683.flags b/test/files/pos/t5683.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/pos/t5683.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/pos/t9178b.flags b/test/files/pos/t9178b.flags deleted file mode 100644 index 48fd867160ba..000000000000 --- a/test/files/pos/t9178b.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/pos/virtpatmat_alts_subst.flags b/test/files/pos/virtpatmat_alts_subst.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_alts_subst.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_binding_opt.flags b/test/files/pos/virtpatmat_binding_opt.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_binding_opt.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_castbinder.flags b/test/files/pos/virtpatmat_castbinder.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_castbinder.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_exist1.flags b/test/files/pos/virtpatmat_exist1.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_exist1.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_exist2.flags b/test/files/pos/virtpatmat_exist2.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_exist2.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_exist3.flags b/test/files/pos/virtpatmat_exist3.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_exist3.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_gadt_array.flags b/test/files/pos/virtpatmat_gadt_array.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_gadt_array.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_infer_single_1.flags b/test/files/pos/virtpatmat_infer_single_1.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_infer_single_1.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_instof_valuetype.flags b/test/files/pos/virtpatmat_instof_valuetype.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_instof_valuetype.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/pos/virtpatmat_obj_in_case.flags b/test/files/pos/virtpatmat_obj_in_case.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/pos/virtpatmat_obj_in_case.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/checked.scala b/test/files/run/checked.scala index e4db9c0916f2..36665ed59ad4 100644 --- a/test/files/run/checked.scala +++ b/test/files/run/checked.scala @@ -1,4 +1,4 @@ -/* Test checked initializers. Needs to be run with -Xexperimental and -checkinit +/* Test checked initializers. Needs to be run with -checkinit */ // 0 inherited fields diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index 7ec8f93d381b..f27445a7bfd4 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -75,7 +75,6 @@ val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message """ override def transformSettings(s: Settings): Settings = { - s.Xexperimental.value = true s.deprecation.value = true // when running that compiler, give it a scala-library to the classpath s.classpath.value = sys.props("java.class.path") diff --git a/test/files/run/inferred-type-constructors-hou.flags b/test/files/run/inferred-type-constructors-hou.flags deleted file mode 100644 index 41565c7e32bd..000000000000 --- a/test/files/run/inferred-type-constructors-hou.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/run/inferred-type-constructors.check b/test/files/run/inferred-type-constructors.check index ee8530d9f97f..f23528160820 100644 --- a/test/files/run/inferred-type-constructors.check +++ b/test/files/run/inferred-type-constructors.check @@ -47,6 +47,7 @@ warning: there were two feature warnings; re-run with -feature for details List[Nothing] scala.collection.immutable.Vector[Nothing] scala.collection.immutable.Iterable[(Int, Int)] + scala.collection.immutable.Map[Int,Int] scala.collection.immutable.Set[Int] Seq[Int] Array[Int] diff --git a/test/files/run/inferred-type-constructors.scala b/test/files/run/inferred-type-constructors.scala index 79a8653f686b..9d12585ec35d 100644 --- a/test/files/run/inferred-type-constructors.scala +++ b/test/files/run/inferred-type-constructors.scala @@ -113,6 +113,7 @@ object Test { whatis(extract(Nil)) whatis(extract(Vector())) + whatis(extract(scala.collection.immutable.Iterable[(Int, Int)]())) whatis(extract(Map[Int,Int]())) whatis(extract(Set[Int]())) whatis(extract(Seq[Int]())) diff --git a/test/files/run/sammy_java8.scala b/test/files/run/sammy_java8.scala index db9df7f5febf..39118486eddd 100644 --- a/test/files/run/sammy_java8.scala +++ b/test/files/run/sammy_java8.scala @@ -5,8 +5,6 @@ object Test extends CompilerTest { import global._ override lazy val units: List[CompilationUnit] = { - global.settings.Xexperimental.value = true - // This test itself does not depend on JDK8. javaCompilationUnits(global)(samSource) ++ compilationUnits(global)(useSamSource) diff --git a/test/files/run/t9178a.flags b/test/files/run/t9178a.flags deleted file mode 100644 index 48fd867160ba..000000000000 --- a/test/files/run/t9178a.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/t9489.flags b/test/files/run/t9489.flags deleted file mode 100644 index 48fd867160ba..000000000000 --- a/test/files/run/t9489.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/virtpatmat_apply.flags b/test/files/run/virtpatmat_apply.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_apply.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_casting.flags b/test/files/run/virtpatmat_casting.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_casting.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_literal.flags b/test/files/run/virtpatmat_literal.flags deleted file mode 100644 index 2d86d5132df7..000000000000 --- a/test/files/run/virtpatmat_literal.flags +++ /dev/null @@ -1 +0,0 @@ - -Ypartial-unification diff --git a/test/files/run/virtpatmat_npe.flags b/test/files/run/virtpatmat_npe.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_npe.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_partial.flags b/test/files/run/virtpatmat_partial.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_partial.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_stringinterp.flags b/test/files/run/virtpatmat_stringinterp.flags deleted file mode 100644 index e1b37447c953..000000000000 --- a/test/files/run/virtpatmat_stringinterp.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental \ No newline at end of file diff --git a/test/files/run/virtpatmat_switch.flags b/test/files/run/virtpatmat_switch.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_switch.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_tailcalls_verifyerror.flags b/test/files/run/virtpatmat_tailcalls_verifyerror.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_tailcalls_verifyerror.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_try.flags b/test/files/run/virtpatmat_try.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_try.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_typed.flags b/test/files/run/virtpatmat_typed.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_typed.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_unapply.flags b/test/files/run/virtpatmat_unapply.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_unapply.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyprod.flags b/test/files/run/virtpatmat_unapplyprod.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_unapplyprod.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyseq.flags b/test/files/run/virtpatmat_unapplyseq.flags deleted file mode 100644 index 3f5a3100e469..000000000000 --- a/test/files/run/virtpatmat_unapplyseq.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index 495042eb5357..d4f210969d6e 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -26,18 +26,6 @@ class SettingsTest { assertThrows[IllegalArgumentException](check("-Ytest-setting:rubbish")) } - @Test def userSettingsHavePrecedenceOverExperimental() { - def check(args: String*): MutableSettings#BooleanSetting = { - val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) - val (ok, residual) = s.processArguments(args.toList, processAll = true) - assert(residual.isEmpty) - s.YpartialUnification // among -Xexperimental - } - assertTrue(check("-Xexperimental").value) - assertFalse(check("-Xexperimental", "-Ypartial-unification:false").value) - assertFalse(check("-Ypartial-unification:false", "-Xexperimental").value) - } - // for the given args, select the desired setting private def check(args: String*)(b: MutableSettings => Boolean): Boolean = { val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))