summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-ant-macros.xml9
-rwxr-xr-xbuild.xml239
-rw-r--r--doc/LICENSE.md (renamed from docs/LICENSE)21
-rw-r--r--doc/License.rtf65
-rw-r--r--doc/README (renamed from docs/README)2
-rw-r--r--doc/licenses/apache_jansi.txt (renamed from docs/licenses/apache_jansi.txt)0
-rw-r--r--doc/licenses/bsd_asm.txt (renamed from docs/licenses/bsd_asm.txt)0
-rw-r--r--doc/licenses/bsd_jline.txt (renamed from docs/licenses/bsd_jline.txt)0
-rw-r--r--doc/licenses/mit_jquery-layout.txt (renamed from docs/licenses/mit_jquery-layout.txt)0
-rw-r--r--doc/licenses/mit_jquery-ui.txt (renamed from docs/licenses/mit_jquery-ui.txt)0
-rw-r--r--doc/licenses/mit_jquery.txt (renamed from docs/licenses/mit_jquery.txt)0
-rw-r--r--doc/licenses/mit_sizzle.txt (renamed from docs/licenses/mit_sizzle.txt)0
-rw-r--r--doc/licenses/mit_tools.tooltip.txt (renamed from docs/licenses/mit_tools.tooltip.txt)0
-rw-r--r--src/build/maven/maven-deploy.xml171
-rw-r--r--src/build/maven/scala-compiler-pom.xml2
-rw-r--r--src/build/maven/scala-dist-pom.xml75
-rw-r--r--src/build/maven/scala-library-all-pom.xml99
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Errors.scala2
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Resolvers.scala35
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Validators.scala18
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Context.scala4
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Enclosures.scala4
-rw-r--r--src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala15
-rw-r--r--src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala14
-rw-r--r--src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala31
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala19
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala1
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala1
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala7
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala5
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala16
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala43
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala11
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala164
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala78
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala155
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala154
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala283
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala383
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala69
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala146
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala62
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala4
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala2
-rw-r--r--src/library/rootdoc.txt63
-rw-r--r--src/library/scala/AnyVal.scala2
-rw-r--r--src/library/scala/App.scala12
-rw-r--r--src/library/scala/Enumeration.scala4
-rw-r--r--src/library/scala/collection/GenSeqLike.scala29
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala24
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala8
-rw-r--r--src/library/scala/collection/TraversableOnce.scala28
-rw-r--r--src/library/scala/collection/convert/Wrappers.scala6
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala6
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala127
-rw-r--r--src/library/scala/collection/immutable/NumericRange.scala33
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala5
-rw-r--r--src/library/scala/collection/immutable/Range.scala21
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala4
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala52
-rw-r--r--src/library/scala/runtime/AbstractPartialFunction.scala12
-rw-r--r--src/library/scala/util/Properties.scala2
-rw-r--r--src/library/scala/util/matching/Regex.scala8
-rw-r--r--src/manual/scala/man1/scala.scala6
-rw-r--r--src/manual/scala/man1/scalac.scala185
-rw-r--r--src/partest-extras/scala/tools/partest/Util.scala4
-rw-r--r--src/reflect/scala/reflect/api/Exprs.scala2
-rw-r--r--src/reflect/scala/reflect/api/FlagSets.scala8
-rw-r--r--src/reflect/scala/reflect/api/Importers.scala2
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala6
-rw-r--r--src/reflect/scala/reflect/api/Printers.scala19
-rw-r--r--src/reflect/scala/reflect/api/Trees.scala16
-rw-r--r--src/reflect/scala/reflect/api/Universe.scala6
-rw-r--r--src/reflect/scala/reflect/internal/BaseTypeSeqs.scala5
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala116
-rw-r--r--src/reflect/scala/reflect/internal/FlagSets.scala1
-rw-r--r--src/reflect/scala/reflect/internal/Flags.scala7
-rw-r--r--src/reflect/scala/reflect/internal/HasFlags.scala1
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala3
-rw-r--r--src/reflect/scala/reflect/internal/Printers.scala795
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala1
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala24
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala20
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala4
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala8
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala20
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala9
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeComparers.scala41
-rw-r--r--src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala11
-rw-r--r--src/reflect/scala/reflect/macros/Aliases.scala4
-rw-r--r--src/reflect/scala/reflect/macros/BlackboxMacro.scala36
-rw-r--r--src/reflect/scala/reflect/macros/Enclosures.scala19
-rw-r--r--src/reflect/scala/reflect/macros/Evals.scala8
-rw-r--r--src/reflect/scala/reflect/macros/ExprUtils.scala4
-rw-r--r--src/reflect/scala/reflect/macros/FrontEnds.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Infrastructure.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Names.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Parsers.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Reifiers.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Typers.scala6
-rw-r--r--src/reflect/scala/reflect/macros/WhiteboxMacro.scala36
-rw-r--r--src/reflect/scala/reflect/macros/blackbox/Context.scala (renamed from src/reflect/scala/reflect/macros/BlackboxContext.scala)29
-rw-r--r--src/reflect/scala/reflect/macros/package.scala8
-rw-r--r--src/reflect/scala/reflect/macros/whitebox/Context.scala (renamed from src/reflect/scala/reflect/macros/WhiteboxContext.scala)13
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala5
-rw-r--r--src/reflect/scala/reflect/runtime/package.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JavapClass.scala6
-rw-r--r--src/repl/scala/tools/nsc/interpreter/Naming.scala7
-rw-r--r--src/swing/scala/swing/Publisher.scala174
-rw-r--r--test/files/neg/macro-abort/Macros_1.scala4
-rw-r--r--test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala8
-rw-r--r--test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala4
-rw-r--r--test/files/neg/macro-blackbox-extractor/Macros_1.scala4
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala4
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala2
-rw-r--r--test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/macro-bundle-abstract.check6
-rw-r--r--test/files/neg/macro-bundle-abstract.scala4
-rw-r--r--test/files/neg/macro-bundle-class.check4
-rw-r--r--test/files/neg/macro-bundle-class.scala11
-rw-r--r--test/files/neg/macro-bundle-mixbox.check4
-rw-r--r--test/files/neg/macro-bundle-mixbox.scala10
-rw-r--r--test/files/neg/macro-bundle-noncontext.check4
-rw-r--r--test/files/neg/macro-bundle-noncontext.scala (renamed from test/files/neg/macro-bundle-nonmacro.scala)2
-rw-r--r--test/files/neg/macro-bundle-nonmacro.check4
-rw-r--r--test/files/neg/macro-bundle-object.check4
-rw-r--r--test/files/neg/macro-bundle-object.scala6
-rw-r--r--test/files/neg/macro-bundle-overloaded.check4
-rw-r--r--test/files/neg/macro-bundle-overloaded.scala12
-rw-r--r--test/files/neg/macro-bundle-polymorphic.check10
-rw-r--r--test/files/neg/macro-bundle-polymorphic.scala12
-rw-r--r--test/files/neg/macro-bundle-trait.check2
-rw-r--r--test/files/neg/macro-bundle-trait.scala7
-rw-r--r--test/files/neg/macro-cyclic/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-exception/Macros_1.scala4
-rw-r--r--test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-incompatible-macro-engine.check7
-rw-r--r--test/files/neg/macro-incompatible-macro-engine/Macros_2.flags1
-rw-r--r--test/files/neg/macro-incompatible-macro-engine/Macros_2.scala7
-rw-r--r--test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala35
-rw-r--r--test/files/neg/macro-incompatible-macro-engine/Test_3.scala4
-rw-r--r--test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml4
-rw-r--r--test/files/neg/macro-invalidimpl.check20
-rw-r--r--test/files/neg/macro-invalidimpl/Impls_1.scala20
-rw-r--r--test/files/neg/macro-invalidimpl/Macros_Test_2.scala4
-rw-r--r--test/files/neg/macro-invalidret.check12
-rw-r--r--test/files/neg/macro-invalidret/Impls_1.scala12
-rw-r--r--test/files/neg/macro-invalidshape/Impls_1.scala4
-rw-r--r--test/files/neg/macro-invalidshape/Macros_Test_2.scala2
-rw-r--r--test/files/neg/macro-invalidsig-params-badtype.check6
-rw-r--r--test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-invalidsig.check58
-rw-r--r--test/files/neg/macro-invalidsig/Impls_1.scala30
-rw-r--r--test/files/neg/macro-invalidusage-badargs/Impls_1.scala4
-rw-r--r--test/files/neg/macro-invalidusage-badbounds/Impls_1.scala4
-rw-r--r--test/files/neg/macro-invalidusage-badtargs/Impls_1.scala4
-rw-r--r--test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala4
-rw-r--r--test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-invalidusage-presuper/Impls_1.scala4
-rw-r--r--test/files/neg/macro-noexpand/Impls_1.scala4
-rw-r--r--test/files/neg/macro-nontypeablebody/Impls_1.scala4
-rw-r--r--test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/macro-override-method-overrides-macro/Impls_1.scala12
-rw-r--r--test/files/neg/macro-quasiquotes/Macros_1.scala4
-rw-r--r--test/files/neg/macro-reify-splice-splice/Macros_1.scala4
-rw-r--r--test/files/neg/macro-without-xmacros-a/Impls_1.scala8
-rw-r--r--test/files/neg/macro-without-xmacros-b/Impls_1.scala8
-rw-r--r--test/files/neg/t2066.check21
-rw-r--r--test/files/neg/t2066.scala70
-rw-r--r--test/files/neg/t2066b.check5
-rw-r--r--test/files/neg/t2066b.scala (renamed from test/pending/neg/t2066.scala)0
-rw-r--r--test/files/neg/t4425.check6
-rw-r--r--test/files/neg/t4425b.check42
-rw-r--r--test/files/neg/t5689.check6
-rw-r--r--test/files/neg/t5689.scala4
-rw-r--r--test/files/neg/t5753/Impls_Macros_1.scala4
-rw-r--r--test/files/neg/t5753/Test_2.scala2
-rw-r--r--test/files/neg/t5903a.check2
-rw-r--r--test/files/neg/t5903a/Macros_1.scala4
-rw-r--r--test/files/neg/t5903b/Macros_1.scala4
-rw-r--r--test/files/neg/t5903c/Macros_1.scala4
-rw-r--r--test/files/neg/t5903d/Macros_1.scala4
-rw-r--r--test/files/neg/t5903e/Macros_1.scala4
-rw-r--r--test/files/neg/t6123-explaintypes-macros.check6
-rw-r--r--test/files/neg/t6123-explaintypes-macros/BadMac_2.scala4
-rw-r--r--test/files/neg/t6123-explaintypes-macros/Macros.scala4
-rw-r--r--test/files/neg/t6539/Macro_1.scala4
-rw-r--r--test/files/neg/t6675b.check37
-rw-r--r--test/files/neg/t6675b.flags1
-rw-r--r--test/files/neg/t6675b.scala40
-rw-r--r--test/files/neg/t7157/Impls_Macros_1.scala26
-rw-r--r--test/files/neg/t7214neg.check7
-rw-r--r--test/files/neg/t7850.check7
-rw-r--r--test/files/neg/t7850.scala16
-rw-r--r--test/files/neg/t7897.check4
-rw-r--r--test/files/neg/t7897.scala23
-rw-r--r--test/files/neg/t8104/Macros_1.scala4
-rw-r--r--test/files/neg/t8146-non-finitary-2.check9
-rw-r--r--test/files/neg/t8146-non-finitary-2.scala8
-rw-r--r--test/files/neg/t8146-non-finitary.check9
-rw-r--r--test/files/neg/t8146-non-finitary.scala7
-rw-r--r--test/files/neg/t997.check7
-rw-r--r--test/files/pos/annotated-original/M_1.scala4
-rw-r--r--test/files/pos/annotated-treecopy/Impls_Macros_1.scala4
-rw-r--r--test/files/pos/attachments-typed-another-ident/Impls_1.scala4
-rw-r--r--test/files/pos/attachments-typed-ident/Impls_1.scala4
-rw-r--r--test/files/pos/macro-implicit-invalidate-on-error.scala2
-rw-r--r--test/files/pos/t2066.scala25
-rw-r--r--test/files/pos/t5692a/Macros_1.scala4
-rw-r--r--test/files/pos/t5692b/Macros_1.scala4
-rw-r--r--test/files/pos/t5706.scala4
-rw-r--r--test/files/pos/t5744/Macros_1.scala6
-rw-r--r--test/files/pos/t6047.scala4
-rw-r--r--test/files/pos/t6447.scala8
-rw-r--r--test/files/pos/t6485a/Macros_1.scala4
-rw-r--r--test/files/pos/t6485b/Test.scala4
-rw-r--r--test/files/pos/t6516.scala6
-rw-r--r--test/files/pos/t7377/Macro_1.scala4
-rw-r--r--test/files/pos/t7461/Macros_1.scala4
-rw-r--r--test/files/pos/t7649.scala2
-rw-r--r--test/files/pos/t7776.scala2
-rw-r--r--test/files/pos/t8001/Macros_1.scala4
-rw-r--r--test/files/pos/t8013/inpervolator_1.scala2
-rw-r--r--test/files/pos/t8045.scala17
-rw-r--r--test/files/pos/t8046.scala20
-rw-r--r--test/files/pos/t8046b.scala16
-rw-r--r--test/files/pos/t8046c.scala19
-rw-r--r--test/files/pos/t8064.flags1
-rw-r--r--test/files/pos/t8064/Client_2.scala8
-rw-r--r--test/files/pos/t8064/Macro_1.scala10
-rw-r--r--test/files/pos/t8064b.flags1
-rw-r--r--test/files/pos/t8064b/Client_2.scala6
-rw-r--r--test/files/pos/t8064b/Macro_1.scala11
-rw-r--r--test/files/pos/t8128.scala15
-rw-r--r--test/files/pos/t8132.scala5
-rw-r--r--test/files/pos/t8146a.scala9
-rw-r--r--test/files/pos/t8146b.scala77
-rw-r--r--test/files/presentation/hyperlinks-macro.check11
-rw-r--r--test/files/presentation/hyperlinks-macro/Runner.scala8
-rw-r--r--test/files/presentation/hyperlinks-macro/src/MacroCall.scala11
-rw-r--r--test/files/presentation/t4287.check11
-rw-r--r--test/files/presentation/t4287/Test.scala3
-rw-r--r--test/files/presentation/t4287/src/Foo.scala5
-rw-r--r--test/files/presentation/t4287b.check6
-rw-r--r--test/files/presentation/t4287b/Test.scala3
-rw-r--r--test/files/presentation/t4287b/src/Foo.scala15
-rw-r--r--test/files/presentation/t4287c.check11
-rw-r--r--test/files/presentation/t4287c.flags1
-rw-r--r--test/files/presentation/t4287c/Test.scala3
-rw-r--r--test/files/presentation/t4287c/src/Foo.scala9
-rw-r--r--test/files/run/macro-abort-fresh/Macros_1.scala4
-rw-r--r--test/files/run/macro-auto-duplicate/Macros_1.scala4
-rw-r--r--test/files/run/macro-basic-ma-md-mi/Impls_1.scala8
-rw-r--r--test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala8
-rw-r--r--test/files/run/macro-basic-mamd-mi/Impls_1.scala8
-rw-r--r--test/files/run/macro-blackbox-materialization/Macros_1.scala4
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Impls_1.scala3
-rw-r--r--test/files/run/macro-bundle-repl.check12
-rw-r--r--test/files/run/macro-bundle-repl.scala6
-rw-r--r--test/files/run/macro-bundle-static/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-bundle-static/Test_2.scala4
-rw-r--r--test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-bundle-toplevel/Test_2.scala4
-rw-r--r--test/files/run/macro-bundle-whitebox.check6
-rw-r--r--test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala26
-rw-r--r--test/files/run/macro-bundle-whitebox/Test_2.scala8
-rw-r--r--test/files/run/macro-def-path-dependent/Test_1.scala4
-rw-r--r--test/files/run/macro-def-path-dependent/Test_2.scala4
-rw-r--r--test/files/run/macro-def-path-dependent/Test_3.scala4
-rw-r--r--test/files/run/macro-def-path-dependent/Test_4.scala4
-rw-r--r--test/files/run/macro-def-path-dependent/Test_5.scala4
-rw-r--r--test/files/run/macro-def-path-dependent/Test_6.scala2
-rw-r--r--test/files/run/macro-default-params/Macros_1.scala4
-rw-r--r--test/files/run/macro-divergence-spurious/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-duplicate/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-enclosures/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-expand-implicit-argument/Macros_1.scala4
-rw-r--r--test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-multiple-arglists/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-nullary-generic/Impls_1.scala12
-rw-r--r--test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala12
-rw-r--r--test/files/run/macro-expand-overload/Impls_1.scala12
-rw-r--r--test/files/run/macro-expand-override/Impls_1.scala12
-rw-r--r--test/files/run/macro-expand-recursive/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-tparams-bounds/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-tparams-explicit/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-tparams-implicit/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-tparams-prefix/Impls_1.scala8
-rw-r--r--test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala4
-rw-r--r--test/files/run/macro-impl-default-params/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-impl-relaxed/Macros_1.scala10
-rw-r--r--test/files/run/macro-impl-rename-context/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala4
-rw-r--r--test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala4
-rw-r--r--test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-openmacros/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala5
-rw-r--r--test/files/run/macro-parse-position/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-quasiquotes/Macros_1.scala4
-rw-r--r--test/files/run/macro-range/Common_1.scala4
-rw-r--r--test/files/run/macro-range/Expansion_Impossible_2.scala4
-rw-r--r--test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala4
-rw-r--r--test/files/run/macro-reify-basic/Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-freevars/Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-nested-a/Impls_Macros_1.scala8
-rw-r--r--test/files/run/macro-reify-nested-b/Impls_Macros_1.scala8
-rw-r--r--test/files/run/macro-reify-ref-to-packageless/Impls_1.scala4
-rw-r--r--test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-staticXXX/Macros_1.scala6
-rw-r--r--test/files/run/macro-reify-tagful-a/Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-type/Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-unreify/Macros_1.scala4
-rw-r--r--test/files/run/macro-repl-basic.check10
-rw-r--r--test/files/run/macro-repl-basic.scala8
-rw-r--r--test/files/run/macro-repl-dontexpand.check8
-rw-r--r--test/files/run/macro-repl-dontexpand.scala4
-rw-r--r--test/files/run/macro-settings/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-sip19-revised/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-sip19/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-subpatterns/Macro_1.scala4
-rw-r--r--test/files/run/macro-system-properties.check8
-rw-r--r--test/files/run/macro-system-properties.scala4
-rw-r--r--test/files/run/macro-term-declared-in-annotation/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-anonymous/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-block/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-class-class/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-class-object/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-class/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-default-param/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-method/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-object-class/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-object-object/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-object/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-package-object/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-refinement/Impls_1.scala4
-rw-r--r--test/files/run/macro-term-declared-in-trait/Impls_1.scala4
-rw-r--r--test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-vampire-false-warning/Macros_1.scala6
-rw-r--r--test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala4
-rw-r--r--test/files/run/macro-whitebox-extractor/Macros_1.scala4
-rw-r--r--test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala4
-rw-r--r--test/files/run/macro-whitebox-fundep-materialization/Test_2.scala2
-rw-r--r--test/files/run/macro-whitebox-structural/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macroPlugins-macroArgs.check2
-rw-r--r--test/files/run/macroPlugins-macroArgs/Macros_2.scala11
-rw-r--r--test/files/run/macroPlugins-macroArgs/Plugin_1.scala21
-rw-r--r--test/files/run/macroPlugins-macroArgs/Test_3.flags1
-rw-r--r--test/files/run/macroPlugins-macroArgs/Test_3.scala4
-rw-r--r--test/files/run/macroPlugins-macroArgs/scalac-plugin.xml4
-rw-r--r--test/files/run/macroPlugins-macroExpand.check2
-rw-r--r--test/files/run/macroPlugins-macroExpand/Macros_2.scala18
-rw-r--r--test/files/run/macroPlugins-macroExpand/Plugin_1.scala27
-rw-r--r--test/files/run/macroPlugins-macroExpand/Test_3.flags1
-rw-r--r--test/files/run/macroPlugins-macroExpand/Test_3.scala4
-rw-r--r--test/files/run/macroPlugins-macroExpand/scalac-plugin.xml4
-rw-r--r--test/files/run/macroPlugins-macroRuntime.check2
-rw-r--r--test/files/run/macroPlugins-macroRuntime/Macros_2.scala11
-rw-r--r--test/files/run/macroPlugins-macroRuntime/Plugin_1.scala20
-rw-r--r--test/files/run/macroPlugins-macroRuntime/Test_3.flags1
-rw-r--r--test/files/run/macroPlugins-macroRuntime/Test_3.scala4
-rw-r--r--test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml4
-rw-r--r--test/files/run/macroPlugins-namerHooks.check45
-rw-r--r--test/files/run/macroPlugins-namerHooks.scala39
-rw-r--r--test/files/run/macroPlugins-typedMacroBody.check2
-rw-r--r--test/files/run/macroPlugins-typedMacroBody/Macros_2.flags1
-rw-r--r--test/files/run/macroPlugins-typedMacroBody/Macros_2.scala18
-rw-r--r--test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala21
-rw-r--r--test/files/run/macroPlugins-typedMacroBody/Test_3.scala4
-rw-r--r--test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml4
-rw-r--r--test/files/run/name-based-patmat.check2
-rw-r--r--test/files/run/name-based-patmat.scala42
-rw-r--r--test/files/run/patmat-mix-case-extractor.check8
-rw-r--r--test/files/run/patmat-mix-case-extractor.scala110
-rw-r--r--test/files/run/reify_ann3.check4
-rw-r--r--test/files/run/repl-term-macros.check16
-rw-r--r--test/files/run/repl-term-macros.scala8
-rw-r--r--test/files/run/t4287inferredMethodTypes.check30
-rw-r--r--test/files/run/t4287inferredMethodTypes.scala25
-rw-r--r--test/files/run/t5603.check4
-rw-r--r--test/files/run/t5713/Impls_Macros_1.scala4
-rw-r--r--test/files/run/t5753_1/Impls_Macros_1.scala4
-rw-r--r--test/files/run/t5753_2/Impls_Macros_1.scala4
-rw-r--r--test/files/run/t5894.scala5
-rw-r--r--test/files/run/t5903a/Macros_1.scala4
-rw-r--r--test/files/run/t5903b/Macros_1.scala4
-rw-r--r--test/files/run/t5903c/Macros_1.scala4
-rw-r--r--test/files/run/t5903d/Macros_1.scala4
-rw-r--r--test/files/run/t5923a/Macros_1.scala4
-rw-r--r--test/files/run/t5923d/Macros_1.scala4
-rw-r--r--test/files/run/t5940.scala6
-rw-r--r--test/files/run/t6187.check10
-rw-r--r--test/files/run/t6187.scala4
-rw-r--r--test/files/run/t6221/Macros_1.scala4
-rw-r--r--test/files/run/t6381.check8
-rw-r--r--test/files/run/t6381.scala4
-rw-r--r--test/files/run/t6394a/Macros_1.scala4
-rw-r--r--test/files/run/t6394b/Macros_1.scala4
-rw-r--r--test/files/run/t6662/Macro_1.scala4
-rw-r--r--test/files/run/t6992/Macros_1.scala2
-rw-r--r--test/files/run/t7008-scala-defined/Impls_Macros_2.scala4
-rw-r--r--test/files/run/t7008/Impls_Macros_2.scala4
-rw-r--r--test/files/run/t7047/Impls_Macros_1.scala4
-rw-r--r--test/files/run/t7157/Impls_Macros_1.scala4
-rw-r--r--test/files/run/t7240/Macros_1.scala4
-rw-r--r--test/files/run/t7326.scala64
-rw-r--r--test/files/run/t7375b/Macros_1.scala4
-rw-r--r--test/files/run/t7617a/Macros_1.scala6
-rw-r--r--test/files/run/t7617b/Macros_1.scala4
-rw-r--r--test/files/run/t7657/Macros_1.scala4
-rw-r--r--test/files/run/t7777/Macros_1.scala4
-rw-r--r--test/files/run/t7871/Macros_1.scala2
-rw-r--r--test/files/run/t7974.check104
-rw-r--r--test/files/run/t7974/Symbols.scala6
-rw-r--r--test/files/run/t7974/Test.scala20
-rw-r--r--test/files/run/t8046.check2
-rw-r--r--test/files/run/t8046/Test.scala18
-rw-r--r--test/files/run/t8046/t8046c.scala13
-rw-r--r--test/files/run/t8048a/Macros_1.scala4
-rw-r--r--test/files/run/t8048b/Macros_1.scala8
-rw-r--r--test/files/run/t8104/Macros_1.scala4
-rw-r--r--test/files/run/toolbox_current_run_compiles.scala4
-rw-r--r--test/files/run/typed-annotated/Macros_1.scala4
-rw-r--r--test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala2
-rw-r--r--test/files/scalacheck/range.scala41
-rw-r--r--test/junit/scala/collection/PagedSeq.scala16
-rw-r--r--test/junit/scala/reflect/internal/PrintersTest.scala815
-rw-r--r--test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala4
-rw-r--r--test/pending/pos/t6161.scala22
-rw-r--r--test/pending/pos/t8128b.scala18
-rw-r--r--test/pending/presentation/context-bounds1.check51
-rw-r--r--test/pending/presentation/context-bounds1/Test.scala3
-rw-r--r--test/pending/presentation/context-bounds1/src/ContextBounds.scala13
-rw-r--r--test/pending/run/macro-expand-default/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala2
-rw-r--r--test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-named/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala4
-rw-r--r--test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala4
-rw-r--r--test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala2
-rw-r--r--test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala4
-rw-r--r--test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala2
-rw-r--r--test/pending/run/macro-reify-array/Macros_1.scala4
-rw-r--r--test/pending/run/macro-reify-tagful-b/Macros_1.scala4
-rw-r--r--test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala4
-rw-r--r--test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala4
-rw-r--r--test/pending/run/reflection-sync-potpourri.scala (renamed from test/files/run/reflection-sync-potpourri.scala)0
-rw-r--r--test/scaladoc/run/SI-6812.check1
-rw-r--r--test/scaladoc/run/SI-6812.scala6
-rw-r--r--test/scaladoc/run/SI-6812b.check1
-rw-r--r--test/scaladoc/run/SI-6812b.scala24
-rw-r--r--versions.properties4
481 files changed, 6096 insertions, 2349 deletions
diff --git a/build-ant-macros.xml b/build-ant-macros.xml
index 593f93b784..0b92f1dab1 100644
--- a/build-ant-macros.xml
+++ b/build-ant-macros.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="build-support">
+<project name="build-support" xmlns:artifact="urn:maven-artifact-ant">
<description> Macros for Scala's ant build </description>
<macrodef name="optimized">
@@ -451,8 +451,8 @@
<attribute name="project"/>
<sequential>
<local name="artifact-base"/>
- <property name="artifact-base" value="${maven-base}/${@{project}.dir}${@{project}.name}/${@{project}.name}"/>
- <mkdir dir="${maven-base}/${@{project}.dir}${@{project}.name}"/>
+ <property name="artifact-base" value="${dist.maven}/${@{project}.dir}${@{project}.name}/${@{project}.name}"/>
+ <mkdir dir="${dist.maven}/${@{project}.dir}${@{project}.name}"/>
<copy tofile="${artifact-base}.jar" file="${build-osgi.dir}/org.scala-lang.${@{project}.package}${@{project}.name}${@{project}.namesuffix}.jar" overwrite="true"/>
<copy tofile="${artifact-base}-src.jar" file="${build-osgi.dir}/${@{project}.name}-src.jar" overwrite="true"/>
<copy tofile="${artifact-base}-pom.xml" file="${src.dir}/build/maven/${@{project}.dir}/${@{project}.name}-pom.xml" overwrite="true"/>
@@ -469,7 +469,8 @@
</sequential>
</macrodef>
-
+ <!-- TODO inline maven-deploy.xml's macrodefs, remove maven-deploy.xml -->
+ <include file="src/build/maven/maven-deploy.xml" as="deploy-macros"/>
<macrodef name="testSuite">
<attribute name="dir" default="${partest.dir}"/>
diff --git a/build.xml b/build.xml
index 53cd998f2d..00ad5f78e9 100755
--- a/build.xml
+++ b/build.xml
@@ -4,17 +4,14 @@
xmlns:artifact="urn:maven-artifact-ant"
xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">
<include file="build-ant-macros.xml" as="macros"/>
- <include file="src/build/maven/maven-deploy.xml" as="maven-deploy"/>
<description>
SuperSabbus for Scala core, builds the scala library and compiler. It can also package it as a simple distribution, tests it for stable bootstrapping and against the Scala test suite.
</description>
<!-- HINTS
-
- for faster builds, have a build.properties in the same directory as build.xml that says:
locker.skip=1
-
-->
<!-- USAGE FROM JENKINS SCRIPTS IS (CURRENTLY) AS FOLLOWS:
@@ -27,11 +24,14 @@ antArgs tend to be:
scalacArgs examples:
"-Dscalac.args=\"-Yrangepos\" -Dpartest.scalac_opts=\"-Yrangepos\""
-targets exercised:
- deploy-core.snapshot publish-opt-nodocs distpack-maven-opt nightly locker.done build build-opt test.suite test.continuations.suite test.scaladoc
+supported/exercised targets
+ to publish: nightly publish-opt-nodocs
+ to build: build build-opt locker.done
+ to run tests: test.suite test.scaladoc
+
+DO NOT RELY ON ANY OTHER TARGETS (ok, you're probably ok assuming the ones defined in the first 100 lines of this file)
-NOTE: after distpack-maven-opt, it is expected there's a build file in dists/maven/latest that defines targets deploy and deploy.local
-TODO: get rid of this separate step
+NOTE: dists/maven/latest/build.xml will soon disappear; call `publish` in this build instead
-->
<!-- To use Zinc with the ant build:
@@ -70,7 +70,6 @@ TODO:
<!-- packaging -->
<target name="distpack" depends="pack-archives.done, pack-maven.done"/>
<target name="distpack-maven" depends="pack-maven.done"/>
-
<target name="distpack-opt" description="Builds an optimised distribution."> <optimized name="distpack"/></target>
<target name="distpack-maven-opt" description="Builds an optimised maven distribution."><optimized name="distpack-maven"/></target>
@@ -81,7 +80,6 @@ TODO:
<param name="scalac.args.optimise" value="-optimise"/>
</antcall>
</target>
-
<target name="publish-core-opt-nodocs" description="Builds an untested, undocumented optimised core (library/reflect/compiler) and publishes to maven.">
<antcall target="publish-core">
<param name="docs.skip" value="1"/>
@@ -93,24 +91,22 @@ TODO:
<param name="docs.skip" value="1"/>
</antcall>
</target>
-
<target name="all.done" depends="test.done, distpack"/>
-
<target name="nightly-nopt" depends="all.done"/>
<target name="nightly"><optimized name="nightly-nopt"/></target>
-
<target name="nightly.checkall">
<antcall target="nightly-nopt"> <param name="partest.scalac_opts" value="-Ycheck:all"/></antcall></target>
+ <!-- prefer the sbt names, but the dotted names are used in jenkins;
+ rename there first before dropping the dotted ones -->
+ <target name="publish-local" depends="publish.local"/>
+ <target name="publish-signed" depends="publish.signed"/>
+
<target name="clean" depends="quick.clean" description="Removes binaries of compiler and library. Locker and distributions are untouched."/>
<target name="docsclean" depends="docs.clean" description="Removes generated documentation. Distributions are untouched."/>
<target name="distclean" depends="dist.clean" description="Removes all distributions. Binaries and documentation are untouched."/>
- <target name="test.continuations.suite">
- <echo message="DEPRECATED: the continuations have moved to https://github.com/scala/scala-continuations"/>
- </target>
-
<!-- ===========================================================================
PROPERTIES
============================================================================ -->
@@ -120,7 +116,7 @@ TODO:
<property name="build.sysclasspath" value="ignore"/>
<!-- Defines the repository layout -->
- <property name="docs.dir" value="${basedir}/docs"/>
+ <property name="doc.dir" value="${basedir}/doc"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="partest.dir" value="${basedir}/test"/>
@@ -151,6 +147,7 @@ TODO:
<property name="build-locker.dir" value="${build.dir}/locker"/>
<property name="build-quick.dir" value="${build.dir}/quick"/>
<property name="build-pack.dir" value="${build.dir}/pack"/>
+ <property name="build-manual.dir" value="${build.dir}/manual"/>
<property name="build-osgi.dir" value="${build.dir}/osgi"/>
<property name="build-junit.dir" value="${build.dir}/junit"/>
<property name="build-strap.dir" value="${build.dir}/strap"/>
@@ -401,6 +398,13 @@ TODO:
<property name="version.number" value="${version.major}.${version.minor}.${version.patch}${version.suffix}-${git.commit.date}-${git.commit.sha}"/>
</else></if>
+ <!-- some default in case something went wrong getting the revision -->
+ <property name="version.number" value="-unknown-"/>
+
+ <property name="dist.name" value="scala-${version.number}"/>
+ <property name="dist.dir" value="${dists.dir}/${dist.name}"/>
+ <property name="dist.maven" value="${dists.dir}/maven/${version.number}"/>
+
<condition property="has.java6">
<equals arg1="${ant.java.version}" arg2="1.6"/>
</condition>
@@ -445,10 +449,6 @@ TODO:
<format property="short" pattern="yyyyMMddHHmmss"/>
</tstamp>
- <!-- some default in case something went wrong getting the revision -->
- <property name="version.number" value="-unknown-"/>
- <property name="init.avail" value="yes"/>
-
<!-- Local libs (developer use.) -->
<mkdir dir="${lib-extra.dir}"/>
@@ -1559,8 +1559,36 @@ TODO:
</staged-docs>
</target>
- <target name="docs.man" depends="docs.start">
- <staged-uptodate stage="docs" project="manual">
+ <target name="docs.core" depends="docs.lib, docs.reflect, docs.comp" unless="docs.skip"/>
+ <!-- TODO modularize compiler: docs.scaladoc, docs.interactive, -->
+ <target name="docs.done" depends="docs.core, docs.actors, docs.scalap" unless="docs.skip"/>
+
+<!-- ===========================================================================
+ DISTRIBUTION
+============================================================================ -->
+ <!-- bin/ -->
+ <target name="dist.bin" depends="pack.bin">
+ <mkdir dir="${dist.dir}/bin"/>
+ <copy toDir="${dist.dir}/bin" overwrite="true">
+ <fileset dir="${build-pack.dir}/bin"/>
+ </copy>
+ <chmod perm="ugo+rx" file="${dist.dir}/bin/scala"/>
+ <chmod perm="ugo+rx" file="${dist.dir}/bin/scalac"/>
+ <chmod perm="ugo+rx" file="${dist.dir}/bin/scaladoc"/>
+ <chmod perm="ugo+rx" file="${dist.dir}/bin/fsc"/>
+ <chmod perm="ugo+rx" file="${dist.dir}/bin/scalap"/>
+ </target>
+
+ <!-- doc/ and man/ -->
+ <target name="dist.doc" depends="scaladoc.task" unless="docs.skip"> <!-- depends on scaladoc.task for scalac taskdef -->
+ <mkdir dir="${dist.dir}/doc"/>
+ <copy toDir="${dist.dir}/doc" overwrite="true">
+ <fileset dir="${doc.dir}"/>
+ </copy>
+
+ <mkdir dir="${dist.dir}/doc/tools"/>
+ <mkdir dir="${dist.dir}/man/man1"/>
+ <staged-uptodate stage="manual" project="manual">
<check><srcfiles dir="${src.dir}/manual"/></check>
<do>
<mkdir dir="${build.dir}/manmaker/classes"/>
@@ -1570,44 +1598,33 @@ TODO:
srcdir="${src.dir}/manual"
includes="**/*.scala"
addparams="${scalac.args.all} -language:implicitConversions"/>
- <mkdir dir="${build-docs.dir}/manual/man/man1"/>
- <mkdir dir="${build-docs.dir}/manual/html"/>
- <mkdir dir="${build-docs.dir}/manual/genman/man1"/>
+ <mkdir dir="${build-manual.dir}/genman/man1"/>
<taskdef name="genman"
classname="scala.tools.docutil.ManMaker"
classpathref="manual.build.path"/>
<genman command="fsc, scala, scalac, scaladoc, scalap"
- htmlout="${build-docs.dir}/manual/html"
- manout="${build-docs.dir}/manual/genman"/>
- <!-- On Windows source and target files can't be the same ! -->
- <fixcrlf
- srcdir="${build-docs.dir}/manual/genman"
- destdir="${build-docs.dir}/manual/man"
- eol="unix" includes="**/*.1"/>
- <copy todir="${build-docs.dir}/manual/html" overwrite="true">
- <fileset dir="${src.dir}/manual/scala/tools/docutil/resources">
- <include name="**/*.html"/>
- <include name="**/*.css"/>
- <include name="**/*.gif"/>
- <include name="**/*.png"/>
- </fileset>
- </copy>
+ htmlout="${dist.dir}/doc/tools"
+ manout="${build-manual.dir}/genman"/>
</do>
</staged-uptodate>
- </target>
-
- <target name="docs.core" depends="docs.lib, docs.reflect, docs.comp" unless="docs.skip"/>
- <!-- TODO modularize compiler: docs.scaladoc, docs.interactive, -->
- <target name="docs.done" depends="docs.core, docs.actors, docs.scalap" unless="docs.skip"/>
-
-<!-- ===========================================================================
- DISTRIBUTION
-============================================================================ -->
- <target name="dist.base" depends="osgi.done">
- <property name="dist.name" value="scala-${version.number}"/>
- <property name="dist.dir" value="${dists.dir}/${dist.name}"/>
+ <!-- On Windows source and target files can't be the same ! -->
+ <fixcrlf
+ srcdir="${build-manual.dir}/genman"
+ destdir="${dist.dir}/man"
+ eol="unix" includes="**/*.1"/>
+ <copy todir="${dist.dir}/doc/tools" overwrite="true">
+ <fileset dir="${src.dir}/manual/scala/tools/docutil/resources">
+ <include name="**/*.html"/>
+ <include name="**/*.css"/>
+ <include name="**/*.gif"/>
+ <include name="**/*.png"/>
+ </fileset>
+ </copy>
+ </target>
+ <!-- lib/ and src/ (jars: classes and sources) -->
+ <target name="dist.lib" depends="osgi.done">
<mkdir dir="${dist.dir}/lib"/>
<mkdir dir="${dist.dir}/src"/>
@@ -1637,29 +1654,10 @@ TODO:
</fileset>
</copy>
<jar whenmanifestonly="fail" destfile="${dist.dir}/src/scalap-src.jar" basedir="${src.dir}/scalap"/>
-
- <mkdir dir="${dist.dir}/bin"/>
- <copy toDir="${dist.dir}/bin" overwrite="true">
- <fileset dir="${build-pack.dir}/bin"/>
- </copy>
- <chmod perm="ugo+rx" file="${dist.dir}/bin/scala"/>
- <chmod perm="ugo+rx" file="${dist.dir}/bin/scalac"/>
- <chmod perm="ugo+rx" file="${dist.dir}/bin/scaladoc"/>
- <chmod perm="ugo+rx" file="${dist.dir}/bin/fsc"/>
- <chmod perm="ugo+rx" file="${dist.dir}/bin/scalap"/>
</target>
-
- <target name="dist.doc" depends="dist.base, docs.done">
- <mkdir dir="${dist.dir}/doc"/>
- <mkdir dir="${dist.dir}/doc/licenses"/>
- <mkdir dir="${dist.dir}/doc/tools"/>
- <copy file="${docs.dir}/LICENSE" toDir="${dist.dir}/doc" overwrite="true"/>
- <copy file="${docs.dir}/README" toDir="${dist.dir}/doc" overwrite="true"/>
- <copy toDir="${dist.dir}/doc/licenses" overwrite="true">
- <fileset dir="${docs.dir}/licenses"/>
- </copy>
-
+ <!-- api/ (scaladoc) -->
+ <target name="dist.api" depends="docs.done" unless="docs.skip">
<mkdir dir="${dist.dir}/api"/>
<copy toDir="${dist.dir}/api" overwrite="true">
<fileset dir="${build-docs.dir}/library"/>
@@ -1674,20 +1672,7 @@ TODO:
</copy>
</target>
-
- <target name="dist.man" depends="dist.base, docs.man">
- <mkdir dir="${dist.dir}/man"/>
- <copy toDir="${dist.dir}/man" overwrite="true">
- <fileset dir="${build-docs.dir}/manual/man"/>
- </copy>
- <mkdir dir="${dist.dir}/doc/scala-devel-docs/tools"/>
- <copy toDir="${dist.dir}/doc/scala-devel-docs/tools" overwrite="true">
- <fileset dir="${build-docs.dir}/manual/html"/>
- </copy>
- </target>
-
-
- <target name="dist.partial" depends="dist.base">
+ <target name="dist.partial" depends="dist.lib, dist.bin, dist.doc">
<if><not><os family="windows"/></not><then>
<symlink link="${dists.dir}/latest" resource="${dist.name}" overwrite="true"/>
</then><else> <!-- XXX THIS PROBABLY DOES NOT WORK: copying must happen last during dist.done! is this guaranteed? -->
@@ -1695,12 +1680,13 @@ TODO:
</else></if>
</target>
- <target name="dist.done" depends="dist.doc, dist.man, dist.partial"/>
+ <target name="dist.done" depends="dist.partial, dist.api"/>
<!-- ===========================================================================
MAIN DISTRIBUTION PACKAGING
============================================================================ -->
+ <!-- TODO: get rid of this, it's redundant between maven and github -->
<target name="pack-archives.done" depends="dist.done, docs.done">
<mkdir dir="${dists.dir}/archives"/>
<property name="archive-base" value="${dists.dir}/archives/${dist.name}"/>
@@ -1716,7 +1702,7 @@ MAIN DISTRIBUTION PACKAGING
<if><not><isset property="docs.skip"/></not><then>
<tarz name="${archive-base}-devel-docs">
- <tarfileset dir="${dist.dir}/doc/scala-devel-docs" prefix="${dist.name}-devel-docs"/>
+ <tarfileset dir="${dist.dir}/api" prefix="${dist.name}-devel-docs"/>
</tarz>
</then></if>
@@ -1761,13 +1747,13 @@ MAIN DISTRIBUTION PACKAGING
</target>
<target name="pack-maven.core" depends="osgi.core, docs.core">
- <property name="maven-base" value="${dists.dir}/maven/${version.number}"/>
- <mkdir dir="${maven-base}"/>
-
<mvn-package project="library"/>
<mvn-package project="reflect"/>
<mvn-package project="compiler"/>
+ <copy tofile="${dist.maven}/scala-library-all/scala-library-all-pom.xml"
+ file="${src.dir}/build/maven/scala-library-all-pom.xml" overwrite="true"/>
+
<!-- for replacestarr -->
<if><isset property="update.starr.version"/><then>
<echo message="From now on, ${maven.version.number} will be used as STARR (`build.properties`'s `starr.version` was modified)."/>
@@ -1777,7 +1763,16 @@ MAIN DISTRIBUTION PACKAGING
</then></if>
</target>
- <target name="pack-maven.base" depends="pack-maven.core, osgi.done, docs.done">
+ <target name="pack-maven.dist" depends="dist.bin, dist.doc">
+ <copy tofile="${dist.maven}/scala-dist/scala-dist-pom.xml" file="${src.dir}/build/maven/scala-dist-pom.xml" overwrite="true"/>
+ <jar whenmanifestonly="fail" destfile="${dist.maven}/scala-dist/scala-dist.jar" basedir="${dist.dir}">
+ <include name="bin/" />
+ <include name="doc/" />
+ <include name="man/" />
+ </jar>
+ </target>
+
+ <target name="pack-maven.base" depends="pack-maven.core, osgi.done, docs.done, pack-maven.dist">
<!-- TODO modularize compiler
<mvn-package project="interactive"/>
<mvn-package project="scaladoc"/>
@@ -1786,19 +1781,21 @@ MAIN DISTRIBUTION PACKAGING
<mvn-package project="actors"/>
<!-- don't bother fitting scalap into the mould: it will move out soon -->
- <copy tofile="${maven-base}/scalap/scalap-pom.xml" file="${src.dir}/build/maven/scalap-pom.xml" overwrite="true"/>
- <copy tofile="${maven-base}/scalap/scalap.jar" file="${scalap.jar}" overwrite="true"/>
- <jar destfile="${maven-base}/scalap/scalap-src.jar" basedir="${src.dir}/scalap" whenmanifestonly="fail"/>
+ <mkdir dir="${dist.maven}"/>
+ <copy tofile="${dist.maven}/scalap/scalap-pom.xml" file="${src.dir}/build/maven/scalap-pom.xml" overwrite="true"/>
+ <copy tofile="${dist.maven}/scalap/scalap.jar" file="${scalap.jar}" overwrite="true"/>
+ <jar destfile="${dist.maven}/scalap/scalap-src.jar" basedir="${src.dir}/scalap" whenmanifestonly="fail"/>
<if><not><isset property="docs.skip"/></not><then>
- <jar destfile="${maven-base}/scalap/scalap-docs.jar" basedir="${build-docs.dir}/scalap"/>
+ <jar destfile="${dist.maven}/scalap/scalap-docs.jar" basedir="${build-docs.dir}/scalap"/>
</then></if>
</target>
+ <!-- TODO: remove this target and delete src/build/maven-deploy.xml -->
<target name="pack-maven.done" depends="pack-maven.base">
<!-- Create dists/maven/latest alias and copy maven-deploy ant build there. -->
<if><isset property="os.win"/><then>
<copy todir="${dists.dir}/maven/latest" overwrite="true">
- <fileset dir="${maven-base}"/>
+ <fileset dir="${dist.maven}"/>
</copy>
</then><else>
<symlink link="${dists.dir}/maven/latest"
@@ -1806,17 +1803,17 @@ MAIN DISTRIBUTION PACKAGING
overwrite="true"/>
</else></if>
<!-- copy build file and its dependencies -->
- <copy todir="${maven-base}"
+ <copy todir="${dist.maven}"
file="${lib-ant.dir}/ant-contrib.jar" overwrite="true"/>
- <copy todir="${maven-base}"
+ <copy todir="${dist.maven}"
file="${lib-ant.dir}/maven-ant-tasks-2.1.1.jar" overwrite="true"/>
- <copy tofile="${maven-base}/build.xml"
+ <copy tofile="${dist.maven}/build.xml"
file="${src.dir}/build/maven/maven-deploy.xml"/>
<!-- export properties for use when deploying -->
- <echoproperties destfile="${maven-base}/build.properties"/>
+ <echoproperties destfile="${dist.maven}/build.properties"/>
</target>
- <!-- keep these properties out of ${maven-base}/build.properties, dumped in pack-maven.done -->
+ <!-- keep these properties out of ${dist.maven}/build.properties, dumped in pack-maven.done -->
<target name="init.maven" depends="init">
<property name="remote.snapshot.repository" value="https://oss.sonatype.org/content/repositories/snapshots" />
<property name="remote.release.repository" value="https://oss.sonatype.org/service/local/staging/deploy/maven2" />
@@ -1840,20 +1837,34 @@ MAIN DISTRIBUTION PACKAGING
<!-- ===========================================================================
MAVEN PUBLISHING
============================================================================ -->
- <!-- TODO: inline maven-deploy.xml here and remove it, once jenkins jobs no longer rely on it -->
- <target name="publish" depends="pack-maven.base, init.maven" description="Publishes unsigned artifacts to the maven repo."> <deploy dir="${maven-base}/"/> </target>
- <target name="publish.local" depends="pack-maven.base, init.maven" description="Publishes unsigned artifacts to the local maven repo."> <deploy dir="${maven-base}/" local="true"/> </target>
- <target name="publish.signed" depends="pack-maven.base, init.maven" description="Publishes signed artifacts to the remote maven repo."> <deploy dir="${maven-base}/" signed="true"/> </target>
+ <target name="publish" depends="pack-maven.base, init.maven" description="Publishes unsigned artifacts to the maven repo.">
+ <deploy />
+ <deploy-pom name="scala-library-all"/>
+ <deploy-jar name="scala-dist"/>
+ </target>
+
+ <target name="publish.local" depends="pack-maven.base, init.maven" description="Publishes unsigned artifacts to the local maven repo.">
+ <deploy local="true"/>
+ <deploy-pom name="scala-library-all" local="true"/>
+ <deploy-jar name="scala-dist" local="true"/>
+ </target>
+
+ <target name="publish.signed" depends="pack-maven.base, init.maven" description="Publishes signed artifacts to the remote maven repo.">
+ <deploy signed="true"/>
+ <deploy-pom name="scala-library-all" signed="true"/>
+ <deploy-jar name="scala-dist" signed="true"/>
+ </target>
<target name="publish-core" depends="pack-maven.core, init.maven">
- <deploy-one dir="${maven-base}/" name="scala-compiler" />
- <deploy-one dir="${maven-base}/" name="scala-library" />
- <deploy-one dir="${maven-base}/" name="scala-reflect" />
+ <deploy-one name="scala-compiler" />
+ <deploy-one name="scala-library" />
+ <deploy-one name="scala-reflect" />
</target>
+
<target name="publish-core-local" depends="pack-maven.core, init.maven">
- <deploy-one dir="${maven-base}/" name="scala-compiler" local="true"/>
- <deploy-one dir="${maven-base}/" name="scala-library" local="true"/>
- <deploy-one dir="${maven-base}/" name="scala-reflect" local="true"/>
+ <deploy-one name="scala-compiler" local="true"/>
+ <deploy-one name="scala-library" local="true"/>
+ <deploy-one name="scala-reflect" local="true"/>
</target>
<target name="publish-core-opt" description="Builds an untested optimised core (library/reflect/compiler) and publishes to maven.">
diff --git a/docs/LICENSE b/doc/LICENSE.md
index 4daedef581..6b039afd68 100644
--- a/docs/LICENSE
+++ b/doc/LICENSE.md
@@ -11,14 +11,14 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the EPFL nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the EPFL nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -39,18 +39,22 @@ which are also included in the `licenses/` directory:
### [Apache License](http://www.apache.org/licenses/LICENSE-2.0.html)
This license is used by the following third-party libraries:
+
* jansi
### [BSD License](http://www.opensource.org/licenses/bsd-license.php)
This license is used by the following third-party libraries:
+
* jline
### [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
This license is used by the following third-party libraries:
+
* asm
### [MIT License](http://www.opensource.org/licenses/MIT)
This license is used by the following third-party libraries:
+
* jquery
* jquery-ui
* jquery-layout
@@ -59,5 +63,6 @@ This license is used by the following third-party libraries:
### Public Domain
The following libraries are freely available in the public domain:
+
* forkjoin
diff --git a/doc/License.rtf b/doc/License.rtf
new file mode 100644
index 0000000000..62ec2d023c
--- /dev/null
+++ b/doc/License.rtf
@@ -0,0 +1,65 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\margl1440\margr1440\vieww25140\viewh18960\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
+
+\f0\fs26 \cf0 Scala is licensed under the {\field{\*\fldinst{HYPERLINK "http://opensource.org/licenses/BSD-3-Clause"}}{\fldrslt BSD 3-Clause License}}.\
+\
+
+\fs48 Scala License
+\fs40 \
+
+\fs26 Copyright (c) 2002-2013 EPFL\
+Copyright (c) 2011-2013 Typesafe, Inc.\
+All rights reserved.\
+\
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\
+ \'95 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\
+ \'95 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\
+ \'95 Neither the name of the EPFL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\
+\
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \'93AS IS\'94 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\
+
+\fs52 \
+
+\fs48 Other Licenses
+\fs52 \
+
+\fs26 This software includes projects with the following licenses, which are also included in the
+\fs24 licenses/
+\fs26 directory:\
+
+\fs30 \
+{\field{\*\fldinst{HYPERLINK "http://www.apache.org/licenses/LICENSE-2.0.html"}}{\fldrslt Apache License}}\
+
+\fs26 This license is used by the following third-party libraries:\
+ \'95 jansi\
+
+\fs30 \
+{\field{\*\fldinst{HYPERLINK "http://www.opensource.org/licenses/bsd-license.php"}}{\fldrslt BSD License}}\
+
+\fs26 This license is used by the following third-party libraries:\
+ \'95 jline\
+
+\fs30 \
+{\field{\*\fldinst{HYPERLINK "http://opensource.org/licenses/BSD-3-Clause"}}{\fldrslt BSD 3-Clause License}}\
+
+\fs26 This license is used by the following third-party libraries:\
+ \'95 asm\
+
+\fs30 \
+{\field{\*\fldinst{HYPERLINK "http://www.opensource.org/licenses/MIT"}}{\fldrslt MIT License}}\
+
+\fs26 This license is used by the following third-party libraries:\
+ \'95 jquery\
+ \'95 jquery-ui\
+ \'95 jquery-layout\
+ \'95 sizzle\
+ \'95 tools tooltip\
+
+\fs30 \
+Public Domain\
+
+\fs26 The following libraries are freely available in the public domain:\
+ \'95 forkjoin} \ No newline at end of file
diff --git a/docs/README b/doc/README
index 1d5f553d2e..29f64c9fef 100644
--- a/docs/README
+++ b/doc/README
@@ -13,7 +13,7 @@ Scala Tools
- scalac Scala compiler
- fsc Scala resident compiler
- scaladoc Scala API documentation generator
-- scalap Scala classfile decoder
+- scalap Scala classfile decoder
Run the command "scalac -help" to display the list of available
compiler options.
diff --git a/docs/licenses/apache_jansi.txt b/doc/licenses/apache_jansi.txt
index 067a5a6a34..067a5a6a34 100644
--- a/docs/licenses/apache_jansi.txt
+++ b/doc/licenses/apache_jansi.txt
diff --git a/docs/licenses/bsd_asm.txt b/doc/licenses/bsd_asm.txt
index 8613cd33a2..8613cd33a2 100644
--- a/docs/licenses/bsd_asm.txt
+++ b/doc/licenses/bsd_asm.txt
diff --git a/docs/licenses/bsd_jline.txt b/doc/licenses/bsd_jline.txt
index 3e5dba75da..3e5dba75da 100644
--- a/docs/licenses/bsd_jline.txt
+++ b/doc/licenses/bsd_jline.txt
diff --git a/docs/licenses/mit_jquery-layout.txt b/doc/licenses/mit_jquery-layout.txt
index 4af6a0a4b0..4af6a0a4b0 100644
--- a/docs/licenses/mit_jquery-layout.txt
+++ b/doc/licenses/mit_jquery-layout.txt
diff --git a/docs/licenses/mit_jquery-ui.txt b/doc/licenses/mit_jquery-ui.txt
index be226805d3..be226805d3 100644
--- a/docs/licenses/mit_jquery-ui.txt
+++ b/doc/licenses/mit_jquery-ui.txt
diff --git a/docs/licenses/mit_jquery.txt b/doc/licenses/mit_jquery.txt
index ef2c570469..ef2c570469 100644
--- a/docs/licenses/mit_jquery.txt
+++ b/doc/licenses/mit_jquery.txt
diff --git a/docs/licenses/mit_sizzle.txt b/doc/licenses/mit_sizzle.txt
index d81d30aa0f..d81d30aa0f 100644
--- a/docs/licenses/mit_sizzle.txt
+++ b/doc/licenses/mit_sizzle.txt
diff --git a/docs/licenses/mit_tools.tooltip.txt b/doc/licenses/mit_tools.tooltip.txt
index 27a4dbc788..27a4dbc788 100644
--- a/docs/licenses/mit_tools.tooltip.txt
+++ b/doc/licenses/mit_tools.tooltip.txt
diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml
index 412d7caab6..a2c3eefbca 100644
--- a/src/build/maven/maven-deploy.xml
+++ b/src/build/maven/maven-deploy.xml
@@ -1,21 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+THIS FILE WILL SOON SELF DESTRUCT; DO NOT USE
+see publish.* targets in /build.xml
+-->
<project name="sabbus-maven-deploy" xmlns:artifact="urn:maven-artifact-ant">
<description>
SuperSabbus extension for deploying a distribution to Maven. THIS FILE IS MEANT TO BE RUN STANDALONE IN THE MAVEN "distpack" DIRECTORY
</description>
+
<macrodef name="deploy-remote">
<attribute name="jar" default=""/>
<attribute name="pom"/>
<element name="artifacts" implicit="true" optional="true"/>
<sequential>
- <artifact:deploy file="@{jar}" settingsFile="${settings.file}">
- <artifact:remoteRepository url="${remote.repository}" id="${repository.credentials.id}" />
- <artifact:pom refid="@{pom}" />
- <artifacts/>
- </artifact:deploy>
+ <if><equals arg1="@{jar}" arg2="true"/><then>
+ <artifact:deploy settingsFile="${settings.file}">
+ <artifact:remoteRepository url="${remote.repository}" id="${repository.credentials.id}" />
+ <artifact:pom refid="@{pom}" />
+ <artifacts/>
+ </artifact:deploy>
+ </then><else>
+ <artifact:deploy file="@{jar}" settingsFile="${settings.file}">
+ <artifact:remoteRepository url="${remote.repository}" id="${repository.credentials.id}" />
+ <artifact:pom refid="@{pom}" />
+ <artifacts/>
+ </artifact:deploy>
+ </else></if>
</sequential>
</macrodef>
@@ -24,11 +37,19 @@
<attribute name="pom"/>
<element name="artifacts" implicit="true" optional="true"/>
<sequential>
- <artifact:install file="@{jar}">
- <artifact:localRepository path="${local.repository}" id="${repository.credentials.id}" />
- <artifact:pom refid="@{pom}" />
- <artifacts/>
- </artifact:install>
+ <if><equals arg1="@{jar}" arg2="true"/><then>
+ <artifact:install>
+ <artifact:localRepository path="${local.repository}" id="${repository.credentials.id}" />
+ <artifact:pom refid="@{pom}" />
+ <artifacts/>
+ </artifact:install>
+ </then><else>
+ <artifact:install file="@{jar}">
+ <artifact:localRepository path="${local.repository}" id="${repository.credentials.id}" />
+ <artifact:pom refid="@{pom}" />
+ <artifacts/>
+ </artifact:install>
+ </else></if>
</sequential>
</macrodef>
@@ -46,26 +67,25 @@
</sequential>
</macrodef>
- <macrodef name="deploy-one">
- <attribute name="dir" default=""/>
+ <macrodef name="filter-pom">
+ <attribute name="path" />
<attribute name="name" />
- <attribute name="local" default="false"/>
- <attribute name="signed" default="false"/>
<sequential>
- <local name="path"/> <property name="path" value="@{dir}@{name}/@{name}"/>
-
- <echo>Deploying ${path}-[pom.xml|src.jar|docs.jar].</echo>
-
<copy file="${path}-pom.xml" tofile="${path}-pom-filtered.xml" overwrite="true">
<filterset>
<filter token="VERSION" value="${maven.version.number}" />
<filter token="SCALA_BINARY_VERSION" value="${scala.binary.version}" />
<filter token="XML_VERSION" value="${scala-xml.version.number}" />
<filter token="PARSER_COMBINATORS_VERSION" value="${scala-parser-combinators.version.number}" />
+ <filter token="CONTINUATIONS_PLUGIN_VERSION" value="${scala-continuations-plugin.version.number}" />
+ <filter token="CONTINUATIONS_LIBRARY_VERSION" value="${scala-continuations-library.version.number}" />
+ <filter token="SCALA_SWING_VERSION" value="${scala-swing.version.number}" />
<filter token="RELEASE_REPOSITORY" value="${remote.release.repository}" />
<filter token="SNAPSHOT_REPOSITORY" value="${remote.snapshot.repository}" />
<filter token="JLINE_VERSION" value="${jline.version}" />
+ <filter token="AKKA_ACTOR_VERSION" value="${akka-actor.version.number}" />
+ <filter token="ACTORS_MIGRATION_VERSION" value="${actors-migration.version.number}" />
<!-- TODO modularize compiler.
<filter token="SCALA_COMPILER_DOC_VERSION" value="${scala-compiler-doc.version.number}" />
@@ -74,6 +94,20 @@
</filterset>
</copy>
<artifact:pom id="@{name}.pom" file="${path}-pom-filtered.xml" />
+ </sequential>
+ </macrodef>
+
+ <macrodef name="deploy-one">
+ <attribute name="name" />
+ <attribute name="local" default="false"/>
+ <attribute name="signed" default="false"/>
+
+ <sequential>
+ <local name="path"/> <property name="path" value="${dist.maven}/@{name}/@{name}"/>
+
+ <echo>Deploying ${path}-[pom.xml|src.jar|docs.jar].</echo>
+
+ <filter-pom name="@{name}" path="@{path}"/>
<if><equals arg1="@{signed}" arg2="false"/><then>
<if><isset property="docs.skip"/><then>
@@ -108,26 +142,94 @@
</sequential>
</macrodef>
+ <macrodef name="deploy-jar">
+ <attribute name="name" />
+ <attribute name="local" default="false"/>
+ <attribute name="signed" default="false"/>
+
+ <sequential>
+ <local name="path"/> <property name="path" value="${dist.maven}/@{name}/@{name}"/>
+
+ <echo>Deploying ${path}.jar with ${path}-pom.xml.</echo>
+
+ <filter-pom name="@{name}" path="@{path}"/>
+
+ <if><equals arg1="@{signed}" arg2="false"/><then>
+ <deploy-to local="@{local}" jar="${path}.jar" pom="@{name}.pom"/>
+ </then><else>
+ <local name="repo"/>
+ <if><equals arg1="@{local}" arg2="false"/><then>
+ <property name="repo" value="${remote.repository}"/>
+ </then><else>
+ <property name="repo" value="${local.repository}"/>
+ </else></if>
+ <artifact:mvn failonerror="true">
+ <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
+ <arg value="-Durl=${repo}" />
+ <arg value="-DrepositoryId=${repository.credentials.id}" />
+ <arg value="-DpomFile=${path}-pom-filtered.xml" />
+ <arg value= "-Dfile=${path}.jar" />
+ <arg value="-Pgpg" />
+ <arg value="-Dgpg.useagent=true" />
+ </artifact:mvn>
+ </else></if>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="deploy-pom">
+ <attribute name="name" />
+ <attribute name="local" default="false"/>
+ <attribute name="signed" default="false"/>
+
+ <sequential>
+ <local name="path"/> <property name="path" value="${dist.maven}/@{name}/@{name}"/>
+
+ <echo>Deploying ${path}-pom.xml.</echo>
+
+ <filter-pom name="@{name}" path="@{path}"/>
+
+ <if><equals arg1="@{signed}" arg2="false"/><then>
+ <deploy-to local="@{local}" pom="@{name}.pom"/>
+ </then><else>
+ <local name="repo"/>
+ <if><equals arg1="@{local}" arg2="false"/><then>
+ <property name="repo" value="${remote.repository}"/>
+ </then><else>
+ <property name="repo" value="${local.repository}"/>
+ </else></if>
+ <artifact:mvn failonerror="true">
+ <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
+ <arg value="-Durl=${repo}" />
+ <arg value="-DrepositoryId=${repository.credentials.id}" />
+ <arg value="-DpomFile=${path}-pom-filtered.xml" />
+ <arg value= "-Dfile=${path}-pom-filtered.xml" />
+ <arg value="-Pgpg" />
+ <arg value="-Dgpg.useagent=true" />
+ </artifact:mvn>
+ </else></if>
+ </sequential>
+ </macrodef>
+
<macrodef name="deploy">
- <attribute name="dir" default=""/>
<attribute name="local" default="false"/>
<attribute name="signed" default="false"/>
<sequential>
- <deploy-one dir="@{dir}" name="scala-library" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}" name="scala-reflect" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}" name="scala-compiler" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-library" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-reflect" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-compiler" local="@{local}" signed="@{signed}"/>
<!-- TODO modularize compiler.
- <deploy-one dir="@{dir}" name="scala-compiler-doc" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}" name="scala-compiler-interactive" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-compiler-doc" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-compiler-interactive" local="@{local}" signed="@{signed}"/>
-->
- <deploy-one dir="@{dir}" name="scala-actors" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}" name="scalap" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scala-actors" local="@{local}" signed="@{signed}"/>
+ <deploy-one name="scalap" local="@{local}" signed="@{signed}"/>
</sequential>
</macrodef>
+
<target name="boot.maven">
<!-- Pull in properties from build -->
<property file="build.properties" />
@@ -162,7 +264,18 @@
</echo>
</target>
- <target name="deploy" depends="init.maven" description="Deploys unsigned artifacts to the maven repo."> <deploy/> </target>
- <target name="deploy.local" depends="init.maven" description="Deploys unsigned artifacts to the local maven repo."> <deploy local="true"/> </target>
- <target name="deploy.signed" depends="init.maven" description="Deploys signed artifacts to the remote maven repo."> <deploy signed="true"/> </target>
+ <target name="deploy" depends="init.maven" description="Deploys unsigned artifacts to the maven repo.">
+ <echo message="WARNING!1! THIS TARGET HAS BEEN DEPRECATED -- CALL `ant publish` FROM /build.xml"/>
+ <deploy/>
+ </target>
+
+ <target name="deploy.local" depends="init.maven" description="Deploys unsigned artifacts to the local maven repo.">
+ <echo message="WARNING!1! THIS TARGET HAS BEEN DEPRECATED -- CALL `ant publish.local` FROM /build.xml"/>
+ <deploy local="true"/>
+ </target>
+
+ <target name="deploy.signed" depends="init.maven" description="Deploys signed artifacts to the remote maven repo.">
+ <echo message="WARNING!1! THIS TARGET HAS BEEN DEPRECATED -- CALL `ant publish.signed` FROM /build.xml"/>
+ <deploy signed="true"/>
+ </target>
</project>
diff --git a/src/build/maven/scala-compiler-pom.xml b/src/build/maven/scala-compiler-pom.xml
index a16fe22343..4a000b27a1 100644
--- a/src/build/maven/scala-compiler-pom.xml
+++ b/src/build/maven/scala-compiler-pom.xml
@@ -50,7 +50,7 @@
<artifactId>scala-parser-combinators_@SCALA_BINARY_VERSION@</artifactId>
<version>@PARSER_COMBINATORS_VERSION@</version>
</dependency>
- <dependency> <!-- for scala-compiler-repl-->
+ <dependency> <!-- for scala-compiler-repl; once it moves there, make it required -->
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>@JLINE_VERSION@</version>
diff --git a/src/build/maven/scala-dist-pom.xml b/src/build/maven/scala-dist-pom.xml
new file mode 100644
index 0000000000..413da928bb
--- /dev/null
+++ b/src/build/maven/scala-dist-pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-dist</artifactId>
+ <packaging>jar</packaging>
+ <version>@VERSION@</version>
+ <name>Scala Distribution Artifacts</name>
+ <description>The Artifacts Distributed with Scala</description>
+ <url>http://www.scala-lang.org/</url>
+ <inceptionYear>2002</inceptionYear>
+ <organization>
+ <name>LAMP/EPFL</name>
+ <url>http://lamp.epfl.ch/</url>
+ </organization>
+ <licenses>
+ <license>
+ <name>BSD 3-Clause</name>
+ <url>http://www.scala-lang.org/license.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:git://github.com/scala/scala.git</connection>
+ <url>https://github.com/scala/scala.git</url>
+ </scm>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.scala-lang.org/</url>
+ </issueManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library-all</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <!-- duplicated from scala-compiler, where it's optional,
+ so that resolving scala-dist's transitive dependencies does not include jline,
+ even though we need to include it in the dist, but macros depending on the compiler
+ shouldn't have to require jline...
+ another reason to modularize and move the dependency to scala-compiler-repl
+ TODO: remove duplication once we have the scala-compiler-repl module -->
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>@JLINE_VERSION@</version>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>scala-tools.org</id>
+ <url>@RELEASE_REPOSITORY@</url>
+ </repository>
+ <snapshotRepository>
+ <id>scala-tools.org</id>
+ <url>@SNAPSHOT_REPOSITORY@</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+ <developers>
+ <developer>
+ <id>lamp</id>
+ <name>EPFL LAMP</name>
+ </developer>
+ <developer>
+ <id>Typesafe</id>
+ <name>Typesafe, Inc.</name>
+ </developer>
+ </developers>
+</project>
diff --git a/src/build/maven/scala-library-all-pom.xml b/src/build/maven/scala-library-all-pom.xml
new file mode 100644
index 0000000000..f34a28e79a
--- /dev/null
+++ b/src/build/maven/scala-library-all-pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library-all</artifactId>
+ <packaging>pom</packaging>
+ <version>@VERSION@</version>
+ <name>Scala Library Powerpack</name>
+ <description>The Scala Standard Library and Official Modules</description>
+ <url>http://www.scala-lang.org/</url>
+ <inceptionYear>2002</inceptionYear>
+ <organization>
+ <name>LAMP/EPFL</name>
+ <url>http://lamp.epfl.ch/</url>
+ </organization>
+ <licenses>
+ <license>
+ <name>BSD 3-Clause</name>
+ <url>http://www.scala-lang.org/license.html</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:git://github.com/scala/scala.git</connection>
+ <url>https://github.com/scala/scala.git</url>
+ </scm>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.scala-lang.org/</url>
+ </issueManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-reflect</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang.modules</groupId>
+ <artifactId>scala-xml_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@XML_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang.modules</groupId>
+ <artifactId>scala-parser-combinators_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@PARSER_COMBINATORS_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang.plugins</groupId>
+ <artifactId>scala-continuations-plugin_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@CONTINUATIONS_PLUGIN_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang.plugins</groupId>
+ <artifactId>scala-continuations-library_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@CONTINUATIONS_LIBRARY_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang.modules</groupId>
+ <artifactId>scala-swing_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@SCALA_SWING_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-actor_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@AKKA_ACTOR_VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-actors-migration_@SCALA_BINARY_VERSION@</artifactId>
+ <version>@ACTORS_MIGRATION_VERSION@</version>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <repository>
+ <id>scala-tools.org</id>
+ <url>@RELEASE_REPOSITORY@</url>
+ </repository>
+ <snapshotRepository>
+ <id>scala-tools.org</id>
+ <url>@SNAPSHOT_REPOSITORY@</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+ <developers>
+ <developer>
+ <id>lamp</id>
+ <name>EPFL LAMP</name>
+ </developer>
+ <developer>
+ <id>Typesafe</id>
+ <name>Typesafe, Inc.</name>
+ </developer>
+ </developers>
+</project>
diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala
index 4c30a9a85c..280baa2a42 100644
--- a/src/compiler/scala/reflect/macros/compiler/Errors.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala
@@ -51,7 +51,7 @@ trait Errors extends Traces {
def MacroBundleNonStaticError() = bundleRefError("macro bundles must be static")
- def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member")
+ def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter")
// compatibility errors
diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
index e4851632a5..d35f1c32a9 100644
--- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
@@ -40,36 +40,11 @@ trait Resolvers {
}
val untypedImplRef = typer.silent(_.typedTypeConstructor(maybeBundleRef)) match {
- case SilentResultValue(result) if mightBeMacroBundleType(result.tpe) =>
- val bundleProto = result.tpe.typeSymbol
- val bundlePkg = bundleProto.enclosingPackageClass
- if (!isMacroBundleProtoType(bundleProto.tpe)) MacroBundleWrongShapeError()
- if (!bundleProto.owner.isStaticOwner) MacroBundleNonStaticError()
-
- // synthesize the bundle, i.e. given a static `trait Foo extends Macro { def expand = ... } `
- // create a top-level definition `class Foo$Bundle(val c: BlackboxContext/WhiteboxContext) extends Foo` in a package next to `Foo`
- val bundlePid = gen.mkUnattributedRef(bundlePkg)
- val bundlePrefix =
- if (bundlePkg == EmptyPackageClass) bundleProto.fullName('$')
- else bundleProto.fullName('$').substring(bundlePkg.fullName('$').length + 1)
- val bundleName = TypeName(bundlePrefix + tpnme.MACRO_BUNDLE_SUFFIX)
- val existingBundle = bundleProto.enclosingPackageClass.info.decl(bundleName)
- if (!currentRun.compiles(existingBundle)) {
- val contextType = if (isBlackboxMacroBundleType(bundleProto.tpe)) BlackboxContextClass.tpe else WhiteboxContextClass.tpe
- def mkContextValDef(flags: Long) = ValDef(Modifiers(flags), nme.c, TypeTree(contextType), EmptyTree)
- val contextField = mkContextValDef(PARAMACCESSOR)
- val contextParam = mkContextValDef(PARAM | PARAMACCESSOR)
- val bundleCtor = DefDef(Modifiers(), nme.CONSTRUCTOR, Nil, List(List(contextParam)), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))
- val bundleParent = gen.mkAppliedTypeTree(Ident(bundleProto), bundleProto.typeParams.map(sym => Ident(sym.name)))
- val bundleTemplate = Template(List(bundleParent), noSelfType, List(contextField, bundleCtor))
- val bundle = atPos(bundleProto.pos)(ClassDef(NoMods, bundleName, bundleProto.typeParams.map(TypeDef(_)), bundleTemplate))
- currentRun.compileLate(bundleName + ".scala", PackageDef(bundlePid, List(bundle)))
- }
-
- // synthesize the macro impl reference, which is going to look like:
- // `new FooBundle(???).macroName` plus the optional type arguments
- val bundleInstance = New(Select(bundlePid, bundleName), List(List(Ident(Predef_???))))
- atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(bundleInstance, methName), targs))
+ case SilentResultValue(result) if looksLikeMacroBundleType(result.tpe) =>
+ val bundle = result.tpe.typeSymbol
+ if (!isMacroBundleType(bundle.tpe)) MacroBundleWrongShapeError()
+ if (!bundle.owner.isStaticOwner) MacroBundleNonStaticError()
+ atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(New(bundle, Ident(Predef_???)), methName), targs))
case _ =>
macroDdef.rhs
}
diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala
index 5936b52890..02c1f7c431 100644
--- a/src/compiler/scala/reflect/macros/compiler/Validators.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala
@@ -26,9 +26,9 @@ trait Validators {
if (macroImpl.isOverloaded) MacroImplOverloadedError()
val implicitParams = aparamss.flatten filter (_.isImplicit)
if (implicitParams.nonEmpty) MacroImplNonTagImplicitParameters(implicitParams)
- val declaredInStaticObject = isImplMethod && (macroImplOwner.isStaticOwner || macroImplOwner.moduleClass.isStaticOwner)
- val declaredInTopLevelClass = isImplBundle && macroImplOwner.owner.isPackageClass
- if (!declaredInStaticObject && !declaredInTopLevelClass) MacroImplReferenceWrongShapeError()
+ val effectiveOwner = if (isImplMethod) macroImplOwner else macroImplOwner.owner
+ val declaredInStaticObject = effectiveOwner.isStaticOwner || effectiveOwner.moduleClass.isStaticOwner
+ if (!declaredInStaticObject) MacroImplReferenceWrongShapeError()
}
private def checkMacroDefMacroImplCorrespondence() = {
@@ -93,20 +93,20 @@ trait Validators {
*
* For the following macro impl:
* def fooBar[T: c.WeakTypeTag]
- * (c: scala.reflect.macros.BlackboxContext)
+ * (c: scala.reflect.macros.blackbox.Context)
* (xs: c.Expr[List[T]])
* : c.Expr[T] = ...
*
* This function will return:
- * (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[List[T]])c.Expr[T]
+ * (c: scala.reflect.macros.blackbox.Context)(xs: c.Expr[List[T]])c.Expr[T]
*
* Note that type tag evidence parameters are not included into the result.
* Type tag context bounds for macro impl tparams are optional.
* Therefore compatibility checks ignore such parameters, and we don't need to bother about them here.
*
* This method cannot be reduced to just macroImpl.info, because macro implementations might
- * come in different shapes. If the implementation is an apply method of a BlackboxMacro/WhiteboxMacro-compatible object,
- * then it won't have (c: BlackboxContext/WhiteboxContext) in its parameters, but will rather refer to BlackboxMacro/WhiteboxMacro.c.
+ * come in different shapes. If the implementation is an apply method of a *box.Macro-compatible object,
+ * then it won't have (c: *box.Context) in its parameters, but will rather refer to *boxMacro.c.
*
* @param macroImpl The macro implementation symbol
*/
@@ -123,8 +123,8 @@ trait Validators {
* def foo[T](xs: List[T]): T = macro fooBar
*
* This function will return:
- * (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[List[T]])c.Expr[T] or
- * (c: scala.reflect.macros.WhiteboxContext)(xs: c.Expr[List[T]])c.Expr[T]
+ * (c: scala.reflect.macros.blackbox.Context)(xs: c.Expr[List[T]])c.Expr[T] or
+ * (c: scala.reflect.macros.whitebox.Context)(xs: c.Expr[List[T]])c.Expr[T]
*
* Note that type tag evidence parameters are not included into the result.
* Type tag context bounds for macro impl tparams are optional.
diff --git a/src/compiler/scala/reflect/macros/contexts/Context.scala b/src/compiler/scala/reflect/macros/contexts/Context.scala
index 7b79b52a18..87dac18849 100644
--- a/src/compiler/scala/reflect/macros/contexts/Context.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Context.scala
@@ -3,8 +3,8 @@ package contexts
import scala.tools.nsc.Global
-abstract class Context extends scala.reflect.macros.BlackboxContext
- with scala.reflect.macros.WhiteboxContext
+abstract class Context extends scala.reflect.macros.blackbox.Context
+ with scala.reflect.macros.whitebox.Context
with Aliases
with Enclosures
with Names
diff --git a/src/compiler/scala/reflect/macros/contexts/Enclosures.scala b/src/compiler/scala/reflect/macros/contexts/Enclosures.scala
index bb88c8d5e1..5e931817b5 100644
--- a/src/compiler/scala/reflect/macros/contexts/Enclosures.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Enclosures.scala
@@ -8,10 +8,6 @@ trait Enclosures {
import universe._
- type MacroRole = analyzer.MacroRole
- def APPLY_ROLE = analyzer.APPLY_ROLE
- def macroRole: MacroRole
-
private lazy val site = callsiteTyper.context
private lazy val enclTrees = site.enclosingContextChain map (_.tree)
private lazy val enclPoses = enclosingMacros map (_.macroApplication.pos) filterNot (_ eq NoPosition)
diff --git a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala
index 450cb4d9ea..ecdd48db22 100644
--- a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala
+++ b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala
@@ -2,7 +2,9 @@ package scala.reflect.macros
package runtime
import scala.reflect.runtime.ReflectionUtils
-import scala.reflect.macros.{Context => ApiContext}
+import scala.reflect.macros.blackbox.{Context => BlackboxContext}
+import scala.reflect.macros.whitebox.{Context => WhiteboxContext}
+import java.lang.reflect.{Constructor => jConstructor}
trait JavaReflectionRuntimes {
self: scala.tools.nsc.typechecker.Analyzer =>
@@ -19,8 +21,15 @@ trait JavaReflectionRuntimes {
macroLogVerbose(s"successfully loaded macro impl as ($implClass, $implMeth)")
args => {
val implObj =
- if (isBundle) implClass.getConstructor(classOf[ApiContext]).newInstance(args.c)
- else ReflectionUtils.staticSingletonInstance(implClass)
+ if (isBundle) {
+ def isMacroContext(clazz: Class[_]) = clazz == classOf[BlackboxContext] || clazz == classOf[WhiteboxContext]
+ def isBundleCtor(ctor: jConstructor[_]) = ctor.getParameterTypes match {
+ case Array(param) if isMacroContext(param) => true
+ case _ => false
+ }
+ val Array(bundleCtor) = implClass.getConstructors.filter(isBundleCtor)
+ bundleCtor.newInstance(args.c)
+ } else ReflectionUtils.staticSingletonInstance(implClass)
val implArgs = if (isBundle) args.others else args.c +: args.others
implMeth.invoke(implObj, implArgs.asInstanceOf[Seq[AnyRef]]: _*)
}
diff --git a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
index 7de3341304..5fd9c0db34 100644
--- a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
+++ b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
@@ -4,7 +4,7 @@ package runtime
import scala.reflect.internal.Flags._
import scala.reflect.runtime.ReflectionUtils
-trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes {
+trait MacroRuntimes extends JavaReflectionRuntimes {
self: scala.tools.nsc.typechecker.Analyzer =>
import global._
@@ -19,8 +19,14 @@ trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes
* @return Requested runtime if macro implementation can be loaded successfully from either of the mirrors,
* `null` otherwise.
*/
+ def macroRuntime(expandee: Tree): MacroRuntime = pluginsMacroRuntime(expandee)
+
+ /** Default implementation of `macroRuntime`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsMacroRuntime for more details)
+ */
private val macroRuntimesCache = perRunCaches.newWeakMap[Symbol, MacroRuntime]
- def macroRuntime(macroDef: Symbol): MacroRuntime = {
+ def standardMacroRuntime(expandee: Tree): MacroRuntime = {
+ val macroDef = expandee.symbol
macroLogVerbose(s"looking for macro implementation: $macroDef")
if (fastTrack contains macroDef) {
macroLogVerbose("macro expansion is serviced by a fast track")
@@ -43,8 +49,7 @@ trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes
/** Abstracts away resolution of macro runtimes.
*/
type MacroRuntime = MacroArgs => Any
- class MacroRuntimeResolver(val macroDef: Symbol) extends JavaReflectionResolvers
- with ScalaReflectionResolvers {
+ class MacroRuntimeResolver(val macroDef: Symbol) extends JavaReflectionResolvers {
val binding = loadMacroImplBinding(macroDef).get
val isBundle = binding.isBundle
val className = binding.className
@@ -57,7 +62,6 @@ trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes
try {
macroLogVerbose(s"resolving macro implementation as $className.$methName (isBundle = $isBundle)")
macroLogVerbose(s"classloader is: ${ReflectionUtils.show(defaultMacroClassloader)}")
- // resolveScalaReflectionRuntime(defaultMacroClassloader)
resolveJavaReflectionRuntime(defaultMacroClassloader)
} catch {
case ex: Exception =>
diff --git a/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala
deleted file mode 100644
index 50f64310f8..0000000000
--- a/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-package scala.reflect.macros
-package runtime
-
-import scala.reflect.runtime.{universe => ru}
-
-trait ScalaReflectionRuntimes {
- self: scala.tools.nsc.typechecker.Analyzer =>
-
- trait ScalaReflectionResolvers {
- self: MacroRuntimeResolver =>
-
- def resolveScalaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = {
- val macroMirror: ru.JavaMirror = ru.runtimeMirror(classLoader)
- val implContainerSym = macroMirror.classSymbol(Class.forName(className, true, classLoader))
- val implMethSym = implContainerSym.typeSignature.member(ru.TermName(methName)).asMethod
- macroLogVerbose(s"successfully loaded macro impl as ($implContainerSym, $implMethSym)")
- args => {
- val implContainer =
- if (isBundle) {
- val implCtorSym = implContainerSym.typeSignature.member(ru.nme.CONSTRUCTOR).asMethod
- macroMirror.reflectClass(implContainerSym).reflectConstructor(implCtorSym)(args.c)
- } else {
- macroMirror.reflectModule(implContainerSym.module.asModule).instance
- }
- val implMeth = macroMirror.reflect(implContainer).reflectMethod(implMethSym)
- val implArgs = if (isBundle) args.others else args.c +: args.others
- implMeth(implArgs: _*)
- }
- }
- }
-}
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 5f079a428b..5492e563dd 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1710,25 +1710,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
}
}
- /** Create and compile a synthetic compilation unit from the provided tree.
- *
- * This needs to create a virtual file underlying the compilation unit in order to appease SBT.
- * However this file cannot have a randomly generated name, because then SBT 0.13 goes into a vicious loop
- * as described on the mailing list: https://groups.google.com/forum/#!msg/scala-user/r1SgSoVfs0U/Wv4av0LOKukJ
- * Therefore I have introduced an additional parameter that makes everyone specify meaningful file names.
- */
- def compileLate(virtualFileName: String, code: PackageDef) {
- // compatibility with SBT
- // on the one hand, we need to specify some jfile here, otherwise sbt crashes with an NPE (SI-6870)
- // on the other hand, we can't specify the obvious enclosingUnit, because then sbt somehow fails to run tests using type macros
- val fakeJfile = new java.io.File(virtualFileName)
- val virtualFile = new VirtualFile(virtualFileName) { override def file = fakeJfile }
- val sourceFile = new BatchSourceFile(virtualFile, code.toString)
- val unit = new CompilationUnit(sourceFile)
- unit.body = code
- compileLate(unit)
- }
-
/** Reset package class to state at typer (not sure what this
* is needed for?)
*/
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 61ea9230a7..d122a1a207 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -623,15 +623,6 @@ self =>
syntaxError(tpt.pos, "no * parameter type allowed here", skipIt = false)
}
- /** Check that tree is a legal clause of a forSome. */
- def checkLegalExistential(t: Tree) = t match {
- case TypeDef(_, _, _, TypeBoundsTree(_, _)) |
- ValDef(_, _, _, EmptyTree) | EmptyTree =>
- ;
- case _ =>
- syntaxError(t.pos, "not a legal existential clause", skipIt = false)
- }
-
/* -------------- TOKEN CLASSES ------------------------------------------- */
def isModifier: Boolean = in.token match {
@@ -885,9 +876,14 @@ self =>
}
}
private def makeExistentialTypeTree(t: Tree) = {
- val whereClauses = refinement()
- whereClauses foreach checkLegalExistential
- ExistentialTypeTree(t, whereClauses)
+ // EmptyTrees in the result of refinement() stand for parse errors
+ // so it's okay for us to filter them out here
+ ExistentialTypeTree(t, refinement() flatMap {
+ case t @ TypeDef(_, _, _, TypeBoundsTree(_, _)) => Some(t)
+ case t @ ValDef(_, _, _, EmptyTree) => Some(t)
+ case EmptyTree => None
+ case _ => syntaxError(t.pos, "not a legal existential clause", skipIt = false); None
+ })
}
/** {{{
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
index 5be5abd895..dd2d63ad17 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -835,6 +835,7 @@ abstract class BCodeTypes extends BCodeIdiomatic {
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
if (sym.isArtifact) ACC_SYNTHETIC else 0,
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
+ if (sym.hasEnumFlag) ACC_ENUM else 0,
if (sym.isVarargsMethod) ACC_VARARGS else 0,
if (sym.hasFlag(symtab.Flags.SYNCHRONIZED)) ACC_SYNCHRONIZED else 0
)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index e92f8c2541..7e1a82a155 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -244,6 +244,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
if (sym.isArtifact) ACC_SYNTHETIC else 0,
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
+ if (sym.hasEnumFlag) ACC_ENUM else 0,
if (sym.isVarargsMethod) ACC_VARARGS else 0,
if (sym.hasFlag(Flags.SYNCHRONIZED)) ACC_SYNCHRONIZED else 0
)
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 7932dd3459..9875d27047 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -792,7 +792,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
val superclazz =
AppliedTypeTree(javaLangDot(tpnme.Enum), List(enumType))
addCompanionObject(consts ::: statics ::: predefs, atPos(pos) {
- ClassDef(mods, name, List(),
+ ClassDef(mods | Flags.ENUM, name, List(),
makeTemplate(superclazz :: interfaces, body))
})
}
@@ -811,10 +811,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
skipAhead()
accept(RBRACE)
}
- // The STABLE flag is to signal to namer that this was read from a
- // java enum, and so should be given a Constant type (thereby making
- // it usable in annotations.)
- ValDef(Modifiers(Flags.STABLE | Flags.JAVA | Flags.STATIC), name.toTermName, enumType, blankExpr)
+ ValDef(Modifiers(Flags.ENUM | Flags.STABLE | Flags.JAVA | Flags.STATIC), name.toTermName, enumType, blankExpr)
}
}
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 183752d4a2..7837f9a11a 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -126,10 +126,11 @@ object Plugin {
}
/** Load all plugins specified by the arguments.
- * Each of `jars` must be a valid plugin archive or exploded archive.
+ * Each location of `paths` must be a valid plugin archive or exploded archive.
+ * Each of `paths` must define one plugin.
* Each of `dirs` may be a directory containing arbitrary plugin archives.
* Skips all plugins named in `ignoring`.
- * A single classloader is created and used to load all of them.
+ * A classloader is created to load each plugin.
*/
def loadAllFrom(
paths: List[List[Path]],
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 7568c789fb..6ec364bcb6 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -94,11 +94,11 @@ trait ScalaSettings extends AbsScalaSettings
val nouescape = BooleanSetting ("-Xno-uescape", "Disable handling of \\u unicode escapes.")
val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing.")
val Xverify = BooleanSetting ("-Xverify", "Verify generic signatures in generated bytecode (asm backend only.)")
- val plugin = MultiStringSetting("-Xplugin", "file", "Load one or more plugins from files.")
- val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable the given plugin(s).")
+ val plugin = MultiStringSetting("-Xplugin", "paths", "Load a plugin from each classpath.")
+ val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable plugins by name.")
val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins.")
- val require = MultiStringSetting("-Xplugin-require", "plugin", "Abort unless the given plugin(s) are available.")
- val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search compiler plugins.", Defaults.scalaPluginPath)
+ val require = MultiStringSetting("-Xplugin-require", "plugin", "Abort if a named plugin is not loaded.")
+ val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search for plugin archives.", Defaults.scalaPluginPath)
val Xprint = PhasesSetting ("-Xprint", "Print out program after")
val writeICode = PhasesSetting ("-Xprint-icode", "Log internal icode to *.icode files after", "icode")
val Xprintpos = BooleanSetting ("-Xprint-pos", "Print tree positions, as offsets.")
@@ -172,7 +172,8 @@ trait ScalaSettings extends AbsScalaSettings
val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.")
val Ymemberpos = StringSetting ("-Yshow-member-pos", "output style", "Show start and end positions of members", "") withPostSetHook (_ => Yrangepos.value = true)
val Yreifycopypaste = BooleanSetting ("-Yreify-copypaste", "Dump the reified trees in copypasteable representation.")
- val Ymacronoexpand = BooleanSetting ("-Ymacro-no-expand", "Don't expand macros. Might be useful for scaladoc and presentation compiler, but will crash anything which uses macros and gets past typer.")
+ val Ymacroexpand = ChoiceSetting ("-Ymacro-expand", "policy", "Control expansion of macros, useful for scaladoc and presentation compiler", List(MacroExpand.Normal, MacroExpand.None, MacroExpand.Discard), MacroExpand.Normal)
+ val Ymacronoexpand = BooleanSetting ("-Ymacro-no-expand", "Don't expand macros. Might be useful for scaladoc and presentation compiler, but will crash anything which uses macros and gets past typer.") withDeprecationMessage(s"Use ${Ymacroexpand.name}:${MacroExpand.None}") withPostSetHook(_ => Ymacroexpand.value = MacroExpand.None)
val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup")
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)" , "")
@@ -249,4 +250,9 @@ trait ScalaSettings extends AbsScalaSettings
def isBCodeAskedFor = (Ybackend.value != "GenASM")
def isICodeAskedFor = ((Ybackend.value == "GenASM") || optimiseSettings.exists(_.value) || writeICode.isSetByUser)
+ object MacroExpand {
+ val None = "none"
+ val Normal = "normal"
+ val Discard = "discard"
+ }
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 2b96961291..664645e53e 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -515,7 +515,7 @@ abstract class ClassfileParser {
val info = readType()
val sym = ownerForFlags(jflags).newValue(name.toTermName, NoPosition, sflags)
- // Note: the info may be overrwritten later with a generic signature
+ // Note: the info may be overwritten later with a generic signature
// parsed from SignatureATTR
sym setInfo {
if (jflags.isEnum) ConstantType(Constant(sym))
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 9738769db9..f14fce5de9 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -481,18 +481,33 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
* For instance, say we have a Scala class:
*
* class Cls {
- * // ...
- * def someSymbol = `symbolic
- * // ...
+ * def someSymbol1 = 'Symbolic1
+ * def someSymbol2 = 'Symbolic2
+ * def sameSymbol1 = 'Symbolic1
+ * val someSymbol3 = 'Symbolic3
* }
*
* After transformation, this class looks like this:
*
* class Cls {
- * private "static" val <some_name>$symbolic = Symbol("symbolic")
- * // ...
- * def someSymbol = <some_name>$symbolic
- * // ...
+ * private <static> var symbol$1: scala.Symbol
+ * private <static> var symbol$2: scala.Symbol
+ * private <static> var symbol$3: scala.Symbol
+ * private val someSymbol3: scala.Symbol
+ *
+ * private <static> def <clinit> = {
+ * symbol$1 = Symbol.apply("Symbolic1")
+ * symbol$2 = Symbol.apply("Symbolic2")
+ * }
+ *
+ * private def <init> = {
+ * someSymbol3 = symbol$3
+ * }
+ *
+ * def someSymbol1 = symbol$1
+ * def someSymbol2 = symbol$2
+ * def sameSymbol1 = symbol$1
+ * val someSymbol3 = someSymbol3
* }
*
* The reasoning behind this transformation is the following. Symbols get interned - they are stored
@@ -502,17 +517,17 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
* is accessed only once during class loading, and after that, the unique symbol is in the static
* member. Hence, it is cheap to both reach the unique symbol and do equality checks on it.
*
- * And, finally, be advised - scala symbol literal and the Symbol class of the compiler
+ * And, finally, be advised - Scala's Symbol literal (scala.Symbol) and the Symbol class of the compiler
* have little in common.
*/
case Apply(fn, (arg @ Literal(Constant(symname: String))) :: Nil) if fn.symbol == Symbol_apply =>
def transformApply = {
- // add the symbol name to a map if it's not there already
- val rhs = gen.mkMethodCall(Symbol_apply, arg :: Nil)
- val staticFieldSym = getSymbolStaticField(tree.pos, symname, rhs, tree)
- // create a reference to a static field
- val ntree = typedWithPos(tree.pos)(REF(staticFieldSym))
- super.transform(ntree)
+ // add the symbol name to a map if it's not there already
+ val rhs = gen.mkMethodCall(Symbol_apply, arg :: Nil)
+ val staticFieldSym = getSymbolStaticField(tree.pos, symname, rhs, tree)
+ // create a reference to a static field
+ val ntree = typedWithPos(tree.pos)(REF(staticFieldSym))
+ super.transform(ntree)
}
transformApply
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 844774e75f..ef50ae276f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -457,12 +457,11 @@ abstract class UnCurry extends InfoTransform
else
super.transform(tree)
case UnApply(fn, args) =>
- val fn1 = transform(fn)
- val args1 = transformTrees(fn.symbol.name match {
- case nme.unapply => args
- case nme.unapplySeq => transformArgs(tree.pos, fn.symbol, args, localTyper.expectedPatternTypes(fn, args))
- case _ => sys.error("internal error: UnApply node has wrong symbol")
- })
+ val fn1 = transform(fn)
+ val args1 = fn.symbol.name match {
+ case nme.unapplySeq => transformArgs(tree.pos, fn.symbol, args, patmat.alignPatterns(tree).expectedTypes)
+ case _ => args
+ }
treeCopy.UnApply(tree, fn1, args1)
case Apply(fn, args) =>
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
index 63f4a4bf25..699e98f963 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
@@ -31,6 +31,30 @@ trait MatchTranslation {
trait MatchTranslator extends TreeMakers with TreeMakerWarnings {
import typer.context
+ /** A conservative approximation of which patterns do not discern anything.
+ * They are discarded during the translation.
+ */
+ object WildcardPattern {
+ def unapply(pat: Tree): Boolean = pat match {
+ case Bind(nme.WILDCARD, WildcardPattern()) => true // don't skip when binding an interesting symbol!
+ case Star(WildcardPattern()) => true
+ case x: Ident => treeInfo.isVarPattern(x)
+ case Alternative(ps) => ps forall unapply
+ case EmptyTree => true
+ case _ => false
+ }
+ }
+
+ object PatternBoundToUnderscore {
+ def unapply(pat: Tree): Boolean = pat match {
+ case Bind(nme.WILDCARD, _) => true // don't skip when binding an interesting symbol!
+ case Ident(nme.WILDCARD) => true
+ case Alternative(ps) => ps forall unapply
+ case Typed(PatternBoundToUnderscore(), _) => true
+ case _ => false
+ }
+ }
+
object SymbolBound {
def unapply(tree: Tree): Option[(Symbol, Tree)] = tree match {
case Bind(_, expr) if hasSym(tree) => Some(tree.symbol -> expr)
@@ -86,10 +110,8 @@ trait MatchTranslation {
// example check: List[Int] <:< ::[Int]
private def extractorStep(): TranslationStep = {
- import extractor.{ paramType, treeMaker }
- if (!extractor.isTyped)
- ErrorUtils.issueNormalTypeError(tree, "Could not typecheck extractor call: "+ extractor)(context)
-
+ def paramType = extractor.aligner.wholeType
+ import extractor.treeMaker
// chain a type-testing extractor before the actual extractor call
// it tests the type, checks the outer pointer and casts to the expected type
// TODO: the outer check is mandated by the spec for case classes, but we do it for user-defined unapplies as well [SPEC]
@@ -355,36 +377,20 @@ trait MatchTranslation {
object ExtractorCall {
// TODO: check unargs == args
def apply(tree: Tree): ExtractorCall = tree match {
- case UnApply(unfun, args) => new ExtractorCallRegular(unfun, args) // extractor
- case Apply(fun, args) => new ExtractorCallProd(fun, args) // case class
+ case UnApply(unfun, args) => new ExtractorCallRegular(alignPatterns(tree), unfun, args) // extractor
+ case Apply(fun, args) => new ExtractorCallProd(alignPatterns(tree), fun, args) // case class
}
}
- abstract class ExtractorCall {
+ abstract class ExtractorCall(val aligner: PatternAligned) {
+ import aligner._
def fun: Tree
def args: List[Tree]
- val nbSubPats = args.length
- val starLength = if (hasStar) 1 else 0
- val nonStarLength = args.length - starLength
-
- // everything okay, captain?
- def isTyped: Boolean
- def isSeq: Boolean
-
- private def hasStar = nbSubPats > 0 && isStar(args.last)
- private def isNonEmptySeq = nbSubPats > 0 && isSeq
-
- /** This is special cased so that a single pattern will accept any extractor
- * result, even if it's a tuple (SI-6675)
- */
- def isSingle = nbSubPats == 1 && !isSeq
-
- // to which type should the previous binder be casted?
- def paramType : Type
-
- protected def rawSubPatTypes: List[Type]
- protected def resultType: Type
+ // don't go looking for selectors if we only expect one pattern
+ def rawSubPatTypes = aligner.extractedTypes
+ def resultInMonad = if (isBool) UnitTpe else typeOfMemberNamedGet(resultType)
+ def resultType = fun.tpe.finalResultType
/** Create the TreeMaker that embodies this extractor call
*
@@ -407,24 +413,14 @@ trait MatchTranslation {
lazy val ignoredSubPatBinders: Set[Symbol] = subPatBinders zip args collect { case (b, PatternBoundToUnderscore()) => b } toSet
// do repeated-parameter expansion to match up with the expected number of arguments (in casu, subpatterns)
- private def nonStarSubPatTypes = formalTypes(rawInit :+ repeatedType, nonStarLength)
+ private def nonStarSubPatTypes = aligner.typedNonStarPatterns map (_.tpe)
- def subPatTypes: List[Type] = (
- if (rawSubPatTypes.isEmpty || !isSeq) rawSubPatTypes
- else if (hasStar) nonStarSubPatTypes :+ sequenceType
- else nonStarSubPatTypes
- )
-
- private def rawGet = typeOfMemberNamedGetOrSelf(resultType)
- private def rawInit = rawSubPatTypes dropRight 1
- protected def sequenceType = typeOfLastSelectorOrSelf(rawGet)
- protected def elementType = elementTypeOfLastSelectorOrSelf(rawGet)
- protected def repeatedType = scalaRepeatedType(elementType)
+ def subPatTypes: List[Type] = typedPatterns map (_.tpe)
- // rawSubPatTypes.last is the Seq, thus there are `rawSubPatTypes.length - 1` non-seq elements in the tuple
- protected def firstIndexingBinder = rawSubPatTypes.length - 1
- protected def lastIndexingBinder = nbSubPats - 1 - starLength
- protected def expectedLength = lastIndexingBinder - firstIndexingBinder + 1
+ // there are `productArity` non-seq elements in the tuple.
+ protected def firstIndexingBinder = productArity
+ protected def expectedLength = elementArity
+ protected def lastIndexingBinder = totalArity - starArity - 1
private def productElemsToN(binder: Symbol, n: Int): List[Tree] = 1 to n map tupleSel(binder) toList
private def genTake(binder: Symbol, n: Int): List[Tree] = (0 until n).toList map (codegen index seqTree(binder))
@@ -438,12 +434,12 @@ trait MatchTranslation {
// referenced by `binder`
protected def subPatRefsSeq(binder: Symbol): List[Tree] = {
def lastTrees: List[Tree] = (
- if (!hasStar) Nil
+ if (!aligner.isStar) Nil
else if (expectedLength == 0) seqTree(binder) :: Nil
else genDrop(binder, expectedLength)
)
// this error-condition has already been checked by checkStarPatOK:
- // if(isSeq) assert(firstIndexingBinder + nbIndexingIndices + (if(lastIsStar) 1 else 0) == nbSubPats, "(resultInMonad, ts, subPatTypes, subPats)= "+(resultInMonad, ts, subPatTypes, subPats))
+ // if(isSeq) assert(firstIndexingBinder + nbIndexingIndices + (if(lastIsStar) 1 else 0) == totalArity, "(resultInMonad, ts, subPatTypes, subPats)= "+(resultInMonad, ts, subPatTypes, subPats))
// [1] there are `firstIndexingBinder` non-seq tuple elements preceding the Seq
// [2] then we have to index the binder that represents the sequence for the remaining subpatterns, except for...
@@ -457,8 +453,10 @@ trait MatchTranslation {
// the trees that select the subpatterns on the extractor's result, referenced by `binder`
// require (nbSubPats > 0 && (!lastIsStar || isSeq))
- protected def subPatRefs(binder: Symbol): List[Tree] =
- if (isNonEmptySeq) subPatRefsSeq(binder) else productElemsToN(binder, nbSubPats)
+ protected def subPatRefs(binder: Symbol): List[Tree] = (
+ if (totalArity > 0 && isSeq) subPatRefsSeq(binder)
+ else productElemsToN(binder, totalArity)
+ )
private def compareInts(t1: Tree, t2: Tree) =
gen.mkMethodCall(termMember(ScalaPackage, "math"), TermName("signum"), Nil, (t1 INT_- t2) :: Nil)
@@ -478,7 +476,7 @@ trait MatchTranslation {
// when the last subpattern is a wildcard-star the expectedLength is but a lower bound
// (otherwise equality is required)
def compareOp: (Tree, Tree) => Tree =
- if (hasStar) _ INT_>= _
+ if (aligner.isStar) _ INT_>= _
else _ INT_== _
// `if (binder != null && $checkExpectedLength [== | >=] 0) then else zero`
@@ -487,26 +485,14 @@ trait MatchTranslation {
def checkedLength: Option[Int] =
// no need to check unless it's an unapplySeq and the minimal length is non-trivially satisfied
- if (!isSeq || expectedLength < starLength) None
+ if (!isSeq || expectedLength < starArity) None
else Some(expectedLength)
}
// TODO: to be called when there's a def unapplyProd(x: T): U
// U must have N members _1,..., _N -- the _i are type checked, call their type Ti,
// for now only used for case classes -- pretending there's an unapplyProd that's the identity (and don't call it)
- class ExtractorCallProd(val fun: Tree, val args: List[Tree]) extends ExtractorCall {
- private def constructorTp = fun.tpe
-
- def isTyped = fun.isTyped
-
- // to which type should the previous binder be casted?
- def paramType = constructorTp.finalResultType
- def resultType = fun.tpe.finalResultType
-
- def isSeq = isVarArgTypes(rawSubPatTypes)
-
- protected def rawSubPatTypes = constructorTp.paramTypes
-
+ class ExtractorCallProd(aligner: PatternAligned, val fun: Tree, val args: List[Tree]) extends ExtractorCall(aligner) {
/** Create the TreeMaker that embodies this extractor call
*
* `binder` has been casted to `paramType` if necessary
@@ -535,20 +521,11 @@ trait MatchTranslation {
if (accessors isDefinedAt (i-1)) REF(binder) DOT accessors(i-1)
else codegen.tupleSel(binder)(i) // this won't type check for case classes, as they do not inherit ProductN
}
-
- override def toString() = s"ExtractorCallProd($fun:${fun.tpe} / ${fun.symbol} / args=$args)"
}
- class ExtractorCallRegular(extractorCallIncludingDummy: Tree, val args: List[Tree]) extends ExtractorCall {
+ class ExtractorCallRegular(aligner: PatternAligned, extractorCallIncludingDummy: Tree, val args: List[Tree]) extends ExtractorCall(aligner) {
val Unapplied(fun) = extractorCallIncludingDummy
- def tpe = fun.tpe
- def paramType = firstParamType(tpe)
- def resultType = tpe.finalResultType
- def isTyped = (tpe ne NoType) && fun.isTyped && (resultInMonad ne ErrorType)
- def isSeq = fun.symbol.name == nme.unapplySeq
- def isBool = resultType =:= BooleanTpe
-
/** Create the TreeMaker that embodies this extractor call
*
* `binder` has been casted to `paramType` if necessary
@@ -571,7 +548,7 @@ trait MatchTranslation {
ExtractorTreeMaker(extractorApply, lengthGuard(binder), binder)(
subPatBinders,
subPatRefs(binder),
- isBool,
+ aligner.isBool,
checkedLength,
patBinderOrCasted,
ignoredSubPatBinders
@@ -583,9 +560,9 @@ trait MatchTranslation {
else super.seqTree(binder)
// the trees that select the subpatterns on the extractor's result, referenced by `binder`
- // require (nbSubPats > 0 && (!lastIsStar || isSeq))
+ // require (totalArity > 0 && (!lastIsStar || isSeq))
override protected def subPatRefs(binder: Symbol): List[Tree] =
- if (isSingle) REF(binder) :: Nil // special case for extractors
+ if (aligner.isSingle) REF(binder) :: Nil // special case for extractors
else super.subPatRefs(binder)
protected def spliceApply(binder: Symbol): Tree = {
@@ -606,40 +583,7 @@ trait MatchTranslation {
splice transform extractorCallIncludingDummy
}
- // what's the extractor's result type in the monad? It is the type of its nullary member `get`.
- protected lazy val resultInMonad: Type = if (isBool) UnitTpe else typeOfMemberNamedGet(resultType)
-
- protected lazy val rawSubPatTypes = (
- if (isBool) Nil
- else if (isSingle) resultInMonad :: Nil // don't go looking for selectors if we only expect one pattern
- else typesOfSelectorsOrSelf(resultInMonad)
- )
-
- override def toString() = s"ExtractorCallRegular($fun: $tpe / ${fun.symbol})"
- }
-
- /** A conservative approximation of which patterns do not discern anything.
- * They are discarded during the translation.
- */
- object WildcardPattern {
- def unapply(pat: Tree): Boolean = pat match {
- case Bind(nme.WILDCARD, WildcardPattern()) => true // don't skip when binding an interesting symbol!
- case Star(WildcardPattern()) => true
- case x: Ident => treeInfo.isVarPattern(x)
- case Alternative(ps) => ps forall unapply
- case EmptyTree => true
- case _ => false
- }
- }
-
- object PatternBoundToUnderscore {
- def unapply(pat: Tree): Boolean = pat match {
- case Bind(nme.WILDCARD, _) => true // don't skip when binding an interesting symbol!
- case Ident(nme.WILDCARD) => true
- case Alternative(ps) => ps forall unapply
- case Typed(PatternBoundToUnderscore(), _) => true
- case _ => false
- }
+ override def rawSubPatTypes = aligner.extractor.varargsTypes
}
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
index 7df03044aa..a80f158949 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
@@ -395,8 +395,10 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging {
debug.patmat("TTTM"+((prevBinder, extractorArgTypeTest, testedBinder, expectedTp, nextBinderTp)))
lazy val outerTestNeeded = (
- !((expectedTp.prefix eq NoPrefix) || expectedTp.prefix.typeSymbol.isPackageClass)
- && needsOuterTest(expectedTp, testedBinder.info, matchOwner))
+ (expectedTp.prefix ne NoPrefix)
+ && !expectedTp.prefix.typeSymbol.isPackageClass
+ && needsOuterTest(expectedTp, testedBinder.info, matchOwner)
+ )
// the logic to generate the run-time test that follows from the fact that
// a `prevBinder` is expected to have type `expectedTp`
@@ -406,44 +408,52 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging {
def renderCondition(cs: TypeTestCondStrategy): cs.Result = {
import cs._
- def default =
- // do type test first to ensure we won't select outer on null
- if (outerTestNeeded) and(typeTest(testedBinder, expectedTp), outerTest(testedBinder, expectedTp))
- else typeTest(testedBinder, expectedTp)
-
// propagate expected type
def expTp(t: Tree): t.type = t setType expectedTp
+ def testedWide = testedBinder.info.widen
+ def expectedWide = expectedTp.widen
+ def isAnyRef = testedWide <:< AnyRefTpe
+ def isAsExpected = testedWide <:< expectedTp
+ def isExpectedPrimitiveType = isAsExpected && isPrimitiveValueType(expectedTp)
+ def isExpectedReferenceType = isAsExpected && (expectedTp <:< AnyRefTpe)
+ def mkNullTest = nonNullTest(testedBinder)
+ def mkOuterTest = outerTest(testedBinder, expectedTp)
+ def mkTypeTest = typeTest(testedBinder, expectedWide)
+
+ def mkEqualsTest(lhs: Tree): cs.Result = equalsTest(lhs, testedBinder)
+ def mkEqTest(lhs: Tree): cs.Result = eqTest(lhs, testedBinder)
+ def addOuterTest(res: cs.Result): cs.Result = if (outerTestNeeded) and(res, mkOuterTest) else res
+
+ // If we conform to expected primitive type:
+ // it cannot be null and cannot have an outer pointer. No further checking.
+ // If we conform to expected reference type:
+ // have to test outer and non-null
+ // If we do not conform to expected type:
+ // have to test type and outer (non-null is implied by successful type test)
+ def mkDefault = (
+ if (isExpectedPrimitiveType) tru
+ else addOuterTest(
+ if (isExpectedReferenceType) mkNullTest
+ else mkTypeTest
+ )
+ )
+
// true when called to type-test the argument to an extractor
// don't do any fancy equality checking, just test the type
- if (extractorArgTypeTest) default
+ // TODO: verify that we don't need to special-case Array
+ // I think it's okay:
+ // - the isInstanceOf test includes a test for the element type
+ // - Scala's arrays are invariant (so we don't drop type tests unsoundly)
+ if (extractorArgTypeTest) mkDefault
else expectedTp match {
- // TODO: [SPEC] the spec requires `eq` instead of `==` for singleton types
- // this implies sym.isStable
- case SingleType(_, sym) => and(equalsTest(gen.mkAttributedQualifier(expectedTp), testedBinder), typeTest(testedBinder, expectedTp.widen))
- // must use == to support e.g. List() == Nil
- case ThisType(sym) if sym.isModule => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen))
- case ConstantType(Constant(null)) if testedBinder.info.widen <:< AnyRefTpe
- => eqTest(expTp(CODE.NULL), testedBinder)
- case ConstantType(const) => equalsTest(expTp(Literal(const)), testedBinder)
- case ThisType(sym) => eqTest(expTp(This(sym)), testedBinder)
-
- // TODO: verify that we don't need to special-case Array
- // I think it's okay:
- // - the isInstanceOf test includes a test for the element type
- // - Scala's arrays are invariant (so we don't drop type tests unsoundly)
- case _ if testedBinder.info.widen <:< expectedTp =>
- // if the expected type is a primitive value type, it cannot be null and it cannot have an outer pointer
- // since the types conform, no further checking is required
- if (isPrimitiveValueType(expectedTp)) tru
- // have to test outer and non-null only when it's a reference type
- else if (expectedTp <:< AnyRefTpe) {
- // do non-null check first to ensure we won't select outer on null
- if (outerTestNeeded) and(nonNullTest(testedBinder), outerTest(testedBinder, expectedTp))
- else nonNullTest(testedBinder)
- } else default
-
- case _ => default
+ // TODO: [SPEC] the spec requires `eq` instead of `==` for singleton types - this implies sym.isStable
+ case SingleType(_, sym) => and(mkEqualsTest(gen.mkAttributedQualifier(expectedTp)), mkTypeTest)
+ case ThisType(sym) if sym.isModule => and(mkEqualsTest(CODE.REF(sym)), mkTypeTest) // must use == to support e.g. List() == Nil
+ case ConstantType(Constant(null)) if isAnyRef => mkEqTest(expTp(CODE.NULL))
+ case ConstantType(const) => mkEqualsTest(expTp(Literal(const)))
+ case ThisType(sym) => mkEqTest(expTp(This(sym)))
+ case _ => mkDefault
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala
new file mode 100644
index 0000000000..e84ccbf754
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala
@@ -0,0 +1,155 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala
+package tools
+package nsc
+package transform
+package patmat
+
+/** An extractor returns: F1, F2, ..., Fi, opt[Seq[E] or E*]
+ * A case matches: P1, P2, ..., Pj, opt[Seq[E]]
+ * Put together: P1/F1, P2/F2, ... Pi/Fi, Pi+1/E, Pi+2/E, ... Pj/E, opt[Seq[E]]
+ *
+ * Here Pm/Fi is the last pattern to match the fixed arity section.
+ *
+ * productArity: the value of i, i.e. the number of non-sequence types in the extractor
+ * nonStarArity: the value of j, i.e. the number of non-star patterns in the case definition
+ * elementArity: j - i, i.e. the number of non-star patterns which must match sequence elements
+ * starArity: 1 or 0 based on whether there is a star (sequence-absorbing) pattern
+ * totalArity: nonStarArity + starArity, i.e. the number of patterns in the case definition
+ *
+ * Note that productArity is a function only of the extractor, and
+ * nonStar/star/totalArity are all functions of the patterns. The key
+ * value for aligning and typing the patterns is elementArity, as it
+ * is derived from both sets of information.
+ */
+trait PatternExpander[Pattern, Type] {
+ /** You'll note we're not inside the cake. "Pattern" and "Type" are
+ * arbitrary types here, and NoPattern and NoType arbitrary values.
+ */
+ def NoPattern: Pattern
+ def NoType: Type
+
+ /** It's not optimal that we're carrying both sequence and repeated
+ * type here, but the implementation requires more unraveling before
+ * it can be avoided.
+ *
+ * sequenceType is Seq[T], elementType is T, repeatedType is T*.
+ */
+ sealed case class Repeated(sequenceType: Type, elementType: Type, repeatedType: Type) {
+ def exists = elementType != NoType
+
+ def elementList = if (exists) elementType :: Nil else Nil
+ def sequenceList = if (exists) sequenceType :: Nil else Nil
+ def repeatedList = if (exists) repeatedType :: Nil else Nil
+
+ override def toString = s"${elementType}*"
+ }
+ object NoRepeated extends Repeated(NoType, NoType, NoType) {
+ override def toString = "<none>"
+ }
+
+ final case class Patterns(fixed: List[Pattern], star: Pattern) {
+ def hasStar = star != NoPattern
+ def starArity = if (hasStar) 1 else 0
+ def nonStarArity = fixed.length
+ def totalArity = nonStarArity + starArity
+ def starPatterns = if (hasStar) star :: Nil else Nil
+ def all = fixed ::: starPatterns
+
+ override def toString = all mkString ", "
+ }
+
+ /** An 'extractor' can be a case class or an unapply or unapplySeq method.
+ * Decoding what it is that they extract takes place before we arrive here,
+ * so that this class can concentrate only on the relationship between
+ * patterns and types.
+ *
+ * In a case class, the class is the unextracted type and the fixed and
+ * repeated types are derived from its constructor parameters.
+ *
+ * In an unapply, this is reversed: the parameter to the unapply is the
+ * unextracted type, and the other types are derived based on the return
+ * type of the unapply method.
+ *
+ * In other words, this case class and unapply are encoded the same:
+ *
+ * case class Foo(x: Int, y: Int, zs: Char*)
+ * def unapplySeq(x: Foo): Option[(Int, Int, Seq[Char])]
+ *
+ * Both are Extractor(Foo, Int :: Int :: Nil, Repeated(Seq[Char], Char, Char*))
+ *
+ * @param whole The type in its unextracted form
+ * @param fixed The non-sequence types which are extracted
+ * @param repeated The sequence type which is extracted
+ */
+ final case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated) {
+ require(whole != NoType, s"expandTypes($whole, $fixed, $repeated)")
+
+ def productArity = fixed.length
+ def hasSeq = repeated.exists
+ def elementType = repeated.elementType
+ def sequenceType = repeated.sequenceType
+ def allTypes = fixed ::: repeated.sequenceList
+ def varargsTypes = fixed ::: repeated.repeatedList
+ def isErroneous = allTypes contains NoType
+
+ private def typeStrings = fixed.map("" + _) ::: ( if (hasSeq) List("" + repeated) else Nil )
+
+ def offeringString = if (isErroneous) "<error>" else typeStrings match {
+ case Nil => "Boolean"
+ case tp :: Nil => tp
+ case tps => tps.mkString("(", ", ", ")")
+ }
+ override def toString = "%s => %s".format(whole, offeringString)
+ }
+
+ final case class TypedPat(pat: Pattern, tpe: Type) {
+ override def toString = s"$pat: $tpe"
+ }
+
+ /** If elementArity is...
+ * 0: A perfect match between extractor and the fixed patterns.
+ * If there is a star pattern it will match any sequence.
+ * > 0: There are more patterns than products. There will have to be a
+ * sequence which can populate at least <elementArity> patterns.
+ * < 0: There are more products than patterns: compile time error.
+ */
+ final case class Aligned(patterns: Patterns, extractor: Extractor) {
+ def elementArity = patterns.nonStarArity - productArity
+ def productArity = extractor.productArity
+ def starArity = patterns.starArity
+ def totalArity = patterns.totalArity
+
+ def wholeType = extractor.whole
+ def sequenceType = extractor.sequenceType
+ def productTypes = extractor.fixed
+ def extractedTypes = extractor.allTypes
+ def typedNonStarPatterns = products ::: elements
+ def typedPatterns = typedNonStarPatterns ::: stars
+
+ def isBool = !isSeq && productArity == 0
+ def isSingle = !isSeq && totalArity == 1
+ def isStar = patterns.hasStar
+ def isSeq = extractor.hasSeq
+
+ private def typedAsElement(pat: Pattern) = TypedPat(pat, extractor.elementType)
+ private def typedAsSequence(pat: Pattern) = TypedPat(pat, extractor.sequenceType)
+ private def productPats = patterns.fixed take productArity
+ private def elementPats = patterns.fixed drop productArity
+ private def products = (productPats, productTypes).zipped map TypedPat
+ private def elements = elementPats map typedAsElement
+ private def stars = patterns.starPatterns map typedAsSequence
+
+ override def toString = s"""
+ |Aligned {
+ | patterns $patterns
+ | extractor $extractor
+ | arities $productArity/$elementArity/$starArity // product/element/star
+ | typed ${typedPatterns mkString ", "}
+ |}""".stripMargin.trim
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala b/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala
index 394ba98f17..f6c960d089 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/PatternMatching.scala
@@ -34,7 +34,8 @@ import scala.reflect.internal.util.Position
* - recover GADT typing by locally inserting implicit witnesses to type equalities derived from the current case, and considering these witnesses during subtyping (?)
* - recover exhaustivity/unreachability of user-defined extractors by partitioning the types they match on using an HList or similar type-level structure
*/
-trait PatternMatching extends Transform with TypingTransformers
+trait PatternMatching extends Transform
+ with TypingTransformers
with Debugging
with Interface
with MatchTranslation
@@ -45,7 +46,8 @@ trait PatternMatching extends Transform with TypingTransformers
with Solving
with MatchAnalysis
with MatchOptimization
- with MatchWarnings {
+ with MatchWarnings
+ with ScalacPatternExpanders {
import global._
val phaseName: String = "patmat"
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala
new file mode 100644
index 0000000000..7858cb5586
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala
@@ -0,0 +1,154 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala
+package tools
+package nsc
+package transform
+package patmat
+
+/** This is scalac-specific logic layered on top of the scalac-agnostic
+ * "matching products to patterns" logic defined in PatternExpander.
+ */
+trait ScalacPatternExpanders {
+ val global: Global
+
+ import global._
+ import definitions._
+ import treeInfo._
+
+ type PatternAligned = ScalacPatternExpander#Aligned
+
+ implicit class AlignedOps(val aligned: PatternAligned) {
+ import aligned._
+ def expectedTypes = typedPatterns map (_.tpe)
+ def unexpandedFormals = extractor.varargsTypes
+ }
+ trait ScalacPatternExpander extends PatternExpander[Tree, Type] {
+ def NoPattern = EmptyTree
+ def NoType = global.NoType
+
+ def newPatterns(patterns: List[Tree]): Patterns = patterns match {
+ case init :+ last if isStar(last) => Patterns(init, last)
+ case _ => Patterns(patterns, NoPattern)
+ }
+ def elementTypeOf(tpe: Type) = {
+ val seq = repeatedToSeq(tpe)
+
+ ( typeOfMemberNamedHead(seq)
+ orElse typeOfMemberNamedApply(seq)
+ orElse definitions.elementType(ArrayClass, seq)
+ )
+ }
+ def newExtractor(whole: Type, fixed: List[Type], repeated: Repeated): Extractor =
+ logResult(s"newExtractor($whole, $fixed, $repeated")(Extractor(whole, fixed, repeated))
+
+ // Turn Seq[A] into Repeated(Seq[A], A, A*)
+ def repeatedFromSeq(seqType: Type): Repeated = {
+ val elem = elementTypeOf(seqType)
+ val repeated = scalaRepeatedType(elem)
+
+ Repeated(seqType, elem, repeated)
+ }
+ // Turn A* into Repeated(Seq[A], A, A*)
+ def repeatedFromVarargs(repeated: Type): Repeated =
+ Repeated(repeatedToSeq(repeated), repeatedToSingle(repeated), repeated)
+
+ /** In this case we are basing the pattern expansion on a case class constructor.
+ * The argument is the MethodType carried by the primary constructor.
+ */
+ def applyMethodTypes(method: Type): Extractor = {
+ val whole = method.finalResultType
+
+ method.paramTypes match {
+ case init :+ last if isScalaRepeatedParamType(last) => newExtractor(whole, init, repeatedFromVarargs(last))
+ case tps => newExtractor(whole, tps, NoRepeated)
+ }
+ }
+
+ /** In this case, expansion is based on an unapply or unapplySeq method.
+ * Unfortunately the MethodType does not carry the information of whether
+ * it was unapplySeq, so we have to funnel that information in separately.
+ */
+ def unapplyMethodTypes(method: Type, isSeq: Boolean): Extractor = {
+ val whole = firstParamType(method)
+ val result = method.finalResultType
+ val expanded = (
+ if (result =:= BooleanTpe) Nil
+ else typeOfMemberNamedGet(result) match {
+ case rawGet if !hasSelectors(rawGet) => rawGet :: Nil
+ case rawGet => typesOfSelectors(rawGet)
+ }
+ )
+ expanded match {
+ case init :+ last if isSeq => newExtractor(whole, init, repeatedFromSeq(last))
+ case tps => newExtractor(whole, tps, NoRepeated)
+ }
+ }
+ }
+ object alignPatterns extends ScalacPatternExpander {
+ /** Converts a T => (A, B, C) extractor to a T => ((A, B, CC)) extractor.
+ */
+ def tupleExtractor(extractor: Extractor): Extractor =
+ extractor.copy(fixed = tupleType(extractor.fixed) :: Nil)
+
+ private def validateAligned(tree: Tree, aligned: Aligned): Aligned = {
+ import aligned._
+
+ def owner = tree.symbol.owner
+ def offering = extractor.offeringString
+ def symString = tree.symbol.fullLocationString
+ def offerString = if (extractor.isErroneous) "" else s" offering $offering"
+ def arityExpected = ( if (extractor.hasSeq) "at least " else "" ) + productArity
+
+ def err(msg: String) = currentUnit.error(tree.pos, msg)
+ def warn(msg: String) = currentUnit.warning(tree.pos, msg)
+ def arityError(what: String) = err(s"$what patterns for $owner$offerString: expected $arityExpected, found $totalArity")
+
+ if (isStar && !isSeq)
+ err("Star pattern must correspond with varargs or unapplySeq")
+ else if (elementArity < 0)
+ arityError("not enough")
+ else if (elementArity > 0 && !extractor.hasSeq)
+ arityError("too many")
+
+ aligned
+ }
+
+ def apply(sel: Tree, args: List[Tree]): Aligned = {
+ val fn = sel match {
+ case Unapplied(fn) => fn
+ case _ => sel
+ }
+ val patterns = newPatterns(args)
+ val isSeq = sel.symbol.name == nme.unapplySeq
+ val isUnapply = sel.symbol.name == nme.unapply
+ val extractor = sel.symbol.name match {
+ case nme.unapply => unapplyMethodTypes(fn.tpe, isSeq = false)
+ case nme.unapplySeq => unapplyMethodTypes(fn.tpe, isSeq = true)
+ case _ => applyMethodTypes(fn.tpe)
+ }
+
+ /** Rather than let the error that is SI-6675 pollute the entire matching
+ * process, we will tuple the extractor before creation Aligned so that
+ * it contains known good values.
+ */
+ def productArity = extractor.productArity
+ def acceptMessage = if (extractor.isErroneous) "" else s" to hold ${extractor.offeringString}"
+ val requiresTupling = isUnapply && patterns.totalArity == 1 && productArity > 1
+
+ if (settings.lint && requiresTupling && effectivePatternArity(args) == 1)
+ currentUnit.warning(sel.pos, s"${sel.symbol.owner} expects $productArity patterns$acceptMessage but crushing into $productArity-tuple to fit single pattern (SI-6675)")
+
+ val normalizedExtractor = if (requiresTupling) tupleExtractor(extractor) else extractor
+ validateAligned(fn, Aligned(patterns, normalizedExtractor))
+ }
+
+ def apply(tree: Tree): Aligned = tree match {
+ case Apply(fn, args) => apply(fn, args)
+ case UnApply(fn, args) => apply(fn, args)
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
index 54e4fefc15..fa6e5399eb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
@@ -13,7 +13,6 @@ package typechecker
trait AnalyzerPlugins { self: Analyzer =>
import global._
-
trait AnalyzerPlugin {
/**
* Selectively activate this analyzer plugin, e.g. according to the compiler phase.
@@ -156,6 +155,117 @@ trait AnalyzerPlugins { self: Analyzer =>
def pluginsTypedReturn(tpe: Type, typer: Typer, tree: Return, pt: Type): Type = tpe
}
+ /**
+ * @define nonCumulativeReturnValueDoc Returns `None` if the plugin doesn't want to customize the default behavior
+ * or something else if the plugin knows better that the implementation provided in scala-compiler.jar.
+ * If multiple plugins return a non-empty result, it's going to be a compilation error.
+ */
+ trait MacroPlugin {
+ /**
+ * Selectively activate this analyzer plugin, e.g. according to the compiler phase.
+ *
+ * Note that the current phase can differ from the global compiler phase (look for `enteringPhase`
+ * invocations in the compiler). For instance, lazy types created by the UnPickler are completed
+ * at the phase in which their symbol is created. Observations show that this can even be the
+ * parser phase. Since symbol completion can trigger subtyping, typing etc, your plugin might
+ * need to be active also in phases other than namer and typer.
+ *
+ * Typically, this method can be implemented as
+ *
+ * global.phase.id < global.currentRun.picklerPhase.id
+ */
+ def isActive(): Boolean = true
+
+ /**
+ * Typechecks the right-hand side of a macro definition (which typically features
+ * a mere reference to a macro implementation).
+ *
+ * Default implementation provided in `self.standardTypedMacroBody` makes sure that the rhs
+ * resolves to a reference to a method in either a static object or a macro bundle,
+ * verifies that the referred method is compatible with the macro def and upon success
+ * attaches a macro impl binding to the macro def's symbol.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = None
+
+ /**
+ * Expands an application of a def macro (i.e. of a symbol that has the MACRO flag set),
+ * possibly using the current typer mode and the provided prototype.
+ *
+ * Default implementation provided in `self.standardMacroExpand` figures out whether the `expandee`
+ * needs to be expanded right away or its expansion has to be delayed until all undetermined
+ * parameters are inferred, then loads the macro implementation using `self.pluginsMacroRuntime`,
+ * prepares the invocation arguments for the macro implementation using `self.pluginsMacroArgs`,
+ * and finally calls into the macro implementation. After the call returns, it typechecks
+ * the expansion and performs some bookkeeping.
+ *
+ * This method is typically implemented if your plugin requires significant changes to the macro engine.
+ * If you only need to customize the macro context, consider implementing `pluginsMacroArgs`.
+ * If you only need to customize how macro implementation are invoked, consider going for `pluginsMacroRuntime`.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Option[Tree] = None
+
+ /**
+ * Computes the arguments that need to be passed to the macro impl corresponding to a particular expandee.
+ *
+ * Default implementation provided in `self.standardMacroArgs` instantiates a `scala.reflect.macros.contexts.Context`,
+ * gathers type and value arguments of the macro application and throws them together into `MacroArgs`.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsMacroArgs(typer: Typer, expandee: Tree): Option[MacroArgs] = None
+
+ /**
+ * Summons a function that encapsulates macro implementation invocations for a particular expandee.
+ *
+ * Default implementation provided in `self.standardMacroRuntime` returns a function that
+ * loads the macro implementation binding from the macro definition symbol,
+ * then uses either Java or Scala reflection to acquire the method that corresponds to the impl,
+ * and then reflectively calls into that method.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsMacroRuntime(expandee: Tree): Option[MacroRuntime] = None
+
+ /**
+ * Creates a symbol for the given tree in lexical context encapsulated by the given namer.
+ *
+ * Default implementation provided in `namer.standardEnterSym` handles MemberDef's and Imports,
+ * doing nothing for other trees (DocDef's are seen through and rewrapped). Typical implementation
+ * of `enterSym` for a particular tree flavor creates a corresponding symbol, assigns it to the tree,
+ * enters the symbol into scope and then might even perform some code generation.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsEnterSym(namer: Namer, tree: Tree): Boolean = false
+
+ /**
+ * Makes sure that for the given class definition, there exists a companion object definition.
+ *
+ * Default implementation provided in `namer.standardEnsureCompanionObject` looks up a companion symbol for the class definition
+ * and then checks whether the resulting symbol exists or not. If it exists, then nothing else is done.
+ * If not, a synthetic object definition is created using the provided factory, which is then entered into namer's scope.
+ *
+ * $nonCumulativeReturnValueDoc.
+ */
+ def pluginsEnsureCompanionObject(namer: Namer, cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Option[Symbol] = None
+
+ /**
+ * Prepares a list of statements for being typechecked by performing domain-specific type-agnostic code synthesis.
+ *
+ * Trees passed into this method are going to be named, but not typed.
+ * In particular, you can rely on the compiler having called `enterSym` on every stat prior to passing calling this method.
+ *
+ * Default implementation does nothing. Current approaches to code syntheses (generation of underlying fields
+ * for getters/setters, creation of companion objects for case classes, etc) are too disparate and ad-hoc
+ * to be treated uniformly, so I'm leaving this for future work.
+ */
+ def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = stats
+ }
+
/** A list of registered analyzer plugins */
@@ -167,59 +277,158 @@ trait AnalyzerPlugins { self: Analyzer =>
analyzerPlugins = plugin :: analyzerPlugins
}
+ private abstract class CumulativeOp[T] {
+ def default: T
+ def accumulate: (T, AnalyzerPlugin) => T
+ }
+
+ private def invoke[T](op: CumulativeOp[T]): T = {
+ if (analyzerPlugins.isEmpty) op.default
+ else analyzerPlugins.foldLeft(op.default)((current, plugin) =>
+ if (!plugin.isActive()) current else op.accumulate(current, plugin))
+ }
/** @see AnalyzerPlugin.pluginsPt */
def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Mode): Type =
+ // performance opt
if (analyzerPlugins.isEmpty) pt
- else analyzerPlugins.foldLeft(pt)((pt, plugin) =>
- if (!plugin.isActive()) pt else plugin.pluginsPt(pt, typer, tree, mode))
+ else invoke(new CumulativeOp[Type] {
+ def default = pt
+ def accumulate = (pt, p) => p.pluginsPt(pt, typer, tree, mode)
+ })
/** @see AnalyzerPlugin.pluginsTyped */
- def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = {
- // support deprecated methods in annotation checkers
- val annotCheckersTpe = addAnnotations(tree, tpe)
- if (analyzerPlugins.isEmpty) annotCheckersTpe
- else analyzerPlugins.foldLeft(annotCheckersTpe)((tpe, plugin) =>
- if (!plugin.isActive()) tpe else plugin.pluginsTyped(tpe, typer, tree, mode, pt))
- }
+ def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type =
+ // performance opt
+ if (analyzerPlugins.isEmpty) addAnnotations(tree, tpe)
+ else invoke(new CumulativeOp[Type] {
+ // support deprecated methods in annotation checkers
+ def default = addAnnotations(tree, tpe)
+ def accumulate = (tpe, p) => p.pluginsTyped(tpe, typer, tree, mode, pt)
+ })
/** @see AnalyzerPlugin.pluginsTypeSig */
- def pluginsTypeSig(tpe: Type, typer: Typer, defTree: Tree, pt: Type): Type =
- if (analyzerPlugins.isEmpty) tpe
- else analyzerPlugins.foldLeft(tpe)((tpe, plugin) =>
- if (!plugin.isActive()) tpe else plugin.pluginsTypeSig(tpe, typer, defTree, pt))
+ def pluginsTypeSig(tpe: Type, typer: Typer, defTree: Tree, pt: Type): Type = invoke(new CumulativeOp[Type] {
+ def default = tpe
+ def accumulate = (tpe, p) => p.pluginsTypeSig(tpe, typer, defTree, pt)
+ })
/** @see AnalyzerPlugin.pluginsTypeSigAccessor */
- def pluginsTypeSigAccessor(tpe: Type, typer: Typer, tree: ValDef, sym: Symbol): Type =
- if (analyzerPlugins.isEmpty) tpe
- else analyzerPlugins.foldLeft(tpe)((tpe, plugin) =>
- if (!plugin.isActive()) tpe else plugin.pluginsTypeSigAccessor(tpe, typer, tree, sym))
+ def pluginsTypeSigAccessor(tpe: Type, typer: Typer, tree: ValDef, sym: Symbol): Type = invoke(new CumulativeOp[Type] {
+ def default = tpe
+ def accumulate = (tpe, p) => p.pluginsTypeSigAccessor(tpe, typer, tree, sym)
+ })
/** @see AnalyzerPlugin.canAdaptAnnotations */
- def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = {
+ def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = invoke(new CumulativeOp[Boolean] {
// support deprecated methods in annotation checkers
- val annotCheckersExists = global.canAdaptAnnotations(tree, mode, pt)
- annotCheckersExists || {
- if (analyzerPlugins.isEmpty) false
- else analyzerPlugins.exists(plugin =>
- plugin.isActive() && plugin.canAdaptAnnotations(tree, typer, mode, pt))
- }
- }
+ def default = global.canAdaptAnnotations(tree, mode, pt)
+ def accumulate = (curr, p) => curr || p.canAdaptAnnotations(tree, typer, mode, pt)
+ })
/** @see AnalyzerPlugin.adaptAnnotations */
- def adaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Tree = {
+ def adaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Tree = invoke(new CumulativeOp[Tree] {
// support deprecated methods in annotation checkers
- val annotCheckersTree = global.adaptAnnotations(tree, mode, pt)
- if (analyzerPlugins.isEmpty) annotCheckersTree
- else analyzerPlugins.foldLeft(annotCheckersTree)((tree, plugin) =>
- if (!plugin.isActive()) tree else plugin.adaptAnnotations(tree, typer, mode, pt))
- }
+ def default = global.adaptAnnotations(tree, mode, pt)
+ def accumulate = (tree, p) => p.adaptAnnotations(tree, typer, mode, pt)
+ })
/** @see AnalyzerPlugin.pluginsTypedReturn */
- def pluginsTypedReturn(tpe: Type, typer: Typer, tree: Return, pt: Type): Type = {
- val annotCheckersType = adaptTypeOfReturn(tree.expr, pt, tpe)
- if (analyzerPlugins.isEmpty) annotCheckersType
- else analyzerPlugins.foldLeft(annotCheckersType)((tpe, plugin) =>
- if (!plugin.isActive()) tpe else plugin.pluginsTypedReturn(tpe, typer, tree, pt))
+ def pluginsTypedReturn(tpe: Type, typer: Typer, tree: Return, pt: Type): Type = invoke(new CumulativeOp[Type] {
+ def default = adaptTypeOfReturn(tree.expr, pt, tpe)
+ def accumulate = (tpe, p) => p.pluginsTypedReturn(tpe, typer, tree, pt)
+ })
+
+ /** A list of registered macro plugins */
+ private var macroPlugins: List[MacroPlugin] = Nil
+
+ /** Registers a new macro plugin */
+ def addMacroPlugin(plugin: MacroPlugin) {
+ if (!macroPlugins.contains(plugin))
+ macroPlugins = plugin :: macroPlugins
+ }
+
+ private abstract class NonCumulativeOp[T] {
+ def position: Position
+ def description: String
+ def default: T
+ def custom(plugin: MacroPlugin): Option[T]
+ }
+
+ private def invoke[T](op: NonCumulativeOp[T]): T = {
+ if (macroPlugins.isEmpty) op.default
+ else {
+ val results = macroPlugins.filter(_.isActive()).map(plugin => (plugin, op.custom(plugin)))
+ results.flatMap { case (p, Some(result)) => Some((p, result)); case _ => None } match {
+ case (p1, _) :: (p2, _) :: _ => typer.context.error(op.position, s"both $p1 and $p2 want to ${op.description}"); op.default
+ case (_, custom) :: Nil => custom
+ case Nil => op.default
+ }
+ }
+ }
+
+ /** @see MacroPlugin.pluginsTypedMacroBody */
+ def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Tree = invoke(new NonCumulativeOp[Tree] {
+ def position = ddef.pos
+ def description = "typecheck this macro definition"
+ def default = standardTypedMacroBody(typer, ddef)
+ def custom(plugin: MacroPlugin) = plugin.pluginsTypedMacroBody(typer, ddef)
+ })
+
+ /** @see MacroPlugin.pluginsMacroExpand */
+ def pluginsMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = invoke(new NonCumulativeOp[Tree] {
+ def position = expandee.pos
+ def description = "expand this macro application"
+ def default = standardMacroExpand(typer, expandee, mode, pt)
+ def custom(plugin: MacroPlugin) = plugin.pluginsMacroExpand(typer, expandee, mode, pt)
+ })
+
+ /** @see MacroPlugin.pluginsMacroArgs */
+ def pluginsMacroArgs(typer: Typer, expandee: Tree): MacroArgs = invoke(new NonCumulativeOp[MacroArgs] {
+ def position = expandee.pos
+ def description = "compute macro arguments for this macro application"
+ def default = standardMacroArgs(typer, expandee)
+ def custom(plugin: MacroPlugin) = plugin.pluginsMacroArgs(typer, expandee)
+ })
+
+ /** @see MacroPlugin.pluginsMacroRuntime */
+ def pluginsMacroRuntime(expandee: Tree): MacroRuntime = invoke(new NonCumulativeOp[MacroRuntime] {
+ def position = expandee.pos
+ def description = "compute macro runtime for this macro application"
+ def default = standardMacroRuntime(expandee)
+ def custom(plugin: MacroPlugin) = plugin.pluginsMacroRuntime(expandee)
+ })
+
+ /** @see MacroPlugin.pluginsEnterSym */
+ def pluginsEnterSym(namer: Namer, tree: Tree): Context =
+ if (macroPlugins.isEmpty) namer.standardEnterSym(tree)
+ else invoke(new NonCumulativeOp[Context] {
+ def position = tree.pos
+ def description = "enter a symbol for this tree"
+ def default = namer.standardEnterSym(tree)
+ def custom(plugin: MacroPlugin) = {
+ val hasExistingSym = tree.symbol != NoSymbol
+ val result = plugin.pluginsEnterSym(namer, tree)
+ if (result && hasExistingSym) Some(namer.context)
+ else if (result && tree.isInstanceOf[Import]) Some(namer.context.make(tree))
+ else if (result) Some(namer.context)
+ else None
+ }
+ })
+
+ /** @see MacroPlugin.pluginsEnsureCompanionObject */
+ def pluginsEnsureCompanionObject(namer: Namer, cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Symbol = invoke(new NonCumulativeOp[Symbol] {
+ def position = cdef.pos
+ def description = "enter a companion symbol for this tree"
+ def default = namer.standardEnsureCompanionObject(cdef, creator)
+ def custom(plugin: MacroPlugin) = plugin.pluginsEnsureCompanionObject(namer, cdef, creator)
+ })
+
+ /** @see MacroPlugin.pluginsEnterStats */
+ def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = {
+ // performance opt
+ if (macroPlugins.isEmpty) stats
+ else macroPlugins.foldLeft(stats)((current, plugin) =>
+ if (!plugin.isActive()) current else plugin.pluginsEnterStats(typer, stats))
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 719d04a7f9..4d0eda2377 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -625,8 +625,7 @@ trait ContextErrors {
setError(tree)
}
- def CaseClassConstructorError(tree: Tree) = {
- val baseMessage = tree.symbol + " is not a case class constructor, nor does it have an unapply/unapplySeq method"
+ def CaseClassConstructorError(tree: Tree, baseMessage: String) = {
val addendum = directUnapplyMember(tree.symbol.info) match {
case sym if hasMultipleNonImplicitParamLists(sym) => s"\nNote: ${sym.defString} exists in ${tree.symbol}, but it cannot be used as an extractor due to its second non-implicit parameter list"
case _ => ""
@@ -726,8 +725,9 @@ trait ContextErrors {
NormalTypeError(expandee, "too many argument lists for " + fun)
}
- def MacroInvalidExpansionError(expandee: Tree, role: String, allowedExpansions: String) = {
- issueNormalTypeError(expandee, s"macro in $role role can only expand into $allowedExpansions")
+ def MacroIncompatibleEngineError(macroEngine: String) = {
+ val message = s"macro cannot be expanded, because it was compiled by an incompatible macro engine $macroEngine"
+ issueNormalTypeError(lastTreeToTyper, message)
}
case object MacroExpansionException extends Exception with scala.util.control.ControlThrowable
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index fdec1edcc0..19fba639e3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1145,7 +1145,7 @@ trait Implicits {
gen.mkAttributedThis(thisSym)
case _ =>
// if `pre` is not a PDT, e.g. if someone wrote
- // implicitly[scala.reflect.macros.BlackboxContext#TypeTag[Int]]
+ // implicitly[scala.reflect.macros.blackbox.Context#TypeTag[Int]]
// then we need to fail, because we don't know the prefix to use during type reification
// upd. we also need to fail silently, because this is a very common situation
// e.g. quite often we're searching for BaseUniverse#TypeTag, e.g. for a type tag in any universe
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 0d46a96b81..cf82d6baac 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -29,7 +29,7 @@ import Fingerprint._
* Then fooBar needs to point to a static method of the following form:
*
* def fooBar[T: c.WeakTypeTag] // type tag annotation is optional
- * (c: scala.reflect.macros.BlackboxContext)
+ * (c: scala.reflect.macros.blackbox.Context)
* (xs: c.Expr[List[T]])
* : c.Expr[T] = {
* ...
@@ -67,7 +67,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
*
* This solution is very simple, but unfortunately it's also lacking. If we use it, then
* signatures of macro defs become transitively dependent on scala-reflect.jar
- * (because they refer to macro impls, and macro impls refer to scala.reflect.macros.BlackboxContext/WhiteboxContext defined in scala-reflect.jar).
+ * (because they refer to macro impls, and macro impls refer to *box.Context defined in scala-reflect.jar).
* More details can be found in comments to https://issues.scala-lang.org/browse/SI-5940.
*
* Therefore we have to avoid putting macro impls into binding pickles and come up with our own serialization format.
@@ -81,9 +81,9 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* and various accounting information necessary when composing an argument list for the reflective invocation.
*/
case class MacroImplBinding(
- // Is this macro impl a bundle (a trait extending BlackboxMacro or WhiteboxMacro) or a vanilla def?
+ // Is this macro impl a bundle (a trait extending *box.Macro) or a vanilla def?
val isBundle: Boolean,
- // Is this macro impl blackbox (i.e. having BlackboxContext in its signature)?
+ // Is this macro impl blackbox (i.e. having blackbox.Context in its signature)?
val isBlackbox: Boolean,
// Java class name of the class that contains the macro implementation
// is used to load the corresponding object with Java reflection
@@ -97,8 +97,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
// * c.Expr[T] => LiftedTyped
// * c.Tree => LiftedUntyped
// * c.WeakTypeTag[T] => Tagged(index of the type parameter corresponding to that type tag)
- // * everything else (e.g. scala.reflect.macros.BlackboxContext/WhiteboxContext) => Other
- // f.ex. for: def impl[T: WeakTypeTag, U, V: WeakTypeTag](c: BlackboxContext)(x: c.Expr[T], y: c.Tree): (U, V) = ???
+ // * everything else (e.g. *box.Context) => Other
+ // f.ex. for: def impl[T: WeakTypeTag, U, V: WeakTypeTag](c: blackbox.Context)(x: c.Expr[T], y: c.Tree): (U, V) = ???
// `signature` will be equal to List(List(Other), List(LiftedTyped, LiftedUntyped), List(Tagged(0), Tagged(2)))
signature: List[List[Fingerprint]],
// type arguments part of a macro impl ref (the right-hand side of a macro definition)
@@ -116,23 +116,22 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* with synthetic content that carries the payload described in `MacroImplBinding`.
*
* For example, for a pair of macro definition and macro implementation:
- * def impl(c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] = ???
+ * def impl(c: scala.reflect.macros.blackbox.Context): c.Expr[Unit] = ???
* def foo: Unit = macro impl
*
* We will have the following annotation added on the macro definition `foo`:
*
* @scala.reflect.macros.internal.macroImpl(
* `macro`(
+ * "macroEngine" = <current macro engine>,
* "isBundle" = false,
* "isBlackbox" = true,
* "signature" = List(Other),
* "methodName" = "impl",
- * "versionFormat" = <current version format>,
* "className" = "Macros$"))
*/
+ def macroEngine = "v7.0 (implemented in Scala 2.11.0-M8)"
object MacroImplBinding {
- val versionFormat = 6.0
-
def pickleAtom(obj: Any): Tree =
obj match {
case list: List[_] => Apply(Ident(ListModule), list map pickleAtom)
@@ -183,12 +182,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
val payload = List[(String, Any)](
- "versionFormat" -> versionFormat,
- "isBundle" -> isBundle,
- "isBlackbox" -> isBlackbox,
- "className" -> className,
- "methodName" -> macroImpl.name.toString,
- "signature" -> signature
+ "macroEngine" -> macroEngine,
+ "isBundle" -> isBundle,
+ "isBlackbox" -> isBlackbox,
+ "className" -> className,
+ "methodName" -> macroImpl.name.toString,
+ "signature" -> signature
)
// the shape of the nucleus is chosen arbitrarily. it doesn't carry any payload.
@@ -237,8 +236,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
raw.asInstanceOf[T]
}
- val pickleVersionFormat = unpickle("versionFormat", classOf[Double])
- if (versionFormat != pickleVersionFormat) fail(s"expected version format $versionFormat, actual $pickleVersionFormat")
+ val macroEngine = unpickle("macroEngine", classOf[String])
+ if (self.macroEngine != macroEngine) typer.TyperErrorGen.MacroIncompatibleEngineError(macroEngine)
val isBundle = unpickle("isBundle", classOf[Boolean])
val isBlackbox = unpickle("isBlackbox", classOf[Boolean])
@@ -315,7 +314,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* @return Macro impl reference for the given macro definition if everything is okay.
* EmptyTree if an error occurs.
*/
- def typedMacroBody(typer: Typer, macroDdef: DefDef): Tree = {
+ def typedMacroBody(typer: Typer, macroDdef: DefDef): Tree = pluginsTypedMacroBody(typer, macroDdef)
+
+ /** Default implementation of `typedMacroBody`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsTypedMacroBody for more details)
+ */
+ def standardTypedMacroBody(typer: Typer, macroDdef: DefDef): Tree = {
val macroDef = macroDdef.symbol
assert(macroDef.isMacro, macroDdef)
@@ -350,7 +354,6 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
val universe: self.global.type = self.global
val callsiteTyper: universe.analyzer.Typer = typer.asInstanceOf[global.analyzer.Typer]
val expandee = universe.analyzer.macroExpanderAttachment(expandeeTree).original orElse duplicateAndKeepPositions(expandeeTree)
- val macroRole = universe.analyzer.macroExpanderAttachment(expandeeTree).role
} with UnaffiliatedMacroContext {
val prefix = Expr[Nothing](prefixTree)(TypeTag.Nothing)
override def toString = "MacroContext(%s@%s +%d)".format(expandee.symbol.name, expandee.pos, enclosingMacros.length - 1 /* exclude myself */)
@@ -360,8 +363,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
/** Calculate the arguments to pass to a macro implementation when expanding the provided tree.
*/
case class MacroArgs(c: MacroContext, others: List[Any])
+ def macroArgs(typer: Typer, expandee: Tree): MacroArgs = pluginsMacroArgs(typer, expandee)
- private def macroArgs(typer: Typer, expandee: Tree): MacroArgs = {
+ /** Default implementation of `macroArgs`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsMacroArgs for more details)
+ */
+ def standardMacroArgs(typer: Typer, expandee: Tree): MacroArgs = {
val macroDef = expandee.symbol
val paramss = macroDef.paramss
val treeInfo.Applied(core, targs, argss) = expandee
@@ -471,20 +478,14 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
/** Keeps track of macros in-flight.
- * See more informations in comments to `openMacros` in `scala.reflect.macros.WhiteboxContext`.
+ * See more informations in comments to `openMacros` in `scala.reflect.macros.whitebox.Context`.
*/
- private var _openMacros = List[MacroContext]()
+ var _openMacros = List[MacroContext]()
def openMacros = _openMacros
- private def pushMacroContext(c: MacroContext) = _openMacros ::= c
- private def popMacroContext() = _openMacros = _openMacros.tail
+ def pushMacroContext(c: MacroContext) = _openMacros ::= c
+ def popMacroContext() = _openMacros = _openMacros.tail
def enclosingMacroPosition = openMacros map (_.macroApplication.pos) find (_ ne NoPosition) getOrElse NoPosition
- /** Describes the role that the macro expandee is performing.
- */
- type MacroRole = scala.tools.nsc.typechecker.MacroRole
- final def APPLY_ROLE = MacroRole.Apply
- final def UNAPPLY_ROLE = MacroRole.Unapply
-
/** Performs macro expansion:
*
* ========= Expandable trees =========
@@ -527,30 +528,24 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* the expandee with an error marker set if the expansion has been cancelled due malformed arguments or implementation
* the expandee with an error marker set if there has been an error
*/
- private abstract class MacroExpander[Result: ClassTag](val role: MacroRole, val typer: Typer, val expandee: Tree) {
- def allowExpandee(expandee: Tree): Boolean = true
- def allowExpanded(expanded: Tree): Boolean = true
- def allowedExpansions: String = "anything"
- def allowResult(result: Result): Boolean = true
-
- def onSuccess(expanded: Tree): Result
- def onFallback(expanded: Tree): Result
- def onSuppressed(expandee: Tree): Result = expandee match { case expandee: Result => expandee }
- def onDelayed(expanded: Tree): Result = expanded match { case expanded: Result => expanded }
- def onSkipped(expanded: Tree): Result = expanded match { case expanded: Result => expanded }
- def onFailure(expanded: Tree): Result = { typer.infer.setError(expandee); expandee match { case expandee: Result => expandee } }
-
- def apply(desugared: Tree): Result = {
+ abstract class MacroExpander(val typer: Typer, val expandee: Tree) {
+ def onSuccess(expanded: Tree): Tree
+ def onFallback(expanded: Tree): Tree
+ def onSuppressed(expandee: Tree): Tree = expandee
+ def onDelayed(expanded: Tree): Tree = expanded
+ def onSkipped(expanded: Tree): Tree = expanded
+ def onFailure(expanded: Tree): Tree = { typer.infer.setError(expandee); expandee }
+
+ def apply(desugared: Tree): Tree = {
if (isMacroExpansionSuppressed(desugared)) onSuppressed(expandee)
else expand(desugared)
}
- protected def expand(desugared: Tree): Result = {
+ protected def expand(desugared: Tree): Tree = {
def showDetailed(tree: Tree) = showRaw(tree, printIds = true, printTypes = true)
def summary() = s"expander = $this, expandee = ${showDetailed(expandee)}, desugared = ${if (expandee == desugared) () else showDetailed(desugared)}"
if (macroDebugVerbose) println(s"macroExpand: ${summary()}")
- assert(allowExpandee(expandee), summary())
- linkExpandeeAndDesugared(expandee, desugared, role)
+ linkExpandeeAndDesugared(expandee, desugared)
val start = if (Statistics.canEnable) Statistics.startTimer(macroExpandNanos) else null
if (Statistics.canEnable) Statistics.incCounter(macroExpandCount)
@@ -562,21 +557,17 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
onFailure(typer.infer.setError(expandee))
} else try {
val expanded = {
- val runtime = macroRuntime(expandee.symbol)
+ val runtime = macroRuntime(expandee)
if (runtime != null) macroExpandWithRuntime(typer, expandee, runtime)
else macroExpandWithoutRuntime(typer, expandee)
}
expanded match {
case Success(expanded) =>
- if (allowExpanded(expanded)) {
- // also see http://groups.google.com/group/scala-internals/browse_thread/thread/492560d941b315cc
- val expanded1 = try onSuccess(duplicateAndKeepPositions(expanded)) finally popMacroContext()
- if (!hasMacroExpansionAttachment(expanded1)) linkExpandeeAndExpanded(expandee, expanded1)
- if (allowResult(expanded1)) expanded1 else onFailure(expanded)
- } else {
- typer.TyperErrorGen.MacroInvalidExpansionError(expandee, role.name, allowedExpansions)
- onFailure(expanded)
- }
+ // also see http://groups.google.com/group/scala-internals/browse_thread/thread/492560d941b315cc
+ val expanded1 = try onSuccess(duplicateAndKeepPositions(expanded)) finally popMacroContext()
+ if (!hasMacroExpansionAttachment(expanded1)) linkExpandeeAndExpanded(expandee, expanded1)
+ if (settings.Ymacroexpand.value == settings.MacroExpand.Discard) expandee.setType(expanded1.tpe)
+ else expanded1
case Fallback(fallback) => onFallback(fallback)
case Delayed(delayed) => onDelayed(delayed)
case Skipped(skipped) => onSkipped(skipped)
@@ -592,151 +583,136 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
}
- /** Expands a tree that carries a term, which happens to be a term macro.
- * @see MacroExpander
- */
- private abstract class TermMacroExpander(role: MacroRole, typer: Typer, expandee: Tree, mode: Mode, pt: Type)
- extends MacroExpander[Tree](role, typer, expandee) {
- override def allowedExpansions: String = "term trees"
- override def allowExpandee(expandee: Tree) = expandee.isTerm
- override def onSuccess(expanded: Tree) = typer.typed(expanded, mode, pt)
- override def onFallback(fallback: Tree) = typer.typed(fallback, mode, pt)
- }
-
/** Expands a term macro used in apply role as `M(2)(3)` in `val x = M(2)(3)`.
* @param outerPt Expected type that comes from enclosing context (something that's traditionally called `pt`).
* @param innerPt Expected type that comes from the signature of a macro def, possibly wildcarded to help type inference.
- * @see MacroExpander
*/
- def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, outerPt: Type): Tree = {
- object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, outerPt) {
- lazy val innerPt = {
- val tp = if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe
- if (isBlackbox(expandee)) tp
- else {
- // approximation is necessary for whitebox macros to guide type inference
- // read more in the comments for onDelayed below
- val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
- deriveTypeWithWildcards(undetparams)(tp)
- }
+ class DefMacroExpander(typer: Typer, expandee: Tree, mode: Mode, outerPt: Type)
+ extends MacroExpander(typer, expandee) {
+ lazy val innerPt = {
+ val tp = if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe
+ if (isBlackbox(expandee)) tp
+ else {
+ // approximation is necessary for whitebox macros to guide type inference
+ // read more in the comments for onDelayed below
+ val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
+ deriveTypeWithWildcards(undetparams)(tp)
}
- override def onSuccess(expanded0: Tree) = {
- // prematurely annotate the tree with a macro expansion attachment
- // so that adapt called indirectly by typer.typed knows that it needs to apply the existential fixup
- linkExpandeeAndExpanded(expandee, expanded0)
-
- def typecheck(label: String, tree: Tree, pt: Type): Tree = {
- if (tree.isErrorTyped) tree
- else {
- if (macroDebugVerbose) println(s"$label (against pt = $pt): $tree")
- // `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
- // therefore we need to re-enable the conversions back temporarily
- val result = typer.context.withImplicitsEnabled(typer.typed(tree, mode, pt))
- if (result.isErrorTyped && macroDebugVerbose) println(s"$label has failed: ${typer.context.reportBuffer.errors}")
- result
- }
- }
+ }
+ override def onSuccess(expanded0: Tree) = {
+ // prematurely annotate the tree with a macro expansion attachment
+ // so that adapt called indirectly by typer.typed knows that it needs to apply the existential fixup
+ linkExpandeeAndExpanded(expandee, expanded0)
- if (isBlackbox(expandee)) {
- val expanded1 = atPos(enclosingMacroPosition.makeTransparent)(Typed(expanded0, TypeTree(innerPt)))
- typecheck("blackbox typecheck", expanded1, outerPt)
- } else {
- val expanded1 = expanded0
- val expanded2 = typecheck("whitebox typecheck #1", expanded1, outerPt)
- typecheck("whitebox typecheck #2", expanded2, innerPt)
+ def typecheck(label: String, tree: Tree, pt: Type): Tree = {
+ if (tree.isErrorTyped) tree
+ else {
+ if (macroDebugVerbose) println(s"$label (against pt = $pt): $tree")
+ // `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
+ // therefore we need to re-enable the conversions back temporarily
+ val result = typer.context.withImplicitsEnabled(typer.typed(tree, mode, pt))
+ if (result.isErrorTyped && macroDebugVerbose) println(s"$label has failed: ${typer.context.reportBuffer.errors}")
+ result
}
}
- override def onDelayed(delayed: Tree) = {
- // =========== THE SITUATION ===========
- //
- // If we've been delayed (i.e. bailed out of the expansion because of undetermined type params present in the expandee),
- // then there are two possible situations we're in:
- // 1) We're in POLYmode, when the typer tests the waters wrt type inference
- // (e.g. as in typedArgToPoly in doTypedApply).
- // 2) We're out of POLYmode, which means that the typer is out of tricks to infer our type
- // (e.g. if we're an argument to a function call, then this means that no previous argument lists
- // can determine our type variables for us).
- //
- // Situation #1 is okay for us, since there's no pressure. In POLYmode we're just verifying that
- // there's nothing outrageously wrong with our undetermined type params (from what I understand!).
- //
- // Situation #2 requires measures to be taken. If we're in it, then noone's going to help us infer
- // the undetermined type params. Therefore we need to do something ourselves or otherwise this
- // expandee will forever remaing not expanded (see SI-5692). A traditional way out of this conundrum
- // is to call `instantiate` and let the inferencer try to find the way out. It works for simple cases,
- // but sometimes, if the inferencer lacks information, it will be forced to approximate.
- //
- // =========== THE PROBLEM ===========
- //
- // Consider the following example (thanks, Miles!):
- //
- // Iso represents an isomorphism between two datatypes:
- // 1) An arbitrary one (e.g. a random case class)
- // 2) A uniform representation for all datatypes (e.g. an HList)
- //
- // trait Iso[T, U] {
- // def to(t : T) : U
- // def from(u : U) : T
- // }
- // implicit def materializeIso[T, U]: Iso[T, U] = macro ???
- //
- // case class Foo(i: Int, s: String, b: Boolean)
- // def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
- // foo(Foo(23, "foo", true))
- //
- // In the snippet above, even though we know that there's a fundep going from T to U
- // (in a sense that a datatype's uniform representation is unambiguously determined by the datatype,
- // e.g. for Foo it will be Int :: String :: Boolean :: HNil), there's no way to convey this information
- // to the typechecker. Therefore the typechecker will infer Nothing for L, which is hardly what we want.
- //
- // =========== THE SOLUTION (ENABLED ONLY FOR WHITEBOX MACROS) ===========
- //
- // To give materializers a chance to say their word before vanilla inference kicks in,
- // we infer as much as possible (e.g. in the example above even though L is hopeless, C still can be inferred to Foo)
- // and then trigger macro expansion with the undetermined type parameters still there.
- // Thanks to that the materializer can take a look at what's going on and react accordingly.
- val shouldInstantiate = typer.context.undetparams.nonEmpty && !mode.inPolyMode
- if (shouldInstantiate) {
- if (isBlackbox(expandee)) typer.instantiatePossiblyExpectingUnit(delayed, mode, outerPt)
- else {
- forced += delayed
- typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), outerPt, keepNothings = false)
- macroExpandApply(typer, delayed, mode, outerPt)
- }
- } else delayed
+
+ if (isBlackbox(expandee)) {
+ val expanded1 = atPos(enclosingMacroPosition.makeTransparent)(Typed(expanded0, TypeTree(innerPt)))
+ typecheck("blackbox typecheck", expanded1, outerPt)
+ } else {
+ val expanded1 = expanded0
+ val expanded2 = typecheck("whitebox typecheck #1", expanded1, outerPt)
+ typecheck("whitebox typecheck #2", expanded2, innerPt)
}
}
- expander(expandee)
+ override def onDelayed(delayed: Tree) = {
+ // =========== THE SITUATION ===========
+ //
+ // If we've been delayed (i.e. bailed out of the expansion because of undetermined type params present in the expandee),
+ // then there are two possible situations we're in:
+ // 1) We're in POLYmode, when the typer tests the waters wrt type inference
+ // (e.g. as in typedArgToPoly in doTypedApply).
+ // 2) We're out of POLYmode, which means that the typer is out of tricks to infer our type
+ // (e.g. if we're an argument to a function call, then this means that no previous argument lists
+ // can determine our type variables for us).
+ //
+ // Situation #1 is okay for us, since there's no pressure. In POLYmode we're just verifying that
+ // there's nothing outrageously wrong with our undetermined type params (from what I understand!).
+ //
+ // Situation #2 requires measures to be taken. If we're in it, then noone's going to help us infer
+ // the undetermined type params. Therefore we need to do something ourselves or otherwise this
+ // expandee will forever remaing not expanded (see SI-5692). A traditional way out of this conundrum
+ // is to call `instantiate` and let the inferencer try to find the way out. It works for simple cases,
+ // but sometimes, if the inferencer lacks information, it will be forced to approximate.
+ //
+ // =========== THE PROBLEM ===========
+ //
+ // Consider the following example (thanks, Miles!):
+ //
+ // Iso represents an isomorphism between two datatypes:
+ // 1) An arbitrary one (e.g. a random case class)
+ // 2) A uniform representation for all datatypes (e.g. an HList)
+ //
+ // trait Iso[T, U] {
+ // def to(t : T) : U
+ // def from(u : U) : T
+ // }
+ // implicit def materializeIso[T, U]: Iso[T, U] = macro ???
+ //
+ // case class Foo(i: Int, s: String, b: Boolean)
+ // def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
+ // foo(Foo(23, "foo", true))
+ //
+ // In the snippet above, even though we know that there's a fundep going from T to U
+ // (in a sense that a datatype's uniform representation is unambiguously determined by the datatype,
+ // e.g. for Foo it will be Int :: String :: Boolean :: HNil), there's no way to convey this information
+ // to the typechecker. Therefore the typechecker will infer Nothing for L, which is hardly what we want.
+ //
+ // =========== THE SOLUTION (ENABLED ONLY FOR WHITEBOX MACROS) ===========
+ //
+ // To give materializers a chance to say their word before vanilla inference kicks in,
+ // we infer as much as possible (e.g. in the example above even though L is hopeless, C still can be inferred to Foo)
+ // and then trigger macro expansion with the undetermined type parameters still there.
+ // Thanks to that the materializer can take a look at what's going on and react accordingly.
+ val shouldInstantiate = typer.context.undetparams.nonEmpty && !mode.inPolyMode
+ if (shouldInstantiate) {
+ if (isBlackbox(expandee)) typer.instantiatePossiblyExpectingUnit(delayed, mode, outerPt)
+ else {
+ forced += delayed
+ typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), outerPt, keepNothings = false)
+ macroExpand(typer, delayed, mode, outerPt)
+ }
+ } else delayed
+ }
+ override def onFallback(fallback: Tree) = typer.typed(fallback, mode, outerPt)
}
- /** Expands a term macro used in unapply role as `u.Quasiquote(StringContext("", "")).q.unapply(x)` in `case q"$x" => ...`.
- * @see MacroExpander
+ /** Expands a term macro used in apply role as `M(2)(3)` in `val x = M(2)(3)`.
+ * @see DefMacroExpander
*/
- def macroExpandUnapply(typer: Typer, original: Tree, fun: Tree, unapply: Symbol, args: List[Tree], mode: Mode, pt: Type) = {
- val expandee = treeCopy.Apply(original, gen.mkAttributedSelect(fun, unapply), args)
- object expander extends TermMacroExpander(UNAPPLY_ROLE, typer, expandee, mode, pt) {
- override def allowedExpansions: String = "unapply trees"
- override def allowExpandee(expandee: Tree) = expandee.isInstanceOf[Apply]
- private def unsupported(what: String) = abort("unapply macros currently don't support " + what)
- override def onFallback(fallback: Tree) = unsupported("fallback")
- override def onDelayed(delayed: Tree) = unsupported("advanced interaction with type inference")
- }
- expander(original)
+ def macroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = pluginsMacroExpand(typer, expandee, mode, pt)
+
+ /** Default implementation of `macroExpand`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsMacroExpand for more details)
+ */
+ def standardMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = {
+ val expander = new DefMacroExpander(typer, expandee, mode, pt)
+ expander(expandee)
}
- private sealed abstract class MacroStatus(val result: Tree)
- private case class Success(expanded: Tree) extends MacroStatus(expanded)
- private case class Fallback(fallback: Tree) extends MacroStatus(fallback) { currentRun.seenMacroExpansionsFallingBack = true }
- private case class Delayed(delayed: Tree) extends MacroStatus(delayed)
- private case class Skipped(skipped: Tree) extends MacroStatus(skipped)
- private case class Failure(failure: Tree) extends MacroStatus(failure)
- private def Delay(expanded: Tree) = Delayed(expanded)
- private def Skip(expanded: Tree) = Skipped(expanded)
+ sealed abstract class MacroStatus(val result: Tree)
+ case class Success(expanded: Tree) extends MacroStatus(expanded)
+ case class Fallback(fallback: Tree) extends MacroStatus(fallback) { currentRun.seenMacroExpansionsFallingBack = true }
+ case class Delayed(delayed: Tree) extends MacroStatus(delayed)
+ case class Skipped(skipped: Tree) extends MacroStatus(skipped)
+ case class Failure(failure: Tree) extends MacroStatus(failure)
+ def Delay(expanded: Tree) = Delayed(expanded)
+ def Skip(expanded: Tree) = Skipped(expanded)
/** Expands a macro when a runtime (i.e. the macro implementation) can be successfully loaded
* Meant for internal use within the macro infrastructure, don't use it elsewhere.
*/
- private def macroExpandWithRuntime(typer: Typer, expandee: Tree, runtime: MacroRuntime): MacroStatus = {
+ def macroExpandWithRuntime(typer: Typer, expandee: Tree, runtime: MacroRuntime): MacroStatus = {
val wasDelayed = isDelayed(expandee)
val undetparams = calculateUndetparams(expandee)
val nowDelayed = !typer.context.macrosEnabled || undetparams.nonEmpty
@@ -767,7 +743,31 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
macroLogLite("" + expanded + "\n" + showRaw(expanded))
val freeSyms = expanded.freeTerms ++ expanded.freeTypes
freeSyms foreach (sym => MacroFreeSymbolError(expandee, sym))
- Success(atPos(enclosingMacroPosition.focus)(expanded))
+ // Macros might have spliced arguments with range positions into non-compliant
+ // locations, notably, under a tree without a range position. Or, they might
+ // splice a tree that `resetAttrs` has assigned NoPosition.
+ //
+ // Here, we just convert all positions in the tree to offset positions, and
+ // convert NoPositions to something sensible.
+ //
+ // Given that the IDE now sees the expandee (by using -Ymacro-expand:discard),
+ // this loss of position fidelity shouldn't cause any real problems.
+ //
+ // Alternatively, we could pursue a way to exclude macro expansions from position
+ // invariant checking, or find a way not to touch expansions that happen to validate.
+ //
+ // This would be useful for cases like:
+ //
+ // macro1 { macro2 { "foo" } }
+ //
+ // to allow `macro1` to see the range position of the "foo".
+ val expandedPos = enclosingMacroPosition.focus
+ def fixPosition(pos: Position) =
+ if (pos == NoPosition) expandedPos else pos.focus
+ expanded.foreach(t => t.pos = fixPosition(t.pos))
+
+ val result = atPos(enclosingMacroPosition.focus)(expanded)
+ Success(result)
}
expanded match {
case expanded: Expr[_] if expandee.symbol.isTermMacro => validateResultingTree(expanded.tree)
@@ -793,7 +793,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
/** Expands a macro when a runtime (i.e. the macro implementation) cannot be loaded
* Meant for internal use within the macro infrastructure, don't use it elsewhere.
*/
- private def macroExpandWithoutRuntime(typer: Typer, expandee: Tree): MacroStatus = {
+ def macroExpandWithoutRuntime(typer: Typer, expandee: Tree): MacroStatus = {
import typer.TyperErrorGen._
val fallbackSym = expandee.symbol.nextOverriddenSymbol orElse MacroImplementationNotFoundError(expandee)
macroLogLite(s"falling back to: $fallbackSym")
@@ -871,7 +871,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
context.implicitsEnabled = typer.context.implicitsEnabled
context.enrichmentEnabled = typer.context.enrichmentEnabled
context.macrosEnabled = typer.context.macrosEnabled
- macroExpandApply(newTyper(context), tree, EXPRmode, WildcardType)
+ macroExpand(newTyper(context), tree, EXPRmode, WildcardType)
case _ =>
tree
})
@@ -902,12 +902,3 @@ object Fingerprint {
val LiftedTyped = new Fingerprint(-2)
val LiftedUntyped = new Fingerprint(-3)
}
-
-class MacroRole private[MacroRole](val name: String) extends AnyVal {
- override def toString = name
-}
-
-object MacroRole {
- val Apply = new MacroRole("apply")
- val Unapply = new MacroRole("unapply")
-}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 86bb99e7fa..27e8698676 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -22,7 +22,7 @@ trait Namers extends MethodSynthesis {
import global._
import definitions._
- private var _lockedCount = 0
+ var _lockedCount = 0
def lockedCount = this._lockedCount
/** Replaces any Idents for which cond is true with fresh TypeTrees().
@@ -107,8 +107,8 @@ trait Namers extends MethodSynthesis {
}
protected def owner = context.owner
- private def contextFile = context.unit.source.file
- private def typeErrorHandler[T](tree: Tree, alt: T): PartialFunction[Throwable, T] = {
+ def contextFile = context.unit.source.file
+ def typeErrorHandler[T](tree: Tree, alt: T): PartialFunction[Throwable, T] = {
case ex: TypeError =>
// H@ need to ensure that we handle only cyclic references
TypeSigError(tree, ex)
@@ -122,10 +122,31 @@ trait Namers extends MethodSynthesis {
|| (vd.mods.isPrivateLocal && !vd.mods.isCaseAccessor)
|| (vd.name startsWith nme.OUTER)
|| (context.unit.isJava)
+ || isEnumConstant(vd)
)
+
def noFinishGetterSetter(vd: ValDef) = (
(vd.mods.isPrivateLocal && !vd.mods.isLazy) // all lazy vals need accessors, even private[this]
- || vd.symbol.isModuleVar)
+ || vd.symbol.isModuleVar
+ || isEnumConstant(vd))
+
+ /** Determines whether this field holds an enum constant.
+ * To qualify, the following conditions must be met:
+ * - The field's class has the ENUM flag set
+ * - The field's class extends java.lang.Enum
+ * - The field has the ENUM flag set
+ * - The field is static
+ * - The field is stable
+ */
+ def isEnumConstant(vd: ValDef) = {
+ val ownerHasEnumFlag =
+ // Necessary to check because scalac puts Java's static members into the companion object
+ // while Scala's enum constants live directly in the class.
+ // We don't check for clazz.superClass == JavaEnumClass, because this causes a illegal
+ // cyclic reference error. See the commit message for details.
+ if (context.unit.isJava) owner.companionClass.hasEnumFlag else owner.hasEnumFlag
+ vd.mods.hasAllFlags(ENUM | STABLE | STATIC) && ownerHasEnumFlag
+ }
def setPrivateWithin[T <: Symbol](tree: Tree, sym: T, mods: Modifiers): T =
if (sym.isPrivateLocal || !mods.hasAccessBoundary) sym
@@ -243,7 +264,12 @@ trait Namers extends MethodSynthesis {
validate(sym2.companionClass)
}
- def enterSym(tree: Tree): Context = {
+ def enterSym(tree: Tree): Context = pluginsEnterSym(this, tree)
+
+ /** Default implementation of `enterSym`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsEnterSym for more details)
+ */
+ def standardEnterSym(tree: Tree): Context = {
def dispatch() = {
var returnContext = this.context
tree match {
@@ -309,7 +335,7 @@ trait Namers extends MethodSynthesis {
* be transferred to the symbol as they are, supply a mask containing
* the flags to keep.
*/
- private def createMemberSymbol(tree: MemberDef, name: Name, mask: Long): Symbol = {
+ def createMemberSymbol(tree: MemberDef, name: Name, mask: Long): Symbol = {
val pos = tree.pos
val isParameter = tree.mods.isParameter
val flags = tree.mods.flags & mask
@@ -327,14 +353,14 @@ trait Namers extends MethodSynthesis {
else owner.newValue(name.toTermName, pos, flags)
}
}
- private def createFieldSymbol(tree: ValDef): TermSymbol =
+ def createFieldSymbol(tree: ValDef): TermSymbol =
owner.newValue(tree.localName, tree.pos, tree.mods.flags & FieldFlags | PrivateLocal)
- private def createImportSymbol(tree: Tree) =
+ def createImportSymbol(tree: Tree) =
NoSymbol.newImport(tree.pos) setInfo completerOf(tree)
/** All PackageClassInfoTypes come from here. */
- private def createPackageSymbol(pos: Position, pid: RefTree): Symbol = {
+ def createPackageSymbol(pos: Position, pid: RefTree): Symbol = {
val pkgOwner = pid match {
case Ident(_) => if (owner.isEmptyPackageClass) rootMirror.RootClass else owner
case Select(qual: RefTree, _) => createPackageSymbol(pos, qual).moduleClass
@@ -393,7 +419,7 @@ trait Namers extends MethodSynthesis {
/** Given a ClassDef or ModuleDef, verifies there isn't a companion which
* has been defined in a separate file.
*/
- private def validateCompanionDefs(tree: ImplDef) {
+ def validateCompanionDefs(tree: ImplDef) {
val sym = tree.symbol orElse { return }
val ctx = if (context.owner.isPackageObjectClass) context.outer else context
val module = if (sym.isModule) sym else ctx.scope lookupModule tree.name
@@ -466,7 +492,13 @@ trait Namers extends MethodSynthesis {
* class definition tree.
* @return the companion object symbol.
*/
- def ensureCompanionObject(cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Symbol = {
+ def ensureCompanionObject(cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Symbol =
+ pluginsEnsureCompanionObject(this, cdef, creator)
+
+ /** Default implementation of `ensureCompanionObject`.
+ * Can be overridden by analyzer plugins (see AnalyzerPlugins.pluginsEnsureCompanionObject for more details)
+ */
+ def standardEnsureCompanionObject(cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Symbol = {
val m = companionSymbolOf(cdef.symbol, context)
// @luc: not sure why "currentRun.compiles(m)" is needed, things breaks
// otherwise. documentation welcome.
@@ -609,11 +641,7 @@ trait Namers extends MethodSynthesis {
else
enterGetterSetter(tree)
- // When java enums are read from bytecode, they are known to have
- // constant types by the jvm flag and assigned accordingly. When
- // they are read from source, the java parser marks them with the
- // STABLE flag, and now we receive that signal.
- if (tree.symbol hasAllFlags STABLE | JAVA)
+ if (isEnumConstant(tree))
tree.symbol setInfo ConstantType(Constant(tree.symbol))
}
@@ -828,9 +856,10 @@ trait Namers extends MethodSynthesis {
* assigns the type to the tpt's node. Returns the type.
*/
private def assignTypeToTree(tree: ValOrDefDef, defnTyper: Typer, pt: Type): Type = {
- val rhsTpe =
- if (tree.symbol.isTermMacro) defnTyper.computeMacroDefType(tree, pt)
- else defnTyper.computeType(tree.rhs, pt)
+ val rhsTpe = tree match {
+ case ddef: DefDef if tree.symbol.isTermMacro => defnTyper.computeMacroDefType(ddef, pt)
+ case _ => defnTyper.computeType(tree.rhs, pt)
+ }
val defnTpe = widenIfNecessary(tree.symbol, rhsTpe, pt)
tree.tpt defineType defnTpe setPos tree.pos.focus
@@ -1620,7 +1649,7 @@ trait Namers extends MethodSynthesis {
val tree: Tree
}
- def mkTypeCompleter(t: Tree)(c: Symbol => Unit) = new LockingTypeCompleter {
+ def mkTypeCompleter(t: Tree)(c: Symbol => Unit) = new LockingTypeCompleter with FlagAgnosticCompleter {
val tree = t
def completeImpl(sym: Symbol) = c(sym)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index 069d6d5fb2..41c656f8ce 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -78,26 +78,34 @@ trait PatternTypers {
// Do some ad-hoc overloading resolution and update the tree's symbol and type
// do not update the symbol if the tree's symbol's type does not define an unapply member
// (e.g. since it's some method that returns an object with an unapply member)
- val fun = inPlaceAdHocOverloadingResolution(fun0)(hasUnapplyMember)
- def caseClass = fun.tpe.typeSymbol.linkedClassOfClass
+ val fun = inPlaceAdHocOverloadingResolution(fun0)(hasUnapplyMember)
+ val caseClass = fun.tpe.typeSymbol.linkedClassOfClass
+ val member = unapplyMember(fun.tpe)
+ def resultType = (fun.tpe memberType member).finalResultType
+ def isEmptyType = resultOfMatchingMethod(resultType, nme.isEmpty)()
+ def isOkay = (
+ resultType.isErroneous
+ || (resultType <:< BooleanTpe)
+ || (isEmptyType <:< BooleanTpe)
+ || member.isMacro
+ || member.isOverloaded // the whole overloading situation is over the rails
+ )
// Dueling test cases: pos/overloaded-unapply.scala, run/case-class-23.scala, pos/t5022.scala
// A case class with 23+ params has no unapply method.
- // A case class constructor be overloaded with unapply methods in the companion.
- if (caseClass.isCase && !unapplyMember(fun.tpe).isOverloaded)
+ // A case class constructor may be overloaded with unapply methods in the companion.
+ if (caseClass.isCase && !member.isOverloaded)
logResult(s"convertToCaseConstructor($fun, $caseClass, pt=$pt)")(convertToCaseConstructor(fun, caseClass, pt))
- else if (hasUnapplyMember(fun))
+ else if (!reallyExists(member))
+ CaseClassConstructorError(fun, s"${fun.symbol} is not a case class, nor does it have an unapply/unapplySeq member")
+ else if (isOkay)
fun
+ else if (isEmptyType == NoType)
+ CaseClassConstructorError(fun, s"an unapply result must have a member `def isEmpty: Boolean")
else
- CaseClassConstructorError(fun)
+ CaseClassConstructorError(fun, s"an unapply result must have a member `def isEmpty: Boolean (found: def isEmpty: $isEmptyType)")
}
- def expectedPatternTypes(fun: Tree, args: List[Tree]): List[Type] =
- newExtractorShape(fun, args).expectedPatternTypes
-
- def typedPatternArgs(fun: Tree, args: List[Tree], mode: Mode): List[Tree] =
- typedArgsForFormals(args, newExtractorShape(fun, args).formals, mode)
-
def typedArgsForFormals(args: List[Tree], formals: List[Type], mode: Mode): List[Tree] = {
def typedArgWithFormal(arg: Tree, pt: Type) = {
val newMode = if (isByNameParamType(pt)) mode.onlySticky else mode.onlySticky | BYVALmode
@@ -158,109 +166,6 @@ trait PatternTypers {
case _ => wrapClassTagUnapply(treeTyped, extractor, tpe)
}
}
-
- def newExtractorShape(fun: Tree, args: List[Tree]): ExtractorShape = ExtractorShape(fun, args)
-
- case class CaseClassInfo(clazz: Symbol, classType: Type) {
- def constructor = clazz.primaryConstructor
- def constructorType = classType.prefix memberType clazz memberType constructor
- def accessors = clazz.caseFieldAccessors
- }
- object NoCaseClassInfo extends CaseClassInfo(NoSymbol, NoType) {
- override def toString = "NoCaseClassInfo"
- }
-
- case class UnapplyMethodInfo(unapply: Symbol, tpe: Type) {
- def name = unapply.name
- def isUnapplySeq = name == nme.unapplySeq
- def unapplyType = tpe memberType method
- def resultType = tpe.finalResultType
- def method = unapplyMember(tpe)
- def paramType = firstParamType(unapplyType)
- def rawGet = if (isBool) UnitTpe else typeOfMemberNamedGetOrSelf(resultType)
- def rawTypes = if (isBool) Nil else typesOfSelectorsOrSelf(rawGet)
- def isBool = resultType =:= BooleanTpe // aka "Tuple0" or "Option[Unit]"
- }
-
- object NoUnapplyMethodInfo extends UnapplyMethodInfo(NoSymbol, NoType) {
- override def toString = "NoUnapplyMethodInfo"
- }
-
- case class ExtractorShape(fun: Tree, args: List[Tree]) {
- def pos = fun.pos
- private def symbol = fun.symbol
- private def tpe = fun.tpe
-
- val ccInfo = tpe.typeSymbol.linkedClassOfClass match {
- case clazz if clazz.isCase => CaseClassInfo(clazz, tpe)
- case _ => NoCaseClassInfo
- }
- val exInfo = UnapplyMethodInfo(symbol, tpe)
- import exInfo.{ rawGet, rawTypes, isUnapplySeq }
-
- override def toString = s"ExtractorShape($fun, $args)"
-
- def unapplyMethod = exInfo.method
- def unapplyType = exInfo.unapplyType
- def unapplyParamType = exInfo.paramType
- def enclClass = symbol.enclClass
-
- // TODO - merge these. The difference between these two methods is that expectedPatternTypes
- // expands the list of types so it is the same length as the number of patterns, whereas formals
- // leaves the varargs type unexpanded.
- def formals = (
- if (isUnapplySeq) productTypes :+ varargsType
- else if (elementArity == 0) productTypes
- else if (isSingle) squishIntoOne()
- else wrongArity(patternFixedArity)
- )
- def expectedPatternTypes = elementArity match {
- case 0 => productTypes
- case _ if elementArity > 0 && isUnapplySeq => productTypes ::: elementTypes
- case _ if productArity > 1 && patternFixedArity == 1 => squishIntoOne()
- case _ => wrongArity(patternFixedArity)
- }
-
- def elementType = elementTypeOfLastSelectorOrSelf(rawGet)
-
- private def hasBogusExtractor = directUnapplyMember(tpe).exists && !unapplyMethod.exists
- private def expectedArity = "" + productArity + ( if (isUnapplySeq) "+" else "")
- private def wrongArityMsg(n: Int) = (
- if (hasBogusExtractor) s"$enclClass does not define a valid extractor method"
- else s"wrong number of patterns for $enclClass offering $rawTypes_s: expected $expectedArity, found $n"
- )
- private def rawTypes_s = rawTypes match {
- case Nil => "()"
- case tp :: Nil => "" + tp
- case tps => tps.mkString("(", ", ", ")")
- }
-
- private def err(msg: String) = { unit.error(pos, msg) ; throw new TypeError(msg) }
- private def wrongArity(n: Int) = err(wrongArityMsg(n))
-
- def squishIntoOne() = {
- if (settings.lint)
- unit.warning(pos, s"$enclClass expects $expectedArity patterns to hold $rawGet but crushing into $productArity-tuple to fit single pattern (SI-6675)")
-
- rawGet :: Nil
- }
- // elementArity is the number of non-sequence patterns minus the
- // the number of non-sequence product elements returned by the extractor.
- // If it is zero, there is a perfect match between those parts, and
- // if there is a wildcard star it will match any sequence.
- // If it is positive, there are more patterns than products,
- // so a sequence will have to fill in the elements. If it is negative,
- // there are more products than patterns, which is a compile time error.
- def elementArity = patternFixedArity - productArity
- def patternFixedArity = treeInfo effectivePatternArity args
- def productArity = productTypes.size
- def isSingle = !isUnapplySeq && (patternFixedArity == 1)
-
- def productTypes = if (isUnapplySeq) rawTypes dropRight 1 else rawTypes
- def elementTypes = List.fill(elementArity)(elementType)
- def varargsType = scalaRepeatedType(elementType)
- }
-
private class VariantToSkolemMap extends TypeMap(trackVariance = true) {
private val skolemBuffer = mutable.ListBuffer[TypeSymbol]()
@@ -365,10 +270,12 @@ trait PatternTypers {
case OverloadedType(_, _) => OverloadedUnapplyError(fun) ; ErrorType
case _ => UnapplyWithSingleArgError(fun) ; ErrorType
}
- val shape = newExtractorShape(fun, args)
- import shape.{ unapplyParamType, unapplyType, unapplyMethod }
+ val unapplyMethod = unapplyMember(fun.tpe)
+ val unapplyType = fun.tpe memberType unapplyMethod
+ val unapplyParamType = firstParamType(unapplyType)
+ def isSeq = unapplyMethod.name == nme.unapplySeq
- def extractor = extractorForUncheckedType(shape.pos, unapplyParamType)
+ def extractor = extractorForUncheckedType(fun.pos, unapplyParamType)
def canRemedy = unapplyParamType match {
case RefinedType(_, decls) if !decls.isEmpty => false
case RefinedType(parents, _) if parents exists isUncheckable => false
@@ -400,7 +307,8 @@ trait PatternTypers {
// the union of the expected type and the inferred type of the argument to unapply
val glbType = glb(ensureFullyDefined(pt) :: unapplyArg.tpe_* :: Nil)
val wrapInTypeTest = canRemedy && !(fun1.symbol.owner isNonBottomSubClass ClassTagClass)
- val args1 = typedPatternArgs(fun1, args, mode)
+ val formals = patmat.alignPatterns(fun1, args).unexpandedFormals
+ val args1 = typedArgsForFormals(args, formals, mode)
val result = UnApply(fun1, args1) setPos tree.pos setType glbType
if (wrapInTypeTest)
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
index 14f47a00fd..995f98cc2c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
@@ -16,7 +16,7 @@ trait StdAttachments {
/** Scratchpad for the macro expander, which is used to store all intermediate data except the details about the runtime.
*/
- case class MacroExpanderAttachment(original: Tree, desugared: Tree, role: MacroRole)
+ case class MacroExpanderAttachment(original: Tree, desugared: Tree)
/** Loads underlying MacroExpanderAttachment from a macro expandee or returns a default value for that attachment.
*/
@@ -24,15 +24,15 @@ trait StdAttachments {
tree.attachments.get[MacroExpanderAttachment] getOrElse {
tree match {
case Apply(fn, _) if tree.isInstanceOf[ApplyToImplicitArgs] => macroExpanderAttachment(fn)
- case _ => MacroExpanderAttachment(tree, EmptyTree, APPLY_ROLE)
+ case _ => MacroExpanderAttachment(tree, EmptyTree)
}
}
/** After macro expansion is completed, links the expandee and the expansion result
* by annotating them both with a `MacroExpansionAttachment`.
*/
- def linkExpandeeAndDesugared(expandee: Tree, desugared: Tree, role: MacroRole): Unit = {
- val metadata = MacroExpanderAttachment(expandee, desugared, role)
+ def linkExpandeeAndDesugared(expandee: Tree, desugared: Tree): Unit = {
+ val metadata = MacroExpanderAttachment(expandee, desugared)
expandee updateAttachment metadata
desugared updateAttachment metadata
}
@@ -95,7 +95,7 @@ trait StdAttachments {
/** Determines whether a tree should not be expanded, because someone has put SuppressMacroExpansionAttachment on it or one of its children.
*/
def isMacroExpansionSuppressed(tree: Tree): Boolean =
- ( settings.Ymacronoexpand.value // SI-6812
+ ( settings.Ymacroexpand.value == settings.MacroExpand.None // SI-6812
|| tree.attachments.get[SuppressMacroExpansionAttachment.type].isDefined
|| (tree match {
// we have to account for the fact that during typechecking an expandee might become wrapped,
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index f0252251f7..9516f94135 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -380,7 +380,7 @@ trait SyntheticMethods extends ast.TreeDSL {
val original = ddef.symbol
val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc =>
newAcc.makePublic
- newAcc resetFlag (ACCESSOR | PARAMACCESSOR)
+ newAcc resetFlag (ACCESSOR | PARAMACCESSOR | OVERRIDE)
ddef.rhs.duplicate
}
// TODO: shouldn't the next line be: `original resetFlag CASEACCESSOR`?
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index dbe85f4f5a..6b5afce993 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1102,7 +1102,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (tree.isType)
adaptType()
else if (mode.typingExprNotFun && treeInfo.isMacroApplication(tree) && !isMacroExpansionSuppressed(tree))
- macroExpandApply(this, tree, mode, pt)
+ macroExpand(this, tree, mode, pt)
else if (mode.typingConstructorPattern)
typedConstructorPattern(tree, pt)
else if (shouldInsertApply(tree))
@@ -1853,12 +1853,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
protected def enterSym(txt: Context, tree: Tree): Context =
- if (txt eq context) namer.enterSym(tree)
- else newNamer(txt).enterSym(tree)
+ if (txt eq context) namer enterSym tree
+ else newNamer(txt) enterSym tree
/** <!-- 2 --> Check that inner classes do not inherit from Annotation
*/
- def typedTemplate(templ: Template, parents1: List[Tree]): Template = {
+ def typedTemplate(templ0: Template, parents1: List[Tree]): Template = {
+ val templ = templ0
+ // please FIXME: uncommenting this line breaks everything
+ // val templ = treeCopy.Template(templ0, templ0.body, templ0.self, templ0.parents)
val clazz = context.owner
clazz.annotations.map(_.completeInfo())
if (templ.symbol == NoSymbol)
@@ -1886,7 +1889,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
)
// the following is necessary for templates generated later
assert(clazz.info.decls != EmptyScope, clazz)
- enterSyms(context.outer.make(templ, clazz, clazz.info.decls), templ.body)
+ val body1 = pluginsEnterStats(this, templ.body)
+ enterSyms(context.outer.make(templ, clazz, clazz.info.decls), body1)
if (!templ.isErrorTyped) // if `parentTypes` has invalidated the template, don't validate it anymore
validateParentClasses(parents1, selfType)
if (clazz.isCase)
@@ -1900,26 +1904,26 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (!phase.erasedTypes && !clazz.info.resultType.isError) // @S: prevent crash for duplicated type members
checkFinitary(clazz.info.resultType.asInstanceOf[ClassInfoType])
- val body = {
- val body =
- if (isPastTyper || reporter.hasErrors) templ.body
- else templ.body flatMap rewrappingWrapperTrees(namer.addDerivedTrees(Typer.this, _))
- val primaryCtor = treeInfo.firstConstructor(body)
+ val body2 = {
+ val body2 =
+ if (isPastTyper || reporter.hasErrors) body1
+ else body1 flatMap rewrappingWrapperTrees(namer.addDerivedTrees(Typer.this, _))
+ val primaryCtor = treeInfo.firstConstructor(body2)
val primaryCtor1 = primaryCtor match {
case DefDef(_, _, _, _, _, Block(earlyVals :+ global.pendingSuperCall, unit)) =>
val argss = superArgs(parents1.head) getOrElse Nil
- val pos = wrappingPos(parents1.head.pos, argss.flatten)
+ val pos = wrappingPos(parents1.head.pos, primaryCtor :: argss.flatten).makeTransparent
val superCall = atPos(pos)(PrimarySuperCall(argss))
deriveDefDef(primaryCtor)(block => Block(earlyVals :+ superCall, unit) setPos pos) setPos pos
case _ => primaryCtor
}
- body mapConserve { case `primaryCtor` => primaryCtor1; case stat => stat }
+ body2 mapConserve { case `primaryCtor` => primaryCtor1; case stat => stat }
}
- val body1 = typedStats(body, templ.symbol)
+ val body3 = typedStats(body2, templ.symbol)
if (clazz.info.firstParent.typeSymbol == AnyValClass)
- validateDerivedValueClass(clazz, body1)
+ validateDerivedValueClass(clazz, body3)
if (clazz.isTrait) {
for (decl <- clazz.info.decls if decl.isTerm && decl.isEarlyInitialized) {
@@ -1927,7 +1931,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
}
- treeCopy.Template(templ, parents1, self1, body1) setType clazz.tpe_*
+ treeCopy.Template(templ, parents1, self1, body3) setType clazz.tpe_*
}
/** Remove definition annotations from modifiers (they have been saved
@@ -2309,10 +2313,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
}
- def typedBlock(block: Block, mode: Mode, pt: Type): Block = {
+ def typedBlock(block0: Block, mode: Mode, pt: Type): Block = {
val syntheticPrivates = new ListBuffer[Symbol]
try {
- namer.enterSyms(block.stats)
+ namer.enterSyms(block0.stats)
+ val block = treeCopy.Block(block0, pluginsEnterStats(this, block0.stats), block0.expr)
for (stat <- block.stats) enterLabelDef(stat)
if (phaseId(currentPeriod) <= currentRun.typerPhase.id) {
@@ -3797,7 +3802,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
protected def typedExistentialTypeTree(tree: ExistentialTypeTree, mode: Mode): Tree = {
for (wc <- tree.whereClauses)
- if (wc.symbol == NoSymbol) { namer.enterSym(wc); wc.symbol setFlag EXISTENTIAL }
+ if (wc.symbol == NoSymbol) { namer enterSym wc; wc.symbol setFlag EXISTENTIAL }
else context.scope enter wc.symbol
val whereClauses1 = typedStats(tree.whereClauses, context.owner)
for (vd @ ValDef(_, _, _, _) <- whereClauses1)
@@ -4948,7 +4953,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val sym: Symbol = tree.symbol
if ((sym ne null) && (sym ne NoSymbol)) sym.initialize
- def typedPackageDef(pdef: PackageDef) = {
+ def typedPackageDef(pdef0: PackageDef) = {
+ val pdef = treeCopy.PackageDef(pdef0, pdef0.pid, pluginsEnterStats(this, pdef0.stats))
val pid1 = typedQualifier(pdef.pid).asInstanceOf[RefTree]
assert(sym.moduleClass ne NoSymbol, sym)
val stats1 = newTyper(context.make(tree, sym.moduleClass, sym.info.decls))
@@ -5494,25 +5500,23 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
tpe
}
- def computeMacroDefType(tree: Tree, pt: Type): Type = {
+ def computeMacroDefType(ddef: DefDef, pt: Type): Type = {
assert(context.owner.isMacro, context.owner)
- assert(tree.symbol.isMacro, tree.symbol)
- assert(tree.isInstanceOf[DefDef], tree.getClass)
- val ddef = tree.asInstanceOf[DefDef]
+ assert(ddef.symbol.isMacro, ddef.symbol)
- val tree1 =
+ val rhs1 =
if (transformed contains ddef.rhs) {
// macro defs are typechecked in `methodSig` (by calling this method) in order to establish their link to macro implementation asap
// if a macro def doesn't have explicitly specified return type, this method will be called again by `assignTypeToTree`
// here we guard against this case
transformed(ddef.rhs)
} else {
- val tree1 = typedMacroBody(this, ddef)
- transformed(ddef.rhs) = tree1
- tree1
+ val rhs1 = typedMacroBody(this, ddef)
+ transformed(ddef.rhs) = rhs1
+ rhs1
}
- val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous)) && tree1 != EmptyTree
+ val isMacroBodyOkay = !ddef.symbol.isErroneous && !(rhs1 exists (_.isErroneous)) && rhs1 != EmptyTree
val shouldInheritMacroImplReturnType = ddef.tpt.isEmpty
if (isMacroBodyOkay && shouldInheritMacroImplReturnType) {
val commonMessage = "macro defs must have explicitly specified return types"
@@ -5524,7 +5528,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val explanation = s"inference of $inferredType from macro impl's c.Expr[$inferredType] is deprecated and is going to stop working in 2.12"
unit.deprecationWarning(ddef.pos, s"$commonMessage ($explanation)")
}
- computeMacroDefTypeFromMacroImplRef(ddef, tree1) match {
+ computeMacroDefTypeFromMacroImplRef(ddef, rhs1) match {
case ErrorType => ErrorType
case NothingTpe => NothingTpe
case NoType => reportFailure(); AnyTpe
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 27f10ff00a..b55a573029 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -88,7 +88,6 @@ trait InteractiveAnalyzer extends Analyzer {
}
}
-
/** The main class of the presentation compiler in an interactive environment such as an IDE
*/
class Global(settings: Settings, _reporter: Reporter, projectName: String = "") extends {
@@ -105,6 +104,9 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
import definitions._
+ if (!settings.Ymacroexpand.isSetByUser)
+ settings.Ymacroexpand.value = settings.MacroExpand.Discard
+
val debugIDE: Boolean = settings.YpresentationDebug.value
val verboseIDE: Boolean = settings.YpresentationVerbose.value
diff --git a/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
index bc490d8d45..343986a45d 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
@@ -94,7 +94,7 @@ private[tests] trait CoreTestDefs
askAllSources(HyperlinkMarker) { pos =>
askTypeAt(pos)(NullReporter)
} { (pos, tree) =>
- if(tree.symbol == compiler.NoSymbol) {
+ if(tree.symbol == compiler.NoSymbol || tree.symbol == null) {
reporter.println("\nNo symbol is associated with tree: "+tree)
}
else {
diff --git a/src/library/rootdoc.txt b/src/library/rootdoc.txt
index 0722d808bf..4795a47efe 100644
--- a/src/library/rootdoc.txt
+++ b/src/library/rootdoc.txt
@@ -2,21 +2,54 @@ This is the documentation for the Scala standard library.
== Package structure ==
-The [[scala]] package contains core types.
-
-[[scala.collection `scala.collection`]] and its subpackages contain a collections framework with higher-order functions for manipulation. Both [[scala.collection.immutable `scala.collection.immutable`]] and [[scala.collection.mutable `scala.collection.mutable`]] data structures are available, with immutable as the default. The [[scala.collection.parallel `scala.collection.parallel`]] collections provide automatic parallel operation.
-
-Other important packages include:
-
- - [[scala.actors `scala.actors`]] - Concurrency framework inspired by Erlang.
- - [[scala.io `scala.io`]] - Input and output.
- - [[scala.math `scala.math`]] - Basic math functions and additional numeric types.
- - [[scala.sys `scala.sys`]] - Interaction with other processes and the operating system.
- - [[scala.util.matching `scala.util.matching`]] - Pattern matching in text using regular expressions.
- - [[scala.util.parsing.combinator `scala.util.parsing.combinator`]] - Composable combinators for parsing.
- - [[scala.xml `scala.xml`]] - XML parsing, manipulation, and serialization.
-
-Many other packages exist. See the complete list on the left.
+The [[scala]] package contains core types like [[scala.Int `Int`]], [[scala.Float `Float`]], [[scala.Array `Array`]]
+or [[scala.Option `Option`]] which are accessible in all Scala compilation units without explicit qualification or
+imports.
+
+Notable packages include:
+
+ - [[scala.collection `scala.collection`]] and its sub-packages contain Scala's collections framework
+ - [[scala.collection.immutable `scala.collection.immutable`]] - Immutable, sequential data-structures such as
+ [[scala.collection.immutable.Vector `Vector`]], [[scala.collection.immutable.List `List`]],
+ [[scala.collection.immutable.Range `Range`]], [[scala.collection.immutable.HashMap `HashMap`]] or
+ [[scala.collection.immutable.HashSet `HasSet`]]
+ - [[scala.collection.mutable `scala.collection.mutable`]] - Mutable, sequential data-structures such as
+ [[scala.collection.mutable.ArrayBuffer `ArrayBuffer`]],
+ [[scala.collection.mutable.StringBuilder `StringBuilder`]],
+ [[scala.collection.mutable.HashMap `HashMap`]] or [[scala.collection.mutable.HashSet `HashSet`]]
+ - [[scala.collection.concurrent `scala.collection.concurrent`]] - Mutable, concurrent data-structures such as
+ [[scala.collection.concurrent.TrieMap `TrieMap`]]
+ - [[scala.collection.parallel.immutable `scala.collection.parallel.immutable`]] - Immutable, parallel
+ data-structures such as [[scala.collection.parallel.immutable.ParVector `ParVector`]],
+ [[scala.collection.parallel.immutable.ParRange `ParRange`]],
+ [[scala.collection.parallel.immutable.ParHashMap `ParHashMap`]] or
+ [[scala.collection.parallel.immutable.ParHashSet `ParHashSet`]]
+ - [[scala.collection.parallel.mutable `scala.collection.parallel.mutable`]] - Mutable, parallel
+ data-structures such as [[scala.collection.parallel.mutable.ParArray `ParArray`]],
+ [[scala.collection.parallel.mutable.ParHashMap `ParHashMap`]],
+ [[scala.collection.parallel.mutable.ParTrieMap `ParTrieMap`]] or
+ [[scala.collection.parallel.mutable.ParHashSet `ParHashSet`]]
+ - [[scala.concurrent `scala.concurrent`]] - Primitives for concurrent programming such as
+ [[scala.concurrent.Future `Futures`]] and [[scala.concurrent.Promise `Promises`]]
+ - [[scala.io `scala.io`]] - Input and output operations
+ - [[scala.math `scala.math`]] - Basic math functions and additional numeric types like
+ [[scala.math.BigInt `BigInt`]] and [[scala.math.BigDecimal `BigDecimal`]]
+ - [[scala.sys `scala.sys`]] - Interaction with other processes and the operating system
+ - [[scala.util.matching `scala.util.matching`]] - [[scala.util.matching.Regex Regular expressions]]
+
+Other packages exist. See the complete list on the left.
+
+Additional parts of the standard library are shipped as separate libraries. These include:
+
+ - [[scala.reflect `scala.reflect`]] - Scala's reflection API (scala-reflect.jar)
+ - [[scala.xml `scala.xml`]] - XML parsing, manipulation, and serialization (scala-xml.jar)
+ - [[scala.swing `scala.swing`]] - A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)
+ - [[scala.util.continuations `scala.util.continuations`]] - Delimited continuations using continuation-passing-style
+ (scala-continuations-library.jar, scala-continuations-plugin.jar)
+ - [[scala.util.parsing `scala.util.parsing`]] - [[scala.util.parsing.combinator Parser combinators]], including an
+ example implementation of a [[scala.util.parsing.json JSON parser]] (scala-parser-combinators.jar)
+ - [[scala.actors `scala.actors`]] - Actor-based concurrency (deprecated and replaced by Akka actors,
+ scala-actors.jar)
== Automatic imports ==
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index 9def6cb054..ff62948413 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -33,7 +33,7 @@ package scala
*
* User-defined value classes which avoid object allocation...
*
- * - must have a single, public `val` parameter that is the underlying runtime representation.
+ * - must have a single `val` parameter that is the underlying runtime representation.
* - can define `def`s, but no `val`s, `var`s, or nested `traits`s, `class`es or `object`s.
* - typically extend no other trait apart from `AnyVal`.
* - cannot be used in type tests or pattern matching.
diff --git a/src/library/scala/App.scala b/src/library/scala/App.scala
index 90a8977e81..ef39ee2134 100644
--- a/src/library/scala/App.scala
+++ b/src/library/scala/App.scala
@@ -28,9 +28,8 @@ import scala.collection.mutable.ListBuffer
* functionality, which means that fields of the object will not have been initialized
* before the main method has been executed.'''''
*
- * It should also be noted that the `main` method will not normally need to be overridden:
- * the purpose is to turn the whole class body into the “main method”. You should only
- * chose to override it if you know what you are doing.
+ * It should also be noted that the `main` method should not be overridden:
+ * the whole class body becomes the “main method”.
*
* @author Martin Odersky
* @version 2.1, 15/02/2011
@@ -61,11 +60,12 @@ trait App extends DelayedInit {
}
/** The main method.
- * This stores all argument so that they can be retrieved with `args`
- * and the executes all initialization code segments in the order they were
- * passed to `delayedInit`
+ * This stores all arguments so that they can be retrieved with `args`
+ * and then executes all initialization code segments in the order in which
+ * they were passed to `delayedInit`.
* @param args the arguments passed to the main method
*/
+ @deprecatedOverriding("main should not be overridden", "2.11.0")
def main(args: Array[String]) = {
this._args = args
for (proc <- initCode) proc()
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 59be0cdfa3..d4b9c17eab 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -11,7 +11,7 @@ package scala
import scala.collection.{ mutable, immutable, generic, SortedSetLike, AbstractSet }
import java.lang.reflect.{ Modifier, Method => JMethod, Field => JField }
import scala.reflect.NameTransformer._
-import java.util.regex.Pattern
+import scala.util.matching.Regex
/** Defines a finite set of values specific to the enumeration. Typically
* these values enumerate all possible forms something can take and provide
@@ -64,7 +64,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
*/
override def toString =
((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
- Pattern.quote(NAME_JOIN_STRING)).last
+ Regex.quote(NAME_JOIN_STRING)).last
/** The mapping from the integer used to identify values to the actual
* values. */
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 27b75c0491..c3bad60072 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -38,8 +38,8 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
* Example:
*
* {{{
- * scala> val x = LinkedList(1, 2, 3, 4, 5)
- * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4, 5)
+ * scala> val x = List(1, 2, 3, 4, 5)
+ * x: List[Int] = List(1, 2, 3, 4, 5)
*
* scala> x(3)
* res1: Int = 4
@@ -190,7 +190,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*/
def lastIndexWhere(p: A => Boolean, end: Int): Int
- /** Returns new $coll wih elements in reversed order.
+ /** Returns new $coll with elements in reversed order.
*
* $willNotTerminateInf
*
@@ -302,14 +302,14 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*
* Example:
* {{{
- * scala> val x = LinkedList(1)
- * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
+ * scala> val x = List(1)
+ * x: List[Int] = List(1)
*
* scala> val y = 2 +: x
- * y: scala.collection.mutable.LinkedList[Int] = LinkedList(2, 1)
+ * y: List[Int] = List(2, 1)
*
* scala> println(x)
- * LinkedList(1)
+ * List(1)
* }}}
*
* @return a new $coll consisting of `elem` followed
@@ -335,17 +335,14 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
*
* Example:
* {{{
- * scala> import scala.collection.mutable.LinkedList
- * import scala.collection.mutable.LinkedList
- *
- * scala> val a = LinkedList(1)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
- *
+ * scala> val a = List(1)
+ * a: List[Int] = List(1)
+ *
* scala> val b = a :+ 2
- * b: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2)
- *
+ * b: List[Int] = List(1, 2)
+ *
* scala> println(a)
- * LinkedList(1)
+ * List(1)
* }}}
*
* @return a new $coll consisting of
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index a0c519884c..ca098e57b9 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -267,20 +267,20 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
*
* Example:
* {{{
- * scala> val a = LinkedList(1)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
- *
- * scala> val b = LinkedList(2)
- * b: scala.collection.mutable.LinkedList[Int] = LinkedList(2)
- *
+ * scala> val a = List(1)
+ * a: List[Int] = List(1)
+ *
+ * scala> val b = List(2)
+ * b: List[Int] = List(2)
+ *
* scala> val c = a ++ b
- * c: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2)
- *
- * scala> val d = LinkedList('a')
- * d: scala.collection.mutable.LinkedList[Char] = LinkedList(a)
- *
+ * c: List[Int] = List(1, 2)
+ *
+ * scala> val d = List('a')
+ * d: List[Char] = List(a)
+ *
* scala> val e = c ++ d
- * e: scala.collection.mutable.LinkedList[AnyVal] = LinkedList(1, 2, a)
+ * e: List[AnyVal] = List(1, 2, a)
* }}}
*
* @return a new $coll which contains all elements of this $coll
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index a9fe279599..01d179aeb6 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -130,8 +130,8 @@ trait GenTraversableOnce[+A] extends Any {
*
* Note that the folding function used to compute b is equivalent to that used to compute c.
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
*
* scala> val b = (5 /: a)(_+_)
* b: Int = 15
@@ -167,8 +167,8 @@ trait GenTraversableOnce[+A] extends Any {
*
* Note that the folding function used to compute b is equivalent to that used to compute c.
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
*
* scala> val b = (a :\ 5)(_+_)
* b: Int = 15
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index 26af32046c..072fd3da44 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -320,14 +320,14 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
- * b: StringBuilder =
- *
- * scala> a.addString(b, "LinkedList(", ", ", ")")
- * res1: StringBuilder = LinkedList(1, 2, 3, 4)
+ * b: StringBuilder =
+ *
+ * scala> a.addString(b , "List(" , ", " , ")")
+ * res5: StringBuilder = List(1, 2, 3, 4)
* }}}
*
* @param b the string builder to which elements are appended.
@@ -362,9 +362,9 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
@@ -385,14 +385,14 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* Example:
*
* {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
+ * scala> val a = List(1,2,3,4)
+ * a: List[Int] = List(1, 2, 3, 4)
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
* scala> val h = a.addString(b)
- * b: StringBuilder = 1234
+ * h: StringBuilder = 1234
* }}}
* @param b the string builder to which elements are appended.
diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala
index 56f1802509..14ae57c43a 100644
--- a/src/library/scala/collection/convert/Wrappers.scala
+++ b/src/library/scala/collection/convert/Wrappers.scala
@@ -102,8 +102,14 @@ private[collection] trait Wrappers {
override def clone(): JListWrapper[A] = JListWrapper(new ju.ArrayList[A](underlying))
}
+ // Note various overrides to avoid performance gotchas.
class SetWrapper[A](underlying: Set[A]) extends ju.AbstractSet[A] {
self =>
+ override def contains(o: Object): Boolean = {
+ try { underlying.contains(o.asInstanceOf[A]) }
+ catch { case cce: ClassCastException => false }
+ }
+ override def isEmpty = underlying.isEmpty
def size = underlying.size
def iterator = new ju.Iterator[A] {
val ui = underlying.iterator
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index fb0a34e64d..0a8524c139 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -59,7 +59,6 @@ class HashMap[A, +B] extends AbstractMap[A, B]
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): HashMap[A, B1] =
this + elem1 + elem2 ++ elems
- // TODO: optimize (might be able to use mutable updates)
def - (key: A): HashMap[A, B] =
removed0(key, computeHash(key), 0)
@@ -168,8 +167,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
}
}
- // TODO: add HashMap2, HashMap3, ...
-
class HashMap1[A,+B](private[collection] val key: A, private[collection] val hash: Int, private[collection] val value: (B @uV), private[collection] var kv: (A,B @uV)) extends HashMap[A,B] {
override def size = 1
@@ -277,7 +274,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
elems(index & 0x1f).get0(key, hash, level + 5)
} else if ((bitmap & mask) != 0) {
val offset = Integer.bitCount(bitmap & (mask-1))
- // TODO: might be worth checking if sub is HashTrieMap (-> monomorphic call site)
elems(offset).get0(key, hash, level + 5)
} else
None
@@ -289,7 +285,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
val offset = Integer.bitCount(bitmap & (mask-1))
if ((bitmap & mask) != 0) {
val sub = elems(offset)
- // TODO: might be worth checking if sub is HashTrieMap (-> monomorphic call site)
val subNew = sub.updated0(key, hash, level + 5, value, kv, merger)
if(subNew eq sub) this else {
val elemsNew = new Array[HashMap[A,B1]](elems.length)
@@ -312,7 +307,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
val offset = Integer.bitCount(bitmap & (mask-1))
if ((bitmap & mask) != 0) {
val sub = elems(offset)
- // TODO: might be worth checking if sub is HashTrieMap (-> monomorphic call site)
val subNew = sub.removed0(key, hash, level + 5)
if (subNew eq sub) this
else if (subNew.isEmpty) {
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 9eaceccd9f..115be09502 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -12,9 +12,9 @@ package scala
package collection
package immutable
-import scala.annotation.unchecked.{ uncheckedVariance => uV }
import generic._
import scala.collection.parallel.immutable.ParHashSet
+import scala.collection.GenSet
/** This class implements immutable sets using a hash trie.
*
@@ -54,11 +54,34 @@ class HashSet[A] extends AbstractSet[A]
def contains(e: A): Boolean = get0(e, computeHash(e), 0)
+ override def subsetOf(that: GenSet[A]) = that match {
+ case that:HashSet[A] =>
+ // call the specialized implementation with a level of 0 since both this and that are top-level hash sets
+ subsetOf0(that, 0)
+ case _ =>
+ // call the generic implementation
+ super.subsetOf(that)
+ }
+
+ /**
+ * A specialized implementation of subsetOf for when both this and that are HashSet[A] and we can take advantage
+ * of the tree structure of both operands and the precalculated hashcodes of the HashSet1 instances.
+ * @param that the other set
+ * @param level the level of this and that hashset
+ * The purpose of level is to keep track of how deep we are in the tree.
+ * We need this information for when we arrive at a leaf and have to call get0 on that
+ * The value of level is 0 for a top-level HashSet and grows in increments of 5
+ * @return true if all elements of this set are contained in that set
+ */
+ protected def subsetOf0(that: HashSet[A], level: Int) = {
+ // The default implementation is for the empty set and returns true because the empty set is a subset of all sets
+ true
+ }
+
override def + (e: A): HashSet[A] = updated0(e, computeHash(e), 0)
override def + (elem1: A, elem2: A, elems: A*): HashSet[A] =
this + elem1 + elem2 ++ elems
- // TODO: optimize (might be able to use mutable updates)
def - (e: A): HashSet[A] =
removed0(e, computeHash(e), 0)
@@ -128,14 +151,20 @@ object HashSet extends ImmutableSetFactory[HashSet] {
}
}
- // TODO: add HashSet2, HashSet3, ...
-
class HashSet1[A](private[HashSet] val key: A, private[HashSet] val hash: Int) extends HashSet[A] {
override def size = 1
override def get0(key: A, hash: Int, level: Int): Boolean =
(hash == this.hash && key == this.key)
+ override def subsetOf0(that: HashSet[A], level: Int) = {
+ // check if that contains this.key
+ // we use get0 with our key and hash at the correct level instead of calling contains,
+ // which would not work since that might not be a top-level HashSet
+ // and in any case would be inefficient because it would require recalculating the hash code
+ that.get0(key, hash, level)
+ }
+
override def updated0(key: A, hash: Int, level: Int): HashSet[A] =
if (hash == this.hash && key == this.key) this
else {
@@ -162,6 +191,14 @@ object HashSet extends ImmutableSetFactory[HashSet] {
override def get0(key: A, hash: Int, level: Int): Boolean =
if (hash == this.hash) ks.contains(key) else false
+ override def subsetOf0(that: HashSet[A], level: Int) = {
+ // we have to check each element
+ // we use get0 with our hash at the correct level instead of calling contains,
+ // which would not work since that might not be a top-level HashSet
+ // and in any case would be inefficient because it would require recalculating the hash code
+ ks.forall(key => that.get0(key, hash, level))
+ }
+
override def updated0(key: A, hash: Int, level: Int): HashSet[A] =
if (hash == this.hash) new HashSetCollision1(hash, ks + key)
else makeHashTrieSet(this.hash, this, hash, new HashSet1(key, hash), level)
@@ -197,6 +234,42 @@ object HashSet extends ImmutableSetFactory[HashSet] {
}
+ /**
+ * A branch node of the HashTrieSet with at least one and up to 32 children.
+ *
+ * @param bitmap encodes which element corresponds to which child
+ * @param elems the up to 32 children of this node.
+ * the number of children must be identical to the number of 1 bits in bitmap
+ * @param size0 the total number of elements. This is stored just for performance reasons.
+ * @tparam A the type of the elements contained in this hash set.
+ *
+ * How levels work:
+ *
+ * When looking up or adding elements, the part of the hashcode that is used to address the children array depends
+ * on how deep we are in the tree. This is accomplished by having a level parameter in all internal methods
+ * that starts at 0 and increases by 5 (32 = 2^5) every time we go deeper into the tree.
+ *
+ * hashcode (binary): 00000000000000000000000000000000
+ * level=0 (depth=0) ^^^^^
+ * level=5 (depth=1) ^^^^^
+ * level=10 (depth=2) ^^^^^
+ * ...
+ *
+ * Be careful: a non-toplevel HashTrieSet is not a self-contained set, so e.g. calling contains on it will not work!
+ * It relies on its depth in the Trie for which part of a hash to use to address the children, but this information
+ * (the level) is not stored due to storage efficiency reasons but has to be passed explicitly!
+ *
+ * How bitmap and elems correspond:
+ *
+ * A naive implementation of a HashTrieSet would always have an array of size 32 for children and leave the unused
+ * children empty (null). But that would be very wasteful regarding memory. Instead, only non-empty children are
+ * stored in elems, and the bitmap is used to encode which elem corresponds to which child bucket. The lowest 1 bit
+ * corresponds to the first element, the second-lowest to the second, etc.
+ *
+ * bitmap (binary): 00010000000000000000100000000000
+ * elems: [a,b]
+ * children: ---b----------------a-----------
+ */
class HashTrieSet[A](private val bitmap: Int, private[collection] val elems: Array[HashSet[A]], private val size0: Int)
extends HashSet[A] {
assert(Integer.bitCount(bitmap) == elems.length)
@@ -212,7 +285,6 @@ object HashSet extends ImmutableSetFactory[HashSet] {
elems(index & 0x1f).get0(key, hash, level + 5)
} else if ((bitmap & mask) != 0) {
val offset = Integer.bitCount(bitmap & (mask-1))
- // TODO: might be worth checking if sub is HashTrieSet (-> monomorphic call site)
elems(offset).get0(key, hash, level + 5)
} else
false
@@ -223,7 +295,6 @@ object HashSet extends ImmutableSetFactory[HashSet] {
val mask = (1 << index)
val offset = Integer.bitCount(bitmap & (mask-1))
if ((bitmap & mask) != 0) {
- // TODO: might be worth checking if sub is HashTrieSet (-> monomorphic call site)
val sub = elems(offset)
val subNew = sub.updated0(key, hash, level + 5)
if (sub eq subNew) this
@@ -249,7 +320,6 @@ object HashSet extends ImmutableSetFactory[HashSet] {
val offset = Integer.bitCount(bitmap & (mask-1))
if ((bitmap & mask) != 0) {
val sub = elems(offset)
- // TODO: might be worth checking if sub is HashTrieMap (-> monomorphic call site)
val subNew = sub.removed0(key, hash, level + 5)
if (sub eq subNew) this
else if (subNew.isEmpty) {
@@ -279,6 +349,49 @@ object HashSet extends ImmutableSetFactory[HashSet] {
}
}
+ override def subsetOf0(that: HashSet[A], level: Int): Boolean = if (that eq this) true else that match {
+ case that: HashTrieSet[A] if this.size0 <= that.size0 =>
+ // create local mutable copies of members
+ var abm = this.bitmap
+ val a = this.elems
+ var ai = 0
+ val b = that.elems
+ var bbm = that.bitmap
+ var bi = 0
+ if ((abm & bbm) == abm) {
+ // I tried rewriting this using tail recursion, but the generated java byte code was less than optimal
+ while(abm!=0) {
+ // highest remaining bit in abm
+ val alsb = abm ^ (abm & (abm - 1))
+ // highest remaining bit in bbm
+ val blsb = bbm ^ (bbm & (bbm - 1))
+ // if both trees have a bit set at the same position, we need to check the subtrees
+ if (alsb == blsb) {
+ // we are doing a comparison of a child of this with a child of that,
+ // so we have to increase the level by 5 to keep track of how deep we are in the tree
+ if (!a(ai).subsetOf0(b(bi), level + 5))
+ return false
+ // clear lowest remaining one bit in abm and increase the a index
+ abm &= ~alsb; ai += 1
+ }
+ // clear lowermost remaining one bit in bbm and increase the b index
+ // we must do this in any case
+ bbm &= ~blsb; bi += 1
+ }
+ true
+ } else {
+ // the bitmap of this contains more one bits than the bitmap of that,
+ // so this can not possibly be a subset of that
+ false
+ }
+ case _ =>
+ // if the other set is a HashTrieSet but has less elements than this, it can not be a subset
+ // if the other set is a HashSet1, we can not be a subset of it because we are a HashTrieSet with at least two children (see assertion)
+ // if the other set is a HashSetCollision1, we can not be a subset of it because we are a HashTrieSet with at least two different hash codes
+ // if the other set is the empty set, we are not a subset of it because we are not empty
+ false
+ }
+
override def iterator = new TrieIterator[A](elems.asInstanceOf[Array[Iterable[A]]]) {
final override def getElem(cc: AnyRef): A = cc.asInstanceOf[HashSet1[A]].key
}
diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala
index 486c2b6c8f..249d76584d 100644
--- a/src/library/scala/collection/immutable/NumericRange.scala
+++ b/src/library/scala/collection/immutable/NumericRange.scala
@@ -175,9 +175,36 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
catch { case _: ClassCastException => false }
final override def sum[B >: T](implicit num: Numeric[B]): B = {
- if (isEmpty) this.num fromInt 0
- else if (numRangeElements == 1) head
- else ((this.num fromInt numRangeElements) * (head + last) / (this.num fromInt 2))
+ // arithmetic series formula can be used for regular addition
+ if ((num eq scala.math.Numeric.IntIsIntegral)||
+ (num eq scala.math.Numeric.BigIntIsIntegral)||
+ (num eq scala.math.Numeric.ShortIsIntegral)||
+ (num eq scala.math.Numeric.ByteIsIntegral)||
+ (num eq scala.math.Numeric.CharIsIntegral)||
+ (num eq scala.math.Numeric.LongIsIntegral)||
+ (num eq scala.math.Numeric.FloatAsIfIntegral)||
+ (num eq scala.math.Numeric.BigDecimalIsFractional)||
+ (num eq scala.math.Numeric.DoubleAsIfIntegral)) {
+ val numAsIntegral = num.asInstanceOf[Integral[B]]
+ import numAsIntegral._
+ if (isEmpty) num fromInt 0
+ else if (numRangeElements == 1) head
+ else ((num fromInt numRangeElements) * (head + last) / (num fromInt 2))
+ } else {
+ // user provided custom Numeric, we cannot rely on arithmetic series formula
+ if (isEmpty) num.zero
+ else {
+ var acc = num.zero
+ var i = head
+ var idx = 0
+ while(idx < length) {
+ acc = num.plus(acc, i)
+ i = i + step
+ idx = idx + 1
+ }
+ acc
+ }
+ }
}
override lazy val hashCode = super.hashCode()
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index 589661a343..3a64820be6 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -188,7 +188,10 @@ extends scala.collection.AbstractSeq[T]
val s = start + _start
val e = if (_end == UndeterminedEnd) _end else start + _end
var f = first1
- while (f.end <= s && !f.isLast) f = f.next
+ while (f.end <= s && !f.isLast) {
+ if (f.next eq null) f.addMore(more)
+ f = f.next
+ }
new PagedSeq(more, f, s, e)
}
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 00f398a4b0..786b18cd21 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -259,9 +259,24 @@ extends scala.collection.AbstractSeq[Int]
final def contains(x: Int) = isWithinBoundaries(x) && ((x - start) % step == 0)
final override def sum[B >: Int](implicit num: Numeric[B]): Int = {
- if (isEmpty) 0
- else if (numRangeElements == 1) head
- else (numRangeElements.toLong * (head + last) / 2).toInt
+ if (num eq scala.math.Numeric.IntIsIntegral) {
+ // this is normal integer range with usual addition. arithmetic series formula can be used
+ if (isEmpty) 0
+ else if (numRangeElements == 1) head
+ else (numRangeElements.toLong * (head + last) / 2).toInt
+ } else {
+ // user provided custom Numeric, we cannot rely on arithmetic series formula
+ if (isEmpty) num.toInt(num.zero)
+ else {
+ var acc = num.zero
+ var i = head
+ while(i != terminalElement) {
+ acc = num.plus(acc, i)
+ i = i + step
+ }
+ num.toInt(acc)
+ }
+ }
}
override def toIterable = this
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index 5a0d24ddd2..43d46cf4d0 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -164,8 +164,8 @@ self =>
* @return the resulting string
*/
def replaceAllLiterally(literal: String, replacement: String): String = {
- val arg1 = java.util.regex.Pattern.quote(literal)
- val arg2 = java.util.regex.Matcher.quoteReplacement(replacement)
+ val arg1 = Regex.quote(literal)
+ val arg2 = Regex.quoteReplacement(replacement)
toString.replaceAll(arg1, arg2)
}
diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala
index e1f18a7036..e342e134b4 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -53,14 +53,14 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza
super.toArray[U]
}
- def :+[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = {
+ def :+[B >: T: ClassTag](elem: B): Array[B] = {
val result = Array.ofDim[B](repr.length + 1)
Array.copy(repr, 0, result, 0, repr.length)
result(repr.length) = elem
result
}
- def +:[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = {
+ def +:[B >: T: ClassTag](elem: B): Array[B] = {
val result = Array.ofDim[B](repr.length + 1)
result(0) = elem
Array.copy(repr, 0, result, 1, repr.length)
@@ -107,6 +107,54 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza
bb.result()
}
}
+
+ /** Converts an array of pairs into an array of first elements and an array of second elements.
+ *
+ * @tparam T1 the type of the first half of the element pairs
+ * @tparam T2 the type of the second half of the element pairs
+ * @param asPair an implicit conversion which asserts that the element type
+ * of this Array is a pair.
+ * @return a pair of Arrays, containing, respectively, the first and second half
+ * of each element pair of this Array.
+ */
+ def unzip[T1: ClassTag, T2: ClassTag](implicit asPair: T => (T1, T2)): (Array[T1], Array[T2]) = {
+ val a1 = new Array[T1](length)
+ val a2 = new Array[T2](length)
+ var i = 0
+ while (i < length) {
+ val e = apply(i)
+ a1(i) = e._1
+ a2(i) = e._2
+ i += 1
+ }
+ (a1, a2)
+ }
+
+ /** Converts an array of triples into three arrays, one containing the elements from each position of the triple.
+ *
+ * @tparam T1 the type of the first of three elements in the triple
+ * @tparam T2 the type of the second of three elements in the triple
+ * @tparam T3 the type of the third of three elements in the triple
+ * @param asTriple an implicit conversion which asserts that the element type
+ * of this Array is a triple.
+ * @return a triple of Arrays, containing, respectively, the first, second, and third
+ * elements from each element triple of this Array.
+ */
+ def unzip3[T1: ClassTag, T2: ClassTag, T3: ClassTag](implicit asTriple: T => (T1, T2, T3)): (Array[T1], Array[T2], Array[T3]) = {
+ val a1 = new Array[T1](length)
+ val a2 = new Array[T2](length)
+ val a3 = new Array[T3](length)
+ var i = 0
+ while (i < length) {
+ val e = apply(i)
+ a1(i) = e._1
+ a2(i) = e._2
+ a3(i) = e._3
+ i += 1
+ }
+ (a1, a2, a3)
+ }
+
def seq = thisCollection
diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala
index 7129f22f60..986cd0390f 100644
--- a/src/library/scala/runtime/AbstractPartialFunction.scala
+++ b/src/library/scala/runtime/AbstractPartialFunction.scala
@@ -35,15 +35,3 @@ abstract class AbstractPartialFunction[@specialized(scala.Int, scala.Long, scala
// let's not make it final so as not to confuse anyone
/*final*/ def apply(x: T1): R = applyOrElse(x, PartialFunction.empty)
}
-
-// Manual stand-ins for formerly specialized variations.
-// Not comprehensive, only sufficent to run scala-check built scala 2.11.0-M5
-// TODO Scala 2.10.0.M6 Remove this once scalacheck is published against M6.
-private[runtime] abstract class AbstractPartialFunction$mcIL$sp extends scala.runtime.AbstractPartialFunction[Any, Int] {
- override def apply(x: Any): Int = apply$mcIL$sp(x)
- def apply$mcIL$sp(x: Any): Int = applyOrElse(x, PartialFunction.empty)
-}
-private[runtime] abstract class AbstractPartialFunction$mcFL$sp extends scala.runtime.AbstractPartialFunction[Any, Float] {
- override def apply(x: Any): Float = apply$mcIL$sp(x)
- def apply$mcIL$sp(x: Any): Float = applyOrElse(x, PartialFunction.empty)
-}
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 13f2362d00..d597feb898 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -173,7 +173,7 @@ private[scala] trait PropertiesTrait {
* isJavaAtLeast("1.6") // true
* isJavaAtLeast("1.7") // true
* isJavaAtLeast("1.8") // false
- * }}
+ * }}}
*/
def isJavaAtLeast(version: String): Boolean = {
def parts(x: String) = {
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 22dbb37789..86132bb876 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -704,6 +704,14 @@ object Regex {
def replace(rs: String) = matcher.appendReplacement(sb, rs)
}
+ /** Quotes strings to be used literally in regex patterns.
+ *
+ * All regex metacharacters in the input match themselves literally in the output.
+ *
+ * @example {{{List("US$", "CAN$").map(Regex.quote).mkString("|").r}}}
+ */
+ def quote(text: String): String = Pattern quote text
+
/** Quotes replacement strings to be used in replacement methods.
*
* Replacement methods give special meaning to backslashes (`\`) and
diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala
index f48b99bd5a..6b3be8b77f 100644
--- a/src/manual/scala/man1/scala.scala
+++ b/src/manual/scala/man1/scala.scala
@@ -39,16 +39,16 @@ object scala extends Command {
CmdOptionBound("howtorun:", Argument("how")),
"How to execute " & Argument("torun") & ", if it is present. " &
"Options for " & Argument("how") & " are " & Mono("guess") &
- " (the default), " & Mono("script") & ", and " & Mono("object") &
+ " (the default), " & Mono("script") & ", " & Mono("jar") & ", and " & Mono("object") &
"."),
Definition(
- CmdOption("i"),
+ CmdOption("i", Argument("file")),
"Requests that a file be pre-loaded. It is only " &
"meaningful for interactive shells."),
Definition(
- CmdOption("e"),
+ CmdOption("e", Argument("string")),
"Requests that its argument be executed as Scala code."),
Definition(
diff --git a/src/manual/scala/man1/scalac.scala b/src/manual/scala/man1/scalac.scala
index 1c0c7c4a96..52e918595c 100644
--- a/src/manual/scala/man1/scalac.scala
+++ b/src/manual/scala/man1/scalac.scala
@@ -109,6 +109,9 @@ object scalac extends Command {
CmdOption("extdirs", Argument("dirs")),
"Override location of installed extensions."),
Definition(
+ CmdOption("feature"),
+ "Emit warning and location for usages of features that should be imported explicitly."),
+ Definition(
CmdOptionBound("g:", "{none,source,line,vars,notailcalls}"),
SeqPara(
Mono("\"none\"") & " generates no debugging info,",
@@ -128,6 +131,9 @@ object scalac extends Command {
CmdOption("javaextdirs", Argument("path")),
"Override Java extdirs classpath."),
Definition(
+ CmdOptionBound("language:", Argument("feature")),
+ "Enable one or more language features."),
+ Definition(
CmdOption("no-specialization"),
"Ignore " & MItalic("@specialize") & " annotations."),
Definition(
@@ -146,6 +152,12 @@ object scalac extends Command {
CmdOption("sourcepath", Argument("path")),
"Specify location(s) of source files."),
Definition(
+ CmdOptionBound("target:", "{jvm-1.5,jvm-1.6,jvm-1.7}"),
+ SeqPara(
+ Mono("\"jvm-1.5\"") & " target JVM 1.5 (deprecated),",
+ Mono("\"jvm-1.6\"") & " target JVM 1.6 (default),",
+ Mono("\"jvm-1.7\"") & " target JVM 1.7,")),
+ Definition(
CmdOption("toolcp", Argument("path")),
"Add to the runner classpath."),
Definition(
@@ -159,6 +171,12 @@ object scalac extends Command {
CmdOption("uniqid"),
"Uniquely tag all identifiers in debugging output."),
Definition(
+ CmdOption("usejavacp"),
+ "Utilize the java.class.path in classpath resolution."),
+ Definition(
+ CmdOption("usemanifestcp"),
+ "Utilize the manifest in classpath resolution."),
+ Definition(
CmdOption("verbose"),
"Output messages about what the compiler is doing"),
Definition(
@@ -175,11 +193,11 @@ object scalac extends Command {
Section("Advanced Options",
DefinitionList(
Definition(
- CmdOption("Xcheck-null"),
- "Warn upon selection of nullable reference"),
- Definition(
CmdOption("Xcheckinit"),
"Wrap field accessors to throw an exception on uninitialized access."),
+ Definition(
+ CmdOption("Xdev"),
+ "Enable warnings for developers working on the Scala compiler"),
Definition(
CmdOption("Xdisable-assertions"),
"Generate no assertions and assumptions"),
@@ -193,6 +211,9 @@ object scalac extends Command {
Definition(
CmdOption("Xfatal-warnings"),
"Fail the compilation if there are any warnings."),
+ Definition(
+ CmdOption("Xfull-lubs"),
+ "Retain pre 2.10 behavior of less aggressive truncation of least upper bounds."),
Definition(
CmdOption("Xfuture"),
"Turn on future language features."),
@@ -202,18 +223,39 @@ object scalac extends Command {
Definition(
CmdOption("Xlint"),
"Enable recommended additional warnings."),
+ Definition(
+ CmdOption("Xlog-free-terms"),
+ "Print a message when reification creates a free term."),
+ Definition(
+ CmdOption("Xlog-free-types"),
+ "Print a message when reification resorts to generating a free type."),
+ Definition(
+ CmdOption("Xlog-implicit-conversions"),
+ "Print a message whenever an implicit conversion is inserted."),
Definition(
CmdOption("Xlog-implicits"),
"Show more detail on why some implicits are not applicable."),
+ Definition(
+ CmdOption("Xlog-reflective-calls"),
+ "Print a message when a reflective method call is generated."),
+ Definition(
+ CmdOptionBound("Xmacro-settings:", Argument("option")),
+ "Custom settings for macros."),
+ Definition(
+ CmdOption("Xmain-class", Argument("path")),
+ "Class for manifest's Main-Class entry (only useful with -d <jar>)."),
Definition(
CmdOption("Xmax-classfile-name", Argument("n")),
"Maximum filename length for generated classes."),
Definition(
- CmdOption("Xmigration"),
- "Warn about constructs whose behavior may have changed between 2.7 and 2.8."),
+ CmdOptionBound("Xmigration:", Argument("version")),
+ "Warn about constructs whose behavior may have changed since" & Argument("version") & "."),
Definition(
CmdOption("Xno-forwarders"),
"Do not generate static forwarders in mirror classes."),
+ Definition(
+ CmdOption("Xno-patmat-analysis"),
+ "Don't perform exhaustivity/unreachability analysis. Also, ignore " & MItalic("@switch") & " annotation."),
Definition(
CmdOption("Xno-uescape"),
"Disable handling of " & BSlash & "u unicode escapes"),
@@ -221,26 +263,26 @@ object scalac extends Command {
CmdOption("Xnojline"),
"Do not use JLine for editing."),
Definition(
- CmdOptionBound("Xplugin:", Argument("file")),
- "Load a plugin from a file"),
+ CmdOptionBound("Xplugin:", Argument("paths")),
+ "Load a plugin from each classpath."),
Definition(
CmdOptionBound("Xplugin-disable:", Argument("plugin")),
- "Disable a plugin"),
+ "Disable plugins by name."),
Definition(
CmdOption("Xplugin-list"),
- "Print a synopsis of loaded plugins"),
+ "Print a synopsis of loaded plugins."),
Definition(
CmdOptionBound("Xplugin-require:", Argument("plugin")),
- "Abort unless the given plugin(s) are available"),
+ "Abort if a named plugin is not loaded."),
Definition(
CmdOption("Xpluginsdir", Argument("path")),
- "Path to search compiler plugins."),
+ "Path to search for plugin archives."),
Definition(
CmdOptionBound("Xprint:", Argument("phases")),
"Print out program after " & Argument("phases") & " (see below)."),
Definition(
- CmdOption("Xprint-icode"),
- "Log internal icode to *.icode files."),
+ CmdOptionBound("Xprint-icode", "[:" & Argument("phases") & "]"),
+ "Log internal icode to *.icode files after" & Argument("phases") & " (default: icode)."),
Definition(
CmdOption("Xprint-pos"),
"Print tree positions, as offsets."),
@@ -269,9 +311,12 @@ object scalac extends Command {
Definition(
CmdOption("Xsource-reader", Argument("classname")),
"Specify a custom method for reading source files."),
+ Definition(
+ CmdOption("Xstrict-inference"),
+ "Don't infer known-unsound types."),
Definition(
CmdOption("Xverify"),
- "Verify generic signatures in generated bytecode."),
+ "Verify generic signatures in generated bytecode (asm backend only)."),
Definition(
CmdOption("Y"),
"Print a synopsis of private options.")
@@ -281,65 +326,101 @@ object scalac extends Command {
Section("Compilation Phases",
DefinitionList(
Definition(
- MItalic("initial"),
- "initializing compiler"),
- Definition(
- MItalic("parse"),
- "parse source files"),
+ MItalic("parser"),
+ "parse source into ASTs, perform simple desugaring"),
Definition(
MItalic("namer"),
- "create symbols"),
+ "resolve names, attach symbols to named trees"),
+ Definition(
+ MItalic("packageobjects"),
+ "load package objects"),
+ Definition(
+ MItalic("typer"),
+ "the meat and potatoes: type the trees"),
+ Definition(
+ MItalic("patmat"),
+ "translate match expressions"),
+ Definition(
+ MItalic("superaccessors"),
+ "add super accessors in traits and nested classes"),
+ Definition(
+ MItalic("extmethods"),
+ "add extension methods for inline classes"),
+ Definition(
+ MItalic("pickler"),
+ "serialize symbol tables"),
+ Definition(
+ MItalic("refchecks"),
+ "reference/override checking, translate nested objects"),
+ Definition(
+ MItalic("selectiveanf"),
+ "ANF pre-transform for " & MItalic("@cps") & " (CPS plugin)"),
+ Definition(
+ MItalic("selectivecps"),
+ MItalic("@cps") & "-driven transform of selectiveanf assignements (CPS plugin)"),
+ Definition(
+ MItalic("uncurry"),
+ "uncurry, translate function values to anonymous classes"),
Definition(
- MItalic("analyze"),
- "name and type analysis"),
+ MItalic("tailcalls"),
+ "replace tail calls by jumps"),
Definition(
- MItalic("refcheck"),
- "reference checking"),
+ MItalic("specialize"),
+ MItalic("@specialized") & "-driven class and method specialization"),
Definition(
- MItalic("uncurry"),
- "uncurry function types and applications"),
+ MItalic("explicitouter"),
+ "this refs to outer pointers, translate patterns"),
+ Definition(
+ MItalic("erasure"),
+ "erase types, add interfaces for traits"),
+ Definition(
+ MItalic("posterasure"),
+ "clean up erased inline classes"),
+ Definition(
+ MItalic("lazyvals"),
+ "allocate bitmaps, translate lazy vals into lazified defs"),
Definition(
MItalic("lambdalift"),
- "lambda lifter"),
+ "move nested functions to top level"),
Definition(
- MItalic("typesasvalues"),
- "represent types as values"),
+ MItalic("constructors"),
+ "move field definitions into constructors"),
Definition(
- MItalic("addaccessors"),
- "add accessors for constructor arguments"),
+ MItalic("flatten"),
+ "eliminate inner classes"),
Definition(
- MItalic("explicitouterclasses"),
- "make links from inner classes to enclosing one explicit"),
+ MItalic("mixin"),
+ "mixin composition"),
Definition(
- MItalic("addconstructors"),
- "add explicit constructor for each class"),
+ MItalic("cleanup"),
+ "platform-specific cleanups, generate reflective calls"),
Definition(
- MItalic("tailcall"),
- "add tail-calls"),
+ MItalic("delambdafy"),
+ "remove lambdas"),
Definition(
- MItalic("wholeprog"),
- "perform whole program analysis"),
+ MItalic("icode"),
+ "generate portable intermediate code"),
Definition(
- MItalic("addinterfaces"),
- "add one interface per class"),
+ MItalic("inliner"),
+ "optimization: do inlining"),
Definition(
- MItalic("expandmixins"),
- "expand mixins by code copying"),
+ MItalic("inlineHandlers"),
+ "optimization: inline exception handlers"),
Definition(
- MItalic("boxing"),
- "makes boxing explicit"),
+ MItalic("closelim"),
+ "optimization: eliminate uncalled closures"),
Definition(
- MItalic("erasure"),
- "type eraser"),
+ MItalic("constopt"),
+ "optimization: optimize null and other constants"),
Definition(
- MItalic("icode"),
- "generate icode"),
+ MItalic("dce"),
+ "optimization: eliminate dead code"),
Definition(
- MItalic("codegen"),
- "enable code generation"),
+ MItalic("jvm"),
+ "generate JVM bytecode"),
Definition(
MItalic("terminal"),
- "compilation terminated"),
+ "the last phase in the compiler chain"),
Definition(
MItalic("all"),
"matches all phases"))))
diff --git a/src/partest-extras/scala/tools/partest/Util.scala b/src/partest-extras/scala/tools/partest/Util.scala
index 8214396291..60e9dbb0f9 100644
--- a/src/partest-extras/scala/tools/partest/Util.scala
+++ b/src/partest-extras/scala/tools/partest/Util.scala
@@ -16,8 +16,8 @@ object Util {
*/
def trace[A](a: A) = macro traceImpl[A]
- import scala.reflect.macros.BlackboxContext
- def traceImpl[A: c.WeakTypeTag](c: BlackboxContext)(a: c.Expr[A]): c.Expr[A] = {
+ import scala.reflect.macros.blackbox.Context
+ def traceImpl[A: c.WeakTypeTag](c: Context)(a: c.Expr[A]): c.Expr[A] = {
import c.universe._
import definitions._
diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/reflect/scala/reflect/api/Exprs.scala
index 50c8aa8779..5b6ff2325c 100644
--- a/src/reflect/scala/reflect/api/Exprs.scala
+++ b/src/reflect/scala/reflect/api/Exprs.scala
@@ -106,7 +106,7 @@ trait Exprs { self: Universe =>
*
* The corresponding macro implementation should have the following signature (note how the return type denotes path-dependency on x):
* {{{
- * object Impls { def foo_impl(c: BlackboxContext)(x: c.Expr[X]): c.Expr[x.value.T] = ... }
+ * object Impls { def foo_impl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ... }
* }}}
*/
@compileTimeOnly("cannot use value except for signatures of macro implementations")
diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala
index 3d5a213f2f..54b65166d8 100644
--- a/src/reflect/scala/reflect/api/FlagSets.scala
+++ b/src/reflect/scala/reflect/api/FlagSets.scala
@@ -169,6 +169,14 @@ trait FlagSets { self: Universe =>
/** Flag indicating that tree was generated by the compiler */
val SYNTHETIC: FlagSet
+
+ /** Flag indicating that tree represents an enum.
+ *
+ * It can only appear at
+ * - the enum's class
+ * - enum constants
+ **/
+ val ENUM: FlagSet
}
/** The empty set of flags
diff --git a/src/reflect/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala
index e239b86452..5667d93e29 100644
--- a/src/reflect/scala/reflect/api/Importers.scala
+++ b/src/reflect/scala/reflect/api/Importers.scala
@@ -34,7 +34,7 @@ package api
* {{{
* def staticEval[T](x: T) = macro staticEval[T]
*
- * def staticEval[T](c: scala.reflect.macros.BlackboxContext)(x: c.Expr[T]) = {
+ * def staticEval[T](c: scala.reflect.macros.blackbox.Context)(x: c.Expr[T]) = {
* // creates a runtime reflection universe to host runtime compilation
* import scala.reflect.runtime.{universe => ru}
* val mirror = ru.runtimeMirror(c.libraryClassLoader)
diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala
index a4cd531053..0f0e2b81c9 100644
--- a/src/reflect/scala/reflect/api/Mirrors.scala
+++ b/src/reflect/scala/reflect/api/Mirrors.scala
@@ -29,19 +29,19 @@ package api
* Compile-time `Mirror`s make use of only classloader `Mirror`s to load `Symbol`s
* by name.
*
- * The entry point to classloader `Mirror`s is via [[scala.reflect.macros.BlackboxContext#mirror]] or [[scala.reflect.macros.WhiteboxContext#mirror]].
+ * The entry point to classloader `Mirror`s is via [[scala.reflect.macros.blackbox.Context#mirror]] or [[scala.reflect.macros.whitebox.Context#mirror]].
* Typical methods which use classloader `Mirror`s include [[scala.reflect.api.Mirror#staticClass]],
* [[scala.reflect.api.Mirror#staticModule]], and [[scala.reflect.api.Mirror#staticPackage]]. For
* example:
* {{{
- * import scala.reflect.macros.BlackboxContext
+ * import scala.reflect.macros.blackbox.Context
*
* case class Location(filename: String, line: Int, column: Int)
*
* object Macros {
* def currentLocation: Location = macro impl
*
- * def impl(c: BlackboxContext): c.Expr[Location] = {
+ * def impl(c: Context): c.Expr[Location] = {
* import c.universe._
* val pos = c.macroApplication.pos
* val clsLocation = c.mirror.staticModule("Location") // get symbol of "Location" object
diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala
index 1e0854d171..5bc92d3893 100644
--- a/src/reflect/scala/reflect/api/Printers.scala
+++ b/src/reflect/scala/reflect/api/Printers.scala
@@ -201,6 +201,25 @@ trait Printers { self: Universe =>
*/
protected def newTreePrinter(out: PrintWriter): TreePrinter
+ /**
+ * Renders the code of the passed tree, so that:
+ * 1) it can be later compiled by scalac retaining the same meaning,
+ * 2) it looks pretty.
+ * At the moment we have handled #1 for unattributed trees and
+ * later on plan to account for typical idiosyncrasies of the typechecker.
+ * #2 is more or less okay indentation-wise, but at the moment there's a lot of desugaring
+ * left in place, and that's what we also plan to improve in the future.
+ *
+ * @group Printers
+ */
+ def showCode(tree: Tree) = render(tree, newCodePrinter)
+
+ /**
+ * Hook to define what `showCode(...)` means.
+ * @group Printers
+ */
+ protected def newCodePrinter(out: PrintWriter): TreePrinter
+
/** Renders internal structure of a reflection artifact as the
* visualization of a Scala syntax tree.
*
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala
index 241747e6d8..83da5141b9 100644
--- a/src/reflect/scala/reflect/api/Trees.scala
+++ b/src/reflect/scala/reflect/api/Trees.scala
@@ -2058,8 +2058,8 @@ trait Trees { self: Universe =>
* @group Extractors
*/
abstract class ExistentialTypeTreeExtractor {
- def apply(tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
- def unapply(existentialTypeTree: ExistentialTypeTree): Option[(Tree, List[Tree])]
+ def apply(tpt: Tree, whereClauses: List[MemberDef]): ExistentialTypeTree
+ def unapply(existentialTypeTree: ExistentialTypeTree): Option[(Tree, List[MemberDef])]
}
/** The API that all existential type trees support
@@ -2069,8 +2069,12 @@ trait Trees { self: Universe =>
/** The underlying type of the existential type. */
def tpt: Tree
- /** The clauses of the definition of the existential type. */
- def whereClauses: List[Tree]
+ /** The clauses of the definition of the existential type.
+ * Elements are one of the following:
+ * 1) TypeDef with TypeBoundsTree right-hand side
+ * 2) ValDef with empty right-hand side
+ */
+ def whereClauses: List[MemberDef]
}
/** A synthetic tree holding an arbitrary type. Not to be confused with
@@ -2533,7 +2537,7 @@ trait Trees { self: Universe =>
/** Creates a `ExistentialTypeTree` node from the given components, having a given `tree` as a prototype.
* Having a tree as a prototype means that the tree's attachments, type and symbol will be copied into the result.
*/
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]): ExistentialTypeTree
}
// ---------------------- traversing and transforming ------------------------------
@@ -2654,6 +2658,8 @@ trait Trees { self: Universe =>
def transformValDefss(treess: List[List[ValDef]]): List[List[ValDef]] =
treess mapConserve (transformValDefs(_))
/** Transforms a list of `CaseDef` nodes. */
+ def transformMemberDefs(trees: List[MemberDef]): List[MemberDef] =
+ trees mapConserve (tree => transform(tree).asInstanceOf[MemberDef])
def transformCaseDefs(trees: List[CaseDef]): List[CaseDef] =
trees mapConserve (tree => transform(tree).asInstanceOf[CaseDef])
/** Transforms a list of `Ident` nodes. */
diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala
index 1da2c24306..1c9b77581a 100644
--- a/src/reflect/scala/reflect/api/Universe.scala
+++ b/src/reflect/scala/reflect/api/Universe.scala
@@ -41,11 +41,11 @@ package api
* res1: reflect.runtime.universe.Type = scala.Either[String,Int]
* }}}
*
- * To obtain a `Universe` for use within a Scala macro, use [[scala.reflect.macros.BlackboxContext#universe]].
- * or [[scala.reflect.macros.WhiteboxContext#universe]]. For example:
+ * To obtain a `Universe` for use within a Scala macro, use [[scala.reflect.macros.blackbox.Context#universe]].
+ * or [[scala.reflect.macros.whitebox.Context#universe]]. For example:
* {{{
* def printf(format: String, params: Any*): Unit = macro impl
- * def impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = {
+ * def impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = {
* import c.universe._
* ...
* }
diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala
index 19c67879f5..0ca8611719 100644
--- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala
+++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala
@@ -166,9 +166,10 @@ trait BaseTypeSeqs {
val index = new Array[Int](nparents)
var i = 0
for (p <- parents) {
+ val parentBts = p.dealias.baseTypeSeq // dealias need for SI-8046.
pbtss(i) =
- if (p.baseTypeSeq eq undetBaseTypeSeq) AnyClass.info.baseTypeSeq
- else p.baseTypeSeq
+ if (parentBts eq undetBaseTypeSeq) AnyClass.info.baseTypeSeq
+ else parentBts
index(i) = 0
i += 1
}
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 1fe6f249b8..0091f50fc6 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -363,6 +363,7 @@ trait Definitions extends api.StandardDefinitions {
lazy val ComparableClass = requiredClass[java.lang.Comparable[_]] modifyInfo fixupAsAnyTrait
lazy val JavaCloneableClass = requiredClass[java.lang.Cloneable]
lazy val JavaNumberClass = requiredClass[java.lang.Number]
+ lazy val JavaEnumClass = requiredClass[java.lang.Enum[_]]
lazy val RemoteInterfaceClass = requiredClass[java.rmi.Remote]
lazy val RemoteExceptionClass = requiredClass[java.rmi.RemoteException]
@@ -482,12 +483,8 @@ trait Definitions extends api.StandardDefinitions {
lazy val TypeCreatorClass = getClassIfDefined("scala.reflect.api.TypeCreator") // defined in scala-reflect.jar, so we need to be careful
lazy val TreeCreatorClass = getClassIfDefined("scala.reflect.api.TreeCreator") // defined in scala-reflect.jar, so we need to be careful
- lazy val BlackboxMacroClass = getClassIfDefined("scala.reflect.macros.BlackboxMacro") // defined in scala-reflect.jar, so we need to be careful
- def BlackboxMacroContextValue = BlackboxMacroClass.map(sym => getMemberValue(sym, nme.c))
- lazy val WhiteboxMacroClass = getClassIfDefined("scala.reflect.macros.WhiteboxMacro") // defined in scala-reflect.jar, so we need to be careful
- def WhiteboxMacroContextValue = WhiteboxMacroClass.map(sym => getMemberValue(sym, nme.c))
- lazy val BlackboxContextClass = getClassIfDefined("scala.reflect.macros.BlackboxContext") // defined in scala-reflect.jar, so we need to be careful
- lazy val WhiteboxContextClass = getClassIfDefined("scala.reflect.macros.WhiteboxContext") // defined in scala-reflect.jar, so we need to be careful
+ lazy val BlackboxContextClass = getClassIfDefined("scala.reflect.macros.blackbox.Context") // defined in scala-reflect.jar, so we need to be careful
+ lazy val WhiteboxContextClass = getClassIfDefined("scala.reflect.macros.whitebox.Context") // defined in scala-reflect.jar, so we need to be careful
def MacroContextPrefix = BlackboxContextClass.map(sym => getMemberMethod(sym, nme.prefix))
def MacroContextPrefixType = BlackboxContextClass.map(sym => getTypeMember(sym, tpnme.PrefixType))
def MacroContextUniverse = BlackboxContextClass.map(sym => getMemberMethod(sym, nme.universe))
@@ -603,32 +600,31 @@ trait Definitions extends api.StandardDefinitions {
def isWhiteboxContextType(tp: Type) =
isMacroContextType(tp) && (tp <:< WhiteboxContextClass.tpe)
- def mightBeMacroBundleType(tp: Type) =
- tp.baseClasses.contains(WhiteboxMacroClass) ||
- tp.baseClasses.contains(BlackboxMacroClass)
-
- def isMacroBundleType(tp: Type) = tp.baseClasses match {
- case _ :: proto :: _ if isMacroBundleProtoType(proto.tpe) => true
- case _ => false
+ private def macroBundleParamInfo(tp: Type) = {
+ val ctor = tp.erasure.typeSymbol.primaryConstructor
+ ctor.paramss match {
+ case List(List(c)) =>
+ val sym = c.info.typeSymbol
+ val isContextCompatible = sym.isNonBottomSubClass(BlackboxContextClass) || sym.isNonBottomSubClass(WhiteboxContextClass)
+ if (isContextCompatible) c.info else NoType
+ case _ =>
+ NoType
+ }
}
- def isBlackboxMacroBundleType(tp: Type) =
- isMacroBundleType(tp) && (tp <:< BlackboxMacroClass.tpe) && !(tp <:< WhiteboxMacroClass.tpe)
+ def looksLikeMacroBundleType(tp: Type) =
+ macroBundleParamInfo(tp) != NoType
- def isMacroBundleProtoType(tp: Type) = {
- val sym = tp.typeSymbol
- val isNonTrivial = tp != ErrorType && tp != NothingTpe && tp != NullTpe
- def subclasses(sym: Symbol) = sym != NoSymbol && tp.baseClasses.contains(sym)
- val isMacroCompatible = subclasses(BlackboxMacroClass) ^ subclasses(WhiteboxMacroClass)
- val isBundlePrototype = sym != BlackboxMacroClass && sym != WhiteboxMacroClass && sym.isTrait && {
- val c = sym.info.member(nme.c)
- def overrides(sym: Symbol) = c.overrideChain.contains(sym)
- val cIsOk = (overrides(BlackboxMacroContextValue) || overrides(WhiteboxMacroContextValue)) && c.isDeferred
- cIsOk && sym.isMonomorphicType
- }
- isNonTrivial && isMacroCompatible && isBundlePrototype
+ def isMacroBundleType(tp: Type) = {
+ val isContextCompatible = macroBundleParamInfo(tp) != NoType
+ val hasSingleConstructor = !tp.declaration(nme.CONSTRUCTOR).isOverloaded
+ val nonAbstract = !tp.erasure.typeSymbol.isAbstractClass
+ isContextCompatible && hasSingleConstructor && nonAbstract
}
+ def isBlackboxMacroBundleType(tp: Type) =
+ isMacroBundleType(tp) && (macroBundleParamInfo(tp) <:< BlackboxContextClass.tpe)
+
def isIterableType(tp: Type) = tp <:< classExistentialType(IterableClass)
// These "direct" calls perform no dealiasing. They are most needed when
@@ -812,46 +808,32 @@ trait Definitions extends api.StandardDefinitions {
def byNameType(arg: Type) = appliedType(ByNameParamClass, arg)
def iteratorOfType(tp: Type) = appliedType(IteratorClass, tp)
def javaRepeatedType(arg: Type) = appliedType(JavaRepeatedParamClass, arg)
+ def optionType(tp: Type) = appliedType(OptionClass, tp)
def scalaRepeatedType(arg: Type) = appliedType(RepeatedParamClass, arg)
def seqType(arg: Type) = appliedType(SeqClass, arg)
// FYI the long clunky name is because it's really hard to put "get" into the
// name of a method without it sounding like the method "get"s something, whereas
// this method is about a type member which just happens to be named get.
- def typeOfMemberNamedGet(tp: Type) = resultOfMatchingMethod(tp, nme.get)()
- def typeOfMemberNamedHead(tp: Type) = resultOfMatchingMethod(tp, nme.head)()
- def typeOfMemberNamedApply(tp: Type) = resultOfMatchingMethod(tp, nme.apply)(IntTpe)
- def typeOfMemberNamedDrop(tp: Type) = resultOfMatchingMethod(tp, nme.drop)(IntTpe)
- def typeOfMemberNamedGetOrSelf(tp: Type) = typeOfMemberNamedGet(tp) orElse tp
- def typesOfSelectors(tp: Type) = getterMemberTypes(tp, productSelectors(tp))
- def typesOfCaseAccessors(tp: Type) = getterMemberTypes(tp, tp.typeSymbol.caseFieldAccessors)
-
- /** If this is a case class, the case field accessors (which may be an empty list.)
- * Otherwise, if there are any product selectors, that list.
- * Otherwise, a list containing only the type itself.
- */
- def typesOfSelectorsOrSelf(tp: Type): List[Type] = (
- if (tp.typeSymbol.isCase)
- typesOfCaseAccessors(tp)
- else typesOfSelectors(tp) match {
- case Nil => tp :: Nil
- case tps => tps
- }
- )
-
- /** If the given type has one or more product selectors, the type of the last one.
- * Otherwise, the type itself.
- */
- def typeOfLastSelectorOrSelf(tp: Type) = typesOfSelectorsOrSelf(tp).last
-
- def elementTypeOfLastSelectorOrSelf(tp: Type) = {
- val last = typeOfLastSelectorOrSelf(tp)
- ( typeOfMemberNamedHead(last)
- orElse typeOfMemberNamedApply(last)
- orElse elementType(ArrayClass, last)
- )
+ def typeOfMemberNamedGet(tp: Type) = typeArgOfBaseTypeOr(tp, OptionClass)(resultOfMatchingMethod(tp, nme.get)())
+ def typeOfMemberNamedHead(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.head)())
+ def typeOfMemberNamedApply(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.apply)(IntTpe))
+ def typeOfMemberNamedDrop(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.drop)(IntTpe))
+ def typesOfSelectors(tp: Type) = getterMemberTypes(tp, productSelectors(tp))
+ // SI-8128 Still using the type argument of the base type at Seq/Option if this is an old-style (2.10 compatible)
+ // extractor to limit exposure to regressions like the reported problem with existentials.
+ // TODO fix the existential problem in the general case, see test/pending/pos/t8128.scala
+ private def typeArgOfBaseTypeOr(tp: Type, baseClass: Symbol)(or: => Type): Type = (tp baseType baseClass).typeArgs match {
+ case x :: Nil => x
+ case _ => or
}
+ // Can't only check for _1 thanks to pos/t796.
+ def hasSelectors(tp: Type) = (
+ (tp.members containsName nme._1)
+ && (tp.members containsName nme._2)
+ )
+
/** Returns the method symbols for members _1, _2, ..., _N
* which exist in the given type.
*/
@@ -861,7 +843,9 @@ trait Definitions extends api.StandardDefinitions {
case m if m.paramss.nonEmpty => Nil
case m => m :: loop(n + 1)
}
- loop(1)
+ // Since ErrorType always returns a symbol from a call to member, we
+ // had better not start looking for _1, _2, etc. expecting it to run out.
+ if (tpe.isErroneous) Nil else loop(1)
}
/** If `tp` has a term member `name`, the first parameter list of which
@@ -1207,15 +1191,21 @@ trait Definitions extends api.StandardDefinitions {
}
def getMemberMethod(owner: Symbol, name: Name): TermSymbol = {
getMember(owner, name.toTermName) match {
- // todo. member symbol becomes a term symbol in cleanup. is this a bug?
- // case x: MethodSymbol => x
case x: TermSymbol => x
case _ => fatalMissingSymbol(owner, name, "method")
}
}
+ private lazy val erasurePhase = findPhaseWithName("erasure")
def getMemberIfDefined(owner: Symbol, name: Name): Symbol =
- owner.info.nonPrivateMember(name)
+ // findMember considered harmful after erasure; e.g.
+ //
+ // scala> exitingErasure(Symbol_apply).isOverloaded
+ // res27: Boolean = true
+ //
+ enteringPhaseNotLaterThan(erasurePhase )(
+ owner.info.nonPrivateMember(name)
+ )
/** Using getDecl rather than getMember may avoid issues with
* OverloadedTypes turning up when you don't want them, if you
diff --git a/src/reflect/scala/reflect/internal/FlagSets.scala b/src/reflect/scala/reflect/internal/FlagSets.scala
index 84825ff2da..799f85054a 100644
--- a/src/reflect/scala/reflect/internal/FlagSets.scala
+++ b/src/reflect/scala/reflect/internal/FlagSets.scala
@@ -43,5 +43,6 @@ trait FlagSets extends api.FlagSets { self: SymbolTable =>
val PRESUPER : FlagSet = Flags.PRESUPER
val DEFAULTINIT : FlagSet = Flags.DEFAULTINIT
val SYNTHETIC : FlagSet = Flags.SYNTHETIC
+ val ENUM : FlagSet = Flags.ENUM
}
}
diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala
index dcdf6728ce..11c1d66190 100644
--- a/src/reflect/scala/reflect/internal/Flags.scala
+++ b/src/reflect/scala/reflect/internal/Flags.scala
@@ -63,7 +63,7 @@ import scala.collection.{ mutable, immutable }
// 45: SYNCHRONIZED/M
// 46: ARTIFACT
// 47: DEFAULTMETHOD/M
-// 48:
+// 48: ENUM
// 49:
// 50:
// 51: lateDEFERRED
@@ -119,6 +119,7 @@ class ModifierFlags {
final val DEFAULTINIT = 1L << 41 // symbol is initialized to the default value: used by -Xcheckinit
final val ARTIFACT = 1L << 46 // symbol should be ignored when typechecking; will be marked ACC_SYNTHETIC in bytecode
final val DEFAULTMETHOD = 1L << 47 // symbol is a java default method
+ final val ENUM = 1L << 48 // symbol is an enum
/** Symbols which are marked ARTIFACT. (Expand this list?)
*
@@ -142,7 +143,7 @@ class ModifierFlags {
}
object ModifierFlags extends ModifierFlags
-/** All flags and associated operatins */
+/** All flags and associated operations */
class Flags extends ModifierFlags {
final val METHOD = 1 << 6 // a method
final val MODULE = 1 << 8 // symbol is module or class implementing a module
@@ -446,7 +447,7 @@ class Flags extends ModifierFlags {
case SYNCHRONIZED => "<synchronized>" // (1L << 45)
case ARTIFACT => "<artifact>" // (1L << 46)
case DEFAULTMETHOD => "<defaultmethod>" // (1L << 47)
- case 0x1000000000000L => "" // (1L << 48)
+ case ENUM => "<enum>" // (1L << 48)
case 0x2000000000000L => "" // (1L << 49)
case 0x4000000000000L => "" // (1L << 50)
case `lateDEFERRED` => "<latedeferred>" // (1L << 51)
diff --git a/src/reflect/scala/reflect/internal/HasFlags.scala b/src/reflect/scala/reflect/internal/HasFlags.scala
index ecbf839bab..1131c94da0 100644
--- a/src/reflect/scala/reflect/internal/HasFlags.scala
+++ b/src/reflect/scala/reflect/internal/HasFlags.scala
@@ -82,6 +82,7 @@ trait HasFlags {
def hasAbstractFlag = hasFlag(ABSTRACT)
def hasAccessorFlag = hasFlag(ACCESSOR)
def hasDefault = hasFlag(DEFAULTPARAM) && hasFlag(METHOD | PARAM) // Second condition disambiguates with TRAIT
+ def hasEnumFlag = hasFlag(ENUM)
def hasLocalFlag = hasFlag(LOCAL)
def hasModuleFlag = hasFlag(MODULE)
def hasPackageFlag = hasFlag(PACKAGE)
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index cc6e55192f..91ba552012 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -409,7 +409,7 @@ trait Importers extends api.Importers { to: SymbolTable =>
case from.TypeBoundsTree(lo, hi) =>
new TypeBoundsTree(importTree(lo), importTree(hi))
case from.ExistentialTypeTree(tpt, whereClauses) =>
- new ExistentialTypeTree(importTree(tpt), whereClauses map importTree)
+ new ExistentialTypeTree(importTree(tpt), whereClauses map importMemberDef)
case from.EmptyTree =>
EmptyTree
case null =>
@@ -475,6 +475,7 @@ trait Importers extends api.Importers { to: SymbolTable =>
new ImportSelector(importName(sel.name), sel.namePos, if (sel.rename != null) importName(sel.rename) else null, sel.renamePos)
def importValDef(tree: from.ValDef): ValDef = importTree(tree).asInstanceOf[ValDef]
def importTypeDef(tree: from.TypeDef): TypeDef = importTree(tree).asInstanceOf[TypeDef]
+ def importMemberDef(tree: from.MemberDef): MemberDef = importTree(tree).asInstanceOf[MemberDef]
def importTemplate(tree: from.Template): Template = importTree(tree).asInstanceOf[Template]
def importRefTree(tree: from.RefTree): RefTree = importTree(tree).asInstanceOf[RefTree]
def importIdent(tree: from.Ident): Ident = importTree(tree).asInstanceOf[Ident]
diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala
index 424e73dce8..8b72f98e4d 100644
--- a/src/reflect/scala/reflect/internal/Printers.scala
+++ b/src/reflect/scala/reflect/internal/Printers.scala
@@ -17,8 +17,6 @@ trait Printers extends api.Printers { self: SymbolTable =>
//nsc import treeInfo.{ IsTrue, IsFalse }
- final val showOuterTests = false
-
/** Adds backticks if the name is a scala keyword. */
def quotedName(name: Name, decode: Boolean): String = {
val s = if (decode) name.decode else name.toString
@@ -53,8 +51,8 @@ trait Printers extends api.Printers { self: SymbolTable =>
*/
def backquotedPath(t: Tree): String = {
t match {
- case Select(qual, name) if name.isTermName => "%s.%s".format(backquotedPath(qual), symName(t, name))
- case Select(qual, name) if name.isTypeName => "%s#%s".format(backquotedPath(qual), symName(t, name))
+ case Select(qual, name) if name.isTermName => s"${backquotedPath(qual)}.${symName(t, name)}"
+ case Select(qual, name) if name.isTypeName => s"${backquotedPath(qual)}#${symName(t, name)}"
case Ident(name) => symName(t, name)
case _ => t.toString
}
@@ -76,7 +74,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
def printPosition(tree: Tree) = if (printPositions) print(tree.pos.show)
- def println() {
+ def println() = {
out.println()
while (indentMargin > indentString.length())
indentString += indentString
@@ -84,116 +82,221 @@ trait Printers extends api.Printers { self: SymbolTable =>
out.write(indentString, 0, indentMargin)
}
- def printSeq[a](ls: List[a])(printelem: a => Unit)(printsep: => Unit) {
+ def printSeq[a](ls: List[a])(printelem: a => Unit)(printsep: => Unit): Unit =
ls match {
case List() =>
case List(x) => printelem(x)
case x :: rest => printelem(x); printsep; printSeq(rest)(printelem)(printsep)
}
- }
- def printColumn(ts: List[Tree], start: String, sep: String, end: String) {
+ def printColumn(ts: List[Tree], start: String, sep: String, end: String) = {
print(start); indent(); println()
printSeq(ts){print(_)}{print(sep); println()}; undent(); println(); print(end)
}
- def printRow(ts: List[Tree], start: String, sep: String, end: String) {
+ def printRow(ts: List[Tree], start: String, sep: String, end: String): Unit = {
print(start); printSeq(ts){print(_)}{print(sep)}; print(end)
}
- def printRow(ts: List[Tree], sep: String) { printRow(ts, "", sep, "") }
+ def printRow(ts: List[Tree], sep: String): Unit = printRow(ts, "", sep, "")
- def printTypeParams(ts: List[TypeDef]) {
- if (!ts.isEmpty) {
+ def printTypeParams(ts: List[TypeDef]): Unit =
+ if (ts.nonEmpty) {
print("["); printSeq(ts){ t =>
printAnnotations(t)
+ if (t.mods.hasFlag(CONTRAVARIANT)) {
+ print("-")
+ } else if (t.mods.hasFlag(COVARIANT)) {
+ print("+")
+ }
printParam(t)
}{print(", ")}; print("]")
}
- }
- def printLabelParams(ps: List[Ident]) {
+ def printLabelParams(ps: List[Ident]) = {
print("(")
printSeq(ps){printLabelParam}{print(", ")}
print(")")
}
- def printLabelParam(p: Ident) {
+ def printLabelParam(p: Ident) = {
print(symName(p, p.name)); printOpt(": ", TypeTree() setType p.tpe)
}
- def printValueParams(ts: List[ValDef]) {
- print("(")
- if (!ts.isEmpty) printFlags(ts.head.mods.flags & IMPLICIT, "")
- printSeq(ts){printParam}{print(", ")}
- print(")")
+ protected def parenthesize(condition: Boolean = true)(body: => Unit) = {
+ if (condition) print("(")
+ body
+ if (condition) print(")")
}
+
+ protected def printImplicitInParamsList(vds: List[ValDef]) =
+ if (vds.nonEmpty) printFlags(vds.head.mods.flags & IMPLICIT, "")
+
+ def printValueParams(ts: List[ValDef], inParentheses: Boolean = true): Unit =
+ parenthesize(inParentheses){
+ printImplicitInParamsList(ts)
+ printSeq(ts){printParam}{print(", ")}
+ }
- def printParam(tree: Tree) {
+ def printParam(tree: Tree) =
tree match {
- case ValDef(mods, name, tp, rhs) =>
+ case vd @ ValDef(mods, name, tp, rhs) =>
printPosition(tree)
- printAnnotations(tree)
+ printAnnotations(vd)
print(symName(tree, name)); printOpt(": ", tp); printOpt(" = ", rhs)
case TypeDef(mods, name, tparams, rhs) =>
printPosition(tree)
print(symName(tree, name))
printTypeParams(tparams); print(rhs)
}
- }
- def printBlock(tree: Tree) {
+ def printBlock(tree: Tree) =
tree match {
case Block(_, _) =>
print(tree)
case _ =>
printColumn(List(tree), "{", ";", "}")
}
- }
private def symFn[T](tree: Tree, f: Symbol => T, orElse: => T): T = tree.symbol match {
- case null | NoSymbol => orElse
- case sym => f(sym)
+ case null | NoSymbol => orElse
+ case sym => f(sym)
}
private def ifSym(tree: Tree, p: Symbol => Boolean) = symFn(tree, p, false)
- def printOpt(prefix: String, tree: Tree) {
- if (!tree.isEmpty) { print(prefix, tree) }
- }
+ def printOpt(prefix: String, tree: Tree) = if (tree.nonEmpty) { print(prefix, tree) }
def printModifiers(tree: Tree, mods: Modifiers): Unit = printFlags(
- if (tree.symbol == NoSymbol) mods.flags else tree.symbol.flags, "" + (
- if (tree.symbol == NoSymbol) mods.privateWithin
- else if (tree.symbol.hasAccessBoundary) tree.symbol.privateWithin.name
- else ""
+ if (tree.symbol == NoSymbol) mods.flags else tree.symbol.flags, "" + (
+ if (tree.symbol == NoSymbol) mods.privateWithin
+ else if (tree.symbol.hasAccessBoundary) tree.symbol.privateWithin.name
+ else ""
)
)
- def printFlags(flags: Long, privateWithin: String) {
+ def printFlags(flags: Long, privateWithin: String) = {
val mask: Long = if (settings.debug) -1L else PrintableFlags
val s = flagsToString(flags & mask, privateWithin)
if (s != "") print(s + " ")
}
- def printAnnotations(tree: Tree) {
+ def printAnnotations(tree: MemberDef) = {
// SI-5885: by default this won't print annotations of not yet initialized symbols
val annots = tree.symbol.annotations match {
- case Nil => tree.asInstanceOf[MemberDef].mods.annotations
+ case Nil => tree.mods.annotations
case anns => anns
}
- annots foreach (annot => print("@"+annot+" "))
+ annots foreach (annot => print(s"@$annot "))
}
private var currentOwner: Symbol = NoSymbol
private var selectorType: Type = NoType
+
+ protected def printPackageDef(tree: PackageDef, separator: String) = {
+ val PackageDef(packaged, stats) = tree
+ printAnnotations(tree)
+ print("package ", packaged); printColumn(stats, " {", separator, "}")
+ }
+
+ protected def printValDef(tree: ValDef, resultName: => String)(printTypeSignature: => Unit)(printRhs: => Unit) = {
+ val ValDef(mods, name, tp, rhs) = tree
+ printAnnotations(tree)
+ printModifiers(tree, mods)
+ print(if (mods.isMutable) "var " else "val ", resultName)
+ printTypeSignature
+ printRhs
+ }
+
+ protected def printDefDef(tree: DefDef, resultName: => String)(printTypeSignature: => Unit)(printRhs: => Unit) = {
+ val DefDef(mods, name, tparams, vparamss, tp, rhs) = tree
+ printAnnotations(tree)
+ printModifiers(tree, mods)
+ print("def " + resultName)
+ printTypeParams(tparams);
+ vparamss foreach {printValueParams(_)}
+ printTypeSignature
+ printRhs
+ }
+
+ protected def printTypeDef(tree: TypeDef, resultName: => String) = {
+ val TypeDef(mods, name, tparams, rhs) = tree
+ if (mods hasFlag (PARAM | DEFERRED)) {
+ printAnnotations(tree)
+ printModifiers(tree, mods)
+ print("type ")
+ printParam(tree)
+ } else {
+ printAnnotations(tree)
+ printModifiers(tree, mods)
+ print("type " + resultName)
+ printTypeParams(tparams)
+ printOpt(" = ", rhs)
+ }
+ }
+
+ protected def printImport(tree: Import, resSelect: => String) = {
+ val Import(expr, selectors) = tree
+ // Is this selector renaming a name (i.e, {name1 => name2})
+ def isNotRename(s: ImportSelector): Boolean =
+ s.name == nme.WILDCARD || s.name == s.rename
+
+ def selectorToString(s: ImportSelector): String = {
+ val from = quotedName(s.name)
+ if (isNotRename(s)) from
+ else from + "=>" + quotedName(s.rename)
+ }
+ print("import ", resSelect, ".")
+ selectors match {
+ case List(s) =>
+ // If there is just one selector and it is not renaming a name, no braces are needed
+ if (isNotRename(s)) print(selectorToString(s))
+ else print("{", selectorToString(s), "}")
+ // If there is more than one selector braces are always needed
+ case many =>
+ print(many.map(selectorToString).mkString("{", ", ", "}"))
+ }
+ }
+
+ protected def printCaseDef(tree: CaseDef) = {
+ val CaseDef(pat, guard, body) = tree
+ print("case ")
+ def patConstr(pat: Tree): Tree = pat match {
+ case Apply(fn, args) => patConstr(fn)
+ case _ => pat
+ }
+
+ print(pat); printOpt(" if ", guard)
+ print(" => ", body)
+ }
+
+ protected def printFunction(tree: Function)(printValueParams: => Unit) = {
+ val Function(vparams, body) = tree
+ print("(");
+ printValueParams
+ print(" => ", body, ")")
+ if (printIds && tree.symbol != null) print("#" + tree.symbol.id)
+ }
+
+ protected def printSuper(tree: Super, resultName: => String) = {
+ val Super(This(qual), mix) = tree
+ if (qual.nonEmpty || tree.symbol != NoSymbol) print(resultName + ".")
+ print("super")
+ if (mix.nonEmpty) print(s"[$mix]")
+ }
+
+ protected def printThis(tree: This, resultName: => String) = {
+ val This(qual) = tree
+ if (qual.nonEmpty) print(resultName + ".")
+ print("this")
+ }
- def printTree(tree: Tree) {
+ def printTree(tree: Tree) = {
tree match {
case EmptyTree =>
print("<empty>")
- case ClassDef(mods, name, tparams, impl) =>
- printAnnotations(tree)
+ case cd @ ClassDef(mods, name, tparams, impl) =>
+ printAnnotations(cd)
printModifiers(tree, mods)
val word =
if (mods.isTrait) "trait"
@@ -204,81 +307,45 @@ trait Printers extends api.Printers { self: SymbolTable =>
printTypeParams(tparams)
print(if (mods.isDeferred) " <: " else " extends ", impl)
- case PackageDef(packaged, stats) =>
- printAnnotations(tree)
- print("package ", packaged); printColumn(stats, " {", ";", "}")
+ case pd @ PackageDef(packaged, stats) =>
+ printPackageDef(pd, ";")
- case ModuleDef(mods, name, impl) =>
- printAnnotations(tree)
+ case md @ ModuleDef(mods, name, impl) =>
+ printAnnotations(md)
printModifiers(tree, mods)
print("object " + symName(tree, name), " extends ", impl)
- case ValDef(mods, name, tp, rhs) =>
- printAnnotations(tree)
- printModifiers(tree, mods)
- print(if (mods.isMutable) "var " else "val ", symName(tree, name))
- printOpt(": ", tp)
- if (!mods.isDeferred)
- print(" = ", if (rhs.isEmpty) "_" else rhs)
+ case vd @ ValDef(mods, name, tp, rhs) =>
+ printValDef(vd, symName(tree, name))(printOpt(": ", tp)) {
+ if (!mods.isDeferred) print(" = ", if (rhs.isEmpty) "_" else rhs)
+ }
- case DefDef(mods, name, tparams, vparamss, tp, rhs) =>
- printAnnotations(tree)
- printModifiers(tree, mods)
- print("def " + symName(tree, name))
- printTypeParams(tparams); vparamss foreach printValueParams
- printOpt(": ", tp); printOpt(" = ", rhs)
+ case dd @ DefDef(mods, name, tparams, vparamss, tp, rhs) =>
+ printDefDef(dd, symName(tree, name))(printOpt(": ", tp))(printOpt(" = ", rhs))
- case TypeDef(mods, name, tparams, rhs) =>
- if (mods hasFlag (PARAM | DEFERRED)) {
- printAnnotations(tree)
- printModifiers(tree, mods); print("type "); printParam(tree)
- } else {
- printAnnotations(tree)
- printModifiers(tree, mods); print("type " + symName(tree, name))
- printTypeParams(tparams); printOpt(" = ", rhs)
- }
+ case td @ TypeDef(mods, name, tparams, rhs) =>
+ printTypeDef(td, symName(tree, name))
case LabelDef(name, params, rhs) =>
print(symName(tree, name)); printLabelParams(params); printBlock(rhs)
- case Import(expr, selectors) =>
- // Is this selector remapping a name (i.e, {name1 => name2})
- def isNotRemap(s: ImportSelector) : Boolean = (s.name == nme.WILDCARD || s.name == s.rename)
- def selectorToString(s: ImportSelector): String = {
- val from = quotedName(s.name)
- if (isNotRemap(s)) from
- else from + "=>" + quotedName(s.rename)
- }
- print("import ", backquotedPath(expr), ".")
- selectors match {
- case List(s) =>
- // If there is just one selector and it is not remapping a name, no braces are needed
- if (isNotRemap(s)) print(selectorToString(s))
- else print("{", selectorToString(s), "}")
- // If there is more than one selector braces are always needed
- case many =>
- print(many.map(selectorToString).mkString("{", ", ", "}"))
- }
+ case imp @ Import(expr, _) =>
+ printImport(imp, backquotedPath(expr))
- case Template(parents, self, body) =>
+ case Template(parents, self, body) =>
val currentOwner1 = currentOwner
if (tree.symbol != NoSymbol) currentOwner = tree.symbol.owner
-// if (parents exists isReferenceToAnyVal) {
-// print("AnyVal")
-// }
-// else {
printRow(parents, " with ")
- if (!body.isEmpty) {
+ if (body.nonEmpty) {
if (self.name != nme.WILDCARD) {
print(" { ", self.name); printOpt(": ", self.tpt); print(" => ")
- } else if (!self.tpt.isEmpty) {
+ } else if (self.tpt.nonEmpty) {
print(" { _ : ", self.tpt, " => ")
} else {
print(" {")
}
printColumn(body, "", ";", "}")
}
-// }
currentOwner = currentOwner1
case Block(stats, expr) =>
@@ -290,18 +357,8 @@ trait Printers extends api.Printers { self: SymbolTable =>
print(selector); printColumn(cases, " match {", "", "}")
selectorType = selectorType1
- case CaseDef(pat, guard, body) =>
- print("case ")
- def patConstr(pat: Tree): Tree = pat match {
- case Apply(fn, args) => patConstr(fn)
- case _ => pat
- }
- if (showOuterTests &&
- needsOuterTest(
- patConstr(pat).tpe.finalResultType, selectorType, currentOwner))
- print("???")
- print(pat); printOpt(" if ", guard)
- print(" => ", body)
+ case cd @ CaseDef(pat, guard, body) =>
+ printCaseDef(cd)
case Alternative(trees) =>
printRow(trees, "(", "| ", ")")
@@ -318,9 +375,8 @@ trait Printers extends api.Printers { self: SymbolTable =>
case ArrayValue(elemtpt, trees) =>
print("Array[", elemtpt); printRow(trees, "]{", ", ", "}")
- case Function(vparams, body) =>
- print("("); printValueParams(vparams); print(" => ", body, ")")
- if (printIds && tree.symbol != null) print("#"+tree.symbol.id)
+ case f @ Function(vparams, body) =>
+ printFunction(f)(printValueParams(vparams))
case Assign(lhs, rhs) =>
print(lhs, " = ", rhs)
@@ -331,7 +387,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
case If(cond, thenp, elsep) =>
print("if (", cond, ")"); indent(); println()
print(thenp); undent()
- if (!elsep.isEmpty) {
+ if (elsep.nonEmpty) {
println(); print("else"); indent(); println(); print(elsep); undent()
}
@@ -340,7 +396,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
case Try(block, catches, finalizer) =>
print("try "); printBlock(block)
- if (!catches.isEmpty) printColumn(catches, " catch {", "", "}")
+ if (catches.nonEmpty) printColumn(catches, " catch {", "", "}")
printOpt(" finally ", finalizer)
case Throw(expr) =>
@@ -362,22 +418,18 @@ trait Printers extends api.Printers { self: SymbolTable =>
print("<apply-dynamic>(", qual, "#", tree.symbol.nameString)
printRow(vargs, ", (", ", ", "))")
- case Super(This(qual), mix) =>
- if (!qual.isEmpty || tree.symbol != NoSymbol) print(symName(tree, qual) + ".")
- print("super")
- if (!mix.isEmpty)
- print("[" + mix + "]")
+ case st @ Super(This(qual), mix) =>
+ printSuper(st, symName(tree, qual))
case Super(qual, mix) =>
print(qual, ".super")
- if (!mix.isEmpty)
+ if (mix.nonEmpty)
print("[" + mix + "]")
- case This(qual) =>
- if (!qual.isEmpty) print(symName(tree, qual) + ".")
- print("this")
+ case th @ This(qual) =>
+ printThis(th, symName(tree, qual))
- case Select(qual @ New(tpe), name) if !settings.debug =>
+ case Select(qual: New, name) if !settings.debug =>
print(qual)
case Select(qualifier, name) =>
@@ -400,10 +452,10 @@ trait Printers extends api.Printers { self: SymbolTable =>
print(tree.tpe.toString)
}
- case Annotated(Apply(Select(New(tpt), nme.CONSTRUCTOR), args), tree) =>
+ case an @ Annotated(Apply(Select(New(tpt), nme.CONSTRUCTOR), args), tree) =>
def printAnnot() {
print("@", tpt)
- if (!args.isEmpty)
+ if (args.nonEmpty)
printRow(args, "(", ",", ")")
}
print(tree, if (tree.isType) " " else ": ")
@@ -435,11 +487,11 @@ trait Printers extends api.Printers { self: SymbolTable =>
print(tpt)
printColumn(whereClauses, " forSome { ", ";", "}")
-// SelectFromArray is no longer visible in scala.reflect.internal.
-// eliminated until we figure out what we will do with both Printers and
-// SelectFromArray.
-// case SelectFromArray(qualifier, name, _) =>
-// print(qualifier); print(".<arr>"); print(symName(tree, name))
+ // SelectFromArray is no longer visible in scala.reflect.internal.
+ // eliminated until we figure out what we will do with both Printers and
+ // SelectFromArray.
+ // case SelectFromArray(qualifier, name, _) =>
+ // print(qualifier); print(".<arr>"); print(symName(tree, name))
case tree =>
xprintTree(this, tree)
@@ -459,11 +511,496 @@ trait Printers extends api.Printers { self: SymbolTable =>
out.print(if (arg == null) "null" else arg.toString)
}
}
+
+ // it's the printer for trees after parser and before typer phases
+ class ParsedTreePrinter(out: PrintWriter) extends TreePrinter(out) {
+ override def withTypes = this
+ override def withIds = this
+ override def withKinds = this
+ override def withMirrors = this
+ override def withPositions = this
+
+ // TODO: add print parameters to typed trees printer
+ printTypes = false
+ printIds = false
+ printKinds = false
+ printMirrors = false
+ printPositions = false
+
+ protected val parentsStack = scala.collection.mutable.Stack[Tree]()
+
+ protected def currentTree = if (parentsStack.nonEmpty) Some(parentsStack.top) else None
+
+ protected def currentParent = if (parentsStack.length > 1) Some(parentsStack(1)) else None
+
+ protected def printedName(name: Name, decoded: Boolean = true) = {
+ import Chars._
+ val decName = name.decoded
+ val bslash = '\\'
+ val brackets = List('[',']','(',')','{','}')
+
+ def addBackquotes(s: String) =
+ if (decoded && (decName.exists(ch => brackets.contains(ch) || isWhitespace(ch)) ||
+ (name.isOperatorName && decName.exists(isOperatorPart) && decName.exists(isScalaLetter) && !decName.contains(bslash))))
+ s"`$s`" else s
+
+ if (name == nme.CONSTRUCTOR) "this"
+ else addBackquotes(quotedName(name, decoded))
+ }
+
+ protected def isIntLitWithDecodedOp(qual: Tree, name: Name) = {
+ val qualIsIntLit = qual match {
+ case Literal(Constant(x: Int)) => true
+ case _ => false
+ }
+ qualIsIntLit && name.isOperatorName
+ }
+
+ protected def needsParentheses(parent: Tree)(insideIf: Boolean = true, insideMatch: Boolean = true,
+ insideTry: Boolean = true, insideAnnotated: Boolean = true, insideBlock: Boolean = true, insideLabelDef: Boolean = true) = {
+ parent match {
+ case _: If => insideIf
+ case _: Match => insideMatch
+ case _: Try => insideTry
+ case _: Annotated => insideAnnotated
+ case _: Block => insideBlock
+ case _: LabelDef => insideLabelDef
+ case _ => false
+ }
+ }
+
+ protected def checkForBlank(cond: Boolean) = if (cond) " " else ""
+ protected def blankForOperatorName(name: Name) = checkForBlank(name.isOperatorName)
+ protected def blankForName(name: Name) = checkForBlank(name.isOperatorName || name.endsWith("_"))
+
+ protected def resolveSelect(t: Tree): String = {
+ t match {
+ // case for: 1) (if (a) b else c).meth1.meth2 or 2) 1 + 5 should be represented as (1).+(5)
+ case Select(qual, name) if (name.isTermName && needsParentheses(qual)(insideLabelDef = false)) || isIntLitWithDecodedOp(qual, name) => s"(${resolveSelect(qual)}).${printedName(name)}"
+ case Select(qual, name) if name.isTermName => s"${resolveSelect(qual)}.${printedName(name)}"
+ case Select(qual, name) if name.isTypeName => s"${resolveSelect(qual)}#${blankForOperatorName(name)}%${printedName(name)}"
+ case Ident(name) => printedName(name)
+ case _ => showCode(t)
+ }
+ }
+
+ val defaultClasses = List(tpnme.AnyRef)
+ val defaultTraitsForCase = List(tpnme.Product, tpnme.Serializable)
+ protected def removeDefaultTypesFromList(trees: List[Tree])(classesToRemove: List[Name] = defaultClasses)(traitsToRemove: List[Name]) = {
+ def removeDefaultTraitsFromList(trees: List[Tree], traitsToRemove: List[Name]): List[Tree] =
+ trees match {
+ case Nil => trees
+ case init :+ last => last match {
+ case Select(Ident(sc), name) if traitsToRemove.contains(name) && sc == nme.scala_ =>
+ removeDefaultTraitsFromList(init, traitsToRemove)
+ case _ => trees
+ }
+ }
+
+ removeDefaultTraitsFromList(removeDefaultClassesFromList(trees, classesToRemove), traitsToRemove)
+ }
+
+ protected def removeDefaultClassesFromList(trees: List[Tree], classesToRemove: List[Name] = defaultClasses) = trees filter {
+ case Select(Ident(sc), name) => !(classesToRemove.contains(name) && sc == nme.scala_)
+ case _ => true
+ }
+
+ def printFlags(mods: Modifiers, primaryCtorParam: Boolean = false): Unit = {
+ val base = AccessFlags | OVERRIDE | ABSTRACT | FINAL | SEALED | LAZY
+ val mask = if (primaryCtorParam) base else base | IMPLICIT
+
+ val s = mods.flagString(mask)
+ if (s != "") print(s"$s ")
+ // case flag should be the last
+ if (mods.isCase) print(mods.flagBitsToString(CASE) + " ")
+ if (mods.isAbstractOverride) print("abstract override ")
+ }
+
+ override def printModifiers(tree: Tree, mods: Modifiers): Unit = printModifiers(mods, primaryCtorParam = false)
+
+ def printModifiers(mods: Modifiers, primaryCtorParam: Boolean): Unit = {
+ def modsAccepted = List(currentTree, currentParent) exists (_ map {
+ case _: ClassDef | _: ModuleDef | _: Template | _: PackageDef => true
+ case _ => false
+ } getOrElse false)
+
+ if (currentParent.isEmpty || modsAccepted)
+ printFlags(mods, primaryCtorParam)
+ else
+ List(IMPLICIT, CASE, LAZY, SEALED).foreach{flag => if (mods.hasFlag(flag)) print(s"${mods.flagBitsToString(flag)} ")}
+ }
+
+ def printParam(tree: Tree, primaryCtorParam: Boolean): Unit =
+ tree match {
+ case vd @ ValDef(mods, name, tp, rhs) =>
+ printAnnotations(vd)
+ val mutableOrOverride = mods.isOverride || mods.isMutable
+ val hideCtorMods = mods.isParamAccessor && mods.isPrivateLocal && !mutableOrOverride
+ val hideCaseCtorMods = mods.isCaseAccessor && mods.isPublic && !mutableOrOverride
+
+ if (primaryCtorParam && !(hideCtorMods || hideCaseCtorMods)) {
+ printModifiers(mods, primaryCtorParam)
+ print(if (mods.isMutable) "var " else "val ");
+ }
+ print(printedName(name), blankForName(name));
+ printOpt(": ", tp);
+ printOpt(" = ", rhs)
+ case TypeDef(_, name, tparams, rhs) =>
+ print(printedName(name))
+ printTypeParams(tparams);
+ print(rhs)
+ case _ =>
+ super.printParam(tree)
+ }
+
+ override def printParam(tree: Tree): Unit = {
+ printParam(tree, primaryCtorParam = false)
+ }
+
+ protected def printArgss(argss: List[List[Tree]]) =
+ argss foreach {x: List[Tree] => if (!(x.isEmpty && argss.size == 1)) printRow(x, "(", ", ", ")")}
+
+ override def printAnnotations(tree: MemberDef) = {
+ val annots = tree.mods.annotations
+ annots foreach {annot => printAnnot(annot); print(" ")}
+ }
+
+ protected def printAnnot(tree: Tree) = {
+ tree match {
+ case treeInfo.Applied(core, _, argss) =>
+ print("@")
+ core match {
+ case Select(New(tree), _) => print(tree)
+ case _ =>
+ }
+ printArgss(argss)
+ case _ => super.printTree(tree)
+ }
+ }
+
+ override def printTree(tree: Tree): Unit = {
+ parentsStack.push(tree)
+ tree match {
+ case cl @ ClassDef(mods, name, tparams, impl) =>
+ if (mods.isJavaDefined) super.printTree(cl)
+ printAnnotations(cl)
+ // traits
+ val clParents: List[Tree] = if (mods.isTrait) {
+ // avoid abstract modifier for traits
+ printModifiers(tree, mods &~ ABSTRACT)
+ print("trait ", printedName(name))
+ printTypeParams(tparams)
+
+ val build.SyntacticTraitDef(_, _, _, _, parents, _, _) = tree
+ parents
+ // classes
+ } else {
+ printModifiers(tree, mods)
+ print("class ", printedName(name))
+ printTypeParams(tparams)
+
+ val build.SyntacticClassDef(_, _, _, ctorMods, vparamss, earlyDefs, parents, selfType, body) = cl
+
+ // constructor's modifier
+ if (ctorMods.hasFlag(AccessFlags)) {
+ print(" ")
+ printModifiers(ctorMods, primaryCtorParam = false)
+ }
+
+ def printConstrParams(ts: List[ValDef]): Unit = {
+ parenthesize() {
+ printImplicitInParamsList(ts)
+ printSeq(ts)(printParam(_, primaryCtorParam = true))(print(", "))
+ }
+ }
+ // constructor's params processing (don't print single empty constructor param list)
+ vparamss match {
+ case Nil | List(Nil) if (!mods.isCase && !ctorMods.hasFlag(AccessFlags)) =>
+ case _ => vparamss foreach printConstrParams
+ }
+ parents
+ }
+
+ // get trees without default classes and traits (when they are last)
+ val printedParents = removeDefaultTypesFromList(clParents)()(if (mods.hasFlag(CASE)) defaultTraitsForCase else Nil)
+ print(if (mods.isDeferred) "<: " else if (printedParents.nonEmpty) " extends " else "", impl)
+
+ case pd @ PackageDef(packaged, stats) =>
+ packaged match {
+ case Ident(name) if name == nme.EMPTY_PACKAGE_NAME =>
+ printSeq(stats) {
+ print(_)
+ } {
+ print(";");
+ println()
+ };
+ case _ =>
+ printPackageDef(pd, "\n")
+ }
+
+ case md @ ModuleDef(mods, name, impl) =>
+ printAnnotations(md)
+ printModifiers(tree, mods)
+ val Template(parents, self, methods) = impl
+ val parWithoutAnyRef = removeDefaultClassesFromList(parents)
+ print("object " + printedName(name), if (parWithoutAnyRef.nonEmpty) " extends " else "", impl)
+
+ case vd @ ValDef(mods, name, tp, rhs) =>
+ printValDef(vd, printedName(name)) {
+ // place space after symbolic def name (val *: Unit does not compile)
+ printOpt(s"${blankForName(name)}: ", tp)
+ } {
+ if (!mods.isDeferred) print(" = ", if (rhs.isEmpty) "_" else rhs)
+ }
+
+ case dd @ DefDef(mods, name, tparams, vparamss, tp, rhs) =>
+ printDefDef(dd, printedName(name)) {
+ if (tparams.isEmpty && (vparamss.isEmpty || vparamss(0).isEmpty)) print(blankForName(name))
+ printOpt(": ", tp)
+ } {
+ printOpt(" = " + (if (mods.isMacro) "macro " else ""), rhs)
+ }
+
+ case td @ TypeDef(mods, name, tparams, rhs) =>
+ printTypeDef(td, printedName(name))
+
+ case LabelDef(name, params, rhs) =>
+ if (name.startsWith(nme.WHILE_PREFIX)) {
+ val If(cond, thenp, elsep) = rhs
+ print("while (", cond, ") ")
+ val Block(list, wh) = thenp
+ printColumn(list, "", ";", "")
+ } else if (name.startsWith(nme.DO_WHILE_PREFIX)) {
+ val Block(bodyList, ifCond @ If(cond, thenp, elsep)) = rhs
+ print("do ")
+ printColumn(bodyList, "", ";", "")
+ print(" while (", cond, ") ")
+ } else {
+ print(printedName(name)); printLabelParams(params);
+ printBlock(rhs)
+ }
+
+ case imp @ Import(expr, _) =>
+ printImport(imp, resolveSelect(expr))
+
+ case Template(parents, self, body) =>
+ val printedParents =
+ currentParent map {
+ case _: CompoundTypeTree => parents
+ case ClassDef(mods, name, _, _) if mods.isCase => removeDefaultTypesFromList(parents)()(List(tpnme.Product, tpnme.Serializable))
+ case _ => removeDefaultClassesFromList(parents)
+ } getOrElse (parents)
+
+ val primaryCtr = treeInfo.firstConstructor(body)
+ val ap: Option[Apply] = primaryCtr match {
+ case DefDef(_, _, _, _, _, Block(ctBody, _)) =>
+ val earlyDefs = treeInfo.preSuperFields(ctBody) ::: body.filter {
+ case td: TypeDef => treeInfo.isEarlyDef(td)
+ case _ => false
+ }
+ if (earlyDefs.nonEmpty) {
+ print("{")
+ printColumn(earlyDefs, "", ";", "")
+ print("} " + (if (printedParents.nonEmpty) "with " else ""))
+ }
+ ctBody collectFirst {
+ case apply: Apply => apply
+ }
+ case _ => None
+ }
+
+ if (printedParents.nonEmpty) {
+ val (clParent :: traits) = printedParents
+ print(clParent)
+
+ val constrArgss = ap match {
+ case Some(treeInfo.Applied(_, _, argss)) => argss
+ case _ => Nil
+ }
+ printArgss(constrArgss)
+ if (traits.nonEmpty) {
+ printRow(traits, " with ", " with ", "")
+ }
+ }
+ /* Remove primary constr def and constr val and var defs
+ * right contains all constructors
+ */
+ val (left, right) = body.filter {
+ // remove valdefs defined in constructor and presuper vals
+ case vd: ValDef => !vd.mods.isParamAccessor && !treeInfo.isEarlyValDef(vd)
+ // remove $this$ from traits
+ case dd: DefDef => dd.name != nme.MIXIN_CONSTRUCTOR
+ case td: TypeDef => !treeInfo.isEarlyDef(td)
+ case EmptyTree => false
+ case _ => true
+ } span {
+ case dd: DefDef => dd.name != nme.CONSTRUCTOR
+ case _ => true
+ }
+ val modBody = left ::: right.drop(1)
+ val showBody = !(modBody.isEmpty && (self == noSelfType || self.isEmpty))
+ if (showBody) {
+ if (self.name != nme.WILDCARD) {
+ print(" { ", self.name);
+ printOpt(": ", self.tpt);
+ print(" =>")
+ } else if (self.tpt.nonEmpty) {
+ print(" { _ : ", self.tpt, " =>")
+ } else {
+ print(" {")
+ }
+ printColumn(modBody, "", ";", "}")
+ }
+
+ case Block(stats, expr) => super.printTree(tree)
+
+ case Match(selector, cases) =>
+ /* Insert braces if match is inner
+ * make this function available for other cases
+ * passing required type for checking
+ */
+ def insertBraces(body: => Unit): Unit =
+ if (parentsStack.nonEmpty && parentsStack.tail.exists(_.isInstanceOf[Match])) {
+ print("(")
+ body
+ print(")")
+ } else body
+
+ val printParentheses = needsParentheses(selector)(insideLabelDef = false)
+ tree match {
+ case Match(EmptyTree, cs) =>
+ printColumn(cases, "{", "", "}")
+ case _ =>
+ insertBraces {
+ parenthesize(printParentheses)(print(selector))
+ printColumn(cases, " match {", "", "}")
+ }
+ }
+
+ case cd @ CaseDef(pat, guard, body) =>
+ printCaseDef(cd)
+
+ case Star(elem) =>
+ print(elem, "*")
+
+ case Bind(name, t) =>
+ if (t == EmptyTree) print("(", printedName(name), ")")
+ else if (t.exists(_.isInstanceOf[Star])) print(printedName(name), " @ ", t)
+ else print("(", printedName(name), " @ ", t, ")")
+
+ case f @ Function(vparams, body) =>
+ // parentheses are not allowed for val a: Int => Int = implicit x => x
+ val printParentheses = vparams match {
+ case head :: _ => !head.mods.isImplicit
+ case _ => true
+ }
+ printFunction(f)(printValueParams(vparams, inParentheses = printParentheses))
+
+ case Typed(expr, tp) =>
+ tp match {
+ case Function(List(), EmptyTree) => print("(", expr, " _)") //func _
+ // parentheses required when (a match {}) : Type
+ case _ => print("((", expr, "): ", tp, ")")
+ }
+
+ case Apply(fun, vargs) =>
+ tree match {
+ // processing methods ending on colons (x \: list)
+ case Apply(Block(l1 @ List(sVD: ValDef), a1 @ Apply(Select(_, methodName), l2 @ List(Ident(iVDName)))), l3)
+ if sVD.mods.isSynthetic && treeInfo.isLeftAssoc(methodName) && sVD.name == iVDName =>
+ val printBlock = Block(l1, Apply(a1, l3))
+ print(printBlock)
+ case Apply(tree1, _) if (needsParentheses(tree1)(insideAnnotated = false)) =>
+ parenthesize()(print(fun)); printRow(vargs, "(", ", ", ")")
+ case _ => super.printTree(tree)
+ }
+
+ case st @ Super(This(qual), mix) =>
+ printSuper(st, printedName(qual))
+
+ case th @ This(qual) =>
+ printThis(th, printedName(qual))
+
+ case Select(qual: New, name) =>
+ print(qual)
+
+ case Select(qualifier, name) => {
+ val printParentheses = needsParentheses(qualifier)(insideAnnotated = false) || isIntLitWithDecodedOp(qualifier, name)
+ if (printParentheses) print("(", resolveSelect(qualifier), ").", printedName(name))
+ else print(resolveSelect(qualifier), ".", printedName(name))
+ }
+
+ case id @ Ident(name) =>
+ if (name.nonEmpty) {
+ if (name == nme.dollarScope) {
+ print(s"scala.xml.${nme.TopScope}")
+ } else {
+ val str = printedName(name)
+ val strIsBackquoted = str.startsWith("`") && str.endsWith("`")
+ print(if (id.isBackquoted && !strIsBackquoted) "`" + str + "`" else str)
+ }
+ } else {
+ print("")
+ }
+
+ case l @ Literal(x) =>
+ x match {
+ case Constant(v: String) if {
+ val strValue = x.stringValue
+ strValue.contains("\n") && strValue.contains("\"\"\"") && strValue.size > 1
+ } =>
+ val splitValue = x.stringValue.split('\n'.toString).toList
+ val multilineStringValue = if (x.stringValue.endsWith("\n")) splitValue :+ "" else splitValue
+ val trQuotes = "\"\"\""
+ print(trQuotes); printSeq(multilineStringValue) { print(_) } { print("\n") }; print(trQuotes)
+ case _ =>
+ // processing Float constants
+ val printValue = x.escapedStringValue + (if (x.value.isInstanceOf[Float]) "F" else "")
+ print(printValue)
+ }
+
+ case an @ Annotated(ap, tree) =>
+ val printParentheses = needsParentheses(tree)()
+ parenthesize(printParentheses) { print(tree) }; print(if (tree.isType) " " else ": ")
+ printAnnot(ap)
+
+ case SelectFromTypeTree(qualifier, selector) =>
+ print("(", qualifier, ")#", blankForOperatorName(selector), printedName(selector))
+
+ case AppliedTypeTree(tp, args) =>
+ // it's possible to have (=> String) => String type but Function1[=> String, String] is not correct
+ val containsByNameTypeParam = args exists treeInfo.isByNameParamType
+
+ if (containsByNameTypeParam) {
+ print("(")
+ printRow(args.init, "(", ", ", ")")
+ print(" => ", args.last, ")")
+ } else {
+ if (treeInfo.isRepeatedParamType(tree) && args.nonEmpty) {
+ print(args(0), "*")
+ } else if (treeInfo.isByNameParamType(tree)) {
+ print("=> ", if (args.isEmpty) "()" else args(0))
+ } else
+ super.printTree(tree)
+ }
+
+ case ExistentialTypeTree(tpt, whereClauses) =>
+ print("(", tpt);
+ printColumn(whereClauses, " forSome { ", ";", "})")
+
+ case EmptyTree =>
+
+ case tree => super.printTree(tree)
+ }
+ parentsStack.pop()
+ }
+ }
/** Hook for extensions */
def xprintTree(treePrinter: TreePrinter, tree: Tree) =
treePrinter.print(tree.productPrefix+tree.productIterator.mkString("(", ", ", ")"))
+ def newCodePrinter(writer: PrintWriter): TreePrinter = new ParsedTreePrinter(writer)
def newTreePrinter(writer: PrintWriter): TreePrinter = new TreePrinter(writer)
def newTreePrinter(stream: OutputStream): TreePrinter = newTreePrinter(new PrintWriter(stream))
def newTreePrinter(): TreePrinter = newTreePrinter(new PrintWriter(ConsoleWriter))
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index ea6afa7349..a54aa1f6e8 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -686,6 +686,7 @@ trait StdNames {
val inlinedEquals: NameType = "inlinedEquals"
val isArray: NameType = "isArray"
val isDefinedAt: NameType = "isDefinedAt"
+ val isEmpty: NameType = "isEmpty"
val isInstanceOf_ : NameType = "isInstanceOf"
val isInstanceOf_Ob : NameType = "$isInstanceOf"
val java: NameType = "java"
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index 0ce5a0fbea..bed8310767 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -244,6 +244,18 @@ abstract class SymbolTable extends macros.Universe
finally popPhase(saved)
}
+ final def findPhaseWithName(phaseName: String): Phase = {
+ var ph = phase
+ while (ph != NoPhase && ph.name != phaseName) {
+ ph = ph.prev
+ }
+ if (ph eq NoPhase) phase else ph
+ }
+ final def enteringPhaseWithName[T](phaseName: String)(body: => T): T = {
+ val phase = findPhaseWithName(phaseName)
+ enteringPhase(phase)(body)
+ }
+
def slowButSafeEnteringPhase[T](ph: Phase)(op: => T): T = {
if (isCompilerUniverse) enteringPhase(ph)(op)
else op
@@ -344,16 +356,18 @@ abstract class SymbolTable extends macros.Universe
// Weak references so the garbage collector will take care of
// letting us know when a cache is really out of commission.
- private val caches = WeakHashSet[Clearable]()
+ import java.lang.ref.WeakReference
+ private var caches = List[WeakReference[Clearable]]()
def recordCache[T <: Clearable](cache: T): T = {
- caches += cache
+ caches ::= new WeakReference(cache)
cache
}
def clearAll() = {
debuglog("Clearing " + caches.size + " caches.")
- caches foreach (_.clear)
+ caches foreach (ref => Option(ref.get).foreach(_.clear))
+ caches = caches.filterNot(_.get == null)
}
def newWeakMap[K, V]() = recordCache(mutable.WeakHashMap[K, V]())
@@ -364,9 +378,9 @@ abstract class SymbolTable extends macros.Universe
val NoCached: T = null.asInstanceOf[T]
var cached: T = NoCached
var cachedRunId = NoRunId
- caches += new Clearable {
+ recordCache(new Clearable {
def clear(): Unit = cached = NoCached
- }
+ })
() => {
if (currentRunId != cachedRunId || cached == NoCached) {
cached = f
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index 6269004298..f6d21ec9bd 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -340,11 +340,13 @@ abstract class TreeGen extends macros.TreeBuilder {
// create parameters for <init> as synthetic trees.
var vparamss1 = mmap(vparamss) { vd =>
- atPos(vd.pos.focus) {
+ val param = atPos(vd.pos.makeTransparent) {
val mods = Modifiers(vd.mods.flags & (IMPLICIT | DEFAULTPARAM | BYNAMEPARAM) | PARAM | PARAMACCESSOR)
- ValDef(mods withAnnotations vd.mods.annotations, vd.name, vd.tpt.duplicate, vd.rhs.duplicate)
+ ValDef(mods withAnnotations vd.mods.annotations, vd.name, vd.tpt.duplicate, duplicateAndKeepPositions(vd.rhs))
}
+ param
}
+
val (edefs, rest) = body span treeInfo.isEarlyDef
val (evdefs, etdefs) = edefs partition treeInfo.isEarlyValDef
val gvdefs = evdefs map {
@@ -377,15 +379,21 @@ abstract class TreeGen extends macros.TreeBuilder {
// this means that we don't know what will be the arguments of the super call
// therefore here we emit a dummy which gets populated when the template is named and typechecked
Some(
- // TODO: previously this was `wrappingPos(superPos, lvdefs ::: argss.flatten)`
- // is it going to be a problem that we can no longer include the `argss`?
- atPos(wrappingPos(superPos, lvdefs)) (
+ atPos(wrappingPos(superPos, lvdefs ::: vparamss1.flatten).makeTransparent) (
DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant())))))
}
}
constr foreach (ensureNonOverlapping(_, parents ::: gvdefs, focus = false))
// Field definitions for the class - remove defaults.
- val fieldDefs = vparamss.flatten map (vd => copyValDef(vd)(mods = vd.mods &~ DEFAULTPARAM, rhs = EmptyTree))
+
+ val fieldDefs = vparamss.flatten map (vd => {
+ val field = copyValDef(vd)(mods = vd.mods &~ DEFAULTPARAM, rhs = EmptyTree)
+ // Prevent overlapping of `field` end's position with default argument's start position.
+ // This is needed for `Positions.Locator(pos).traverse` to return the correct tree when
+ // the `pos` is a point position with all its values equal to `vd.rhs.pos.start`.
+ if(field.pos.isRange && vd.rhs.pos.isRange) field.pos = field.pos.withEnd(vd.rhs.pos.start - 1)
+ field
+ })
global.Template(parents, self, gvdefs ::: fieldDefs ::: constr ++: etdefs ::: rest)
}
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 8fdf4dc27a..497a7c91b1 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -612,8 +612,8 @@ abstract class TreeInfo {
def effectivePatternArity(args: List[Tree]): Int = flattenedPatternArgs(args).length
def flattenedPatternArgs(args: List[Tree]): List[Tree] = args map unbind match {
- case Apply(fun, xs) :: Nil if isTupleSymbol(fun.symbol) => xs
- case xs => xs
+ case build.SyntacticTuple(xs) :: Nil => xs
+ case xs => xs
}
// used in the symbols for labeldefs and valdefs emitted by the pattern matcher
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index d191fbd38f..4a518f6c56 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -541,7 +541,7 @@ trait Trees extends api.Trees {
extends TypTree with TypeBoundsTreeApi
object TypeBoundsTree extends TypeBoundsTreeExtractor
- case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree])
+ case class ExistentialTypeTree(tpt: Tree, whereClauses: List[MemberDef])
extends TypTree with ExistentialTypeTreeApi
object ExistentialTypeTree extends ExistentialTypeTreeExtractor
@@ -694,7 +694,7 @@ trait Trees extends api.Trees {
new AppliedTypeTree(tpt, args).copyAttrs(tree)
def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree) =
new TypeBoundsTree(lo, hi).copyAttrs(tree)
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) =
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]) =
new ExistentialTypeTree(tpt, whereClauses).copyAttrs(tree)
}
@@ -910,7 +910,7 @@ trait Trees extends api.Trees {
if (lo0 == lo) && (hi0 == hi) => t
case _ => treeCopy.TypeBoundsTree(tree, lo, hi)
}
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) = tree match {
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[MemberDef]) = tree match {
case t @ ExistentialTypeTree(tpt0, whereClauses0)
if (tpt0 == tpt) && (whereClauses0 == whereClauses) => t
case _ => treeCopy.ExistentialTypeTree(tree, tpt, whereClauses)
@@ -1421,7 +1421,7 @@ trait Trees extends api.Trees {
case CompoundTypeTree(templ) =>
treeCopy.CompoundTypeTree(tree, transformTemplate(templ))
case ExistentialTypeTree(tpt, whereClauses) =>
- treeCopy.ExistentialTypeTree(tree, transform(tpt), transformTrees(whereClauses))
+ treeCopy.ExistentialTypeTree(tree, transform(tpt), transformMemberDefs(whereClauses))
case Return(expr) =>
treeCopy.Return(tree, transform(expr))
case Alternative(trees) =>
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 99e6ae633f..e9230aceee 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -8,7 +8,6 @@ package reflect
package internal
import scala.collection.{ mutable, immutable, generic }
-import generic.Clearable
import scala.ref.WeakReference
import mutable.ListBuffer
import Flags._
@@ -1999,7 +1998,9 @@ trait Types
if (sym.typeParams.size != args.size)
devWarning(s"$this.transform($tp), but tparams.isEmpty and args=$args")
- asSeenFromOwner(tp).instantiateTypeParams(sym.typeParams, args)
+ val GenPolyType(tparams, result) = asSeenFromOwner(tp)
+ assert((tparams eq Nil) || tparams == sym.typeParams, (tparams, sym.typeParams))
+ result.instantiateTypeParams(sym.typeParams, args)
}
// note: does not go through typeRef. There's no need to because
@@ -2309,7 +2310,14 @@ trait Types
}
thisInfo.decls
}
- protected[Types] def baseTypeSeqImpl: BaseTypeSeq = sym.info.baseTypeSeq map transform
+ protected[Types] def baseTypeSeqImpl: BaseTypeSeq =
+ if (sym.info.baseTypeSeq exists (_.typeSymbolDirect.isAbstractType))
+ // SI-8046 base type sequence might have more elements in a subclass, we can't map it element wise.
+ transform(sym.info).baseTypeSeq
+ else
+ // Optimization: no abstract types, we can compute the BTS of this TypeRef as an element-wise map
+ // of the BTS of the referenced symbol.
+ sym.info.baseTypeSeq map transform
override def baseTypeSeq: BaseTypeSeq = {
val cache = baseTypeSeqCache
@@ -3660,7 +3668,11 @@ trait Types
if (Statistics.canEnable) Statistics.incCounter(rawTypeCount)
if (uniqueRunId != currentRunId) {
uniques = util.WeakHashSet[Type](initialUniquesCapacity)
- perRunCaches.recordCache(uniques)
+ // JZ: We used to register this as a perRunCache so it would be cleared eagerly at
+ // the end of the compilation run. But, that facility didn't actually clear this map (SI-8129)!
+ // When i fixed that bug, run/tpeCache-tyconCache.scala started failing. Why was that?
+ // I've removed the registration for now. I don't think its particularly harmful anymore
+ // as a) this is now a weak set, and b) it is discarded completely before the next run.
uniqueRunId = currentRunId
}
(uniques findEntryOrUpdate tp).asInstanceOf[T]
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index a6c34935ad..3d222fce10 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -487,6 +487,7 @@ abstract class UnPickler {
def nameRef() = readNameRef()
def tparamRef() = readTypeDefRef()
def vparamRef() = readValDefRef()
+ def memberRef() = readMemberDefRef()
def constRef() = readConstantRef()
def idRef() = readIdentRef()
def termNameRef() = readNameRef().toTermName
@@ -520,7 +521,7 @@ abstract class UnPickler {
case CLASStree => ClassDef(modsRef, typeNameRef, rep(tparamRef), implRef)
case COMPOUNDTYPEtree => CompoundTypeTree(implRef)
case DEFDEFtree => DefDef(modsRef, termNameRef, rep(tparamRef), rep(rep(vparamRef)), ref, ref)
- case EXISTENTIALTYPEtree => ExistentialTypeTree(ref, all(ref))
+ case EXISTENTIALTYPEtree => ExistentialTypeTree(ref, all(memberRef))
case FUNCTIONtree => Function(rep(vparamRef), ref)
case IMPORTtree => Import(ref, selectorsRef)
case LABELtree => LabelDef(termNameRef, rep(idRef), ref)
@@ -634,6 +635,12 @@ abstract class UnPickler {
case other =>
errorBadSignature("expected an TypeDef (" + other + ")")
}
+ protected def readMemberDefRef(): MemberDef =
+ readTreeRef() match {
+ case tree:MemberDef => tree
+ case other =>
+ errorBadSignature("expected an MemberDef (" + other + ")")
+ }
protected def errorBadSignature(msg: String) =
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg)
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
index b60fecd66e..1620d8156b 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeComparers.scala
@@ -17,20 +17,15 @@ trait TypeComparers {
private val _pendingSubTypes = new mutable.HashSet[SubTypePair]
def pendingSubTypes = _pendingSubTypes
- class SubTypePair(val tp1: Type, val tp2: Type) {
- override def hashCode = tp1.hashCode * 41 + tp2.hashCode
- override def equals(other: Any) = (this eq other.asInstanceOf[AnyRef]) || (other match {
- // suspend TypeVars in types compared by =:=,
- // since we don't want to mutate them simply to check whether a subtype test is pending
- // in addition to making subtyping "more correct" for type vars,
- // it should avoid the stackoverflow that's been plaguing us (https://groups.google.com/d/topic/scala-internals/2gHzNjtB4xA/discussion)
- // this method is only called when subtyping hits a recursion threshold (subsametypeRecursions >= LogPendingSubTypesThreshold)
- case stp: SubTypePair =>
- val tvars = List(tp1, stp.tp1, tp2, stp.tp2) flatMap (t => if (t.isGround) Nil else typeVarsInType(t))
- suspendingTypeVars(tvars)(tp1 =:= stp.tp1 && tp2 =:= stp.tp2)
- case _ =>
- false
- })
+ final case class SubTypePair(tp1: Type, tp2: Type) {
+ // SI-8146 we used to implement equality here in terms of pairwise =:=.
+ // But, this was inconsistent with hashCode, which was based on the
+ // Type#hashCode, based on the structure of types, not the meaning.
+ // Now, we use `Type#{equals,hashCode}` as the (consistent) basis for
+ // detecting cycles (aka keeping subtyping decidable.)
+ //
+ // I added a tests to show that we detect the cycle: neg/t8146-no-finitary*
+
override def toString = tp1+" <:<? "+tp2
}
@@ -170,11 +165,20 @@ trait TypeComparers {
// corresponds does not check length of two sequences before checking the predicate,
// but SubstMap assumes it has been checked (SI-2956)
( sameLength(tparams1, tparams2)
- && (tparams1 corresponds tparams2)((p1, p2) => p1.info =:= subst(p2.info))
+ && (tparams1 corresponds tparams2)((p1, p2) => methodHigherOrderTypeParamsSameVariance(p1, p2) && p1.info =:= subst(p2.info))
&& (res1 =:= subst(res2))
)
}
+ // SI-2066 This prevents overrides with incompatible variance in higher order type parameters.
+ private def methodHigherOrderTypeParamsSameVariance(sym1: Symbol, sym2: Symbol) = {
+ def ignoreVariance(sym: Symbol) = !(sym.isHigherOrderTypeParameter && sym.logicallyEnclosingMember.isMethod)
+ ignoreVariance(sym1) || ignoreVariance(sym2) || sym1.variance == sym2.variance
+ }
+
+ private def methodHigherOrderTypeParamsSubVariance(low: Symbol, high: Symbol) =
+ methodHigherOrderTypeParamsSameVariance(low, high) || low.variance.isInvariant
+
def isSameType2(tp1: Type, tp2: Type): Boolean = {
def retry(lhs: Type, rhs: Type) = ((lhs ne tp1) || (rhs ne tp2)) && isSameType(lhs, rhs)
@@ -262,7 +266,7 @@ trait TypeComparers {
if (subsametypeRecursions >= LogPendingSubTypesThreshold) {
val p = new SubTypePair(tp1, tp2)
if (pendingSubTypes(p))
- false
+ false // see neg/t8146-no-finitary*
else
try {
pendingSubTypes += p
@@ -327,7 +331,10 @@ trait TypeComparers {
val substitutes = if (isMethod) tparams1 else cloneSymbols(tparams1)
def sub1(tp: Type) = if (isMethod) tp else tp.substSym(tparams1, substitutes)
def sub2(tp: Type) = tp.substSym(tparams2, substitutes)
- def cmp(p1: Symbol, p2: Symbol) = sub2(p2.info) <:< sub1(p1.info)
+ def cmp(p1: Symbol, p2: Symbol) = (
+ methodHigherOrderTypeParamsSubVariance(p2, p1)
+ && sub2(p2.info) <:< sub1(p1.info)
+ )
(tparams1 corresponds tparams2)(cmp) && (sub1(res1) <:< sub2(res2))
}
diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
index f61c1f3c50..e4a6503184 100644
--- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
+++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
@@ -41,7 +41,8 @@ trait TraceSymbolActivity {
}
}
- private def signature(id: Int) = runBeforeErasure(allSymbols(id).defString)
+ private lazy val erasurePhase = findPhaseWithName("erasure")
+ private def signature(id: Int) = enteringPhase(erasurePhase)(allSymbols(id).defString)
private def dashes(s: Any): String = ("" + s) map (_ => '-')
private def show(s1: Any, ss: Any*) {
@@ -87,14 +88,6 @@ trait TraceSymbolActivity {
private def showFreq[T, U](xs: Traversable[T])(groupFn: T => U, showFn: U => String) = {
showMapFreq(xs.toList groupBy groupFn)(showFn)
}
- private lazy val findErasurePhase: Phase = {
- var ph = phase
- while (ph != NoPhase && ph.name != "erasure") {
- ph = ph.prev
- }
- if (ph eq NoPhase) phase else ph
- }
- private def runBeforeErasure[T](body: => T): T = enteringPhase(findErasurePhase)(body)
def showAllSymbols() {
if (!enabled) return
diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala
index ca599dbd49..cc92cd10c7 100644
--- a/src/reflect/scala/reflect/macros/Aliases.scala
+++ b/src/reflect/scala/reflect/macros/Aliases.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that defines shorthands for the
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that defines shorthands for the
* most frequently used types and functions of the underlying compiler universe.
*/
trait Aliases {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** The type of symbols representing declarations. */
type Symbol = universe.Symbol
diff --git a/src/reflect/scala/reflect/macros/BlackboxMacro.scala b/src/reflect/scala/reflect/macros/BlackboxMacro.scala
deleted file mode 100644
index df142e9238..0000000000
--- a/src/reflect/scala/reflect/macros/BlackboxMacro.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package scala.reflect
-package macros
-
-/**
- * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
- *
- * Traditionally macro implementations are defined as methods,
- * but this trait provides an alternative way of encoding macro impls as
- * bundles, traits which extend `scala.reflect.macros.BlackboxMacro` or`scala.reflect.macros.WhiteboxMacro` .
- *
- * Instead of:
- *
- * def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[Int]) = ...
- *
- * One can write:
- *
- * trait Impl extends BlackboxMacro {
- * def apply[T: c.WeakTypeTag](x: c.Expr[Int]) = ...
- * }
- *
- * Without changing anything else at all.
- *
- * This language feature is useful in itself in cases when macro implementations
- * are complex and need to be modularized. State of the art technique of addressing this need is quite heavyweight:
- * http://docs.scala-lang.org/overviews/macros/overview.html#writing_bigger_macros.
- *
- * @see `scala.reflect.macros.WhiteboxMacro`
- */
-trait BlackboxMacro {
- /** The context to be used by the macro implementation.
- *
- * Vanilla macro implementations have to carry it in their signatures, however when a macro is a full-fledged module,
- * it can define the context next to the implementation, makes implementation signature more lightweight.
- */
- val c: BlackboxContext
-}
diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala
index 31905c4739..5f248d25d3 100644
--- a/src/reflect/scala/reflect/macros/Enclosures.scala
+++ b/src/reflect/scala/reflect/macros/Enclosures.scala
@@ -7,32 +7,19 @@ import scala.language.existentials // SI-6541
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that exposes
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that exposes
* enclosing trees (method, class, compilation unit and currently compiled application),
* the enclosing position of the macro expansion, as well as macros and implicits
* that are currently in-flight.
*/
trait Enclosures {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** The tree that undergoes macro expansion.
* Can be useful to get an offset or a range position of the entire tree being processed.
*/
def macroApplication: Tree
- /** The semantic role that `macroApplication` plays in the code.
- */
- type MacroRole
-
- /** The role that represents an application of a term macro,
- * e.g. `M(2)(3)` in `val x = M(2)(3)` or `M(a, b)` in `x match { case x @ M(a, b) => }`.
- */
- def APPLY_ROLE: MacroRole
-
- /** The semantic role that `macroApplication` plays in the code.
- */
- def macroRole: MacroRole
-
/** Contexts that represent macros in-flight, including the current one. Very much like a stack trace, but for macros only.
* Can be useful for interoperating with other macros and for imposing compiler-friendly limits on macro expansion.
*
@@ -43,7 +30,7 @@ trait Enclosures {
* Unlike `openMacros`, this is a val, which means that it gets initialized when the context is created
* and always stays the same regardless of whatever happens during macro expansion.
*/
- def enclosingMacros: List[BlackboxContext]
+ def enclosingMacros: List[blackbox.Context]
/** Tries to guess a position for the enclosing application.
* But that is simple, right? Just dereference `pos` of `macroApplication`? Not really.
diff --git a/src/reflect/scala/reflect/macros/Evals.scala b/src/reflect/scala/reflect/macros/Evals.scala
index eb37e83cad..222ae43d79 100644
--- a/src/reflect/scala/reflect/macros/Evals.scala
+++ b/src/reflect/scala/reflect/macros/Evals.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that provides
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that provides
* a facility to evaluate trees.
*/
trait Evals {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Takes a typed wrapper for a tree of type `T` and evaluates it to a value of type `T`.
*
@@ -21,12 +21,12 @@ trait Evals {
* mutates the tree in place, therefore the conventional approach is to `duplicate` the tree first.
*
* {{{
- * scala> def impl(c: BlackboxContext)(x: c.Expr[String]) = {
+ * scala> def impl(c: Context)(x: c.Expr[String]) = {
* | val x1 = c.Expr[String](c.resetAllAttrs(x.tree.duplicate))
* | println(s"compile-time value is: \${c.eval(x1)}")
* | x
* | }
- * impl: (c: BlackboxContext)(x: c.Expr[String])c.Expr[String]
+ * impl: (c: Context)(x: c.Expr[String])c.Expr[String]
*
* scala> def test(x: String) = macro impl
* test: (x: String)String
diff --git a/src/reflect/scala/reflect/macros/ExprUtils.scala b/src/reflect/scala/reflect/macros/ExprUtils.scala
index 58b61e446a..c438653c92 100644
--- a/src/reflect/scala/reflect/macros/ExprUtils.scala
+++ b/src/reflect/scala/reflect/macros/ExprUtils.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that defines shorthands for the
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that defines shorthands for the
* most common `Expr`-creating functions.
*/
trait ExprUtils {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Shorthand for `Literal(Constant(null))` in the underlying `universe`. */
@deprecated("Use quasiquotes instead", "2.11.0")
diff --git a/src/reflect/scala/reflect/macros/FrontEnds.scala b/src/reflect/scala/reflect/macros/FrontEnds.scala
index 3a910d89ad..a770f325b2 100644
--- a/src/reflect/scala/reflect/macros/FrontEnds.scala
+++ b/src/reflect/scala/reflect/macros/FrontEnds.scala
@@ -5,12 +5,12 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* provides facilities to communicate with the compiler's front end
* (emit warnings, errors and other sorts of messages).
*/
trait FrontEnds {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** For sending a message which should not be labeled as a warning/error,
* but also shouldn't require -verbose to be visible.
diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala
index b6585f94d2..0f2d9ce4cf 100644
--- a/src/reflect/scala/reflect/macros/Infrastructure.scala
+++ b/src/reflect/scala/reflect/macros/Infrastructure.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* provides facilities to communicate with the compiler's infrastructure.
*/
trait Infrastructure {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Exposes macro-specific settings as a list of strings.
* These settings are passed to the compiler via the "-Xmacro-settings:setting1,setting2...,settingN" command-line option.
diff --git a/src/reflect/scala/reflect/macros/Names.scala b/src/reflect/scala/reflect/macros/Names.scala
index 6bd3e1a199..af60dffbfc 100644
--- a/src/reflect/scala/reflect/macros/Names.scala
+++ b/src/reflect/scala/reflect/macros/Names.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* provides functions that generate unique names.
*/
trait Names {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Creates a unique string. */
@deprecated("Use freshName instead", "2.11.0")
diff --git a/src/reflect/scala/reflect/macros/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala
index 9d4a7e2953..720b754649 100644
--- a/src/reflect/scala/reflect/macros/Parsers.scala
+++ b/src/reflect/scala/reflect/macros/Parsers.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* exposes functions to parse strings with Scala code into trees.
*/
trait Parsers {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Parses a string with a Scala expression into an abstract syntax tree.
* Only works for expressions, i.e. parsing a package declaration will fail.
diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala
index 67d10dc10a..ff1f7a3b28 100644
--- a/src/reflect/scala/reflect/macros/Reifiers.scala
+++ b/src/reflect/scala/reflect/macros/Reifiers.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* exposes functions to save reflection artifacts for runtime.
*/
trait Reifiers {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Given a tree, generate a tree that when compiled and executed produces the original tree.
* For more information and examples see the documentation for `Universe.reify`.
diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala
index 5a25801335..54336900f8 100644
--- a/src/reflect/scala/reflect/macros/Typers.scala
+++ b/src/reflect/scala/reflect/macros/Typers.scala
@@ -5,11 +5,11 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context]] that
* partially exposes the type checker to macro writers.
*/
trait Typers {
- self: BlackboxContext =>
+ self: blackbox.Context =>
/** Contexts that represent macros in-flight, including the current one. Very much like a stack trace, but for macros only.
* Can be useful for interoperating with other macros and for imposing compiler-friendly limits on macro expansion.
@@ -21,7 +21,7 @@ trait Typers {
* Unlike `enclosingMacros`, this is a def, which means that it gets recalculated on every invocation,
* so it might change depending on what is going on during macro expansion.
*/
- def openMacros: List[BlackboxContext]
+ def openMacros: List[blackbox.Context]
/** @see `Typers.typecheck`
*/
diff --git a/src/reflect/scala/reflect/macros/WhiteboxMacro.scala b/src/reflect/scala/reflect/macros/WhiteboxMacro.scala
deleted file mode 100644
index 1c581313eb..0000000000
--- a/src/reflect/scala/reflect/macros/WhiteboxMacro.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package scala.reflect
-package macros
-
-/**
- * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
- *
- * Traditionally macro implementations are defined as methods,
- * but this trait provides an alternative way of encoding macro impls as
- * bundles, traits which extend `scala.reflect.macros.BlackboxMacro` or`scala.reflect.macros.WhiteboxMacro` .
- *
- * Instead of:
- *
- * def impl[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Expr[Int]) = ...
- *
- * One can write:
- *
- * trait Impl extends WhiteboxMacro {
- * def apply[T: c.WeakTypeTag](x: c.Expr[Int]) = ...
- * }
- *
- * Without changing anything else at all.
- *
- * This language feature is useful in itself in cases when macro implementations
- * are complex and need to be modularized. State of the art technique of addressing this need is quite heavyweight:
- * http://docs.scala-lang.org/overviews/macros/overview.html#writing_bigger_macros.
- *
- * @see `scala.reflect.macros.BlackboxMacro`
- */
-trait WhiteboxMacro {
- /** The context to be used by the macro implementation.
- *
- * Vanilla macro implementations have to carry it in their signatures, however when a macro is a full-fledged module,
- * it can define the context next to the implementation, makes implementation signature more lightweight.
- */
- val c: WhiteboxContext
-}
diff --git a/src/reflect/scala/reflect/macros/BlackboxContext.scala b/src/reflect/scala/reflect/macros/blackbox/Context.scala
index 2c77289866..05d9595c3a 100644
--- a/src/reflect/scala/reflect/macros/BlackboxContext.scala
+++ b/src/reflect/scala/reflect/macros/blackbox/Context.scala
@@ -1,6 +1,7 @@
package scala
package reflect
package macros
+package blackbox
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
@@ -24,24 +25,24 @@ package macros
* enclosing trees and compilation units, evaluating trees, logging warnings/errors and much more.
* Refer to the documentation of top-level traits in this package to learn the details.
*
- * If a macro def refers to a macro impl that uses `BlackboxContext`, then this macro def becomes a blackbox macro,
+ * If a macro def refers to a macro impl that uses `blackbox.Context`, then this macro def becomes a blackbox macro,
* which means that its expansion will be upcast to its return type, enforcing faithfullness of that macro to its
- * type signature. Whitebox macros, i.e. the ones defined with `WhiteboxContext`, aren't bound by this restriction,
+ * type signature. Whitebox macros, i.e. the ones defined with `whitebox.Context`, aren't bound by this restriction,
* which enables a number of important use cases, but they are also going to enjoy less support than blackbox macros,
* so choose wisely. See the [[http://docs.scala-lang.org/overviews/macros.html Macros Guide]] for more information.
*
- * @see `scala.reflect.macros.WhiteboxContext`
+ * @see `scala.reflect.macros.whitebox.Context`
*/
-trait BlackboxContext extends Aliases
- with Enclosures
- with Names
- with Reifiers
- with FrontEnds
- with Infrastructure
- with Typers
- with Parsers
- with Evals
- with ExprUtils {
+trait Context extends Aliases
+ with Enclosures
+ with Names
+ with Reifiers
+ with FrontEnds
+ with Infrastructure
+ with Typers
+ with Parsers
+ with Evals
+ with ExprUtils {
/** The compile-time universe. */
val universe: Universe
@@ -63,7 +64,7 @@ trait BlackboxContext extends Aliases
* scala> class Coll[T] {
* | def filter(p: T => Boolean): Coll[T] = macro M.filter[T]
* | }; object M {
- * | def filter[T](c: BlackboxContext { type PrefixType = Coll[T] })
+ * | def filter[T](c: Context { type PrefixType = Coll[T] })
* | (p: c.Expr[T => Boolean]): c.Expr[Coll[T]] =
* | {
* | println(c.prefix.tree)
diff --git a/src/reflect/scala/reflect/macros/package.scala b/src/reflect/scala/reflect/macros/package.scala
index 6a8434a163..cc7111d794 100644
--- a/src/reflect/scala/reflect/macros/package.scala
+++ b/src/reflect/scala/reflect/macros/package.scala
@@ -19,10 +19,10 @@ package object macros {
* with the former being better supported and the latter being more powerful. You can read about
* the details of the split and the associated trade-offs in the [[http://docs.scala-lang.org/overviews/macros.html Macros Guide]].
*
- * `scala.reflect.macros.Context` follows this tendency and turns into `scala.reflect.macros.BlackboxContext`
- * and `scala.reflect.macros.WhiteboxContext`. The original `Context` is left in place for compatibility reasons,
+ * `scala.reflect.macros.Context` follows this tendency and turns into `scala.reflect.macros.blackbox.Context`
+ * and `scala.reflect.macros.whitebox.Context`. The original `Context` is left in place for compatibility reasons,
* but it is now deprecated, nudging the users to choose between blackbox and whitebox macros.
*/
- @deprecated("Use BlackboxContext or WhiteboxContext instead", "2.11.0")
- type Context = WhiteboxContext
+ @deprecated("Use blackbox.Context or whitebox.Context instead", "2.11.0")
+ type Context = whitebox.Context
} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/macros/WhiteboxContext.scala b/src/reflect/scala/reflect/macros/whitebox/Context.scala
index 9d65a5c16e..bd48df46cc 100644
--- a/src/reflect/scala/reflect/macros/WhiteboxContext.scala
+++ b/src/reflect/scala/reflect/macros/whitebox/Context.scala
@@ -1,6 +1,7 @@
package scala
package reflect
package macros
+package whitebox
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
@@ -24,22 +25,22 @@ package macros
* enclosing trees and compilation units, evaluating trees, logging warnings/errors and much more.
* Refer to the documentation of top-level traits in this package to learn the details.
*
- * If a macro def refers to a macro impl that uses `WhiteboxContext`, then this macro def becomes a whitebox macro,
+ * If a macro def refers to a macro impl that uses `whitebox.Context`, then this macro def becomes a whitebox macro,
* gaining the ability to refine the type of its expansion beyond its official return type, which enables a number of important use cases.
- * Blackbox macros, i.e. the ones defined with `BlackboxContext`, can't do that, so they are less powerful.
+ * Blackbox macros, i.e. the ones defined with `blackbox.Context`, can't do that, so they are less powerful.
* However blackbox macros are also going to enjoy better support than whitebox macros, so choose wisely.
* See the [[http://docs.scala-lang.org/overviews/macros.html Macros Guide]] for more information.
*
- * @see `scala.reflect.macros.BlackboxContext`
+ * @see `scala.reflect.macros.blackbox.Context`
*/
-trait WhiteboxContext extends BlackboxContext {
+trait Context extends blackbox.Context {
/** @inheritdoc
*/
- def openMacros: List[WhiteboxContext]
+ def openMacros: List[Context]
/** @inheritdoc
*/
- def enclosingMacros: List[WhiteboxContext]
+ def enclosingMacros: List[Context]
/** Information about one of the currently considered implicit candidates.
* Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 9c4a3a5fe1..6b3985d434 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -198,6 +198,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
this.ErroneousCollector
this.adaptToNewRunMap
// inaccessible: this.commonOwnerMapObj
+ this.SubTypePair
this.SymbolKind
this.NoSymbol
this.CyclicReference
@@ -273,6 +274,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.ComparableClass
definitions.JavaCloneableClass
definitions.JavaNumberClass
+ definitions.JavaEnumClass
definitions.RemoteInterfaceClass
definitions.RemoteExceptionClass
definitions.ByNameParamClass
@@ -319,8 +321,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.MirrorClass
definitions.TypeCreatorClass
definitions.TreeCreatorClass
- definitions.BlackboxMacroClass
- definitions.WhiteboxMacroClass
definitions.BlackboxContextClass
definitions.WhiteboxContextClass
definitions.MacroImplAnnotation
@@ -425,6 +425,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.languageFeatureModule
definitions.metaAnnotations
definitions.AnnotationDefaultAttr
+ // inaccessible: definitions.erasurePhase
definitions.isPhantomClass
definitions.syntheticCoreClasses
definitions.syntheticCoreMethods
diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala
index 3a7688aa2c..3c9bbccba3 100644
--- a/src/reflect/scala/reflect/runtime/package.scala
+++ b/src/reflect/scala/reflect/runtime/package.scala
@@ -26,7 +26,7 @@ package object runtime {
package runtime {
private[scala] object Macros {
- def currentMirror(c: scala.reflect.macros.BlackboxContext): c.Expr[universe.Mirror] = {
+ def currentMirror(c: scala.reflect.macros.blackbox.Context): c.Expr[universe.Mirror] = {
import c.universe._
val runtimeClass = c.reifyEnclosingRuntimeClass
if (runtimeClass.isEmpty) c.abort(c.enclosingPosition, "call site does not have an enclosing class")
diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
index 496d5face1..915fd57bf8 100644
--- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
@@ -11,7 +11,6 @@ import java.lang.{ ClassLoader => JavaClassLoader, Iterable => JIterable }
import scala.tools.nsc.util.ScalaClassLoader
import java.io.{ ByteArrayInputStream, CharArrayWriter, FileNotFoundException, PrintWriter, Writer }
import java.util.{ Locale }
-import java.util.regex.Pattern
import java.util.concurrent.ConcurrentLinkedQueue
import javax.tools.{ Diagnostic, DiagnosticCollector, DiagnosticListener,
ForwardingJavaFileManager, JavaFileManager, JavaFileObject,
@@ -20,6 +19,7 @@ import scala.reflect.io.{ AbstractFile, Directory, File, Path }
import scala.io.Source
import scala.util.{ Try, Success, Failure }
import scala.util.Properties.lineSeparator
+import scala.util.matching.Regex
import scala.collection.JavaConverters
import scala.collection.generic.Clearable
import java.net.URL
@@ -608,12 +608,12 @@ object JavapClass {
// class k, candidate f without prefix
def isFunOfClass(k: String, f: String) = {
- val p = (s"${Pattern quote k}\\$$+anonfun").r
+ val p = (s"${Regex quote k}\\$$+anonfun").r
(p findPrefixOf f).nonEmpty
}
// class k, candidate f without prefix, method m
def isFunOfMethod(k: String, m: String, f: String) = {
- val p = (s"${Pattern quote k}\\$$+anonfun\\$$${Pattern quote m}\\$$").r
+ val p = (s"${Regex quote k}\\$$+anonfun\\$$${Regex quote m}\\$$").r
(p findPrefixOf f).nonEmpty
}
def isFunOfTarget(k: String, m: Option[String], f: String) =
diff --git a/src/repl/scala/tools/nsc/interpreter/Naming.scala b/src/repl/scala/tools/nsc/interpreter/Naming.scala
index cf38a2ae3a..e09c6f315e 100644
--- a/src/repl/scala/tools/nsc/interpreter/Naming.scala
+++ b/src/repl/scala/tools/nsc/interpreter/Naming.scala
@@ -8,6 +8,7 @@ package tools.nsc
package interpreter
import scala.util.Properties.lineSeparator
+import scala.util.matching.Regex
/** This is for name logic which is independent of the compiler (notice there's no Global.)
* That includes at least generating, metaquoting, mangling, and unmangling.
@@ -38,12 +39,10 @@ trait Naming {
//
// $line3.$read.$iw.$iw.Bippy =
// $line3.$read$$iw$$iw$Bippy@4a6a00ca
-
- private def noMeta(s: String) = "\\Q" + s + "\\E"
lazy val lineRegex = {
val sn = sessionNames
- val members = List(sn.read, sn.eval, sn.print) map noMeta mkString ("(?:", "|", ")")
- debugging("lineRegex")(noMeta(sn.line) + """\d+[./]""" + members + """[$.]""")
+ val members = List(sn.read, sn.eval, sn.print) map Regex.quote mkString ("(?:", "|", ")")
+ debugging("lineRegex")(Regex.quote(sn.line) + """\d+[./]""" + members + """[$.]""")
}
private def removeLineWrapper(s: String) = s.replaceAll(lineRegex, "")
diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala
deleted file mode 100644
index 578ef71e09..0000000000
--- a/src/swing/scala/swing/Publisher.scala
+++ /dev/null
@@ -1,174 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import scala.collection.mutable
-import mutable.Buffer
-import event.Event
-
-/** <p>
- * Notifies registered reactions when an event is published. Publishers are
- * also reactors and listen to themselves per default as a convenience.
- * </p>
- * <p>
- * In order to reduce memory leaks, reactions are weakly referenced by default,
- * unless they implement <code>Reactions.StronglyReferenced</code>. That way,
- * the lifetime of reactions are more easily bound to the registering object,
- * which are reactors in common client code and hold strong references to their
- * reactions. As a result, reactors can be garbage collected even though they
- * still have reactions registered at some publisher, but not vice versa
- * since reactors (strongly) reference publishers they are interested in.
- * </p>
- */
-trait Publisher extends Reactor {
- import Reactions._
-
- protected val listeners = new RefSet[Reaction] {
- import scala.ref._
- val underlying = new mutable.HashSet[Reference[Reaction]]
- protected def Ref(a: Reaction) = a match {
- case a: StronglyReferenced => new StrongReference[Reaction](a) with super.Ref[Reaction]
- case _ => new WeakReference[Reaction](a, referenceQueue) with super.Ref[Reaction]
- }
- }
-
- private[swing] def subscribe(listener: Reaction) { listeners += listener }
- private[swing] def unsubscribe(listener: Reaction) { listeners -= listener }
-
- /**
- * Notify all registered reactions.
- */
- def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) }
-
- listenTo(this)
-}
-
-/**
- * A publisher that subscribes itself to an underlying event source not before the first
- * reaction is installed. Can unsubscribe itself when the last reaction is uninstalled.
- */
-private[swing] trait LazyPublisher extends Publisher {
- import Reactions._
-
- protected def onFirstSubscribe()
- protected def onLastUnsubscribe()
-
- override def subscribe(listener: Reaction) {
- if(listeners.size == 1) onFirstSubscribe()
- super.subscribe(listener)
- }
- override def unsubscribe(listener: Reaction) {
- super.unsubscribe(listener)
- if(listeners.size == 1) onLastUnsubscribe()
- }
-}
-
-
-
-import scala.ref._
-
-private[swing] trait SingleRefCollection[+A <: AnyRef] extends Iterable[A] { self =>
-
- trait Ref[+A <: AnyRef] extends Reference[A] {
- override def hashCode() = get match {
- case Some(x) => x.##
- case _ => 0
- }
- override def equals(that: Any) = that match {
- case that: ReferenceWrapper[_] =>
- val v1 = this.get
- val v2 = that.get
- v1 == v2
- case _ => false
- }
- }
-
- //type Ref <: Reference[A] // TODO: could use higher kinded types, but currently crashes
- protected[this] def Ref(a: A): Ref[A]
- protected[this] val referenceQueue = new ReferenceQueue[A]
-
- protected val underlying: Iterable[Reference[A]]
-
- def purgeReferences() {
- var ref = referenceQueue.poll
- while (ref != None) {
- removeReference(ref.get.asInstanceOf[Reference[A]])
- ref = referenceQueue.poll
- }
- }
-
- protected[this] def removeReference(ref: Reference[A])
-
- def iterator = new Iterator[A] {
- private val elems = self.underlying.iterator
- private var hd: A = _
- private var ahead: Boolean = false
- private def skip(): Unit =
- while (!ahead && elems.hasNext) {
- // make sure we have a reference to the next element,
- // otherwise it might be garbage collected
- val next = elems.next.get
- ahead = next != None
- if (ahead) hd = next.get
- }
- def hasNext: Boolean = { skip; ahead }
- def next(): A =
- if (hasNext) { ahead = false; hd }
- else throw new NoSuchElementException("next on empty iterator")
- }
-}
-
-private[swing] class StrongReference[+T <: AnyRef](value: T) extends Reference[T] {
- private[this] var ref: Option[T] = Some(value)
- def isValid: Boolean = ref != None
- def apply(): T = ref.get
- def get : Option[T] = ref
- override def toString = get.map(_.toString).getOrElse("<deleted>")
- def clear() { ref = None }
- def enqueue(): Boolean = false
- def isEnqueued(): Boolean = false
- }
-
-abstract class RefBuffer[A <: AnyRef] extends Buffer[A] with SingleRefCollection[A] { self =>
- protected val underlying: Buffer[Reference[A]]
-
- def +=(el: A): this.type = { purgeReferences(); underlying += Ref(el); this }
- def +=:(el: A) = { purgeReferences(); Ref(el) +=: underlying; this }
- def remove(el: A) { underlying -= Ref(el); purgeReferences(); }
- def remove(n: Int) = { val el = apply(n); remove(el); el }
- def insertAll(n: Int, iter: Iterable[A]) {
- purgeReferences()
- underlying.insertAll(n, iter.view.map(Ref(_)))
- }
- def update(n: Int, el: A) { purgeReferences(); underlying(n) = Ref(el) }
- def apply(n: Int) = {
- purgeReferences()
- var el = underlying(n).get
- while (el == None) {
- purgeReferences(); el = underlying(n).get
- }
- el.get
- }
-
- def length = { purgeReferences(); underlying.length }
- def clear() { underlying.clear(); purgeReferences() }
-
- protected[this] def removeReference(ref: Reference[A]) { underlying -= ref }
-}
-
-private[swing] abstract class RefSet[A <: AnyRef] extends mutable.Set[A] with SingleRefCollection[A] { self =>
- protected val underlying: mutable.Set[Reference[A]]
-
- def -=(el: A): this.type = { underlying -= Ref(el); purgeReferences(); this }
- def +=(el: A): this.type = { purgeReferences(); underlying += Ref(el); this }
- def contains(el: A): Boolean = { purgeReferences(); underlying.contains(Ref(el)) }
- override def size = { purgeReferences(); underlying.size }
-
- protected[this] def removeReference(ref: Reference[A]) { underlying -= ref }
-}
diff --git a/test/files/neg/macro-abort/Macros_1.scala b/test/files/neg/macro-abort/Macros_1.scala
index 577e640089..2077e99ad7 100644
--- a/test/files/neg/macro-abort/Macros_1.scala
+++ b/test/files/neg/macro-abort/Macros_1.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
c.abort(c.enclosingPosition, "aborted")
}
def abort = macro impl
diff --git a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala
index ae34815d37..325bb7276f 100644
--- a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala
+++ b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala
@@ -1,17 +1,17 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr[Int](q"$x + 1")
}
- def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr[Int](q"$x + 2")
}
- def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr[Int](q"$x + 3")
}
diff --git a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala
index a00d195005..3cfbdf45e9 100644
--- a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala
+++ b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
trait Foo[T]
@@ -15,7 +15,7 @@ object Foo extends LowPriority {
}
object Macros {
- def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
+ def impl[T: c.WeakTypeTag](c: Context) = {
import c.universe._
val tpe = weakTypeOf[T]
if (tpe.members.exists(_.typeSignature =:= typeOf[Int]))
diff --git a/test/files/neg/macro-blackbox-extractor/Macros_1.scala b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
index f0bfe53aa2..64b6270b74 100644
--- a/test/files/neg/macro-blackbox-extractor/Macros_1.scala
+++ b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Extractor {
@@ -6,7 +6,7 @@ object Extractor {
}
object Macros {
- def unapplyImpl(c: BlackboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala
index 6bddef4b9d..a6f7de23bb 100644
--- a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala
+++ b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
trait Iso[T, U] {
def to(t : T) : U
@@ -8,7 +8,7 @@ trait Iso[T, U] {
object Iso {
implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U]
- def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext): c.Expr[Iso[T, U]] = {
+ def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = {
import c.universe._
import definitions._
import Flag._
diff --git a/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala b/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala
index a00f4ed7db..40ca1d549c 100644
--- a/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala
+++ b/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala
@@ -1,4 +1,4 @@
-// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+// see the comments for macroExpand.onDelayed for an explanation of what's tested here
object Test extends App {
case class Foo(i: Int, s: String, b: Boolean)
def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
index f5e85d57ea..a86a26d2c0 100644
--- a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
+++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
import scala.language.experimental.macros
object Macros {
- def impl(c: scala.reflect.macros.BlackboxContext) = {
+ def impl(c: scala.reflect.macros.blackbox.Context) = {
import c.universe._
q"""
trait Foo {
diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check
index 8ef59106b8..3afd079521 100644
--- a/test/files/neg/macro-bundle-abstract.check
+++ b/test/files/neg/macro-bundle-abstract.check
@@ -1,4 +1,4 @@
-macro-bundle-abstract.scala:4: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined
-trait Bundle extends BlackboxMacro {
- ^
+macro-bundle-abstract.scala:10: error: macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter
+ def foo = macro Bundle.impl
+ ^
one error found
diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala
index f7778d03be..0afeaafc01 100644
--- a/test/files/neg/macro-bundle-abstract.scala
+++ b/test/files/neg/macro-bundle-abstract.scala
@@ -1,7 +1,7 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.blackbox.Context
-trait Bundle extends BlackboxMacro {
+abstract class Bundle(c: Context) {
def deferred: Int
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check
deleted file mode 100644
index 7108c15b8d..0000000000
--- a/test/files/neg/macro-bundle-class.check
+++ /dev/null
@@ -1,4 +0,0 @@
-macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
- def foo = macro Bundle.impl
- ^
-one error found
diff --git a/test/files/neg/macro-bundle-class.scala b/test/files/neg/macro-bundle-class.scala
deleted file mode 100644
index 024e2dbaaa..0000000000
--- a/test/files/neg/macro-bundle-class.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
-import scala.reflect.macros.BlackboxContext
-
-class Bundle(val c: BlackboxContext) extends BlackboxMacro {
- def impl = ???
-}
-
-object Macros {
- def foo = macro Bundle.impl
-} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-mixbox.check b/test/files/neg/macro-bundle-mixbox.check
deleted file mode 100644
index c3136d9369..0000000000
--- a/test/files/neg/macro-bundle-mixbox.check
+++ /dev/null
@@ -1,4 +0,0 @@
-macro-bundle-mixbox.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
- def foo = macro Bundle.impl
- ^
-one error found
diff --git a/test/files/neg/macro-bundle-mixbox.scala b/test/files/neg/macro-bundle-mixbox.scala
deleted file mode 100644
index 1e36f3d94c..0000000000
--- a/test/files/neg/macro-bundle-mixbox.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-import scala.language.experimental.macros
-import scala.reflect.macros.{BlackboxMacro, WhiteboxMacro}
-
-trait Bundle extends BlackboxMacro with WhiteboxMacro {
- def impl = ???
-}
-
-object Macros {
- def foo = macro Bundle.impl
-} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-noncontext.check b/test/files/neg/macro-bundle-noncontext.check
new file mode 100644
index 0000000000..bb5d0851f5
--- /dev/null
+++ b/test/files/neg/macro-bundle-noncontext.check
@@ -0,0 +1,4 @@
+macro-bundle-noncontext.scala:8: error: not found: value Bundle
+ def foo = Bundle.impl
+ ^
+one error found
diff --git a/test/files/neg/macro-bundle-nonmacro.scala b/test/files/neg/macro-bundle-noncontext.scala
index c7d99f4582..c228827e70 100644
--- a/test/files/neg/macro-bundle-nonmacro.scala
+++ b/test/files/neg/macro-bundle-noncontext.scala
@@ -1,6 +1,6 @@
import scala.language.experimental.macros
-trait Bundle {
+class Bundle {
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-nonmacro.check b/test/files/neg/macro-bundle-nonmacro.check
deleted file mode 100644
index 5a265b5724..0000000000
--- a/test/files/neg/macro-bundle-nonmacro.check
+++ /dev/null
@@ -1,4 +0,0 @@
-macro-bundle-nonmacro.scala:8: error: not found: value Bundle
- def foo = Bundle.impl
- ^
-one error found
diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check
index 78e7119fa7..b8800105f5 100644
--- a/test/files/neg/macro-bundle-object.check
+++ b/test/files/neg/macro-bundle-object.check
@@ -1,6 +1,6 @@
macro-bundle-object.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
found : : Nothing
number of parameter sections differ
def foo = macro Bundle.impl
diff --git a/test/files/neg/macro-bundle-object.scala b/test/files/neg/macro-bundle-object.scala
index 105c81f1f5..6e1eec1686 100644
--- a/test/files/neg/macro-bundle-object.scala
+++ b/test/files/neg/macro-bundle-object.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.{BlackboxMacro, BlackboxContext}
+import scala.reflect.macros.blackbox.Context
-object Bundle extends BlackboxMacro {
- val c: BlackboxContext = ???
+object Bundle {
+ val c: Context = ???
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-overloaded.check b/test/files/neg/macro-bundle-overloaded.check
new file mode 100644
index 0000000000..fc94ff0000
--- /dev/null
+++ b/test/files/neg/macro-bundle-overloaded.check
@@ -0,0 +1,4 @@
+macro-bundle-overloaded.scala:11: error: macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter
+ def foo = macro Bundle.impl
+ ^
+one error found
diff --git a/test/files/neg/macro-bundle-overloaded.scala b/test/files/neg/macro-bundle-overloaded.scala
new file mode 100644
index 0000000000..a4bc66f974
--- /dev/null
+++ b/test/files/neg/macro-bundle-overloaded.scala
@@ -0,0 +1,12 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.{Context => BlackboxContext}
+import scala.reflect.macros.whitebox.{Context => WhiteboxContext}
+
+class Bundle(val c: BlackboxContext) {
+ def this(c: WhiteboxContext) = this(c: BlackboxContext)
+ def impl = ???
+}
+
+object Macros {
+ def foo = macro Bundle.impl
+} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check
deleted file mode 100644
index e024fcde93..0000000000
--- a/test/files/neg/macro-bundle-polymorphic.check
+++ /dev/null
@@ -1,10 +0,0 @@
-macro-bundle-polymorphic.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
- def foo = macro Bundle.impl
- ^
-macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
- def foo = macro Bundle[Int].impl
- ^
-macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
- def foo = macro Bundle[Int, Nothing].impl
- ^
-three errors found
diff --git a/test/files/neg/macro-bundle-polymorphic.scala b/test/files/neg/macro-bundle-polymorphic.scala
deleted file mode 100644
index faf1e2e9e5..0000000000
--- a/test/files/neg/macro-bundle-polymorphic.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
-
-trait Bundle[T] extends BlackboxMacro {
- def impl = ???
-}
-
-object Macros {
- def foo = macro Bundle.impl
- def foo = macro Bundle[Int].impl
- def foo = macro Bundle[Int, Nothing].impl
-} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check
index 3cb7985013..869c67e1e3 100644
--- a/test/files/neg/macro-bundle-trait.check
+++ b/test/files/neg/macro-bundle-trait.check
@@ -1,4 +1,4 @@
-macro-bundle-trait.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member
+macro-bundle-trait.scala:10: error: not found: value Bundle
def foo = macro Bundle.impl
^
one error found
diff --git a/test/files/neg/macro-bundle-trait.scala b/test/files/neg/macro-bundle-trait.scala
index 62ade49953..2aa63216f5 100644
--- a/test/files/neg/macro-bundle-trait.scala
+++ b/test/files/neg/macro-bundle-trait.scala
@@ -1,9 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
-trait Bundle extends BlackboxMacro {
- val c: BlackboxContext = ???
+trait Bundle {
+ val c: Context = ???
def impl = ???
}
diff --git a/test/files/neg/macro-cyclic/Impls_Macros_1.scala b/test/files/neg/macro-cyclic/Impls_Macros_1.scala
index ba08345bcc..ad6890144d 100644
--- a/test/files/neg/macro-cyclic/Impls_Macros_1.scala
+++ b/test/files/neg/macro-cyclic/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
c.universe.reify { implicitly[SourceLocation] }
}
diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala
index 9fb374800b..186c285871 100644
--- a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala
+++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
trait Complex[T]
@@ -6,7 +6,7 @@ trait Complex[T]
class Foo(val foo: Foo)
object Complex {
- def impl[T: c.WeakTypeTag](c: WhiteboxContext): c.Expr[Complex[T]] = {
+ def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = {
import c.universe._
val tpe = weakTypeOf[T]
for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) {
diff --git a/test/files/neg/macro-exception/Macros_1.scala b/test/files/neg/macro-exception/Macros_1.scala
index 7bd8415e4f..3d6109dc9d 100644
--- a/test/files/neg/macro-exception/Macros_1.scala
+++ b/test/files/neg/macro-exception/Macros_1.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
throw new Exception()
}
def exception = macro impl
diff --git a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala
index 1bd808d55d..a97dfd4ddf 100644
--- a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala
+++ b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala
@@ -1,11 +1,11 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Helper {
def unapplySeq[T](x: List[T]): Option[Seq[T]] =
}
object Macros {
- def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[List[T]]) = {
+ def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = {
c.universe.reify(Helper.unapplySeq(x.splice))
}
diff --git a/test/files/neg/macro-incompatible-macro-engine.check b/test/files/neg/macro-incompatible-macro-engine.check
new file mode 100644
index 0000000000..1d582e5ed6
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine.check
@@ -0,0 +1,7 @@
+Test_3.scala:2: error: macro cannot be expanded, because it was compiled by an incompatible macro engine vxxx (implemented in the incompatibleMacroEngine plugin)
+ Macros.foo
+ ^
+Test_3.scala:3: error: macro cannot be expanded, because it was compiled by an incompatible macro engine vxxx (implemented in the incompatibleMacroEngine plugin)
+ Macros.foo
+ ^
+two errors found
diff --git a/test/files/neg/macro-incompatible-macro-engine/Macros_2.flags b/test/files/neg/macro-incompatible-macro-engine/Macros_2.flags
new file mode 100644
index 0000000000..966df731d0
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine/Macros_2.flags
@@ -0,0 +1 @@
+-Xplugin:. \ No newline at end of file
diff --git a/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala b/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala
new file mode 100644
index 0000000000..39708eee49
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala
@@ -0,0 +1,7 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl(c: Context) = c.universe.Literal(c.universe.Constant(()))
+ def foo: Unit = macro impl
+} \ No newline at end of file
diff --git a/test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala b/test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala
new file mode 100644
index 0000000000..44ed91d2fb
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala
@@ -0,0 +1,35 @@
+package incompatibleMacroEngine
+
+import scala.tools.nsc.Global
+import scala.tools.nsc.plugins.{Plugin => NscPlugin}
+
+class Plugin(val global: Global) extends NscPlugin {
+ import global._
+ import analyzer._
+
+ val name = "incompatibleMacroEngine"
+ val description = "A sample analyzer plugin that crafts a macro impl binding with a non-standard macro engine."
+ val components = Nil
+ addMacroPlugin(MacroPlugin)
+
+ object MacroPlugin extends MacroPlugin {
+ def fixupBinding(tree: Tree) = new Transformer {
+ override def transform(tree: Tree) = {
+ tree match {
+ case Literal(const @ Constant(x)) if tree.tpe == null => tree setType ConstantType(const)
+ case _ if tree.tpe == null => tree setType NoType
+ case _ => ;
+ }
+ super.transform(tree)
+ }
+ }.transform(tree)
+
+ override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = {
+ val result = standardTypedMacroBody(typer, ddef)
+ val List(AnnotationInfo(atp, List(Apply(nucleus, _ :: others)), Nil)) = ddef.symbol.annotations
+ val updatedBinding = Apply(nucleus, Assign(Literal(Constant("macroEngine")), Literal(Constant("vxxx (implemented in the incompatibleMacroEngine plugin)"))) :: others)
+ ddef.symbol.setAnnotations(List(AnnotationInfo(atp, List(fixupBinding(updatedBinding)), Nil)))
+ Some(result)
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/macro-incompatible-macro-engine/Test_3.scala b/test/files/neg/macro-incompatible-macro-engine/Test_3.scala
new file mode 100644
index 0000000000..7e4fae5236
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine/Test_3.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ Macros.foo
+ Macros.foo
+} \ No newline at end of file
diff --git a/test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml b/test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml
new file mode 100644
index 0000000000..42b9cdd75d
--- /dev/null
+++ b/test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml
@@ -0,0 +1,4 @@
+<plugin>
+ <name>incompatible-macro-engine</name>
+ <classname>incompatibleMacroEngine.Plugin</classname>
+</plugin> \ No newline at end of file
diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check
index 5eff401bef..ea7d71c667 100644
--- a/test/files/neg/macro-invalidimpl.check
+++ b/test/files/neg/macro-invalidimpl.check
@@ -19,28 +19,28 @@ macro [<macro bundle>].<method name>[[<type args>]]
def foo(x: Any) = macro Impls4.foo
^
Macros_Test_2.scala:26: error: ambiguous reference to overloaded definition,
-both method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any])Nothing
-and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any])Nothing
+both method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing
+and method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any])Nothing
match expected type ?
def foo(x: Any) = macro Impls5.foo
^
Macros_Test_2.scala:27: error: ambiguous reference to overloaded definition,
-both method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any])Nothing
-and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any])Nothing
+both method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing
+and method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any])Nothing
match expected type ?
def foo(x: Any, y: Any) = macro Impls5.foo
^
Macros_Test_2.scala:31: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit]
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Unit]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(): c.Expr[Unit]
number of parameter sections differ
def foo1 = macro Impls6.fooEmpty
^
Macros_Test_2.scala:32: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit]
- or : (c: scala.reflect.macros.BlackboxContext)(): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit]
+ required: (c: scala.reflect.macros.blackbox.Context)(): c.Expr[Unit]
+ or : (c: scala.reflect.macros.blackbox.Context)(): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context): c.Expr[Unit]
number of parameter sections differ
def bar1() = macro Impls6.fooNullary
^
diff --git a/test/files/neg/macro-invalidimpl/Impls_1.scala b/test/files/neg/macro-invalidimpl/Impls_1.scala
index b85ac9ee43..a1c885a4bf 100644
--- a/test/files/neg/macro-invalidimpl/Impls_1.scala
+++ b/test/files/neg/macro-invalidimpl/Impls_1.scala
@@ -1,39 +1,39 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
class Impls1 {
- def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
object Impls2 {
- def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
trait MacroHelpers {
object Impls4 {
- def foo(c: BlackboxContext)(x: c.Expr[Any]) = x
+ def foo(c: Context)(x: c.Expr[Any]) = x
}
}
object Impls5 {
- def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
- def foo(c: BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any], y: c.Expr[Any]) = ???
}
object Impls6 {
- def fooNullary(c: BlackboxContext) = {
+ def fooNullary(c: Context) = {
import c.universe._
c.Expr[Unit](q"""Predef.println("it works")""")
}
- def fooEmpty(c: BlackboxContext)() = fooNullary(c)
+ def fooEmpty(c: Context)() = fooNullary(c)
}
object Impls7 {
- def foo[U <: Int](c: BlackboxContext) = ???
+ def foo[U <: Int](c: Context) = ???
}
package foo {
object Impls8 {
- private[foo] def impl(c: BlackboxContext) = ???
+ private[foo] def impl(c: Context) = ???
}
} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidimpl/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala
index 0df7d2e0c5..6760d99959 100644
--- a/test/files/neg/macro-invalidimpl/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros1 {
val impls = new Impls1
@@ -12,7 +12,7 @@ object Macros2 {
class Macros3 {
object Impls3 {
- def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
def foo(x: Any) = macro Impls3.foo
diff --git a/test/files/neg/macro-invalidret.check b/test/files/neg/macro-invalidret.check
index 6c5baf76b4..99f29e57ce 100644
--- a/test/files/neg/macro-invalidret.check
+++ b/test/files/neg/macro-invalidret.check
@@ -1,14 +1,14 @@
Macros_Test_2.scala:2: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext): Int
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Any]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context): Int
type mismatch for return type: Int does not conform to c.Expr[Any]
def foo1 = macro Impls.foo1
^
Macros_Test_2.scala:3: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext): reflect.runtime.universe.Literal
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Any]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context): reflect.runtime.universe.Literal
type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any]
def foo2 = macro Impls.foo2
^
diff --git a/test/files/neg/macro-invalidret/Impls_1.scala b/test/files/neg/macro-invalidret/Impls_1.scala
index b32463899e..434aeef10f 100644
--- a/test/files/neg/macro-invalidret/Impls_1.scala
+++ b/test/files/neg/macro-invalidret/Impls_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.runtime.{universe => ru}
object Impls {
- def foo1(c: BlackboxContext) = 2
- def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42))
- def foo3(c: BlackboxContext) = ???
- def foo5(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(42))
- def foo6(c: BlackboxContext) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42)))
+ def foo1(c: Context) = 2
+ def foo2(c: Context) = ru.Literal(ru.Constant(42))
+ def foo3(c: Context) = ???
+ def foo5(c: Context) = c.universe.Literal(c.universe.Constant(42))
+ def foo6(c: Context) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42)))
}
diff --git a/test/files/neg/macro-invalidshape/Impls_1.scala b/test/files/neg/macro-invalidshape/Impls_1.scala
index 3d5da9a2ed..acc6b52b7b 100644
--- a/test/files/neg/macro-invalidshape/Impls_1.scala
+++ b/test/files/neg/macro-invalidshape/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
diff --git a/test/files/neg/macro-invalidshape/Macros_Test_2.scala b/test/files/neg/macro-invalidshape/Macros_Test_2.scala
index 8f643ab281..160bbf5f53 100644
--- a/test/files/neg/macro-invalidshape/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidshape/Macros_Test_2.scala
@@ -3,7 +3,7 @@ object Macros {
def foo2(x: Any) = macro Impls.foo(null)(null)
def foo3(x: Any) = macro {2; Impls.foo}
{
- def impl(c: scala.reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: scala.reflect.macros.blackbox.Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo = macro impl
foo
}
diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check
index d6b5c5521d..159754c72e 100644
--- a/test/files/neg/macro-invalidsig-params-badtype.check
+++ b/test/files/neg/macro-invalidsig-params-badtype.check
@@ -1,7 +1,7 @@
Impls_Macros_1.scala:8: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(x: Int): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(x: Int): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to Int
def foo(x: Int) = macro Impls.foo
^
diff --git a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala
index 5f468424bd..e549cc9576 100644
--- a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala
+++ b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: Int) = ???
+ def foo(c: Context)(x: Int) = ???
}
object Macros {
diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check
index 5ff4ed18cb..8898ffc3de 100644
--- a/test/files/neg/macro-invalidsig.check
+++ b/test/files/neg/macro-invalidsig.check
@@ -2,30 +2,30 @@ Macros_Test_2.scala:2: error: macro implementations cannot have implicit paramet
def foo[U]: Int = macro Impls1.foo[U]
^
Macros_Test_2.scala:6: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
found : : Nothing
number of parameter sections differ
def foo = macro Impls2.foo
^
Macros_Test_2.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
found : (c: scala.reflect.api.Universe): Nothing
-type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe
+type mismatch for parameter c: scala.reflect.macros.blackbox.Context does not conform to scala.reflect.api.Universe
def foo = macro Impls3.foo
^
Macros_Test_2.scala:14: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
- found : (cs: scala.reflect.macros.BlackboxContext*): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
+ found : (cs: scala.reflect.macros.blackbox.Context*): Nothing
types incompatible for parameter cs: corresponding is not a vararg parameter
def foo = macro Impls4.foo
^
Macros_Test_2.scala:18: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context): Nothing
number of parameter sections differ
def foo(x: Any) = macro Impls5.foo
^
@@ -33,37 +33,37 @@ Macros_Test_2.scala:22: error: macro implementations cannot have implicit parame
def foo[U](x: Int) = macro Impls6.foo[T, U]
^
Macros_Test_2.scala:26: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing
parameter lists have different length, found extra parameter y: c.Expr[Int]
def foo(x: Int) = macro Impls7.foo
^
Macros_Test_2.scala:30: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(x: c.universe.Symbol): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(x: c.universe.Symbol): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol
def foo(x: Int) = macro Impls8.foo
^
Macros_Test_2.scala:34: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[Int]*): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree, y: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(xs: c.Expr[Int]*): Nothing
parameter lists have different length, required extra parameter y: c.Expr[Int]
def foo(x: Int, y: Int) = macro Impls9.foo
^
Macros_Test_2.scala:38: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree, y: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing
parameter names differ: x != y
def foo(x: Int, y: Int) = macro Impls10.foo
^
Macros_Test_2.scala:42: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
- or : (c: scala.reflect.macros.BlackboxContext): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing
+ required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing]
+ or : (c: scala.reflect.macros.blackbox.Context): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(U: c.universe.Type): Nothing
number of parameter sections differ
def foo[U] = macro Impls11.foo[U]
^
@@ -73,13 +73,13 @@ Macros_Test_2.scala:46: error: type arguments [U] do not conform to method foo's
Macros_Test_2.scala:50: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String]
def foo[U <: Int] = macro Impls13.foo[U]
^
-Macros_Test_2.scala:54: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.BlackboxContext)(implicit evidence$4: c.WeakTypeTag[U])Nothing
+Macros_Test_2.scala:54: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.blackbox.Context)(implicit evidence$4: c.WeakTypeTag[U])Nothing
def foo = macro Impls14.foo
^
-Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.blackbox.Context)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo15[V]: Unit = macro Impls15.foo
^
-Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.blackbox.Context)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo16[V]: Unit = macro Impls16.foo[V]
^
16 errors found
diff --git a/test/files/neg/macro-invalidsig/Impls_1.scala b/test/files/neg/macro-invalidsig/Impls_1.scala
index 7c98160925..b0a3912380 100644
--- a/test/files/neg/macro-invalidsig/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig/Impls_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls1 {
- def foo[U: c.WeakTypeTag: Numeric](c: BlackboxContext) = { import c.universe._; q"42" }
+ def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" }
}
object Impls2 {
@@ -14,15 +14,15 @@ object Impls3 {
}
object Impls4 {
- def foo(cs: BlackboxContext*) = ???
+ def foo(cs: Context*) = ???
}
object Impls5 {
- def foo(c: BlackboxContext) = ???
+ def foo(c: Context) = ???
}
object Impls6 {
- def foo[T, U: c.WeakTypeTag](c: BlackboxContext)(implicit x: c.Expr[Int]) = {
+ def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = {
import c.{prefix => prefix}
import c.universe._
c.Expr[Unit](q"""
@@ -34,39 +34,39 @@ object Impls6 {
}
object Impls7 {
- def foo(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]) = ???
+ def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = ???
}
object Impls8 {
- def foo(c: BlackboxContext)(x: c.universe.Symbol) = ???
+ def foo(c: Context)(x: c.universe.Symbol) = ???
}
object Impls9 {
- def foo(c: BlackboxContext)(xs: c.Expr[Int]*) = ???
+ def foo(c: Context)(xs: c.Expr[Int]*) = ???
}
object Impls10 {
- def foo(c: BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]) = ???
+ def foo(c: Context)(y: c.Expr[Int], x: c.Expr[Int]) = ???
}
object Impls11 {
- def foo[U](c: BlackboxContext)(U: c.universe.Type) = ???
+ def foo[U](c: Context)(U: c.universe.Type) = ???
}
object Impls12 {
- def foo[U <: String](c: BlackboxContext) = ???
+ def foo[U <: String](c: Context) = ???
}
object Impls13 {
- def foo[U <: String](c: BlackboxContext) = ???
+ def foo[U <: String](c: Context) = ???
}
object Impls14 {
- def foo[U: c.WeakTypeTag](c: BlackboxContext) = ???
+ def foo[U: c.WeakTypeTag](c: Context) = ???
}
object Impls15 {
- def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
println(implicitly[c.WeakTypeTag[T]])
println(implicitly[c.WeakTypeTag[U]])
@@ -76,7 +76,7 @@ object Impls15 {
}
object Impls16 {
- def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
println(implicitly[c.WeakTypeTag[T]])
println(implicitly[c.WeakTypeTag[U]])
diff --git a/test/files/neg/macro-invalidusage-badargs/Impls_1.scala b/test/files/neg/macro-invalidusage-badargs/Impls_1.scala
index 678cb53929..8765cfbd5f 100644
--- a/test/files/neg/macro-invalidusage-badargs/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badargs/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = x
+ def foo(c: Context)(x: c.Expr[Int]) = x
}
diff --git a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala
index 393f7de976..1769da91e1 100644
--- a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U <: String](c: Ctx) = { import c.universe._; c.Expr[Unit](q"()") }
+ def foo[U <: String](c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
}
diff --git a/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala b/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala
index 678cb53929..8765cfbd5f 100644
--- a/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = x
+ def foo(c: Context)(x: c.Expr[Int]) = x
}
diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
index 15894efb68..776f8bf71c 100644
--- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.universe._
c.Expr[Unit](q"""println("it works")""")
}
diff --git a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala
index 44e508a1c6..b6b9611743 100644
--- a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala
+++ b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.universe._
val body = Ident(TermName("IDoNotExist"))
c.Expr[Int](body)
diff --git a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala
index 02c87b5a81..ea98f01fa4 100644
--- a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
} \ No newline at end of file
diff --git a/test/files/neg/macro-noexpand/Impls_1.scala b/test/files/neg/macro-noexpand/Impls_1.scala
index 3d5da9a2ed..acc6b52b7b 100644
--- a/test/files/neg/macro-noexpand/Impls_1.scala
+++ b/test/files/neg/macro-noexpand/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
diff --git a/test/files/neg/macro-nontypeablebody/Impls_1.scala b/test/files/neg/macro-nontypeablebody/Impls_1.scala
index 3d5da9a2ed..acc6b52b7b 100644
--- a/test/files/neg/macro-nontypeablebody/Impls_1.scala
+++ b/test/files/neg/macro-nontypeablebody/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Any]) = ???
+ def foo(c: Context)(x: c.Expr[Any]) = ???
}
diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
index 9c05db83e3..916b454463 100644
--- a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
+++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: Ctx)(x: c.Expr[Int]) = x
+ def impl(c: Context)(x: c.Expr[Int]) = x
}
trait Foo {
diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala
index c98279b2b8..17827abf7a 100644
--- a/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala
+++ b/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
trait T { def t(): Unit }
trait A { def t(): Unit = () }
-object Macro { def t(c: BlackboxContext)(): c.Expr[Unit] = c.universe.reify(()) }
+object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
trait C extends T { self: A => override def t(): Unit = macro Macro.t }
diff --git a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala
index f2d3f67ccc..f3917e3093 100644
--- a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala
+++ b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala
@@ -1,14 +1,14 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
+ def impl(c: Context)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
import c.universe._
c.Expr[Unit](q"println($tag, ${prefix.toString}, $x)")
}
- def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x)
- def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x)
- def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x)
- def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x)
+ def fooBString(c: Context)(x: c.Expr[_]) = impl(c)("fooBString", x)
+ def fooBInt(c: Context)(x: c.Expr[_]) = impl(c)("fooBInt", x)
+ def fooDInt(c: Context)(x: c.Expr[_]) = impl(c)("fooDInt", x)
+ def fooZString(c: Context)(x: c.Expr[_]) = impl(c)("fooZString", x)
} \ No newline at end of file
diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala
index 098e4b3b92..b123c475c2 100644
--- a/test/files/neg/macro-quasiquotes/Macros_1.scala
+++ b/test/files/neg/macro-quasiquotes/Macros_1.scala
@@ -1,7 +1,7 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.blackbox.Context
-trait Impls extends BlackboxMacro {
+class Impls(val c: Context) {
import c.universe._
def impl1(x: Expr[Int]) = q"println(x)"
def impl2(x: Tree) = q"println(x)"
diff --git a/test/files/neg/macro-reify-splice-splice/Macros_1.scala b/test/files/neg/macro-reify-splice-splice/Macros_1.scala
index 691f22ad07..306e78ad97 100644
--- a/test/files/neg/macro-reify-splice-splice/Macros_1.scala
+++ b/test/files/neg/macro-reify-splice-splice/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo = macro Impls.foo
object Impls {
- def foo(c: Ctx) = c.universe.reify {
+ def foo(c: Context) = c.universe.reify {
{ c.universe.reify(c.universe.reify("hello world")) }.splice.splice
}
}
diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
index 6b73a96184..035913f3e3 100644
--- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
@@ -1,17 +1,17 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 1")
}
- def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 2")
}
- def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 3")
}
diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
index 6b73a96184..035913f3e3 100644
--- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
@@ -1,17 +1,17 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 1")
}
- def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 2")
}
- def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(q"$x + 3")
}
diff --git a/test/files/neg/t2066.check b/test/files/neg/t2066.check
new file mode 100644
index 0000000000..efade87e26
--- /dev/null
+++ b/test/files/neg/t2066.check
@@ -0,0 +1,21 @@
+t2066.scala:6: error: overriding method f in trait A1 of type [T[_]]=> Unit;
+ method f has incompatible type
+ override def f[T[+_]] = ()
+ ^
+t2066.scala:10: error: overriding method f in trait A1 of type [T[_]]=> Unit;
+ method f has incompatible type
+ override def f[T[-_]] = ()
+ ^
+t2066.scala:23: error: overriding method f in trait A2 of type [T[+_]]=> Unit;
+ method f has incompatible type
+ override def f[T[-_]] = ()
+ ^
+t2066.scala:45: error: overriding method f in trait A4 of type [T[X[+_]]]=> Unit;
+ method f has incompatible type
+ override def f[T[X[_]]] = ()
+ ^
+t2066.scala:53: error: overriding method f in trait A5 of type [T[X[-_]]]=> Unit;
+ method f has incompatible type
+ override def f[T[X[_]]] = ()
+ ^
+5 errors found
diff --git a/test/files/neg/t2066.scala b/test/files/neg/t2066.scala
new file mode 100644
index 0000000000..7f15d39c67
--- /dev/null
+++ b/test/files/neg/t2066.scala
@@ -0,0 +1,70 @@
+trait A1 {
+ def f[T[_]] = ()
+}
+
+trait B1 extends A1 {
+ override def f[T[+_]] = ()
+}
+
+trait C1 extends A1 {
+ override def f[T[-_]] = ()
+}
+
+
+trait A2 {
+ def f[T[+_]] = ()
+}
+
+trait B2 extends A2 {
+ override def f[T[_]] = () // okay
+}
+
+trait C2 extends A2 {
+ override def f[T[-_]] = ()
+}
+
+
+trait A3 {
+ def f[T[-_]] = ()
+}
+
+trait B3 extends A3 {
+ override def f[T[_]] = () // okay
+}
+
+trait C3 extends A3 {
+ override def f[T[-_]] = ()
+}
+
+
+trait A4 {
+ def f[T[X[+_]]] = ()
+}
+
+trait B4 extends A4 {
+ override def f[T[X[_]]] = ()
+}
+
+trait A5 {
+ def f[T[X[-_]]] = ()
+}
+
+trait B5 extends A5 {
+ override def f[T[X[_]]] = ()
+}
+
+
+
+trait A6 {
+ def f[T[X[_]]] = ()
+}
+
+trait B6 extends A6 {
+ override def f[T[X[+_]]] = () // okay
+}
+trait C6 extends A6 {
+ override def f[T[X[_]]] = () // okay
+}
+trait D6 extends A6 {
+ override def f[T[X[-_]]] = ()
+}
diff --git a/test/files/neg/t2066b.check b/test/files/neg/t2066b.check
new file mode 100644
index 0000000000..097c44fef3
--- /dev/null
+++ b/test/files/neg/t2066b.check
@@ -0,0 +1,5 @@
+t2066b.scala:7: error: overriding method f in trait A of type [T[_]](x: T[Int])T[Any];
+ method f has incompatible type
+ def f[T[+_]](x : T[Int]) : T[Any] = x
+ ^
+one error found
diff --git a/test/pending/neg/t2066.scala b/test/files/neg/t2066b.scala
index 46177b19f7..46177b19f7 100644
--- a/test/pending/neg/t2066.scala
+++ b/test/files/neg/t2066b.scala
diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check
index 95b88a6b3d..00006c08f0 100644
--- a/test/files/neg/t4425.check
+++ b/test/files/neg/t4425.check
@@ -1,12 +1,12 @@
-t4425.scala:3: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425.scala:3: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: Int)(y: Option[Int]): None.type exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
42 match { case _ X _ => () }
^
-t4425.scala:8: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425.scala:8: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: Int)(y: Int): Some[(Int, Int)] exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
42 match { case _ X _ => () }
^
-t4425.scala:13: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425.scala:13: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Some[(Int, Int)] exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
"" match { case _ X _ => () }
^
diff --git a/test/files/neg/t4425b.check b/test/files/neg/t4425b.check
index 1186e8b609..8418b4fd12 100644
--- a/test/files/neg/t4425b.check
+++ b/test/files/neg/t4425b.check
@@ -1,61 +1,49 @@
-t4425b.scala:5: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:5: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println( "" match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:6: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:6: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:7: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:7: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println( "" match { case X(_) => "ok" ; case _ => "fail" })
^
-t4425b.scala:8: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:8: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println((X: Any) match { case X(_) => "ok" ; case _ => "fail" })
^
-t4425b.scala:9: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:9: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:10: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method
+t4425b.scala:10: error: object X is not a case class, nor does it have an unapply/unapplySeq member
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:18: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:18: error: too many patterns for object X: expected 1, found 2
println( "" match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:19: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:19: error: too many patterns for object X: expected 1, found 2
println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:22: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:22: error: too many patterns for object X: expected 1, found 2
println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:22: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
- println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
- ^
-t4425b.scala:23: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:23: error: too many patterns for object X: expected 1, found 2
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:23: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
- println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
- ^
-t4425b.scala:31: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:31: error: too many patterns for object X offering Nothing: expected 1, found 2
println( "" match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:32: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:32: error: too many patterns for object X offering Nothing: expected 1, found 2
println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:35: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:35: error: too many patterns for object X offering Nothing: expected 1, found 2
println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:35: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
- println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
- ^
-t4425b.scala:36: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
+t4425b.scala:36: error: too many patterns for object X offering Nothing: expected 1, found 2
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:36: error: wrong number of patterns for object X offering Nothing: expected 1, found 2
- println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
- ^
-18 errors found
+14 errors found
diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check
index 9271f709ca..7d4f7fb63a 100644
--- a/test/files/neg/t5689.check
+++ b/test/files/neg/t5689.check
@@ -1,7 +1,7 @@
t5689.scala:4: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[String]
- or : (c: scala.reflect.macros.BlackboxContext)(i: c.Tree): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[Int]
+ required: (c: scala.reflect.macros.blackbox.Context)(i: c.Expr[Double]): c.Expr[String]
+ or : (c: scala.reflect.macros.blackbox.Context)(i: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(i: c.Expr[Double]): c.Expr[Int]
type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String]
def returnsString(i: Double): String = macro returnsIntImpl
^
diff --git a/test/files/neg/t5689.scala b/test/files/neg/t5689.scala
index d0e468849d..d757a55417 100644
--- a/test/files/neg/t5689.scala
+++ b/test/files/neg/t5689.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
def returnsString(i: Double): String = macro returnsIntImpl
- def returnsIntImpl(c: BlackboxContext)(i: c.Expr[Double]): c.Expr[Int] = ???
+ def returnsIntImpl(c: Context)(i: c.Expr[Double]): c.Expr[Int] = ???
}
diff --git a/test/files/neg/t5753/Impls_Macros_1.scala b/test/files/neg/t5753/Impls_Macros_1.scala
index 0e81e21c77..9872c69171 100644
--- a/test/files/neg/t5753/Impls_Macros_1.scala
+++ b/test/files/neg/t5753/Impls_Macros_1.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
trait Impls {
- def impl(c: Ctx)(x: c.Expr[Any]) = x
+ def impl(c: Context)(x: c.Expr[Any]) = x
}
diff --git a/test/files/neg/t5753/Test_2.scala b/test/files/neg/t5753/Test_2.scala
index 150850a0eb..d52ed65c60 100644
--- a/test/files/neg/t5753/Test_2.scala
+++ b/test/files/neg/t5753/Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros extends Impls {
def foo(x: Any): Any = macro impl
diff --git a/test/files/neg/t5903a.check b/test/files/neg/t5903a.check
index 2e5cc87167..34003b0a82 100644
--- a/test/files/neg/t5903a.check
+++ b/test/files/neg/t5903a.check
@@ -1,4 +1,4 @@
-Test_2.scala:4: error: wrong number of patterns for <$anon: AnyRef> offering (SomeTree.type, SomeTree.type): expected 2, found 3
+Test_2.scala:4: error: too many patterns for <$anon: AnyRef> offering (SomeTree.type, SomeTree.type): expected 2, found 3
case nq"$x + $y + $z" => println((x, y))
^
one error found
diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala
index ce1b035260..5d084ceed5 100644
--- a/test/files/neg/t5903a/Macros_1.scala
+++ b/test/files/neg/t5903a/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
trait Tree
@@ -13,7 +13,7 @@ object NewQuasiquotes {
}
object QuasiquoteMacros {
- def unapplyImpl(c: WhiteboxContext)(t: c.Tree) = {
+ def unapplyImpl(c: Context)(t: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/neg/t5903b/Macros_1.scala b/test/files/neg/t5903b/Macros_1.scala
index dfe9d8d489..6ce49c0228 100644
--- a/test/files/neg/t5903b/Macros_1.scala
+++ b/test/files/neg/t5903b/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/neg/t5903c/Macros_1.scala b/test/files/neg/t5903c/Macros_1.scala
index d13c3c2ec2..4792f00454 100644
--- a/test/files/neg/t5903c/Macros_1.scala
+++ b/test/files/neg/t5903c/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
import c.universe._
if (!(c.weakTypeOf[Int] =:= c.weakTypeOf[T])) c.abort(c.enclosingPosition, s"${c.weakTypeOf[T]} is not supported")
else {
diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala
index 2d26e998a1..3500c2a782 100644
--- a/test/files/neg/t5903d/Macros_1.scala
+++ b/test/files/neg/t5903d/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: BlackboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
import c.universe._
q"""
class Match(x: Int) {
diff --git a/test/files/neg/t5903e/Macros_1.scala b/test/files/neg/t5903e/Macros_1.scala
index 5bdc25b832..a64ff7e0b9 100644
--- a/test/files/neg/t5903e/Macros_1.scala
+++ b/test/files/neg/t5903e/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/neg/t6123-explaintypes-macros.check b/test/files/neg/t6123-explaintypes-macros.check
index ef545fcc32..2c86f3c9cc 100644
--- a/test/files/neg/t6123-explaintypes-macros.check
+++ b/test/files/neg/t6123-explaintypes-macros.check
@@ -1,9 +1,9 @@
c.universe.Expr[Any]* <: c.universe.Expr[String]*?
false
BadMac_2.scala:6: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit]
- or : (c: scala.reflect.macros.BlackboxContext)(format: c.Tree, params: Tree*): c.Tree
- found : (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit]
+ required: (c: scala.reflect.macros.blackbox.Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit]
+ or : (c: scala.reflect.macros.blackbox.Context)(format: c.Tree, params: Tree*): c.Tree
+ found : (c: scala.reflect.macros.blackbox.Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit]
type mismatch for parameter params: c.Expr[Any]* does not conform to c.Expr[String]*
def printf(format: String, params: Any*): Unit = macro printf_impl
^
diff --git a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala
index 456e753893..75ded4ef7d 100644
--- a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala
+++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
// explain some macro types to me
object BadMac {
def printf(format: String, params: Any*): Unit = macro printf_impl
- def printf_impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ???
+ def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ???
}
diff --git a/test/files/neg/t6123-explaintypes-macros/Macros.scala b/test/files/neg/t6123-explaintypes-macros/Macros.scala
index cdcea34272..f2238b39a7 100644
--- a/test/files/neg/t6123-explaintypes-macros/Macros.scala
+++ b/test/files/neg/t6123-explaintypes-macros/Macros.scala
@@ -1,9 +1,9 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
def printf(format: String, params: Any*): Unit = macro printf_impl
- def printf_impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ???
+ def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ???
}
// something trivial to run
diff --git a/test/files/neg/t6539/Macro_1.scala b/test/files/neg/t6539/Macro_1.scala
index 454489752c..60db669c46 100644
--- a/test/files/neg/t6539/Macro_1.scala
+++ b/test/files/neg/t6539/Macro_1.scala
@@ -1,9 +1,9 @@
import language.experimental.macros
-import reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object M {
def m(a: Any, b: Any): Any = macro mImpl
- def mImpl(c: BlackboxContext)(a: c.Expr[Any], b: c.Expr[Any]) = c.universe.reify(println(a.splice))
+ def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = c.universe.reify(println(a.splice))
@reflect.internal.annotations.compileTimeOnly("cto may only be used as an argument to " + "m")
def cto = 0
diff --git a/test/files/neg/t6675b.check b/test/files/neg/t6675b.check
new file mode 100644
index 0000000000..77f6b3ccbc
--- /dev/null
+++ b/test/files/neg/t6675b.check
@@ -0,0 +1,37 @@
+t6675b.scala:17: warning: object LeftOrRight expects 2 patterns to hold (Int, Int) but crushing into 2-tuple to fit single pattern (SI-6675)
+ def f1 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case LeftOrRight(a) => a } // warn
+ ^
+t6675b.scala:19: error: constructor cannot be instantiated to expected type;
+ found : (T1, T2, T3)
+ required: (Int, Int)
+ def f3 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case LeftOrRight((a, b, c)) => a } // fail
+ ^
+t6675b.scala:24: warning: object LeftOrRight expects 2 patterns to hold (A, A) but crushing into 2-tuple to fit single pattern (SI-6675)
+ def f2[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case LeftOrRight(a) => a } // warn
+ ^
+t6675b.scala:26: error: constructor cannot be instantiated to expected type;
+ found : (T1, T2, T3)
+ required: (?A11, ?A12) where type ?A12 <: A (this is a GADT skolem), type ?A11 <: A (this is a GADT skolem)
+ def f4[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case LeftOrRight((a, b, c)) => a } // fail
+ ^
+t6675b.scala:30: warning: object NativelyTwo expects 2 patterns to hold ((Int, Int), (Int, Int)) but crushing into 2-tuple to fit single pattern (SI-6675)
+ def f1 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case NativelyTwo(a) => a } // warn
+ ^
+t6675b.scala:32: error: constructor cannot be instantiated to expected type;
+ found : (T1, T2, T3)
+ required: ((Int, Int), (Int, Int))
+ def f3 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case NativelyTwo((a, b, c)) => a } // fail
+ ^
+t6675b.scala:36: warning: object NativelyTwo expects 2 patterns to hold (A, A) but crushing into 2-tuple to fit single pattern (SI-6675)
+ def f1[A](x: A) = (Left(x): Either[A, A]) match { case NativelyTwo(a) => a } // warn
+ ^
+t6675b.scala:37: warning: object NativelyTwo expects 2 patterns to hold ((A, A), (A, A)) but crushing into 2-tuple to fit single pattern (SI-6675)
+ def f2[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case NativelyTwo(a) => a } // warn
+ ^
+t6675b.scala:39: error: constructor cannot be instantiated to expected type;
+ found : (T1, T2, T3)
+ required: ((?A17, ?A18), (?A19, ?A20)) where type ?A20 <: A (this is a GADT skolem), type ?A19 <: A (this is a GADT skolem), type ?A18 <: A (this is a GADT skolem), type ?A17 <: A (this is a GADT skolem)
+ def f4[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case NativelyTwo((a, b, c)) => a } // fail
+ ^
+5 warnings found
+four errors found
diff --git a/test/files/neg/t6675b.flags b/test/files/neg/t6675b.flags
new file mode 100644
index 0000000000..1008b0a70c
--- /dev/null
+++ b/test/files/neg/t6675b.flags
@@ -0,0 +1 @@
+-Xlint
diff --git a/test/files/neg/t6675b.scala b/test/files/neg/t6675b.scala
new file mode 100644
index 0000000000..c86c9c3955
--- /dev/null
+++ b/test/files/neg/t6675b.scala
@@ -0,0 +1,40 @@
+object LeftOrRight {
+ def unapply[A](value: Either[A, A]): Option[A] = value match {
+ case scala.Left(x) => Some(x)
+ case scala.Right(x) => Some(x)
+ }
+}
+
+object NativelyTwo {
+ def unapply[A](value: Either[A, A]): Option[(A, A)] = value match {
+ case scala.Left(x) => Some(x -> x)
+ case scala.Right(x) => Some(x -> x)
+ }
+}
+
+
+class A {
+ def f1 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case LeftOrRight(a) => a } // warn
+ def f2 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case LeftOrRight((a, b)) => a } // no warn
+ def f3 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case LeftOrRight((a, b, c)) => a } // fail
+}
+
+class B {
+ def f1[A](x: A) = (Left(x): Either[A, A]) match { case LeftOrRight(a) => a } // no warn
+ def f2[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case LeftOrRight(a) => a } // warn
+ def f3[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case LeftOrRight((a, b)) => a } // no warn
+ def f4[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case LeftOrRight((a, b, c)) => a } // fail
+}
+
+class C {
+ def f1 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case NativelyTwo(a) => a } // warn
+ def f2 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case NativelyTwo((a, b)) => a } // no warn
+ def f3 = (Left((0, 0)): Either[(Int, Int), (Int, Int)]) match { case NativelyTwo((a, b, c)) => a } // fail
+}
+
+class D {
+ def f1[A](x: A) = (Left(x): Either[A, A]) match { case NativelyTwo(a) => a } // warn
+ def f2[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case NativelyTwo(a) => a } // warn
+ def f3[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case NativelyTwo((a, b)) => a } // no warn
+ def f4[A](x: A) = (Left(x -> x): Either[(A, A), (A, A)]) match { case NativelyTwo((a, b, c)) => a } // fail
+}
diff --git a/test/files/neg/t7157/Impls_Macros_1.scala b/test/files/neg/t7157/Impls_Macros_1.scala
index 16cb001422..31d4d786d0 100644
--- a/test/files/neg/t7157/Impls_Macros_1.scala
+++ b/test/files/neg/t7157/Impls_Macros_1.scala
@@ -1,31 +1,31 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
- def impl1_0_0(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl1_1_1(c: BlackboxContext)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl1_2_2(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_0_0(c: Context)() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_1_1(c: Context)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
def m1_0_0() = macro impl1_0_0
def m1_1_1(x: Int) = macro impl1_1_1
def m1_2_2(x: Int, y: Int) = macro impl1_2_2
- def impl1_0_inf(c: BlackboxContext)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl1_1_inf(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl1_2_inf(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl1_2_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
def m1_0_inf(x: Int*) = macro impl1_0_inf
def m1_1_inf(x: Int, y: Int*) = macro impl1_1_inf
def m1_2_inf(x: Int, y: Int, z: Int*) = macro impl1_2_inf
- def impl2_0_0(c: BlackboxContext)()() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl2_1_1(c: BlackboxContext)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl2_2_2(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_0_0(c: Context)()() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_1_1(c: Context)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
def m2_0_0()() = macro impl2_0_0
def m2_1_1()(x: Int) = macro impl2_1_1
def m2_2_2()(x: Int, y: Int) = macro impl2_2_2
- def impl2_0_inf(c: BlackboxContext)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl2_1_inf(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
- def impl2_2_inf(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def impl2_2_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
def m2_0_inf()(x: Int*) = macro impl2_0_inf
def m2_1_inf()(x: Int, y: Int*) = macro impl2_1_inf
def m2_2_inf()(x: Int, y: Int, z: Int*) = macro impl2_2_inf
diff --git a/test/files/neg/t7214neg.check b/test/files/neg/t7214neg.check
index 0660cccd02..291af04578 100644
--- a/test/files/neg/t7214neg.check
+++ b/test/files/neg/t7214neg.check
@@ -1,7 +1,4 @@
-t7214neg.scala:28: error: wrong number of patterns for object Extractor offering Any: expected 1, found 0
+t7214neg.scala:28: error: not enough patterns for object Extractor offering Any: expected 1, found 0
case Extractor() =>
^
-t7214neg.scala:28: error: wrong number of patterns for object Extractor offering Any: expected 1, found 0
- case Extractor() =>
- ^
-two errors found
+one error found
diff --git a/test/files/neg/t7850.check b/test/files/neg/t7850.check
new file mode 100644
index 0000000000..317be2bbce
--- /dev/null
+++ b/test/files/neg/t7850.check
@@ -0,0 +1,7 @@
+t7850.scala:11: error: an unapply result must have a member `def isEmpty: Boolean (found: def isEmpty: Casey)
+ val Casey(x1) = new Casey(1)
+ ^
+t7850.scala:12: error: an unapply result must have a member `def isEmpty: Boolean
+ val Dingy(x2) = new Dingy(1)
+ ^
+two errors found
diff --git a/test/files/neg/t7850.scala b/test/files/neg/t7850.scala
new file mode 100644
index 0000000000..04edad82b5
--- /dev/null
+++ b/test/files/neg/t7850.scala
@@ -0,0 +1,16 @@
+// isEmpty returns non-boolean
+class Casey(a: Int) { def isEmpty = this; def get = this }
+object Casey { def unapply(a: Casey) = a }
+
+// no isEmpty method at all
+class Dingy(a: Int) { def get = this }
+object Dingy { def unapply(a: Dingy) = a }
+
+object Test {
+ def main(args: Array[String]) {
+ val Casey(x1) = new Casey(1)
+ val Dingy(x2) = new Dingy(1)
+ println(s"$x1 $x2")
+ }
+}
+
diff --git a/test/files/neg/t7897.check b/test/files/neg/t7897.check
new file mode 100644
index 0000000000..48eff511c7
--- /dev/null
+++ b/test/files/neg/t7897.check
@@ -0,0 +1,4 @@
+t7897.scala:19: error: value length is not a member of p0.Single
+ case p0.Single(x) => println(s"`$x` has ${x.length} chars")
+ ^
+one error found
diff --git a/test/files/neg/t7897.scala b/test/files/neg/t7897.scala
new file mode 100644
index 0000000000..87c966b1e0
--- /dev/null
+++ b/test/files/neg/t7897.scala
@@ -0,0 +1,23 @@
+package p0 {
+ class Single(val x: Any) extends AnyRef with Product1[String] {
+ private def s = "" + x
+ override def canEqual(x: Any) = this eq x.asInstanceOf[AnyRef]
+ def isEmpty = false
+ def get = this
+ def _1 = s + " only"
+
+ override def toString = s"Single(${_1})"
+ }
+
+ object Single {
+ def unapply(x: Any): Single = new Single(x)
+ }
+}
+object Test {
+ def main(args: Array[String]): Unit = {
+ "catdog" match {
+ case p0.Single(x) => println(s"`$x` has ${x.length} chars")
+ case x => println("fail: " + x)
+ }
+ }
+}
diff --git a/test/files/neg/t8104/Macros_1.scala b/test/files/neg/t8104/Macros_1.scala
index 21d81a3687..2ad4bc5a99 100644
--- a/test/files/neg/t8104/Macros_1.scala
+++ b/test/files/neg/t8104/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
- def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = {
+ def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = {
import c.universe._
import definitions._
val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
diff --git a/test/files/neg/t8146-non-finitary-2.check b/test/files/neg/t8146-non-finitary-2.check
new file mode 100644
index 0000000000..8c2e1436c2
--- /dev/null
+++ b/test/files/neg/t8146-non-finitary-2.check
@@ -0,0 +1,9 @@
+t8146-non-finitary-2.scala:5: error: class graph is not finitary because type parameter X is expansively recursive
+trait C[X] extends N[N[C[D[X]]]]
+ ^
+t8146-non-finitary-2.scala:7: error: type mismatch;
+ found : C[Int]
+ required: N[C[Int]]
+ def foo(c: C[Int]): N[C[Int]] = c
+ ^
+two errors found
diff --git a/test/files/neg/t8146-non-finitary-2.scala b/test/files/neg/t8146-non-finitary-2.scala
new file mode 100644
index 0000000000..c12f5f8f49
--- /dev/null
+++ b/test/files/neg/t8146-non-finitary-2.scala
@@ -0,0 +1,8 @@
+// Example 3 from "On Decidability of Nominal Subtyping with Variance" (Pierce, Kennedy)
+// http://research.microsoft.com/pubs/64041/fool2007.pdf
+trait N[-Z]
+trait D[Y]
+trait C[X] extends N[N[C[D[X]]]]
+object Test {
+ def foo(c: C[Int]): N[C[Int]] = c
+}
diff --git a/test/files/neg/t8146-non-finitary.check b/test/files/neg/t8146-non-finitary.check
new file mode 100644
index 0000000000..8363b750ca
--- /dev/null
+++ b/test/files/neg/t8146-non-finitary.check
@@ -0,0 +1,9 @@
+t8146-non-finitary.scala:4: error: class graph is not finitary because type parameter A is expansively recursive
+trait C[A] extends N[N[C[C[A]]]]
+ ^
+t8146-non-finitary.scala:6: error: type mismatch;
+ found : C[Int]
+ required: N[C[Int]]
+ def foo(c: C[Int]): N[C[Int]] = c
+ ^
+two errors found
diff --git a/test/files/neg/t8146-non-finitary.scala b/test/files/neg/t8146-non-finitary.scala
new file mode 100644
index 0000000000..3d8a3074c7
--- /dev/null
+++ b/test/files/neg/t8146-non-finitary.scala
@@ -0,0 +1,7 @@
+// Example 3 from "On Decidability of Nominal Subtyping with Variance" (Pierce, Kennedy)
+// http://research.microsoft.com/pubs/64041/fool2007.pdf
+trait N[-A]
+trait C[A] extends N[N[C[C[A]]]]
+object Test {
+ def foo(c: C[Int]): N[C[Int]] = c
+}
diff --git a/test/files/neg/t997.check b/test/files/neg/t997.check
index 8c41060ba2..b118792229 100644
--- a/test/files/neg/t997.check
+++ b/test/files/neg/t997.check
@@ -1,7 +1,4 @@
-t997.scala:13: error: wrong number of patterns for object Foo offering (String, String): expected 2, found 3
+t997.scala:13: error: too many patterns for object Foo offering (String, String): expected 2, found 3
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
^
-t997.scala:13: error: wrong number of patterns for object Foo offering (String, String): expected 2, found 3
-"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
- ^
-two errors found
+one error found
diff --git a/test/files/pos/annotated-original/M_1.scala b/test/files/pos/annotated-original/M_1.scala
index 089a3a13c5..e312f9abbf 100644
--- a/test/files/pos/annotated-original/M_1.scala
+++ b/test/files/pos/annotated-original/M_1.scala
@@ -1,7 +1,7 @@
import language.experimental.macros
-import reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object M {
- def impl(c: BlackboxContext)(a: c.Expr[Any]) = c.Expr[Any](c.resetLocalAttrs(a.tree))
+ def impl(c: Context)(a: c.Expr[Any]) = c.Expr[Any](c.resetLocalAttrs(a.tree))
def m(a: Any) = macro impl
}
diff --git a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala
index 50c671707d..b02864b994 100644
--- a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala
+++ b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import collection.mutable.ListBuffer
import collection.mutable.Stack
@@ -12,7 +12,7 @@ object Macros {
def tree[T,U](f:Function1[T,U]): Function1[T,U] = macro tree_impl[T,U]
- def tree_impl[T:c.WeakTypeTag,U:c.WeakTypeTag](c: BlackboxContext)
+ def tree_impl[T:c.WeakTypeTag,U:c.WeakTypeTag](c: Context)
(f:c.Expr[Function1[T,U]]): c.Expr[Function1[T,U]] = {
import c.universe._
val ttag = c.weakTypeTag[U]
diff --git a/test/files/pos/attachments-typed-another-ident/Impls_1.scala b/test/files/pos/attachments-typed-another-ident/Impls_1.scala
index 6271359921..8016143a4c 100644
--- a/test/files/pos/attachments-typed-another-ident/Impls_1.scala
+++ b/test/files/pos/attachments-typed-another-ident/Impls_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object MyAttachment
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val ident = Ident(TermName("bar")) updateAttachment MyAttachment
assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments)
diff --git a/test/files/pos/attachments-typed-ident/Impls_1.scala b/test/files/pos/attachments-typed-ident/Impls_1.scala
index f24ea88a5d..af2cc59ecd 100644
--- a/test/files/pos/attachments-typed-ident/Impls_1.scala
+++ b/test/files/pos/attachments-typed-ident/Impls_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object MyAttachment
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val ident = Ident(TermName("bar")) updateAttachment MyAttachment
assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments)
diff --git a/test/files/pos/macro-implicit-invalidate-on-error.scala b/test/files/pos/macro-implicit-invalidate-on-error.scala
index f9756d965f..bb83e3cc38 100644
--- a/test/files/pos/macro-implicit-invalidate-on-error.scala
+++ b/test/files/pos/macro-implicit-invalidate-on-error.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Context
+import scala.reflect.macros.blackbox.Context
trait LegacyLiftable[T] {
def apply(universe: scala.reflect.api.Universe, value: T): universe.Tree
diff --git a/test/files/pos/t2066.scala b/test/files/pos/t2066.scala
new file mode 100644
index 0000000000..30cb99d45c
--- /dev/null
+++ b/test/files/pos/t2066.scala
@@ -0,0 +1,25 @@
+trait A1 {
+ def f[T[+_]] = ()
+}
+
+trait B1 extends A1 {
+ override def f[T[_]] = ()
+}
+
+
+trait A2 {
+ def f[T[-_]] = ()
+}
+
+trait B2 extends A2 {
+ override def f[T[_]] = ()
+}
+
+
+trait A3 {
+ def f[T[X[_]]] = ()
+}
+
+trait B3 extends A3 {
+ override def f[T[X[+_]]] = ()
+}
diff --git a/test/files/pos/t5692a/Macros_1.scala b/test/files/pos/t5692a/Macros_1.scala
index 0e91f4d6a0..440e37d75d 100644
--- a/test/files/pos/t5692a/Macros_1.scala
+++ b/test/files/pos/t5692a/Macros_1.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl[T](c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl[T](c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo[T] = macro impl[T]
} \ No newline at end of file
diff --git a/test/files/pos/t5692b/Macros_1.scala b/test/files/pos/t5692b/Macros_1.scala
index 1034a1ea4a..98fb882844 100644
--- a/test/files/pos/t5692b/Macros_1.scala
+++ b/test/files/pos/t5692b/Macros_1.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl[T, U](c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl[T, U](c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo[T, U] = macro impl[T, U]
} \ No newline at end of file
diff --git a/test/files/pos/t5706.scala b/test/files/pos/t5706.scala
index 1970f5971f..6f0207366b 100644
--- a/test/files/pos/t5706.scala
+++ b/test/files/pos/t5706.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.BlackboxContext
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.blackbox.{Context => BlackboxContext}
+import scala.reflect.macros.whitebox.{Context => WhiteboxContext}
class Logger {
def error1(message: String) = macro Impls.error1
diff --git a/test/files/pos/t5744/Macros_1.scala b/test/files/pos/t5744/Macros_1.scala
index 0fc13c12d7..6e2bf4825b 100644
--- a/test/files/pos/t5744/Macros_1.scala
+++ b/test/files/pos/t5744/Macros_1.scala
@@ -1,18 +1,18 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[U: Numeric](x: U) = macro foo_impl[U]
def bar[U: Numeric : Equiv, Y <% String](x: U)(implicit s: String) = macro bar_impl[U, Y]
- def foo_impl[U](c: BlackboxContext)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]]) = {
+ def foo_impl[U](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]]) = {
import c.universe._
val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne))
c.Expr[Unit](body)
}
- def bar_impl[U, Y](c: BlackboxContext)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]], equiv: c.Expr[Equiv[U]], viewAsString: c.Expr[Y => String], s: c.Expr[String]) = {
+ def bar_impl[U, Y](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]], equiv: c.Expr[Equiv[U]], viewAsString: c.Expr[Y => String], s: c.Expr[String]) = {
import c.universe._
val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
val plusLen = Apply(Select(numeric.tree, newTermName("plus")), List(plusOne, Select(s.tree, newTermName("length"))))
diff --git a/test/files/pos/t6047.scala b/test/files/pos/t6047.scala
index c5bb44d87e..8c3dd18953 100644
--- a/test/files/pos/t6047.scala
+++ b/test/files/pos/t6047.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import java.io.InputStream
object Macros {
def unpack[A](input: InputStream): A = macro unpack_impl[A]
- def unpack_impl[A: c.WeakTypeTag](c: BlackboxContext)(input: c.Expr[InputStream]): c.Expr[A] = {
+ def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = {
import c.universe._
def unpackcode(tpe: c.Type): c.Expr[_] = {
diff --git a/test/files/pos/t6447.scala b/test/files/pos/t6447.scala
index 8203c0cddd..6ef69d4852 100644
--- a/test/files/pos/t6447.scala
+++ b/test/files/pos/t6447.scala
@@ -1,18 +1,18 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
class X { type T }
object X {
// this works
def foo(x: X): x.T = macro fooImpl
- def fooImpl(c: BlackboxContext)(x: c.Expr[X]): c.Expr[x.value.T] = ???
+ def fooImpl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ???
// this doesn't
def bar(x: X, y: X): (x.T, y.T) = macro barImpl
- def barImpl(c: BlackboxContext)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ???
+ def barImpl(c: Context)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ???
// neither does this
def baz(x: X)(xs: List[x.T]): Unit = macro bazImpl
- def bazImpl(c: BlackboxContext)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ???
+ def bazImpl(c: Context)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ???
}
diff --git a/test/files/pos/t6485a/Macros_1.scala b/test/files/pos/t6485a/Macros_1.scala
index c637c2cfee..570c987709 100644
--- a/test/files/pos/t6485a/Macros_1.scala
+++ b/test/files/pos/t6485a/Macros_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def crash(c: BlackboxContext): c.Expr[Unit] = c.universe.reify(())
+ def crash(c: Context): c.Expr[Unit] = c.universe.reify(())
} \ No newline at end of file
diff --git a/test/files/pos/t6485b/Test.scala b/test/files/pos/t6485b/Test.scala
index 9897987516..3b81c6f8ab 100644
--- a/test/files/pos/t6485b/Test.scala
+++ b/test/files/pos/t6485b/Test.scala
@@ -1,10 +1,10 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
final class Ops[T](val x: T) extends AnyVal {
def f = macro Macros.crash
}
object Macros {
- def crash(c: BlackboxContext): c.Expr[Unit] = c.universe.reify(())
+ def crash(c: Context): c.Expr[Unit] = c.universe.reify(())
} \ No newline at end of file
diff --git a/test/files/pos/t6516.scala b/test/files/pos/t6516.scala
index aed359976e..2980d83eb6 100644
--- a/test/files/pos/t6516.scala
+++ b/test/files/pos/t6516.scala
@@ -1,17 +1,17 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.collection.TraversableLike
// This one compiles
object Test {
- type Alias[T, CC[_]] = BlackboxContext { type PrefixType = TraversableLike[T, CC[T]] }
+ type Alias[T, CC[_]] = Context { type PrefixType = TraversableLike[T, CC[T]] }
def f() = macro f_impl
def f_impl(c: Alias[Int, List])() = ???
}
// This one doesn't
object Test2 {
- type Ctx = scala.reflect.macros.BlackboxContext
+ type Ctx = scala.reflect.macros.blackbox.Context
type Alias[T, CC[_]] = Ctx { type PrefixType = TraversableLike[T, CC[T]] }
def f() = macro f_impl
diff --git a/test/files/pos/t7377/Macro_1.scala b/test/files/pos/t7377/Macro_1.scala
index 7280cfeaf5..9f51248095 100644
--- a/test/files/pos/t7377/Macro_1.scala
+++ b/test/files/pos/t7377/Macro_1.scala
@@ -1,7 +1,7 @@
import language.experimental._
-import reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object M {
- def noopImpl[A](c: BlackboxContext)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typecheck(c.resetLocalAttrs(expr.tree)))
+ def noopImpl[A](c: Context)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typecheck(c.resetLocalAttrs(expr.tree)))
def noop[A](expr: A): A = macro noopImpl[A]
}
diff --git a/test/files/pos/t7461/Macros_1.scala b/test/files/pos/t7461/Macros_1.scala
index 89ae7c70e3..ca84d75624 100644
--- a/test/files/pos/t7461/Macros_1.scala
+++ b/test/files/pos/t7461/Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val wut = c.typecheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true)
// println(showRaw(wut, printIds = true, printTypes = true))
diff --git a/test/files/pos/t7649.scala b/test/files/pos/t7649.scala
index fa5d13369f..d70dc05ea4 100644
--- a/test/files/pos/t7649.scala
+++ b/test/files/pos/t7649.scala
@@ -1,5 +1,5 @@
object Test {
- val c: reflect.macros.BlackboxContext = ???
+ val c: scala.reflect.macros.blackbox.Context = ???
import c.universe._
reify {
// The lookup of the implicit WeakTypeTag[Any]
diff --git a/test/files/pos/t7776.scala b/test/files/pos/t7776.scala
index e0584b70e2..a36497a7a1 100644
--- a/test/files/pos/t7776.scala
+++ b/test/files/pos/t7776.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Context
+import scala.reflect.macros.blackbox.Context
class MacroErasure {
def app(f: Any => Any, x: Any): Any = macro MacroErasure.appMacro
diff --git a/test/files/pos/t8001/Macros_1.scala b/test/files/pos/t8001/Macros_1.scala
index fd26016d4b..3b80b88295 100644
--- a/test/files/pos/t8001/Macros_1.scala
+++ b/test/files/pos/t8001/Macros_1.scala
@@ -1,9 +1,9 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo: Unit = macro impl
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
q"()"
}
diff --git a/test/files/pos/t8013/inpervolator_1.scala b/test/files/pos/t8013/inpervolator_1.scala
index fb71571afc..89b7c22709 100644
--- a/test/files/pos/t8013/inpervolator_1.scala
+++ b/test/files/pos/t8013/inpervolator_1.scala
@@ -4,7 +4,7 @@ package t8013
// perverse macro to confuse Xlint
import scala.language.experimental.macros
-import scala.reflect.macros.{ BlackboxContext => Context }
+import scala.reflect.macros.blackbox.Context
object Perverse {
diff --git a/test/files/pos/t8045.scala b/test/files/pos/t8045.scala
new file mode 100644
index 0000000000..21154e386a
--- /dev/null
+++ b/test/files/pos/t8045.scala
@@ -0,0 +1,17 @@
+object Test extends App {
+ case class Number(i: Int)
+
+ object UnliftNumber {
+ def unapply(t: Any): Option[Number] = t match {
+ case i: Int => Some(Number(i))
+ case _ => None
+ }
+ }
+
+ def eval(expr: Any): Option[Number] = expr match {
+ case UnliftNumber(n) => Some(n)
+ case _ => None
+ }
+
+ println(eval(1))
+}
diff --git a/test/files/pos/t8046.scala b/test/files/pos/t8046.scala
new file mode 100644
index 0000000000..304d70b6b8
--- /dev/null
+++ b/test/files/pos/t8046.scala
@@ -0,0 +1,20 @@
+trait One {
+ type Op[A]
+ type Alias[A] = Op[A]
+}
+
+trait Two extends One {
+ trait Op[A] extends (A => A)
+
+ // This compiles
+ class View1 extends Op[Int] { def apply(xs: Int) = xs }
+
+ // ??? base class View2 not found in basetypes of class View2
+ // ./a.scala:9: error: class View2 needs to be abstract, since \
+ // method apply in trait Function1 of type (v1: T1)R is not defined
+ // (Note that T1 does not match Int)
+ // class View2 extends Alias[Int] { def apply(xs: Int) = xs }
+ // ^
+ // one error found
+ class View2 extends Alias[Int] { def apply(xs: Int) = xs }
+}
diff --git a/test/files/pos/t8046b.scala b/test/files/pos/t8046b.scala
new file mode 100644
index 0000000000..45b99fd7e0
--- /dev/null
+++ b/test/files/pos/t8046b.scala
@@ -0,0 +1,16 @@
+trait One {
+ type Op[A]
+ type Alias = Op[Int]
+}
+
+trait Two extends One {
+ trait Op[A] extends M[A]
+ //(a: Alias) => a.value.toChar // okay
+ // (=> A).asSeenFrom(a.type, trait M): => Int
+ class View2 extends Alias { value.toChar } // toChar is not a member of type parameter A
+ // (=> A).asSeenFrom(View2.this.type, trait M): => A
+
+ // override type Alias = Op[Int] // works with this
+}
+
+trait M[A] { def value: A = sys.error("") }
diff --git a/test/files/pos/t8046c.scala b/test/files/pos/t8046c.scala
new file mode 100644
index 0000000000..f05b4c15b5
--- /dev/null
+++ b/test/files/pos/t8046c.scala
@@ -0,0 +1,19 @@
+trait One {
+ type Op[A]
+ type Alias[A] = Op[A]
+}
+
+trait Three extends One {
+ trait Op[A] extends (A => A)
+
+ def f1(f: Op[Int]) = f(5)
+ def f2(f: Alias[Int]) = f(5)
+ def f3[T <: Op[Int]](f: T) = f(5)
+ def f4[T <: Alias[Int]](f: T) = f(5)
+ // ./a.scala:12: error: type mismatch;
+ // found : Int(5)
+ // required: T1
+ // def f4[T <: Alias[Int]](f: T) = f(5)
+ // ^
+}
+
diff --git a/test/files/pos/t8064.flags b/test/files/pos/t8064.flags
new file mode 100644
index 0000000000..281f0a10cd
--- /dev/null
+++ b/test/files/pos/t8064.flags
@@ -0,0 +1 @@
+-Yrangepos
diff --git a/test/files/pos/t8064/Client_2.scala b/test/files/pos/t8064/Client_2.scala
new file mode 100644
index 0000000000..44106782c7
--- /dev/null
+++ b/test/files/pos/t8064/Client_2.scala
@@ -0,0 +1,8 @@
+object Test {
+ Macro {
+ def s = ""
+ Macro(s): @unchecked
+ ???
+ }
+}
+// Was: a range position validation error (unpositioned tree) \ No newline at end of file
diff --git a/test/files/pos/t8064/Macro_1.scala b/test/files/pos/t8064/Macro_1.scala
new file mode 100644
index 0000000000..dd42950b34
--- /dev/null
+++ b/test/files/pos/t8064/Macro_1.scala
@@ -0,0 +1,10 @@
+import language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macro {
+ def apply(a: Any): Any = macro impl
+
+ def impl(c: Context)(a: c.Tree): c.Tree = {
+ c.resetLocalAttrs(a)
+ }
+}
diff --git a/test/files/pos/t8064b.flags b/test/files/pos/t8064b.flags
new file mode 100644
index 0000000000..281f0a10cd
--- /dev/null
+++ b/test/files/pos/t8064b.flags
@@ -0,0 +1 @@
+-Yrangepos
diff --git a/test/files/pos/t8064b/Client_2.scala b/test/files/pos/t8064b/Client_2.scala
new file mode 100644
index 0000000000..a7bf2b9fb4
--- /dev/null
+++ b/test/files/pos/t8064b/Client_2.scala
@@ -0,0 +1,6 @@
+object Test {
+ Macro {
+ "".reverse
+ }
+}
+// Was: a range position validation error (tree with offset position enclosing tree with range position) \ No newline at end of file
diff --git a/test/files/pos/t8064b/Macro_1.scala b/test/files/pos/t8064b/Macro_1.scala
new file mode 100644
index 0000000000..60996bfeca
--- /dev/null
+++ b/test/files/pos/t8064b/Macro_1.scala
@@ -0,0 +1,11 @@
+import language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macro {
+ def apply(a: Any): Any = macro impl
+ def impl(c: Context)(a: c.Tree): c.Tree = {
+ import c.universe._
+
+ q"{$a; true}"
+ }
+}
diff --git a/test/files/pos/t8128.scala b/test/files/pos/t8128.scala
new file mode 100644
index 0000000000..b6f76691b0
--- /dev/null
+++ b/test/files/pos/t8128.scala
@@ -0,0 +1,15 @@
+object G {
+ def unapply(m: Any): Option[_] = Some("")
+}
+
+object H {
+ def unapplySeq(m: Any): Option[Seq[_]] = None
+}
+
+object Test {
+ (0: Any) match {
+ case G(v) => v
+ case H(v) => v
+ case _ =>
+ }
+}
diff --git a/test/files/pos/t8132.scala b/test/files/pos/t8132.scala
new file mode 100644
index 0000000000..b4d6fd9441
--- /dev/null
+++ b/test/files/pos/t8132.scala
@@ -0,0 +1,5 @@
+trait T {
+ protected def s: String
+}
+
+case class G(override protected val s: String) extends T
diff --git a/test/files/pos/t8146a.scala b/test/files/pos/t8146a.scala
new file mode 100644
index 0000000000..e4eb8d3fd1
--- /dev/null
+++ b/test/files/pos/t8146a.scala
@@ -0,0 +1,9 @@
+trait M[+A]
+
+object Test {
+ type Inty = Int
+ def t1(
+ x: M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[Int @unchecked]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
+ ): M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[M[Inty @unchecked]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
+ = x
+}
diff --git a/test/files/pos/t8146b.scala b/test/files/pos/t8146b.scala
new file mode 100644
index 0000000000..dd031f66c8
--- /dev/null
+++ b/test/files/pos/t8146b.scala
@@ -0,0 +1,77 @@
+// non-deterministic type errors, non-termination.
+// seems to be due to inconsistent hashing/equality in SubTypePair
+
+import scala.language.{existentials, implicitConversions}
+import scala.annotation.unchecked.uncheckedVariance
+
+trait Column[T]
+
+// Turning this into a trait reduces (eliminates?) the likelihood of type errors (but not of non-termination)
+abstract class Shape[Level <: ShapeLevel, -Mixed_, Unpacked_, Packed_]
+
+trait ShapeLevel
+trait NestedShapeLevel extends ShapeLevel
+trait FlatShapeLevel extends NestedShapeLevel
+trait ColumnsShapeLevel extends FlatShapeLevel
+
+trait ProvenShape[U]
+
+object ProvenShape {
+ implicit def proveShapeOf[T, U](v: T)(implicit sh: Shape[_ <: FlatShapeLevel, T, U, _]): ProvenShape[U] = ???
+}
+
+sealed abstract class HList {
+ type Self <: HList
+ type :: [E] = HCons[E, Self]
+ final def :: [E](elem: E): :: [E] = ???
+}
+
+final class HCons[+H, +T <: HList](val head: H, val tail: T) extends HList {
+ type Self = HCons[H @uncheckedVariance, T @uncheckedVariance]
+}
+
+final object HNil extends HList {
+ type Self = HNil.type
+}
+
+// Success is more likely when not using these aliases
+object syntax {
+ type :: [+H, +T <: HList] = HCons[H, T]
+ type HNil = HNil.type
+}
+
+class HListBench {
+
+ import syntax._
+
+ implicit def columnShape[T, Level <: ShapeLevel]: Shape[Level, Column[T], T, Column[T]] = ???
+ implicit def provenShape[T, P](implicit shape: Shape[_ <: FlatShapeLevel, T, _, P]): Shape[FlatShapeLevel, ProvenShape[T], T, P] = ???
+ final class HListShape[Level <: ShapeLevel, M <: HList, U <: HList, P <: HList](val shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]) extends Shape[Level, M, U, P]
+ implicit def hnilShape[Level <: ShapeLevel] = new HListShape[Level, HNil.type, HNil.type, HNil.type](Nil)
+ implicit def hconsShape[Level <: ShapeLevel, M1, M2 <: HList, U1, U2 <: HList, P1, P2 <: HList]
+ (implicit s1: Shape[_ <: Level, M1, U1, P1], s2: HListShape[_ <: Level, M2, U2, P2]) =
+ new HListShape[Level, M1 :: M2, U1 :: U2, P1 :: P2](s1 +: s2.shapes)
+
+ trait A[T] {
+ def * : ProvenShape[T]
+ }
+
+ trait B extends A[
+ Int :: Int :: Int :: Int :: Int ::
+ Int :: Int :: Int :: Int :: Int ::
+ Int :: Int :: Int :: Int :: Int ::
+ Int :: Int :: Int :: Int :: Int ::
+ Int :: Int :: Int :: Int :: Int ::
+ Int :: Int :: HNil ] {
+
+ def c: Column[Int]
+
+ def * = c :: c :: c :: c :: c ::
+ c :: c :: c :: c :: c ::
+ c :: c :: c :: c :: c ::
+ c :: c :: c :: c :: c ::
+ c :: c :: c :: c :: c ::
+ c :: c :: HNil
+
+ }
+}
diff --git a/test/files/presentation/hyperlinks-macro.check b/test/files/presentation/hyperlinks-macro.check
new file mode 100644
index 0000000000..80d2268fa1
--- /dev/null
+++ b/test/files/presentation/hyperlinks-macro.check
@@ -0,0 +1,11 @@
+reload: MacroCall.scala
+
+askHyperlinkPos for `foo` at (5,7) MacroCall.scala
+================================================================================
+[response] found askHyperlinkPos for `foo` at (2,7) MacroCall.scala
+================================================================================
+
+askHyperlinkPos for `foo` at (9,7) MacroCall.scala
+================================================================================
+[response] found askHyperlinkPos for `foo` at (2,7) MacroCall.scala
+================================================================================
diff --git a/test/files/presentation/hyperlinks-macro/Runner.scala b/test/files/presentation/hyperlinks-macro/Runner.scala
new file mode 100644
index 0000000000..c2f89bdb17
--- /dev/null
+++ b/test/files/presentation/hyperlinks-macro/Runner.scala
@@ -0,0 +1,8 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest {
+ override def runDefaultTests() {
+ sourceFiles foreach (src => askLoadedTyped(src).get)
+ super.runDefaultTests()
+ }
+}
diff --git a/test/files/presentation/hyperlinks-macro/src/MacroCall.scala b/test/files/presentation/hyperlinks-macro/src/MacroCall.scala
new file mode 100644
index 0000000000..d9676b3d2a
--- /dev/null
+++ b/test/files/presentation/hyperlinks-macro/src/MacroCall.scala
@@ -0,0 +1,11 @@
+object Test {
+ def foo = 0
+
+ scala.reflect.runtime.universe.reify {
+ foo/*#*/
+ }
+
+ identity {
+ foo/*#*/
+ }
+}
diff --git a/test/files/presentation/t4287.check b/test/files/presentation/t4287.check
new file mode 100644
index 0000000000..a922421e18
--- /dev/null
+++ b/test/files/presentation/t4287.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `B` at (1,24) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `B` at (3,8) Foo.scala
+================================================================================
+
+askHyperlinkPos for `a` at (1,31) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `a` at (4,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287/Test.scala b/test/files/presentation/t4287/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287/src/Foo.scala b/test/files/presentation/t4287/src/Foo.scala
new file mode 100644
index 0000000000..a744eaabe2
--- /dev/null
+++ b/test/files/presentation/t4287/src/Foo.scala
@@ -0,0 +1,5 @@
+class Baz(val f: Int = B/*#*/.a/*#*/)
+
+object B {
+ val a = 2
+}
diff --git a/test/files/presentation/t4287b.check b/test/files/presentation/t4287b.check
new file mode 100644
index 0000000000..d4b33650fd
--- /dev/null
+++ b/test/files/presentation/t4287b.check
@@ -0,0 +1,6 @@
+reload: Foo.scala
+
+askHyperlinkPos for `i` at (14,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `i` at (10,9) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287b/Test.scala b/test/files/presentation/t4287b/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287b/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287b/src/Foo.scala b/test/files/presentation/t4287b/src/Foo.scala
new file mode 100644
index 0000000000..47c676e2a2
--- /dev/null
+++ b/test/files/presentation/t4287b/src/Foo.scala
@@ -0,0 +1,15 @@
+trait Greeting {
+ val name: String
+ val msg = "How are you, "+name
+}
+
+object Greeting {
+ val hello = "hello"
+}
+
+class C(i: Int) extends {
+ val nameElse = "Bob"
+} with Greeting {
+ val name = "avc"
+ println(i/*#*/)
+} \ No newline at end of file
diff --git a/test/files/presentation/t4287c.check b/test/files/presentation/t4287c.check
new file mode 100644
index 0000000000..42fc30997d
--- /dev/null
+++ b/test/files/presentation/t4287c.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `A` at (1,18) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (3,8) Foo.scala
+================================================================================
+
+askHyperlinkPos for `a` at (1,25) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `a` at (4,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287c.flags b/test/files/presentation/t4287c.flags
new file mode 100644
index 0000000000..d1a8244169
--- /dev/null
+++ b/test/files/presentation/t4287c.flags
@@ -0,0 +1 @@
+-Yinfer-argument-types \ No newline at end of file
diff --git a/test/files/presentation/t4287c/Test.scala b/test/files/presentation/t4287c/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287c/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287c/src/Foo.scala b/test/files/presentation/t4287c/src/Foo.scala
new file mode 100644
index 0000000000..26870b5021
--- /dev/null
+++ b/test/files/presentation/t4287c/src/Foo.scala
@@ -0,0 +1,9 @@
+class A(a: Int = A/*#*/.a/*#*/)
+
+object A {
+ val a = 2
+}
+
+class B extends A {
+ def this(a) = this()
+} \ No newline at end of file
diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala
index 350d7b41aa..2b03512efb 100644
--- a/test/files/run/macro-abort-fresh/Macros_1.scala
+++ b/test/files/run/macro-abort-fresh/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
println(c.fresh())
println(c.fresh("qwe"))
diff --git a/test/files/run/macro-auto-duplicate/Macros_1.scala b/test/files/run/macro-auto-duplicate/Macros_1.scala
index 255dafd47e..2c910e6af7 100644
--- a/test/files/run/macro-auto-duplicate/Macros_1.scala
+++ b/test/files/run/macro-auto-duplicate/Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val x = Ident(newTermName("x"))
def defAndUseX(rhs: Tree) = {
diff --git a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala
index c63353164e..fc75b99ef2 100644
--- a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala
+++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala
@@ -1,19 +1,19 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
c.Expr[Int](body)
}
- def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))
c.Expr[Int](body)
}
- def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala
index 3cdd531316..73a5a971a4 100644
--- a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala
+++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala
@@ -1,19 +1,19 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
c.Expr[Int](body)
}
- def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))
c.Expr[Int](body)
}
- def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala
index 3feddd2786..0be915c119 100644
--- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala
+++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala
@@ -1,17 +1,17 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def foo(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))))
}
- def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def bar(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))))
}
- def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
+ def quux(c: Context)(x: c.Expr[Int]): c.Expr[Int] = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-blackbox-materialization/Macros_1.scala b/test/files/run/macro-blackbox-materialization/Macros_1.scala
index 7c31dd7dc2..ea8d1bed14 100644
--- a/test/files/run/macro-blackbox-materialization/Macros_1.scala
+++ b/test/files/run/macro-blackbox-materialization/Macros_1.scala
@@ -1,6 +1,6 @@
// For the full version of the test, take a look at run/t5923a
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
case class C[T](t: String)
@@ -9,7 +9,7 @@ object C {
}
object Macros {
- def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
+ def impl[T: c.WeakTypeTag](c: Context) = {
import c.universe._
reify(C[T](c.literal(weakTypeOf[T].toString).splice))
}
diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
index 8506239952..d46af4952d 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
@@ -1,5 +1,6 @@
import scala.language.experimental.macros
-import scala.reflect.macros.{BlackboxContext, WhiteboxContext}
+import scala.reflect.macros.blackbox.{Context => BlackboxContext}
+import scala.reflect.macros.whitebox.{Context => WhiteboxContext}
object Impls {
def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check
index 8487042d66..4a0b421606 100644
--- a/test/files/run/macro-bundle-repl.check
+++ b/test/files/run/macro-bundle-repl.check
@@ -4,17 +4,17 @@ Type :help for more information.
scala> import scala.language.experimental.macros
import scala.language.experimental.macros
-scala> import scala.reflect.macros.BlackboxMacro
-import scala.reflect.macros.BlackboxMacro
+scala> import scala.reflect.macros.blackbox.Context
+import scala.reflect.macros.blackbox.Context
-scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
-defined trait Bar
+scala> class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
+defined class Bar
defined term macro bar: Unit
scala> bar
-scala> trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
-defined trait Foo
+scala> class Foo(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
+defined class Foo
scala> def foo: Unit = macro Foo.impl
defined term macro foo: Unit
diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala
index db64f05943..8084418454 100644
--- a/test/files/run/macro-bundle-repl.scala
+++ b/test/files/run/macro-bundle-repl.scala
@@ -3,10 +3,10 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
-trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
+import scala.reflect.macros.blackbox.Context
+class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
bar
-trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
+class Foo(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
def foo: Unit = macro Foo.impl
foo
"""
diff --git a/test/files/run/macro-bundle-static/Impls_Macros_1.scala b/test/files/run/macro-bundle-static/Impls_Macros_1.scala
index b859411325..0142e5d945 100644
--- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
object Enclosing {
- trait Impl extends BlackboxMacro {
+ class Impl(val c: Context) {
def mono = { import c.universe._; c.Expr[Unit](q"()") }
def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") }
def weird = macro mono
@@ -16,7 +16,7 @@ object Macros {
package pkg {
object Enclosing {
- trait Impl extends BlackboxMacro {
+ class Impl(val c: Context) {
def mono = { import c.universe._; c.Expr[Boolean](q"true") }
def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") }
def weird = macro mono
diff --git a/test/files/run/macro-bundle-static/Test_2.scala b/test/files/run/macro-bundle-static/Test_2.scala
index 72160f6ec2..e35260cdce 100644
--- a/test/files/run/macro-bundle-static/Test_2.scala
+++ b/test/files/run/macro-bundle-static/Test_2.scala
@@ -1,8 +1,8 @@
object Test extends App {
println(Macros.mono)
println(Macros.poly[Int])
- println(new Enclosing.Impl{val c = ???}.weird)
+ println(new Enclosing.Impl(???).weird)
println(pkg.Macros.mono)
println(pkg.Macros.poly[Int])
- println(new pkg.Enclosing.Impl{val c = ???}.weird)
+ println(new pkg.Enclosing.Impl(???).weird)
} \ No newline at end of file
diff --git a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
index e026768642..6fd7be3b25 100644
--- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.blackbox.Context
-trait Impl extends BlackboxMacro {
+class Impl(val c: Context) {
def mono = { import c.universe._; c.Expr[Unit](q"()") }
def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") }
def weird = macro mono
@@ -12,7 +12,7 @@ object Macros {
}
package pkg {
- trait Impl extends BlackboxMacro {
+ class Impl(val c: Context) {
def mono = { import c.universe._; c.Expr[Boolean](q"true") }
def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") }
def weird = macro mono
diff --git a/test/files/run/macro-bundle-toplevel/Test_2.scala b/test/files/run/macro-bundle-toplevel/Test_2.scala
index 139cc5bef2..195fb49262 100644
--- a/test/files/run/macro-bundle-toplevel/Test_2.scala
+++ b/test/files/run/macro-bundle-toplevel/Test_2.scala
@@ -1,8 +1,8 @@
object Test extends App {
println(Macros.mono)
println(Macros.poly[Int])
- println(new Impl{val c = ???}.weird)
+ println(new Impl(???).weird)
println(pkg.Macros.mono)
println(pkg.Macros.poly[Int])
- println(new pkg.Impl{val c = ???}.weird)
+ println(new pkg.Impl(???).weird)
} \ No newline at end of file
diff --git a/test/files/run/macro-bundle-whitebox.check b/test/files/run/macro-bundle-whitebox.check
new file mode 100644
index 0000000000..37c8eaf27a
--- /dev/null
+++ b/test/files/run/macro-bundle-whitebox.check
@@ -0,0 +1,6 @@
+()
+Int
+()
+true
+IntInt
+true
diff --git a/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala b/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala
new file mode 100644
index 0000000000..5e1b11895d
--- /dev/null
+++ b/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala
@@ -0,0 +1,26 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.whitebox.Context
+
+class Impl(val c: Context) {
+ def mono = { import c.universe._; c.Expr[Unit](q"()") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") }
+ def weird = macro mono
+}
+
+object Macros {
+ def mono = macro Impl.mono
+ def poly[T] = macro Impl.poly[T]
+}
+
+package pkg {
+ class Impl(val c: Context) {
+ def mono = { import c.universe._; c.Expr[Boolean](q"true") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") }
+ def weird = macro mono
+ }
+
+ object Macros {
+ def mono = macro Impl.mono
+ def poly[T] = macro Impl.poly[T]
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-bundle-whitebox/Test_2.scala b/test/files/run/macro-bundle-whitebox/Test_2.scala
new file mode 100644
index 0000000000..195fb49262
--- /dev/null
+++ b/test/files/run/macro-bundle-whitebox/Test_2.scala
@@ -0,0 +1,8 @@
+object Test extends App {
+ println(Macros.mono)
+ println(Macros.poly[Int])
+ println(new Impl(???).weird)
+ println(pkg.Macros.mono)
+ println(pkg.Macros.poly[Int])
+ println(new pkg.Impl(???).weird)
+} \ No newline at end of file
diff --git a/test/files/run/macro-def-path-dependent/Test_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala
index bba97fcae1..4161a64303 100644
--- a/test/files/run/macro-def-path-dependent/Test_1.scala
+++ b/test/files/run/macro-def-path-dependent/Test_1.scala
@@ -2,7 +2,7 @@
// package test1
//
-// import scala.reflect.macros.{BlackboxContext => Ctx}
+// import scala.reflect.macros.blackbox.Context
//
// trait Exprs {
// self: Universe =>
@@ -21,5 +21,5 @@
// trait Universe extends Exprs with Reifiers
//
// object Impls {
-// def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
+// def reify[T](cc: Context{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
// }
diff --git a/test/files/run/macro-def-path-dependent/Test_2.scala b/test/files/run/macro-def-path-dependent/Test_2.scala
index c884ab9d0b..75a03b54e7 100644
--- a/test/files/run/macro-def-path-dependent/Test_2.scala
+++ b/test/files/run/macro-def-path-dependent/Test_2.scala
@@ -1,6 +1,6 @@
package test2
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
trait Exprs {
self: Universe =>
@@ -18,5 +18,5 @@ trait Universe extends Exprs with Reifiers {
}
object Impls {
- def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
+ def reify[T](cc: Context{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
}
diff --git a/test/files/run/macro-def-path-dependent/Test_3.scala b/test/files/run/macro-def-path-dependent/Test_3.scala
index 6d856d1450..1a5da8200b 100644
--- a/test/files/run/macro-def-path-dependent/Test_3.scala
+++ b/test/files/run/macro-def-path-dependent/Test_3.scala
@@ -1,6 +1,6 @@
package test3
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
trait Exprs {
self: Universe =>
@@ -18,5 +18,5 @@ trait Universe extends Exprs with Reifiers {
}
object Impls {
- def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
+ def reify[T](cc: Context{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
}
diff --git a/test/files/run/macro-def-path-dependent/Test_4.scala b/test/files/run/macro-def-path-dependent/Test_4.scala
index 6562802013..67cb88ee6f 100644
--- a/test/files/run/macro-def-path-dependent/Test_4.scala
+++ b/test/files/run/macro-def-path-dependent/Test_4.scala
@@ -1,11 +1,11 @@
package test4
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.api.Universe
object Test {
def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro materializeTypeTag_impl[T]
- def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
+ def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
} \ No newline at end of file
diff --git a/test/files/run/macro-def-path-dependent/Test_5.scala b/test/files/run/macro-def-path-dependent/Test_5.scala
index 22407b850c..b518ce864c 100644
--- a/test/files/run/macro-def-path-dependent/Test_5.scala
+++ b/test/files/run/macro-def-path-dependent/Test_5.scala
@@ -1,9 +1,9 @@
package test56
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.api.Universe
object Impls {
- def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
+ def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
} \ No newline at end of file
diff --git a/test/files/run/macro-def-path-dependent/Test_6.scala b/test/files/run/macro-def-path-dependent/Test_6.scala
index 011e726b3f..a8b50ce7d2 100644
--- a/test/files/run/macro-def-path-dependent/Test_6.scala
+++ b/test/files/run/macro-def-path-dependent/Test_6.scala
@@ -1,7 +1,7 @@
package test56
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.api.Universe
object Macros {
diff --git a/test/files/run/macro-default-params/Macros_1.scala b/test/files/run/macro-default-params/Macros_1.scala
index 47780ea4b8..74588a1cf4 100644
--- a/test/files/run/macro-default-params/Macros_1.scala
+++ b/test/files/run/macro-default-params/Macros_1.scala
@@ -1,11 +1,11 @@
import scala.language.experimental.macros
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
def id[A]: A = null.asInstanceOf[A]
def foo: Any = macro impl
- def impl(c: WhiteboxContext): c.Tree = {
+ def impl(c: Context): c.Tree = {
import c.universe._
import Flag._
diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala
index 4bafa84128..85d0f0bb7e 100644
--- a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala
+++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
trait Complex[T]
@@ -7,7 +7,7 @@ class Foo(val bar: Bar)
class Bar(val s: String)
object Complex {
- def impl[T: c.WeakTypeTag](c: BlackboxContext): c.Expr[Complex[T]] = {
+ def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = {
import c.universe._
val tpe = weakTypeOf[T]
for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) {
diff --git a/test/files/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala
index ab852c9e46..84fb2c5b61 100644
--- a/test/files/run/macro-duplicate/Impls_Macros_1.scala
+++ b/test/files/run/macro-duplicate/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val Expr(Block((cdef: ClassDef) :: Nil, _)) = reify { class C { def x = 2 } }
val cdef1 =
diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala
index dfffb48e73..5b04cf29e9 100644
--- a/test/files/run/macro-enclosures/Impls_Macros_1.scala
+++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
reify {
println("enclosingPackage = " + c.Expr[String](Literal(Constant(c.enclosingPackage.toString))).splice)
diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala
index 7ac30e3ff2..465f313ef2 100644
--- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala
+++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala
@@ -5,7 +5,7 @@ import scala.{specialized => spec}
import language.experimental.macros
import scala.reflect.ClassTag
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
def alloc[@spec A:ClassTag](src:Array[A], s1:Int, len:Int) = {
@@ -35,7 +35,7 @@ object Macros {
* arr
* }
*/
- def arrayMacro[A:c.WeakTypeTag](c:BlackboxContext)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = {
+ def arrayMacro[A:c.WeakTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = {
import c.mirror._
import c.universe._
def const(x:Int) = Literal(Constant(x))
diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala
index c56489e61c..18c97956e4 100644
--- a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala
+++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(x.tree))
c.Expr[Unit](body)
diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala
index f93d9100e8..aeceee5a5b 100644
--- a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala
+++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
+ def foo(c: Context)(x: c.Expr[String]): c.Expr[Option[Int]] = {
import c.universe._
val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt"))))
c.Expr[Option[Int]](body)
diff --git a/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala
index a8b478e9f2..fd267d32c4 100644
--- a/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala
+++ b/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.universe._
val body = Literal(Constant(2))
c.Expr[Int](body)
diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala
index f93d9100e8..aeceee5a5b 100644
--- a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala
+++ b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
+ def foo(c: Context)(x: c.Expr[String]): c.Expr[Option[Int]] = {
import c.universe._
val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt"))))
c.Expr[Option[Int]](body)
diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
index bc3d768a67..9278633c11 100644
--- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
+++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = {
import c.universe._
val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum))
diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala
index e0a048046f..9362d6c17a 100644
--- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala
@@ -1,15 +1,15 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl[T: c.WeakTypeTag](c: Ctx)(meth: String) = {
+ def impl[T: c.WeakTypeTag](c: Context)(meth: String) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(s"$meth[${c.weakTypeOf[T]}]"))))
c.Expr[Unit](body)
}
- def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c)("fooNullary")
- def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c)("fooEmpty")
- def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c)("barNullary")
- def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c)("barEmpty")
+ def fooNullary[T: c.WeakTypeTag](c: Context) = impl[T](c)("fooNullary")
+ def fooEmpty[T: c.WeakTypeTag](c: Context)() = impl[T](c)("fooEmpty")
+ def barNullary[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int]) = impl[T](c)("barNullary")
+ def barEmpty[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int])() = impl[T](c)("barEmpty")
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
index 5da33babd3..c8c3d255c4 100644
--- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
@@ -1,15 +1,15 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: Ctx)(meth: String) = {
+ def impl(c: Context)(meth: String) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(meth))))
c.Expr[Unit](body)
}
- def fooNullary(c: Ctx) = impl(c)("fooNullary")
- def fooEmpty(c: Ctx)() = impl(c)("fooEmpty")
- def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c)("barNullary")
- def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c)("barEmpty")
+ def fooNullary(c: Context) = impl(c)("fooNullary")
+ def fooEmpty(c: Context)() = impl(c)("fooEmpty")
+ def barNullary(c: Context)(x: c.Expr[Int]) = impl(c)("barNullary")
+ def barEmpty(c: Context)(x: c.Expr[Int])() = impl(c)("barEmpty")
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala
index ea68e9eb93..ef9d01d4ed 100644
--- a/test/files/run/macro-expand-overload/Impls_1.scala
+++ b/test/files/run/macro-expand-overload/Impls_1.scala
@@ -1,15 +1,15 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
+ def impl(c: Context)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree))
c.Expr[Unit](body)
}
- def fooObjectString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectString", x)
- def fooObjectInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectInt", x)
- def fooClassString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassString", x)
- def fooClassInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassInt", x)
+ def fooObjectString(c: Context)(x: c.Expr[_]) = impl(c)("fooObjectString", x)
+ def fooObjectInt(c: Context)(x: c.Expr[_]) = impl(c)("fooObjectInt", x)
+ def fooClassString(c: Context)(x: c.Expr[_]) = impl(c)("fooClassString", x)
+ def fooClassInt(c: Context)(x: c.Expr[_]) = impl(c)("fooClassInt", x)
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala
index 648641f578..e6ce18f172 100644
--- a/test/files/run/macro-expand-override/Impls_1.scala
+++ b/test/files/run/macro-expand-override/Impls_1.scala
@@ -1,15 +1,15 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
+ def impl(c: Context)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree))
c.Expr[Unit](body)
}
- def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x)
- def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x)
- def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x)
- def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x)
+ def fooBString(c: Context)(x: c.Expr[_]) = impl(c)("fooBString", x)
+ def fooBInt(c: Context)(x: c.Expr[_]) = impl(c)("fooBInt", x)
+ def fooDInt(c: Context)(x: c.Expr[_]) = impl(c)("fooDInt", x)
+ def fooZString(c: Context)(x: c.Expr[_]) = impl(c)("fooZString", x)
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala
index 8ba1a24540..3def2d2fbe 100644
--- a/test/files/run/macro-expand-recursive/Impls_1.scala
+++ b/test/files/run/macro-expand-recursive/Impls_1.scala
@@ -1,13 +1,13 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))
c.Expr[Unit](body)
}
- def fooFoo(c: Ctx) = {
+ def fooFoo(c: Context) = {
import c.universe._
val body = Select(Ident(TermName("Macros")), TermName("foo"))
c.Expr[Unit](body)
diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
index a255072774..95aaa1c3d7 100644
--- a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
@@ -1,12 +1,12 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls1 {
- def foo[U <: String](c: BlackboxContext): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") }
+ def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") }
}
class C
class D extends C
object Impls2 {
- def foo[U <: C](c: BlackboxContext): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") }
+ def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") }
}
diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
index e95d61a36a..c33ac6d1b7 100644
--- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U: c.WeakTypeTag](c: Ctx) = {
+ def foo[U: c.WeakTypeTag](c: Context) = {
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString))))
diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
index 37cf785c0d..32cee0d5fb 100644
--- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = {
+ def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = {
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString))))
diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
index 8f85ffff4a..289f07162b 100644
--- a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls1 {
- def foo[U: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[U]) = {
+ def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = {
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
c.Expr[Unit](q"println(${U.toString})")
@@ -10,7 +10,7 @@ object Impls1 {
}
object Impls2 {
- def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[U]) = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = {
import c.universe._
val T = implicitly[c.WeakTypeTag[T]]
val U = implicitly[c.WeakTypeTag[U]]
@@ -20,7 +20,7 @@ object Impls2 {
}
object Impls345 {
- def foo[T, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
c.Expr(q"""
println(${T.toString})
diff --git a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala
index 7bfff374e2..64f16c6a89 100644
--- a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala
+++ b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala
@@ -1,11 +1,11 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Helper {
def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x)
}
object Macros {
- def impl[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Expr[List[T]]) = {
+ def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = {
c.universe.reify(Helper.unapplySeq(x.splice))
}
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala
index 2480af61ad..18af84583a 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(xs: c.Expr[Int]*) = {
+ def foo(c: Context)(xs: c.Expr[Int]*) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList)
c.Expr[Unit](body)
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala
index a31c92a01c..4bdc5bec00 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(xs: c.Expr[Int]*) = {
+ def foo(c: Context)(xs: c.Expr[Int]*) = {
import c.universe._
val stripped_xs = xs map (_.tree) toList match {
case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped)
diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala
index 889240d628..64ab7de02a 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala
@@ -1,11 +1,11 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
def myprintln(xs: Int*) = {
println(xs)
}
- def foo(c: Ctx)(xs: c.Expr[Int]*) = {
+ def foo(c: Context)(xs: c.Expr[Int]*) = {
import c.universe._
val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList)
c.Expr[Unit](body)
diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala
index 2480af61ad..18af84583a 100644
--- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala
+++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(xs: c.Expr[Int]*) = {
+ def foo(c: Context)(xs: c.Expr[Int]*) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList)
c.Expr[Unit](body)
diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala
index 889240d628..64ab7de02a 100644
--- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala
+++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala
@@ -1,11 +1,11 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
def myprintln(xs: Int*) = {
println(xs)
}
- def foo(c: Ctx)(xs: c.Expr[Int]*) = {
+ def foo(c: Context)(xs: c.Expr[Int]*) = {
import c.universe._
val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList)
c.Expr[Unit](body)
diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
index aa76a410ea..9b1d0eed35 100644
--- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
+++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
+ def foo_targs[T, U: c.WeakTypeTag](c: Context = null)(x: c.Expr[Int] = null) = {
import c.{prefix => prefix}
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
diff --git a/test/files/run/macro-impl-relaxed/Macros_1.scala b/test/files/run/macro-impl-relaxed/Macros_1.scala
index 3cf5090ec8..420eb2a399 100644
--- a/test/files/run/macro-impl-relaxed/Macros_1.scala
+++ b/test/files/run/macro-impl-relaxed/Macros_1.scala
@@ -1,11 +1,11 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def implUU(c: BlackboxContext)(x: c.Tree): c.Tree = x
- def implTU(c: BlackboxContext)(x: c.Expr[Int]): c.Tree = x.tree
- def implUT(c: BlackboxContext)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x)
- def implTT(c: BlackboxContext)(x: c.Expr[Int]): c.Expr[Int] = x
+ def implUU(c: Context)(x: c.Tree): c.Tree = x
+ def implTU(c: Context)(x: c.Expr[Int]): c.Tree = x.tree
+ def implUT(c: Context)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x)
+ def implTT(c: Context)(x: c.Expr[Int]): c.Expr[Int] = x
def fooUU(x: Int): Int = macro implUU
def fooTU(x: Int): Int = macro implTU
diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
index c79fc30628..acc47fcde6 100644
--- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
+++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = {
+ def foo(unconventionalName: Context)(x: unconventionalName.Expr[Int]) = {
import unconventionalName.universe._
unconventionalName.Expr[Unit](q"""println("invoking foo...")""")
}
diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
index 55cf0dcafa..705defb18f 100644
--- a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
+++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
+ def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") }
}
diff --git a/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala
index bcc746e39a..fc72e7a979 100644
--- a/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala
+++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U](c: Ctx) = {
+ def foo[U](c: Context) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("don't know U"))))
c.Expr[Unit](body)
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala
index 5a51d27b24..603500b597 100644
--- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx): c.Expr[Int] = {
+ def foo(c: Context): c.Expr[Int] = {
import c.universe._
c.Expr(Literal(Constant("42")))
}
diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
index 44e508a1c6..b6b9611743 100644
--- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.universe._
val body = Ident(TermName("IDoNotExist"))
c.Expr[Int](body)
diff --git a/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala
index a54eaa4001..0d4c5755f0 100644
--- a/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = x
+ def foo(c: Context)(x: c.Expr[Int]) = x
}
object Macros {
diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala
index a67a296335..8b5c59bde8 100644
--- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = {
+ def foo[T: c.WeakTypeTag](c: Context)(x: c.Expr[T]) = {
import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString))))
c.Expr[Unit](body)
diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
index 88929df27a..6970b4dd7e 100644
--- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = {
import c.universe._
val sum = Apply(Select(x.tree, TermName("$plus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum))
diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala
index 22e94f32cd..b60ca90d91 100644
--- a/test/files/run/macro-openmacros/Impls_Macros_1.scala
+++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext): c.Expr[Unit] = {
+ def impl(c: Context): c.Expr[Unit] = {
// we're macros, so we can reflect against our source path
// so we don't need any partests to clean up after us!
val dir = c.enclosingUnit.source.file.file.getCanonicalFile.getParentFile
diff --git a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
index 2417eb6897..b623d8820a 100644
--- a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
+++ b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
@@ -1,8 +1,9 @@
import scala.language.experimental.macros
-import scala.reflect.macros.{Context => Ctx, ParseException}
+import scala.reflect.macros.blackbox.Context
+import scala.reflect.macros.ParseException
object Macros {
- def impl(c: Ctx)() = {
+ def impl(c: Context)() = {
import c.universe._
val out = try {
c.parse("foo(bar")
diff --git a/test/files/run/macro-parse-position/Impls_Macros_1.scala b/test/files/run/macro-parse-position/Impls_Macros_1.scala
index 92f64a8e70..dd20fd291b 100644
--- a/test/files/run/macro-parse-position/Impls_Macros_1.scala
+++ b/test/files/run/macro-parse-position/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: Ctx)() = {
+ def impl(c: Context)() = {
import c.universe._
val t = c.parse("foo bar")
val out = s"${t.pos == NoPosition}\n${t.pos}\n${t.pos.source.content.length}\n${new String(t.pos.source.content)}"
diff --git a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala
index 04aa11b8fe..df189b70d3 100644
--- a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala
+++ b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
object Impls {
- def foo(c: Ctx)(x: c.Expr[Any]) = x
+ def foo(c: Context)(x: c.Expr[Any]) = x
}
def foo(x: Any) = macro Impls.foo
diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala
index 81775d98e8..764542a870 100644
--- a/test/files/run/macro-quasiquotes/Macros_1.scala
+++ b/test/files/run/macro-quasiquotes/Macros_1.scala
@@ -1,7 +1,7 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.blackbox.Context
-trait Impls extends BlackboxMacro {
+class Impls(val c: Context) {
import c.universe._
def impl1 = q"println(1)"
def impl2 = q"{ println(2); println(3) }"
diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala
index 1ad2a6c6eb..0e66815f15 100644
--- a/test/files/run/macro-range/Common_1.scala
+++ b/test/files/run/macro-range/Common_1.scala
@@ -1,4 +1,4 @@
-import reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
abstract class RangeDefault {
val from, to: Int
@@ -10,7 +10,7 @@ abstract class RangeDefault {
/** This class should go into reflect.macro once it is a bit more stable. */
abstract class Utils {
- val context: BlackboxContext
+ val context: Context
import context.universe._
class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer {
diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala
index fa869a2569..514de6864a 100644
--- a/test/files/run/macro-range/Expansion_Impossible_2.scala
+++ b/test/files/run/macro-range/Expansion_Impossible_2.scala
@@ -1,7 +1,7 @@
-import reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foreach(c: BlackboxContext)(f: c.Expr[Int => Unit]): c.Expr[Unit] = {
+ def foreach(c: Context)(f: c.Expr[Int => Unit]): c.Expr[Unit] = {
// todo. read the compiler config and print if -Ydebug is set
//println("macro-expand, _this = "+ _this)
object utils extends Utils { val context: c.type = c }
diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala
index 53b96691e9..e964da2106 100644
--- a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala
+++ b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala
index 81ad5cae0b..89a818d99c 100644
--- a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala
+++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-reify-basic/Macros_1.scala b/test/files/run/macro-reify-basic/Macros_1.scala
index e1a6d8abfb..1cf2a8a406 100644
--- a/test/files/run/macro-reify-basic/Macros_1.scala
+++ b/test/files/run/macro-reify-basic/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo(s: String) = macro Impls.foo
object Impls {
- def foo(c: Ctx)(s: c.Expr[String]) = c.universe.reify {
+ def foo(c: Context)(s: c.Expr[String]) = c.universe.reify {
println("hello " + s.splice)
}
}
diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala
index 2cd94f600a..912f602c6c 100644
--- a/test/files/run/macro-reify-freevars/Macros_1.scala
+++ b/test/files/run/macro-reify-freevars/Macros_1.scala
@@ -2,7 +2,7 @@ package scala.collection.slick
object QueryableMacros{
def map[T:c.WeakTypeTag, S:c.WeakTypeTag]
- (c: scala.reflect.macros.BlackboxContext)
+ (c: scala.reflect.macros.blackbox.Context)
(projection: c.Expr[T => S])
: c.Expr[scala.collection.slick.Queryable[S]] = {
import c.universe._
diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
index 8f7a34a10a..8d2aa1e70a 100644
--- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
-case class Utils[C <: BlackboxContext]( c:C ) {
+case class Utils[C <: Context]( c:C ) {
import c.universe._
import c.{Tree=>_}
object removeDoubleReify extends c.universe.Transformer {
@@ -21,7 +21,7 @@ case class Utils[C <: BlackboxContext]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: BlackboxContext,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
import c.universe._
import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
@@ -34,7 +34,7 @@ object QueryableMacros{
c.universe.reify{ Queryable.factory[S]( foo.splice )}
}
def map[T:c.WeakTypeTag, S:c.WeakTypeTag]
- (c: scala.reflect.macros.BlackboxContext)
+ (c: scala.reflect.macros.blackbox.Context)
(projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
}
class Queryable[T]{
diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
index 8f7a34a10a..8d2aa1e70a 100644
--- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
-case class Utils[C <: BlackboxContext]( c:C ) {
+case class Utils[C <: Context]( c:C ) {
import c.universe._
import c.{Tree=>_}
object removeDoubleReify extends c.universe.Transformer {
@@ -21,7 +21,7 @@ case class Utils[C <: BlackboxContext]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: BlackboxContext,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
import c.universe._
import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
@@ -34,7 +34,7 @@ object QueryableMacros{
c.universe.reify{ Queryable.factory[S]( foo.splice )}
}
def map[T:c.WeakTypeTag, S:c.WeakTypeTag]
- (c: scala.reflect.macros.BlackboxContext)
+ (c: scala.reflect.macros.blackbox.Context)
(projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
}
class Queryable[T]{
diff --git a/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala b/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala
index bc0015774e..38ec6f022e 100644
--- a/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala
+++ b/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
val `Answer to the Ultimate Question of Life, the Universe, and Everything` = 42
- def foo(c: Ctx) = c.universe.reify { `Answer to the Ultimate Question of Life, the Universe, and Everything` }
+ def foo(c: Context) = c.universe.reify { `Answer to the Ultimate Question of Life, the Universe, and Everything` }
}
diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
index d89a5e380d..624479480d 100644
--- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val x1 = c.Expr[Int](c.resetAllAttrs(x.tree))
c.Expr[Int](Literal(Constant(c.eval(x1))))
diff --git a/test/files/run/macro-reify-staticXXX/Macros_1.scala b/test/files/run/macro-reify-staticXXX/Macros_1.scala
index 077271d582..2993218bb4 100644
--- a/test/files/run/macro-reify-staticXXX/Macros_1.scala
+++ b/test/files/run/macro-reify-staticXXX/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object B { override def toString = "object" }
class C { override def toString = "class" }
@@ -14,7 +14,7 @@ object foo {
}
object packageless {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
reify {
println(B)
@@ -31,7 +31,7 @@ object packageless {
package packageful {
object Test {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
reify {
println(B)
diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala
index 56d43c1c53..6f061fd26a 100644
--- a/test/files/run/macro-reify-tagful-a/Macros_1.scala
+++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala
@@ -1,11 +1,11 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[T](s: T) = macro Impls.foo[T]
object Impls {
- def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify {
+ def foo[T: c.WeakTypeTag](c: Context)(s: c.Expr[T]) = c.universe.reify {
List(s.splice)
}
}
diff --git a/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala b/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala
index 27acaa1626..faac3e3a31 100644
--- a/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[T](s: T) = macro Impls.foo[T]
object Impls {
- def foo[T](c: Ctx)(s: c.Expr[T]) = c.universe.reify {
+ def foo[T](c: Context)(s: c.Expr[T]) = c.universe.reify {
List[T](s.splice)
}
}
diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala
index 04634b649a..bac1744c50 100644
--- a/test/files/run/macro-reify-type/Macros_1.scala
+++ b/test/files/run/macro-reify-type/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.runtime.{universe => ru}
object StaticReflect {
def method[A](name: String): ru.Type = macro methodImpl[A]
- def methodImpl[A: c.WeakTypeTag](c: BlackboxContext)(name: c.Expr[String]): c.Expr[ru.Type] = {
+ def methodImpl[A: c.WeakTypeTag](c: Context)(name: c.Expr[String]): c.Expr[ru.Type] = {
import c.universe._
val nameName: TermName = name.tree match {
diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala
index 055959018a..6e358eb72d 100644
--- a/test/files/run/macro-reify-unreify/Macros_1.scala
+++ b/test/files/run/macro-reify-unreify/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo(s: String) = macro Impls.foo
object Impls {
- def foo(c: Ctx)(s: c.Expr[String]) = {
+ def foo(c: Context)(s: c.Expr[String]) = {
import c.universe._
import treeBuild._
diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check
index cc974897f2..86b4d472ed 100644
--- a/test/files/run/macro-repl-basic.check
+++ b/test/files/run/macro-repl-basic.check
@@ -4,25 +4,25 @@ Type :help for more information.
scala> import language.experimental.macros
import language.experimental.macros
-scala> import scala.reflect.macros.{BlackboxContext => Ctx}
-import scala.reflect.macros.{BlackboxContext=>Ctx}
+scala> import scala.reflect.macros.blackbox.Context
+import scala.reflect.macros.blackbox.Context
scala>
scala> object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
c.Expr[Int](body)
}
- def bar(c: Ctx)(x: c.Expr[Int]) = {
+ def bar(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))
c.Expr[Int](body)
}
- def quux(c: Ctx)(x: c.Expr[Int]) = {
+ def quux(c: Context)(x: c.Expr[Int]) = {
import c.universe._
val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))
c.Expr[Int](body)
diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala
index dea36c481c..217f3bc0eb 100644
--- a/test/files/run/macro-repl-basic.scala
+++ b/test/files/run/macro-repl-basic.scala
@@ -3,22 +3,22 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
|import language.experimental.macros
- |import scala.reflect.macros.{BlackboxContext => Ctx}
+ |import scala.reflect.macros.blackbox.Context
|
|object Impls {
- | def foo(c: Ctx)(x: c.Expr[Int]) = {
+ | def foo(c: Context)(x: c.Expr[Int]) = {
| import c.universe._
| val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))
| c.Expr[Int](body)
| }
|
- | def bar(c: Ctx)(x: c.Expr[Int]) = {
+ | def bar(c: Context)(x: c.Expr[Int]) = {
| import c.universe._
| val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))
| c.Expr[Int](body)
| }
|
- | def quux(c: Ctx)(x: c.Expr[Int]) = {
+ | def quux(c: Context)(x: c.Expr[Int]) = {
| import c.universe._
| val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))
| c.Expr[Int](body)
diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check
index 9f538c04b6..20d3b2d702 100644
--- a/test/files/run/macro-repl-dontexpand.check
+++ b/test/files/run/macro-repl-dontexpand.check
@@ -1,14 +1,14 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ???
-bar1: (c: scala.reflect.macros.BlackboxContext)Nothing
+scala> def bar1(c: scala.reflect.macros.blackbox.Context) = ???
+bar1: (c: scala.reflect.macros.blackbox.Context)Nothing
scala> def foo1 = macro bar1
defined term macro foo1: Nothing
-scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
-bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing
+scala> def bar2(c: scala.reflect.macros.whitebox.Context) = ???
+bar2: (c: scala.reflect.macros.whitebox.Context)Nothing
scala> def foo2 = macro bar2
defined term macro foo2: Nothing
diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala
index 733288e513..920f40084f 100644
--- a/test/files/run/macro-repl-dontexpand.scala
+++ b/test/files/run/macro-repl-dontexpand.scala
@@ -3,9 +3,9 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-language:experimental.macros"
def code = """
- |def bar1(c: scala.reflect.macros.BlackboxContext) = ???
+ |def bar1(c: scala.reflect.macros.blackbox.Context) = ???
|def foo1 = macro bar1
- |def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
+ |def bar2(c: scala.reflect.macros.whitebox.Context) = ???
|def foo2 = macro bar2
|""".stripMargin
}
diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala
index c9cecfa99f..851a987206 100644
--- a/test/files/run/macro-settings/Impls_Macros_1.scala
+++ b/test/files/run/macro-settings/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
reify {
println(c.Expr[String](Literal(Constant(c.settings.toString))).splice)
diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
index 3acc52dbe0..ded4d85cfc 100644
--- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
- def impl(c: WhiteboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").toType)
diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala
index f830d2af0d..f66ab71479 100644
--- a/test/files/run/macro-sip19/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
- def impl(c: WhiteboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val Apply(fun, args) = c.enclosingImplicits(0).tree
val fileName = fun.pos.source.file.file.getName
diff --git a/test/files/run/macro-subpatterns/Macro_1.scala b/test/files/run/macro-subpatterns/Macro_1.scala
index d8e86e27c6..2de6b4da9d 100644
--- a/test/files/run/macro-subpatterns/Macro_1.scala
+++ b/test/files/run/macro-subpatterns/Macro_1.scala
@@ -1,9 +1,9 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Extractor {
def unapply(x: Any): Any = macro unapplyImpl
- def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
val st = c.universe.asInstanceOf[reflect.internal.SymbolTable]
import st._
val subpatterns = x.attachments.get[SubpatternsAttachment].get.patterns
diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check
index ceed1079b2..ffbd5a8aa8 100644
--- a/test/files/run/macro-system-properties.check
+++ b/test/files/run/macro-system-properties.check
@@ -1,14 +1,14 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> import language.experimental._, reflect.macros.BlackboxContext
-import language.experimental._
-import reflect.macros.BlackboxContext
+scala> import scala.language.experimental._, scala.reflect.macros.blackbox.Context
+import scala.language.experimental._
+import scala.reflect.macros.blackbox.Context
scala> object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
- def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
+ def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab(): Unit = macro impl
}
defined object GrabContext
diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala
index 3325c1747a..db88eb7df6 100644
--- a/test/files/run/macro-system-properties.scala
+++ b/test/files/run/macro-system-properties.scala
@@ -3,11 +3,11 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
- import language.experimental._, reflect.macros.BlackboxContext
+ import scala.language.experimental._, scala.reflect.macros.blackbox.Context
object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
- def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
+ def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab(): Unit = macro impl
}
object Test { class C(implicit a: Any) { GrabContext.grab } }
diff --git a/test/files/run/macro-term-declared-in-annotation/Impls_1.scala b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala
index df3509731b..c4bcfbc1ba 100644
--- a/test/files/run/macro-term-declared-in-annotation/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-block/Impls_1.scala b/test/files/run/macro-term-declared-in-block/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-block/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-block/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-class-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-class-class/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-class-object/Impls_1.scala b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-class-object/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-class/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-class/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-default-param/Impls_1.scala b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala
index 4fae9b200f..ef0f136139 100644
--- a/test/files/run/macro-term-declared-in-default-param/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala
index 053af625a2..ef00f6ff32 100644
--- a/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala
+++ b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def toOptionOfInt(c: Ctx) = {
+ def toOptionOfInt(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-method/Impls_1.scala b/test/files/run/macro-term-declared-in-method/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-method/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-method/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-object/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-object/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-term-declared-in-trait/Impls_1.scala b/test/files/run/macro-term-declared-in-trait/Impls_1.scala
index d69422872b..c43f5f3f53 100644
--- a/test/files/run/macro-term-declared-in-trait/Impls_1.scala
+++ b/test/files/run/macro-term-declared-in-trait/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
index ce937671cc..956331cfae 100644
--- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl_with_implicits_enabled(c: BlackboxContext) = {
+ def impl_with_implicits_enabled(c: Context) = {
import c.universe._
val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2))))
@@ -11,7 +11,7 @@ object Macros {
def foo_with_implicits_enabled = macro impl_with_implicits_enabled
- def impl_with_implicits_disabled(c: BlackboxContext) = {
+ def impl_with_implicits_disabled(c: Context) = {
import c.universe._
try {
diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
index 45b9a4fcc8..eb558f49b5 100644
--- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl_with_macros_enabled(c: BlackboxContext) = {
+ def impl_with_macros_enabled(c: Context) = {
import c.universe._
val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe"))
@@ -12,7 +12,7 @@ object Macros {
def foo_with_macros_enabled = macro impl_with_macros_enabled
- def impl_with_macros_disabled(c: BlackboxContext) = {
+ def impl_with_macros_disabled(c: Context) = {
import c.universe._
val rupkg = c.mirror.staticModule("scala.reflect.runtime.package")
diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
index d37a654957..3412f5c88f 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl_with_macros_enabled(c: BlackboxContext) = {
+ def impl_with_macros_enabled(c: Context) = {
import c.universe._
val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe"))
@@ -12,7 +12,7 @@ object Macros {
def foo_with_macros_enabled = macro impl_with_macros_enabled
- def impl_with_macros_disabled(c: BlackboxContext) = {
+ def impl_with_macros_disabled(c: Context) = {
import c.universe._
val rupkg = c.mirror.staticModule("scala.reflect.runtime.package")
diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala
index 1af0579abc..5df5f96aa8 100644
--- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala
+++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def cons_impl[A: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = {
+ def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = {
import c.universe._
reify {
println("A = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[A]].toString))).splice)
@@ -10,7 +10,7 @@ object Macros {
}
}
- def nil_impl[B: c.WeakTypeTag](c: BlackboxContext): c.Expr[List[B]] = {
+ def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = {
import c.universe._
reify {
println("B = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[B]].toString))).splice)
diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala
index f698320579..1eb257e1d9 100644
--- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala
+++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl[T: c.WeakTypeTag](c: BlackboxContext)(foo: c.Expr[T]): c.Expr[Unit] = {
+ def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = {
import c.universe._
reify { println(c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[T]].toString))).splice) }
}
diff --git a/test/files/run/macro-vampire-false-warning/Macros_1.scala b/test/files/run/macro-vampire-false-warning/Macros_1.scala
index bf75e924e8..0912bfba0c 100644
--- a/test/files/run/macro-vampire-false-warning/Macros_1.scala
+++ b/test/files/run/macro-vampire-false-warning/Macros_1.scala
@@ -1,20 +1,20 @@
// As per http://meta.plasm.us/posts/2013/08/31/feeding-our-vampires/
import scala.annotation.StaticAnnotation
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import scala.language.experimental.macros
class body(tree: Any) extends StaticAnnotation
object Macros {
- def selFieldImpl(c: WhiteboxContext) = {
+ def selFieldImpl(c: Context) = {
import c.universe._
val field = c.macroApplication.symbol
val bodyAnn = field.annotations.filter(_.tpe <:< typeOf[body]).head
c.Expr[Any](bodyAnn.scalaArgs.head)
}
- def mkObjectImpl(c: WhiteboxContext)(xs: c.Expr[Any]*) = {
+ def mkObjectImpl(c: Context)(xs: c.Expr[Any]*) = {
import c.universe._
import Flag._
// val kvps = xs.toList map { case q"${_}(${Literal(Constant(name: String))}).->[${_}]($value)" => name -> value }
diff --git a/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala
index 87cd310b09..60a8d011f1 100644
--- a/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala
+++ b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import scala.language.experimental.macros
trait Foo[T]
@@ -15,7 +15,7 @@ object Foo extends LowPriority {
}
object Macros {
- def impl[T: c.WeakTypeTag](c: WhiteboxContext) = {
+ def impl[T: c.WeakTypeTag](c: Context) = {
import c.universe._
val tpe = weakTypeOf[T]
if (tpe.members.exists(_.typeSignature =:= typeOf[Int]))
diff --git a/test/files/run/macro-whitebox-extractor/Macros_1.scala b/test/files/run/macro-whitebox-extractor/Macros_1.scala
index 64053b8a24..d394c0241a 100644
--- a/test/files/run/macro-whitebox-extractor/Macros_1.scala
+++ b/test/files/run/macro-whitebox-extractor/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Extractor {
@@ -6,7 +6,7 @@ object Extractor {
}
object Macros {
- def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala
index 671a4fff4e..a8309e35b0 100644
--- a/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala
+++ b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
trait Iso[T, U] {
def to(t : T) : U
@@ -8,7 +8,7 @@ trait Iso[T, U] {
object Iso {
implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U]
- def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: WhiteboxContext): c.Expr[Iso[T, U]] = {
+ def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = {
import c.universe._
import definitions._
import Flag._
diff --git a/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala
index a00f4ed7db..40ca1d549c 100644
--- a/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala
+++ b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala
@@ -1,4 +1,4 @@
-// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+// see the comments for macroExpand.onDelayed for an explanation of what's tested here
object Test extends App {
case class Foo(i: Int, s: String, b: Boolean)
def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
diff --git a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
index b8d0c042be..45fdb79c30 100644
--- a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
+++ b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import scala.language.experimental.macros
object Macros {
- def impl(c: WhiteboxContext) = {
+ def impl(c: Context) = {
import c.universe._
q"""
trait Foo {
diff --git a/test/files/run/macroPlugins-macroArgs.check b/test/files/run/macroPlugins-macroArgs.check
new file mode 100644
index 0000000000..a68f8069b6
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs.check
@@ -0,0 +1,2 @@
+hijacked 1
+hijacked 2
diff --git a/test/files/run/macroPlugins-macroArgs/Macros_2.scala b/test/files/run/macroPlugins-macroArgs/Macros_2.scala
new file mode 100644
index 0000000000..b19b8f18dc
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs/Macros_2.scala
@@ -0,0 +1,11 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl(c: Context)(arg: c.Tree) = {
+ import c.universe._
+ q"""println($arg)"""
+ }
+
+ def foo(arg: String): Unit = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroArgs/Plugin_1.scala b/test/files/run/macroPlugins-macroArgs/Plugin_1.scala
new file mode 100644
index 0000000000..23e80ced3b
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs/Plugin_1.scala
@@ -0,0 +1,21 @@
+package macroArgs
+
+import scala.tools.nsc.Global
+import scala.tools.nsc.plugins.{Plugin => NscPlugin}
+
+class Plugin(val global: Global) extends NscPlugin {
+ import global._
+ import analyzer._
+
+ val name = "macroArgs"
+ val description = "A sample analyzer plugin that overrides macroArgs."
+ val components = Nil
+ addMacroPlugin(MacroPlugin)
+
+ object MacroPlugin extends MacroPlugin {
+ override def pluginsMacroArgs(typer: Typer, expandee: Tree): Option[MacroArgs] = {
+ val MacroArgs(c, List(Literal(Constant(s: String)))) = standardMacroArgs(typer, expandee)
+ Some(MacroArgs(c, List(Literal(Constant("hijacked " + s)))))
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroArgs/Test_3.flags b/test/files/run/macroPlugins-macroArgs/Test_3.flags
new file mode 100644
index 0000000000..966df731d0
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs/Test_3.flags
@@ -0,0 +1 @@
+-Xplugin:. \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroArgs/Test_3.scala b/test/files/run/macroPlugins-macroArgs/Test_3.scala
new file mode 100644
index 0000000000..a54d608178
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs/Test_3.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ Macros.foo("1")
+ Macros.foo("2")
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml b/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml
new file mode 100644
index 0000000000..0849f0f4ea
--- /dev/null
+++ b/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml
@@ -0,0 +1,4 @@
+<plugin>
+ <name>macro-args</name>
+ <classname>macroArgs.Plugin</classname>
+</plugin> \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroExpand.check b/test/files/run/macroPlugins-macroExpand.check
new file mode 100644
index 0000000000..6f685c2af4
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand.check
@@ -0,0 +1,2 @@
+expanded into println("impl1")
+expanded into println("impl2")
diff --git a/test/files/run/macroPlugins-macroExpand/Macros_2.scala b/test/files/run/macroPlugins-macroExpand/Macros_2.scala
new file mode 100644
index 0000000000..c9c88ad2fd
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand/Macros_2.scala
@@ -0,0 +1,18 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl1(c: Context) = {
+ import c.universe._
+ q"""println("impl1")"""
+ }
+
+ def impl2(c: Context) = {
+ import c.universe._
+ q"""println("impl2")"""
+ }
+
+ def foo1: Unit = macro impl1
+
+ def foo2: Unit = macro impl2
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroExpand/Plugin_1.scala b/test/files/run/macroPlugins-macroExpand/Plugin_1.scala
new file mode 100644
index 0000000000..13df85cb23
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand/Plugin_1.scala
@@ -0,0 +1,27 @@
+package macroExpand
+
+import scala.tools.nsc.Global
+import scala.tools.nsc.plugins.{Plugin => NscPlugin}
+
+class Plugin(val global: Global) extends NscPlugin {
+ import global._
+ import analyzer._
+ import scala.reflect.internal.Mode
+
+ val name = "macroExpand"
+ val description = "A sample analyzer plugin that overrides macroExpand."
+ val components = Nil
+ addMacroPlugin(MacroPlugin)
+
+ object MacroPlugin extends MacroPlugin {
+ override def pluginsMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Option[Tree] = {
+ object expander extends DefMacroExpander(typer, expandee, mode, pt) {
+ override def onSuccess(expanded: Tree) = {
+ val message = s"expanded into ${expanded.toString}"
+ typer.typed(q"println($message)")
+ }
+ }
+ Some(expander(expandee))
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroExpand/Test_3.flags b/test/files/run/macroPlugins-macroExpand/Test_3.flags
new file mode 100644
index 0000000000..966df731d0
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand/Test_3.flags
@@ -0,0 +1 @@
+-Xplugin:. \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroExpand/Test_3.scala b/test/files/run/macroPlugins-macroExpand/Test_3.scala
new file mode 100644
index 0000000000..def9b5608a
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand/Test_3.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ Macros.foo1
+ Macros.foo2
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml b/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml
new file mode 100644
index 0000000000..860150865c
--- /dev/null
+++ b/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml
@@ -0,0 +1,4 @@
+<plugin>
+ <name>macro-expand</name>
+ <classname>macroExpand.Plugin</classname>
+</plugin> \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroRuntime.check b/test/files/run/macroPlugins-macroRuntime.check
new file mode 100644
index 0000000000..af16d1ac36
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime.check
@@ -0,0 +1,2 @@
+hijacked
+hijacked
diff --git a/test/files/run/macroPlugins-macroRuntime/Macros_2.scala b/test/files/run/macroPlugins-macroRuntime/Macros_2.scala
new file mode 100644
index 0000000000..b19b8f18dc
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime/Macros_2.scala
@@ -0,0 +1,11 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl(c: Context)(arg: c.Tree) = {
+ import c.universe._
+ q"""println($arg)"""
+ }
+
+ def foo(arg: String): Unit = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala b/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala
new file mode 100644
index 0000000000..a55adadb48
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala
@@ -0,0 +1,20 @@
+package macroRuntime
+
+import scala.tools.nsc.Global
+import scala.tools.nsc.plugins.{Plugin => NscPlugin}
+
+class Plugin(val global: Global) extends NscPlugin {
+ import global._
+ import analyzer._
+
+ val name = "macroRuntime"
+ val description = "A sample analyzer plugin that overrides macroRuntime."
+ val components = Nil
+ addMacroPlugin(MacroPlugin)
+
+ object MacroPlugin extends MacroPlugin {
+ override def pluginsMacroRuntime(expandee: Tree): Option[MacroRuntime] = Some({
+ case MacroArgs(_, List(msg)) => q"""println("hijacked")"""
+ })
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroRuntime/Test_3.flags b/test/files/run/macroPlugins-macroRuntime/Test_3.flags
new file mode 100644
index 0000000000..966df731d0
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime/Test_3.flags
@@ -0,0 +1 @@
+-Xplugin:. \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroRuntime/Test_3.scala b/test/files/run/macroPlugins-macroRuntime/Test_3.scala
new file mode 100644
index 0000000000..a54d608178
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime/Test_3.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ Macros.foo("1")
+ Macros.foo("2")
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml b/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml
new file mode 100644
index 0000000000..8001af1054
--- /dev/null
+++ b/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml
@@ -0,0 +1,4 @@
+<plugin>
+ <name>macro-runtime</name>
+ <classname>macroRuntime.Plugin</classname>
+</plugin> \ No newline at end of file
diff --git a/test/files/run/macroPlugins-namerHooks.check b/test/files/run/macroPlugins-namerHooks.check
new file mode 100644
index 0000000000..c2db5935d4
--- /dev/null
+++ b/test/files/run/macroPlugins-namerHooks.check
@@ -0,0 +1,45 @@
+enterSym(package <empty> { case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } } })
+enterSym(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } })
+ensureCompanionObject(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } }, ...)
+enterSym(<synthetic> object C extends runtime.this.AbstractFunction2[Int, Int, C] { def <init>() = { super.<init>(); () }; final override <synthetic> def toString() = "C" })
+enterStat(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } })
+enterSym(<caseaccessor> <paramaccessor> val x: Int = _)
+enterSym(<caseaccessor> <paramaccessor> val y: Int = _)
+enterSym(def <init>(x: Int, y: Int) = { super.<init>(); () })
+enterSym(<synthetic> def copy(x = x, y = y) = new C(x, y))
+enterStat(<caseaccessor> <paramaccessor> private[this] val x: Int = _)
+enterStat(<caseaccessor> <paramaccessor> private[this] val y: Int = _)
+enterStat(def <init>(x: Int, y: Int) = { super.<init>(); () })
+enterSym(<caseaccessor> <paramaccessor> private[this] val x: Int = _)
+enterSym(<caseaccessor> <paramaccessor> private[this] val y: Int = _)
+enterSym(def <init>(x: Int, y: Int) = { super.<init>(); () })
+enterSym(super.<init>())
+enterStat(super.<init>())
+enterSym(<synthetic> def copy$default$1 = x)
+enterSym(<synthetic> def copy$default$2 = y)
+enterSym(<synthetic> var acc: Int = -889275714)
+enterSym(acc = Statics.this.mix(acc, x))
+enterSym(acc = Statics.this.mix(acc, y))
+enterStat(<synthetic> var acc: Int = -889275714)
+enterStat(acc = Statics.this.mix(acc, x))
+enterStat(acc = Statics.this.mix(acc, y))
+enterSym(<synthetic> val C$1: C = x$1.asInstanceOf[C])
+enterStat(<synthetic> val C$1: C = x$1.asInstanceOf[C])
+enterSym(def <init>() = { super.<init>(); () })
+enterSym(final override <synthetic> def toString() = "C")
+enterSym(case <synthetic> def apply(x: Int, y: Int): C = new C(x, y))
+enterSym(case <synthetic> def unapply(x$0: C) = if (x$0.==(null)) scala.this.None else Some(scala.Tuple2(x$0.x, x$0.y)))
+enterStat(def <init>() = { super.<init>(); () })
+enterStat(final override <synthetic> def toString() = "C")
+enterSym(def <init>() = { super.<init>(); () })
+enterSym(final override <synthetic> def toString() = "C")
+enterSym(super.<init>())
+enterStat(super.<init>())
+enterSym(case <synthetic> val x1: Int = x$1)
+enterStat(case <synthetic> val x1: Int = x$1)
+enterSym(case <synthetic> val x1: Any = x$1)
+enterSym(case5(){ if (x1.isInstanceOf[C]) matchEnd4(true) else case6() })
+enterSym(case6(){ matchEnd4(false) })
+enterStat(case <synthetic> val x1: Any = x$1)
+enterStat(case5(){ if (x1.isInstanceOf[C]) matchEnd4(true) else case6() })
+enterStat(case6(){ matchEnd4(false) })
diff --git a/test/files/run/macroPlugins-namerHooks.scala b/test/files/run/macroPlugins-namerHooks.scala
new file mode 100644
index 0000000000..302429b19e
--- /dev/null
+++ b/test/files/run/macroPlugins-namerHooks.scala
@@ -0,0 +1,39 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends DirectTest {
+ override def extraSettings: String = "-usejavacp"
+
+ def code = """
+ case class C(x: Int, y: Int)
+ """.trim
+
+ def show() {
+ val global = newCompiler()
+ import global._
+ import analyzer._
+
+ val output = collection.mutable.ListBuffer[String]()
+ def log(what: String) = output += what.replace(String.format("%n"), " ")
+
+ object macroPlugin extends MacroPlugin {
+ override def pluginsEnterSym(namer: Namer, tree: Tree): Boolean = {
+ log(s"enterSym($tree)")
+ namer.standardEnterSym(tree)
+ true
+ }
+ override def pluginsEnsureCompanionObject(namer: Namer, cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Option[Symbol] = {
+ log(s"ensureCompanionObject($cdef, ...)")
+ Some(namer.standardEnsureCompanionObject(cdef, creator))
+ }
+ override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = {
+ stats.foreach(stat => log(s"enterStat($stat)"))
+ stats
+ }
+ }
+
+ addMacroPlugin(macroPlugin)
+ compileString(global)(code)
+ println(output.mkString("\n"))
+ }
+}
diff --git a/test/files/run/macroPlugins-typedMacroBody.check b/test/files/run/macroPlugins-typedMacroBody.check
new file mode 100644
index 0000000000..b6f8436189
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody.check
@@ -0,0 +1,2 @@
+impl1
+impl2
diff --git a/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags b/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags
new file mode 100644
index 0000000000..966df731d0
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags
@@ -0,0 +1 @@
+-Xplugin:. \ No newline at end of file
diff --git a/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala b/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala
new file mode 100644
index 0000000000..80acfec659
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala
@@ -0,0 +1,18 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl1(c: Context) = {
+ import c.universe._
+ q"""println("impl1")"""
+ }
+
+ def impl2(c: Context) = {
+ import c.universe._
+ q"""println("impl2")"""
+ }
+
+ def foo1: Unit = macro 1
+
+ def foo2: Unit = macro 2
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala b/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala
new file mode 100644
index 0000000000..e99cf7f75d
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala
@@ -0,0 +1,21 @@
+package typedMacroBody
+
+import scala.tools.nsc.Global
+import scala.tools.nsc.plugins.{Plugin => NscPlugin}
+
+class Plugin(val global: Global) extends NscPlugin {
+ import global._
+ import analyzer._
+
+ val name = "typedMacroBody"
+ val description = "A sample analyzer plugin that overrides typedMacroBody."
+ val components = Nil
+ addMacroPlugin(MacroPlugin)
+
+ object MacroPlugin extends MacroPlugin {
+ override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = {
+ val DefDef(_, _, _, _, _, Literal(Constant(num: Int))) = ddef
+ Some(standardTypedMacroBody(typer, copyDefDef(ddef)(rhs = Ident(TermName("impl" + num)))))
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-typedMacroBody/Test_3.scala b/test/files/run/macroPlugins-typedMacroBody/Test_3.scala
new file mode 100644
index 0000000000..def9b5608a
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody/Test_3.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ Macros.foo1
+ Macros.foo2
+} \ No newline at end of file
diff --git a/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml b/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml
new file mode 100644
index 0000000000..e223fa5dca
--- /dev/null
+++ b/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml
@@ -0,0 +1,4 @@
+<plugin>
+ <name>typed-macro-body</name>
+ <classname>typedMacroBody.Plugin</classname>
+</plugin> \ No newline at end of file
diff --git a/test/files/run/name-based-patmat.check b/test/files/run/name-based-patmat.check
index 1cc605ea3d..3d5fc40ed7 100644
--- a/test/files/run/name-based-patmat.check
+++ b/test/files/run/name-based-patmat.check
@@ -1,3 +1,5 @@
+`catdog only` has 11 chars
+`catdog only, no product` has 23 chars
catdog
2 catdogs! A ha ha!
3 catdogs! A ha ha!
diff --git a/test/files/run/name-based-patmat.scala b/test/files/run/name-based-patmat.scala
index 2c429c141f..8e20940100 100644
--- a/test/files/run/name-based-patmat.scala
+++ b/test/files/run/name-based-patmat.scala
@@ -1,5 +1,33 @@
final class MiniSome[T](val get: T) extends AnyVal { def isEmpty = false }
+package p0 {
+ class Single(val x: Any) extends AnyRef with Product1[String] {
+ private def s = "" + x
+ override def canEqual(x: Any) = this eq x.asInstanceOf[AnyRef]
+ def isEmpty = false
+ def get = this
+ def _1 = s + " only"
+
+ override def toString = s"Single(${_1})"
+ }
+
+ object Single {
+ def unapply(x: Any): Single = new Single(x)
+ }
+
+ class SingleNoProduct(val x: Any) extends AnyRef {
+ private def s = "" + x
+ def isEmpty = false
+ def get = s + " only, no product"
+
+ override def toString = s"SingleNoProduct($get)"
+ }
+
+ object SingleNoProduct {
+ def unapply(x: Any): SingleNoProduct = new SingleNoProduct(x)
+ }
+}
+
package p1 {
class Triple(val x: Any) extends AnyRef with Product3[String, String, String] {
private def s = "" + x
@@ -49,14 +77,16 @@ package p3 {
}
object Test {
-
- // def f(x: Any) = x match {
- // case p1.Foo(x, y, z) => println((x, y, z))
- // case x => println(x)
- // }
-
def main(args: Array[String]): Unit = {
"catdog" match {
+ case p0.Single(x) => println(s"`${x._1}` has ${x._1.length} chars")
+ case x => println("fail: " + x)
+ }
+ "catdog" match {
+ case p0.SingleNoProduct(x) => println(s"`$x` has ${x.length} chars")
+ case x => println("fail: " + x)
+ }
+ "catdog" match {
case p1.Triple(x, y, z) => List(x, y, z) foreach println
case x => println("fail: " + x)
}
diff --git a/test/files/run/patmat-mix-case-extractor.check b/test/files/run/patmat-mix-case-extractor.check
new file mode 100644
index 0000000000..a6e1bd23df
--- /dev/null
+++ b/test/files/run/patmat-mix-case-extractor.check
@@ -0,0 +1,8 @@
+-1
+6
+4
+18
+-1
+1006
+1004
+1018
diff --git a/test/files/run/patmat-mix-case-extractor.scala b/test/files/run/patmat-mix-case-extractor.scala
new file mode 100644
index 0000000000..964e6f743c
--- /dev/null
+++ b/test/files/run/patmat-mix-case-extractor.scala
@@ -0,0 +1,110 @@
+trait CaseClass
+trait ProdCaseClass extends CaseClass { def x: Int }
+trait SeqCaseClass extends CaseClass { def xs: Seq[Int] }
+
+case class CaseClass1() extends CaseClass
+case class CaseClass2(xs: Int*) extends SeqCaseClass
+case class CaseClass3(x: Int) extends ProdCaseClass
+case class CaseClass4(x: Int, xs: Int*) extends ProdCaseClass with SeqCaseClass
+
+object Extractor1 { def unapply(x: CaseClass): Boolean = false }
+object Extractor2 { def unapplySeq(x: SeqCaseClass): Option[Seq[Int]] = Some(x.xs) }
+object Extractor3 { def unapply(x: ProdCaseClass): Option[Int] = Some(x.x) }
+object Extractor4 { def unapplySeq(x: ProdCaseClass with SeqCaseClass): Option[(Int, Seq[Int])] = Some(x.x, x.xs) }
+
+class A {
+ def f1(x: Any) = x match {
+ case CaseClass1() => -1
+ case CaseClass2(xs @ _*) => xs.sum
+ case CaseClass3(x) => x
+ case CaseClass4(x, xs @ _*) => x + xs.sum
+ case Extractor4(x, xs @ _*) => 1000 + x + xs.sum
+ case Extractor3(x) => 1000 + x
+ case Extractor2(xs @ _*) => 1000 + xs.sum
+ case Extractor1() => -3
+ case _ => -2
+ }
+ def f2(x: Any) = x match {
+ case Extractor4(x, xs @ _*) => 1000 + x + xs.sum
+ case Extractor3(x) => 1000 + x
+ case Extractor2(xs @ _*) => 1000 + xs.sum
+ case Extractor1() => -3
+ case CaseClass1() => -1
+ case CaseClass2(xs @ _*) => xs.sum
+ case CaseClass3(x) => x
+ case CaseClass4(x, xs @ _*) => x + xs.sum
+ case _ => -2
+ }
+ def run() {
+ List(
+ f1(CaseClass1()),
+ f1(CaseClass2(1, 2, 3)),
+ f1(CaseClass3(4)),
+ f1(CaseClass4(5, 6, 7)),
+ f2(CaseClass1()),
+ f2(CaseClass2(1, 2, 3)),
+ f2(CaseClass3(4)),
+ f2(CaseClass4(5, 6, 7))
+ ) foreach println
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ (new A).run
+ }
+}
+
+
+class B {
+ case class CaseClass0()
+ case class CaseClass0v(xs: Int*)
+
+ case class CaseClass(x: Int, y: Int)
+ object Extractor { def unapply(x: Any): Option[(Int, Int)] = Some((1, 1)) }
+
+ case class CaseSeq(x: Char, y: Double, zs: Int*)
+ object ExtractorSeq { def unapplySeq(x: Any): Option[(Int, Int, Seq[Int])] = Some((1, 1, List(1))) }
+
+ def f1(x: CaseClass) = x match { case CaseClass(y, z) => y }
+ def f2(x: Any) = x match { case Extractor(y, z) => y }
+
+ def f3(x: CaseSeq) = x match {
+ case CaseSeq(x, y) => y
+ case CaseSeq(x, y, z) => z
+ }
+ def f4(x: CaseSeq) = x match {
+ case CaseSeq(x, y, z) => z :: Nil
+ case CaseSeq(x, y, z @ _*) => z
+ }
+
+ def f5(x: Any) = x match { case ExtractorSeq(x, y, z) => z }
+ def f6(x: Any) = x match { case ExtractorSeq(x, y, z @ _*) => z }
+
+ def g1(x: CaseClass0) = x match {
+ case CaseClass0() => true
+ }
+ def g2(x: CaseClass0v) = x match {
+ case CaseClass0v() => true
+ case CaseClass0v(5) => true
+ case CaseClass0v(x) => true
+ case CaseClass0v(xs @ _*) => false
+ }
+}
+
+package p1 {
+ trait _X {
+ case class _Foo();
+ object _Bar {
+ def unapply(foo: _Foo): Boolean = true;
+ }
+ }
+
+ object Y extends _X {
+ val foo = _Foo()
+ foo match {
+ case _Bar() =>
+ case _ => assert(false)
+ }
+ }
+}
diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check
index d4cf660758..4f1c61cf0e 100644
--- a/test/files/run/reify_ann3.check
+++ b/test/files/run/reify_ann3.check
@@ -1,5 +1,5 @@
{
- class Tree[A, B] extends AnyRef {
+ class Tree[A, +B] extends AnyRef {
@new inline @getter() final <paramaccessor> val key: A = _;
def <init>(key: A) = {
super.<init>();
@@ -9,7 +9,7 @@
()
}
{
- class Tree[A, B] extends AnyRef {
+ class Tree[A, +B] extends AnyRef {
final <paramaccessor> private[this] val key: A = _;
@inline @scala.annotation.meta.getter final <stable> <accessor> <paramaccessor> def key: A = Tree.this.key;
def <init>(key: A): Tree[A,B] = {
diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check
index f73abb5dc3..3580bfe1f1 100644
--- a/test/files/run/repl-term-macros.check
+++ b/test/files/run/repl-term-macros.check
@@ -1,16 +1,16 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> import scala.reflect.macros.BlackboxContext
-import scala.reflect.macros.BlackboxContext
+scala> import scala.reflect.macros.blackbox.Context
+import scala.reflect.macros.blackbox.Context
scala> import language.experimental.macros
import language.experimental.macros
scala>
-scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
-impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit]
+scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+impl1: (c: scala.reflect.macros.blackbox.Context)c.Expr[Unit]
scala> def foo1: Unit = macro impl1
defined term macro foo1: Unit
@@ -19,8 +19,8 @@ scala> foo1
scala>
-scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
-impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit]
+scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
+impl2: (c: scala.reflect.macros.blackbox.Context)()c.Expr[Unit]
scala> def foo2(): Unit = macro impl2
defined term macro foo2: ()Unit
@@ -29,8 +29,8 @@ scala> foo2()
scala>
-scala> def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
-impl3: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
+scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
+impl3: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
scala> def foo3(x: Int)(y: Int): Unit = macro impl3
defined term macro foo3: (x: Int)(y: Int)Unit
diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala
index b4660e258e..32892b7314 100644
--- a/test/files/run/repl-term-macros.scala
+++ b/test/files/run/repl-term-macros.scala
@@ -2,18 +2,18 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
- import scala.reflect.macros.BlackboxContext
+ import scala.reflect.macros.blackbox.Context
import language.experimental.macros
-def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo1: Unit = macro impl1
foo1
-def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
+def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
def foo2(): Unit = macro impl2
foo2()
-def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
+def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
def foo3(x: Int)(y: Int): Unit = macro impl3
foo3(2)(3)
"""
diff --git a/test/files/run/t4287inferredMethodTypes.check b/test/files/run/t4287inferredMethodTypes.check
new file mode 100644
index 0000000000..56e9c097cc
--- /dev/null
+++ b/test/files/run/t4287inferredMethodTypes.check
@@ -0,0 +1,30 @@
+[[syntax trees at end of typer]] // newSource1.scala
+[0:92]package [0:0]<empty> {
+ [0:21]class A extends [7:21][23]scala.AnyRef {
+ [8:16]<paramaccessor> private[this] val a: [8]Int = _;
+ <8:20>def <init>(<8:20>a: [11]<type: [11]scala.Int> = [17:20]A.a): [7]A = <8:20>{
+ <8:20><8:20><8:20>A.super.<init>();
+ <8:20>()
+ }
+ };
+ [23:47]object A extends [32:47][49]scala.AnyRef {
+ [49]def <init>(): [32]A.type = [49]{
+ [49][49][49]A.super.<init>();
+ [32]()
+ };
+ [36:45]private[this] val a: [40]Int = [44:45]2;
+ [40]<stable> <accessor> def a: [40]Int = [40][40]A.this.a;
+ [8]<synthetic> def <init>$default$1: [8]Int = [19]A.a
+ };
+ [49:92]class B extends [57:92][65:66]A {
+ [65]def <init>(): [57]B = [65]{
+ [65][65][65]B.super.<init>([65]A.<init>$default$1);
+ [57]()
+ };
+ [70:90]def <init>([79:80]a: [79]Int): [74]B = [84:90]{
+ [84:90][84:90][84]B.this.<init>();
+ [84]()
+ }
+ }
+}
+
diff --git a/test/files/run/t4287inferredMethodTypes.scala b/test/files/run/t4287inferredMethodTypes.scala
new file mode 100644
index 0000000000..f14e672da8
--- /dev/null
+++ b/test/files/run/t4287inferredMethodTypes.scala
@@ -0,0 +1,25 @@
+import scala.tools.partest.DirectTest
+
+object Test extends DirectTest {
+
+ override def extraSettings: String =
+ s"-usejavacp -Yinfer-argument-types -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}"
+
+ override def code = """
+class A(a: Int = A.a)
+
+object A {
+ val a = 2
+}
+
+class B extends A {
+ def this(a) = this()
+}
+ """.trim
+
+ override def show(): Unit = {
+ Console.withErr(System.out) {
+ compile()
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check
index 188f39ff82..760a92567c 100644
--- a/test/files/run/t5603.check
+++ b/test/files/run/t5603.check
@@ -10,10 +10,10 @@
[87:209]class C extends [94:209][151:159]Greeting {
[119:139]val nameElse = _;
[95:101]<paramaccessor> private[this] val i: [98:101]Int = _;
- <119:139>def <init>([95]i: [98]Int) = <119:139>{
+ <95:139>def <init>(<95:101>i: [98]Int) = <95:139>{
<119:139>val nameElse = <134:139>"Bob";
[NoPosition][NoPosition][NoPosition]super.<init>();
- [94]()
+ <95:139>()
};
[168:184]val name = [179:184]"avc";
[191:203][191:198]println([199:202]msg)
diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala
index bfe2fc4efd..7b04197cfa 100644
--- a/test/files/run/t5713/Impls_Macros_1.scala
+++ b/test/files/run/t5713/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
package m
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Level extends Enumeration {
val Error = Value(5)
@@ -13,7 +13,7 @@ object Logger {
private object LoggerMacros {
- type LoggerContext = BlackboxContext { type PrefixType = Logger.type }
+ type LoggerContext = Context { type PrefixType = Logger.type }
def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] =
log(c)(c.universe.reify(Level.Error), message)
diff --git a/test/files/run/t5753_1/Impls_Macros_1.scala b/test/files/run/t5753_1/Impls_Macros_1.scala
index 3ddff56c38..ce07138852 100644
--- a/test/files/run/t5753_1/Impls_Macros_1.scala
+++ b/test/files/run/t5753_1/Impls_Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
trait Impls {
- def impl(c: BlackboxContext)(x: c.Expr[Any]) = x
+ def impl(c: Context)(x: c.Expr[Any]) = x
}
object Macros extends Impls {
diff --git a/test/files/run/t5753_2/Impls_Macros_1.scala b/test/files/run/t5753_2/Impls_Macros_1.scala
index c95c9a41b3..d446d37bdf 100644
--- a/test/files/run/t5753_2/Impls_Macros_1.scala
+++ b/test/files/run/t5753_2/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.blackbox.Context
trait Macro_T {
- def foo[T](c: Ctx)(s: c.Expr[T]) = s
+ def foo[T](c: Context)(s: c.Expr[T]) = s
}
object Macros {
diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala
index 5d482333f5..6e118fd396 100644
--- a/test/files/run/t5894.scala
+++ b/test/files/run/t5894.scala
@@ -1,10 +1,11 @@
-import language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+import scala.language.experimental.macros
class Test
object Test {
def foo: Unit = macro fooImpl
- def fooImpl(c: reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def fooImpl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def main(args: Array[String]) {
try {
diff --git a/test/files/run/t5903a/Macros_1.scala b/test/files/run/t5903a/Macros_1.scala
index ce1b035260..5d084ceed5 100644
--- a/test/files/run/t5903a/Macros_1.scala
+++ b/test/files/run/t5903a/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
trait Tree
@@ -13,7 +13,7 @@ object NewQuasiquotes {
}
object QuasiquoteMacros {
- def unapplyImpl(c: WhiteboxContext)(t: c.Tree) = {
+ def unapplyImpl(c: Context)(t: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/run/t5903b/Macros_1.scala b/test/files/run/t5903b/Macros_1.scala
index 97f15cec3b..29a05f7fec 100644
--- a/test/files/run/t5903b/Macros_1.scala
+++ b/test/files/run/t5903b/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/run/t5903c/Macros_1.scala b/test/files/run/t5903c/Macros_1.scala
index 979284a263..34fe1d8808 100644
--- a/test/files/run/t5903c/Macros_1.scala
+++ b/test/files/run/t5903c/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/run/t5903d/Macros_1.scala b/test/files/run/t5903d/Macros_1.scala
index dc1989462b..f1f8dc1fde 100644
--- a/test/files/run/t5903d/Macros_1.scala
+++ b/test/files/run/t5903d/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ def unapplyImpl(c: Context)(x: c.Tree) = {
import c.universe._
q"""
new {
diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala
index 445392ff95..9aa7a02708 100644
--- a/test/files/run/t5923a/Macros_1.scala
+++ b/test/files/run/t5923a/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
case class C[T](t: String)
@@ -7,7 +7,7 @@ object C {
}
object Macros {
- def impl[T](c: WhiteboxContext)(ttag: c.WeakTypeTag[T]) = {
+ def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = {
import c.universe._
val ttag0 = ttag;
{
diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala
index b6e7134b95..1400674d4b 100644
--- a/test/files/run/t5923d/Macros_1.scala
+++ b/test/files/run/t5923d/Macros_1.scala
@@ -1,9 +1,9 @@
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
trait MappedRow
trait RowMapper[T <: MappedRow]
object RowMapper {
implicit def mapper[T <: MappedRow]: RowMapper[T] = macro impl[T]
- def impl[T <: MappedRow : c.WeakTypeTag](c: BlackboxContext) = c.universe.reify(new RowMapper[T]{})
+ def impl[T <: MappedRow : c.WeakTypeTag](c: Context) = c.universe.reify(new RowMapper[T]{})
} \ No newline at end of file
diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala
index 062f11c467..7b025b43af 100644
--- a/test/files/run/t5940.scala
+++ b/test/files/run/t5940.scala
@@ -4,15 +4,15 @@ object Test extends DirectTest {
def code = ???
def macros_1 = """
- import scala.reflect.macros.BlackboxContext
+ import scala.reflect.macros.blackbox.Context
object Impls {
- def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
}
object Macros {
//import Impls._
- def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo: Unit = macro impl
}
"""
diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check
index c833b45443..97ee68271a 100644
--- a/test/files/run/t6187.check
+++ b/test/files/run/t6187.check
@@ -1,15 +1,15 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> import language.experimental.macros, reflect.macros.BlackboxContext
-import language.experimental.macros
-import reflect.macros.BlackboxContext
+scala> import scala.language.experimental.macros, scala.reflect.macros.blackbox.Context
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
-scala> def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(t: c.Expr[T]): c.Expr[List[T]] = {
+scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
val r = c.universe.reify { List(t.splice) }
c.Expr[List[T]]( c.resetLocalAttrs(r.tree) )
}
-macroImpl: [T](c: scala.reflect.macros.BlackboxContext)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]]
+macroImpl: [T](c: scala.reflect.macros.blackbox.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]]
scala> def demo[T](t: T): List[T] = macro macroImpl[T]
defined term macro demo: [T](t: T)List[T]
diff --git a/test/files/run/t6187.scala b/test/files/run/t6187.scala
index fc6fa6e9a7..7d84419b8a 100644
--- a/test/files/run/t6187.scala
+++ b/test/files/run/t6187.scala
@@ -2,8 +2,8 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def code = """
-import language.experimental.macros, reflect.macros.BlackboxContext
-def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(t: c.Expr[T]): c.Expr[List[T]] = {
+import scala.language.experimental.macros, scala.reflect.macros.blackbox.Context
+def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
val r = c.universe.reify { List(t.splice) }
c.Expr[List[T]]( c.resetLocalAttrs(r.tree) )
}
diff --git a/test/files/run/t6221/Macros_1.scala b/test/files/run/t6221/Macros_1.scala
index 60ed0aa3e3..b5c28360fa 100644
--- a/test/files/run/t6221/Macros_1.scala
+++ b/test/files/run/t6221/Macros_1.scala
@@ -1,6 +1,6 @@
import language.experimental.macros
import language.implicitConversions
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import scala.reflect.runtime.universe.Tree
class ReflectiveClosure[A, B](val tree: Tree, fn: A => B) extends (A => B) {
@@ -12,7 +12,7 @@ object ReflectiveClosure {
}
object Macros {
- def reflectiveClosureImpl[A, B](c: BlackboxContext)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = {
+ def reflectiveClosureImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = {
import c.universe._
val u = treeBuild.mkRuntimeUniverseRef
val m = EmptyTree
diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check
index ef08d0da09..4ed11d59ff 100644
--- a/test/files/run/t6381.check
+++ b/test/files/run/t6381.check
@@ -1,14 +1,14 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> import language.experimental.macros
-import language.experimental.macros
+scala> import scala.language.experimental.macros
+import scala.language.experimental.macros
-scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = {
+scala> def pos_impl(c: scala.reflect.macros.blackbox.Context): c.Expr[String] = {
import c.universe._
c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString)))
}
-pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String]
+pos_impl: (c: scala.reflect.macros.blackbox.Context)c.Expr[String]
scala> def pos: String = macro pos_impl
defined term macro pos: String
diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala
index c78dc13ed7..5a687c10c1 100644
--- a/test/files/run/t6381.scala
+++ b/test/files/run/t6381.scala
@@ -2,8 +2,8 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
- |import language.experimental.macros
- |def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = {
+ |import scala.language.experimental.macros
+ |def pos_impl(c: scala.reflect.macros.blackbox.Context): c.Expr[String] = {
| import c.universe._
| c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString)))
|}
diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala
index b934b5ebb1..376d85ba67 100644
--- a/test/files/run/t6394a/Macros_1.scala
+++ b/test/files/run/t6394a/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c:BlackboxContext): c.Expr[Any] = {
+ def impl(c:Context): c.Expr[Any] = {
import c.universe._
val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass)
diff --git a/test/files/run/t6394b/Macros_1.scala b/test/files/run/t6394b/Macros_1.scala
index 01fbc4f09e..53215e63aa 100644
--- a/test/files/run/t6394b/Macros_1.scala
+++ b/test/files/run/t6394b/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c:BlackboxContext): c.Expr[Any] = {
+ def impl(c:Context): c.Expr[Any] = {
import c.universe._
val selfTree = This(tpnme.EMPTY)
diff --git a/test/files/run/t6662/Macro_1.scala b/test/files/run/t6662/Macro_1.scala
index cecf242f66..419859772d 100644
--- a/test/files/run/t6662/Macro_1.scala
+++ b/test/files/run/t6662/Macro_1.scala
@@ -1,8 +1,8 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Demo {
def id[T](a: T): T = macro idImpl[T]
- def idImpl[T: c.WeakTypeTag](c: BlackboxContext)(a: c.Expr[T]): c.Expr[T] = a
+ def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a
}
diff --git a/test/files/run/t6992/Macros_1.scala b/test/files/run/t6992/Macros_1.scala
index 25566dddbf..d101efdda3 100644
--- a/test/files/run/t6992/Macros_1.scala
+++ b/test/files/run/t6992/Macros_1.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Context
+import scala.reflect.macros.whitebox.Context
object Macros {
def foo(name: String): Any = macro foo_impl
diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala
index 0ce5daf0d0..7049ed6490 100644
--- a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala
+++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala
@@ -1,8 +1,8 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList
val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL)
diff --git a/test/files/run/t7008/Impls_Macros_2.scala b/test/files/run/t7008/Impls_Macros_2.scala
index 6da9dca913..9dfa66a20a 100644
--- a/test/files/run/t7008/Impls_Macros_2.scala
+++ b/test/files/run/t7008/Impls_Macros_2.scala
@@ -1,8 +1,8 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
val decls = c.typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList
val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL)
diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala
index 0d64729791..787ea6cfe8 100644
--- a/test/files/run/t7047/Impls_Macros_1.scala
+++ b/test/files/run/t7047/Impls_Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
class Foo
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
try {
c.inferImplicitValue(typeOf[Foo], silent = false)
diff --git a/test/files/run/t7157/Impls_Macros_1.scala b/test/files/run/t7157/Impls_Macros_1.scala
index e48fbcaed3..cc258b016a 100644
--- a/test/files/run/t7157/Impls_Macros_1.scala
+++ b/test/files/run/t7157/Impls_Macros_1.scala
@@ -1,9 +1,9 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
object AImpl {
- def a(ctx: BlackboxContext)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = {
+ def a(ctx: Context)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = {
import ctx.universe._
ctx.Expr[Unit](Apply(Ident(TermName("println")), List(Literal(Constant(1)))))
}
diff --git a/test/files/run/t7240/Macros_1.scala b/test/files/run/t7240/Macros_1.scala
index 84ad231043..019ddf7cd6 100644
--- a/test/files/run/t7240/Macros_1.scala
+++ b/test/files/run/t7240/Macros_1.scala
@@ -1,7 +1,7 @@
package bakery
import scala.language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
trait FailureCake {
implicit def liftAnyFails[T: Manifest]: Any = ???
@@ -13,7 +13,7 @@ trait FailureCake {
object Bakery {
def failure: Any = macro failureImpl
- def failureImpl(c: BlackboxContext): c.Expr[Any] = {
+ def failureImpl(c: Context): c.Expr[Any] = {
import c.universe._
def dslTrait(dslName: String) = {
diff --git a/test/files/run/t7326.scala b/test/files/run/t7326.scala
new file mode 100644
index 0000000000..ed9471ea8e
--- /dev/null
+++ b/test/files/run/t7326.scala
@@ -0,0 +1,64 @@
+import scala.collection.immutable.ListSet
+import scala.collection.immutable.HashSet
+
+object Test extends App {
+
+ def testCorrectness() {
+ // a key that has many hashCode collisions
+ case class Collision(i: Int) { override def hashCode = i / 5 }
+
+ def subsetTest[T](emptyA:Set[T], emptyB:Set[T], mkKey:Int => T, n:Int) {
+ val outside = mkKey(n + 1)
+ for(i <- 0 to n) {
+ val a = emptyA ++ (0 until i).map(mkKey)
+ // every set must be a subset of itself
+ require(a.subsetOf(a), "A set must be the subset of itself")
+ for(k <- 0 to i) {
+ // k <= i, so b is definitely a subset
+ val b = emptyB ++ (0 until k).map(mkKey)
+ // c has less elements than a, but contains a value that is not in a
+ // so it is not a subset, but that is not immediately obvious due to size
+ val c = b + outside
+ require(b.subsetOf(a), s"$b must be a subset of $a")
+ require(!c.subsetOf(a), s"$c must not be a subset of $a")
+ }
+ }
+ }
+
+ // test the HashSet/HashSet case
+ subsetTest(HashSet.empty[Int], HashSet.empty[Int], identity, 100)
+
+ // test the HashSet/other set case
+ subsetTest(HashSet.empty[Int], ListSet.empty[Int], identity, 100)
+
+ // test the HashSet/HashSet case for Collision keys
+ subsetTest(HashSet.empty[Collision], HashSet.empty[Collision], Collision, 100)
+
+ // test the HashSet/other set case for Collision keys
+ subsetTest(HashSet.empty[Collision], ListSet.empty[Collision], Collision, 100)
+ }
+
+ /**
+ * A main performance benefit of the new subsetOf is that we do not have to call hashCode during subsetOf
+ * since we already have the hash codes in the HashSet1 nodes.
+ */
+ def testNoHashCodeInvocationsDuringSubsetOf() = {
+ var count = 0
+
+ case class HashCodeCounter(i:Int) {
+ override def hashCode = {
+ count += 1
+ i
+ }
+ }
+
+ val a = HashSet.empty ++ (0 until 100).map(HashCodeCounter)
+ val b = HashSet.empty ++ (0 until 50).map(HashCodeCounter)
+ val count0 = count
+ val result = b.subsetOf(a)
+ require(count == count0, "key.hashCode must not be called during subsetOf of two HashSets")
+ result
+ }
+ testCorrectness()
+ testNoHashCodeInvocationsDuringSubsetOf()
+}
diff --git a/test/files/run/t7375b/Macros_1.scala b/test/files/run/t7375b/Macros_1.scala
index bcd8e52172..b6090e730b 100644
--- a/test/files/run/t7375b/Macros_1.scala
+++ b/test/files/run/t7375b/Macros_1.scala
@@ -1,5 +1,5 @@
import language.experimental.macros
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
class C1(val n: Int) extends AnyVal
class C2(val n: Int) extends AnyRef
@@ -9,7 +9,7 @@ object Macros {
type F2 = C2
def foo = macro impl
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
def test[T: c.TypeTag] = reify(println(c.Expr[String](Literal(Constant(c.reifyRuntimeClass(c.typeOf[T]).toString))).splice)).tree
def tests = Block(List(test[C1], test[C2], test[F1], test[F2]), Literal(Constant(())))
diff --git a/test/files/run/t7617a/Macros_1.scala b/test/files/run/t7617a/Macros_1.scala
index d19f112bf4..77b18c20e2 100644
--- a/test/files/run/t7617a/Macros_1.scala
+++ b/test/files/run/t7617a/Macros_1.scala
@@ -1,12 +1,12 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
- def getValueImpl[T](c: BlackboxContext): c.Expr[T] = {
+ def getValueImpl[T](c: Context): c.Expr[T] = {
import c.universe._
c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil))
}
- def setValueImpl[T](c: BlackboxContext)(value: c.Expr[T]): c.Expr[Unit] = {
+ def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = {
import c.universe._
c.Expr[Unit](Apply(Select(c.prefix.tree, newTermName("setVal")), List(value.tree)))
}
diff --git a/test/files/run/t7617b/Macros_1.scala b/test/files/run/t7617b/Macros_1.scala
index b1406f30bb..90fcfda47d 100644
--- a/test/files/run/t7617b/Macros_1.scala
+++ b/test/files/run/t7617b/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
object Macros {
- def impl(c: BlackboxContext)(name: c.Expr[String])(value: c.Expr[Any]) = {
+ def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = {
import c.universe._
reify(println(s"${name.splice} = ${value.splice}"))
}
diff --git a/test/files/run/t7657/Macros_1.scala b/test/files/run/t7657/Macros_1.scala
index 9aac02031d..a883f76bc3 100644
--- a/test/files/run/t7657/Macros_1.scala
+++ b/test/files/run/t7657/Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
trait T { def t(): Unit }
abstract class A extends T { override def t(): Unit = () }
-object Macro { def t(c: BlackboxContext)(): c.Expr[Unit] = c.universe.reify(()) }
+object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
class C extends A { override def t(): Unit = macro Macro.t }
diff --git a/test/files/run/t7777/Macros_1.scala b/test/files/run/t7777/Macros_1.scala
index 459ab3edbb..1dc6d6740c 100644
--- a/test/files/run/t7777/Macros_1.scala
+++ b/test/files/run/t7777/Macros_1.scala
@@ -1,6 +1,6 @@
import scala.language.experimental.macros
import scala.language.dynamics
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
class DynMacro extends Dynamic {
def applyDynamic(s: String)(xs: Any*): DynMacro =
@@ -8,7 +8,7 @@ class DynMacro extends Dynamic {
}
object DynMacro extends DynMacro {
- def applyDynamicMacro(c: WhiteboxContext)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = {
+ def applyDynamicMacro(c: Context)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = {
import c.universe._
val Literal(Constant(n: String)) = s.tree
val args = xs.map(_.tree.toString).mkString("(", ", ", ")")
diff --git a/test/files/run/t7871/Macros_1.scala b/test/files/run/t7871/Macros_1.scala
index 801a6af4e7..dca2508128 100644
--- a/test/files/run/t7871/Macros_1.scala
+++ b/test/files/run/t7871/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.whitebox.Context
import language.experimental.macros
trait Tree
diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check
new file mode 100644
index 0000000000..0be496d8d0
--- /dev/null
+++ b/test/files/run/t7974.check
@@ -0,0 +1,104 @@
+public class Symbols {
+
+ // compiled from: Symbols.scala
+
+
+
+ // access flags 0x12
+ private final Lscala/Symbol; someSymbol3
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$1
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$2
+
+ // access flags 0xA
+ private static Lscala/Symbol; symbol$3
+
+ // access flags 0x9
+ public static <clinit>()V
+ L0
+ LINENUMBER 2 L0
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic1"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ L1
+ LINENUMBER 3 L1
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic2"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$2 : Lscala/Symbol;
+ L2
+ LINENUMBER 5 L2
+ GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
+ LDC "Symbolic3"
+ INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
+ PUTSTATIC Symbols.symbol$3 : Lscala/Symbol;
+ RETURN
+ MAXSTACK = 2
+ MAXLOCALS = 0
+
+ // access flags 0x1
+ public someSymbol1()Lscala/Symbol;
+ L0
+ LINENUMBER 2 L0
+ GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public someSymbol2()Lscala/Symbol;
+ L0
+ LINENUMBER 3 L0
+ GETSTATIC Symbols.symbol$2 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public sameSymbol1()Lscala/Symbol;
+ L0
+ LINENUMBER 4 L0
+ GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public someSymbol3()Lscala/Symbol;
+ L0
+ LINENUMBER 5 L0
+ ALOAD 0
+ GETFIELD Symbols.someSymbol3 : Lscala/Symbol;
+ ARETURN
+ L1
+ LOCALVARIABLE this LSymbols; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+
+ // access flags 0x1
+ public <init>()V
+ L0
+ LINENUMBER 6 L0
+ ALOAD 0
+ INVOKESPECIAL java/lang/Object.<init> ()V
+ L1
+ LINENUMBER 5 L1
+ ALOAD 0
+ GETSTATIC Symbols.symbol$3 : Lscala/Symbol;
+ PUTFIELD Symbols.someSymbol3 : Lscala/Symbol;
+ RETURN
+ L2
+ LOCALVARIABLE this LSymbols; L0 L2 0
+ MAXSTACK = 2
+ MAXLOCALS = 1
+}
diff --git a/test/files/run/t7974/Symbols.scala b/test/files/run/t7974/Symbols.scala
new file mode 100644
index 0000000000..2363b724eb
--- /dev/null
+++ b/test/files/run/t7974/Symbols.scala
@@ -0,0 +1,6 @@
+class Symbols {
+ def someSymbol1 = 'Symbolic1
+ def someSymbol2 = 'Symbolic2
+ def sameSymbol1 = 'Symbolic1
+ val someSymbol3 = 'Symbolic3
+}
diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala
new file mode 100644
index 0000000000..9403ea332b
--- /dev/null
+++ b/test/files/run/t7974/Test.scala
@@ -0,0 +1,20 @@
+import java.io.PrintWriter;
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm.util._
+import scala.tools.nsc.util.stringFromWriter
+
+object Test extends BytecodeTest {
+ def show {
+ val classNode = loadClassNode("Symbols", skipDebugInfo = false)
+ val textifier = new Textifier
+ classNode.accept(new TraceClassVisitor(null, textifier, null))
+
+ val classString = stringFromWriter(w => textifier.print(w))
+ val result =
+ classString.split('\n')
+ .dropWhile(elem => elem != "public class Symbols {")
+ .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig"))
+ result foreach println
+ }
+}
diff --git a/test/files/run/t8046.check b/test/files/run/t8046.check
new file mode 100644
index 0000000000..905b0b35ca
--- /dev/null
+++ b/test/files/run/t8046.check
@@ -0,0 +1,2 @@
+List(trait Op, trait Function1, class Object, class Any)
+BTS(T,Three.this.Op[Int],Int => Int,Object,Any)
diff --git a/test/files/run/t8046/Test.scala b/test/files/run/t8046/Test.scala
new file mode 100644
index 0000000000..f6b525d1b5
--- /dev/null
+++ b/test/files/run/t8046/Test.scala
@@ -0,0 +1,18 @@
+import scala.tools.partest._
+
+object Test extends DirectTest {
+ override def code = ""
+ override def extraSettings: String = "-usejavacp"
+
+ override def show() {
+ val c = newCompiler()
+ new c.Run
+ import c._
+
+ val f4 = typeOf[Three].member(newTermName("f4"))
+ val f4ParamInfo = f4.paramss.head.head.info
+ println(f4ParamInfo.baseClasses)
+ println(f4ParamInfo.baseTypeSeq)
+ }
+}
+
diff --git a/test/files/run/t8046/t8046c.scala b/test/files/run/t8046/t8046c.scala
new file mode 100644
index 0000000000..0b484da530
--- /dev/null
+++ b/test/files/run/t8046/t8046c.scala
@@ -0,0 +1,13 @@
+import language._
+
+trait One {
+ type Op[A]
+ type Alias[A] = Op[A]
+}
+
+trait Three extends One {
+ trait Op[A] extends (A => A)
+
+ def f4[T <: Alias[Int]](f: T) = 0
+}
+
diff --git a/test/files/run/t8048a/Macros_1.scala b/test/files/run/t8048a/Macros_1.scala
index f48e84f1de..d13e851d90 100644
--- a/test/files/run/t8048a/Macros_1.scala
+++ b/test/files/run/t8048a/Macros_1.scala
@@ -1,8 +1,8 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
import scala.language.experimental.macros
object Macros {
- def impl(c: WhiteboxContext) = {
+ def impl(c: Context) = {
import c.universe._
q"if (true) Some(2) else None"
}
diff --git a/test/files/run/t8048b/Macros_1.scala b/test/files/run/t8048b/Macros_1.scala
index b113af86ea..520a6fac06 100644
--- a/test/files/run/t8048b/Macros_1.scala
+++ b/test/files/run/t8048b/Macros_1.scala
@@ -6,10 +6,10 @@
// * https://groups.google.com/forum/#!topic/scala-internals/eXQt-BPm4i8
import scala.language.experimental.macros
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
- def impl1(c: WhiteboxContext) = {
+ def impl1(c: Context) = {
import c.universe._
q"""
trait Foo { def x = 2 }
@@ -18,7 +18,7 @@ object Macros {
}
def foo1: Any = macro impl1
- def impl2(c: WhiteboxContext) = {
+ def impl2(c: Context) = {
import c.universe._
q"""
class Foo { def x = 2 }
@@ -27,7 +27,7 @@ object Macros {
}
def foo2: Any = macro impl2
- def impl3(c: WhiteboxContext) = {
+ def impl3(c: Context) = {
import c.universe._
q"""
new { def x = 2 }
diff --git a/test/files/run/t8104/Macros_1.scala b/test/files/run/t8104/Macros_1.scala
index 21d81a3687..2ad4bc5a99 100644
--- a/test/files/run/t8104/Macros_1.scala
+++ b/test/files/run/t8104/Macros_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.WhiteboxContext
+import scala.reflect.macros.whitebox.Context
object Macros {
- def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = {
+ def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = {
import c.universe._
import definitions._
val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
diff --git a/test/files/run/toolbox_current_run_compiles.scala b/test/files/run/toolbox_current_run_compiles.scala
index 31e0a45eea..6ec7074643 100644
--- a/test/files/run/toolbox_current_run_compiles.scala
+++ b/test/files/run/toolbox_current_run_compiles.scala
@@ -1,9 +1,9 @@
package pkg {
- import scala.reflect.macros.BlackboxContext
+ import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
object Macros {
- def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
+ def impl[T: c.WeakTypeTag](c: Context) = {
import c.universe._
val sym = c.weakTypeOf[T].typeSymbol
val g = c.universe.asInstanceOf[scala.tools.nsc.Global]
diff --git a/test/files/run/typed-annotated/Macros_1.scala b/test/files/run/typed-annotated/Macros_1.scala
index 42478cb988..d805d82f39 100644
--- a/test/files/run/typed-annotated/Macros_1.scala
+++ b/test/files/run/typed-annotated/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.blackbox.Context
import language.experimental.macros
class ann extends scala.annotation.StaticAnnotation
object Macros {
- def impl(c: BlackboxContext) = {
+ def impl(c: Context) = {
import c.universe._
// val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), Ident(newTypeName("Int")))
val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), TypeTree(weakTypeOf[Int]))
diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
index c5cac3ea45..fe90d7222f 100644
--- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
+++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
@@ -92,7 +92,7 @@ trait ArbitraryTreesAndNames {
yield DefDef(mods, name, tparams, vparamss, tpt, rhs)
def genExistentialTypeTree(size: Int) =
- for(tpt <- genTree(size - 1); where <- smallList(size, genTree(size - 1)))
+ for(tpt <- genTree(size - 1); where <- smallList(size, oneOf(genValDef(size - 1), genTypeDef(size - 1))))
yield ExistentialTypeTree(tpt, where)
def genFunction(size: Int) =
diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala
index 6c7c32bfdf..1eb186f303 100644
--- a/test/files/scalacheck/range.scala
+++ b/test/files/scalacheck/range.scala
@@ -127,6 +127,47 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) {
(visited == expectedSize(r)) :| str(r)
}
+ property("sum") = forAll(myGen) { r =>
+// println("----------")
+// println("sum "+str(r))
+ val rSum = r.sum
+ val expected = r.length match {
+ case 0 => 0
+ case 1 => r.head
+ case _ => ((r.head + r.last).toLong * r.length / 2).toInt
+ }
+// println("size: " + r.length)
+// println("expected: " + expected)
+// println("obtained: " + rSum)
+
+ (rSum == expected) :| str(r)
+ }
+
+/* checks that sum respects custom Numeric */
+ property("sumCustomNumeric") = forAll(myGen) { r =>
+ val mod = 65536
+ object mynum extends Numeric[Int] {
+ def plus(x: Int, y: Int): Int = (x + y) % mod
+ override def zero = 0
+
+ def fromInt(x: Int): Int = ???
+ def minus(x: Int, y: Int): Int = ???
+ def negate(x: Int): Int = ???
+ def times(x: Int, y: Int): Int = ???
+ def toDouble(x: Int): Double = ???
+ def toFloat(x: Int): Float = ???
+ def toInt(x: Int): Int = ((x % mod) + mod * 2) % mod
+ def toLong(x: Int): Long = ???
+ def compare(x: Int, y: Int): Int = ???
+ }
+
+ val rSum = r.sum(mynum)
+ val expected = mynum.toInt(r.sum)
+
+ (rSum == expected) :| str(r)
+ }
+
+
property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r =>
// println("length "+str(r))
(r.length == expectedSize(r)) :| str(r)
diff --git a/test/junit/scala/collection/PagedSeq.scala b/test/junit/scala/collection/PagedSeq.scala
new file mode 100644
index 0000000000..5f83cf6f31
--- /dev/null
+++ b/test/junit/scala/collection/PagedSeq.scala
@@ -0,0 +1,16 @@
+package scala.collection.immutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import org.junit.Assert._
+
+/* Test for SI-6615 */
+@RunWith(classOf[JUnit4])
+class PagedSeqTest {
+ @Test
+ def rovingDoesNotNPE(): Unit = {
+ // should not NPE, and should equal the given Seq
+ assertEquals(Seq('a'), PagedSeq.fromStrings(List.fill(5000)("a")).slice(4096, 4097))
+ }
+}
diff --git a/test/junit/scala/reflect/internal/PrintersTest.scala b/test/junit/scala/reflect/internal/PrintersTest.scala
new file mode 100644
index 0000000000..53ea3fd8a3
--- /dev/null
+++ b/test/junit/scala/reflect/internal/PrintersTest.scala
@@ -0,0 +1,815 @@
+package scala.reflect.internal
+
+import org.junit.Test
+import org.junit.Assert._
+import scala.tools.reflect._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror=>cm}
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class PrintersTest extends BasePrintTests
+ with ClassPrintTests
+ with TraitPrintTests
+ with ValAndDefPrintTests
+ with QuasiTreesPrintTests
+ with PackagePrintTests
+
+object PrinterHelper {
+ val toolbox = cm.mkToolBox()
+ def assertPrintedCode(code: String, tree: Tree = EmptyTree) = {
+ val toolboxTree =
+ try{
+ toolbox.parse(code)
+ } catch {
+ case e:scala.tools.reflect.ToolBoxError => throw new Exception(e.getMessage + ": " + code)
+ }
+ if (tree ne EmptyTree) assertEquals("using quasiquote or given tree"+"\n", code.trim, showCode(tree))
+ else assertEquals("using toolbox parser", code.trim, showCode(toolboxTree))
+ }
+
+ implicit class StrContextStripMarginOps(val stringContext: StringContext) extends util.StripMarginInterpolator
+}
+
+import PrinterHelper._
+
+trait BasePrintTests {
+ @Test def testIdent = assertPrintedCode("*", Ident("*"))
+
+ @Test def testConstant1 = assertPrintedCode("\"*\"", Literal(Constant("*")))
+
+ @Test def testConstant2 = assertPrintedCode("42", Literal(Constant(42)))
+
+ @Test def testConstantFloat = assertPrintedCode("42.0F", Literal(Constant(42f)))
+
+ @Test def testConstantDouble = assertPrintedCode("42.0", Literal(Constant(42d)))
+
+ @Test def testConstantLong = assertPrintedCode("42L", Literal(Constant(42l)))
+
+ @Test def testOpExpr = assertPrintedCode("(5).+(4)")
+
+ @Test def testName1 = assertPrintedCode("class test")
+
+ @Test def testName2 = assertPrintedCode("class *")
+
+ @Test def testName4 = assertPrintedCode("class `a*`")
+
+ @Test def testName5 = assertPrintedCode("val :::: = 1")
+
+ @Test def testName6 = assertPrintedCode("val `::::t` = 1")
+
+ @Test def testName7 = assertPrintedCode("""class \/""")
+
+ @Test def testName8 = assertPrintedCode("""class \\\\""")
+
+ @Test def testName9 = assertPrintedCode("""class test_\/""")
+
+ @Test def testName10 = assertPrintedCode("""class `*_*`""")
+
+ @Test def testName11 = assertPrintedCode("""class `a_*`""")
+
+ @Test def testName12 = assertPrintedCode("""class `*_a`""")
+
+ @Test def testName13 = assertPrintedCode("""class a_a""")
+
+ @Test def testName14 = assertPrintedCode("val x$11 = 5")
+
+ @Test def testName15 = assertPrintedCode("class `[]`")
+
+ @Test def testName16 = assertPrintedCode("class `()`")
+
+ @Test def testName17 = assertPrintedCode("class `{}`")
+
+ @Test def testName18 = assertPrintedCode("class <>")
+
+ @Test def testName19 = assertPrintedCode("""class `class`""")
+
+ @Test def testName20 = assertPrintedCode("""class `test name`""")
+
+ @Test def testIfExpr1 = assertPrintedCode(sm"""
+ |if (a)
+ | ((expr1): Int)
+ |else
+ | ((expr2): Int)""")
+
+ @Test def testIfExpr2 = assertPrintedCode(sm"""
+ |(if (a)
+ | {
+ | expr1;
+ | ()
+ | }
+ |else
+ | {
+ | expr2;
+ | ()
+ | }).toString""")
+
+ @Test def testIfExpr3 = assertPrintedCode(sm"""
+ |(if (a)
+ | {
+ | expr1;
+ | ()
+ | }
+ |else
+ | {
+ | expr2;
+ | ()
+ | }).method1().method2()""")
+
+ //val x = true && true && false.!
+ @Test def testBooleanExpr1 = assertPrintedCode("val x = true.&&(true).&&(false.!)")
+
+ //val x = true && !(true && false)
+ @Test def testBooleanExpr2 = assertPrintedCode("val x = true.&&(true.&&(false).`unary_!`)")
+
+ @Test def testNewExpr1 = assertPrintedCode("new foo()")
+
+ //new foo { test }
+ @Test def testNewExpr2 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon extends foo {
+ | test
+ | };
+ | new $$anon()
+ |}""")
+
+ @Test def testNewExpr3 = assertPrintedCode("new foo[t]()")
+
+ @Test def testNewExpr4 = assertPrintedCode("new foo(x)")
+
+ @Test def testNewExpr5 = assertPrintedCode("new foo[t](x)")
+
+ //new foo[t](x) { () }
+ @Test def testNewExpr6 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon extends foo[t](x) {
+ | ()
+ | };
+ | new $$anon()
+ |}""")
+
+ //new foo with bar
+ @Test def testNewExpr7 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon extends foo with bar;
+ | new $$anon()
+ |}""")
+
+ //new { anonymous }
+ @Test def testNewExpr8 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon {
+ | anonymous
+ | };
+ | new $$anon()
+ |}""")
+
+ //new { val early = 1 } with Parent[Int] { body }
+ @Test def testNewExpr9 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon extends {
+ | val early = 1
+ | } with Parent[Int] {
+ | body
+ | };
+ | new $$anon()
+ |}""")
+
+ //new Foo { self => }
+ @Test def testNewExpr10 = assertPrintedCode(sm"""
+ |{
+ | final class $$anon extends Foo { self =>
+ |
+ | };
+ | new $$anon()
+ |}""")
+
+ @Test def testReturn = assertPrintedCode("def test: Int = return 42")
+
+ @Test def testFunc1 = assertPrintedCode("List(1, 2, 3).map(((i: Int) => i.-(1)))")
+
+ //val sum: Seq[Int] => Int = _ reduceLeft (_+_)
+ @Test def testFunc2 = assertPrintedCode("val sum: _root_.scala.Function1[Seq[Int], Int] = ((x$1) => x$1.reduceLeft(((x$2, x$3) => x$2.+(x$3))))")
+
+ //List(1, 2, 3) map (_ - 1)
+ @Test def testFunc3 = assertPrintedCode("List(1, 2, 3).map(((x$1) => x$1.-(1)))")
+
+ @Test def testImport1 = assertPrintedCode("import scala.collection.mutable")
+
+ @Test def testImport2 = assertPrintedCode("import java.lang.{String=>Str}")
+
+ @Test def testImport3 = assertPrintedCode("import java.lang.{String=>Str, Object=>_, _}")
+
+ @Test def testImport4 = assertPrintedCode("import scala.collection._")
+}
+
+trait ClassPrintTests {
+ @Test def testClass = assertPrintedCode("class *")
+
+ @Test def testClassWithBody = assertPrintedCode(sm"""
+ |class X {
+ | def y = "test"
+ |}""")
+
+ @Test def testClassWithPublicParams = assertPrintedCode("class X(val x: Int, val s: String)")
+
+ @Test def testClassWithParams1 = assertPrintedCode("class X(x: Int, s: String)")
+
+ @Test def testClassWithParams2 = assertPrintedCode("class X(@test x: Int, s: String)")
+
+ @Test def testClassWithParams3 = assertPrintedCode("class X(implicit x: Int, s: String)")
+
+ @Test def testClassWithParams4 = assertPrintedCode("class X(implicit @test x: Int, s: String)")
+
+ @Test def testClassWithParams5 = assertPrintedCode("class X(override private[this] val x: Int, s: String) extends Y")
+
+ @Test def testClassWithParams6 = assertPrintedCode("class X(@test1 override private[this] val x: Int, @test2(param1 = 7) s: String) extends Y")
+
+ @Test def testClassWithParams7 = assertPrintedCode("class X protected (val x: Int, val s: String)")
+
+ @Test def testClassWithParams8 = assertPrintedCode("class X(var x: Int)")
+
+ @Test def testClassWithParams9 = assertPrintedCode("class X(var x: Int*)")
+
+ @Test def testClassWithByNameParam = assertPrintedCode("class X(x: => Int)")
+
+ @Test def testClassWithDefault = assertPrintedCode("class X(var x: Int = 5)")
+
+ @Test def testClassWithParams10 = assertPrintedCode("class X(protected[zzz] var x: Int)")
+
+ @Test def testClassWithParams11 = assertPrintedCode("class X(override var x: Int) extends F(x) with E(x)")
+
+ @Test def testClassWithParams12 = assertPrintedCode("class X(val y: Int)()(var z: Double)")
+
+ @Test def testClassWithImplicitParams = assertPrintedCode("class X(var i: Int)(implicit val d: Double, var f: Float)")
+
+ @Test def testClassWithEarly = assertPrintedCode(sm"""
+ |class X(var i: Int) extends {
+ | val a: String = i;
+ | type B
+ |} with Y""")
+
+ @Test def testClassWithThrow1 = assertPrintedCode(sm"""
+ |class Throw1 {
+ | throw new Exception("exception!")
+ |}""")
+
+ @Test def testClassWithThrow2 = assertPrintedCode(sm"""
+ |class Throw2 {
+ | var msg = " ";
+ | val e = new Exception(msg);
+ | throw e
+ |}""")
+
+ /*
+ class Test {
+ val (a, b) = (1, 2)
+ }
+ */
+ @Test def testClassWithAssignmentWithTuple1 = assertPrintedCode(sm"""
+ |class Test {
+ | private[this] val x$$1 = (scala.Tuple2(1, 2): @scala.unchecked) match {
+ | case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b)
+ | };
+ | val a = x$$1._1;
+ | val b = x$$1._2
+ |}""")
+
+ /*
+ class Test {
+ val (a, b) = (1).->(2)
+ }
+ */
+ @Test def testClassWithAssignmentWithTuple2 = assertPrintedCode(sm"""
+ |class Test {
+ | private[this] val x$$1 = ((1).->(2): @scala.unchecked) match {
+ | case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b)
+ | };
+ | val a = x$$1._1;
+ | val b = x$$1._2
+ |}""")
+
+ /*
+ class Test {
+ val List(one, three, five) = List(1,3,5)
+ }
+ */
+ @Test def testClassWithPatternMatchInAssignment = assertPrintedCode(sm"""
+ |class Test {
+ | private[this] val x$$1 = (List(1, 3, 5): @scala.unchecked) match {
+ | case List((one @ _), (three @ _), (five @ _)) => scala.Tuple3(one, three, five)
+ | };
+ | val one = x$$1._1;
+ | val three = x$$1._2;
+ | val five = x$$1._3
+ |}""")
+
+ //class A(l: List[_])
+ @Test def testClassWithExistentialParameter1 = assertPrintedCode(sm"""
+ |class Test(l: (List[_$$1] forSome {
+ | type _$$1
+ |}))""")
+
+ @Test def testClassWithExistentialParameter2 = assertPrintedCode(sm"""
+ |class B(l: (List[T] forSome {
+ | type T
+ |}))""")
+
+ @Test def testClassWithCompoundTypeTree = assertPrintedCode(sm"""
+ |{
+ | trait A;
+ | trait B;
+ | abstract class C(val a: A with B) {
+ | def method(x: A with B with C {
+ | val x: Float
+ | }): A with B
+ | };
+ | ()
+ |}""")
+
+ @Test def testClassWithSelectFromTypeTree = assertPrintedCode(sm"""
+ |{
+ | trait A {
+ | type T
+ | };
+ | class B(t: (A)#T);
+ | ()
+ |}""")
+
+ @Test def testImplicitClass = assertPrintedCode("implicit class X(protected[zzz] var x: Int)")
+
+ @Test def testAbstractClass = assertPrintedCode("abstract class X(protected[zzz] var x: Int)")
+
+ @Test def testCaseClassWithParams1 = assertPrintedCode("case class X(x: Int, s: String)")
+
+ @Test def testCaseClassWithParams2 = assertPrintedCode("case class X(protected val x: Int, s: String)")
+
+ @Test def testCaseClassWithParams3 = assertPrintedCode("case class X(implicit x: Int, s: String)")
+
+ @Test def testCaseClassWithParams4 = assertPrintedCode("case class X(override val x: Int, s: String) extends Y")
+
+ @Test def testCaseClassWithBody = assertPrintedCode(sm"""
+ |case class X() {
+ | def y = "test"
+ |}""")
+
+ @Test def testLocalClass = assertPrintedCode(sm"""
+ |def test = {
+ | class X(var a: Int) {
+ | def y = "test"
+ | };
+ | new X(5)
+ |}""")
+
+ @Test def testLocalCaseClass = assertPrintedCode(sm"""
+ |def test = {
+ | case class X(var a: Int) {
+ | def y = "test"
+ | };
+ | new X(5)
+ |}""")
+
+ @Test def testSuperInClass = assertPrintedCode(sm"""
+ |{
+ | trait Root {
+ | def r = "Root"
+ | };
+ | class X extends Root {
+ | def superX = super.r
+ | };
+ | class Y extends X with Root {
+ | class Inner {
+ | val myY = Y.super.r
+ | };
+ | def fromX = super[X].r;
+ | def fromRoot = super[Root].r
+ | };
+ | ()
+ |}""")
+
+ @Test def testThisInClass = assertPrintedCode(sm"""
+ |class Outer {
+ | class Inner {
+ | val outer = Root.this
+ | };
+ | val self = this
+ |}""")
+
+ @Test def testCaseClassWithParamsAndBody = assertPrintedCode(sm"""
+ |case class X(x: Int, s: String) {
+ | def y = "test"
+ |}""")
+
+ @Test def testObject = assertPrintedCode("object *")
+
+ @Test def testObjectWithBody = assertPrintedCode(sm"""
+ |object X {
+ | def y = "test"
+ |}""")
+
+ @Test def testObjectWithEarly1 = assertPrintedCode(sm"""
+ |object X extends {
+ | val early: T = v
+ |} with Bar""")
+
+ @Test def testObjectWithEarly2 = assertPrintedCode(sm"""
+ |object X extends {
+ | val early: T = v;
+ | type EarlyT = String
+ |} with Bar""")
+
+ @Test def testObjectWithSelf = assertPrintedCode(sm"""
+ |object Foo extends Foo { self =>
+ | body
+ |}""")
+
+ @Test def testObjectInh = assertPrintedCode("private[Y] object X extends Bar with Baz")
+
+ @Test def testObjectWithPatternMatch1 = assertPrintedCode(sm"""
+ |object PM1 {
+ | List(1, 2) match {
+ | case (i @ _) => i
+ | }
+ |}""")
+
+ @Test def testObjectWithPatternMatch2 = assertPrintedCode(sm"""
+ |object PM2 {
+ | List(1, 2).map({
+ | case (i @ _) if i.>(5) => i
+ | })
+ |}""")
+
+ //case i: Int => i
+ @Test def testObjectWithPatternMatch3 = assertPrintedCode(sm"""
+ |object PM3 {
+ | List(1, 2).map({
+ | case (i @ ((_): Int)) => i
+ | })
+ |}""")
+
+ //case a @ (i: Int) => i
+ @Test def testObjectWithPatternMatch4 = assertPrintedCode(sm"""
+ |object PM4 {
+ | List(1, 2).map({
+ | case (a @ (i @ ((_): Int))) => i
+ | })
+ |}""")
+
+ @Test def testObjectWithPatternMatch5 = assertPrintedCode(sm"""
+ |object PM5 {
+ | List(1, 2).map({
+ | case _ => 42
+ | })
+ |}""")
+
+ @Test def testObjectWithPatternMatch6 = assertPrintedCode(sm"""
+ |object PM6 {
+ | List(1, 2) match {
+ | case ::((x @ _), (xs @ _)) => x
+ | }
+ |}""")
+
+ @Test def testObjectWithPatternMatch7 = assertPrintedCode(sm"""
+ |object PM7 {
+ | List(1, 2).map({
+ | case (0| 1) => true
+ | case _ => false
+ | })
+ |}""")
+
+ @Test def testObjectWithPatternMatch8 = assertPrintedCode(sm"""
+ |object PM8 {
+ | "abcde".toList match {
+ | case Seq((car @ _), _*) => car
+ | }
+ |}""")
+
+ @Test def testObjectWithPatternMatch9 = assertPrintedCode(sm"""
+ |{
+ | object Extractor {
+ | def unapply(i: Int) = Some(i)
+ | };
+ | object PM9 {
+ | 42 match {
+ | case (a @ Extractor((i @ _))) => i
+ | }
+ | };
+ | ()
+ |}""")
+
+ @Test def testObjectWithPartialFunc = assertPrintedCode(sm"""
+ |object Test {
+ | def partFuncTest[A, B](e: Either[A, B]): scala.Unit = e match {
+ | case Right(_) => ()
+ | }
+ |}""")
+
+ @Test def testObjectWithTry = assertPrintedCode(sm"""
+ |object Test {
+ | import java.io;
+ | var file: PrintStream = null;
+ | try {
+ | val out = new FileOutputStream("myfile.txt");
+ | file = new PrintStream(out)
+ | } catch {
+ | case (ioe @ ((_): IOException)) => println("ioe")
+ | case (e @ ((_): Exception)) => println("e")
+ | } finally println("finally")
+ |}""")
+}
+
+trait TraitPrintTests {
+ @Test def testTrait = assertPrintedCode("trait *")
+
+ @Test def testTraitWithBody = assertPrintedCode(sm"""
+ |trait X {
+ | def y = "test"
+ |}""")
+
+ @Test def testTraitWithSelfTypeAndBody = assertPrintedCode(sm"""
+ |trait X { self: Order =>
+ | def y = "test"
+ |}""")
+
+ @Test def testTraitWithSelf1 = assertPrintedCode(sm"""
+ |trait X { self =>
+ | def y = "test"
+ |}""")
+
+ @Test def testTraitWithSelf2 = assertPrintedCode(sm"""
+ |trait X { self: Foo with Bar =>
+ | val x: Int = 1
+ |}""")
+
+ @Test def testTraitTypeParams = assertPrintedCode("trait X[A, B]")
+
+ @Test def testTraitWithBody2 = assertPrintedCode(sm"""
+ |trait X {
+ | def foo: scala.Unit;
+ | val bar: Baz
+ |}""")
+
+ @Test def testTraitWithInh = assertPrintedCode("trait X extends A with B")
+
+ @Test def testTraitWithEarly1 = assertPrintedCode(sm"""
+ |trait X extends {
+ | val x: Int = 1
+ |} with Any""")
+
+ @Test def testTraitWithEarly2 = assertPrintedCode(sm"""
+ |trait X extends {
+ | val x: Int = 0;
+ | type Foo = Bar
+ |} with Y""")
+
+ @Test def testTraitWithEarly3 = assertPrintedCode(sm"""
+ |trait X extends {
+ | val x: Int = 5;
+ | val y: Double = 4.0;
+ | type Foo;
+ | type XString = String
+ |} with Y""")
+
+ @Test def testTraitWithEarly4 = assertPrintedCode(sm"""
+ |trait X extends {
+ | val x: Int = 5;
+ | val y: Double = 4.0;
+ | type Foo;
+ | type XString = String
+ |} with Y {
+ | val z = 7
+ |}""")
+
+ @Test def testTraitWithEarly5 = assertPrintedCode(sm"""
+ |trait X extends {
+ | override protected[this] val x: Int = 5;
+ | val y: Double = 4.0;
+ | private type Foo;
+ | private[ee] type XString = String
+ |} with Y {
+ | val z = 7
+ |}""")
+
+ @Test def testTraitWithSingletonTypeTree = assertPrintedCode(sm"""
+ |trait Test {
+ | def testReturnSingleton(): this.type
+ |}""")
+
+ @Test def testTraitWithThis = assertPrintedCode(sm"""
+ |trait Test { _ : X with Y =>
+ |
+ |}""", q"trait Test { this: X with Y => }")
+
+ @Test def testTraitWithWhile1 = assertPrintedCode(sm"""
+ |trait Test {
+ | while (true.!=(false))
+ | println("testing...")
+ |
+ |}""")
+
+ @Test def testTraitWithWhile2 = assertPrintedCode(sm"""
+ |trait Test {
+ | while (true)
+ | {
+ | println("testing...");
+ | println("testing...")
+ | }
+ |
+ |}""")
+
+ @Test def testTraitWithDoWhile1 = assertPrintedCode(sm"""
+ |trait Test {
+ | do
+ | println("testing...")
+ | while (true)
+ |}""")
+
+ @Test def testTraitWithTypes = assertPrintedCode(sm"""
+ |trait Test {
+ | type A = Int;
+ | type B >: Nothing <: AnyRef;
+ | protected type C >: Nothing;
+ | type D <: AnyRef
+ |}""")
+}
+
+trait ValAndDefPrintTests {
+ @Test def testVal1 = assertPrintedCode("val a: Unit = null")
+
+ @Test def testVal2 = assertPrintedCode("val * : Unit = null")
+
+ @Test def testVal3 = assertPrintedCode("val a_ : Unit = null")
+
+ @Test def testDef1 = assertPrintedCode("def a: Unit = null")
+
+ @Test def testDef2 = assertPrintedCode("def * : Unit = null")
+
+ @Test def testDef3 = assertPrintedCode("def a_(x: Int): Unit = null")
+
+ @Test def testDef4 = assertPrintedCode("def a_ : Unit = null")
+
+ @Test def testDef5 = assertPrintedCode("def a_(* : Int): Unit = null")
+
+ @Test def testDef6 = assertPrintedCode("def a_(b_ : Int): Unit = null")
+
+ @Test def testDef7 = assertPrintedCode(sm"""
+ |{
+ | def test1 = ();
+ | def test2() = ()
+ |}""",
+ Block(
+ DefDef(NoMods, newTermName("test1"), Nil, Nil, EmptyTree, Literal(Constant(()))),
+ DefDef(NoMods, newTermName("test2"), Nil, Nil :: Nil, EmptyTree, Literal(Constant(())))
+ )
+ )
+
+ @Test def testDef8 = {
+ val arg = ValDef(Modifiers(Flag.IMPLICIT) , newTermName("a"),
+ AppliedTypeTree(Ident(newTypeName("R")), List(Ident(newTypeName("X")))), EmptyTree)
+
+ //def m[X](implicit a: R[X]) = ()
+ val tree = DefDef(NoMods, newTermName("test"), TypeDef(NoMods, newTypeName("X"), Nil, EmptyTree) :: Nil,
+ List(List(arg)), EmptyTree, Literal(Constant(())))
+
+ assertPrintedCode("def test[X](implicit a: R[X]) = ()", tree)
+ }
+
+ @Test def testDefWithParams1 = assertPrintedCode("def foo(x: Int*) = null")
+
+ @Test def testDefWithParams2 = assertPrintedCode("def foo(x: Int)(y: Int = 1) = null")
+
+ @Test def testDefWithTypeParams1 = assertPrintedCode("def foo[A, B, C](x: A)(y: Int = 1): C = null")
+
+ @Test def testDefWithTypeParams2 = assertPrintedCode("def foo[A, B <: Bar] = null")
+
+ @Test def testDefWithAnn1 = assertPrintedCode("@annot def foo = null")
+
+ @Test def testDefWithAnn2 = assertPrintedCode("@a(x) def foo = null")
+
+ @Test def testDefWithAnn3 = assertPrintedCode("@Foo[A, B] def foo = null")
+
+ @Test def testDefWithAnn4 = assertPrintedCode("@Foo(a)(b)(x, y) def foo = null")
+
+ @Test def testDefWithAnn5 = assertPrintedCode("@Foo[A, B](a)(b) @Bar def foo(x: Int) = null")
+
+ @Test def testDefWithAnn6 = assertPrintedCode("@test1(new test2()) def foo = 42")
+
+ @Test def testDefWithAnn7 = assertPrintedCode("@`t*` def foo = 42")
+
+ @Test def testDefWithAnn8 = assertPrintedCode("@throws(classOf[Exception]) def foo = throw new Exception()")
+
+ @Test def testAnnotated1 = assertPrintedCode("def foo = 42: @test1")
+
+ @Test def testAnnotated2 = assertPrintedCode("""def foo = 42: @test1(42, z = "5")""")
+
+ @Test def testAnnotated3 = assertPrintedCode("def foo = (42: @test1): @test2(new test1())")
+
+ @Test def testAnnotated4 = assertPrintedCode("""def foo = 42: @test1(4, "testing")(4.2)""")
+
+ @Test def testAnnotated5 = assertPrintedCode("""def foo = (42: @test1(4, "testing")(4.2)): @test2(1, "bar")(3.14)""")
+
+ @Test def testAnnotated6 = assertPrintedCode("def foo = ((42: @test1): @test2(new test1())): @test3(1)(2, 3)(4)")
+
+ @Test def testAnnotated7 = assertPrintedCode(sm"""
+ |(x: @unchecked) match {
+ | case ((_): Int) => true
+ | case _ => false
+ |}""")
+
+ @Test def testAnnotated8 = assertPrintedCode(sm"""
+ |((x: @unchecked): @test1(1, "testing")(3.14)) match {
+ | case _ => true
+ |}""")
+}
+
+trait PackagePrintTests {
+ @Test def testPackage1 = assertPrintedCode(sm"""
+ |package foo.bar {
+ |
+ |}""")
+
+ @Test def testPackage2 = assertPrintedCode(sm"""
+ |package foo {
+ | class C
+ |
+ | object D
+ |}""")
+
+ //package object foo extends a with b
+ @Test def testPackage3 = assertPrintedCode(sm"""
+ |package foo {
+ | object `package` extends a with b
+ |}""")
+
+ //package object foo { def foo; val x = 1 }
+ @Test def testPackage4 = assertPrintedCode(sm"""
+ |package foo {
+ | object `package` {
+ | def foo: scala.Unit;
+ | val x = 1
+ | }
+ |}""")
+
+ //package object foo extends { val x = 1; type I = Int } with Any
+ @Test def testPackage5 = assertPrintedCode(sm"""
+ |package foo {
+ | object `package` extends {
+ | val x = 1;
+ | type I = Int
+ | } with Any
+ |}""")
+}
+
+trait QuasiTreesPrintTests {
+ @Test def testQuasiIdent = assertPrintedCode("*", q"*")
+
+ @Test def testQuasiVal = assertPrintedCode("val * : Unit = null", q"val * : Unit = null")
+
+ @Test def testQuasiDef = assertPrintedCode("def * : Unit = null", q"def * : Unit = null")
+
+ @Test def testQuasiTrait = assertPrintedCode("trait *", q"trait *")
+
+ @Test def testQuasiClass = assertPrintedCode("class *", q"class *")
+
+ @Test def testQuasiClassWithPublicParams = assertPrintedCode( "class X(val x: Int, val s: String)", q"class X(val x: Int, val s:String)" )
+
+ @Test def testQuasiClassWithParams = assertPrintedCode("class X(x: Int, s: String)", q"class X(x: Int, s:String)")
+
+ @Test def testQuasiObject = assertPrintedCode("object *", q"object *")
+
+ @Test def testQuasiObjectWithBody = assertPrintedCode(sm"""
+ |object X {
+ | def y = "test"
+ |}""", q"""object X{ def y = "test" }""")
+
+ @Test def testQuasiClassWithBody = assertPrintedCode(sm"""
+ |class X {
+ | def y = "test"
+ |}""", q"""class X{ def y = "test" }""")
+
+ @Test def testQuasiTraitWithBody = assertPrintedCode(sm"""
+ |trait X {
+ | def y = "test"
+ |}""", q"""trait X{ def y = "test" }""")
+
+ @Test def testQuasiTraitWithSelfTypeAndBody = assertPrintedCode(sm"""
+ |trait X { self: Order =>
+ | def y = "test"
+ |}""", q"""trait X{ self: Order => def y = "test" }""")
+
+ @Test def testQuasiTraitWithSelf = assertPrintedCode(sm"""
+ |trait X { self =>
+ | def y = "test"
+ |}""", q"""trait X{ self => def y = "test" }""")
+
+ @Test def testQuasiCaseClassWithBody = assertPrintedCode(sm"""
+ |case class X() {
+ | def y = "test"
+ |}""", q"""case class X() { def y = "test" }""")
+
+ @Test def testQuasiCaseClassWithParamsAndBody = assertPrintedCode(sm"""
+ |case class X(x: Int, s: String) {
+ | def y = "test"
+ |}""", q"""case class X(x: Int, s: String){ def y = "test" }""")
+}
diff --git a/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala b/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala
index 89020de7dd..be47d5cec4 100644
--- a/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala
+++ b/test/pending/neg/macro-invalidusage-badbounds-b/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U <: String](c: Ctx) = ???
+ def foo[U <: String](c: Context) = ???
}
diff --git a/test/pending/pos/t6161.scala b/test/pending/pos/t6161.scala
new file mode 100644
index 0000000000..5783cc85f2
--- /dev/null
+++ b/test/pending/pos/t6161.scala
@@ -0,0 +1,22 @@
+object t6161 {
+ trait N {
+ type Name
+ }
+
+ trait N1 extends N {
+ class Name {
+ type ThisNameType <: Name
+ def encode: ThisNameType = ???
+ }
+ }
+
+ trait S {
+ self: N => // change to N1 and it compiles
+ type NameType <: Name
+ }
+
+ object g extends S with N1
+
+ val n1: g.NameType = ???
+ val n2: g.Name = n1.encode
+}
diff --git a/test/pending/pos/t8128b.scala b/test/pending/pos/t8128b.scala
new file mode 100644
index 0000000000..dd44a25a90
--- /dev/null
+++ b/test/pending/pos/t8128b.scala
@@ -0,0 +1,18 @@
+class Optiony[X] { def isEmpty = true; def get: X = ??? }
+class Seqy[X] { def head: X = ???; def length = 0; def apply(i: Int): X = ??? }
+
+object G {
+ def unapply(m: Any): Optiony[_] = ???
+}
+
+object H {
+ def unapplySeq(m: Any): Optiony[Seqy[_]] = ???
+}
+
+object Test {
+ (0: Any) match {
+ case G(v) => v
+ case H(v) => v
+ case _ =>
+ }
+}
diff --git a/test/pending/presentation/context-bounds1.check b/test/pending/presentation/context-bounds1.check
new file mode 100644
index 0000000000..b444de59a4
--- /dev/null
+++ b/test/pending/presentation/context-bounds1.check
@@ -0,0 +1,51 @@
+reload: ContextBounds.scala
+
+askHyperlinkPos for `Blubb` at (2,23) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Blubb` at (13,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Foo` at (4,17) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Foo` at (9,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Blubb` at (4,32) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Blubb` at (13,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (4,42) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (4,51) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `blubb` at (4,66) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `blubb` at (2,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `Foo` at (5,18) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `Foo` at (9,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (5,25) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (4,12) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `foo` at (5,36) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `foo` at (10,7) ContextBounds.scala
+================================================================================
+
+askHyperlinkPos for `A` at (10,14) ContextBounds.scala
+================================================================================
+[response] found askHyperlinkPos for `A` at (9,11) ContextBounds.scala
+================================================================================
diff --git a/test/pending/presentation/context-bounds1/Test.scala b/test/pending/presentation/context-bounds1/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/pending/presentation/context-bounds1/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/pending/presentation/context-bounds1/src/ContextBounds.scala b/test/pending/presentation/context-bounds1/src/ContextBounds.scala
new file mode 100644
index 0000000000..72a8f694a3
--- /dev/null
+++ b/test/pending/presentation/context-bounds1/src/ContextBounds.scala
@@ -0,0 +1,13 @@
+object ContextBound {
+ val blubb = new Blubb/*#*/
+
+ def work[A: Foo/*#*/](f: Blubb/*#*/ => A/*#*/): A/*#*/ = f(blubb/*#*/) ensuring {
+ implicitly[Foo/*#*/[A/*#*/]].foo/*#*/(_) >= 42
+ }
+}
+
+trait Foo[A] {
+ def foo(a: A/*#*/): Int
+}
+
+class Blubb \ No newline at end of file
diff --git a/test/pending/run/macro-expand-default/Impls_1.scala b/test/pending/run/macro-expand-default/Impls_1.scala
index bb55f02ab2..fd5d8d7f18 100644
--- a/test/pending/run/macro-expand-default/Impls_1.scala
+++ b/test/pending/run/macro-expand-default/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = {
import c.universe._
val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum))
diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
index 15bcb581c8..e8170fda07 100644
--- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
+++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.whitebox.Context
object Impls {
def foo[T: c.WeakTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify {
diff --git a/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala
index eed68280cd..34182b7968 100644
--- a/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala
+++ b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[U](c: Ctx)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = {
+ def foo[U](c: Context)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = {
import c.universe._
val plusOne = Apply(Select(evidence.tree, TermName("plus")), List(x.tree, Literal(Constant(1))))
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(plusOne))
diff --git a/test/pending/run/macro-expand-named/Impls_1.scala b/test/pending/run/macro-expand-named/Impls_1.scala
index bb55f02ab2..fd5d8d7f18 100644
--- a/test/pending/run/macro-expand-named/Impls_1.scala
+++ b/test/pending/run/macro-expand-named/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = {
+ def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = {
import c.universe._
val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum))
diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
index 487ac79673..683622b29d 100644
--- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
Block(List(
Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))),
diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
index 487ac79673..683622b29d 100644
--- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
Block(List(
Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))),
diff --git a/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala b/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala
index daedde4021..741a921b72 100644
--- a/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala
+++ b/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala
@@ -1,5 +1,5 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
trait Impls {
- def impl(c: Ctx)(x: c.Expr[Any]) = x
+ def impl(c: Context)(x: c.Expr[Any]) = x
} \ No newline at end of file
diff --git a/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala b/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala
index 27140a77ad..2735321eae 100644
--- a/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala
+++ b/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros extends Impls {
def foo(x: Any) = macro impl
diff --git a/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala b/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala
index 246fc9f904..b023d31f05 100644
--- a/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala
+++ b/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
trait ImplContainer {
object Impls {
- def foo(c: Ctx)(x: c.Expr[Any]) = x
+ def foo(c: Context)(x: c.Expr[Any]) = x
}
} \ No newline at end of file
diff --git a/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala b/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala
index da9445ac52..639d93fb5f 100644
--- a/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala
+++ b/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros extends ImplContainer {
def foo(x: Any) = macro Impls.foo
diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala
index f970be5caa..eea0133feb 100644
--- a/test/pending/run/macro-reify-array/Macros_1.scala
+++ b/test/pending/run/macro-reify-array/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[T](s: String) = macro Impls.foo[T]
object Impls {
- def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify {
+ def foo[T: c.WeakTypeTag](c: Context)(s: c.Expr[T]) = c.universe.reify {
Array(s.splice)
}
}
diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala
index 59dbe7157b..f4d8062a14 100644
--- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala
+++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[T](s: T) = macro Impls.foo[List[T]]
object Impls {
- def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify {
+ def foo[T: c.WeakTypeTag](c: Context)(s: c.Expr[T]) = c.universe.reify {
List(s.splice)
}
}
diff --git a/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
index a581c47026..1307052394 100644
--- a/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
+++ b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Macros {
def foo[T](s: T) = macro Impls.foo[List[T]]
object Impls {
- def foo[T](c: Ctx)(s: c.Expr[T]) = c.universe.reify {
+ def foo[T](c: Context)(s: c.Expr[T]) = c.universe.reify {
List(s.splice)
}
}
diff --git a/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala
index 348f3420f2..c43f5f3f53 100644
--- a/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala
+++ b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.blackbox.Context
object Impls {
- def foo(c: Ctx) = {
+ def foo(c: Context) = {
import c.{prefix => prefix}
import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix))))
diff --git a/test/files/run/reflection-sync-potpourri.scala b/test/pending/run/reflection-sync-potpourri.scala
index 0ad5f2ab66..0ad5f2ab66 100644
--- a/test/files/run/reflection-sync-potpourri.scala
+++ b/test/pending/run/reflection-sync-potpourri.scala
diff --git a/test/scaladoc/run/SI-6812.check b/test/scaladoc/run/SI-6812.check
index 619c56180b..3be8a300e7 100644
--- a/test/scaladoc/run/SI-6812.check
+++ b/test/scaladoc/run/SI-6812.check
@@ -1 +1,2 @@
+warning: -Ymacro-no-expand is deprecated: Use -Ymacro-expand:none
Done.
diff --git a/test/scaladoc/run/SI-6812.scala b/test/scaladoc/run/SI-6812.scala
index 059c327e7e..90005b8db4 100644
--- a/test/scaladoc/run/SI-6812.scala
+++ b/test/scaladoc/run/SI-6812.scala
@@ -5,11 +5,11 @@ import language._
object Test extends ScaladocModelTest {
override def code = """
- import scala.reflect.macros.BlackboxContext
+ import scala.reflect.macros.blackbox.Context
import language.experimental.macros
object Macros {
- def impl(c: BlackboxContext) = c.literalUnit
+ def impl(c: Context) = c.literalUnit
def foo: Unit = macro impl
}
@@ -19,6 +19,6 @@ object Test extends ScaladocModelTest {
"""
def scaladocSettings = ""
- override def extraSettings = super.extraSettings + " -Ymacro-no-expand"
+ override def extraSettings = super.extraSettings + " -Ymacro-no-expand -deprecation"
def testModel(root: Package) = ()
}
diff --git a/test/scaladoc/run/SI-6812b.check b/test/scaladoc/run/SI-6812b.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/SI-6812b.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/SI-6812b.scala b/test/scaladoc/run/SI-6812b.scala
new file mode 100644
index 0000000000..74dbd130a3
--- /dev/null
+++ b/test/scaladoc/run/SI-6812b.scala
@@ -0,0 +1,24 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+import language._
+
+object Test extends ScaladocModelTest {
+
+ override def code = """
+ import scala.reflect.macros.blackbox.Context
+ import language.experimental.macros
+
+ object Macros {
+ def impl(c: Context) = c.literalUnit
+ def foo: Unit = macro impl
+ }
+
+ class C {
+ def bar = Macros.foo
+ }
+ """
+
+ def scaladocSettings = ""
+ override def extraSettings = super.extraSettings + " -Ymacro-expand:none"
+ def testModel(root: Package) = ()
+}
diff --git a/versions.properties b/versions.properties
index 90448dc49a..62ba7ac379 100644
--- a/versions.properties
+++ b/versions.properties
@@ -12,6 +12,10 @@ scala-continuations-plugin.version.number=1.0.0-RC2
scala-continuations-library.version.number=1.0.0-RC2
scala-swing.version.number=1.0.0-RC2
+# these ship with distribution (and scala-library-all depends on them)
+akka-actor.version.number=2.2.3
+actors-migration.version.number=1.0.0
+
# external modules, used internally (not shipped)
partest.version.number=1.0.0-RC8
scalacheck.version.number=1.11.1