summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md2
-rwxr-xr-xbuild.xml165
-rw-r--r--docs/examples/fors.scala2
-rw-r--r--docs/examples/iterators.scala4
-rw-r--r--docs/examples/jolib/Ref.scala8
-rw-r--r--docs/examples/jolib/parallelOr.scala22
-rw-r--r--docs/examples/monads/callccInterpreter.scala18
-rw-r--r--docs/examples/monads/directInterpreter.scala14
-rw-r--r--docs/examples/monads/errorInterpreter.scala10
-rw-r--r--docs/examples/monads/simpleInterpreter.scala14
-rw-r--r--docs/examples/monads/stateInterpreter.scala24
-rw-r--r--docs/examples/patterns.scala8
-rw-r--r--docs/examples/pilib/elasticBuffer.scala8
-rw-r--r--docs/examples/pilib/handover.scala38
-rw-r--r--docs/examples/pilib/piNat.scala16
-rw-r--r--docs/examples/typeinf.scala50
-rw-r--r--src/actors/scala/actors/Future.scala14
-rw-r--r--src/actors/scala/actors/remote/NetKernel.scala8
-rw-r--r--src/actors/scala/actors/remote/Proxy.scala4
-rw-r--r--src/actors/scala/actors/remote/RemoteActor.scala4
-rw-r--r--src/actors/scala/actors/remote/TcpService.scala8
-rw-r--r--src/build/bnd/scala-compiler-doc.bnd6
-rw-r--r--src/build/bnd/scala-compiler-interactive.bnd6
-rw-r--r--src/build/maven/maven-deploy.xml23
-rw-r--r--src/build/maven/scala-compiler-doc-pom.xml69
-rw-r--r--src/build/maven/scala-compiler-interactive-pom.xml59
-rw-r--r--src/build/maven/scala-compiler-pom.xml17
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Errors.scala2
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Resolvers.scala22
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Validators.scala16
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Context.scala3
-rw-r--r--src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala2
-rw-r--r--src/compiler/scala/reflect/macros/util/Helpers.scala10
-rw-r--r--src/compiler/scala/tools/ant/ScalaTool.scala4
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Compilers.scala2
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-windows.tmpl17
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeDSL.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala48
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala73
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala362
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala26
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala14
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala2
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala6
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/Mixer.scala99
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala21
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala111
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala74
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala115
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/util/package.scala35
-rw-r--r--src/compiler/scala/tools/reflect/StdTags.scala2
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala33
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala8
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala1
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala13
-rw-r--r--src/eclipse/README.md7
-rw-r--r--src/eclipse/partest/.classpath2
-rw-r--r--src/eclipse/scaladoc/.classpath6
-rw-r--r--src/interactive/scala/tools/nsc/interactive/CompilerControl.scala37
-rw-r--r--src/interactive/scala/tools/nsc/interactive/ContextTrees.scala64
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala182
-rw-r--r--src/interactive/scala/tools/nsc/interactive/REPL.scala55
-rw-r--r--src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala201
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala2
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala19
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala43
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala10
-rw-r--r--src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala4
-rw-r--r--src/library/scala/Predef.scala6
-rw-r--r--src/library/scala/Responder.scala2
-rw-r--r--src/library/scala/annotation/migration.scala5
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala2
-rw-r--r--src/library/scala/collection/immutable/LongMap.scala2
-rw-r--r--src/library/scala/collection/immutable/Range.scala16
-rw-r--r--src/library/scala/collection/mutable/AnyRefMap.scala451
-rw-r--r--src/library/scala/collection/mutable/LongMap.scala558
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala5
-rw-r--r--src/library/scala/concurrent/Future.scala2
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala6
-rw-r--r--src/library/scala/math/BigDecimal.scala3
-rw-r--r--src/library/scala/math/BigInt.scala3
-rw-r--r--src/library/scala/reflect/ClassManifestDeprecatedApis.scala23
-rw-r--r--src/library/scala/reflect/Manifest.scala12
-rw-r--r--src/library/scala/runtime/WorksheetSupport.scala93
-rw-r--r--src/library/scala/util/control/NonFatal.scala4
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala8
-rw-r--r--src/manual/scala/man1/scala.scala2
-rw-r--r--src/partest-extras/scala/tools/partest/Util.scala4
-rw-r--r--src/reflect/scala/reflect/api/BuildUtils.scala29
-rw-r--r--src/reflect/scala/reflect/api/Exprs.scala2
-rw-r--r--src/reflect/scala/reflect/api/Importers.scala2
-rw-r--r--src/reflect/scala/reflect/api/JavaUniverse.scala2
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala6
-rw-r--r--src/reflect/scala/reflect/api/Quasiquotes.scala1
-rw-r--r--src/reflect/scala/reflect/api/Universe.scala5
-rw-r--r--src/reflect/scala/reflect/internal/BuildUtils.scala303
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala72
-rw-r--r--src/reflect/scala/reflect/internal/FreshNames.scala35
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala14
-rw-r--r--src/reflect/scala/reflect/internal/Mirrors.scala12
-rw-r--r--src/reflect/scala/reflect/internal/StdAttachments.scala13
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala9
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala24
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala450
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala16
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala10
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala6
-rw-r--r--src/reflect/scala/reflect/internal/util/FreshNameCreator.scala7
-rw-r--r--src/reflect/scala/reflect/macros/Aliases.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Attachments.scala4
-rw-r--r--src/reflect/scala/reflect/macros/BlackboxContext.scala (renamed from src/reflect/scala/reflect/macros/Context.scala)36
-rw-r--r--src/reflect/scala/reflect/macros/BlackboxMacro.scala (renamed from src/reflect/scala/reflect/macros/Macro.scala)15
-rw-r--r--src/reflect/scala/reflect/macros/Enclosures.scala18
-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.scala27
-rw-r--r--src/reflect/scala/reflect/macros/WhiteboxContext.scala76
-rw-r--r--src/reflect/scala/reflect/macros/WhiteboxMacro.scala36
-rw-r--r--src/reflect/scala/reflect/macros/package.scala14
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala11
-rw-r--r--src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala11
-rw-r--r--src/reflect/scala/reflect/runtime/package.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/IMain.scala3
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JavapClass.scala2
-rw-r--r--src/scaladoc/scala/tools/ant/Scaladoc.scala6
-rw-r--r--src/scalap/scala/tools/scalap/Arguments.scala6
-rwxr-xr-xtest/build-partest.xml3
-rw-r--r--test/disabled/run/lisp.scala16
-rw-r--r--test/files/jvm/non-fatal-tests.scala4
-rw-r--r--test/files/jvm/typerep.scala2
-rw-r--r--test/files/neg/class-of-double-targs.check4
-rw-r--r--test/files/neg/class-of-double-targs.scala3
-rw-r--r--test/files/neg/macro-abort/Macros_1.scala4
-rw-r--r--test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala2
-rw-r--r--test/files/neg/macro-blackbox-dynamic-materialization.check4
-rw-r--r--test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala25
-rw-r--r--test/files/neg/macro-blackbox-dynamic-materialization/Test_2.scala4
-rw-r--r--test/files/neg/macro-blackbox-extractor.check4
-rw-r--r--test/files/neg/macro-blackbox-extractor/Macros_1.scala21
-rw-r--r--test/files/neg/macro-blackbox-extractor/Test_2.scala5
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization.check8
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization.flags1
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala (renamed from test/files/run/t5923c/Macros_1.scala)6
-rw-r--r--test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala (renamed from test/files/run/t5923c/Test_2.scala)0
-rw-r--r--test/files/neg/macro-blackbox-structural.check4
-rw-r--r--test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala15
-rw-r--r--test/files/neg/macro-blackbox-structural/Test_2.scala5
-rw-r--r--test/files/neg/macro-bundle-abstract.check4
-rw-r--r--test/files/neg/macro-bundle-abstract.scala5
-rw-r--r--test/files/neg/macro-bundle-class.check2
-rw-r--r--test/files/neg/macro-bundle-class.scala6
-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-object.check6
-rw-r--r--test/files/neg/macro-bundle-object.scala7
-rw-r--r--test/files/neg/macro-bundle-polymorphic.check6
-rw-r--r--test/files/neg/macro-bundle-polymorphic.scala5
-rw-r--r--test/files/neg/macro-bundle-trait.check2
-rw-r--r--test/files/neg/macro-bundle-trait.scala8
-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-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.scala6
-rw-r--r--test/files/neg/macro-invalidshape/Impls_1.scala2
-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.scala2
-rw-r--r--test/files/neg/macro-invalidsig.check70
-rw-r--r--test/files/neg/macro-invalidsig/Impls_1.scala30
-rw-r--r--test/files/neg/macro-invalidusage-badargs/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidusage-badbounds/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidusage-badtargs/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/macro-invalidusage-presuper/Impls_1.scala4
-rw-r--r--test/files/neg/macro-noexpand/Impls_1.scala2
-rw-r--r--test/files/neg/macro-nontypeablebody/Impls_1.scala2
-rw-r--r--test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala2
-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.scala2
-rw-r--r--test/files/neg/macro-quasiquotes/Macros_1.scala4
-rw-r--r--test/files/neg/macro-without-xmacros-a/Impls_1.scala2
-rw-r--r--test/files/neg/macro-without-xmacros-b/Impls_1.scala2
-rw-r--r--test/files/neg/patmatexhaust.scala4
-rw-r--r--test/files/neg/t414.scala2
-rw-r--r--test/files/neg/t5689.check6
-rw-r--r--test/files/neg/t5689.scala4
-rw-r--r--test/files/neg/t5702-neg-bad-and-wild.check2
-rw-r--r--test/files/neg/t5702-neg-bad-and-wild.scala2
-rw-r--r--test/files/neg/t5753/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/t5753/Test_2.scala2
-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.check2
-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/t7157/Impls_Macros_1.scala26
-rw-r--r--test/files/neg/t7605-deprecation.check15
-rw-r--r--test/files/neg/t7605-deprecation.scala7
-rw-r--r--test/files/neg/t997.scala2
-rw-r--r--test/files/neg/wellkinded_wrongarity.check4
-rw-r--r--test/files/neg/wellkinded_wrongarity.scala2
-rw-r--r--test/files/pos/SI-4012-a.scala7
-rw-r--r--test/files/pos/SI-4012-b.scala15
-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/bounds.scala6
-rw-r--r--test/files/pos/macro-implicit-invalidate-on-error.check0
-rw-r--r--test/files/pos/macro-implicit-invalidate-on-error.scala28
-rw-r--r--test/files/pos/patmat.scala4
-rw-r--r--test/files/pos/spec-doubledef-new.scala6
-rw-r--r--test/files/pos/spec-doubledef-old.scala6
-rw-r--r--test/files/pos/t0064.scala2
-rw-r--r--test/files/pos/t1014.scala16
-rw-r--r--test/files/pos/t1203a.scala13
-rw-r--r--test/files/pos/t247.scala4
-rw-r--r--test/files/pos/t2698.scala14
-rw-r--r--test/files/pos/t3160.scala6
-rw-r--r--test/files/pos/t443.scala8
-rw-r--r--test/files/pos/t4579.scala12
-rw-r--r--test/files/pos/t5120.scala4
-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.scala13
-rw-r--r--test/files/pos/t5744/Macros_1.scala6
-rw-r--r--test/files/pos/t6047.scala4
-rw-r--r--test/files/pos/t6201.scala19
-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/t7983.scala31
-rw-r--r--test/files/pos/t7987/Macro_1.scala6
-rw-r--r--test/files/pos/t7987/Test_2.scala12
-rw-r--r--test/files/pos/tcpoly_bounds1.scala4
-rw-r--r--test/files/pos/typealiases.scala2
-rw-r--r--test/files/pos/unapplyNeedsMemberType.scala2
-rw-r--r--test/files/pos/valdefs.scala2
-rw-r--r--test/files/positions/ExcludedPrefix1.scala2
-rw-r--r--test/files/positions/Overlap4.scala2
-rw-r--r--test/files/positions/Scaladoc7.scala2
-rw-r--r--test/files/presentation/callcc-interpreter.check8
-rw-r--r--test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala32
-rw-r--r--test/files/presentation/completion-implicit-chained.check29
-rw-r--r--test/files/presentation/completion-implicit-chained/Test.scala3
-rw-r--r--test/files/presentation/completion-implicit-chained/src/Completions.scala12
-rw-r--r--test/files/presentation/ide-bug-1000349.check2
-rw-r--r--test/files/presentation/ide-bug-1000475.check6
-rw-r--r--test/files/presentation/ide-bug-1000531.check2
-rw-r--r--test/files/presentation/implicit-member.check2
-rw-r--r--test/files/presentation/memory-leaks/MemoryLeaksTest.scala17
-rw-r--r--test/files/presentation/ping-pong.check4
-rw-r--r--test/files/presentation/scope-completion-1.check19
-rw-r--r--test/files/presentation/scope-completion-1/Test.scala3
-rw-r--r--test/files/presentation/scope-completion-1/src/Completions.scala12
-rw-r--r--test/files/presentation/scope-completion-2.check35
-rw-r--r--test/files/presentation/scope-completion-2/Test.scala3
-rw-r--r--test/files/presentation/scope-completion-2/src/Completions.scala35
-rw-r--r--test/files/presentation/scope-completion-3.check111
-rw-r--r--test/files/presentation/scope-completion-3/Test.scala3
-rw-r--r--test/files/presentation/scope-completion-3/src/Completions.scala106
-rw-r--r--test/files/presentation/scope-completion-4.check293
-rw-r--r--test/files/presentation/scope-completion-4/Test.scala3
-rw-r--r--test/files/presentation/scope-completion-4/src/Completions.scala84
-rw-r--r--test/files/presentation/scope-completion-import.check141
-rw-r--r--test/files/presentation/scope-completion-import/Test.scala3
-rw-r--r--test/files/presentation/scope-completion-import/src/Completions.scala64
-rw-r--r--test/files/presentation/t1207.check12
-rw-r--r--test/files/presentation/t5708.check2
-rw-r--r--test/files/presentation/t7915.check11
-rw-r--r--test/files/presentation/t7915/Test.scala8
-rw-r--r--test/files/presentation/t7915/src/Foo.scala9
-rw-r--r--test/files/presentation/visibility.check10
-rw-r--r--test/files/run/Course-2002-05.scala16
-rw-r--r--test/files/run/Course-2002-06.scala2
-rw-r--r--test/files/run/Course-2002-07.scala140
-rw-r--r--test/files/run/Course-2002-08.scala28
-rw-r--r--test/files/run/Course-2002-09.scala40
-rw-r--r--test/files/run/Course-2002-13.scala16
-rw-r--r--test/files/run/bugs.scala2
-rw-r--r--test/files/run/ctries-old/main.scala2
-rw-r--r--test/files/run/delambdafy-dependent-on-param-subst-2.scala20
-rw-r--r--test/files/run/delambdafy-dependent-on-param-subst.flags1
-rw-r--r--test/files/run/delambdafy-dependent-on-param-subst.scala20
-rw-r--r--test/files/run/fors.check28
-rw-r--r--test/files/run/fors.scala84
-rw-r--r--test/files/run/getClassTest-old.scala2
-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.scala2
-rw-r--r--test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-basic-mamd-mi/Impls_1.scala2
-rw-r--r--test/files/run/macro-blackbox-materialization.check3
-rw-r--r--test/files/run/macro-blackbox-materialization/Macros_1.scala16
-rw-r--r--test/files/run/macro-blackbox-materialization/Test_2.scala5
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Impls_1.scala7
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-bundle-repl.check8
-rw-r--r--test/files/run/macro-bundle-repl.scala8
-rw-r--r--test/files/run/macro-bundle-static/Impls_Macros_1.scala7
-rw-r--r--test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala7
-rw-r--r--test/files/run/macro-def-infer-return-type/Impls_1.scala8
-rw-r--r--test/files/run/macro-def-path-dependent/Test_1.scala2
-rw-r--r--test/files/run/macro-def-path-dependent/Test_2.scala2
-rw-r--r--test/files/run/macro-def-path-dependent/Test_3.scala2
-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-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.scala2
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-multiple-arglists/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-nullary-generic/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-overload/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-override/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-recursive/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-tparams-bounds.check2
-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.scala2
-rw-r--r--test/files/run/macro-expand-tparams-implicit/Impls_1.scala2
-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.scala2
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala2
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala2
-rw-r--r--test/files/run/macro-impl-default-params/Impls_Macros_1.scala2
-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.scala2
-rw-r--r--test/files/run/macro-impl-tparam-only-in-impl.check1
-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.scala2
-rw-r--r--test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-invalidusage-badret.check2
-rw-r--r--test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-openmacros/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-parse-position/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala2
-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.scala2
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala2
-rw-r--r--test/files/run/macro-reify-basic/Macros_1.scala2
-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.scala2
-rw-r--r--test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-splice-splice/Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-staticXXX/Macros_1.scala6
-rw-r--r--test/files/run/macro-reify-tagful-a/Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-type/Macros_1.scala4
-rw-r--r--test/files/run/macro-reify-unreify/Macros_1.scala2
-rw-r--r--test/files/run/macro-repl-basic.check4
-rw-r--r--test/files/run/macro-repl-basic.scala2
-rw-r--r--test/files/run/macro-repl-dontexpand.check14
-rw-r--r--test/files/run/macro-repl-dontexpand.scala6
-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-system-properties.check12
-rw-r--r--test/files/run/macro-system-properties.scala4
-rw-r--r--test/files/run/macro-term-declared-in-annotation/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-anonymous/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-block/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class-class/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class-object/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-default-param/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-method/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object-class/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object-object/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-package-object/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-refinement/Impls_1.scala2
-rw-r--r--test/files/run/macro-term-declared-in-trait/Impls_1.scala2
-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.check2
-rw-r--r--test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala25
-rw-r--r--test/files/run/macro-whitebox-dynamic-materialization/Test_2.scala4
-rw-r--r--test/files/run/macro-whitebox-extractor.check1
-rw-r--r--test/files/run/macro-whitebox-extractor/Macros_1.scala21
-rw-r--r--test/files/run/macro-whitebox-extractor/Test_2.scala5
-rw-r--r--test/files/run/macro-whitebox-fundep-materialization.check (renamed from test/files/run/t5923c.check)0
-rw-r--r--test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala39
-rw-r--r--test/files/run/macro-whitebox-fundep-materialization/Test_2.scala12
-rw-r--r--test/files/run/macro-whitebox-structural.check1
-rw-r--r--test/files/run/macro-whitebox-structural/Impls_Macros_1.scala16
-rw-r--r--test/files/run/macro-whitebox-structural/Test_2.scala5
-rw-r--r--test/files/run/map_test.scala2
-rw-r--r--test/files/run/mutable-anyrefmap.scala91
-rw-r--r--test/files/run/mutable-longmap.scala79
-rw-r--r--test/files/run/patmatnew.scala28
-rw-r--r--test/files/run/reflection-sync-subtypes.check0
-rw-r--r--test/files/run/reflection-sync-subtypes.scala (renamed from test/disabled/run/reflection-sync-subtypes.scala)0
-rw-r--r--test/files/run/repl-backticks.check2
-rw-r--r--test/files/run/repl-backticks.scala18
-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/t1500.check3
-rw-r--r--test/files/run/t1500.scala46
-rw-r--r--test/files/run/t1501.check3
-rw-r--r--test/files/run/t1501.scala56
-rw-r--r--test/files/run/t3888.scala2
-rw-r--r--test/files/run/t4124.check4
-rw-r--r--test/files/run/t4124.scala24
-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.scala2
-rw-r--r--test/files/run/t5894.scala2
-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/t5923c.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.check8
-rw-r--r--test/files/run/t6187.scala4
-rw-r--r--test/files/run/t6221/Macros_1.scala4
-rw-r--r--test/files/run/t6329_repl_bug.check17
-rw-r--r--test/files/run/t6329_repl_bug.scala (renamed from test/files/run/t6329_repl_bug.pending)0
-rw-r--r--test/files/run/t6329_vanilla_bug.check3
-rw-r--r--test/files/run/t6329_vanilla_bug.scala (renamed from test/files/run/t6329_vanilla_bug.pending)0
-rw-r--r--test/files/run/t6381.check4
-rw-r--r--test/files/run/t6381.scala2
-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/t6546.flags1
-rw-r--r--test/files/run/t6546/A_1.scala6
-rw-r--r--test/files/run/t6546/B_2.scala8
-rw-r--r--test/files/run/t6662/Macro_1.scala4
-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/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/t7985.scala3
-rw-r--r--test/files/run/t7985b.scala5
-rw-r--r--test/files/run/tailcalls.scala2
-rw-r--r--test/files/run/tcpoly_parseridioms.check4
-rw-r--r--test/files/run/tcpoly_parseridioms.scala8
-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/run/value-class-partial-func-depmet.scala24
-rw-r--r--test/files/run/withIndex.scala2
-rw-r--r--test/files/scalacheck/CheckCollections.scala9
-rw-r--r--test/files/scalacheck/CheckEither.scala12
-rw-r--r--test/files/scalacheck/array-new.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala17
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala10
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala9
-rw-r--r--test/files/scalacheck/quasiquotes/ErrorProps.scala8
-rw-r--r--test/files/scalacheck/quasiquotes/ForProps.scala70
-rw-r--r--test/files/scalacheck/quasiquotes/LiftableProps.scala9
-rw-r--r--test/files/scalacheck/quasiquotes/PatternConstructionProps.scala9
-rw-r--r--test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala10
-rw-r--r--test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala55
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala19
-rw-r--r--test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala9
-rw-r--r--test/files/scalacheck/quasiquotes/Test.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/TypeConstructionProps.scala15
-rw-r--r--test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala9
-rw-r--r--test/files/scalacheck/quasiquotes/TypecheckedProps.scala53
-rw-r--r--test/files/scalacheck/si4147.scala4
-rw-r--r--test/files/scalacheck/t2460.scala5
-rw-r--r--test/files/scalacheck/treeset.scala2
-rw-r--r--test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala47
-rw-r--r--test/pending/run/reify_callccinterpreter.scala12
-rw-r--r--test/pending/run/reify_simpleinterpreter.scala10
-rw-r--r--test/pending/shootout/fasta.scala64
-rw-r--r--test/pending/shootout/revcomp.scala-2.scala18
-rw-r--r--test/pending/shootout/revcomp.scala-3.scala40
-rw-r--r--versions.properties19
528 files changed, 6186 insertions, 2775 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2451a52682..1c05b4fd6b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -63,4 +63,4 @@ Example:
## The Scala Improvement Process
A new language feature requires a SIP (Scala Improvement Process) proposal. Note that significant additions to the standard library are also considered candidates for a SIP proposal.
-For more details on submitting SIPs, see (how to submit a SIP)[http://docs.scala-lang.org/sips/sip-submission.html].
+For more details on submitting SIPs, see [how to submit a SIP](http://docs.scala-lang.org/sips/sip-submission.html).
diff --git a/build.xml b/build.xml
index 37d894e7d3..545d17ef58 100755
--- a/build.xml
+++ b/build.xml
@@ -29,7 +29,7 @@ scalacArgs examples:
"-Dscalac.args=\"-Yrangepos\" -Dpartest.scalac_opts=\"-Yrangepos\""
targets exercised:
- distpack-maven-opt nightly locker.done build-opt test.suite test.continuations.suite test.scaladoc
+ deploy-core.snapshot publish-opt-nodocs distpack-maven-opt nightly locker.done build build-opt test.suite test.continuations.suite test.scaladoc
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
@@ -278,18 +278,20 @@ TODO:
<artifact:remoteRepository id="extra-repo" url="${extra.repo.url}"/>
+ <!-- TODO: delay until absolutely necessary to allow minimal build, also move out partest dependency from scaladoc -->
<artifact:dependencies pathId="partest.classpath" filesetId="partest.fileset" versionsId="partest.versions">
<!-- uncomment the following if you're deploying your own partest locally -->
<!-- <localRepository path="${user.home}/.m2/repository"/> -->
<!-- so we don't have to wait for artifacts to synch to maven central
(we don't distribute partest with Scala, so the risk of sonatype and maven being out of synch is irrelevant):
-->
- <!-- <artifact:remoteRepository refid="extra-repo"/> -->
+ <artifact:remoteRepository refid="extra-repo"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-partest_${scala.binary.version}" version="${partest.version.number}" />
</artifact:dependencies>
<copy-deps project="partest"/>
<artifact:dependencies pathId="scalacheck.classpath" filesetId="scalacheck.fileset" versionsId="scalacheck.versions">
+ <artifact:remoteRepository refid="extra-repo"/>
<dependency groupId="org.scalacheck" artifactId="scalacheck_${scala.binary.version}" version="${scalacheck.version.number}" />
</artifact:dependencies>
@@ -301,7 +303,7 @@ TODO:
<!-- used by the test.osgi target to create osgi bundles for the xml, parser-combinator jars
must specify sourcesFilesetId, javadocFilesetId to download these types of artifacts -->
<artifact:dependencies pathId="external-modules.deps.classpath" sourcesFilesetId="external-modules.sources.fileset" javadocFilesetId="external-modules.javadoc.fileset">
- <!-- <artifact:remoteRepository refid="extra-repo"/> -->
+ <artifact:remoteRepository refid="extra-repo"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-xml_${scala.binary.version}" version="${scala-xml.version.number}"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-parser-combinators_${scala.binary.version}" version="${scala-parser-combinators.version.number}"/>
</artifact:dependencies>
@@ -573,9 +575,23 @@ TODO:
<property name="reflect.skipPackages" value="scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"/>
<property name="compiler.description" value="Scala Compiler"/>
- <property name="compiler.name" value="scala-compiler"/>
<property name="compiler.docroot" value="rootdoc.txt"/>
+ <!-- these are not used used, preparation for the 'TODO modularize compiler' task -->
+ <property name="interactive.description" value="Scala Interactive Compiler" />
+ <property name="interactive.package" value="modules." />
+ <property name="interactive.name" value="scala-compiler-interactive"/>
+ <property name="interactive.namesuffix" value="_${scala.binary.version}"/>
+ <property name="interactive.version" value="${scala-compiler-interactive.version.number}"/>
+ <property name="interactive.targetjar" value="scala-compiler-interactive_${scala.binary.version}-${scala-compiler-interactive.version.number}.jar"/>
+
+ <property name="scaladoc.description" value="Scala Documentation Generator"/>
+ <property name="scaladoc.package" value="modules." />
+ <property name="scaladoc.name" value="scala-compiler-doc" />
+ <property name="scaladoc.namesuffix" value="_${scala.binary.version}"/>
+ <property name="scaladoc.version" value="${scala-compiler-doc.version.number}"/>
+ <property name="scaladoc.targetjar" value="scala-compiler-doc_${scala.binary.version}-${scala-compiler-doc.version.number}.jar"/>
+
<property name="actors.description" value="Scala Actors Library"/>
<property name="continuations-plugin.description" value="Scala Delimited Continuations Compiler Plugin"/>
@@ -623,7 +639,7 @@ TODO:
</macrodef>
<!-- projects without project-specific options: asm, forkjoin, manual, bin, repl -->
- <for list="actors,compiler,continuations-library,continuations-plugin,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml" param="project">
+ <for list="actors,compiler,interactive,scaladoc,continuations-library,continuations-plugin,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml" param="project">
<sequential>
<!-- description is mandatory -->
<init-project-prop project="@{project}" name="package" default=""/>
@@ -673,7 +689,9 @@ TODO:
There must be a variable of the shape @{stage}.@{project}.build.path
for all @{stage} in locker, quick, strap
and all @{project} in library, reflect, compiler
- when stage is quick, @{project} also includes: actors, repl, swing, continuations-plugin, continuations-library, interactive, scaladoc, scalap
+ when stage is quick, @{project} also includes: actors, repl, swing, continuations-plugin, continuations-library, scalap
+
+ NOTE: interactive, scaladoc, are only used upto quick; they are still packed into the compiler jar
-->
<!-- LOCKER -->
@@ -766,7 +784,6 @@ TODO:
<path id="quick.interactive.build.path">
<path refid="quick.compiler.build.path"/>
- <pathelement location="${build-quick.dir}/classes/scaladoc"/>
<pathelement location="${build-quick.dir}/classes/interactive"/>
</path>
@@ -795,6 +812,7 @@ TODO:
<pathelement location="${actors.jar}"/>
<pathelement location="${reflect.jar}"/>
<pathelement location="${compiler.jar}"/>
+ <!-- TODO modularize compiler: <pathelement location="${scaladoc.jar}"/> -->
<pathelement location="${scalap.jar}"/>
<path refid="repl.deps.classpath"/>
<path refid="aux.libs"/>
@@ -812,12 +830,19 @@ TODO:
<path id="pack.compiler.files">
<fileset dir="${build-quick.dir}/classes/compiler"/>
- <fileset dir="${build-quick.dir}/classes/repl"/>
+
+ <!-- TODO modularize compiler. Remove the other class dirs as soon as they become modules -->
<fileset dir="${build-quick.dir}/classes/scaladoc"/>
<fileset dir="${build-quick.dir}/classes/interactive"/>
+ <fileset dir="${build-quick.dir}/classes/repl"/>
<fileset dir="${asm-classes}"/>
</path>
+ <!-- TODO modularize compiler.
+ <path id="pack.scaladoc.files"> <fileset dir="${build-quick.dir}/classes/scaladoc"/> </path>
+ <path id="pack.interactive.files"><fileset dir="${build-quick.dir}/classes/interactive"/> </path>
+ -->
+
<path id="pack.swing.files"> <fileset dir="${build-quick.dir}/classes/swing"/> </path>
<path id="pack.reflect.files"> <fileset dir="${build-quick.dir}/classes/reflect"/> </path>
<path id="pack.continuations-plugin.files"> <fileset dir="${build-quick.dir}/classes/continuations-plugin"/> </path>
@@ -849,18 +874,26 @@ TODO:
<path id="docs.library.build.path"> <path refid="quick.library.build.path"/> </path>
<path id="docs.reflect.build.path"> <path refid="quick.reflect.build.path"/> </path>
<path id="docs.compiler.build.path"> <path refid="quick.compiler.build.path"/> </path>
+ <path id="docs.scaladoc.build.path"> <path refid="quick.scaladoc.build.path"/> </path>
+ <path id="docs.interactive.build.path"> <path refid="quick.interactive.build.path"/> </path>
<path id="docs.scalap.build.path"> <path refid="quick.scalap.build.path"/> </path>
<path id="docs.continuations-plugin.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
<path id="docs.continuations-library.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
<path id="docs.actors.build.path"> <path refid="quick.actors.build.path"/> </path>
<path id="docs.swing.build.path"> <path refid="quick.swing.build.path"/> </path>
- <!-- run-time classpath for scaladoc: should be resolved through maven once it's an actual module -->
+ <!-- run-time classpath for scaladoc TODO: resolve through maven -->
<path id="scaladoc.classpath">
<path refid="external-modules-nocore"/>
<pathelement location="${library.jar}"/>
<pathelement location="${reflect.jar}"/>
<pathelement location="${compiler.jar}"/>
+
+ <!-- TODO modularize compiler
+ <pathelement location="${interactive.jar}"/>
+ <pathelement location="${scaladoc.jar}"/>
+ -->
+
<pathelement location="${ant.jar}"/>
<path refid="aux.libs"/>
</path>
@@ -874,10 +907,10 @@ TODO:
<!-- MISC -->
<path id="sbt.compile.build.path">
- <path refid="quick.compiler.build.path"/>
- <pathelement location="${build-quick.dir}/classes/repl"/>
- <pathelement location="${build-quick.dir}/classes/scaladoc"/>
- <pathelement location="${build-quick.dir}/classes/interactive"/>
+ <path refid="scaladoc.classpath"/>
+ <!-- TODO modularize compiler: bring back when repl leaves compiler jar
+ <pathelement location="${build-quick.dir}/classes/repl"/>
+ -->
<pathelement location="${sbt.interface.jar}"/>
</path>
@@ -888,9 +921,20 @@ TODO:
Why, the compiler we're testing, of course, and partest with all its dependencies.
-->
<path id="partest.compilation.path">
+ <path refid="partest.compilation.path.core"/>
+ <path refid="partest.compilation.path.noncore"/>
+ </path>
+ <path id="partest.compilation.path.core">
<pathelement location="${library.jar}"/>
<pathelement location="${reflect.jar}"/>
<pathelement location="${compiler.jar}"/>
+ </path>
+ <path id="partest.compilation.path.noncore">
+
+ <!-- TODO modularize compiler
+ <pathelement location="${scaladoc.jar}"/>
+ <pathelement location="${interactive.jar}"/>
+ -->
<!-- TODO: move scalap & actors out of repo -->
<pathelement location="${scalap.jar}"/>
@@ -1352,6 +1396,8 @@ TODO:
</sequential>
</macrodef>
+
+
<!-- ===========================================================================
LOCAL REFERENCE BUILD (LOCKER)
============================================================================ -->
@@ -1406,13 +1452,6 @@ TODO:
<target name="quick.swing" depends="quick.actors, quick.lib" if="has.java6">
<staged-build with="locker" stage="quick" project="swing"/> </target>
- <target name="quick.partest-extras"
- depends="quick.comp">
- <!-- compile compiler-specific parts of partest -->
- <staged-build with="starr" stage="quick" project="partest-extras" />
- <staged-build with="starr" stage="quick" project="partest-javaagent" />
- </target>
-
<target name="quick.plugins" depends="quick.comp">
<staged-uptodate stage="quick" project="continuations-plugin">
@@ -1458,6 +1497,7 @@ TODO:
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
+ <!-- TODO modularize compiler. Remove other quick targets when they become modules. -->
<target name="pack.comp" depends="quick.comp, quick.scaladoc, quick.interactive, quick.repl, asm.done">
<staged-pack project="compiler" manifest="${build-pack.dir}/META-INF/MANIFEST.MF">
<pre> <!-- TODO the files copied here do not influence actuality of this target (nor does the manifest) -->
@@ -1484,6 +1524,11 @@ TODO:
</staged-pack>
</target>
+ <!-- TODO modularize compiler. These targets are currently not used.
+ <target name="pack.scaladoc" depends="quick.scaladoc"> <staged-pack project="scaladoc"/> </target>
+ <target name="pack.interactive" depends="quick.interactive"> <staged-pack project="interactive"/> </target>
+ -->
+
<target name="pack.actors" depends="quick.actors"> <staged-pack project="actors"/> </target>
<target name="pack.swing" if="has.java6" depends="quick.swing"> <staged-pack project="swing"/> </target>
@@ -1493,21 +1538,27 @@ TODO:
<target name="pack.core" depends="pack.reflect, pack.comp, pack.lib"/>
- <target name="pack.modules" depends="pack.core, pack.actors, pack.swing, pack.plugins, pack.scalap">
+ <!-- TODO modularize compiler: pack.scaladoc, pack.interactive, -->
+ <target name="pack.modules" depends="pack.actors, pack.swing, pack.plugins, pack.scalap">
<copy todir="${build-pack.dir}/lib">
<path refid="external-modules-nocore" />
<mapper type="flatten" />
</copy>
</target>
- <target name="scaladoc.task" depends="pack.modules" unless="docs.skip">
+ <!-- depends on pack.core for scaladoc -->
+ <target name="scaladoc.task" depends="pack.core, pack.modules" unless="docs.skip">
<taskdef resource="scala/tools/ant/antlib.xml" classpathref="scaladoc.classpath"/>
</target>
- <target name="pack.partest-extras" depends="quick.partest-extras">
- <staged-pack project="partest-extras"/>
- <staged-pack project="partest-javaagent"
- manifest="${src.dir}/partest-javaagent/scala/tools/partest/javaagent/MANIFEST.MF"/>
+ <target name="pack.partest-extras" depends="quick.comp">
+ <!-- compile compiler-specific parts of partest -->
+ <staged-build with="quick" stage="quick" project="partest-extras" />
+ <staged-build with="quick" stage="quick" project="partest-javaagent" />
+
+ <staged-pack project="partest-extras"/>
+ <staged-pack project="partest-javaagent"
+ manifest="${src.dir}/partest-javaagent/scala/tools/partest/javaagent/MANIFEST.MF"/>
</target>
<target name="pack.bin" depends="pack.core, pack.modules, pack.partest-extras">
@@ -1557,6 +1608,10 @@ TODO:
<!-- ===========================================================================
OSGi Artifacts
============================================================================ -->
+ <!-- This task takes the output of the pack stage and OSGi-fies the jars based on the bnd files in src/build/bnd
+ This means adding manifests and enforcing the Exports clauses (removing non-exported classes!)
+ These jars are then copied to the distribution and published to maven.
+ -->
<macrodef name="make-bundle">
<attribute name="project" />
<element name="srcs" description="Sources for this bundle" optional="true" implicit="true"/>
@@ -1619,11 +1674,12 @@ TODO:
<fileset dir="${src.dir}/reflect"/>
</make-bundle>
+ <!-- TODO modularize compiler. Remove the other class dirs as soon as they become modules -->
<make-bundle project="compiler">
<fileset dir="${src.dir}/compiler"/>
- <fileset dir="${src.dir}/repl"/>
<fileset dir="${src.dir}/scaladoc"/>
<fileset dir="${src.dir}/interactive"/>
+ <fileset dir="${src.dir}/repl"/>
</make-bundle>
<touch file="${build-osgi.dir}/bundles.core.complete" verbose="no"/>
@@ -1632,10 +1688,16 @@ TODO:
</target>
<target name="osgi.done" depends="pack.done, osgi.core">
- <uptodate property="osgi.bundles.available" targetfile="${build-osgi.dir}/bundles.all.complete">
+ <uptodate property="osgi.all.bundles.available" targetfile="${build-osgi.dir}/bundles.all.complete">
<srcfiles dir="${basedir}">
<include name="build.xml"/>
<include name="src/build/bnd/*.bnd"/>
+
+ <!-- TODO modularize compiler
+ <include name="${interactive.jar}"/>
+ <include name="${scaladoc.jar}"/>
+ -->
+
<include name="${actors.jar}"/>
<include name="${continuations-plugin.jar}"/>
<include name="${swing.jar}"/>
@@ -1644,9 +1706,22 @@ TODO:
</srcfiles>
</uptodate>
- <if><not><isset property="osgi.bundles.available"/></not><then>
+ <if><not><isset property="osgi.all.bundles.available"/></not><then>
<stopwatch name="osgi.all.timer"/>
+ <!-- TODO modularize compiler
+ TODO: refactor so that we can restrict exported packages to scala.tools.nsc.doc.*
+ move ant task, partest stuff to other jars,
+ and move scala.tools.nsc.ScalaDoc main class to scala.tools.nsc.doc
+ <make-bundle project="scaladoc">
+ <fileset dir="${src.dir}/scaladoc"/>
+ </make-bundle>
+
+ TODO: refactor so that we can restrict exported packages to scala.tools.nsc.interactive.*
+ <make-bundle project="interactive">
+ <fileset dir="${src.dir}/interactive"/>
+ </make-bundle>
+ -->
<make-bundle project="actors">
<fileset dir="${src.dir}/actors"/>
@@ -1824,6 +1899,17 @@ TODO:
<testSuite colors="8" kinds="pos neg run jvm res scalap scalacheck specialized instrumented"/>
</target>
+ <target name="test.suite.quick" depends="init, quick.done">
+ <path id="test.suite.path">
+ <path refid="quick.bin.tool.path"/>
+ <path refid="quick.interactive.build.path"/>
+ <path refid="partest.compilation.path.noncore"/>
+ </path>
+ <property name="pcp" value="${toString:test.suite.path}"/>
+ <taskdef classpathref="test.suite.path" resource="scala/tools/partest/antlib.xml"/>
+ <testSuite colors="8" kinds="pos neg run jvm res scalap scalacheck specialized instrumented" pcp="${pcp}"/>
+ </target>
+
<target name="test.run" depends="test.suite.init">
<testSuite kinds="run jvm"/>
</target>
@@ -1969,6 +2055,20 @@ TODO:
</staged-docs>
</target>
+ <!-- TODO modularize compiler. These targets are currently not used.
+ <target name="docs.scaladoc" depends="docs.start" unless="docs.skip">
+ <staged-docs project="scaladoc">
+ <include name="**/*.scala"/>
+ </staged-docs>
+ </target>
+
+ <target name="docs.interactive" depends="docs.start" unless="docs.skip">
+ <staged-docs project="interactive">
+ <include name="**/*.scala"/>
+ </staged-docs>
+ </target>
+ -->
+
<target name="docs.actors" depends="docs.start" unless="docs.skip">
<staged-docs project="actors">
<include name="**/*.scala"/>
@@ -2037,6 +2137,7 @@ TODO:
</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.swing, docs.scalap, docs.continuations-plugin, docs.continuations-library" unless="docs.skip"/>
<!-- ===========================================================================
@@ -2096,6 +2197,7 @@ TODO:
<chmod perm="ugo+rx" file="${dist.dir}/bin/scalap"/>
</target>
+
<target name="dist.doc" depends="dist.base, docs.done">
<mkdir dir="${dist.dir}/doc/scala-devel-docs"/>
<copy toDir="${dist.dir}/doc/scala-devel-docs" overwrite="true" flatten="true">
@@ -2256,6 +2358,11 @@ MAIN DISTRIBUTION PACKAGING
</target>
<target name="pack-maven.base" depends="pack-maven.core, osgi.done, docs.done">
+ <!-- TODO modularize compiler
+ <mvn-package project="interactive"/>
+ <mvn-package project="scaladoc"/>
+ -->
+
<mvn-package project="swing"/>
<mvn-package project="actors"/>
<mvn-package project="continuations-plugin"/>
diff --git a/docs/examples/fors.scala b/docs/examples/fors.scala
index b937e53fcd..29616b61b1 100644
--- a/docs/examples/fors.scala
+++ b/docs/examples/fors.scala
@@ -83,7 +83,7 @@ object fors {
if b1 != b2;
Elem(_, "author", _, _, Text(a1)) <- b1.toList;
Elem(_, "author", _, _, Text(a2)) <- b2.toList;
- if a1 == a2) yield Pair(a1, a2))
+ if a1 == a2) yield (a1, a2))
def removeDuplicates[a](xs: List[a]): List[a] =
if (xs.isEmpty)
diff --git a/docs/examples/iterators.scala b/docs/examples/iterators.scala
index e2e5e050a0..9ddb141d61 100644
--- a/docs/examples/iterators.scala
+++ b/docs/examples/iterators.scala
@@ -15,8 +15,8 @@ object iterators {
def findGreater(xs: Array[Double], limit: Double) =
xs.iterator
.zip(Iterator.from(0))
- .filter{case Pair(x, i) => x > limit }
- .map{case Pair(x, i) => i}
+ .filter{case (x, i) => x > limit }
+ .map{case (x, i) => i}
def main(args: Array[String]) {
val ar = Array/*[Double]*/(6, 2, 8, 5, 1)
diff --git a/docs/examples/jolib/Ref.scala b/docs/examples/jolib/Ref.scala
index 32952b4351..099a3c2df2 100644
--- a/docs/examples/jolib/Ref.scala
+++ b/docs/examples/jolib/Ref.scala
@@ -12,20 +12,20 @@ import concurrent.SyncVar;
import concurrent.jolib._;
class Ref[a](init: a) extends Join {
-
+
object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
object state extends Asynchr(this) { case class C(x: a); }
rules (
- Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) =>
+ (List(get, state), { case List(g @ get.C(), state.C(x) ) =>
{ g.set(x); state(state.C(x)) } }),
- Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
+ (List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
{ s.set(()); state(state.C(x)) } })
);
state(state.C(init));
-
+
def Get: a = get(get.C());
def Set(x: a): unit = set(set.C(x));
}
diff --git a/docs/examples/jolib/parallelOr.scala b/docs/examples/jolib/parallelOr.scala
index fb8288c5b2..a0305c56bf 100644
--- a/docs/examples/jolib/parallelOr.scala
+++ b/docs/examples/jolib/parallelOr.scala
@@ -13,27 +13,27 @@ import concurrent.SyncVar;
/** Implementation in the join-calculus of a parallel OR. */
object or extends Join {
-
+
object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res1 extends Asynchr(this) { case class C(b: boolean); }
object res2 extends Asynchr(this) { case class C(b: boolean); }
object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
-
+
rules(
- Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
+ (List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
if (b) r.set(b) else r.set(res1False(res1False.C())) }),
-
- Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
+
+ (List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
if (b) r.set(b) else r.set(res2False(res2False.C())) }),
-
- Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
+
+ (List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
r.set(b) }),
-
- Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
+
+ (List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
r.set(b) })
);
-
+
def apply(b1: => boolean, b2: => boolean): boolean = {
concurrent.ops.spawn(res1(res1.C(b1)));
concurrent.ops.spawn(res2(res2.C(b2)));
@@ -42,7 +42,7 @@ object or extends Join {
}
*/
object parallelOr {
-
+
def main(args: Array[String]): unit = {
def loop: boolean = { while (true) {}; true };
/*
diff --git a/docs/examples/monads/callccInterpreter.scala b/docs/examples/monads/callccInterpreter.scala
index 5b556bd8fa..b5008c4c1b 100644
--- a/docs/examples/monads/callccInterpreter.scala
+++ b/docs/examples/monads/callccInterpreter.scala
@@ -14,7 +14,7 @@ object callccInterpreter {
def showM(m: M[Value]): String = (m in id).toString();
- def callCC[A](h: (A => M[A]) => M[A]) =
+ def callCC[A](h: (A => M[A]) => M[A]) =
M[A](c => h(a => M[A](d => c(a))) in c);
type Name = String;
@@ -30,7 +30,7 @@ object callccInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
@@ -38,15 +38,15 @@ object callccInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -62,15 +62,15 @@ object callccInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/monads/directInterpreter.scala b/docs/examples/monads/directInterpreter.scala
index 06fffba8e2..d8ca8ccfa7 100644
--- a/docs/examples/monads/directInterpreter.scala
+++ b/docs/examples/monads/directInterpreter.scala
@@ -20,15 +20,15 @@ object directInterpreter {
case Fun(f) => "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): Value = e match {
case List() => Wrong
- case Pair(y, b) :: e1 => if (x == y) b else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) b else lookup(x, e1)
}
- def add(a: Value, b: Value): Value = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => Num(m + n)
+ def add(a: Value, b: Value): Value = (a, b) match {
+ case (Num(m), Num(n)) => Num(m + n)
case _ => Wrong
}
@@ -41,15 +41,15 @@ object directInterpreter {
case Var(x) => lookup(x, e)
case Con(n) => Num(n)
case Add(l, r) => add(interp(l, e), interp(r, e))
- case Lam(x, t) => Fun(a => interp(t, Pair(x, a) :: e))
+ case Lam(x, t) => Fun(a => interp(t, (x, a) :: e))
case App(f, t) => apply(interp(f, e), interp(t, e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showval(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- def main(args: Array[String]) =
+ def main(args: Array[String]) =
System.out.println(test(term0));
}
diff --git a/docs/examples/monads/errorInterpreter.scala b/docs/examples/monads/errorInterpreter.scala
index d3cc45627d..c15e1041e2 100644
--- a/docs/examples/monads/errorInterpreter.scala
+++ b/docs/examples/monads/errorInterpreter.scala
@@ -41,15 +41,15 @@ object errorInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => errorM("unbound variable: " + x);
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => errorM("should be numbers: " + a + "," + b)
}
@@ -65,7 +65,7 @@ object errorInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
diff --git a/docs/examples/monads/simpleInterpreter.scala b/docs/examples/monads/simpleInterpreter.scala
index cde3a92dbb..64636749ff 100644
--- a/docs/examples/monads/simpleInterpreter.scala
+++ b/docs/examples/monads/simpleInterpreter.scala
@@ -22,7 +22,7 @@ object simpleInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
@@ -30,15 +30,15 @@ object simpleInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -54,14 +54,14 @@ object simpleInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/monads/stateInterpreter.scala b/docs/examples/monads/stateInterpreter.scala
index 97f3335dab..e13e9049da 100644
--- a/docs/examples/monads/stateInterpreter.scala
+++ b/docs/examples/monads/stateInterpreter.scala
@@ -4,20 +4,20 @@ object stateInterpreter {
type State = Int;
- val tickS = new M(s => Pair((), s + 1));
+ val tickS = new M(s => ((), s + 1));
- case class M[A](in: State => Pair[A, State]) {
- def bind[B](k: A => M[B]) = M[B]{ s0 =>
- val Pair(a, s1) = this in s0; k(a) in s1
+ case class M[A](in: State => Tuple2[A, State]) {
+ def bind[B](k: A => M[B]) = M[B]{ s0 =>
+ val (a, s1) = this in s0; k(a) in s1
}
def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
def flatMap[B](f: A => M[B]): M[B] = bind(f);
}
- def unitM[A](a: A) = M[A](s => Pair(a, s));
+ def unitM[A](a: A) = M[A](s => (a, s));
def showM(m: M[Value]): String = {
- val Pair(a, s1) = m in 0;
+ val (a, s1) = m in 0;
"Value: " + a + "; Count: " + s1
}
@@ -41,15 +41,15 @@ object stateInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
case _ => unitM(Wrong)
}
@@ -65,14 +65,14 @@ object stateInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
diff --git a/docs/examples/patterns.scala b/docs/examples/patterns.scala
index 738deabc66..d082fcc3de 100644
--- a/docs/examples/patterns.scala
+++ b/docs/examples/patterns.scala
@@ -13,17 +13,17 @@ object patterns {
case Leaf(x) => x
}
- def find[a,b](it: Iterator[Pair[a, b]], x: a): Option[b] = {
+ def find[a,b](it: Iterator[Tuple2[a, b]], x: a): Option[b] = {
var result: Option[b] = None
var found = false
while (it.hasNext && !found) {
- val Pair(x1, y) = it.next
+ val (x1, y) = it.next
if (x == x1) { found = true; result = Some(y) }
}
result
}
- def printFinds[a](xs: List[Pair[a, String]], x: a) =
+ def printFinds[a](xs: List[Tuple2[a, String]], x: a) =
find(xs.iterator, x) match {
case Some(y) => System.out.println(y)
case None => System.out.println("no match")
@@ -31,6 +31,6 @@ object patterns {
def main(args: Array[String]) {
println("sum of leafs=" + sumLeaves(tree1))
- printFinds(List(Pair(3, "three"), Pair(4, "four")), 4)
+ printFinds(List((3, "three"), (4, "four")), 4)
}
}
diff --git a/docs/examples/pilib/elasticBuffer.scala b/docs/examples/pilib/elasticBuffer.scala
index 5fec96ab6c..c173735dbb 100644
--- a/docs/examples/pilib/elasticBuffer.scala
+++ b/docs/examples/pilib/elasticBuffer.scala
@@ -8,7 +8,7 @@ object elasticBuffer {
* Recursive type for channels that carry a "String" channel and
* an object of the type we define.
*/
- class MetaChan extends Chan[Pair[Chan[String], MetaChan]]
+ class MetaChan extends Chan[Tuple2[Chan[String], MetaChan]]
def Buffer(put: Chan[String], get: Chan[String]): Unit = {
@@ -18,19 +18,19 @@ object elasticBuffer {
def Bl(i:Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan): unit =
choice (
- l(Pair(o,r)) * (System.out.println("Removed one cell.")),
+ l((o,r)) * (System.out.println("Removed one cell.")),
i * (inp => Cl(i, l, o, r, inp))
)
/**
* A buffer cell containing a value, ready to receive (o,r) from the right.
*/
- def Cl(i: Chan[String], l: MetaChan,
+ def Cl(i: Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan, content: String): Unit =
choice (
o(content) * (Bl(i,l,o,r)),
i * (inp => Dl(i,l,o,r,content, inp)),
- r * ( { case Pair(newo, newr) => Cl(i,l,newo,newr,content) })
+ r * ( { case (newo, newr) => Cl(i,l,newo,newr,content) })
)
/**
diff --git a/docs/examples/pilib/handover.scala b/docs/examples/pilib/handover.scala
index c9b6156c2c..4e9a5670a0 100644
--- a/docs/examples/pilib/handover.scala
+++ b/docs/examples/pilib/handover.scala
@@ -13,14 +13,14 @@ object handoverRecursive {
* Recursive type for channels that carry a channel "unit" and
* an object of the type we define.
*/
- class Switch extends Chan[Pair[Chan[unit], Switch]]
+ class Switch extends Chan[Tuple2[Chan[unit], Switch]]
/**
* Car.
*/
def Car(talk: Chan[unit], switch: Switch): unit =
choice (
- switch * ({ case Pair(t,s) => Car(t, s) }),
+ switch * ({ case (t,s) => Car(t, s) }),
talk(()) * ( {
Thread.sleep(1 + random.nextInt(1000));
System.out.println("Car emitted a message.");
@@ -32,20 +32,20 @@ object handoverRecursive {
* Control center.
*/
def Control(talk1: Chan[unit], switch1: Switch,
- gain1: Switch, lose1: Switch,
+ gain1: Switch, lose1: Switch,
talk2: Chan[unit], switch2: Switch,
gain2: Switch, lose2: Switch): unit
= {
def Control1: unit= {
Thread.sleep(1 + random.nextInt(1000));
- lose1.write(Pair(talk2, switch2));
- gain2.write(Pair(talk2, switch2));
+ lose1.write((talk2, switch2));
+ gain2.write((talk2, switch2));
Control2
}
def Control2: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose2.write(Pair(talk1, switch1));
- gain1.write(Pair(talk1, switch1));
+ lose2.write((talk1, switch1));
+ gain1.write((talk1, switch1));
Control1
}
Control1
@@ -62,8 +62,8 @@ object handoverRecursive {
System.out.println(id + " received a message.")
ActiveTransmitter(id, talk, switch, gain, lose)
}),
- lose * ({ case Pair(t, s) => {
- switch.write(Pair(t, s))
+ lose * ({ case (t, s) => {
+ switch.write((t, s))
IdleTransmitter(id, gain, lose)
}})
);
@@ -72,7 +72,7 @@ object handoverRecursive {
* Idle transmitter.
*/
def IdleTransmitter(id: String, gain: Switch, lose: Switch): unit = {
- val Pair(t, s) = gain.read;
+ val (t, s) = gain.read;
ActiveTransmitter(id, t, s, gain, lose)
}
@@ -108,7 +108,7 @@ object handoverCast {
def Car(talk: Chan[Any], switch: Chan[Any]): unit =
choice (
switch * (o => {
- val Pair(t,s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]];
+ val (t,s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]];
Car(t, s)
}),
talk(()) * ( {
@@ -122,20 +122,20 @@ object handoverCast {
* Control center.
*/
def Control(talk1: Chan[Any], switch1: Chan[Any],
- gain1: Chan[Any], lose1: Chan[Any],
+ gain1: Chan[Any], lose1: Chan[Any],
talk2: Chan[Any], switch2: Chan[Any],
gain2: Chan[Any], lose2: Chan[Any]): unit
= {
def Control1: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose1.write(Pair(talk2, switch2));
- gain2.write(Pair(talk2, switch2));
+ lose1.write((talk2, switch2));
+ gain2.write((talk2, switch2));
Control2
}
def Control2: unit = {
Thread.sleep(1 + random.nextInt(1000));
- lose2.write(Pair(talk1, switch1));
- gain1.write(Pair(talk1, switch1));
+ lose2.write((talk1, switch1));
+ gain1.write((talk1, switch1));
Control1
}
Control1
@@ -153,8 +153,8 @@ object handoverCast {
ActiveTransmitter(id, talk, switch, gain, lose)
}),
lose * (o => {
- val Pair(t, s) = o.asInstanceOf[Pair[Chan[Any],Chan[Any]]]
- switch.write(Pair(t, s))
+ val (t, s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
+ switch.write((t, s))
IdleTransmitter(id, gain, lose)
})
)
@@ -163,7 +163,7 @@ object handoverCast {
* Idle transmitter.
*/
def IdleTransmitter(id: String, gain: Chan[Any], lose: Chan[Any]): unit = {
- val Pair(t, s) = gain.read.asInstanceOf[Pair[Chan[Any],Chan[Any]]]
+ val (t, s) = gain.read.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
ActiveTransmitter(id, t, s, gain, lose)
}
diff --git a/docs/examples/pilib/piNat.scala b/docs/examples/pilib/piNat.scala
index a1a0e682e1..c6d9bdaf5c 100644
--- a/docs/examples/pilib/piNat.scala
+++ b/docs/examples/pilib/piNat.scala
@@ -4,23 +4,23 @@ import scala.concurrent.pilib._
/** Church encoding of naturals in the Pi-calculus */
object piNat extends Application {
-
+
/** Locations of Pi-calculus natural */
- class NatChan extends Chan[Triple[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
+ class NatChan extends Chan[Tuple3[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
/** Zero */
def Z(l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => z.write(()) }
+ l * { case (z, sd, d) => z.write(()) }
)
/** Successor of Double */
def SD(n: NatChan, l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => sd.write(n) }
+ l * { case (z, sd, d) => sd.write(n) }
)
/** Double */
def D(n: NatChan, l: NatChan): Unit = choice (
- l * { case Triple(z, sd, d) => d.write(n) }
+ l * { case (z, sd, d) => d.write(n) }
)
/** Make "l" a location representing the natural "n" */
@@ -34,7 +34,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < m.write(Triple(z, sd, d)) >;
+ spawn < m.write((z, sd, d)) >;
choice (
z * { x => make(1, n) },
sd * { m1 => { val n1 = new NatChan; spawn < D(n1, n) >; Succ(m1, n1) } },
@@ -47,7 +47,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < l.write(Triple(z, sd, d)) >;
+ spawn < l.write((z, sd, d)) >;
choice (
z * { x => spawn < Z(m) >; Z(n) },
sd * { l1 => { val m1 = new NatChan; val n1 = new NatChan;
@@ -64,7 +64,7 @@ object piNat extends Application {
val z = new Chan[Unit]
val sd = new Chan[NatChan]
val d = new Chan[NatChan]
- spawn < n.write(Triple(z, sd, d)) >;
+ spawn < n.write((z, sd, d)) >;
choice (
z * { x => 0 },
sd * { n1 => 2 * value(n1) + 1 },
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala
index d4bc8bf3e1..ac6cc35f6b 100644
--- a/docs/examples/typeinf.scala
+++ b/docs/examples/typeinf.scala
@@ -53,11 +53,11 @@ object typeInfer {
(emptySubst /: tyvars) ((s, tv) => s.extend(tv, newTyvar())) (tpe)
}
- type Env = List[Pair[String, TypeScheme]]
+ type Env = List[Tuple2[String, TypeScheme]]
def lookup(env: Env, x: String): TypeScheme = env match {
case List() => null
- case Pair(y, t) :: env1 => if (x == y) t else lookup(env1, x)
+ case (y, t) :: env1 => if (x == y) t else lookup(env1, x)
}
def gen(env: Env, t: Type): TypeScheme =
@@ -69,22 +69,22 @@ object typeInfer {
case Tycon(k, ts) => (List[Tyvar]() /: ts) ((tvs, t) => tvs union tyvars(t))
}
- def tyvars(ts: TypeScheme): List[Tyvar] =
+ def tyvars(ts: TypeScheme): List[Tyvar] =
tyvars(ts.tpe) diff ts.tyvars;
def tyvars(env: Env): List[Tyvar] =
(List[Tyvar]() /: env) ((tvs, nt) => tvs union tyvars(nt._2))
- def mgu(t: Type, u: Type, s: Subst): Subst = Pair(s(t), s(u)) match {
- case Pair(Tyvar(a), Tyvar(b)) if (a == b) =>
+ def mgu(t: Type, u: Type, s: Subst): Subst = (s(t), s(u)) match {
+ case (Tyvar(a), Tyvar(b)) if (a == b) =>
s
- case Pair(Tyvar(a), _) if !(tyvars(u) contains a) =>
+ case (Tyvar(a), _) if !(tyvars(u) contains a) =>
s.extend(Tyvar(a), u)
- case Pair(_, Tyvar(a)) =>
+ case (_, Tyvar(a)) =>
mgu(u, t, s)
- case Pair(Arrow(t1, t2), Arrow(u1, u2)) =>
+ case (Arrow(t1, t2), Arrow(u1, u2)) =>
mgu(t1, u1, mgu(t2, u2, s))
- case Pair(Tycon(k1, ts), Tycon(k2, us)) if (k1 == k2) =>
+ case (Tycon(k1, ts), Tycon(k2, us)) if (k1 == k2) =>
(s /: (ts zip us)) ((s, tu) => mgu(tu._1, tu._2, s))
case _ =>
throw new TypeError("cannot unify " + s(t) + " with " + s(u))
@@ -103,7 +103,7 @@ object typeInfer {
case Lam(x, e1) =>
val a, b = newTyvar()
val s1 = mgu(t, Arrow(a, b), s)
- val env1 = Pair(x, TypeScheme(List(), a)) :: env
+ val env1 = (x, TypeScheme(List(), a)) :: env
tp(env1, e1, b, s1)
case App(e1, e2) =>
@@ -114,7 +114,7 @@ object typeInfer {
case Let(x, e1, e2) =>
val a = newTyvar()
val s1 = tp(env, e1, a, s)
- tp(Pair(x, gen(env, s1(a))) :: env, e2, t, s1)
+ tp((x, gen(env, s1(a))) :: env, e2, t, s1)
}
}
var current: Term = null
@@ -134,18 +134,18 @@ object typeInfer {
private val a = typeInfer.newTyvar()
val env = List(
/*
- Pair("true", gen(booleanType)),
- Pair("false", gen(booleanType)),
- Pair("if", gen(Arrow(booleanType, Arrow(a, Arrow(a, a))))),
- Pair("zero", gen(intType)),
- Pair("succ", gen(Arrow(intType, intType))),
- Pair("nil", gen(listType(a))),
- Pair("cons", gen(Arrow(a, Arrow(listType(a), listType(a))))),
- Pair("isEmpty", gen(Arrow(listType(a), booleanType))),
- Pair("head", gen(Arrow(listType(a), a))),
- Pair("tail", gen(Arrow(listType(a), listType(a)))),
+ ("true", gen(booleanType)),
+ ("false", gen(booleanType)),
+ ("if", gen(Arrow(booleanType, Arrow(a, Arrow(a, a))))),
+ ("zero", gen(intType)),
+ ("succ", gen(Arrow(intType, intType))),
+ ("nil", gen(listType(a))),
+ ("cons", gen(Arrow(a, Arrow(listType(a), listType(a))))),
+ ("isEmpty", gen(Arrow(listType(a), booleanType))),
+ ("head", gen(Arrow(listType(a), a))),
+ ("tail", gen(Arrow(listType(a), listType(a)))),
*/
- Pair("fix", gen(Arrow(Arrow(a, a), a)))
+ ("fix", gen(Arrow(Arrow(a, a), a)))
)
}
@@ -181,7 +181,7 @@ object typeInfer {
yield Lam(x, t): Term )
|||
( for (
- letid <- id if letid == "let";
+ letid <- id if letid == "let";
x <- ident;
_ <- wschr('=');
t <- term;
@@ -220,7 +220,7 @@ object typeInfer {
val input = 0
def any = new Parser[char] {
def apply(in: int): Parser[char]#Result =
- if (in < s.length()) Some(Pair(s charAt in, in + 1)) else None
+ if (in < s.length()) Some((s charAt in, in + 1)) else None
}
}
@@ -239,7 +239,7 @@ object typeInfer {
if (args.length == 1) {
val ps = new ParseString(args(0)) with MiniMLParsers
ps.all(ps.input) match {
- case Some(Pair(term, _)) =>
+ case Some((term, _)) =>
"" + term + ": " + showType(term)
case None =>
"syntax error"
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index 9d123cb2d5..4421c7a07a 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -180,17 +180,17 @@ object Futures {
var cnt = 0
val mappedFts = fts.map(ft =>
- Pair({cnt+=1; cnt-1}, ft))
+ ({cnt+=1; cnt-1}, ft))
- val unsetFts = mappedFts.filter((p: Pair[Int, Future[Any]]) => {
+ val unsetFts = mappedFts.filter((p: Tuple2[Int, Future[Any]]) => {
if (p._2.isSet) { resultsMap(p._1) = Some(p._2()); false }
else { resultsMap(p._1) = None; true }
})
- val partFuns = unsetFts.map((p: Pair[Int, Future[Any]]) => {
+ val partFuns = unsetFts.map((p: Tuple2[Int, Future[Any]]) => {
val FutCh = p._2.inputChannel
- val singleCase: PartialFunction[Any, Pair[Int, Any]] = {
- case FutCh ! any => Pair(p._1, any)
+ val singleCase: PartialFunction[Any, Tuple2[Int, Any]] = {
+ case FutCh ! any => (p._1, any)
}
singleCase
})
@@ -201,7 +201,7 @@ object Futures {
}
Actor.timer.schedule(timerTask, timeout)
- def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
+ def awaitWith(partFuns: Seq[PartialFunction[Any, Tuple2[Int, Any]]]) {
val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
@@ -212,7 +212,7 @@ object Futures {
case _ => {
val pfOpt = partFuns find (_ isDefinedAt msg)
val pf = pfOpt.get // succeeds always
- val Pair(idx, subres) = pf(msg)
+ val (idx, subres) = pf(msg)
resultsMap(idx) = Some(subres)
val partFunsRest = partFuns filter (_ != pf)
diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala
index 4795ff3eb6..57d7af6d26 100644
--- a/src/actors/scala/actors/remote/NetKernel.scala
+++ b/src/actors/scala/actors/remote/NetKernel.scala
@@ -43,8 +43,8 @@ private[remote] class NetKernel(service: Service) {
private val names = new mutable.HashMap[OutputChannel[Any], Symbol]
def register(name: Symbol, a: OutputChannel[Any]): Unit = synchronized {
- actors += Pair(name, a)
- names += Pair(a, name)
+ actors(name) = a
+ names(a) = name
}
def getOrCreateName(from: OutputChannel[Any]) = names.get(from) match {
@@ -79,7 +79,7 @@ private[remote] class NetKernel(service: Service) {
def createProxy(node: Node, sym: Symbol): Proxy = {
val p = new Proxy(node, sym, this)
- proxies += Pair((node, sym), p)
+ proxies((node, sym)) = p
p
}
@@ -99,7 +99,7 @@ private[remote] class NetKernel(service: Service) {
proxies.synchronized {
proxies.get((senderNode, senderName)) match {
case Some(senderProxy) => // do nothing
- case None => proxies += Pair((senderNode, senderName), p)
+ case None => proxies((senderNode, senderName)) = p
}
}
diff --git a/src/actors/scala/actors/remote/Proxy.scala b/src/actors/scala/actors/remote/Proxy.scala
index 43a43ac99c..9949b36181 100644
--- a/src/actors/scala/actors/remote/Proxy.scala
+++ b/src/actors/scala/actors/remote/Proxy.scala
@@ -142,7 +142,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create a new reply channel...
val replyCh = new Channel[Any](this)
// ...that maps to session
- sessionMap += Pair(replyCh, session)
+ sessionMap(replyCh) = session
// local send
out.send(msg, replyCh)
@@ -178,7 +178,7 @@ private[remote] class DelegateActor(creator: Proxy, node: Node, name: Symbol, ke
// create fresh session ID...
val fresh = FreshNameCreator.newName(node+"@"+name)
// ...that maps to reply channel
- channelMap += Pair(fresh, sender)
+ channelMap(fresh) = sender
kernel.forward(sender, node, name, msg, fresh)
} else {
kernel.forward(sender, node, name, msg, 'nosession)
diff --git a/src/actors/scala/actors/remote/RemoteActor.scala b/src/actors/scala/actors/remote/RemoteActor.scala
index 799076a01f..2daf9ceb43 100644
--- a/src/actors/scala/actors/remote/RemoteActor.scala
+++ b/src/actors/scala/actors/remote/RemoteActor.scala
@@ -64,7 +64,7 @@ object RemoteActor {
val serv = TcpService(port, cl)
val kern = serv.kernel
val s = Actor.self(Scheduler)
- kernels += Pair(s, kern)
+ kernels(s) = kern
s.onTerminate {
Debug.info("alive actor "+s+" terminated")
@@ -90,7 +90,7 @@ object RemoteActor {
val kernel = kernels.get(Actor.self(Scheduler)) match {
case None =>
val serv = TcpService(TcpService.generatePort, cl)
- kernels += Pair(Actor.self(Scheduler), serv.kernel)
+ kernels(Actor.self(Scheduler)) = serv.kernel
serv.kernel
case Some(k) =>
k
diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala
index 75e36b2738..69e5c46c52 100644
--- a/src/actors/scala/actors/remote/TcpService.scala
+++ b/src/actors/scala/actors/remote/TcpService.scala
@@ -35,7 +35,7 @@ object TcpService {
service
case None =>
val service = new TcpService(port, cl)
- ports += Pair(port, service)
+ ports(port) = service
service.start()
Debug.info("created service at "+service.node)
service
@@ -106,9 +106,9 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
// when remote net kernel comes up
(pendingSends.get(node): @unchecked) match {
case None =>
- pendingSends += Pair(node, List(data))
+ pendingSends(node) = List(data)
case Some(msgs) if msgs.length < TcpService.BufSize =>
- pendingSends += Pair(node, data :: msgs)
+ pendingSends(node) = data :: msgs
}
}
@@ -183,7 +183,7 @@ class TcpService(port: Int, cl: ClassLoader) extends Thread with Service {
new mutable.HashMap[Node, TcpServiceWorker]
private[actors] def addConnection(node: Node, worker: TcpServiceWorker) = synchronized {
- connections += Pair(node, worker)
+ connections(node) = worker
}
def getConnection(n: Node) = synchronized {
diff --git a/src/build/bnd/scala-compiler-doc.bnd b/src/build/bnd/scala-compiler-doc.bnd
new file mode 100644
index 0000000000..4910e5fcb0
--- /dev/null
+++ b/src/build/bnd/scala-compiler-doc.bnd
@@ -0,0 +1,6 @@
+Bundle-Name: Scala Documentation Generator
+Bundle-SymbolicName: org.scala-lang.modules.scala-compiler-doc_@SCALA_BINARY_VERSION@
+ver: @SCALA_COMPILER_DOC_VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
+Import-Package: *
diff --git a/src/build/bnd/scala-compiler-interactive.bnd b/src/build/bnd/scala-compiler-interactive.bnd
new file mode 100644
index 0000000000..34d2f2956d
--- /dev/null
+++ b/src/build/bnd/scala-compiler-interactive.bnd
@@ -0,0 +1,6 @@
+Bundle-Name: Scala Interactive Compiler
+Bundle-SymbolicName: org.scala-lang.modules.scala-compiler-interactive_@SCALA_BINARY_VERSION@
+ver: @SCALA_COMPILER_INTERACTIVE_VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
+Import-Package: *
diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml
index 7cff0b457e..822cc1a25f 100644
--- a/src/build/maven/maven-deploy.xml
+++ b/src/build/maven/maven-deploy.xml
@@ -59,13 +59,18 @@
<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="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="RELEASE_REPOSITORY" value="${remote.release.repository}" />
- <filter token="SNAPSHOT_REPOSITORY" value="${remote.snapshot.repository}" />
- <filter token="JLINE_VERSION" value="${jline.version}" />
+ <filter token="RELEASE_REPOSITORY" value="${remote.release.repository}" />
+ <filter token="SNAPSHOT_REPOSITORY" value="${remote.snapshot.repository}" />
+ <filter token="JLINE_VERSION" value="${jline.version}" />
+
+ <!-- TODO modularize compiler.
+ <filter token="SCALA_COMPILER_DOC_VERSION" value="${scala-compiler-doc.version.number}" />
+ <filter token="SCALA_COMPILER_INTERACTIVE_VERSION" value="${scala-compiler-interactive.version.number}" />
+ -->
</filterset>
</copy>
<artifact:pom id="@{name}.pom" file="${path}-pom-filtered.xml" />
@@ -112,6 +117,12 @@
<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}"/>
+
+ <!-- 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 dir="@{dir}" name="scala-actors" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scala-swing" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scalap" local="@{local}" signed="@{signed}"/>
diff --git a/src/build/maven/scala-compiler-doc-pom.xml b/src/build/maven/scala-compiler-doc-pom.xml
new file mode 100644
index 0000000000..30161d2fea
--- /dev/null
+++ b/src/build/maven/scala-compiler-doc-pom.xml
@@ -0,0 +1,69 @@
+<?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.modules</groupId>
+ <artifactId>scala-compiler-doc_@SCALA_BINARY_VERSION@</artifactId>
+ <packaging>jar</packaging>
+ <version>@SCALA_COMPILER_DOC_VERSION@</version>
+ <name>Scala Documentation Generator</name>
+ <description>Documentation generator for the Scala Programming Language</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-compiler</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>
+ </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-compiler-interactive-pom.xml b/src/build/maven/scala-compiler-interactive-pom.xml
new file mode 100644
index 0000000000..d59f305a9f
--- /dev/null
+++ b/src/build/maven/scala-compiler-interactive-pom.xml
@@ -0,0 +1,59 @@
+<?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.modules</groupId>
+ <artifactId>scala-compiler-interactive_@SCALA_BINARY_VERSION@</artifactId>
+ <packaging>jar</packaging>
+ <version>@SCALA_COMPILER_INTERACTIVE_VERSION@</version>
+ <name>Scala Interactive Compiler</name>
+ <description>Interactive Compiler for the Scala Programming Language</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-compiler</artifactId>
+ <version>@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-compiler-pom.xml b/src/build/maven/scala-compiler-pom.xml
index 442fe6a8d5..a16fe22343 100644
--- a/src/build/maven/scala-compiler-pom.xml
+++ b/src/build/maven/scala-compiler-pom.xml
@@ -35,23 +35,22 @@
<version>@VERSION@</version>
</dependency>
<dependency>
- <!-- for scaladoc -->
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-reflect</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <!-- TODO modularize compiler: these dependencies will disappear then the compiler is modularized -->
+ <dependency> <!-- for scala-compiler-doc -->
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-xml_@SCALA_BINARY_VERSION@</artifactId>
<version>@XML_VERSION@</version>
</dependency>
- <dependency>
- <!-- for scaladoc -->
+ <dependency> <!-- for scala-compiler-doc -->
<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</groupId>
- <artifactId>scala-reflect</artifactId>
- <version>@VERSION@</version>
- </dependency>
- <dependency>
+ <dependency> <!-- for scala-compiler-repl-->
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>@JLINE_VERSION@</version>
diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala
index 30ba082a81..9799428b40 100644
--- a/src/compiler/scala/reflect/macros/compiler/Errors.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala
@@ -33,7 +33,7 @@ trait Errors extends Traces {
def MacroBundleNonStaticError() = implRefError("macro bundles must be static")
- def MacroBundleWrongShapeError() = implRefError("macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member")
+ def MacroBundleWrongShapeError() = implRefError("macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member")
// compatibility errors
diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
index 9c4db1990b..e4851632a5 100644
--- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
@@ -9,16 +9,12 @@ trait Resolvers {
import global._
import analyzer._
- import definitions.{EmptyPackageClass => _, _}
+ import definitions._
import treeInfo._
import gen._
private val runDefinitions = currentRun.runDefinitions
import runDefinitions.{Predef_???, _}
- /** Determines the type of context implied by the macro def.
- */
- val ctxTpe = MacroContextClass.tpe
-
/** Resolves a macro impl reference provided in the right-hand side of the given macro definition.
*
* Acceptable shapes of the right-hand side:
@@ -44,14 +40,14 @@ trait Resolvers {
}
val untypedImplRef = typer.silent(_.typedTypeConstructor(maybeBundleRef)) match {
- case SilentResultValue(result) if result.tpe.baseClasses.contains(MacroClass) =>
+ 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: Context) extends Foo` in a package next to `Foo`
+ // 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('$')
@@ -59,7 +55,8 @@ trait Resolvers {
val bundleName = TypeName(bundlePrefix + tpnme.MACRO_BUNDLE_SUFFIX)
val existingBundle = bundleProto.enclosingPackageClass.info.decl(bundleName)
if (!currentRun.compiles(existingBundle)) {
- def mkContextValDef(flags: Long) = ValDef(Modifiers(flags), nme.c, TypeTree(ctxTpe), EmptyTree)
+ 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(()))))
@@ -88,12 +85,13 @@ trait Resolvers {
// lazy val (isImplBundle, macroImplOwner, macroImpl, macroImplTargs) =
private lazy val dissectedMacroImplRef =
macroImplRef match {
- case MacroImplReference(isBundle, owner, meth, targs) => (isBundle, owner, meth, targs)
+ case MacroImplReference(isBundle, isBlackbox, owner, meth, targs) => (isBundle, isBlackbox, owner, meth, targs)
case _ => MacroImplReferenceWrongShapeError()
}
lazy val isImplBundle = dissectedMacroImplRef._1
lazy val isImplMethod = !isImplBundle
- lazy val macroImplOwner = dissectedMacroImplRef._2
- lazy val macroImpl = dissectedMacroImplRef._3
- lazy val targs = dissectedMacroImplRef._4
+ lazy val isImplBlackbox = dissectedMacroImplRef._2
+ lazy val macroImplOwner = dissectedMacroImplRef._3
+ lazy val macroImpl = dissectedMacroImplRef._4
+ lazy val targs = dissectedMacroImplRef._5
}
diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala
index 088b108844..e77c129c51 100644
--- a/src/compiler/scala/reflect/macros/compiler/Validators.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala
@@ -49,8 +49,8 @@ trait Validators {
map2(aparamss.flatten, rparamss.flatten)((aparam, rparam) => {
if (aparam.name != rparam.name && !rparam.isSynthetic) MacroImplParamNameMismatchError(aparam, rparam)
if (isRepeated(aparam) ^ isRepeated(rparam)) MacroImplVarargMismatchError(aparam, rparam)
- val aparamtpe = aparam.tpe.dealias match {
- case RefinedType(List(tpe), Scope(sym)) if tpe =:= ctxTpe && sym.allOverriddenSymbols.contains(MacroContextPrefixType) => tpe
+ val aparamtpe = aparam.tpe match {
+ case MacroContextType(tpe) => tpe
case tpe => tpe
}
checkMacroImplParamTypeMismatch(atpeToRtpe(aparamtpe), rparam)
@@ -93,20 +93,20 @@ trait Validators {
*
* For the following macro impl:
* def fooBar[T: c.WeakTypeTag]
- * (c: scala.reflect.macros.Context)
+ * (c: scala.reflect.macros.BlackboxContext)
* (xs: c.Expr[List[T]])
* : c.Expr[T] = ...
*
* This function will return:
- * (c: scala.reflect.macros.Context)(xs: c.Expr[List[T]])c.Expr[T]
+ * (c: scala.reflect.macros.BlackboxContext)(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 Macro-compatible object,
- * then it won't have (c: Context) in its parameters, but will rather refer to Macro.c.
+ * 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.
*
* @param macroImpl The macro implementation symbol
*/
@@ -123,7 +123,8 @@ trait Validators {
* def foo[T](xs: List[T]): T = macro fooBar
*
* This function will return:
- * (c: scala.reflect.macros.Context)(xs: c.Expr[List[T]])c.Expr[T]
+ * (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]
*
* Note that type tag evidence parameters are not included into the result.
* Type tag context bounds for macro impl tparams are optional.
@@ -145,6 +146,7 @@ trait Validators {
// had to move method's body to an object because of the recursive dependencies between sigma and param
object SigGenerator {
val cache = scala.collection.mutable.Map[Symbol, Symbol]()
+ val ctxTpe = if (isImplBlackbox) BlackboxContextClass.tpe else WhiteboxContextClass.tpe
val ctxPrefix =
if (isImplMethod) singleType(NoPrefix, makeParam(nme.macroContext, macroDdef.pos, ctxTpe, SYNTHETIC))
else singleType(ThisType(macroImpl.owner), macroImpl.owner.tpe.member(nme.c))
diff --git a/src/compiler/scala/reflect/macros/contexts/Context.scala b/src/compiler/scala/reflect/macros/contexts/Context.scala
index 1355a839d9..7b79b52a18 100644
--- a/src/compiler/scala/reflect/macros/contexts/Context.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Context.scala
@@ -3,7 +3,8 @@ package contexts
import scala.tools.nsc.Global
-abstract class Context extends scala.reflect.macros.Context
+abstract class Context extends scala.reflect.macros.BlackboxContext
+ with scala.reflect.macros.WhiteboxContext
with Aliases
with Enclosures
with Names
diff --git a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
index ffdbe11151..7de3341304 100644
--- a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
+++ b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala
@@ -45,7 +45,7 @@ trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes
type MacroRuntime = MacroArgs => Any
class MacroRuntimeResolver(val macroDef: Symbol) extends JavaReflectionResolvers
with ScalaReflectionResolvers {
- val binding = loadMacroImplBinding(macroDef)
+ val binding = loadMacroImplBinding(macroDef).get
val isBundle = binding.isBundle
val className = binding.className
val methName = binding.methName
diff --git a/src/compiler/scala/reflect/macros/util/Helpers.scala b/src/compiler/scala/reflect/macros/util/Helpers.scala
index bb4f2055ad..ff03696524 100644
--- a/src/compiler/scala/reflect/macros/util/Helpers.scala
+++ b/src/compiler/scala/reflect/macros/util/Helpers.scala
@@ -27,13 +27,13 @@ trait Helpers {
import runDefinitions._
val MacroContextUniverse = definitions.MacroContextUniverse
- val treeInfo.MacroImplReference(isBundle, _, macroImpl, _) = macroImplRef
+ val treeInfo.MacroImplReference(isBundle, _, _, macroImpl, _) = macroImplRef
val paramss = macroImpl.paramss
val ContextParam = paramss match {
- case Nil | _ :+ Nil => NoSymbol // no implicit parameters in the signature => nothing to do
- case _ if isBundle => macroImpl.owner.tpe member nme.c
- case (cparam :: _) :: _ if cparam.tpe <:< MacroContextClass.tpe => cparam
- case _ => NoSymbol // no context parameter in the signature => nothing to do
+ case Nil | _ :+ Nil => NoSymbol // no implicit parameters in the signature => nothing to do
+ case _ if isBundle => macroImpl.owner.tpe member nme.c
+ case (cparam :: _) :: _ if isMacroContextType(cparam.tpe) => cparam
+ case _ => NoSymbol // no context parameter in the signature => nothing to do
}
def transformTag(param: Symbol): Symbol = param.tpe.dealias match {
case TypeRef(SingleType(SingleType(_, ContextParam), MacroContextUniverse), WeakTypeTagClass, targ :: Nil) => transform(param, targ.typeSymbol)
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala
index e7ac53c8fb..bb6a933d3f 100644
--- a/src/compiler/scala/tools/ant/ScalaTool.scala
+++ b/src/compiler/scala/tools/ant/ScalaTool.scala
@@ -139,7 +139,7 @@ class ScalaTool extends ScalaMatchingTask {
val st = s.trim
val stArray = st.split("=", 2)
if (stArray.length == 2) {
- if (input != "") List(Pair(stArray(0), stArray(1))) else Nil
+ if (input != "") List((stArray(0), stArray(1))) else Nil
}
else
buildError("Property " + st + " is not formatted properly.")
@@ -170,7 +170,7 @@ class ScalaTool extends ScalaMatchingTask {
private def getProperties: String =
properties.map({
- case Pair(name,value) => "-D" + name + "=\"" + value + "\""
+ case (name,value) => "-D" + name + "=\"" + value + "\""
}).mkString("", " ", "")
/*============================================================================*\
diff --git a/src/compiler/scala/tools/ant/sabbus/Compilers.scala b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
index b1994233e8..a0aad49f20 100644
--- a/src/compiler/scala/tools/ant/sabbus/Compilers.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Compilers.scala
@@ -27,7 +27,7 @@ object Compilers extends scala.collection.DefaultMap[String, Compiler] {
if (debug) println("Making compiler " + id)
if (debug) println(" memory before: " + freeMemoryString)
val comp = new Compiler(classpath, settings)
- container += Pair(id, comp)
+ container(id) = comp
if (debug) println(" memory after: " + freeMemoryString)
comp
}
diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
index 1288eb0b7c..8441f3af23 100644
--- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl
@@ -12,15 +12,18 @@ setlocal enableextensions enabledelayedexpansion
set _LINE_TOOLCP=
-:another_param
-
rem Use "%~1" to handle spaces in paths. See http://ss64.com/nt/syntax-args.html
-if "%~1"=="-toolcp" (
- set _LINE_TOOLCP=%~2
- shift
- shift
- goto another_param
+rem SI-7295 The goto here is needed to avoid problems with `scala Script.cmd "arg(with)paren"`,
+rem we must not evaluate %~2 eagerly, but delayed expansion doesn't seem to allow
+rem removal of quotation marks.
+if not [%~1]==[-toolcp] (
+ goto :notoolcp
)
+shift
+set _LINE_TOOLCP=%~1
+shift
+
+:notoolcp
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
set _JAVA_PARAMS=
diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala
index 0020528c5b..6dda30b5e7 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala
@@ -137,7 +137,7 @@ trait TreeDSL {
def IF(tree: Tree) = new IfStart(tree, EmptyTree)
def TRY(tree: Tree) = new TryStart(tree, Nil, EmptyTree)
def BLOCK(xs: Tree*) = Block(xs.init.toList, xs.last)
- def SOME(xs: Tree*) = Apply(SomeClass.companionSymbol, treeBuilder.makeTupleTerm(xs.toList, flattenUnary = true))
+ def SOME(xs: Tree*) = Apply(SomeClass.companionSymbol, gen.mkTuple(xs.toList))
/** Typed trees from symbols. */
def REF(sym: Symbol) = gen.mkAttributedRef(sym)
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 28b127698f..4ac6672727 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -53,13 +53,6 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
NewFromConstructor(constructor, expr)
}
- // annotate the expression with @unchecked
- def mkUnchecked(expr: Tree): Tree = atPos(expr.pos) {
- // This can't be "Annotated(New(UncheckedClass), expr)" because annotations
- // are very picky about things and it crashes the compiler with "unexpected new".
- Annotated(New(scalaDot(UncheckedClass.name), Nil), expr)
- }
-
// Builds a tree of the form "{ lhs = rhs ; lhs }"
def mkAssignAndReturn(lhs: Symbol, rhs: Tree): Tree = {
def lhsRef = if (lhs.owner.isClass) Select(This(lhs.owner), lhs) else Ident(lhs)
@@ -264,6 +257,43 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
mkNew(Nil, noSelfType, stats1, NoPosition, NoPosition)
}
- def mkSyntheticParam(pname: TermName) =
- ValDef(Modifiers(PARAM | SYNTHETIC), pname, TypeTree(), EmptyTree)
+ /**
+ * Create a method based on a Function
+ *
+ * Used both to under `-Ydelambdafy:method` create a lifted function and
+ * under `-Ydelamdafy:inline` to create the apply method on the anonymous
+ * class.
+ *
+ * It creates a method definition with value params cloned from the
+ * original lambda. Then it calls a supplied function to create
+ * the body and types the result. Finally
+ * everything is wrapped up in a DefDef
+ *
+ * @param owner The owner for the new method
+ * @param name name for the new method
+ * @param additionalFlags flags to be put on the method in addition to FINAL
+ */
+ def mkMethodFromFunction(localTyper: analyzer.Typer)
+ (fun: Function, owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags) = {
+ val funParams = fun.vparams map (_.symbol)
+ val formals :+ restpe = fun.tpe.typeArgs
+
+ val methSym = owner.newMethod(name, fun.pos, FINAL | additionalFlags)
+
+ val paramSyms = map2(formals, fun.vparams) {
+ (tp, vparam) => methSym.newSyntheticValueParam(tp, vparam.name)
+ }
+
+ methSym setInfo MethodType(paramSyms, restpe.deconst)
+
+ fun.body.substituteSymbols(funParams, paramSyms)
+ fun.body changeOwner (fun.symbol -> methSym)
+
+ val methDef = DefDef(methSym, fun.body)
+
+ // Have to repack the type to avoid mismatches when existentials
+ // appear in the result - see SI-4869.
+ methDef.tpt setType localTyper.packedType(fun.body, methSym).deconst
+ methDef
+ }
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index cfa60cabc3..0429e295b4 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -861,7 +861,7 @@ self =>
atPos(start, in.skipToken()) { makeFunctionTypeTree(ts, typ()) }
else {
ts foreach checkNotByNameOrVarargs
- val tuple = atPos(start) { makeTupleType(ts, flattenUnary = true) }
+ val tuple = atPos(start) { makeTupleType(ts) }
infixTypeRest(
compoundTypeRest(
annotTypeRest(
@@ -923,7 +923,7 @@ self =>
def simpleType(): Tree = {
val start = in.offset
simpleTypeRest(in.token match {
- case LPAREN => atPos(start)(makeTupleType(inParens(types()), flattenUnary = true))
+ case LPAREN => atPos(start)(makeTupleType(inParens(types())))
case USCORE => wildcardType(in.skipToken())
case _ =>
path(thisOK = false, typeOK = true) match {
@@ -1394,9 +1394,9 @@ self =>
newLinesOpt()
if (in.token == YIELD) {
in.nextToken()
- makeForYield(enums, expr())
+ gen.mkFor(enums, gen.Yield(expr()))
} else {
- makeFor(enums, expr())
+ gen.mkFor(enums, expr())
}
}
def adjustStart(tree: Tree) =
@@ -1700,22 +1700,25 @@ self =>
* | val Pattern1 `=' Expr
* }}}
*/
- def enumerators(): List[Enumerator] = {
- val enums = new ListBuffer[Enumerator]
- generator(enums, eqOK = false)
+ def enumerators(): List[Tree] = {
+ val enums = new ListBuffer[Tree]
+ enums ++= enumerator(isFirst = true)
while (isStatSep) {
in.nextToken()
- if (in.token == IF) enums += makeFilter(in.offset, guard())
- else generator(enums, eqOK = true)
+ enums ++= enumerator(isFirst = false)
}
enums.toList
}
+ def enumerator(isFirst: Boolean, allowNestedIf: Boolean = true): List[Tree] =
+ if (in.token == IF && !isFirst) makeFilter(in.offset, guard()) :: Nil
+ else generator(!isFirst, allowNestedIf)
+
/** {{{
* Generator ::= Pattern1 (`<-' | `=') Expr [Guard]
* }}}
*/
- def generator(enums: ListBuffer[Enumerator], eqOK: Boolean) {
+ def generator(eqOK: Boolean, allowNestedIf: Boolean = true): List[Tree] = {
val start = in.offset
val hasVal = in.token == VAL
if (hasVal)
@@ -1733,13 +1736,22 @@ self =>
if (hasEq && eqOK) in.nextToken()
else accept(LARROW)
val rhs = expr()
- enums += makeGenerator(r2p(start, point, in.lastOffset max start), pat, hasEq, rhs)
- // why max above? IDE stress tests have shown that lastOffset could be less than start,
+
+ def loop(): List[Tree] =
+ if (in.token != IF) Nil
+ else makeFilter(in.offset, guard()) :: loop()
+
+ val tail =
+ if (allowNestedIf) loop()
+ else Nil
+
+ // why max? IDE stress tests have shown that lastOffset could be less than start,
// I guess this happens if instead if a for-expression we sit on a closing paren.
- while (in.token == IF) enums += makeFilter(in.offset, guard())
+ val genPos = r2p(start, point, in.lastOffset max start)
+ gen.mkGenerator(genPos, pat, hasEq, rhs) :: tail
}
- def makeFilter(start: Offset, tree: Tree) = Filter(r2p(start, tree.pos.point, tree.pos.end), tree)
+ def makeFilter(start: Offset, tree: Tree) = gen.Filter(tree).setPos(r2p(start, tree.pos.point, tree.pos.end))
/* -------- PATTERNS ------------------------------------------- */
@@ -1762,10 +1774,12 @@ self =>
in.nextToken()
if (in.token == SUBTYPE || in.token == SUPERTYPE) wildcardType(start)
else atPos(start) { Bind(tpnme.WILDCARD, EmptyTree) }
- case IDENTIFIER if nme.isVariableName(in.name) =>
- atPos(start) { Bind(identForType(), EmptyTree) }
case _ =>
- typ()
+ typ() match {
+ case Ident(name: TypeName) if nme.isVariableName(name) =>
+ atPos(start) { Bind(name, EmptyTree) }
+ case t => t
+ }
}
}
@@ -2454,11 +2468,10 @@ self =>
EmptyTree
}
def mkDefs(p: Tree, tp: Tree, rhs: Tree): List[Tree] = {
- val trees =
- makePatDef(newmods,
- if (tp.isEmpty) p
- else Typed(p, tp) setPos (p.pos union tp.pos),
- rhs)
+ val trees = {
+ val pat = if (tp.isEmpty) p else Typed(p, tp) setPos (p.pos union tp.pos)
+ gen.mkPatDef(newmods, pat, rhs)
+ }
if (newmods.isDeferred) {
trees match {
case List(ValDef(_, _, _, EmptyTree)) =>
@@ -2519,11 +2532,7 @@ self =>
val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
val rhs = in.token match {
- case LBRACE => {
- if (settings.future)
- deprecationWarning(in.offset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.")
- atPos(in.offset) { constrBlock(vparamss) }
- }
+ case LBRACE => atPos(in.offset) { constrBlock(vparamss) }
case _ => accept(EQUALS) ; atPos(in.offset) { constrExpr(vparamss) }
}
DefDef(mods, nme.CONSTRUCTOR, List(), vparamss, TypeTree(), rhs)
@@ -2549,14 +2558,16 @@ self =>
var restype = fromWithinReturnType(typedOpt())
val rhs =
if (isStatSep || in.token == RBRACE) {
- if (settings.future)
- deprecationWarning(in.lastOffset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit`.")
- if (restype.isEmpty) restype = scalaUnitConstr
+ if (restype.isEmpty) {
+ if (settings.future)
+ deprecationWarning(in.lastOffset, s"Procedure syntax is deprecated. Convert procedure `$name` to method by adding `: Unit`.")
+ restype = scalaUnitConstr
+ }
newmods |= Flags.DEFERRED
EmptyTree
} else if (restype.isEmpty && in.token == LBRACE) {
if (settings.future)
- deprecationWarning(in.offset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.")
+ deprecationWarning(in.offset, s"Procedure syntax is deprecated. Convert procedure `$name` to method by adding `: Unit =`.")
restype = scalaUnitConstr
blockExpr()
} else {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 28d5aefc2b..d88470bd5e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -31,88 +31,6 @@ abstract class TreeBuilder {
def convertToTypeName(t: Tree) = gen.convertToTypeName(t)
- /** Convert all occurrences of (lower-case) variables in a pattern as follows:
- * x becomes x @ _
- * x: T becomes x @ (_: T)
- */
- object patvarTransformer extends Transformer {
- override def transform(tree: Tree): Tree = tree match {
- case Ident(name) if (treeInfo.isVarPattern(tree) && name != nme.WILDCARD) =>
- atPos(tree.pos)(Bind(name, atPos(tree.pos.focus) (Ident(nme.WILDCARD))))
- case Typed(id @ Ident(name), tpt) if (treeInfo.isVarPattern(id) && name != nme.WILDCARD) =>
- atPos(tree.pos.withPoint(id.pos.point)) {
- Bind(name, atPos(tree.pos.withStart(tree.pos.point)) {
- Typed(Ident(nme.WILDCARD), tpt)
- })
- }
- case Apply(fn @ Apply(_, _), args) =>
- treeCopy.Apply(tree, transform(fn), transformTrees(args))
- case Apply(fn, args) =>
- treeCopy.Apply(tree, fn, transformTrees(args))
- case Typed(expr, tpt) =>
- treeCopy.Typed(tree, transform(expr), tpt)
- case Bind(name, body) =>
- treeCopy.Bind(tree, name, transform(body))
- case Alternative(_) | Star(_) =>
- super.transform(tree)
- case _ =>
- tree
- }
- }
-
- /** Traverse pattern and collect all variable names with their types in buffer
- * The variables keep their positions; whereas the pattern is converted to be
- * synthetic for all nodes that contain a variable position.
- */
- class GetVarTraverser extends Traverser {
- val buf = new ListBuffer[(Name, Tree, Position)]
-
- def namePos(tree: Tree, name: Name): Position =
- if (!tree.pos.isRange || name.containsName(nme.raw.DOLLAR)) tree.pos.focus
- else {
- val start = tree.pos.start
- val end = start + name.decode.length
- r2p(start, start, end)
- }
-
- override def traverse(tree: Tree): Unit = {
- def seenName(name: Name) = buf exists (_._1 == name)
- def add(name: Name, t: Tree) = if (!seenName(name)) buf += ((name, t, namePos(tree, name)))
- val bl = buf.length
-
- tree match {
- case Bind(nme.WILDCARD, _) =>
- super.traverse(tree)
-
- case Bind(name, Typed(tree1, tpt)) =>
- val newTree = if (treeInfo.mayBeTypePat(tpt)) TypeTree() else tpt.duplicate
- add(name, newTree)
- traverse(tree1)
-
- case Bind(name, tree1) =>
- // can assume only name range as position, as otherwise might overlap
- // with binds embedded in pattern tree1
- add(name, TypeTree())
- traverse(tree1)
-
- case _ =>
- super.traverse(tree)
- }
- if (buf.length > bl)
- tree setPos tree.pos.makeTransparent
- }
- def apply(tree: Tree) = {
- traverse(tree)
- buf.toList
- }
- }
-
- /** Returns list of all pattern variables, possibly with their types,
- * without duplicates
- */
- private def getVariables(tree: Tree): List[(Name, Tree, Position)] =
- new GetVarTraverser apply tree
-
def byNameApplication(tpe: Tree): Tree =
AppliedTypeTree(rootScalaDot(tpnme.BYNAME_PARAM_CLASS_NAME), List(tpe))
def repeatedApplication(tpe: Tree): Tree =
@@ -121,25 +39,12 @@ abstract class TreeBuilder {
def makeImportSelector(name: Name, nameOffset: Int): ImportSelector =
ImportSelector(name, nameOffset, name, nameOffset)
- private def makeTuple(trees: List[Tree], isType: Boolean): Tree = {
- val tupString = "Tuple" + trees.length
- Apply(scalaDot(if (isType) newTypeName(tupString) else newTermName(tupString)), trees)
- }
-
- def makeTupleTerm(trees: List[Tree], flattenUnary: Boolean): Tree = trees match {
- case Nil => Literal(Constant(()))
- case List(tree) if flattenUnary => tree
- case _ => makeTuple(trees, isType = false)
- }
+ def makeTupleTerm(elems: List[Tree]) = gen.mkTuple(elems)
- def makeTupleType(trees: List[Tree], flattenUnary: Boolean): Tree = trees match {
- case Nil => scalaUnitConstr
- case List(tree) if flattenUnary => tree
- case _ => AppliedTypeTree(scalaDot(newTypeName("Tuple" + trees.length)), trees)
- }
+ def makeTupleType(elems: List[Tree]) = gen.mkTupleType(elems)
def stripParens(t: Tree) = t match {
- case Parens(ts) => atPos(t.pos) { makeTupleTerm(ts, flattenUnary = true) }
+ case Parens(ts) => atPos(t.pos) { makeTupleTerm(ts) }
case _ => t
}
@@ -149,22 +54,6 @@ abstract class TreeBuilder {
def makeSelfDef(name: TermName, tpt: Tree): ValDef =
ValDef(Modifiers(PRIVATE), name, tpt, EmptyTree)
- /** If tree is a variable pattern, return Some("its name and type").
- * Otherwise return none */
- private def matchVarPattern(tree: Tree): Option[(Name, Tree)] = {
- def wildType(t: Tree): Option[Tree] = t match {
- case Ident(x) if x.toTermName == nme.WILDCARD => Some(TypeTree())
- case Typed(Ident(x), tpt) if x.toTermName == nme.WILDCARD => Some(tpt)
- case _ => None
- }
- tree match {
- case Ident(name) => Some((name, TypeTree()))
- case Bind(name, body) => wildType(body) map (x => (name, x))
- case Typed(Ident(name), tpt) => Some((name, tpt))
- case _ => None
- }
- }
-
/** Create tree representing (unencoded) binary operation expression or pattern. */
def makeBinop(isExpr: Boolean, left: Tree, op: TermName, right: Tree, opPos: Position): Tree = {
def mkNamed(args: List[Tree]) = if (isExpr) args map treeInfo.assignmentToMaybeNamedArg else args
@@ -214,173 +103,12 @@ abstract class TreeBuilder {
/** Create block of statements `stats` */
def makeBlock(stats: List[Tree]): Tree = gen.mkBlock(stats)
- def makeFilter(tree: Tree, condition: Tree, scrutineeName: String): Tree = {
- val cases = List(
- CaseDef(condition, EmptyTree, Literal(Constant(true))),
- CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(Constant(false)))
- )
- val matchTree = makeVisitor(cases, checkExhaustive = false, scrutineeName)
-
- atPos(tree.pos)(Apply(Select(tree, nme.withFilter), matchTree :: Nil))
- }
-
- /** Create tree for for-comprehension generator <val pat0 <- rhs0> */
- def makeGenerator(pos: Position, pat: Tree, valeq: Boolean, rhs: Tree): Enumerator = {
- val pat1 = patvarTransformer.transform(pat)
- val rhs1 =
- if (valeq || treeInfo.isVarPatternDeep(pat)) rhs
- else makeFilter(rhs, pat1.duplicate, nme.CHECK_IF_REFUTABLE_STRING)
-
- if (valeq) ValEq(pos, pat1, rhs1)
- else ValFrom(pos, pat1, rhs1)
- }
-
def makeParam(pname: TermName, tpe: Tree) =
ValDef(Modifiers(PARAM), pname, tpe, EmptyTree)
def makeSyntheticTypeParam(pname: TypeName, bounds: Tree) =
TypeDef(Modifiers(DEFERRED | SYNTHETIC), pname, Nil, bounds)
- abstract class Enumerator { def pos: Position }
- case class ValFrom(pos: Position, pat: Tree, rhs: Tree) extends Enumerator
- case class ValEq(pos: Position, pat: Tree, rhs: Tree) extends Enumerator
- case class Filter(pos: Position, test: Tree) extends Enumerator
-
- /** Create tree for for-comprehension <for (enums) do body> or
- * <for (enums) yield body> where mapName and flatMapName are chosen
- * corresponding to whether this is a for-do or a for-yield.
- * The creation performs the following rewrite rules:
- *
- * 1.
- *
- * for (P <- G) E ==> G.foreach (P => E)
- *
- * Here and in the following (P => E) is interpreted as the function (P => E)
- * if P is a variable pattern and as the partial function { case P => E } otherwise.
- *
- * 2.
- *
- * for (P <- G) yield E ==> G.map (P => E)
- *
- * 3.
- *
- * for (P_1 <- G_1; P_2 <- G_2; ...) ...
- * ==>
- * G_1.flatMap (P_1 => for (P_2 <- G_2; ...) ...)
- *
- * 4.
- *
- * for (P <- G; E; ...) ...
- * =>
- * for (P <- G.filter (P => E); ...) ...
- *
- * 5. For N < MaxTupleArity:
- *
- * for (P_1 <- G; P_2 = E_2; val P_N = E_N; ...)
- * ==>
- * for (TupleN(P_1, P_2, ... P_N) <-
- * for (x_1 @ P_1 <- G) yield {
- * val x_2 @ P_2 = E_2
- * ...
- * val x_N & P_N = E_N
- * TupleN(x_1, ..., x_N)
- * } ...)
- *
- * If any of the P_i are variable patterns, the corresponding `x_i @ P_i' is not generated
- * and the variable constituting P_i is used instead of x_i
- *
- * @param mapName The name to be used for maps (either map or foreach)
- * @param flatMapName The name to be used for flatMaps (either flatMap or foreach)
- * @param enums The enumerators in the for expression
- * @param body The body of the for expression
- */
- private def makeFor(mapName: TermName, flatMapName: TermName, enums: List[Enumerator], body: Tree): Tree = {
-
- /* make a closure pat => body.
- * The closure is assigned a transparent position with the point at pos.point and
- * the limits given by pat and body.
- */
- def makeClosure(pos: Position, pat: Tree, body: Tree): Tree = {
- def splitpos = wrappingPos(List(pat, body)).withPoint(pos.point).makeTransparent
- matchVarPattern(pat) match {
- case Some((name, tpt)) =>
- Function(
- List(atPos(pat.pos) { ValDef(Modifiers(PARAM), name.toTermName, tpt, EmptyTree) }),
- body) setPos splitpos
- case None =>
- atPos(splitpos) {
- makeVisitor(List(CaseDef(pat, EmptyTree, body)), checkExhaustive = false)
- }
- }
- }
-
- /* Make an application qual.meth(pat => body) positioned at `pos`.
- */
- def makeCombination(pos: Position, meth: TermName, qual: Tree, pat: Tree, body: Tree): Tree =
- Apply(Select(qual, meth) setPos qual.pos, List(makeClosure(pos, pat, body))) setPos pos
-
- /* If `pat` is not yet a `Bind` wrap it in one with a fresh name */
- def makeBind(pat: Tree): Tree = pat match {
- case Bind(_, _) => pat
- case _ => Bind(freshTermName(), pat) setPos pat.pos
- }
-
- /* A reference to the name bound in Bind `pat`. */
- def makeValue(pat: Tree): Tree = pat match {
- case Bind(name, _) => Ident(name) setPos pat.pos.focus
- }
-
- /* The position of the closure that starts with generator at position `genpos`. */
- def closurePos(genpos: Position) = {
- val end = body.pos match {
- case NoPosition => genpos.point
- case bodypos => bodypos.end
- }
- r2p(genpos.start, genpos.point, end)
- }
-
-// val result =
- enums match {
- case ValFrom(pos, pat, rhs) :: Nil =>
- makeCombination(closurePos(pos), mapName, rhs, pat, body)
- case ValFrom(pos, pat, rhs) :: (rest @ (ValFrom(_, _, _) :: _)) =>
- makeCombination(closurePos(pos), flatMapName, rhs, pat,
- makeFor(mapName, flatMapName, rest, body))
- case ValFrom(pos, pat, rhs) :: Filter(_, test) :: rest =>
- makeFor(mapName, flatMapName,
- ValFrom(pos, pat, makeCombination(rhs.pos union test.pos, nme.withFilter, rhs, pat.duplicate, test)) :: rest,
- body)
- case ValFrom(pos, pat, rhs) :: rest =>
- val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile(_.isInstanceOf[ValEq])
- assert(!valeqs.isEmpty)
- val rest1 = rest.drop(valeqs.length)
- val pats = valeqs map { case ValEq(_, pat, _) => pat }
- val rhss = valeqs map { case ValEq(_, _, rhs) => rhs }
- val defpat1 = makeBind(pat)
- val defpats = pats map makeBind
- val pdefs = (defpats, rhss).zipped flatMap makePatDef
- val ids = (defpat1 :: defpats) map makeValue
- val rhs1 = makeForYield(
- List(ValFrom(pos, defpat1, rhs)),
- Block(pdefs, atPos(wrappingPos(ids)) { makeTupleTerm(ids, flattenUnary = true) }) setPos wrappingPos(pdefs))
- val allpats = (pat :: pats) map (_.duplicate)
- val vfrom1 = ValFrom(r2p(pos.start, pos.point, rhs1.pos.end), atPos(wrappingPos(allpats)) { makeTuple(allpats, isType = false) } , rhs1)
- makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
- case _ =>
- EmptyTree //may happen for erroneous input
- }
-// println("made for "+result)
-// result
- }
-
- /** Create tree for for-do comprehension <for (enums) body> */
- def makeFor(enums: List[Enumerator], body: Tree): Tree =
- makeFor(nme.foreach, nme.foreach, enums, body)
-
- /** Create tree for for-yield comprehension <for (enums) yield body> */
- def makeForYield(enums: List[Enumerator], body: Tree): Tree =
- makeFor(nme.map, nme.flatMap, enums, body)
-
/** Create tree for a pattern alternative */
def makeAlternative(ts: List[Tree]): Tree = {
def alternatives(t: Tree): List[Tree] = t match {
@@ -390,21 +118,9 @@ abstract class TreeBuilder {
Alternative(ts flatMap alternatives)
}
- /** Create visitor <x => x match cases> */
- def makeVisitor(cases: List[CaseDef], checkExhaustive: Boolean): Tree =
- makeVisitor(cases, checkExhaustive, "x$")
-
- /** Create visitor <x => x match cases> */
- def makeVisitor(cases: List[CaseDef], checkExhaustive: Boolean, prefix: String): Tree = {
- val x = freshTermName(prefix)
- val id = Ident(x)
- val sel = if (checkExhaustive) id else gen.mkUnchecked(id)
- Function(List(gen.mkSyntheticParam(x)), Match(sel, cases))
- }
-
/** Create tree for case definition <case pat if guard => rhs> */
def makeCaseDef(pat: Tree, guard: Tree, rhs: Tree): CaseDef =
- CaseDef(patvarTransformer.transform(pat), guard, rhs)
+ CaseDef(gen.patvarTransformer.transform(pat), guard, rhs)
/** Creates tree representing:
* { case x: Throwable =>
@@ -428,76 +144,6 @@ abstract class TreeBuilder {
makeCaseDef(pat, EmptyTree, body)
}
- /** Create tree for pattern definition <val pat0 = rhs> */
- def makePatDef(pat: Tree, rhs: Tree): List[Tree] =
- makePatDef(Modifiers(0), pat, rhs)
-
- /** Create tree for pattern definition <mods val pat0 = rhs> */
- def makePatDef(mods: Modifiers, pat: Tree, rhs: Tree): List[Tree] = matchVarPattern(pat) match {
- case Some((name, tpt)) =>
- List(atPos(pat.pos union rhs.pos) {
- ValDef(mods, name.toTermName, tpt, rhs)
- })
-
- case None =>
- // in case there is exactly one variable x_1 in pattern
- // val/var p = e ==> val/var x_1 = e.match (case p => (x_1))
- //
- // in case there are zero or more than one variables in pattern
- // val/var p = e ==> private synthetic val t$ = e.match (case p => (x_1, ..., x_N))
- // val/var x_1 = t$._1
- // ...
- // val/var x_N = t$._N
-
- val rhsUnchecked = gen.mkUnchecked(rhs)
-
- // TODO: clean this up -- there is too much information packked into makePatDef's `pat` argument
- // when it's a simple identifier (case Some((name, tpt)) -- above),
- // pat should have the type ascription that was specified by the user
- // however, in `case None` (here), we must be careful not to generate illegal pattern trees (such as `(a, b): Tuple2[Int, String]`)
- // i.e., this must hold: pat1 match { case Typed(expr, tp) => assert(expr.isInstanceOf[Ident]) case _ => }
- // if we encounter such an erroneous pattern, we strip off the type ascription from pat and propagate the type information to rhs
- val (pat1, rhs1) = patvarTransformer.transform(pat) match {
- // move the Typed ascription to the rhs
- case Typed(expr, tpt) if !expr.isInstanceOf[Ident] =>
- val rhsTypedUnchecked =
- if (tpt.isEmpty) rhsUnchecked
- else Typed(rhsUnchecked, tpt) setPos (rhs.pos union tpt.pos)
- (expr, rhsTypedUnchecked)
- case ok =>
- (ok, rhsUnchecked)
- }
- val vars = getVariables(pat1)
- val matchExpr = atPos((pat1.pos union rhs.pos).makeTransparent) {
- Match(
- rhs1,
- List(
- atPos(pat1.pos) {
- CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident.apply, flattenUnary = true))
- }
- ))
- }
- vars match {
- case List((vname, tpt, pos)) =>
- List(atPos(pat.pos union pos union rhs.pos) {
- ValDef(mods, vname.toTermName, tpt, matchExpr)
- })
- case _ =>
- val tmp = freshTermName()
- val firstDef =
- atPos(matchExpr.pos) {
- ValDef(Modifiers(PrivateLocal | SYNTHETIC | ARTIFACT | (mods.flags & LAZY)),
- tmp, TypeTree(), matchExpr)
- }
- var cnt = 0
- val restDefs = for ((vname, tpt, pos) <- vars) yield atPos(pos) {
- cnt += 1
- ValDef(mods, vname.toTermName, tpt, Select(Ident(tmp), newTermName("_" + cnt)))
- }
- firstDef :: restDefs
- }
- }
-
/** Create a tree representing the function type (argtpes) => restpe */
def makeFunctionTypeTree(argtpes: List[Tree], restpe: Tree): Tree = gen.mkFunctionTypeTree(argtpes, restpe)
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index 60f7857d0c..939641c3eb 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -69,7 +69,7 @@ abstract class Liveness {
case STORE_LOCAL(local) if (!genSet(local)) => killSet = killSet + local
case _ => ()
}
- Pair(genSet, killSet)
+ (genSet, killSet)
}
override def run() {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index 7a53293384..f10d7cdc40 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -418,7 +418,7 @@ abstract class TypeFlowAnalysis {
!blackballed(concreteMethod)
}
if(isCandidate) {
- remainingCALLs += Pair(cm, CallsiteInfo(b, receiver, result.stack.length, concreteMethod))
+ remainingCALLs(cm) = CallsiteInfo(b, receiver, result.stack.length, concreteMethod)
} else {
remainingCALLs.remove(cm)
isOnWatchlist.remove(cm)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
index c166b0bb7e..4f9f4c9e31 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
@@ -741,13 +741,13 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
var flatKeys: List[Int] = Nil
var targets: List[asm.Label] = Nil
var default: asm.Label = null
- var switchBlocks: List[Pair[asm.Label, Tree]] = Nil
+ var switchBlocks: List[Tuple2[asm.Label, Tree]] = Nil
// collect switch blocks and their keys, but don't emit yet any switch-block.
for (caze @ CaseDef(pat, guard, body) <- tree.cases) {
assert(guard == EmptyTree, guard)
val switchBlockPoint = new asm.Label
- switchBlocks ::= Pair(switchBlockPoint, body)
+ switchBlocks ::= (switchBlockPoint, body)
pat match {
case Literal(value) =>
flatKeys ::= value.intValue
@@ -772,7 +772,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
// emit switch-blocks.
val postMatch = new asm.Label
for (sb <- switchBlocks.reverse) {
- val Pair(caseLabel, caseBody) = sb
+ val (caseLabel, caseBody) = sb
markProgramPoint(caseLabel)
genLoad(caseBody, generatedType)
bc goTo postMatch
@@ -790,7 +790,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
genLoad(expr, expectedType)
val end = currProgramPoint()
if (emitVars) { // add entries to LocalVariableTable JVM attribute
- for (Pair(sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
+ for ((sym, start) <- varsInScope.reverse) { emitLocalVarScope(sym, start, end) }
}
varsInScope = savedScope
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index c22ced26a5..64ed094a47 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -112,7 +112,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
val ta = exemplars.get(a)
val tb = exemplars.get(b)
- val res = Pair(ta.isInterface, tb.isInterface) match {
+ val res = (ta.isInterface, tb.isInterface) match {
case (true, true) =>
// exercised by test/files/run/t4761.scala
if (tb.isSubtypeOf(ta.c)) ta.c
@@ -759,7 +759,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
index 5fe03624cf..c921d11d00 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
@@ -436,7 +436,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
var labelDef: scala.collection.Map[Symbol, LabelDef] = null// (LabelDef-sym -> LabelDef)
// bookkeeping the scopes of non-synthetic local vars, to emit debug info (`emitVars`).
- var varsInScope: List[Pair[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
+ var varsInScope: List[Tuple2[Symbol, asm.Label]] = null // (local-var-sym -> start-of-scope)
// helpers around program-points.
def lastInsn: asm.tree.AbstractInsnNode = {
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
index 916d118b6e..5be5abd895 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -90,11 +90,11 @@ abstract class BCodeTypes extends BCodeIdiomatic {
)
boxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.boxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.boxMethod)
yield (msym -> classLiteral(primitiveTypeMap(csym)))
unboxResultType =
- for(Pair(csym, msym) <- currentRun.runDefinitions.unboxMethod)
+ for((csym, msym) <- currentRun.runDefinitions.unboxMethod)
yield (msym -> primitiveTypeMap(csym))
// boxed classes are looked up in the `exemplars` map by jvmWiseLUB().
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index 8bbc382251..e92f8c2541 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -104,6 +104,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
if (settings.Xdce)
for ((sym, cls) <- icodes.classes if inliner.isClosureClass(sym) && !deadCode.liveClosures(sym)) {
log(s"Optimizer eliminated ${sym.fullNameString}")
+ deadCode.elidedClosures += sym
icodes.classes -= sym
}
@@ -292,7 +293,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def inameToSymbol(iname: String): Symbol = {
val name = global.newTypeName(iname)
val res0 =
- if (nme.isModuleName(name)) rootMirror.getModule(name.dropModule)
+ if (nme.isModuleName(name)) rootMirror.getModuleByName(name.dropModule)
else rootMirror.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested).
assert(res0 != NoSymbol)
val res = jsymbol(res0)
@@ -334,7 +335,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
assert(a.isClass)
assert(b.isClass)
- val res = Pair(a.isInterface, b.isInterface) match {
+ val res = (a.isInterface, b.isInterface) match {
case (true, true) =>
global.lub(List(a.tpe, b.tpe)).typeSymbol // TODO assert == firstCommonSuffix of resp. parents
case (true, false) =>
@@ -639,7 +640,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
innerClassBuffer += m
}
- val allInners: List[Symbol] = innerClassBuffer.toList
+ val allInners: List[Symbol] = innerClassBuffer.toList filterNot deadCode.elidedClosures
+
if (allInners.nonEmpty) {
debuglog(csym.fullName('.') + " contains " + allInners.size + " inner classes.")
@@ -1012,7 +1014,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
if (annotationss forall (_.isEmpty)) return
- for (Pair(annots, idx) <- annotationss.zipWithIndex;
+ for ((annots, idx) <- annotationss.zipWithIndex;
annot <- annots) {
val AnnotationInfo(typ, args, assocs) = annot
assert(args.isEmpty, args)
@@ -2154,7 +2156,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
def getMerged(): scala.collection.Map[Local, List[Interval]] = {
// TODO should but isn't: unbalanced start(s) of scope(s)
- val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }
+ val shouldBeEmpty = pending filter { p => val (_, st) = p; st.nonEmpty }
val merged = mutable.Map[Local, List[Interval]]()
def addToMerged(lv: Local, start: Label, end: Label) {
val intv = Interval(start, end)
@@ -2167,7 +2169,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
(b) take the latest end (onePastLast if none available)
(c) merge the thus made-up interval
*/
- for(Pair(k, st) <- shouldBeEmpty) {
+ for((k, st) <- shouldBeEmpty) {
var start = st.toList.sortBy(_.getOffset).head
if(merged.isDefinedAt(k)) {
val balancedStart = merged(k).head.lstart
@@ -2204,25 +2206,25 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
}
// adding non-param locals
var anonCounter = 0
- var fltnd: List[Triple[String, Local, Interval]] = Nil
- for(Pair(local, ranges) <- scoping.getMerged()) {
+ var fltnd: List[Tuple3[String, Local, Interval]] = Nil
+ for((local, ranges) <- scoping.getMerged()) {
var name = javaName(local.sym)
if (name == null) {
anonCounter += 1
name = "<anon" + anonCounter + ">"
}
for(intrvl <- ranges) {
- fltnd ::= Triple(name, local, intrvl)
+ fltnd ::= (name, local, intrvl)
}
}
// quest for deterministic output that Map.toList doesn't provide (so that ant test.stability doesn't complain).
val srtd = fltnd.sortBy { kr =>
- val Triple(name: String, _, intrvl: Interval) = kr
+ val (name: String, _, intrvl: Interval) = kr
- Triple(intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
+ (intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name)
}
- for(Triple(name, local, Interval(start, end)) <- srtd) {
+ for((name, local, Interval(start, end)) <- srtd) {
jmethod.visitLocalVariable(name, descriptor(local.kind), null, start, end, indexOf(local))
}
// "There may be no more than one LocalVariableTable attribute per local variable in the Code attribute"
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 193aae37b6..0f317422ac 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -41,7 +41,13 @@ abstract class DeadCodeElimination extends SubComponent {
}
/** closures that are instantiated at least once, after dead code elimination */
- val liveClosures: mutable.Set[Symbol] = new mutable.HashSet()
+ val liveClosures = perRunCaches.newSet[Symbol]()
+
+ /** closures that are eliminated, populated by GenASM.AsmPhase.run()
+ * these class symbols won't have a .class physical file, thus shouldn't be included in InnerClasses JVM attribute,
+ * otherwise some tools get confused or slow (SI-6546)
+ * */
+ val elidedClosures = perRunCaches.newSet[Symbol]()
/** Remove dead code.
*/
@@ -113,7 +119,7 @@ abstract class DeadCodeElimination extends SubComponent {
m foreachBlock { bb =>
useful(bb) = new mutable.BitSet(bb.size)
var rd = rdef.in(bb)
- for (Pair(i, idx) <- bb.toList.zipWithIndex) {
+ for ((i, idx) <- bb.toList.zipWithIndex) {
// utility for adding to worklist
def moveToWorkList() = moveToWorkListIf(cond = true)
@@ -131,7 +137,7 @@ abstract class DeadCodeElimination extends SubComponent {
i match {
case LOAD_LOCAL(_) =>
- defs = defs + Pair(((bb, idx)), rd.vars)
+ defs = defs + (((bb, idx), rd.vars))
moveToWorkListIf(cond = false)
case STORE_LOCAL(l) =>
@@ -344,7 +350,7 @@ abstract class DeadCodeElimination extends SubComponent {
val oldInstr = bb.toList
bb.open()
bb.clear()
- for (Pair(i, idx) <- oldInstr.zipWithIndex) {
+ for ((i, idx) <- oldInstr.zipWithIndex) {
if (useful(bb)(idx)) {
debuglog(" * " + i + " is useful")
bb.emit(i, i.pos)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 1578caff26..d194c095f8 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -144,7 +144,7 @@ object Plugin {
// (j, Try(descriptor))
def required(j: Path) = j -> loadDescriptionFromJar(j)
- type Paired = Pair[Path, Try[PluginDescription]]
+ type Paired = Tuple2[Path, Try[PluginDescription]]
val included: List[Paired] = (dirs flatMap (_ ifDirectory scan)).flatten
val exploded: List[Paired] = jars flatMap (_ ifDirectory explode)
val explicit: List[Paired] = jars flatMap (_ ifFile required)
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 0544da5d3c..68362c066d 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -80,10 +80,4 @@ abstract class Reporter {
WARNING.count = 0
cancelled = false
}
-
- // sbt compat
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- def countElementsAsString(n: Int, elements: String): String = StringOps.countElementsAsString(n, elements)
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- def countAsString(n: Int): String = StringOps.countAsString(n)
}
diff --git a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala
deleted file mode 100644
index 3aecc06b1e..0000000000
--- a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala
+++ /dev/null
@@ -1,99 +0,0 @@
-package scala.tools.nsc.scratchpad
-
-import java.io.{FileInputStream, InputStreamReader, IOException}
-
-import scala.collection.mutable.ArrayBuffer
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-class Mixer {
-
- protected val stdSeparator = "//> "
- protected val ctdSeparator = "//| "
- protected val sepColumn = 50
- protected val tabInc = 8
-
- type Comments = Seq[(Int, Array[Char])]
-
- def parseComments(comments: Array[Char]): Iterator[(Int, Array[Char])] = new Iterator[(Int, Array[Char])] {
- var idx = 0
- def hasNext = idx < comments.length
- def next() = {
- val nextSpace = comments indexOf (' ', idx)
- var nextNL = comments indexOf ('\n', nextSpace + 1)
- if (nextNL < 0) nextNL = comments.length
- val result =
- (new String(comments.slice(idx, nextSpace)).toInt, comments.slice(nextSpace + 1, nextNL))
- idx = nextNL + 1
- result
- }
- }
-
- def mix(source: Array[Char], comments: Array[Char]): Array[Char] = {
- val mixed = new ArrayBuffer[Char]
- var written = 0
- def align() = {
- var idx = mixed.lastIndexOf('\n') + 1
- var col = 0
- while (idx < mixed.length) {
- col =
- if (mixed(idx) == '\t') (col / tabInc) * tabInc + tabInc
- else col + 1
- idx += 1
- }
- if (col > sepColumn) {
- mixed += '\n'
- col = 0
- }
- while (col < sepColumn) {
- mixed += ' '
- col += 1
- }
- }
- for ((offset, cs) <- parseComments(comments)) {
- val sep =
- if (written < offset) {
- for (i <- written until offset) mixed += source(i)
- written = offset
- stdSeparator
- } else {
- mixed += '\n'
- ctdSeparator
- }
- align()
- mixed ++= sep ++= cs
- }
- mixed ++= source.view(written, source.length)
- mixed.toArray
- }
-
-}
-
-object Mixer extends Mixer {
-
- def contents(name: String): Array[Char] = {
- val page = new Array[Char](2 << 14)
- val buf = new ArrayBuffer[Char]
- val in = new FileInputStream(name)
- val rdr = new InputStreamReader(in)
- var nread = 0
- do {
- nread = rdr.read(page, 0, page.length)
- buf ++= (if (nread == page.length) page else page.take(nread))
- } while (nread >= 0)
- buf.toArray
- }
-
- def main(args: Array[String]) {
- val mixer = new Mixer
- try {
- require(args.length == 2, "required arguments: file1 file2")
- val source = contents(args(0))
- val comments = contents(args(1))
- val mixed = mixer.mix(source, comments)
- println(mixed.mkString)
- } catch {
- case ex: IOException =>
- println("error: "+ ex.getMessage)
- }
- }
-}
diff --git a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
deleted file mode 100644
index 61c1717fea..0000000000
--- a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-package scala.tools.nsc
-package scratchpad
-
-import scala.reflect.internal.Chars._
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-object SourceInserter {
- def stripRight(cs: Array[Char]): Array[Char] = {
- val lines =
- new String(cs) split "\n"
- def leftPart(str: String) =
- (str split """//>|//\|""").head
- def isContinuation(str: String) =
- ((str contains "//>") || (str contains "//|")) && (leftPart(str) forall isWhitespace)
- def stripTrailingWS(str: String) =
- str take (str lastIndexWhere (!isWhitespace(_))) + 1
- val prefixes =
- lines filterNot isContinuation map leftPart map stripTrailingWS
- (prefixes mkString "\n").toArray
- }
-}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 3d648ccbac..844774e75f 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -217,112 +217,33 @@ abstract class UnCurry extends InfoTransform
// nullary or parameterless
case fun1 if fun1 ne fun => fun1
case _ =>
- val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
- val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation
- anonClass setInfo ClassInfoType(parents, newScope, anonClass)
-
- val targs = fun.tpe.typeArgs
- val (formals, restpe) = (targs.init, targs.last)
+ def typedFunPos(t: Tree) = localTyper.typedPos(fun.pos)(t)
+ val funParams = fun.vparams map (_.symbol)
+ def mkMethod(owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags): DefDef =
+ gen.mkMethodFromFunction(localTyper)(fun, owner, name, additionalFlags)
if (inlineFunctionExpansion) {
- val applyMethodDef = {
- val methSym = anonClass.newMethod(nme.apply, fun.pos, FINAL)
- val paramSyms = map2(formals, fun.vparams) {
- (tp, param) => methSym.newSyntheticValueParam(tp, param.name)
- }
- methSym setInfoAndEnter MethodType(paramSyms, restpe)
-
- fun.vparams foreach (_.symbol.owner = methSym)
- fun.body changeOwner (fun.symbol -> methSym)
-
- val body = localTyper.typedPos(fun.pos)(fun.body)
- val methDef = DefDef(methSym, List(fun.vparams), body)
+ val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe))
+ val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation
+ anonClass setInfo ClassInfoType(parents, newScope, anonClass)
- // Have to repack the type to avoid mismatches when existentials
- // appear in the result - see SI-4869.
- methDef.tpt setType localTyper.packedType(body, methSym)
- methDef
- }
+ val applyMethodDef = mkMethod(anonClass, nme.apply)
+ anonClass.info.decls enter applyMethodDef.symbol
- localTyper.typedPos(fun.pos) {
+ typedFunPos {
Block(
- List(ClassDef(anonClass, NoMods, ListOfNil, List(applyMethodDef), fun.pos)),
+ ClassDef(anonClass, NoMods, ListOfNil, List(applyMethodDef), fun.pos),
Typed(New(anonClass.tpe), TypeTree(fun.tpe)))
}
} else {
- /**
- * Abstracts away the common functionality required to create both
- * the lifted function and the apply method on the anonymous class
- * It creates a method definition with value params cloned from the
- * original lambda. Then it calls a supplied function to create
- * the body and types the result. Finally
- * everything is wrapped up in a MethodDef
- *
- * TODO it is intended that this common functionality be used
- * whether inlineFunctionExpansion is true or not. However, it
- * seems to introduce subtle ownwership changes that produce
- * binary incompatible changes and so it is completely
- * hidden behind the inlineFunctionExpansion for now.
- *
- * @param owner The owner for the new method
- * @param name name for the new method
- * @param additionalFlags flags to be put on the method in addition to FINAL
- * @bodyF function that turns the method symbol and list of value params
- * into a body for the method
- */
- def createMethod(owner: Symbol, name: TermName, additionalFlags: Long)(bodyF: (Symbol, List[ValDef]) => Tree) = {
- val methSym = owner.newMethod(name, fun.pos, FINAL | additionalFlags)
- val vparams = fun.vparams map (_.duplicate)
-
- val paramSyms = map2(formals, vparams) {
- (tp, vparam) => methSym.newSyntheticValueParam(tp, vparam.name)
- }
- foreach2(vparams, paramSyms){(valdef, sym) => valdef.symbol = sym}
- vparams foreach (_.symbol.owner = methSym)
-
- val methodType = MethodType(paramSyms, restpe.deconst)
- methSym setInfo methodType
-
- // TODO this is probably cleaner if bodyF only works with symbols rather than parameter ValDefs
- val tempBody = bodyF(methSym, vparams)
- val body = localTyper.typedPos(fun.pos)(tempBody)
- val methDef = DefDef(methSym, List(vparams), body)
-
- // Have to repack the type to avoid mismatches when existentials
- // appear in the result - see SI-4869.
- methDef.tpt setType localTyper.packedType(body, methSym).deconst
- methDef
- }
-
- val methodFlags = ARTIFACT
// method definition with the same arguments, return type, and body as the original lambda
- val liftedMethod = createMethod(fun.symbol.owner, tpnme.ANON_FUN_NAME.toTermName, methodFlags){
- case(methSym, vparams) =>
- fun.body.substituteSymbols(fun.vparams map (_.symbol), vparams map (_.symbol))
- fun.body changeOwner (fun.symbol -> methSym)
- }
-
- // callsite for the lifted method
- val args = fun.vparams map { vparam =>
- val ident = Ident(vparam.symbol)
- // if -Yeta-expand-keeps-star is turned on then T* types can get through. In order
- // to forward them we need to forward x: T* ascribed as "x:_*"
- if (settings.etaExpandKeepsStar && definitions.isRepeatedParamType(vparam.tpt.tpe))
- gen.wildcardStar(ident)
- else
- ident
- }
-
- val funTyper = localTyper.typedPos(fun.pos) _
-
- val liftedMethodCall = funTyper(Apply(liftedMethod.symbol, args:_*))
+ val liftedMethod = mkMethod(fun.symbol.owner, nme.ANON_FUN_NAME, additionalFlags = ARTIFACT)
// new function whose body is just a call to the lifted method
- val newFun = treeCopy.Function(fun, fun.vparams, liftedMethodCall)
- funTyper(Block(
- List(funTyper(liftedMethod)),
- super.transform(newFun)
- ))
+ val newFun = deriveFunction(fun)(_ => typedFunPos(
+ gen.mkForwarder(gen.mkAttributedRef(liftedMethod.symbol), funParams :: Nil)
+ ))
+ typedFunPos(Block(liftedMethod, super.transform(newFun)))
}
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 92f95e282b..7ecc2be9be 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -527,6 +527,9 @@ trait ContextErrors {
def TooManyArgsPatternError(fun: Tree) =
NormalTypeError(fun, "too many arguments for unapply pattern, maximum = "+definitions.MaxTupleArity)
+ def BlackboxExtractorExpansion(fun: Tree) =
+ NormalTypeError(fun, "extractor macros can only be whitebox")
+
def WrongShapeExtractorExpansion(fun: Tree) =
NormalTypeError(fun, "extractor macros can only expand into extractor calls")
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index b1a48f7478..fdec1edcc0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -388,11 +388,11 @@ trait Implicits {
*/
private def dominates(dtor: Type, dted: Type): Boolean = {
def core(tp: Type): Type = tp.dealiasWiden match {
- case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner)
+ case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner)
case AnnotatedType(annots, tp, selfsym) => core(tp)
- case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
- case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
- case _ => tp
+ case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
+ case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi)))
+ case _ => tp
}
def stripped(tp: Type): Type = {
// `t.typeSymbol` returns the symbol of the normalized type. If that normalized type
@@ -401,23 +401,18 @@ trait Implicits {
val syms = for (t <- tp; if t.typeSymbol.isTypeParameter) yield t.typeSymbol
deriveTypeWithWildcards(syms.distinct)(tp)
}
- def sum(xs: List[Int]) = (0 /: xs)(_ + _)
- def complexity(tp: Type): Int = tp.dealiasWiden match {
- case NoPrefix =>
- 0
- case SingleType(pre, sym) =>
- if (sym.isPackage) 0 else complexity(tp.dealiasWiden)
- case TypeRef(pre, sym, args) =>
- complexity(pre) + sum(args map complexity) + 1
- case RefinedType(parents, _) =>
- sum(parents map complexity) + 1
- case _ =>
- 1
+ def complexity(tp: Type): Int = tp.dealias match {
+ case NoPrefix => 0
+ case SingleType(pre, sym) => if (sym.isPackage) 0 else complexity(tp.dealiasWiden)
+ case ThisType(sym) => if (sym.isPackage) 0 else 1
+ case TypeRef(pre, sym, args) => complexity(pre) + (args map complexity).sum + 1
+ case RefinedType(parents, _) => (parents map complexity).sum + 1
+ case _ => 1
}
def overlaps(tp1: Type, tp2: Type): Boolean = (tp1, tp2) match {
case (RefinedType(parents, _), _) => parents exists (overlaps(_, tp2))
case (_, RefinedType(parents, _)) => parents exists (overlaps(tp1, _))
- case _ => tp1.typeSymbol == tp2.typeSymbol
+ case _ => tp1.typeSymbol == tp2.typeSymbol
}
val dtor1 = stripped(core(dtor))
val dted1 = stripped(core(dted))
@@ -596,7 +591,7 @@ trait Implicits {
// workaround for deficient context provided by ModelFactoryImplicitSupport#makeImplicitConstraints
val isScalaDoc = context.tree == EmptyTree
- val itree = atPos(pos.focus) {
+ val itree0 = atPos(pos.focus) {
if (isLocal && !isScalaDoc) {
// SI-4270 SI-5376 Always use an unattributed Ident for implicits in the local scope,
// rather than an attributed Select, to detect shadowing.
@@ -608,15 +603,16 @@ trait Implicits {
Select(gen.mkAttributedQualifier(info.pre), implicitMemberName)
}
}
- typingLog("considering", typeDebug.ptTree(itree))
+ val itree1 = if (isBlackbox(info.sym)) suppressMacroExpansion(itree0) else itree0
+ typingLog("considering", typeDebug.ptTree(itree1))
- def fail(reason: String): SearchResult = failure(itree, reason)
- def fallback = typed1(itree, EXPRmode, wildPt)
+ def fail(reason: String): SearchResult = failure(itree0, reason)
+ def fallback = typed1(itree1, EXPRmode, wildPt)
try {
- val itree1 = if (!isView) fallback else pt match {
+ val itree2 = if (!isView) fallback else pt match {
case Function1(arg1, arg2) =>
typed1(
- atPos(itree.pos)(Apply(itree, List(Ident("<argument>") setType approximate(arg1)))),
+ atPos(itree0.pos)(Apply(itree1, List(Ident("<argument>") setType approximate(arg1)))),
EXPRmode,
approximate(arg2)
) match {
@@ -647,10 +643,10 @@ trait Implicits {
if (Statistics.canEnable) Statistics.incCounter(typedImplicits)
- val itree2 = if (isView) treeInfo.dissectApplied(itree1).callee
- else adapt(itree1, EXPRmode, wildPt)
+ val itree3 = if (isView) treeInfo.dissectApplied(itree2).callee
+ else adapt(itree2, EXPRmode, wildPt)
- typingStack.showAdapt(itree, itree2, pt, context)
+ typingStack.showAdapt(itree0, itree3, pt, context)
def hasMatchingSymbol(tree: Tree): Boolean = (tree.symbol == info.sym) || {
tree match {
@@ -663,21 +659,23 @@ trait Implicits {
if (context.hasErrors)
fail("hasMatchingSymbol reported error: " + context.firstError.get.errMsg)
- else if (isLocal && !hasMatchingSymbol(itree1))
+ else if (itree3.isErroneous)
+ fail("error typechecking implicit candidate")
+ else if (isLocal && !hasMatchingSymbol(itree2))
fail("candidate implicit %s is shadowed by %s".format(
- info.sym.fullLocationString, itree1.symbol.fullLocationString))
+ info.sym.fullLocationString, itree2.symbol.fullLocationString))
else {
val tvars = undetParams map freshVar
def ptInstantiated = pt.instantiateTypeParams(undetParams, tvars)
- if (matchesPt(itree2.tpe, ptInstantiated, undetParams)) {
+ if (matchesPt(itree3.tpe, ptInstantiated, undetParams)) {
if (tvars.nonEmpty)
typingLog("solve", ptLine("tvars" -> tvars, "tvars.constr" -> tvars.map(_.constr)))
- val targs = solvedTypes(tvars, undetParams, undetParams map varianceInType(pt), upper = false, lubDepth(itree2.tpe :: pt :: Nil))
+ val targs = solvedTypes(tvars, undetParams, undetParams map varianceInType(pt), upper = false, lubDepth(itree3.tpe :: pt :: Nil))
// #2421: check that we correctly instantiated type parameters outside of the implicit tree:
- checkBounds(itree2, NoPrefix, NoSymbol, undetParams, targs, "inferred ")
+ checkBounds(itree3, NoPrefix, NoSymbol, undetParams, targs, "inferred ")
context.firstError match {
case Some(err) =>
return fail("type parameters weren't correctly instantiated outside of the implicit tree: " + err.errMsg)
@@ -693,7 +691,7 @@ trait Implicits {
if (okParams.isEmpty) EmptyTreeTypeSubstituter
else {
val subst = new TreeTypeSubstituter(okParams, okArgs)
- subst traverse itree2
+ subst traverse itree3
notifyUndetparamsInferred(okParams, okArgs)
subst
}
@@ -711,9 +709,9 @@ trait Implicits {
// This is just called for the side effect of error detection,
// see SI-6966 to see what goes wrong if we use the result of this
// as the SearchResult.
- itree2 match {
- case TypeApply(fun, args) => typedTypeApply(itree2, EXPRmode, fun, args)
- case Apply(TypeApply(fun, args), _) => typedTypeApply(itree2, EXPRmode, fun, args) // t2421c
+ itree3 match {
+ case TypeApply(fun, args) => typedTypeApply(itree3, EXPRmode, fun, args)
+ case Apply(TypeApply(fun, args), _) => typedTypeApply(itree3, EXPRmode, fun, args) // t2421c
case t => t
}
@@ -721,13 +719,13 @@ trait Implicits {
case Some(err) =>
fail("typing TypeApply reported errors for the implicit tree: " + err.errMsg)
case None =>
- val result = new SearchResult(itree2, subst)
+ val result = new SearchResult(unsuppressMacroExpansion(itree3), subst)
if (Statistics.canEnable) Statistics.incCounter(foundImplicits)
typingLog("success", s"inferred value of type $ptInstantiated is $result")
result
}
}
- else fail("incompatible: %s does not match expected type %s".format(itree2.tpe, ptInstantiated))
+ else fail("incompatible: %s does not match expected type %s".format(itree3.tpe, ptInstantiated))
}
}
catch {
@@ -1147,7 +1145,7 @@ trait Implicits {
gen.mkAttributedThis(thisSym)
case _ =>
// if `pre` is not a PDT, e.g. if someone wrote
- // implicitly[scala.reflect.macros.Context#TypeTag[Int]]
+ // implicitly[scala.reflect.macros.BlackboxContext#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 02fb70f3e5..27920dbd74 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.Context)
+ * (c: scala.reflect.macros.BlackboxContext)
* (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.Context defined in scala-reflect.jar).
+ * (because they refer to macro impls, and macro impls refer to scala.reflect.macros.BlackboxContext/WhiteboxContext 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,40 +81,42 @@ 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 Macro) or a vanilla def?
- val isBundle: Boolean,
- // Java class name of the class that contains the macro implementation
- // is used to load the corresponding object with Java reflection
- className: String,
- // method name of the macro implementation
- // `className` and `methName` are all we need to reflectively invoke a macro implementation
- // because macro implementations cannot be overloaded
- methName: String,
- // flattens the macro impl's parameter lists having symbols replaced with their fingerprints
- // currently fingerprints are calculated solely from types of the symbols:
- // * 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.Context) => Other
- // f.ex. for: def impl[T: WeakTypeTag, U, V: WeakTypeTag](c: 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)
- // these trees don't refer to a macro impl, so we can pickle them as is
- targs: List[Tree]) {
-
+ // Is this macro impl a bundle (a trait extending BlackboxMacro or WhiteboxMacro) or a vanilla def?
+ val isBundle: Boolean,
+ // Is this macro impl blackbox (i.e. having BlackboxContext 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
+ className: String,
+ // method name of the macro implementation
+ // `className` and `methName` are all we need to reflectively invoke a macro implementation
+ // because macro implementations cannot be overloaded
+ methName: String,
+ // flattens the macro impl's parameter lists having symbols replaced with their fingerprints
+ // currently fingerprints are calculated solely from types of the symbols:
+ // * 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) = ???
+ // `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)
+ // these trees don't refer to a macro impl, so we can pickle them as is
+ targs: List[Tree]) {
// Was this binding derived from a `def ... = macro ???` definition?
def is_??? = {
val Predef_??? = currentRun.runDefinitions.Predef_???
className == Predef_???.owner.javaClassName && methName == Predef_???.name.encoded
}
+ def isWhitebox = !isBlackbox
}
/** Macro def -> macro impl bindings are serialized into a `macroImpl` annotation
* 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.Context): c.Expr[Unit] = ???
+ * def impl(c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] = ???
* def foo: Unit = macro impl
*
* We will have the following annotation added on the macro definition `foo`:
@@ -122,13 +124,14 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* @scala.reflect.macros.internal.macroImpl(
* `macro`(
* "isBundle" = false,
+ * "isBlackbox" = true,
* "signature" = List(Other),
* "methodName" = "impl",
* "versionFormat" = <current version format>,
* "className" = "Macros$"))
*/
object MacroImplBinding {
- val versionFormat = 5.0
+ val versionFormat = 6.0
def pickleAtom(obj: Any): Tree =
obj match {
@@ -151,7 +154,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
def pickle(macroImplRef: Tree): Tree = {
val runDefinitions = currentRun.runDefinitions
import runDefinitions._
- val MacroImplReference(isBundle, owner, macroImpl, targs) = macroImplRef
+ val MacroImplReference(isBundle, isBlackbox, owner, macroImpl, targs) = macroImplRef
// todo. refactor when fixing SI-5498
def className: String = {
@@ -182,6 +185,7 @@ 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
@@ -237,10 +241,11 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
if (versionFormat != pickleVersionFormat) fail(s"expected version format $versionFormat, actual $pickleVersionFormat")
val isBundle = unpickle("isBundle", classOf[Boolean])
+ val isBlackbox = unpickle("isBlackbox", classOf[Boolean])
val className = unpickle("className", classOf[String])
val methodName = unpickle("methodName", classOf[String])
val signature = unpickle("signature", classOf[List[List[Fingerprint]]])
- MacroImplBinding(isBundle, className, methodName, signature, targs)
+ MacroImplBinding(isBundle, isBlackbox, className, methodName, signature, targs)
}
}
@@ -249,14 +254,17 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
macroDef withAnnotation AnnotationInfo(MacroImplAnnotation.tpe, List(pickle), Nil)
}
- def loadMacroImplBinding(macroDef: Symbol): MacroImplBinding = {
- val Some(AnnotationInfo(_, List(pickle), _)) = macroDef.getAnnotation(MacroImplAnnotation)
- MacroImplBinding.unpickle(pickle)
- }
+ def loadMacroImplBinding(macroDef: Symbol): Option[MacroImplBinding] =
+ macroDef.getAnnotation(MacroImplAnnotation) collect {
+ case AnnotationInfo(_, List(pickle), _) => MacroImplBinding.unpickle(pickle)
+ }
+
+ def isBlackbox(expandee: Tree): Boolean = isBlackbox(dissectApplied(expandee).core.symbol)
+ def isBlackbox(macroDef: Symbol): Boolean = loadMacroImplBinding(macroDef).map(_.isBlackbox).getOrElse(false)
def computeMacroDefTypeFromMacroImplRef(macroDdef: DefDef, macroImplRef: Tree): Type = {
macroImplRef match {
- case MacroImplReference(_, _, macroImpl, targs) =>
+ case MacroImplReference(_, _, _, macroImpl, targs) =>
// Step I. Transform c.Expr[T] to T and everything else to Any
var runtimeType = decreaseMetalevel(macroImpl.info.finalResultType)
@@ -450,7 +458,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
(trees :+ tags).flatten
}
- val binding = loadMacroImplBinding(macroDef)
+ val binding = loadMacroImplBinding(macroDef).get
if (binding.is_???) Nil
else calculateMacroArgs(binding)
}
@@ -459,7 +467,7 @@ 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.Context`.
+ * See more informations in comments to `openMacros` in `scala.reflect.macros.WhiteboxContext`.
*/
private var _openMacros = List[MacroContext]()
def openMacros = _openMacros
@@ -596,21 +604,27 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
*/
def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = {
object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, pt) {
- override def onSuccess(expanded: Tree) = {
+ override def onSuccess(expanded0: Tree) = {
+ def approximate(tp: Type) = {
+ // approximation is necessary for whitebox macros to guide type inference
+ // read more in the comments for onDelayed below
+ if (isBlackbox(expandee)) tp
+ else {
+ val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
+ deriveTypeWithWildcards(undetparams)(tp)
+ }
+ }
+ val macroPt = approximate(if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe)
+ val expanded = if (isBlackbox(expandee)) atPos(enclosingMacroPosition.focus)(Typed(expanded0, TypeTree(macroPt))) else expanded0
+
// 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, expanded)
- // approximation is necessary for whitebox macros to guide type inference
- // read more in the comments for onDelayed below
- def approximate(tp: Type) = {
- val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
- deriveTypeWithWildcards(undetparams)(tp)
- }
- val macroPtApprox = approximate(if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe)
+
// `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
// therefore we need to re-enable the conversions back temporarily
- if (macroDebugVerbose) println(s"typecheck #1 (against macroPtApprox = $macroPtApprox): $expanded")
- val expanded1 = typer.context.withImplicitsEnabled(typer.typed(expanded, mode, macroPtApprox))
+ if (macroDebugVerbose) println(s"typecheck #1 (against macroPt = $macroPt): $expanded")
+ val expanded1 = typer.context.withImplicitsEnabled(typer.typed(expanded, mode, macroPt))
if (expanded1.isErrorTyped) {
if (macroDebugVerbose) println(s"typecheck #1 has failed: ${typer.context.reportBuffer.errors}")
expanded1
@@ -664,7 +678,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
// 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 ===========
+ // =========== 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)
@@ -672,9 +686,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
// 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) {
- forced += delayed
- typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), pt, keepNothings = false)
- macroExpandApply(typer, delayed, mode, pt)
+ if (isBlackbox(expandee)) typer.instantiatePossiblyExpectingUnit(delayed, mode, pt)
+ else {
+ forced += delayed
+ typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), pt, keepNothings = false)
+ macroExpandApply(typer, delayed, mode, pt)
+ }
} else delayed
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 03aad71165..46ff98875f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -162,7 +162,7 @@ trait NamesDefaults { self: Analyzer =>
// never used for constructor calls, they always have a stable qualifier
def blockWithQualifier(qual: Tree, selected: Name) = {
- val sym = blockTyper.context.owner.newValue(unit.freshTermName("qual$"), qual.pos, newFlags = ARTIFACT) setInfo uncheckedBounds(qual.tpe)
+ val sym = blockTyper.context.owner.newValue(unit.freshTermName("qual$"), newFlags = ARTIFACT) setInfo uncheckedBounds(qual.tpe) setPos (qual.pos.makeTransparent)
blockTyper.context.scope enter sym
val vd = atPos(sym.pos)(ValDef(sym, qual) setType NoType)
// it stays in Vegas: SI-5720, SI-5727
@@ -173,13 +173,16 @@ trait NamesDefaults { self: Analyzer =>
// setSymbol below is important because the 'selected' function might be overloaded. by
// assigning the correct method symbol, typedSelect will just assign the type. the reason
// to still call 'typed' is to correctly infer singleton types, SI-5259.
- val f = blockTyper.typedOperator(Select(newQual, selected).setSymbol(baseFun1.symbol))
+ val selectPos =
+ if(qual.pos.isRange && baseFun.pos.isRange) qual.pos.union(baseFun.pos).withStart(Math.min(qual.pos.end, baseFun.pos.end))
+ else baseFun.pos
+ val f = blockTyper.typedOperator(Select(newQual, selected).setSymbol(baseFun1.symbol).setPos(selectPos))
if (funTargs.isEmpty) f
else TypeApply(f, funTargs).setType(baseFun.tpe)
}
val b = Block(List(vd), baseFunTransformed)
- .setType(baseFunTransformed.tpe).setPos(baseFun.pos)
+ .setType(baseFunTransformed.tpe).setPos(baseFun.pos.makeTransparent)
context.namedApplyBlockInfo =
Some((b, NamedApplyInfo(Some(newQual), defaultTargs, Nil, blockTyper)))
b
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index f69b8a9697..ba135d7d25 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -409,9 +409,10 @@ trait PatternTypers {
if (fun1.tpe.isErroneous)
duplErrTree
- else if (unapplyMethod.isMacro && !fun1.isInstanceOf[Apply])
- duplErrorTree(WrongShapeExtractorExpansion(tree))
- else
+ else if (unapplyMethod.isMacro && !fun1.isInstanceOf[Apply]) {
+ if (isBlackbox(unapplyMethod)) duplErrorTree(BlackboxExtractorExpansion(tree))
+ else duplErrorTree(WrongShapeExtractorExpansion(tree))
+ } else
makeTypedUnApply()
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index f90c6f1d86..355e52ce2b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1111,7 +1111,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
if (tree.isType)
adaptType()
- else if (mode.typingExprNotFun && treeInfo.isMacroApplication(tree))
+ else if (mode.typingExprNotFun && treeInfo.isMacroApplication(tree) && !isMacroExpansionSuppressed(tree))
macroExpandApply(this, tree, mode, pt)
else if (mode.typingConstructorPattern)
typedConstructorPattern(tree, pt)
@@ -5052,7 +5052,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// @M: fun is typed in TAPPmode because it is being applied to its actual type parameters
val fun1 = typed(fun, mode.forFunMode | TAPPmode)
- val tparams = fun1.symbol.typeParams
+ val tparams = if (fun1.symbol == null) Nil else fun1.symbol.typeParams
//@M TODO: val undets_fun = context.undetparams ?
// "do args first" (by restoring the context.undetparams) in order to maintain context.undetparams on the function side.
diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala
index cb46004174..4237f36ade 100644
--- a/src/compiler/scala/tools/nsc/util/package.scala
+++ b/src/compiler/scala/tools/nsc/util/package.scala
@@ -90,51 +90,22 @@ package object util {
lazy val trace = new SimpleTracer(System.out)
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- val StringOps = scala.reflect.internal.util.StringOps
-
- @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0")
- type StringOps = scala.reflect.internal.util.StringOps
-
- @deprecated("scala.reflect.internal.util.WeakHashSet", "2.10.0")
- type WeakHashSet[T <: AnyRef] = scala.reflect.internal.util.WeakHashSet[T]
-
- @deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0")
- val Position = scala.reflect.internal.util.Position
-
+ // These four deprecated since 2.10.0 are still used in (at least)
+ // the sbt 0.12.4 compiler interface.
@deprecated("Moved to scala.reflect.internal.util.Position", "2.10.0")
type Position = scala.reflect.internal.util.Position
-
@deprecated("Moved to scala.reflect.internal.util.NoPosition", "2.10.0")
val NoPosition = scala.reflect.internal.util.NoPosition
-
@deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0")
val FakePos = scala.reflect.internal.util.FakePos
-
@deprecated("Moved to scala.reflect.internal.util.FakePos", "2.10.0")
type FakePos = scala.reflect.internal.util.FakePos
- @deprecated("Moved to scala.reflect.internal.util.OffsetPosition", "2.10.0")
- type OffsetPosition = scala.reflect.internal.util.OffsetPosition
-
+ // These three were still used in scala-refactoring.
@deprecated("Moved to scala.reflect.internal.util.RangePosition", "2.10.0")
type RangePosition = scala.reflect.internal.util.RangePosition
-
@deprecated("Moved to scala.reflect.internal.util.SourceFile", "2.10.0")
type SourceFile = scala.reflect.internal.util.SourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.NoSourceFile", "2.10.0")
- val NoSourceFile = scala.reflect.internal.util.NoSourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.NoFile", "2.10.0")
- val NoFile = scala.reflect.internal.util.NoFile
-
- @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0")
- val ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile
-
- @deprecated("Moved to scala.reflect.internal.util.ScriptSourceFile", "2.10.0")
- type ScriptSourceFile = scala.reflect.internal.util.ScriptSourceFile
-
@deprecated("Moved to scala.reflect.internal.util.BatchSourceFile", "2.10.0")
type BatchSourceFile = scala.reflect.internal.util.BatchSourceFile
diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala
index 6c1821f8aa..5c53c81e8b 100644
--- a/src/compiler/scala/tools/reflect/StdTags.scala
+++ b/src/compiler/scala/tools/reflect/StdTags.scala
@@ -49,7 +49,7 @@ object StdRuntimeTags extends StdTags {
}
abstract class StdContextTags extends StdTags {
- val tc: scala.reflect.macros.Context
+ val tc: scala.reflect.macros.contexts.Context
val u: tc.universe.type = tc.universe
val m = tc.mirror
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
index 0b5ade0b4c..126c14ac81 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
@@ -55,19 +55,17 @@ trait Parsers { self: Quasiquotes =>
def isHole(name: Name): Boolean = holeMap.contains(name)
- override implicit def fresh: FreshNameCreator = new FreshNameCreator {
- override def newName(prefix: String) = super.newName(nme.QUASIQUOTE_PREFIX + prefix)
- }
+ override implicit def fresh: FreshNameCreator = new FreshNameCreator(nme.QUASIQUOTE_PREFIX)
override val treeBuilder = new ParserTreeBuilder {
override implicit def fresh: FreshNameCreator = parser.fresh
// q"(..$xs)"
- override def makeTupleTerm(trees: List[Tree], flattenUnary: Boolean): Tree =
+ override def makeTupleTerm(trees: List[Tree]): Tree =
Apply(Ident(nme.QUASIQUOTE_TUPLE), trees)
// tq"(..$xs)"
- override def makeTupleType(trees: List[Tree], flattenUnary: Boolean): Tree =
+ override def makeTupleType(trees: List[Tree]): Tree =
AppliedTypeTree(Ident(tpnme.QUASIQUOTE_TUPLE), trees)
// q"{ $x }"
@@ -152,6 +150,13 @@ trait Parsers { self: Quasiquotes =>
in.nextToken()
stats
}
+
+ override def enumerator(isFirst: Boolean, allowNestedIf: Boolean = true) =
+ if (isHole && lookingAhead { in.token == EOF || in.token == RPAREN || isStatSep }) {
+ val res = build.SyntacticValFrom(Bind(in.name, Ident(nme.WILDCARD)), Ident(nme.QUASIQUOTE_FOR_ENUM)) :: Nil
+ in.nextToken()
+ res
+ } else super.enumerator(isFirst, allowNestedIf)
}
}
@@ -170,17 +175,17 @@ trait Parsers { self: Quasiquotes =>
object PatternParser extends Parser {
def entryPoint = { parser =>
val pat = parser.noSeq.pattern1()
- parser.treeBuilder.patvarTransformer.transform(pat)
+ gen.patvarTransformer.transform(pat)
}
}
- object FreshName {
- def unapply(name: Name): Option[String] =
- name.toString.split("\\$") match {
- case Array(qq, left, right) if qq + "$" == nme.QUASIQUOTE_PREFIX && Try(right.toInt).isSuccess =>
- Some(left + "$")
- case _ =>
- None
- }
+ object ForEnumeratorParser extends Parser {
+ def entryPoint = { parser =>
+ val enums = parser.enumerator(isFirst = false, allowNestedIf = false)
+ assert(enums.length == 1)
+ enums.head
+ }
}
+
+ object FreshName extends FreshNameExtractor(nme.QUASIQUOTE_PREFIX)
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
index c31d1fcd12..54be9123c7 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
@@ -161,4 +161,12 @@ trait Placeholders { self: Quasiquotes =>
case _ => None
}
}
+
+ object ForEnumPlaceholder {
+ def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
+ case build.SyntacticValFrom(Bind(Placeholder(tree, location, card), Ident(nme.WILDCARD)), Ident(nme.QUASIQUOTE_FOR_ENUM)) =>
+ Some((tree, location, card))
+ case _ => None
+ }
+ }
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala b/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
index f4d6b39d02..7d777ef7d5 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
@@ -31,6 +31,7 @@ abstract class Quasiquotes extends Parsers
case nme.tq => TypeParser.parse(_)
case nme.cq => CaseParser.parse(_)
case nme.pq => PatternParser.parse(_)
+ case nme.fq => ForEnumeratorParser.parse(_)
case other => global.abort(s"Unknown quasiquote flavor: $other")
}
(universe0, args0, parts1, parse0, reify0, method0)
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index 3d1ecf95b2..b28c85cfc2 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -127,6 +127,7 @@ trait Reifiers { self: Quasiquotes =>
case RefineStatPlaceholder(tree, _, _) => reifyRefineStat(tree)
case EarlyDefPlaceholder(tree, _, _) => reifyEarlyDef(tree)
case PackageStatPlaceholder(tree, _, _) => reifyPackageStat(tree)
+ case ForEnumPlaceholder(tree, _, _) => tree
case _ => EmptyTree
}
@@ -148,6 +149,16 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticValDef, mods, name, tpt, rhs)
case SyntacticVarDef(mods, name, tpt, rhs) =>
reifyBuildCall(nme.SyntacticVarDef, mods, name, tpt, rhs)
+ case SyntacticValFrom(pat, rhs) =>
+ reifyBuildCall(nme.SyntacticValFrom, pat, rhs)
+ case SyntacticValEq(pat, rhs) =>
+ reifyBuildCall(nme.SyntacticValEq, pat, rhs)
+ case SyntacticFilter(cond) =>
+ reifyBuildCall(nme.SyntacticFilter, cond)
+ case SyntacticFor(enums, body) =>
+ reifyBuildCall(nme.SyntacticFor, enums, body)
+ case SyntacticForYield(enums, body) =>
+ reifyBuildCall(nme.SyntacticForYield, enums, body)
case SyntacticAssign(lhs, rhs) =>
reifyBuildCall(nme.SyntacticAssign, lhs, rhs)
case SyntacticApplied(fun, List(args))
@@ -275,7 +286,7 @@ trait Reifiers { self: Quasiquotes =>
case RefineStatPlaceholder(tree, _, DotDot) => reifyRefineStat(tree)
case EarlyDefPlaceholder(tree, _, DotDot) => reifyEarlyDef(tree)
case PackageStatPlaceholder(tree, _, DotDot) => reifyPackageStat(tree)
-
+ case ForEnumPlaceholder(tree, _, DotDot) => tree
case List(Placeholder(tree, _, DotDotDot)) => tree
} {
reify(_)
diff --git a/src/eclipse/README.md b/src/eclipse/README.md
index d23e10ca1c..5311651db5 100644
--- a/src/eclipse/README.md
+++ b/src/eclipse/README.md
@@ -70,7 +70,12 @@ and Eclipse .classpath of the different projects isn’t updated accordingly. Th
the build path of each project and make sure the version of the declared dependencies is in sync with the version
declared in the `version.properties` file. If it isn’t, update it manually and, when done, don’t forget to share
your changes via a pull request.
-(We are aware this is manual process is cumbersome. If you feel like scripting this process, pull requests are of course welcome.)
+(We are aware this is cumbersome. If you feel like scripting the process, pull requests are of course welcome.)
+
+Launching & Debugging scalac
+============================
+
+Read [here](http://scala-ide.org/docs/tutorials/scalac-trunk/index.html#Launching_and_Debugging_scalac).
DETAILS
=======
diff --git a/src/eclipse/partest/.classpath b/src/eclipse/partest/.classpath
index abe92cebb5..35528a276d 100644
--- a/src/eclipse/partest/.classpath
+++ b/src/eclipse/partest/.classpath
@@ -5,7 +5,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
<classpathentry kind="var" path="M2_REPO/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-tools/testing/test-interface/0.5/test-interface-0.5.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M5/1.0-RC5/scala-partest_2.11.0-M5-1.0-RC5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M7/1.0.0-RC8/scala-partest_2.11.0-M7-1.0.0-RC8.jar"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_COMPILER_CONTAINER"/>
diff --git a/src/eclipse/scaladoc/.classpath b/src/eclipse/scaladoc/.classpath
index c5b8a02c0b..c8f0e89b8a 100644
--- a/src/eclipse/scaladoc/.classpath
+++ b/src/eclipse/scaladoc/.classpath
@@ -6,8 +6,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
<classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11.0-M5/1.0-RC4/scala-xml_2.11.0-M5-1.0-RC4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11.0-M5/1.0-RC2/scala-parser-combinators_2.11.0-M5-1.0-RC2.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M5/1.0-RC5/scala-partest_2.11.0-M5-1.0-RC5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11.0-M7/1.0.0-RC7/scala-xml_2.11.0-M7-1.0.0-RC7.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11.0-M7/1.0.0-RC5/scala-parser-combinators_2.11.0-M7-1.0.0-RC5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M7/1.0.0-RC8/scala-partest_2.11.0-M7-1.0.0-RC8.jar"/>
<classpathentry kind="output" path="build-quick-scaladoc"/>
</classpath>
diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
index d036a6e853..69cae24808 100644
--- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
@@ -62,17 +62,6 @@ trait CompilerControl { self: Global =>
def onUnitOf[T](source: SourceFile)(op: RichCompilationUnit => T): T =
op(unitOfFile.getOrElse(source.file, new RichCompilationUnit(source)))
- /** The compilation unit corresponding to a source file
- * if it does not yet exist create a new one atomically
- * Note: We want to get roid of this operation as it messes compiler invariants.
- */
- @deprecated("use getUnitOf(s) or onUnitOf(s) instead", "2.10.0")
- def unitOf(s: SourceFile): RichCompilationUnit = getOrCreateUnitOf(s)
-
- /** The compilation unit corresponding to a position */
- @deprecated("use getUnitOf(pos.source) or onUnitOf(pos.source) instead", "2.10.0")
- def unitOf(pos: Position): RichCompilationUnit = getOrCreateUnitOf(pos.source)
-
/** Removes the CompilationUnit corresponding to the given SourceFile
* from consideration for recompilation.
*/
@@ -229,18 +218,6 @@ trait CompilerControl { self: Global =>
def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) =
postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response))
- /** Set sync var `response` to a pair consisting of
- * - the fully qualified name of the first top-level object definition in the file.
- * or "" if there are no object definitions.
- * - the text of the instrumented program which, when run,
- * prints its output and all defined values in a comment column.
- *
- * @param source The source file to be analyzed
- * @param response The response.
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def askInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) =
- postWorkItem(new AskInstrumentedItem(source, line, response))
/** Cancels current compiler run and start a fresh one where everything will be re-typechecked
* (but not re-loaded).
@@ -250,11 +227,6 @@ trait CompilerControl { self: Global =>
/** Tells the compile server to shutdown, and not to restart again */
def askShutdown() = scheduler raise ShutdownReq
- @deprecated("use parseTree(source) instead", "2.10.0") // deleted 2nd parameter, as this has to run on 2.8 also.
- def askParse(source: SourceFile, response: Response[Tree]) = respond(response) {
- parseTree(source)
- }
-
/** Returns parse tree for source `source`. No symbols are entered. Syntax errors are reported.
*
* This method is thread-safe and as such can safely run outside of the presentation
@@ -419,15 +391,6 @@ trait CompilerControl { self: Global =>
response raise new MissingResponse
}
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- case class AskInstrumentedItem(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) extends WorkItem {
- def apply() = self.getInstrumented(source, line, response)
- override def toString = "getInstrumented "+source
-
- def raiseMissing() =
- response raise new MissingResponse
- }
-
/** A do-nothing work scheduler that responds immediately with MissingResponse.
*
* Used during compiler shutdown.
diff --git a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
index 93ef4c4d6c..4f67a22b8f 100644
--- a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
+++ b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala
@@ -6,6 +6,7 @@ package scala.tools.nsc
package interactive
import scala.collection.mutable.ArrayBuffer
+import scala.annotation.tailrec
trait ContextTrees { self: Global =>
@@ -28,44 +29,59 @@ trait ContextTrees { self: Global =>
override def toString = "ContextTree("+pos+", "+children+")"
}
- /** Optionally returns the smallest context that contains given `pos`, or None if none exists.
+ /** Returns the most precise context possible for the given `pos`.
+ *
+ * It looks for the finest ContextTree containing `pos`, and then look inside
+ * this ContextTree for a child ContextTree located immediately before `pos`.
+ * If such a child exists, returns its context, otherwise returns the context of
+ * the parent ContextTree.
+ *
+ * This is required to always return a context which contains the all the imports
+ * declared up to `pos` (see SI-7280 for a test case).
+ *
+ * Can return None if `pos` is before any valid Scala code.
*/
def locateContext(contexts: Contexts, pos: Position): Option[Context] = synchronized {
- def locateNearestContextTree(contexts: Contexts, pos: Position, recent: Array[ContextTree]): Option[ContextTree] = {
- locateContextTree(contexts, pos) match {
- case Some(x) =>
- recent(0) = x
- locateNearestContextTree(x.children, pos, recent)
- case None => recent(0) match {
- case null => None
- case x => Some(x)
- }
+ @tailrec
+ def locateFinestContextTree(context: ContextTree): ContextTree = {
+ if (context.pos includes pos) {
+ locateContextTree(context.children, pos) match {
+ case Some(x) =>
+ locateFinestContextTree(x)
+ case None =>
+ context
+ }
+ } else {
+ context
}
}
- locateNearestContextTree(contexts, pos, new Array[ContextTree](1)) map (_.context)
+ locateContextTree(contexts, pos) map locateFinestContextTree map (_.context)
}
+ /** Returns the ContextTree containing `pos`, or the ContextTree positioned just before `pos`,
+ * or None if `pos` is located before all ContextTrees.
+ */
def locateContextTree(contexts: Contexts, pos: Position): Option[ContextTree] = {
if (contexts.isEmpty) None
else {
- val hi = contexts.length - 1
- if ((contexts(hi).pos properlyPrecedes pos) || (pos properlyPrecedes contexts(0).pos)) None
- else {
- def loop(lo: Int, hi: Int): Option[ContextTree] = {
+ @tailrec
+ def loop(lo: Int, hi: Int, previousSibling: Option[ContextTree]): Option[ContextTree] = {
+ if (pos properlyPrecedes contexts(lo).pos)
+ previousSibling
+ else if (contexts(hi).pos properlyPrecedes pos)
+ Some(contexts(hi))
+ else {
val mid = (lo + hi) / 2
val midpos = contexts(mid).pos
- if ((pos precedes midpos) && (mid < hi))
- loop(lo, mid)
- else if ((midpos precedes pos) && (lo < mid))
- loop(mid, hi)
- else if (midpos includes pos)
+ if (midpos includes pos)
Some(contexts(mid))
- else if (contexts(mid+1).pos includes pos)
- Some(contexts(mid+1))
- else None
+ else if (midpos properlyPrecedes pos)
+ loop(mid + 1, hi, Some(contexts(mid)))
+ else
+ loop(lo, mid, previousSibling)
}
- loop(0, hi)
}
+ loop(0, contexts.length - 1, None)
}
}
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 736a1e68c4..441398e443 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -13,12 +13,12 @@ import scala.tools.nsc.io.AbstractFile
import scala.reflect.internal.util.{ SourceFile, BatchSourceFile, Position, NoPosition }
import scala.tools.nsc.reporters._
import scala.tools.nsc.symtab._
-import scala.tools.nsc.doc.ScaladocAnalyzer
import scala.tools.nsc.typechecker.Analyzer
import symtab.Flags.{ACCESSOR, PARAMACCESSOR}
import scala.annotation.{ elidable, tailrec }
import scala.language.implicitConversions
import scala.tools.nsc.typechecker.Typers
+import scala.util.control.Breaks._
/**
* This trait allows the IDE to have an instance of the PC that
@@ -32,13 +32,6 @@ trait CommentPreservingTypers extends Typers {
override def resetDocComments() = {}
}
-trait InteractiveScaladocAnalyzer extends InteractiveAnalyzer with ScaladocAnalyzer {
- val global : Global
- override def newTyper(context: Context) = new Typer(context) with InteractiveTyper with ScaladocTyper {
- override def canAdaptConstantTypeToLiteral = false
- }
-}
-
trait InteractiveAnalyzer extends Analyzer {
val global : Global
import global._
@@ -108,7 +101,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
with CompilerControl
with ContextTrees
with RichCompilationUnits
- with ScratchPadMaker
with Picklers {
import definitions._
@@ -414,85 +406,91 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
*
*/
private[interactive] def pollForWork(pos: Position) {
- if (!interruptsEnabled) return
- if (pos == NoPosition || nodesSeen % yieldPeriod == 0)
- Thread.`yield`()
-
- def nodeWithWork(): Option[WorkEvent] =
- if (scheduler.moreWork || pendingResponse.isCancelled) Some(new WorkEvent(nodesSeen, System.currentTimeMillis))
- else None
-
- nodesSeen += 1
- logreplay("atnode", nodeWithWork()) match {
- case Some(WorkEvent(id, _)) =>
- debugLog("some work at node "+id+" current = "+nodesSeen)
-// assert(id >= nodesSeen)
- moreWorkAtNode = id
- case None =>
- }
+ var loop: Boolean = true
+ while (loop) {
+ breakable{
+ loop = false
+ if (!interruptsEnabled) return
+ if (pos == NoPosition || nodesSeen % yieldPeriod == 0)
+ Thread.`yield`()
+
+ def nodeWithWork(): Option[WorkEvent] =
+ if (scheduler.moreWork || pendingResponse.isCancelled) Some(new WorkEvent(nodesSeen, System.currentTimeMillis))
+ else None
+
+ nodesSeen += 1
+ logreplay("atnode", nodeWithWork()) match {
+ case Some(WorkEvent(id, _)) =>
+ debugLog("some work at node "+id+" current = "+nodesSeen)
+ // assert(id >= nodesSeen)
+ moreWorkAtNode = id
+ case None =>
+ }
- if (nodesSeen >= moreWorkAtNode) {
-
- logreplay("asked", scheduler.pollInterrupt()) match {
- case Some(ir) =>
- try {
- interruptsEnabled = false
- debugLog("ask started"+timeStep)
- ir.execute()
- } finally {
- debugLog("ask finished"+timeStep)
- interruptsEnabled = true
+ if (nodesSeen >= moreWorkAtNode) {
+
+ logreplay("asked", scheduler.pollInterrupt()) match {
+ case Some(ir) =>
+ try {
+ interruptsEnabled = false
+ debugLog("ask started"+timeStep)
+ ir.execute()
+ } finally {
+ debugLog("ask finished"+timeStep)
+ interruptsEnabled = true
+ }
+ loop = true; break
+ case _ =>
}
- pollForWork(pos)
- case _ =>
- }
-
- if (logreplay("cancelled", pendingResponse.isCancelled)) {
- throw CancelException
- }
-
- logreplay("exception thrown", scheduler.pollThrowable()) match {
- case Some(ex: FreshRunReq) =>
- newTyperRun()
- minRunId = currentRunId
- demandNewCompilerRun()
-
- case Some(ShutdownReq) =>
- scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
- val units = scheduler.dequeueAll {
- case item: WorkItem => Some(item.raiseMissing())
- case _ => Some(())
- }
-
- // don't forget to service interrupt requests
- scheduler.dequeueAllInterrupts(_.execute())
- debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size))
- debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)"
- .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size))
- checkNoResponsesOutstanding()
-
- log.flush()
- scheduler = new NoWorkScheduler
- throw ShutdownReq
+ if (logreplay("cancelled", pendingResponse.isCancelled)) {
+ throw CancelException
}
- case Some(ex: Throwable) => log.flush(); throw ex
- case _ =>
- }
-
- lastWasReload = false
+ logreplay("exception thrown", scheduler.pollThrowable()) match {
+ case Some(ex: FreshRunReq) =>
+ newTyperRun()
+ minRunId = currentRunId
+ demandNewCompilerRun()
+
+ case Some(ShutdownReq) =>
+ scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
+ val units = scheduler.dequeueAll {
+ case item: WorkItem => Some(item.raiseMissing())
+ case _ => Some(())
+ }
+
+ // don't forget to service interrupt requests
+ scheduler.dequeueAllInterrupts(_.execute())
+
+ debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size))
+ debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)"
+ .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size))
+ checkNoResponsesOutstanding()
+
+ log.flush()
+ scheduler = new NoWorkScheduler
+ throw ShutdownReq
+ }
+
+ case Some(ex: Throwable) => log.flush(); throw ex
+ case _ =>
+ }
- logreplay("workitem", scheduler.nextWorkItem()) match {
- case Some(action) =>
- try {
- debugLog("picked up work item at "+pos+": "+action+timeStep)
- action()
- debugLog("done with work item: "+action)
- } finally {
- debugLog("quitting work item: "+action+timeStep)
+ lastWasReload = false
+
+ logreplay("workitem", scheduler.nextWorkItem()) match {
+ case Some(action) =>
+ try {
+ debugLog("picked up work item at "+pos+": "+action+timeStep)
+ action()
+ debugLog("done with work item: "+action)
+ } finally {
+ debugLog("quitting work item: "+action+timeStep)
+ }
+ case None =>
}
- case None =>
+ }
}
}
}
@@ -1064,8 +1062,15 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
case t => t
}
val context = doLocateContext(pos)
+
+ val shouldTypeQualifier = tree0.tpe match {
+ case null => true
+ case mt: MethodType => mt.isImplicit
+ case _ => false
+ }
+
// TODO: guard with try/catch to deal with ill-typed qualifiers.
- val tree = if (tree0.tpe eq null) analyzer newTyper context typedQualifier tree0 else tree0
+ val tree = if (shouldTypeQualifier) analyzer newTyper context typedQualifier tree0 else tree0
debugLog("typeMembers at "+tree+" "+tree.tpe)
val superAccess = tree.isInstanceOf[Super]
@@ -1172,18 +1177,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
}
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def getInstrumented(source: SourceFile, line: Int, response: Response[(String, Array[Char])]) {
- try {
- interruptsEnabled = false
- respond(response) {
- instrument(source, line)
- }
- } finally {
- interruptsEnabled = true
- }
- }
-
// ---------------- Helper classes ---------------------------
/** The typer run */
@@ -1239,4 +1232,3 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
object CancelException extends Exception
-
diff --git a/src/interactive/scala/tools/nsc/interactive/REPL.scala b/src/interactive/scala/tools/nsc/interactive/REPL.scala
index 33981771ec..8e9b0ceee0 100644
--- a/src/interactive/scala/tools/nsc/interactive/REPL.scala
+++ b/src/interactive/scala/tools/nsc/interactive/REPL.scala
@@ -9,7 +9,6 @@ package interactive
import scala.reflect.internal.util._
import scala.tools.nsc.reporters._
import scala.tools.nsc.io._
-import scala.tools.nsc.scratchpad.SourceInserter
import java.io.FileWriter
/** Interface of interactive compiler to a client such as an IDE
@@ -89,8 +88,6 @@ object REPL {
val completeResult = new Response[List[comp.Member]]
val typedResult = new Response[comp.Tree]
val structureResult = new Response[comp.Tree]
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- val instrumentedResult = new Response[(String, Array[Char])]
def makePos(file: String, off1: String, off2: String) = {
val source = toSourceFile(file)
@@ -112,52 +109,6 @@ object REPL {
show(structureResult)
}
- /** Write instrumented source file to disk.
- * @param iFullName The full name of the first top-level object in source
- * @param iContents An Array[Char] containing the instrumented source
- * @return The name of the instrumented source file
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def writeInstrumented(iFullName: String, suffix: String, iContents: Array[Char]): String = {
- val iSimpleName = iFullName drop ((iFullName lastIndexOf '.') + 1)
- val iSourceName = iSimpleName + suffix
- val ifile = new FileWriter(iSourceName)
- ifile.write(iContents)
- ifile.close()
- iSourceName
- }
-
- /** The method for implementing worksheet functionality.
- * @param arguments a file name, followed by optional command line arguments that are passed
- * to the compiler that processes the instrumented source.
- * @param line A line number that controls uop to which line results should be produced
- * If line = -1, results are produced for all expressions in the worksheet.
- * @return The generated file content containing original source in the left column
- * and outputs in the right column, or None if the presentation compiler
- * does not respond to askInstrumented.
- */
- @deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
- def instrument(arguments: List[String], line: Int): Option[(String, String)] = {
- val source = toSourceFile(arguments.head)
- // strip right hand side comment column and any trailing spaces from all lines
- val strippedContents = SourceInserter.stripRight(source.content)
- val strippedSource = new BatchSourceFile(source.file, strippedContents)
- println("stripped source = "+strippedSource+":"+strippedContents.mkString)
- comp.askReload(List(strippedSource), reloadResult)
- comp.askInstrumented(strippedSource, line, instrumentedResult)
- using(instrumentedResult) {
- case (iFullName, iContents) =>
- println(s"instrumented source $iFullName = ${iContents.mkString}")
- val iSourceName = writeInstrumented(iFullName, "$instrumented.scala", iContents)
- val sSourceName = writeInstrumented(iFullName, "$stripped.scala", strippedContents)
- (iSourceName, sSourceName)
-/*
- * val vdirOpt = compileInstrumented(iSourceName, arguments.tail)
- runInstrumented(vdirOpt, iFullName, strippedSource.content)
- */
- }
- }
-
loop { line =>
(line split " ").toList match {
case "reload" :: args =>
@@ -177,10 +128,6 @@ object REPL {
doComplete(makePos(file, off1, off2))
case List("complete", file, off1) =>
doComplete(makePos(file, off1, off1))
- case "instrument" :: arguments =>
- println(instrument(arguments, -1))
- case "instrumentTo" :: line :: arguments =>
- println(instrument(arguments, line.toInt))
case List("quit") =>
comp.askShutdown()
sys.exit(1)
@@ -195,8 +142,6 @@ object REPL {
| typeat <file> <pos>
| complete <file> <start-pos> <end-pos>
| compile <file> <pos>
- | instrument <file> <arg>*
- | instrumentTo <line-num> <file> <arg>*
| structure <file>
| quit
|""".stripMargin)
diff --git a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala
deleted file mode 100644
index 2400b97d97..0000000000
--- a/src/interactive/scala/tools/nsc/interactive/ScratchPadMaker.scala
+++ /dev/null
@@ -1,201 +0,0 @@
-package scala
-package tools.nsc
-package interactive
-
-import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition}
-import scala.collection.mutable.ArrayBuffer
-import scala.reflect.internal.Chars.{isLineBreakChar, isWhitespace}
-import ast.parser.Tokens._
-
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-trait ScratchPadMaker { self: Global =>
-
- import definitions._
-
- private case class Patch(offset: Int, text: String)
-
- private class Patcher(contents: Array[Char], lex: LexicalStructure, endOffset: Int) extends Traverser {
- var objectName: String = ""
-
- private val patches = new ArrayBuffer[Patch]
- private val toPrint = new ArrayBuffer[String]
- private var skipped = 0
- private var resNum: Int = -1
-
- private def nextRes(): String = {
- resNum += 1
- "res$"+resNum
- }
-
- private def nameType(name: String, tpe: Type): String = {
- // if name ends in symbol character, add a space to separate it from the following ':'
- val pad = if (Character.isLetter(name.last) || Character.isDigit(name.last)) "" else " "
- name+pad+": "+tpe
- }
-
- private def nameType(sym: Symbol): String = nameType(sym.name.decoded, sym.tpe)
-
- private def literal(str: String) = "\"\"\""+str+"\"\"\""
-
- private val prologue = ";import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{"
-
- private val epilogue = "}"
-
- private def applyPendingPatches(offset: Int) = {
- if (skipped == 0) patches += Patch(offset, prologue)
- for (msg <- toPrint) patches += Patch(offset, ";System.out.println("+msg+")")
- toPrint.clear()
- }
-
- /** The position where to insert an instrumentation statement in front of given statement.
- * This is at the latest `stat.pos.start`. But in order not to mess with column numbers
- * in position we try to insert it at the end of the previous token instead.
- * Furthermore, `(' tokens have to be skipped because they do not show up
- * in statement range positions.
- */
- private def instrumentPos(start: Int): Int = {
- val (prevToken, prevStart, prevEnd) = lex.locate(start - 1)
- if (prevStart >= start) start
- else if (prevToken == LPAREN) instrumentPos(prevStart)
- else prevEnd
- }
-
- private def addSkip(stat: Tree): Unit = {
- val ipos = instrumentPos(stat.pos.start)
- if (stat.pos.start > skipped) applyPendingPatches(ipos)
- if (stat.pos.start >= endOffset)
- patches += Patch(ipos, ";$stop()")
- var end = stat.pos.end
- if (end > skipped) {
- while (end < contents.length && !isLineBreakChar(contents(end))) end += 1
- patches += Patch(ipos, ";$skip("+(end-skipped)+"); ")
- skipped = end
- }
- }
-
- private def addSandbox(expr: Tree) = {}
-// patches += (Patch(expr.pos.start, "sandbox("), Patch(expr.pos.end, ")"))
-
- private def resultString(prefix: String, expr: String) =
- literal(prefix + " = ") + " + $show(" + expr + ")"
-
- private def traverseStat(stat: Tree) =
- if (stat.pos.isInstanceOf[RangePosition]) {
- stat match {
- case ValDef(_, _, _, rhs) =>
- addSkip(stat)
- if (stat.symbol.isLazy)
- toPrint += literal(nameType(stat.symbol) + " = <lazy>")
- else if (!stat.symbol.isSynthetic) {
- addSandbox(rhs)
- toPrint += resultString(nameType(stat.symbol), stat.symbol.name.toString)
- }
- case DefDef(_, _, _, _, _, _) =>
- addSkip(stat)
- toPrint += literal(nameType(stat.symbol))
- case Annotated(_, arg) =>
- traverse(arg)
- case DocDef(_, defn) =>
- traverse(defn)
- case _ =>
- if (stat.isTerm) {
- addSkip(stat)
- if (stat.tpe.typeSymbol == UnitClass) {
- addSandbox(stat)
- } else {
- val resName = nextRes()
- val dispResName = resName filter ('$' != _)
- val offset = instrumentPos(stat.pos.start)
- patches += Patch(offset, "val " + resName + " = ")
- addSandbox(stat)
- toPrint += resultString(nameType(dispResName, stat.tpe), resName)
- }
- }
- }
- }
-
- override def traverse(tree: Tree): Unit = tree match {
- case PackageDef(_, _) =>
- super.traverse(tree)
- case ModuleDef(_, name, Template(_, _, body)) =>
- val topLevel = objectName.isEmpty
- if (topLevel) {
- objectName = tree.symbol.fullName
- body foreach traverseStat
- if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements
- applyPendingPatches(skipped)
- patches += Patch(skipped, epilogue)
- }
- }
- case _ =>
- }
-
- /** The patched text.
- * @require traverse is run first
- */
- def result: Array[Char] = {
- val reslen = contents.length + (patches map (_.text.length)).sum
- val res = Array.ofDim[Char](reslen)
- var lastOffset = 0
- var from = 0
- var to = 0
- for (Patch(offset, text) <- patches) {
- val delta = offset - lastOffset
- assert(delta >= 0)
- Array.copy(contents, from, res, to, delta)
- from += delta
- to += delta
- lastOffset = offset
- text.copyToArray(res, to)
- to += text.length
- }
- assert(contents.length - from == reslen - to)
- Array.copy(contents, from, res, to, contents.length - from)
- res
- }
- }
-
- class LexicalStructure(source: SourceFile) {
- val token = new ArrayBuffer[Int]
- val startOffset = new ArrayBuffer[Int]
- val endOffset = new ArrayBuffer[Int]
- private val scanner = new syntaxAnalyzer.UnitScanner(new CompilationUnit(source))
- scanner.init()
- while (scanner.token != EOF) {
- startOffset += scanner.offset
- token += scanner.token
- scanner.nextToken()
- endOffset += scanner.lastOffset
- }
-
- /** @return token that starts before or at offset, its startOffset, its endOffset
- */
- def locate(offset: Int): (Int, Int, Int) = {
- var lo = 0
- var hi = token.length - 1
- while (lo < hi) {
- val mid = (lo + hi + 1) / 2
- if (startOffset(mid) <= offset) lo = mid
- else hi = mid - 1
- }
- (token(lo), startOffset(lo), endOffset(lo))
- }
- }
-
- /** Compute an instrumented version of a sourcefile.
- * @param source The given sourcefile.
- * @param line The line up to which results should be printed, -1 = whole document.
- * @return A pair consisting of
- * - the fully qualified name of the first top-level object definition in the file.
- * or "" if there are no object definitions.
- * - the text of the instrumented program which, when run,
- * prints its output and all defined values in a comment column.
- */
- protected def instrument(source: SourceFile, line: Int): (String, Array[Char]) = {
- val tree = typedTree(source, forceReload = true)
- val endOffset = if (line < 0) source.length else source.lineToOffset(line + 1)
- val patcher = new Patcher(source.content, new LexicalStructure(source), endOffset)
- patcher.traverse(tree)
- (patcher.objectName, patcher.result)
- }
-}
diff --git a/src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala
index f30d896fb7..2cb4f5fd4a 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala
@@ -61,7 +61,7 @@ abstract class InteractiveTest
* Override this member if you need to change the default set of executed test actions.
*/
protected lazy val testActions: ListBuffer[PresentationCompilerTestDef] = {
- ListBuffer(new CompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
+ ListBuffer(new TypeCompletionAction(compiler), new ScopeCompletionAction(compiler), new TypeAction(compiler), new HyperlinkAction(compiler))
}
/** Add new presentation compiler actions to test. Presentation compiler's test
diff --git a/src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala
index 8d446cbbf8..4f9df6808f 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/core/AskCommand.scala
@@ -42,7 +42,7 @@ trait AskParse extends AskCommand {
import compiler.Tree
/** `sources` need to be entirely parsed before running the test
- * (else commands such as `AskCompletionAt` may fail simply because
+ * (else commands such as `AskTypeCompletionAt` may fail simply because
* the source's AST is not yet loaded).
*/
def askParse(sources: Seq[SourceFile]) {
@@ -72,10 +72,10 @@ trait AskReload extends AskCommand {
}
/** Ask the presentation compiler for completion at a given position. */
-trait AskCompletionAt extends AskCommand {
+trait AskTypeCompletionAt extends AskCommand {
import compiler.Member
- private[tests] def askCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ private[tests] def askTypeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
reporter.println("\naskTypeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
ask {
@@ -84,6 +84,19 @@ trait AskCompletionAt extends AskCommand {
}
}
+/** Ask the presentation compiler for scope completion at a given position. */
+trait AskScopeCompletionAt extends AskCommand {
+ import compiler.Member
+
+ private[tests] def askScopeCompletionAt(pos: Position)(implicit reporter: Reporter): Response[List[Member]] = {
+ reporter.println("\naskScopeCompletion at " + pos.source.file.name + ((pos.line, pos.column)))
+
+ ask {
+ compiler.askScopeCompletion(pos, _)
+ }
+ }
+}
+
/** Ask the presentation compiler for type info at a given position. */
trait AskTypeAt extends AskCommand {
import compiler.Tree
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 e28bf20745..bc490d8d45 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
@@ -12,16 +12,16 @@ private[tests] trait CoreTestDefs
/** Ask the presentation compiler for completion at all locations
* (in all sources) where the defined `marker` is found. */
- class CompletionAction(override val compiler: Global)
+ class TypeCompletionAction(override val compiler: Global)
extends PresentationCompilerTestDef
- with AskCompletionAt {
+ with AskTypeCompletionAt {
override def runTest() {
- askAllSources(CompletionMarker) { pos =>
- askCompletionAt(pos)
+ askAllSources(TypeCompletionMarker) { pos =>
+ askTypeCompletionAt(pos)
} { (pos, members) =>
withResponseDelimiter {
- reporter.println("[response] askCompletionAt " + format(pos))
+ reporter.println("[response] askTypeCompletion at " + format(pos))
// we skip getClass because it changed signature between 1.5 and 1.6, so there is no
// universal check file that we can provide for this to work
reporter.println("retrieved %d members".format(members.size))
@@ -34,6 +34,37 @@ private[tests] trait CoreTestDefs
}
}
+ /** Ask the presentation compiler for completion at all locations
+ * (in all sources) where the defined `marker` is found. */
+ class ScopeCompletionAction(override val compiler: Global)
+ extends PresentationCompilerTestDef
+ with AskScopeCompletionAt {
+
+ override def runTest() {
+ askAllSources(ScopeCompletionMarker) { pos =>
+ askScopeCompletionAt(pos)
+ } { (pos, members) =>
+ withResponseDelimiter {
+ reporter.println("[response] askScopeCompletion at " + format(pos))
+ try {
+ // exclude members not from source (don't have position), for more focused and self contained tests.
+ def eligible(sym: compiler.Symbol) = sym.pos != compiler.NoPosition
+ val filtered = members.filter(member => eligible(member.sym))
+
+ reporter.println("retrieved %d members".format(filtered.size))
+ compiler ask { () =>
+ reporter.println(filtered.map(_.forceInfoString).sorted mkString "\n")
+ }
+ } catch {
+ case t: Throwable =>
+ t.printStackTrace()
+ }
+
+ }
+ }
+ }
+ }
+
/** Ask the presentation compiler for type info at all locations
* (in all sources) where the defined `marker` is found. */
class TypeAction(override val compiler: Global)
@@ -57,7 +88,7 @@ private[tests] trait CoreTestDefs
class HyperlinkAction(override val compiler: Global)
extends PresentationCompilerTestDef
with AskTypeAt
- with AskCompletionAt {
+ with AskTypeCompletionAt {
override def runTest() {
askAllSources(HyperlinkMarker) { pos =>
diff --git a/src/interactive/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala b/src/interactive/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala
index 9a2abd5139..29e546f9fe 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala
@@ -7,22 +7,16 @@ import reporters.{Reporter => CompilerReporter}
/** Trait encapsulating the creation of a presentation compiler's instance.*/
private[tests] trait PresentationCompilerInstance extends TestSettings {
protected val settings = new Settings
- protected val withDocComments = false
protected val compilerReporter: CompilerReporter = new InteractiveReporter {
override def compiler = PresentationCompilerInstance.this.compiler
}
- private class ScaladocEnabledGlobal extends Global(settings, compilerReporter) {
- override lazy val analyzer = new {
- val global: ScaladocEnabledGlobal.this.type = ScaladocEnabledGlobal.this
- } with InteractiveScaladocAnalyzer
- }
+ protected def createGlobal: Global = new Global(settings, compilerReporter)
protected lazy val compiler: Global = {
prepareSettings(settings)
- if (withDocComments) new ScaladocEnabledGlobal
- else new Global(settings, compilerReporter)
+ createGlobal
}
/**
diff --git a/src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala b/src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala
index a5c228a549..3f9b40277c 100644
--- a/src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala
+++ b/src/interactive/scala/tools/nsc/interactive/tests/core/TestMarker.scala
@@ -20,7 +20,9 @@ abstract case class TestMarker(marker: String) {
TestMarker.checkForDuplicate(this)
}
-object CompletionMarker extends TestMarker("/*!*/")
+object TypeCompletionMarker extends TestMarker("/*!*/")
+
+object ScopeCompletionMarker extends TestMarker("/*_*/")
object TypeMarker extends TestMarker("/*?*/")
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index cd96b5182c..8900450fa3 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -26,8 +26,6 @@ import scala.io.ReadStdin
* [[scala.collection.immutable.Set]], and the [[scala.collection.immutable.List]]
* constructors ([[scala.collection.immutable.::]] and
* [[scala.collection.immutable.Nil]]).
- * The types `Pair` (a [[scala.Tuple2]]) and `Triple` (a [[scala.Tuple3]]), with
- * simple constructors, are also provided.
*
* === Console I/O ===
* Predef provides a number of simple functions for console I/O, such as
@@ -230,13 +228,17 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
// tupling ------------------------------------------------------------
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
type Pair[+A, +B] = Tuple2[A, B]
+ @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0")
object Pair {
def apply[A, B](x: A, y: B) = Tuple2(x, y)
def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
}
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
type Triple[+A, +B, +C] = Tuple3[A, B, C]
+ @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0")
object Triple {
def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z)
def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala
index 0a42ddb0ea..8a658e252a 100644
--- a/src/library/scala/Responder.scala
+++ b/src/library/scala/Responder.scala
@@ -18,6 +18,7 @@ package scala
* @see class Responder
* @since 2.1
*/
+@deprecated("This object will be removed", "2.11.0")
object Responder {
/** Creates a responder that answer continuations with the constant `a`.
@@ -58,6 +59,7 @@ object Responder {
* @version 1.0
* @since 2.1
*/
+@deprecated("This class will be removed", "2.11.0")
abstract class Responder[+A] extends Serializable {
def respond(k: A => Unit): Unit
diff --git a/src/library/scala/annotation/migration.scala b/src/library/scala/annotation/migration.scala
index 65bee4c2cb..e71be00f32 100644
--- a/src/library/scala/annotation/migration.scala
+++ b/src/library/scala/annotation/migration.scala
@@ -25,7 +25,4 @@ package scala.annotation
*
* @since 2.8
*/
- private[scala] final class migration(message: String, changedIn: String) extends scala.annotation.StaticAnnotation {
- @deprecated("Use the constructor taking two Strings instead.", "2.10.0")
- def this(majorVersion: Int, minorVersion: Int, message: String) = this(message, majorVersion + "." + minorVersion)
- }
+ private[scala] final class migration(message: String, changedIn: String) extends scala.annotation.StaticAnnotation
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index 07e2ddaae2..8991d0b75a 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -213,7 +213,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
}
/**
- * Loop over the keys of the map. The same as `keys.foreach(f)`, but may
+ * Loop over the values of the map. The same as `values.foreach(f)`, but may
* be more efficient.
*
* @param f The loop body
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index 506546c5ba..868c0c0f47 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -205,7 +205,7 @@ extends AbstractMap[Long, T]
}
/**
- * Loop over the keys of the map. The same as keys.foreach(f), but may
+ * Loop over the values of the map. The same as values.foreach(f), but may
* be more efficient.
*
* @param f The loop body
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 34b2346851..00f398a4b0 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -117,22 +117,6 @@ extends scala.collection.AbstractSeq[Int]
fail()
}
- @deprecated("Range.foreach() is now self-contained, making this auxiliary method redundant.", "2.10.1")
- def validateRangeBoundaries(f: Int => Any): Boolean = {
- validateMaxLength()
-
- start != Int.MinValue || end != Int.MinValue || {
- var count = 0
- var num = start
- while (count < numRangeElements) {
- f(num)
- count += 1
- num += step
- }
- false
- }
- }
-
final def apply(idx: Int): Int = {
validateMaxLength()
if (idx < 0 || idx >= numRangeElements) throw new IndexOutOfBoundsException(idx.toString)
diff --git a/src/library/scala/collection/mutable/AnyRefMap.scala b/src/library/scala/collection/mutable/AnyRefMap.scala
new file mode 100644
index 0000000000..df74bb5187
--- /dev/null
+++ b/src/library/scala/collection/mutable/AnyRefMap.scala
@@ -0,0 +1,451 @@
+package scala
+package collection
+package mutable
+
+import generic.CanBuildFrom
+
+/** This class implements mutable maps with `AnyRef` keys based on a hash table with open addressing.
+ *
+ * Basic map operations on single entries, including `contains` and `get`,
+ * are typically significantly faster with `AnyRefMap` than [[HashMap]].
+ * Note that numbers and characters are not handled specially in AnyRefMap;
+ * only plain `equals` and `hashCode` are used in comparisons.
+ *
+ * Methods that traverse or regenerate the map, including `foreach` and `map`,
+ * are not in general faster than with `HashMap`. The methods `foreachKey`,
+ * `foreachValue`, `mapValuesNow`, and `transformValues` are, however, faster
+ * than alternative ways to achieve the same functionality.
+ *
+ * Maps with open addressing may become less efficient at lookup after
+ * repeated addition/removal of elements. Although `AnyRefMap` makes a
+ * decent attempt to remain efficient regardless, calling `repack`
+ * on a map that will no longer have elements removed but will be
+ * used heavily may save both time and storage space.
+ *
+ * This map is not indended to contain more than 2^29 entries (approximately
+ * 500 million). The maximum capacity is 2^30, but performance will degrade
+ * rapidly as 2^30 is approached.
+ *
+ */
+final class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K => V, initialBufferSize: Int, initBlank: Boolean)
+extends AbstractMap[K, V]
+ with Map[K, V]
+ with MapLike[K, V, AnyRefMap[K, V]]
+{
+ import AnyRefMap._
+ def this() = this(AnyRefMap.exceptionDefault, 16, true)
+
+ /** Creates a new `AnyRefMap` that returns default values according to a supplied key-value mapping. */
+ def this(defaultEntry: K => V) = this(defaultEntry, 16, true)
+
+ /** Creates a new `AnyRefMap` with an initial buffer of specified size.
+ *
+ * An `AnyRefMap` can typically contain half as many elements as its buffer size
+ * before it requires resizing.
+ */
+ def this(initialBufferSize: Int) = this(AnyRefMap.exceptionDefault, initialBufferSize, true)
+
+ /** Creates a new `AnyRefMap` with specified default values and initial buffer size. */
+ def this(defaultEntry: K => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
+
+ private[this] var mask = 0
+ private[this] var _size = 0
+ private[this] var _vacant = 0
+ private[this] var _hashes: Array[Int] = null
+ private[this] var _keys: Array[AnyRef] = null
+ private[this] var _values: Array[AnyRef] = null
+
+ if (initBlank) defaultInitialize(initialBufferSize)
+
+ private[this] def defaultInitialize(n: Int) {
+ mask =
+ if (n<0) 0x7
+ else (((1 << (32 - java.lang.Integer.numberOfLeadingZeros(n-1))) - 1) & 0x3FFFFFFF) | 0x7
+ _hashes = new Array[Int](mask+1)
+ _keys = new Array[AnyRef](mask+1)
+ _values = new Array[AnyRef](mask+1)
+ }
+
+ private[collection] def initializeTo(
+ m: Int, sz: Int, vc: Int, hz: Array[Int], kz: Array[AnyRef], vz: Array[AnyRef]
+ ) {
+ mask = m; _size = sz; _vacant = vc; _hashes = hz; _keys = kz; _values = vz
+ }
+
+ override def size: Int = _size
+ override def empty: AnyRefMap[K,V] = new AnyRefMap(defaultEntry)
+
+ private def imbalanced: Boolean =
+ (_size + _vacant) > 0.5*mask || _vacant > _size
+
+ private def hashOf(key: K): Int = {
+ if (key eq null) 0x41081989
+ else {
+ val h = key.hashCode
+ // Part of the MurmurHash3 32 bit finalizer
+ val i = (h ^ (h >>> 16)) * 0x85EBCA6B
+ val j = (i ^ (i >>> 13))
+ if (j==0) 0x41081989 else j & 0x7FFFFFFF
+ }
+ }
+
+ private def seekEntry(h: Int, k: AnyRef): Int = {
+ var e = h & mask
+ var x = 0
+ var g = 0
+ while ({ g = _hashes(e); g != 0}) {
+ if (g == h && { val q = _keys(e); (q eq k) || ((q ne null) && (q equals k)) }) return e
+ x += 1
+ e = (e + 2*(x+1)*x - 3) & mask
+ }
+ e | MissingBit
+ }
+
+ private def seekEntryOrOpen(h: Int, k: AnyRef): Int = {
+ var e = h & mask
+ var x = 0
+ var g = 0
+ var o = -1
+ while ({ g = _hashes(e); g != 0}) {
+ if (g == h && { val q = _keys(e); (q eq k) || ((q ne null) && (q equals k)) }) return e
+ else if (o == -1 && g+g == 0) o = e
+ x += 1
+ e = (e + 2*(x+1)*x - 3) & mask
+ }
+ if (o >= 0) o | MissVacant else e | MissingBit
+ }
+
+ override def contains(key: K): Boolean = seekEntry(hashOf(key), key) >= 0
+
+ override def get(key: K): Option[V] = {
+ val i = seekEntry(hashOf(key), key)
+ if (i < 0) None else Some(_values(i).asInstanceOf[V])
+ }
+
+ override def getOrElse[V1 >: V](key: K, default: => V1): V1 = {
+ val i = seekEntry(hashOf(key), key)
+ if (i < 0) default else _values(i).asInstanceOf[V]
+ }
+
+ override def getOrElseUpdate(key: K, defaultValue: => V): V = {
+ val h = hashOf(key)
+ val i = seekEntryOrOpen(h, key)
+ if (i < 0) {
+ val value = defaultValue
+ _size += 1
+ val j = i & IndexMask
+ _hashes(j) = h
+ _keys(j) = key.asInstanceOf[AnyRef]
+ _values(j) = value.asInstanceOf[AnyRef]
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ value
+ }
+ else _values(i).asInstanceOf[V]
+ }
+
+ /** Retrieves the value associated with a key, or the default for that type if none exists
+ * (null for AnyRef, 0 for floats and integers).
+ *
+ * Note: this is the fastest way to retrieve a value that may or
+ * may not exist, if the default null/zero is acceptable. For key/value
+ * pairs that do exist, `apply` (i.e. `map(key)`) is equally fast.
+ */
+ def getOrNull(key: K): V = {
+ val i = seekEntry(hashOf(key), key)
+ (if (i < 0) null else _values(i)).asInstanceOf[V]
+ }
+
+ /** Retrieves the value associated with a key.
+ * If the key does not exist in the map, the `defaultEntry` for that key
+ * will be returned instead; an exception will be thrown if no
+ * `defaultEntry` was supplied.
+ */
+ override def apply(key: K): V = {
+ val i = seekEntry(hashOf(key), key)
+ if (i < 0) defaultEntry(key) else _values(i).asInstanceOf[V]
+ }
+
+ /** Defers to defaultEntry to find a default value for the key. Throws an
+ * exception if no other default behavior was specified.
+ */
+ override def default(key: K) = defaultEntry(key)
+
+ private def repack(newMask: Int) {
+ val oh = _hashes
+ val ok = _keys
+ val ov = _values
+ mask = newMask
+ _hashes = new Array[Int](mask+1)
+ _keys = new Array[AnyRef](mask+1)
+ _values = new Array[AnyRef](mask+1)
+ _vacant = 0
+ var i = 0
+ while (i < oh.length) {
+ val h = oh(i)
+ if (h+h != 0) {
+ var e = h & mask
+ var x = 0
+ while (_hashes(e) != 0) { x += 1; e = (e + 2*(x+1)*x - 3) & mask }
+ _hashes(e) = h
+ _keys(e) = ok(i)
+ _values(e) = ov(i)
+ }
+ i += 1
+ }
+ }
+
+ /** Repacks the contents of this `AnyRefMap` for maximum efficiency of lookup.
+ *
+ * For maps that undergo a complex creation process with both addition and
+ * removal of keys, and then are used heavily with no further removal of
+ * elements, calling `repack` after the end of the creation can result in
+ * improved performance. Repacking takes time proportional to the number
+ * of entries in the map.
+ */
+ def repack() {
+ var m = mask
+ if (_size + _vacant >= 0.5*mask && !(_vacant > 0.2*mask)) m = ((m << 1) + 1) & IndexMask
+ while (m > 8 && 8*_size < m) m = m >>> 1
+ repack(m)
+ }
+
+ override def put(key: K, value: V): Option[V] = {
+ val h = hashOf(key)
+ val k = key
+ var i = seekEntryOrOpen(h, k)
+ if (i < 0) {
+ val j = i & IndexMask
+ _hashes(j) = h
+ _keys(j) = k
+ _values(j) = value.asInstanceOf[AnyRef]
+ _size += 1
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ None
+ }
+ else {
+ val ans = Some(_values(i).asInstanceOf[V])
+ _hashes(i) = h
+ _keys(i) = k
+ _values(i) = value.asInstanceOf[AnyRef]
+ ans
+ }
+ }
+
+ /** Updates the map to include a new key-value pair.
+ *
+ * This is the fastest way to add an entry to an `AnyRefMap`.
+ */
+ override def update(key: K, value: V): Unit = {
+ val h = hashOf(key)
+ val k = key
+ var i = seekEntryOrOpen(h, k)
+ if (i < 0) {
+ val j = i & IndexMask
+ _hashes(j) = h
+ _keys(j) = k
+ _values(j) = value.asInstanceOf[AnyRef]
+ _size += 1
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ }
+ else {
+ _hashes(i) = h
+ _keys(i) = k
+ _values(i) = value.asInstanceOf[AnyRef]
+ }
+ }
+
+ /** Adds a new key/value pair to this map and returns the map. */
+ def +=(key: K, value: V): this.type = { update(key, value); this }
+
+ def +=(kv: (K, V)): this.type = { update(kv._1, kv._2); this }
+
+ def -=(key: K): this.type = {
+ val i = seekEntry(hashOf(key), key)
+ if (i >= 0) {
+ _size -= 1
+ _vacant += 1
+ _hashes(i) = Int.MinValue
+ _keys(i) = null
+ _values(i) = null
+ }
+ this
+ }
+
+ def iterator: Iterator[(K, V)] = new Iterator[(K, V)] {
+ private[this] val hz = _hashes
+ private[this] val kz = _keys
+ private[this] val vz = _values
+
+ private[this] var index = 0
+ private[this] var found = false
+
+ def hasNext = found || (index<hz.length && {
+ var h = hz(index)
+ if (h+h != 0) found = true
+ else {
+ index += 1
+ while (index < hz.length && { h = hz(index); h+h == 0 }) index += 1
+ found = (index < hz.length)
+ }
+ found
+ })
+
+ def next = {
+ if (found || hasNext) {
+ val ans = (_keys(index).asInstanceOf[K], _values(index).asInstanceOf[V])
+ index += 1
+ found = false
+ ans
+ }
+ else throw new NoSuchElementException("next")
+ }
+ }
+
+ override def foreach[A](f: ((K,V)) => A) {
+ var i = 0
+ var e = _size
+ while (e > 0) {
+ while(i < _hashes.length && { val h = _hashes(i); h+h == 0 && i < _hashes.length}) i += 1
+ if (i < _hashes.length) {
+ f((_keys(i).asInstanceOf[K], _values(i).asInstanceOf[V]))
+ i += 1
+ e -= 1
+ }
+ else return
+ }
+ }
+
+ override def clone(): AnyRefMap[K, V] = {
+ val hz = java.util.Arrays.copyOf(_hashes, _hashes.length)
+ val kz = java.util.Arrays.copyOf(_keys, _keys.length)
+ val vz = java.util.Arrays.copyOf(_values, _values.length)
+ val arm = new AnyRefMap[K, V](defaultEntry, 1, false)
+ arm.initializeTo(mask, _size, _vacant, hz, kz, vz)
+ arm
+ }
+
+ private[this] def foreachElement[A,B](elems: Array[AnyRef], f: A => B) {
+ var i,j = 0
+ while (i < _hashes.length & j < _size) {
+ val h = _hashes(i)
+ if (h+h != 0) {
+ j += 1
+ f(elems(i).asInstanceOf[A])
+ }
+ i += 1
+ }
+ }
+
+ /** Applies a function to all keys of this map. */
+ def foreachKey[A](f: K => A) { foreachElement[K,A](_keys, f) }
+
+ /** Applies a function to all values of this map. */
+ def foreachValue[A](f: V => A) { foreachElement[V,A](_values, f) }
+
+ /** Creates a new `AnyRefMap` with different values.
+ * Unlike `mapValues`, this method generates a new
+ * collection immediately.
+ */
+ def mapValuesNow[V1](f: V => V1): AnyRefMap[K, V1] = {
+ val arm = new AnyRefMap[K,V1](AnyRefMap.exceptionDefault, 1, false)
+ val hz = java.util.Arrays.copyOf(_hashes, _hashes.length)
+ val kz = java.util.Arrays.copyOf(_keys, _keys.length)
+ val vz = new Array[AnyRef](_values.length)
+ var i,j = 0
+ while (i < _hashes.length & j < _size) {
+ val h = _hashes(i)
+ if (h+h != 0) {
+ j += 1
+ vz(i) = f(_values(i).asInstanceOf[V]).asInstanceOf[AnyRef]
+ }
+ i += 1
+ }
+ arm.initializeTo(mask, _size, _vacant, hz, kz, vz)
+ arm
+ }
+
+ /** Applies a transformation function to all values stored in this map.
+ * Note: the default, if any, is not transformed.
+ */
+ def transformValues(f: V => V): this.type = {
+ var i,j = 0
+ while (i < _hashes.length & j < _size) {
+ val h = _hashes(i)
+ if (h+h != 0) {
+ j += 1
+ _values(i) = f(_values(i).asInstanceOf[V]).asInstanceOf[AnyRef]
+ }
+ i += 1
+ }
+ this
+ }
+
+}
+
+object AnyRefMap {
+ private final val IndexMask = 0x3FFFFFFF
+ private final val MissingBit = 0x80000000
+ private final val VacantBit = 0x40000000
+ private final val MissVacant = 0xC0000000
+
+ private val exceptionDefault = (k: Any) => throw new NoSuchElementException(if (k == null) "(null)" else k.toString)
+
+ implicit def canBuildFrom[K <: AnyRef, V, J <: AnyRef, U]: CanBuildFrom[AnyRefMap[K,V], (J, U), AnyRefMap[J,U]] =
+ new CanBuildFrom[AnyRefMap[K,V], (J, U), AnyRefMap[J,U]] {
+ def apply(from: AnyRefMap[K,V]): AnyRefMapBuilder[J, U] = apply()
+ def apply(): AnyRefMapBuilder[J, U] = new AnyRefMapBuilder[J, U]
+ }
+
+ final class AnyRefMapBuilder[K <: AnyRef, V] extends Builder[(K, V), AnyRefMap[K, V]] {
+ private[collection] var elems: AnyRefMap[K, V] = new AnyRefMap[K, V]
+ def +=(entry: (K, V)): this.type = {
+ elems += entry
+ this
+ }
+ def clear() { elems = new AnyRefMap[K, V] }
+ def result(): AnyRefMap[K, V] = elems
+ }
+
+ /** Creates a new `AnyRefMap` with zero or more key/value pairs. */
+ def apply[K <: AnyRef, V](elems: (K, V)*): AnyRefMap[K, V] = {
+ val sz = if (elems.hasDefiniteSize) elems.size else 4
+ val arm = new AnyRefMap[K, V](sz * 2)
+ elems.foreach{ case (k,v) => arm(k) = v }
+ if (arm.size < (sz>>3)) arm.repack()
+ arm
+ }
+
+ /** Creates a new empty `AnyRefMap`. */
+ def empty[K <: AnyRef, V]: AnyRefMap[K, V] = new AnyRefMap[K, V]
+
+ /** Creates a new empty `AnyRefMap` with the supplied default */
+ def withDefault[K <: AnyRef, V](default: K => V): AnyRefMap[K, V] = new AnyRefMap[K, V](default)
+
+ /** Creates a new `AnyRefMap` from arrays of keys and values.
+ * Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
+ */
+ def fromZip[K <: AnyRef, V](keys: Array[K], values: Array[V]): AnyRefMap[K, V] = {
+ val sz = math.min(keys.length, values.length)
+ val arm = new AnyRefMap[K, V](sz * 2)
+ var i = 0
+ while (i < sz) { arm(keys(i)) = values(i); i += 1 }
+ if (arm.size < (sz>>3)) arm.repack()
+ arm
+ }
+
+ /** Creates a new `AnyRefMap` from keys and values.
+ * Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
+ */
+ def fromZip[K <: AnyRef, V](keys: Iterable[K], values: Iterable[V]): AnyRefMap[K, V] = {
+ val sz = math.min(keys.size, values.size)
+ val arm = new AnyRefMap[K, V](sz * 2)
+ val ki = keys.iterator
+ val vi = values.iterator
+ while (ki.hasNext && vi.hasNext) arm(ki.next) = vi.next
+ if (arm.size < (sz >> 3)) arm.repack()
+ arm
+ }
+}
diff --git a/src/library/scala/collection/mutable/LongMap.scala b/src/library/scala/collection/mutable/LongMap.scala
new file mode 100644
index 0000000000..81c381279f
--- /dev/null
+++ b/src/library/scala/collection/mutable/LongMap.scala
@@ -0,0 +1,558 @@
+package scala
+package collection
+package mutable
+
+import generic.CanBuildFrom
+
+/** This class implements mutable maps with `Long` keys based on a hash table with open addressing.
+ *
+ * Basic map operations on single entries, including `contains` and `get`,
+ * are typically substantially faster with `LongMap` than [[HashMap]]. Methods
+ * that act on the whole map, including `foreach` and `map` are not in
+ * general expected to be faster than with a generic map, save for those
+ * that take particular advantage of the internal structure of the map:
+ * `foreachKey`, `foreachValue`, `mapValuesNow`, and `transformValues`.
+ *
+ * Maps with open addressing may become less efficient at lookup after
+ * repeated addition/removal of elements. Although `LongMap` makes a
+ * decent attempt to remain efficient regardless, calling `repack`
+ * on a map that will no longer have elements removed but will be
+ * used heavily may save both time and storage space.
+ *
+ * This map is not indended to contain more than 2^29 entries (approximately
+ * 500 million). The maximum capacity is 2^30, but performance will degrade
+ * rapidly as 2^30 is approached.
+ *
+ */
+final class LongMap[V] private[collection] (defaultEntry: Long => V, initialBufferSize: Int, initBlank: Boolean)
+extends AbstractMap[Long, V]
+ with Map[Long, V]
+ with MapLike[Long, V, LongMap[V]]
+ with Serializable
+{
+ import LongMap._
+
+ def this() = this(LongMap.exceptionDefault, 16, true)
+
+ /** Creates a new `LongMap` that returns default values according to a supplied key-value mapping. */
+ def this(defaultEntry: Long => V) = this(defaultEntry, 16, true)
+
+ /** Creates a new `LongMap` with an initial buffer of specified size.
+ *
+ * A LongMap can typically contain half as many elements as its buffer size
+ * before it requires resizing.
+ */
+ def this(initialBufferSize: Int) = this(LongMap.exceptionDefault, initialBufferSize, true)
+
+ /** Creates a new `LongMap` with specified default values and initial buffer size. */
+ def this(defaultEntry: Long => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
+
+ private[this] var mask = 0
+ private[this] var extraKeys: Int = 0
+ private[this] var zeroValue: AnyRef = null
+ private[this] var minValue: AnyRef = null
+ private[this] var _size = 0
+ private[this] var _vacant = 0
+ private[this] var _keys: Array[Long] = null
+ private[this] var _values: Array[AnyRef] = null
+
+ if (initBlank) defaultInitialize(initialBufferSize)
+
+ private[this] def defaultInitialize(n: Int) = {
+ mask =
+ if (n<0) 0x7
+ else (((1 << (32 - java.lang.Integer.numberOfLeadingZeros(n-1))) - 1) & 0x3FFFFFFF) | 0x7
+ _keys = new Array[Long](mask+1)
+ _values = new Array[AnyRef](mask+1)
+ }
+
+ private[collection] def initializeTo(
+ m: Int, ek: Int, zv: AnyRef, mv: AnyRef, sz: Int, vc: Int, kz: Array[Long], vz: Array[AnyRef]
+ ) {
+ mask = m; extraKeys = ek; zeroValue = zv; minValue = mv; _size = sz; _vacant = vc; _keys = kz; _values = vz
+ }
+
+ override def size: Int = _size + (extraKeys+1)/2
+ override def empty: LongMap[V] = new LongMap()
+
+ private def imbalanced: Boolean =
+ (_size + _vacant) > 0.5*mask || _vacant > _size
+
+ private def toIndex(k: Long): Int = {
+ // Part of the MurmurHash3 32 bit finalizer
+ val h = ((k ^ (k >>> 32)) & 0xFFFFFFFFL).toInt
+ var x = (h ^ (h >>> 16)) * 0x85EBCA6B
+ (x ^ (x >>> 13)) & mask
+ }
+
+ private def seekEmpty(k: Long): Int = {
+ var e = toIndex(k)
+ var x = 0
+ while (_keys(e) != 0) { x += 1; e = (e + 2*(x+1)*x - 3) & mask }
+ e
+ }
+
+ private def seekEntry(k: Long): Int = {
+ var e = toIndex(k)
+ var x = 0
+ var q = 0L
+ while ({ q = _keys(e); if (q==k) return e; q != 0}) { x += 1; e = (e + 2*(x+1)*x - 3) & mask }
+ e | MissingBit
+ }
+
+ private def seekEntryOrOpen(k: Long): Int = {
+ var e = toIndex(k)
+ var x = 0
+ var q = 0L
+ while ({ q = _keys(e); if (q==k) return e; q+q != 0}) {
+ x += 1
+ e = (e + 2*(x+1)*x - 3) & mask
+ }
+ if (q == 0) return e | MissingBit
+ val o = e | MissVacant
+ while ({ q = _keys(e); if (q==k) return e; q != 0}) {
+ x += 1
+ e = (e + 2*(x+1)*x - 3) & mask
+ }
+ o
+ }
+
+ override def contains(key: Long): Boolean = {
+ if (key == -key) (((key>>>63).toInt+1) & extraKeys) != 0
+ else seekEntry(key) >= 0
+ }
+
+ override def get(key: Long): Option[V] = {
+ if (key == -key) {
+ if ((((key>>>63).toInt+1) & extraKeys) == 0) None
+ else if (key == 0) Some(zeroValue.asInstanceOf[V])
+ else Some(minValue.asInstanceOf[V])
+ }
+ else {
+ val i = seekEntry(key)
+ if (i < 0) None else Some(_values(i).asInstanceOf[V])
+ }
+ }
+
+ override def getOrElse[V1 >: V](key: Long, default: => V1): V1 = {
+ if (key == -key) {
+ if ((((key>>>63).toInt+1) & extraKeys) == 0) default
+ else if (key == 0) zeroValue.asInstanceOf[V1]
+ else minValue.asInstanceOf[V1]
+ }
+ else {
+ val i = seekEntry(key)
+ if (i < 0) default else _values(i).asInstanceOf[V1]
+ }
+ }
+
+ override def getOrElseUpdate(key: Long, defaultValue: => V): V = {
+ if (key == -key) {
+ val kbits = (key>>>63).toInt + 1
+ if ((kbits & extraKeys) == 0) {
+ val value = defaultValue
+ extraKeys |= kbits
+ if (key == 0) zeroValue = value.asInstanceOf[AnyRef]
+ else minValue = value.asInstanceOf[AnyRef]
+ value
+ }
+ else if (key == 0) zeroValue.asInstanceOf[V]
+ else minValue.asInstanceOf[V]
+ }
+ else {
+ val i = seekEntryOrOpen(key)
+ if (i < 0) {
+ val value = defaultValue
+ _size += 1
+ val j = i & IndexMask
+ _keys(j) = key
+ _values(j) = value.asInstanceOf[AnyRef]
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ value
+ }
+ else _values(i).asInstanceOf[V]
+ }
+ }
+
+ /** Retrieves the value associated with a key, or the default for that type if none exists
+ * (null for AnyRef, 0 for floats and integers).
+ *
+ * Note: this is the fastest way to retrieve a value that may or
+ * may not exist, if the default null/zero is acceptable. For key/value
+ * pairs that do exist, `apply` (i.e. `map(key)`) is equally fast.
+ */
+ def getOrNull(key: Long): V = {
+ if (key == -key) {
+ if ((((key>>>63).toInt+1) & extraKeys) == 0) null.asInstanceOf[V]
+ else if (key == 0) zeroValue.asInstanceOf[V]
+ else minValue.asInstanceOf[V]
+ }
+ else {
+ val i = seekEntry(key)
+ if (i < 0) null.asInstanceOf[V] else _values(i).asInstanceOf[V]
+ }
+ }
+
+ /** Retrieves the value associated with a key.
+ * If the key does not exist in the map, the `defaultEntry` for that key
+ * will be returned instead.
+ */
+ override def apply(key: Long): V = {
+ if (key == -key) {
+ if ((((key>>>63).toInt+1) & extraKeys) == 0) defaultEntry(key)
+ else if (key == 0) zeroValue.asInstanceOf[V]
+ else minValue.asInstanceOf[V]
+ }
+ else {
+ val i = seekEntry(key)
+ if (i < 0) defaultEntry(key) else _values(i).asInstanceOf[V]
+ }
+ }
+
+ /** The user-supplied default value for the key. Throws an exception
+ * if no other default behavior was specified.
+ */
+ override def default(key: Long) = defaultEntry(key)
+
+ private def repack(newMask: Int) {
+ val ok = _keys
+ val ov = _values
+ mask = newMask
+ _keys = new Array[Long](mask+1)
+ _values = new Array[AnyRef](mask+1)
+ _vacant = 0
+ var i = 0
+ while (i < ok.length) {
+ val k = ok(i)
+ if (k != -k) {
+ val j = seekEmpty(k)
+ _keys(j) = k
+ _values(j) = ov(i)
+ }
+ i += 1
+ }
+ }
+
+ /** Repacks the contents of this `LongMap` for maximum efficiency of lookup.
+ *
+ * For maps that undergo a complex creation process with both addition and
+ * removal of keys, and then are used heavily with no further removal of
+ * elements, calling `repack` after the end of the creation can result in
+ * improved performance. Repacking takes time proportional to the number
+ * of entries in the map.
+ */
+ def repack() {
+ var m = mask
+ if (_size + _vacant >= 0.5*mask && !(_vacant > 0.2*mask)) m = ((m << 1) + 1) & IndexMask
+ while (m > 8 && 8*_size < m) m = m >>> 1
+ repack(m)
+ }
+
+ override def put(key: Long, value: V): Option[V] = {
+ if (key == -key) {
+ if (key == 0) {
+ val ans = if ((extraKeys&1) == 1) Some(zeroValue.asInstanceOf[V]) else None
+ zeroValue = value.asInstanceOf[AnyRef]
+ extraKeys |= 1
+ ans
+ }
+ else {
+ val ans = if ((extraKeys&2) == 1) Some(minValue.asInstanceOf[V]) else None
+ minValue = value.asInstanceOf[AnyRef]
+ extraKeys |= 2
+ ans
+ }
+ }
+ else {
+ val i = seekEntryOrOpen(key)
+ if (i < 0) {
+ val j = i & IndexMask
+ _keys(j) = key
+ _values(j) = value.asInstanceOf[AnyRef]
+ _size += 1
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ None
+ }
+ else {
+ val ans = Some(_values(i).asInstanceOf[V])
+ _keys(i) = key
+ _values(i) = value.asInstanceOf[AnyRef]
+ ans
+ }
+ }
+ }
+
+ /** Updates the map to include a new key-value pair.
+ *
+ * This is the fastest way to add an entry to a `LongMap`.
+ */
+ override def update(key: Long, value: V): Unit = {
+ if (key == -key) {
+ if (key == 0) {
+ zeroValue = value.asInstanceOf[AnyRef]
+ extraKeys |= 1
+ }
+ else {
+ minValue = value.asInstanceOf[AnyRef]
+ extraKeys |= 2
+ }
+ }
+ else {
+ var i = seekEntryOrOpen(key)
+ if (i < 0) {
+ val j = i & IndexMask
+ _keys(j) = key
+ _values(j) = value.asInstanceOf[AnyRef]
+ _size += 1
+ if ((i & VacantBit) != 0) _vacant -= 1
+ else if (imbalanced) repack()
+ }
+ else {
+ _keys(i) = key
+ _values(i) = value.asInstanceOf[AnyRef]
+ }
+ }
+ }
+
+ /** Adds a new key/value pair to this map and returns the map. */
+ def +=(key: Long, value: V): this.type = { update(key, value); this }
+
+ def +=(kv: (Long, V)): this.type = { update(kv._1, kv._2); this }
+
+ def -=(key: Long): this.type = {
+ if (key == -key) {
+ if (key == 0L) {
+ extraKeys &= 0x2
+ zeroValue = null
+ }
+ else {
+ extraKeys &= 0x1
+ minValue = null
+ }
+ }
+ else {
+ val i = seekEntry(key)
+ if (i >= 0) {
+ _size -= 1
+ _vacant += 1
+ _keys(i) = Long.MinValue
+ _values(i) = null
+ }
+ }
+ this
+ }
+
+ def iterator: Iterator[(Long, V)] = new Iterator[(Long, V)] {
+ private[this] val kz = _keys
+ private[this] val vz = _values
+
+ private[this] var nextPair: (Long, V) =
+ if (extraKeys==0) null
+ else if ((extraKeys&1)==1) (0L, zeroValue.asInstanceOf[V])
+ else (Long.MinValue, minValue.asInstanceOf[V])
+
+ private[this] var anotherPair: (Long, V) =
+ if (extraKeys==3) (Long.MinValue, minValue.asInstanceOf[V])
+ else null
+
+ private[this] var index = 0
+
+ def hasNext: Boolean = nextPair != null || (index < kz.length && {
+ var q = kz(index)
+ while (q == -q) {
+ index += 1
+ if (index >= kz.length) return false
+ q = kz(index)
+ }
+ nextPair = (kz(index), vz(index).asInstanceOf[V])
+ index += 1
+ true
+ })
+ def next = {
+ if (nextPair == null && !hasNext) throw new NoSuchElementException("next")
+ val ans = nextPair
+ if (anotherPair != null) {
+ nextPair = anotherPair
+ anotherPair = null
+ }
+ nextPair = null
+ ans
+ }
+ }
+
+ override def foreach[A](f: ((Long,V)) => A) {
+ var i,j = 0
+ while (i < _keys.length & j < _size) {
+ val k = _keys(i)
+ if (k != -k) {
+ j += 1
+ f((k, _values(i).asInstanceOf[V]))
+ }
+ i += 1
+ }
+ if ((extraKeys & 1) == 1) f((0L, zeroValue.asInstanceOf[V]))
+ if ((extraKeys & 2) == 2) f((Long.MinValue, minValue.asInstanceOf[V]))
+ }
+
+ override def clone(): LongMap[V] = {
+ val kz = java.util.Arrays.copyOf(_keys, _keys.length)
+ val vz = java.util.Arrays.copyOf(_values, _values.length)
+ val lm = new LongMap[V](defaultEntry, 1, false)
+ lm.initializeTo(mask, extraKeys, zeroValue, minValue, _size, _vacant, kz, vz)
+ lm
+ }
+
+ /** Applies a function to all keys of this map. */
+ def foreachKey[A](f: Long => A) {
+ var i,j = 0
+ while (i < _keys.length & j < _size) {
+ val k = _keys(i)
+ if (k != -k) {
+ j += 1
+ f(k)
+ }
+ i += 1
+ }
+ if ((extraKeys & 1) == 1) f(0L)
+ if ((extraKeys & 2) == 2) f(Long.MinValue)
+ }
+
+ /** Applies a function to all values of this map. */
+ def foreachValue[A](f: V => A) {
+ var i,j = 0
+ while (i < _keys.length & j < _size) {
+ val k = _keys(i)
+ if (k != -k) {
+ j += 1
+ f(_values(i).asInstanceOf[V])
+ }
+ i += 1
+ }
+ if ((extraKeys & 1) == 1) f(zeroValue.asInstanceOf[V])
+ if ((extraKeys & 2) == 2) f(minValue.asInstanceOf[V])
+ }
+
+ /** Creates a new `LongMap` with different values.
+ * Unlike `mapValues`, this method generates a new
+ * collection immediately.
+ */
+ def mapValuesNow[V1](f: V => V1): LongMap[V1] = {
+ val lm = new LongMap[V1](LongMap.exceptionDefault, 1, false)
+ val kz = java.util.Arrays.copyOf(_keys, _keys.length)
+ val vz = new Array[AnyRef](_values.length)
+ var i,j = 0
+ while (i < _keys.length & j < _size) {
+ val k = _keys(i)
+ if (k != -k) {
+ j += 1
+ vz(i) = f(_values(i).asInstanceOf[V]).asInstanceOf[AnyRef]
+ }
+ i += 1
+ }
+ val zv = if ((extraKeys & 1) == 1) f(zeroValue.asInstanceOf[V]).asInstanceOf[AnyRef] else null
+ val mv = if ((extraKeys & 2) == 2) f(minValue.asInstanceOf[V]).asInstanceOf[AnyRef] else null
+ lm.initializeTo(mask, extraKeys, zv, mv, _size, _vacant, kz, vz)
+ lm
+ }
+
+ /** Applies a transformation function to all values stored in this map.
+ * Note: the default, if any, is not transformed.
+ */
+ def transformValues(f: V => V): this.type = {
+ var i,j = 0
+ while (i < _keys.length & j < _size) {
+ val k = _keys(i)
+ if (k != -k) {
+ j += 1
+ _values(i) = f(_values(i).asInstanceOf[V]).asInstanceOf[AnyRef]
+ }
+ i += 1
+ }
+ if ((extraKeys & 1) == 1) zeroValue = f(zeroValue.asInstanceOf[V]).asInstanceOf[AnyRef]
+ if ((extraKeys & 2) == 2) minValue = f(minValue.asInstanceOf[V]).asInstanceOf[AnyRef]
+ this
+ }
+
+ /*
+ override def toString = {
+ val sb = new StringBuilder("LongMap(")
+ var n = 0
+ foreach{ case (k,v) =>
+ if (n > 0) sb ++= ", "
+ sb ++= k.toString
+ sb ++= " -> "
+ sb ++= v.toString
+ n += 1
+ }
+ sb += ')'
+ sb.result
+ }
+ */
+}
+
+object LongMap {
+ private final val IndexMask = 0x3FFFFFFF
+ private final val MissingBit = 0x80000000
+ private final val VacantBit = 0x40000000
+ private final val MissVacant = 0xC0000000
+
+ private val exceptionDefault: Long => Nothing = (k: Long) => throw new NoSuchElementException(k.toString)
+
+ implicit def canBuildFrom[V, U]: CanBuildFrom[LongMap[V], (Long, U), LongMap[U]] =
+ new CanBuildFrom[LongMap[V], (Long, U), LongMap[U]] {
+ def apply(from: LongMap[V]): LongMapBuilder[U] = apply()
+ def apply(): LongMapBuilder[U] = new LongMapBuilder[U]
+ }
+
+ final class LongMapBuilder[V] extends Builder[(Long, V), LongMap[V]] {
+ private[collection] var elems: LongMap[V] = new LongMap[V]
+ def +=(entry: (Long, V)): this.type = {
+ elems += entry
+ this
+ }
+ def clear() { elems = new LongMap[V] }
+ def result(): LongMap[V] = elems
+ }
+
+ /** Creates a new `LongMap` with zero or more key/value pairs. */
+ def apply[V](elems: (Long, V)*): LongMap[V] = {
+ val sz = if (elems.hasDefiniteSize) elems.size else 4
+ val lm = new LongMap[V](sz * 2)
+ elems.foreach{ case (k,v) => lm(k) = v }
+ if (lm.size < (sz>>3)) lm.repack()
+ lm
+ }
+
+ /** Creates a new empty `LongMap`. */
+ def empty[V]: LongMap[V] = new LongMap[V]
+
+ /** Creates a new empty `LongMap` with the supplied default */
+ def withDefault[V](default: Long => V): LongMap[V] = new LongMap[V](default)
+
+ /** Creates a new `LongMap` from arrays of keys and values.
+ * Equivalent to but more efficient than `LongMap((keys zip values): _*)`.
+ */
+ def fromZip[V](keys: Array[Long], values: Array[V]): LongMap[V] = {
+ val sz = math.min(keys.length, values.length)
+ val lm = new LongMap[V](sz * 2)
+ var i = 0
+ while (i < sz) { lm(keys(i)) = values(i); i += 1 }
+ if (lm.size < (sz>>3)) lm.repack()
+ lm
+ }
+
+ /** Creates a new `LongMap` from keys and values.
+ * Equivalent to but more efficient than `LongMap((keys zip values): _*)`.
+ */
+ def fromZip[V](keys: Iterable[Long], values: Iterable[V]): LongMap[V] = {
+ val sz = math.min(keys.size, values.size)
+ val lm = new LongMap[V](sz * 2)
+ val ki = keys.iterator
+ val vi = values.iterator
+ while (ki.hasNext && vi.hasNext) lm(ki.next) = vi.next
+ if (lm.size < (sz >> 3)) lm.repack()
+ lm
+ }
+}
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index 7d522d1e6e..aade2ed6fb 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -17,7 +17,6 @@ package mutable
* @since 2.7
*/
object OpenHashMap {
- import generic.BitOperations.Int.highestOneBit
def apply[K, V](elems : (K, V)*) = new OpenHashMap[K, V] ++= elems
def empty[K, V] = new OpenHashMap[K, V]
@@ -27,7 +26,7 @@ object OpenHashMap {
var value: Option[Value])
extends HashEntry[Key, OpenEntry[Key, Value]]
- private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1
+ private[mutable] def nextPositivePowerOfTwo(i : Int) = 1 << (32 - Integer.numberOfLeadingZeros(i - 1))
}
/** A mutable hash map based on an open hashing scheme. The precise scheme is
@@ -62,7 +61,7 @@ extends AbstractMap[Key, Value]
override def empty: OpenHashMap[Key, Value] = OpenHashMap.empty[Key, Value]
- private[this] val actualInitialSize = OpenHashMap.nextPowerOfTwo(initialSize)
+ private[this] val actualInitialSize = OpenHashMap.nextPositivePowerOfTwo(initialSize)
private var mask = actualInitialSize - 1
private var table : Array[Entry] = new Array[Entry](actualInitialSize)
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index dd86af0dd4..f905785bd6 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -488,7 +488,7 @@ object Future {
*/
def apply[T](body: =>T)(implicit @deprecatedName('execctx) executor: ExecutionContext): Future[T] = impl.Future(body)
- /** Simple version of `Futures.traverse`. Transforms a `TraversableOnce[Future[A]]` into a `Future[TraversableOnce[A]]`.
+ /** Simple version of `Future.traverse`. Transforms a `TraversableOnce[Future[A]]` into a `Future[TraversableOnce[A]]`.
* Useful for reducing many `Future`s into a single `Future`.
*/
def sequence[A, M[_] <: TraversableOnce[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = {
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 418d859d79..b15601058e 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -82,11 +82,11 @@ private[concurrent] object Promise {
* 2. Complete, with a result.
* 3. Linked to another DefaultPromise.
*
- * If a DefaultPromise is linked it another DefaultPromise then it will
+ * If a DefaultPromise is linked to another DefaultPromise, it will
* delegate all its operations to that other promise. This means that two
* DefaultPromises that are linked will appear, to external callers, to have
- * exactly the same state and behaviour. E.g. they will both appear to be
- * either complete or incomplete, and with the same values.
+ * exactly the same state and behaviour. For instance, both will appear as
+ * incomplete, or as complete with the same result value.
*
* A DefaultPromise stores its state entirely in the AnyRef cell exposed by
* AbstractPromise. The type of object stored in the cell fully describes the
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index 0a2da16523..d783dd29f5 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -158,8 +158,7 @@ object BigDecimal {
* @author Stephane Micheloud
* @version 1.0
*/
-@deprecatedInheritance("This class will be made final.", "2.10.0")
-class BigDecimal(
+final class BigDecimal(
val bigDecimal: BigDec,
val mc: MathContext)
extends ScalaNumber with ScalaNumericConversions with Serializable {
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala
index b25dbefebd..5e70bdc2f6 100644
--- a/src/library/scala/math/BigInt.scala
+++ b/src/library/scala/math/BigInt.scala
@@ -109,8 +109,7 @@ object BigInt {
* @author Martin Odersky
* @version 1.0, 15/07/2003
*/
-@deprecatedInheritance("This class will be made final.", "2.10.0")
-class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
+final class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
/** Returns the hash code for this BigInt. */
override def hashCode(): Int =
if (isValidLong) unifiedPrimitiveHashcode()
diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
index 798746851a..ca7a3cddb8 100644
--- a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
+++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
@@ -16,6 +16,7 @@ import java.lang.{ Class => jClass }
trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
self: ClassManifest[T] =>
+ // Still in use in target test.junit.comp.
@deprecated("Use runtimeClass instead", "2.10.0")
def erasure: jClass[_] = runtimeClass
@@ -64,12 +65,12 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
// when the erasure is the same, even before considering variance.
!cannotMatch && {
// this part is wrong for not considering variance
- if (this.erasure == that.erasure)
+ if (this.runtimeClass == that.runtimeClass)
subargs(this.typeArguments, that.typeArguments)
// this part is wrong for punting unless the rhs has no type
// arguments, but it's better than a blindfolded pinata swing.
else
- that.typeArguments.isEmpty && subtype(this.erasure, that.erasure)
+ that.typeArguments.isEmpty && subtype(this.runtimeClass, that.runtimeClass)
}
}
@@ -91,29 +92,29 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
@deprecated("Use wrap instead", "2.10.0")
def arrayManifest: ClassManifest[Array[T]] =
- ClassManifest.classType[Array[T]](arrayClass[T](erasure), this)
+ ClassManifest.classType[Array[T]](arrayClass[T](runtimeClass), this)
override def newArray(len: Int): Array[T] =
- java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]]
+ java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]]
@deprecated("Use wrap.newArray instead", "2.10.0")
def newArray2(len: Int): Array[Array[T]] =
- java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len)
+ java.lang.reflect.Array.newInstance(arrayClass[T](runtimeClass), len)
.asInstanceOf[Array[Array[T]]]
@deprecated("Use wrap.wrap.newArray instead", "2.10.0")
def newArray3(len: Int): Array[Array[Array[T]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](runtimeClass)), len)
.asInstanceOf[Array[Array[Array[T]]]]
@deprecated("Use wrap.wrap.wrap.newArray instead", "2.10.0")
def newArray4(len: Int): Array[Array[Array[Array[T]]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass))), len)
.asInstanceOf[Array[Array[Array[Array[T]]]]]
@deprecated("Use wrap.wrap.wrap.wrap.newArray instead", "2.10.0")
def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] =
- java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len)
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](runtimeClass)))), len)
.asInstanceOf[Array[Array[Array[Array[Array[T]]]]]]
@deprecated("Create WrappedArray directly instead", "2.10.0")
@@ -131,7 +132,7 @@ trait ClassManifestDeprecatedApis[T] extends OptManifest[T] {
protected def argString =
if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]")
- else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]"
+ else if (runtimeClass.isArray) "["+ClassManifest.fromClass(runtimeClass.getComponentType)+"]"
else ""
}
@@ -221,7 +222,7 @@ object ClassManifestFactory {
*/
def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] =
new ClassManifest[T] {
- override def runtimeClass = upperbound.erasure
+ override def runtimeClass = upperbound.runtimeClass
override val typeArguments = args.toList
override def toString = prefix.toString+"#"+name+argString
}
@@ -236,6 +237,6 @@ private class ClassTypeManifest[T](
{
override def toString =
(if (prefix.isEmpty) "" else prefix.get.toString+"#") +
- (if (erasure.isArray) "Array" else erasure.getName) +
+ (if (runtimeClass.isArray) "Array" else runtimeClass.getName) +
argString
} \ No newline at end of file
diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala
index 3bc76da295..803c980058 100644
--- a/src/library/scala/reflect/Manifest.scala
+++ b/src/library/scala/reflect/Manifest.scala
@@ -46,7 +46,7 @@ trait Manifest[T] extends ClassManifest[T] with Equals {
override def typeArguments: List[Manifest[_]] = Nil
override def arrayManifest: Manifest[Array[T]] =
- Manifest.classType[Array[T]](arrayClass[T](erasure), this)
+ Manifest.classType[Array[T]](arrayClass[T](runtimeClass), this)
override def canEqual(that: Any): Boolean = that match {
case _: Manifest[_] => true
@@ -56,10 +56,10 @@ trait Manifest[T] extends ClassManifest[T] with Equals {
* faster than <:< and rules out most comparisons.
*/
override def equals(that: Any): Boolean = that match {
- case m: Manifest[_] => (m canEqual this) && (this.erasure == m.erasure) && (this <:< m) && (m <:< this)
+ case m: Manifest[_] => (m canEqual this) && (this.runtimeClass == m.runtimeClass) && (this <:< m) && (m <:< this)
case _ => false
}
- override def hashCode = this.erasure.##
+ override def hashCode = this.runtimeClass.##
}
// TODO undeprecated until Scala reflection becomes non-experimental
@@ -238,7 +238,7 @@ object ManifestFactory {
override val typeArguments: List[Manifest[_]]) extends Manifest[T] {
override def toString =
(if (prefix.isEmpty) "" else prefix.get.toString+"#") +
- (if (erasure.isArray) "Array" else erasure.getName) +
+ (if (runtimeClass.isArray) "Array" else runtimeClass.getName) +
argString
}
@@ -259,7 +259,7 @@ object ManifestFactory {
*/
def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] =
new Manifest[T] {
- def runtimeClass = upperBound.erasure
+ def runtimeClass = upperBound.runtimeClass
override def toString =
"_" +
(if (lowerBound eq Nothing) "" else " >: "+lowerBound) +
@@ -269,7 +269,7 @@ object ManifestFactory {
/** Manifest for the intersection type `parents_0 with ... with parents_n'. */
def intersectionType[T](parents: Manifest[_]*): Manifest[T] =
new Manifest[T] {
- def runtimeClass = parents.head.erasure
+ def runtimeClass = parents.head.runtimeClass
override def toString = parents.mkString(" with ")
}
}
diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala
deleted file mode 100644
index d86f8873aa..0000000000
--- a/src/library/scala/runtime/WorksheetSupport.scala
+++ /dev/null
@@ -1,93 +0,0 @@
-package scala.runtime
-import java.io.{OutputStream, PrintStream}
-import scala.runtime.ScalaRunTime.stringOf
-
-/** A utility object that's needed by the code that executes a worksheet.
- */
-@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
-object WorksheetSupport {
-
- /** The offset in the source which should be printed */
- private var currentOffset = 0
-
- /** A stream that flushes in regular intervals so that output can be captured
- * in real time. The flush interval is determined by the field "flushInterval".
- * By default it is 30ms.
- */
- private class FlushedOutputStream(out: OutputStream) extends OutputStream {
- protected def flushInterval = 30000000L // interval between flushes, by default 30ms
- protected def width = 80 // output width, by default 80 characters
- protected def tabInc = 8 // tab increment, by default 8 characters
- private var lastFlush: Long = 0L
- private var col = -1
- override def write(b: Array[Byte], off: Int, len: Int) = {
- for (idx <- off until (off + len min b.length)) writeOne(b(idx).toInt)
- flush()
- }
- override def write(c: Int) {
- writeOne(c)
- flush()
- }
- override def flush() {
- val current = System.nanoTime
- if (current - lastFlush >= flushInterval) {
- out.flush()
- lastFlush = current
- }
- }
- def writeOne(c: Int) {
- if (col < 0) {
- col = 0
- write((currentOffset+" ").getBytes)
- }
- out.write(c)
- col =
- if (c == '\n') -1
- else if (c == '\t') (col / tabInc) * tabInc + tabInc
- else col + 1
- if (col >= width) writeOne('\n')
- }
- def ensureNewLine() = if (col > 0) writeOne('\n')
- }
-
- private val flushedOut = new FlushedOutputStream(System.out)
- private val printOut = new PrintStream(flushedOut)
-
- private def redirected(op: => Unit) = {
- val oldSysOut = System.out
- val oldSysErr = System.err
- val oldConsOut = Console.out
- val oldConsErr = Console.err
- System.setOut(printOut)
- System.setErr(printOut)
- Console.setOut(printOut)
- Console.setErr(printOut)
- try op
- finally {
- printOut.close()
- System.setOut(oldSysOut)
- System.setErr(oldSysErr)
- Console.setOut(oldConsOut)
- Console.setErr(oldConsErr)
- }
- }
-
- def $execute(op: => Unit) = redirected {
- try op
- catch {
- case ex: StopException => ;
- case ex: Throwable => ex.printStackTrace()
- }
- }
-
- def $skip(n: Int) = {
- flushedOut.ensureNewLine()
- currentOffset += n
- }
-
- def $stop() = throw new StopException
-
- def $show(x: Any): String = stringOf(x)
-}
-
-class StopException extends Exception
diff --git a/src/library/scala/util/control/NonFatal.scala b/src/library/scala/util/control/NonFatal.scala
index 11fb988e8e..9d3dfea074 100644
--- a/src/library/scala/util/control/NonFatal.scala
+++ b/src/library/scala/util/control/NonFatal.scala
@@ -11,9 +11,8 @@ package util.control
/**
* Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError`
- * (for example, `OutOfMemoryError`, a subclass of `VirtualMachineError`), `ThreadDeath`,
+ * (for example, `OutOfMemoryError` and `StackOverflowError`, subclasses of `VirtualMachineError`), `ThreadDeath`,
* `LinkageError`, `InterruptedException`, `ControlThrowable`.
- * However, `StackOverflowError` is matched, i.e. considered non-fatal.
*
* Note that [[scala.util.control.ControlThrowable]], an internal Throwable, is not matched by
* `NonFatal` (and would therefore be thrown).
@@ -34,7 +33,6 @@ object NonFatal {
* Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal
*/
def apply(t: Throwable): Boolean = t match {
- case _: StackOverflowError => true // StackOverflowError ok even though it is a VirtualMachineError
// VirtualMachineError includes OutOfMemoryError and other fatal errors
case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable => false
case _ => true
diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index c85664349e..1bfaeb255b 100644
--- a/src/library/scala/util/hashing/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -275,12 +275,4 @@ object MurmurHash3 extends MurmurHash3 {
finalizeHash(h, n)
}
*/
-
- @deprecated("Use unorderedHash", "2.10.0")
- final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int =
- unorderedHash(xs.seq, seed)
-
- @deprecated("Use orderedHash", "2.10.0")
- final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int =
- orderedHash(xs.seq, seed)
}
diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala
index dbd4ea55a2..f48b99bd5a 100644
--- a/src/manual/scala/man1/scala.scala
+++ b/src/manual/scala/man1/scala.scala
@@ -55,7 +55,7 @@ object scala extends Command {
CmdOption("savecompiled"),
"Save this compiled version of scripts in order to speed up " &
"later executions of the same script. When running a script, " &
- "save the compiled version of in a file with the same name as the " &
+ "save the compiled version in a file with the same name as the " &
"script but with an extension of " & Mono(".jar") & ". On subsequent " &
"runs of the same script, the pre-compiled " & Mono(".jar") & " file " &
"will be used if it is newer than the script file."),
diff --git a/src/partest-extras/scala/tools/partest/Util.scala b/src/partest-extras/scala/tools/partest/Util.scala
index 114658b0cd..8214396291 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.Context
- def traceImpl[A: c.WeakTypeTag](c: Context)(a: c.Expr[A]): c.Expr[A] = {
+ import scala.reflect.macros.BlackboxContext
+ def traceImpl[A: c.WeakTypeTag](c: BlackboxContext)(a: c.Expr[A]): c.Expr[A] = {
import c.universe._
import definitions._
diff --git a/src/reflect/scala/reflect/api/BuildUtils.scala b/src/reflect/scala/reflect/api/BuildUtils.scala
index 28551b1dcd..cf05aefe72 100644
--- a/src/reflect/scala/reflect/api/BuildUtils.scala
+++ b/src/reflect/scala/reflect/api/BuildUtils.scala
@@ -223,5 +223,34 @@ private[reflect] trait BuildUtils { self: Universe =>
def apply(lhs: Tree, rhs: Tree): Tree
def unapply(tree: Tree): Option[(Tree, Tree)]
}
+
+ val SyntacticValFrom: SyntacticValFromExtractor
+
+ trait SyntacticValFromExtractor {
+ def apply(pat: Tree, rhs: Tree): Tree
+ def unapply(tree: Tree): Option[(Tree, Tree)]
+ }
+
+ val SyntacticValEq: SyntacticValEqExtractor
+
+ trait SyntacticValEqExtractor {
+ def apply(pat: Tree, rhs: Tree): Tree
+ def unapply(tree: Tree): Option[(Tree, Tree)]
+ }
+
+ val SyntacticFilter: SyntacticFilterExtractor
+
+ trait SyntacticFilterExtractor {
+ def apply(test: Tree): Tree
+ def unapply(tree: Tree): Option[(Tree)]
+ }
+
+ val SyntacticFor: SyntacticForExtractor
+ val SyntacticForYield: SyntacticForExtractor
+
+ trait SyntacticForExtractor {
+ def apply(enums: List[Tree], body: Tree): Tree
+ def unapply(tree: Tree): Option[(List[Tree], Tree)]
+ }
}
}
diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/reflect/scala/reflect/api/Exprs.scala
index 5b6ff2325c..50c8aa8779 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: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ... }
+ * object Impls { def foo_impl(c: BlackboxContext)(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/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala
index 4182b7d0ba..e239b86452 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.Context)(x: c.Expr[T]) = {
+ * def staticEval[T](c: scala.reflect.macros.BlackboxContext)(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/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala
index 6fc76c9693..df5e0699a5 100644
--- a/src/reflect/scala/reflect/api/JavaUniverse.scala
+++ b/src/reflect/scala/reflect/api/JavaUniverse.scala
@@ -34,7 +34,7 @@ trait JavaUniverse extends Universe with JavaMirrors { self =>
mirror.universe match {
case ju: JavaUniverse =>
val jm = mirror.asInstanceOf[ju.Mirror]
- val sym = jm.classSymbol(manifest.erasure)
+ val sym = jm.classSymbol(manifest.runtimeClass)
val tpe =
if (manifest.typeArguments.isEmpty) sym.toType
else ju.appliedType(sym.toTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe))
diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala
index ec128e31a3..a4cd531053 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.Context#mirror]].
+ * The entry point to classloader `Mirror`s is via [[scala.reflect.macros.BlackboxContext#mirror]] or [[scala.reflect.macros.WhiteboxContext#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.Context
+ * import scala.reflect.macros.BlackboxContext
*
* case class Location(filename: String, line: Int, column: Int)
*
* object Macros {
* def currentLocation: Location = macro impl
*
- * def impl(c: Context): c.Expr[Location] = {
+ * def impl(c: BlackboxContext): 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/Quasiquotes.scala b/src/reflect/scala/reflect/api/Quasiquotes.scala
index 3687ccba63..fcf8edcec7 100644
--- a/src/reflect/scala/reflect/api/Quasiquotes.scala
+++ b/src/reflect/scala/reflect/api/Quasiquotes.scala
@@ -14,5 +14,6 @@ trait Quasiquotes { self: Universe =>
object tq extends api
object cq extends api
object pq extends api
+ object fq extends api
}
}
diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala
index 77b4827eab..534f69a23e 100644
--- a/src/reflect/scala/reflect/api/Universe.scala
+++ b/src/reflect/scala/reflect/api/Universe.scala
@@ -41,10 +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.Context#universe]]. For example:
+ * To obtain a `Universe` for use within a Scala macro, use [[scala.reflect.macros.BlackboxContext#universe]].
+ * or [[scala.reflect.macros.WhiteboxContext#universe]]. For example:
* {{{
* def printf(format: String, params: Any*): Unit = macro impl
- * def impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = {
+ * def impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = {
* import c.universe._
* ...
* }
diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala
index fc6b26db3f..8fc1869dd2 100644
--- a/src/reflect/scala/reflect/internal/BuildUtils.scala
+++ b/src/reflect/scala/reflect/internal/BuildUtils.scala
@@ -9,7 +9,6 @@ trait BuildUtils { self: SymbolTable =>
import definitions.{TupleClass, FunctionClass, ScalaPackage, UnitClass}
class BuildImpl extends BuildApi {
-
def selectType(owner: Symbol, name: String): TypeSymbol =
select(owner, newTypeName(name)).asType
@@ -19,7 +18,7 @@ trait BuildUtils { self: SymbolTable =>
else result
}
- private def select(owner: Symbol, name: Name): Symbol = {
+ protected def select(owner: Symbol, name: Name): Symbol = {
val result = owner.info decl name
if (result ne NoSymbol) result
else
@@ -135,7 +134,7 @@ trait BuildUtils { self: SymbolTable =>
def withFreshTypeName[T](prefix: String)(f: TypeName => T): T = f(freshTypeName(prefix))
- private implicit def fresh: FreshNameCreator = self.currentFreshNameCreator
+ protected implicit def fresh: FreshNameCreator = self.currentFreshNameCreator
object FlagsRepr extends FlagsReprExtractor {
def apply(bits: Long): FlagSet = bits
@@ -175,7 +174,8 @@ trait BuildUtils { self: SymbolTable =>
}
}
- private object UnCtor {
+ // recover constructor contents generated by gen.mkTemplate
+ protected object UnCtor {
def unapply(tree: Tree): Option[(Modifiers, List[List[ValDef]], List[Tree])] = tree match {
case DefDef(mods, nme.MIXIN_CONSTRUCTOR, _, _, _, Block(lvdefs, _)) =>
Some((mods | Flag.TRAIT, Nil, lvdefs))
@@ -185,7 +185,8 @@ trait BuildUtils { self: SymbolTable =>
}
}
- private object UnMkTemplate {
+ // undo gen.mkTemplate
+ protected object UnMkTemplate {
def unapply(templ: Template): Option[(List[Tree], ValDef, Modifiers, List[List[ValDef]], List[Tree], List[Tree])] = {
val Template(parents, selfType, tbody) = templ
def result(ctorMods: Modifiers, vparamss: List[List[ValDef]], edefs: List[Tree], body: List[Tree]) =
@@ -297,8 +298,8 @@ trait BuildUtils { self: SymbolTable =>
}
}
- private trait ScalaMemberRef {
- val symbols: Seq[Symbol]
+ // match references to `scala.$name`
+ protected class ScalaMemberRef(symbols: Seq[Symbol]) {
def result(name: Name): Option[Symbol] =
symbols.collect { case sym if sym.name == name => sym }.headOption
def unapply(tree: Tree): Option[Symbol] = tree match {
@@ -311,31 +312,23 @@ trait BuildUtils { self: SymbolTable =>
case _ => None
}
}
- private object TupleClassRef extends ScalaMemberRef {
- val symbols = TupleClass.seq
- }
- private object TupleCompanionRef extends ScalaMemberRef {
- val symbols = TupleClass.seq.map { _.companionModule }
- }
- private object UnitClassRef extends ScalaMemberRef {
- val symbols = Seq(UnitClass)
- }
- private object FunctionClassRef extends ScalaMemberRef {
- val symbols = FunctionClass.seq
- }
+ protected object TupleClassRef extends ScalaMemberRef(TupleClass.seq)
+ protected object TupleCompanionRef extends ScalaMemberRef(TupleClass.seq.map { _.companionModule })
+ protected object UnitClassRef extends ScalaMemberRef(Seq(UnitClass))
+ protected object FunctionClassRef extends ScalaMemberRef(FunctionClass.seq)
object SyntacticTuple extends SyntacticTupleExtractor {
- def apply(args: List[Tree]): Tree = args match {
- case Nil => Literal(Constant(()))
- case _ =>
- require(TupleClass(args.length).exists, s"Tuples with ${args.length} arity aren't supported")
- self.Apply(TupleClass(args.length).companionModule, args: _*)
+ def apply(args: List[Tree]): Tree = {
+ require(args.isEmpty || TupleClass(args.length).exists, s"Tuples with ${args.length} arity aren't supported")
+ gen.mkTuple(args, flattenUnary = false)
}
def unapply(tree: Tree): Option[List[Tree]] = tree match {
case Literal(Constant(())) =>
Some(Nil)
- case Apply(TupleCompanionRef(sym), args) if sym == TupleClass(args.length).companionModule =>
+ case Apply(MaybeTypeTreeOriginal(SyntacticTypeApplied(MaybeSelectApply(TupleCompanionRef(sym)), targs)), args)
+ if sym == TupleClass(args.length).companionModule
+ && (targs.isEmpty || targs.length == args.length) =>
Some(args)
case _ =>
None
@@ -343,17 +336,16 @@ trait BuildUtils { self: SymbolTable =>
}
object SyntacticTupleType extends SyntacticTupleExtractor {
- def apply(args: List[Tree]): Tree = args match {
- case Nil => self.Select(self.Ident(nme.scala_), tpnme.Unit)
- case _ =>
- require(TupleClass(args.length).exists, s"Tuples with ${args.length} arity aren't supported")
- AppliedTypeTree(Ident(TupleClass(args.length)), args)
+ def apply(args: List[Tree]): Tree = {
+ require(args.isEmpty || TupleClass(args.length).exists, s"Tuples with ${args.length} arity aren't supported")
+ gen.mkTupleType(args, flattenUnary = false)
}
- def unapply(tree: Tree): Option[List[Tree]] = tree match {
- case UnitClassRef(_) =>
+ def unapply(tree: Tree): Option[List[Tree]] = tree match {
+ case MaybeTypeTreeOriginal(UnitClassRef(_)) =>
Some(Nil)
- case AppliedTypeTree(TupleClassRef(sym), args) if sym == TupleClass(args.length) =>
+ case MaybeTypeTreeOriginal(AppliedTypeTree(TupleClassRef(sym), args))
+ if sym == TupleClass(args.length) =>
Some(args)
case _ =>
None
@@ -367,7 +359,8 @@ trait BuildUtils { self: SymbolTable =>
}
def unapply(tree: Tree): Option[(List[Tree], Tree)] = tree match {
- case AppliedTypeTree(FunctionClassRef(sym), args @ (argtpes :+ restpe)) if sym == FunctionClass(args.length - 1) =>
+ case MaybeTypeTreeOriginal(AppliedTypeTree(FunctionClassRef(sym), args @ (argtpes :+ restpe)))
+ if sym == FunctionClass(args.length - 1) =>
Some((argtpes, restpe))
case _ => None
}
@@ -423,9 +416,7 @@ trait BuildUtils { self: SymbolTable =>
}
}
- trait SyntacticValDefBase extends SyntacticValDefExtractor {
- val isMutable: Boolean
-
+ protected class SyntacticValDefBase(isMutable: Boolean) extends SyntacticValDefExtractor {
def apply(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) = {
val mods1 = if (isMutable) mods | MUTABLE else mods
ValDef(mods1, name, tpt, rhs)
@@ -438,9 +429,8 @@ trait BuildUtils { self: SymbolTable =>
None
}
}
-
- object SyntacticValDef extends SyntacticValDefBase { val isMutable = false }
- object SyntacticVarDef extends SyntacticValDefBase { val isMutable = true }
+ object SyntacticValDef extends SyntacticValDefBase(isMutable = false)
+ object SyntacticVarDef extends SyntacticValDefBase(isMutable = true)
object SyntacticAssign extends SyntacticAssignExtractor {
def apply(lhs: Tree, rhs: Tree): Tree = gen.mkAssign(lhs, rhs)
@@ -451,7 +441,238 @@ trait BuildUtils { self: SymbolTable =>
case _ => None
}
}
+
+ object SyntacticValFrom extends SyntacticValFromExtractor {
+ def apply(pat: Tree, rhs: Tree): Tree = gen.ValFrom(pat, gen.mkCheckIfRefutable(pat, rhs))
+ def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
+ case gen.ValFrom(pat, UnCheckIfRefutable(pat1, rhs1)) if pat.equalsStructure(pat1) =>
+ Some((pat, rhs1))
+ case gen.ValFrom(pat, rhs) =>
+ Some((pat, rhs))
+ case _ => None
+ }
+ }
+
+ object SyntacticValEq extends SyntacticValEqExtractor {
+ def apply(pat: Tree, rhs: Tree): Tree = gen.ValEq(pat, rhs)
+ def unapply(tree: Tree): Option[(Tree, Tree)] = gen.ValEq.unapply(tree)
+ }
+
+ object SyntacticFilter extends SyntacticFilterExtractor {
+ def apply(tree: Tree): Tree = gen.Filter(tree)
+ def unapply(tree: Tree): Option[Tree] = gen.Filter.unapply(tree)
+ }
+
+ // abstract over possible alternative representations of no type in valdef
+ protected object EmptyTypTree {
+ def unapply(tree: Tree): Boolean = tree match {
+ case EmptyTree => true
+ case tt: TypeTree if (tt.original == null || tt.original.isEmpty) => true
+ case _ => false
+ }
+ }
+
+ // match a sequence of desugared `val $pat = $value`
+ protected object UnPatSeq {
+ def unapply(trees: List[Tree]): Option[List[(Tree, Tree)]] = trees match {
+ case Nil => Some(Nil)
+ // case q"$mods val ${_}: ${_} = ${MaybeUnchecked(value)} match { case $pat => (..$ids) }" :: tail
+ case ValDef(mods, _, _, Match(MaybeUnchecked(value), CaseDef(pat, EmptyTree, SyntacticTuple(ids)) :: Nil)) :: tail
+ if mods.hasFlag(SYNTHETIC) && mods.hasFlag(ARTIFACT) =>
+ tail.drop(ids.length) match {
+ case UnPatSeq(rest) => Some((pat, value) :: rest)
+ case _ => None
+ }
+ // case q"${_} val $name1: ${_} = ${MaybeUnchecked(value)} match { case $pat => ${Ident(name2)} }" :: UnPatSeq(rest)
+ case ValDef(_, name1, _, Match(MaybeUnchecked(value), CaseDef(pat, EmptyTree, Ident(name2)) :: Nil)) :: UnPatSeq(rest)
+ if name1 == name2 =>
+ Some((pat, value) :: rest)
+ // case q"${_} val $name: ${EmptyTypTree()} = $value" :: UnPatSeq(rest) =>
+ case ValDef(_, name, EmptyTypTree(), value) :: UnPatSeq(rest) =>
+ Some((Bind(name, self.Ident(nme.WILDCARD)), value) :: rest)
+ // case q"${_} val $name: $tpt = $value" :: UnPatSeq(rest) =>
+ case ValDef(_, name, tpt, value) :: UnPatSeq(rest) =>
+ Some((Bind(name, Typed(self.Ident(nme.WILDCARD), tpt)), value) :: rest)
+ case _ => None
+ }
+ }
+
+ // match a sequence of desugared `val $pat = $value` with a tuple in the end
+ protected object UnPatSeqWithRes {
+ def unapply(tree: Tree): Option[(List[(Tree, Tree)], List[Tree])] = tree match {
+ case SyntacticBlock(UnPatSeq(trees) :+ SyntacticTuple(elems)) => Some((trees, elems))
+ case _ => None
+ }
+ }
+
+ // undo gen.mkSyntheticParam
+ protected object UnSyntheticParam {
+ def unapply(tree: Tree): Option[TermName] = tree match {
+ case ValDef(mods, name, _, EmptyTree)
+ if mods.hasFlag(SYNTHETIC) && mods.hasFlag(PARAM) =>
+ Some(name)
+ case _ => None
+ }
+ }
+
+ // undo gen.mkVisitor
+ protected object UnVisitor {
+ def unapply(tree: Tree): Option[(TermName, List[CaseDef])] = tree match {
+ case Function(UnSyntheticParam(x1) :: Nil, Match(MaybeUnchecked(Ident(x2)), cases))
+ if x1 == x2 =>
+ Some((x1, cases))
+ case _ => None
+ }
+ }
+
+ // undo gen.mkFor:makeClosure
+ protected object UnClosure {
+ def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
+ case Function(ValDef(Modifiers(PARAM, _, _), name, tpt, EmptyTree) :: Nil, body) =>
+ tpt match {
+ case EmptyTypTree() => Some((Bind(name, self.Ident(nme.WILDCARD)), body))
+ case _ => Some((Bind(name, Typed(self.Ident(nme.WILDCARD), tpt)), body))
+ }
+ case UnVisitor(_, CaseDef(pat, EmptyTree, body) :: Nil) =>
+ Some((pat, body))
+ case _ => None
+ }
+ }
+
+ // match call to either withFilter or filter
+ protected object FilterCall {
+ def unapply(tree: Tree): Option[(Tree,Tree)] = tree match {
+ case Apply(Select(obj, nme.withFilter | nme.filter), arg :: Nil) =>
+ Some(obj, arg)
+ case _ => None
+ }
+ }
+
+ // transform a chain of withFilter calls into a sequence of for filters
+ protected object UnFilter {
+ def unapply(tree: Tree): Some[(Tree, List[Tree])] = tree match {
+ case UnCheckIfRefutable(_, _) =>
+ Some((tree, Nil))
+ case FilterCall(UnFilter(rhs, rest), UnClosure(_, test)) =>
+ Some((rhs, rest :+ SyntacticFilter(test)))
+ case _ =>
+ Some((tree, Nil))
+ }
+ }
+
+ // undo gen.mkCheckIfRefutable
+ protected object UnCheckIfRefutable {
+ def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
+ case FilterCall(rhs, UnVisitor(name,
+ CaseDef(pat, EmptyTree, Literal(Constant(true))) ::
+ CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(Constant(false))) :: Nil))
+ if name.toString.contains(nme.CHECK_IF_REFUTABLE_STRING) =>
+ Some((pat, rhs))
+ case _ => None
+ }
+ }
+
+ // undo gen.mkFor:makeCombination accounting for possible extra implicit argument
+ protected class UnForCombination(name: TermName) {
+ def unapply(tree: Tree) = tree match {
+ case SyntacticApplied(SyntacticTypeApplied(sel @ Select(lhs, meth), _), (f :: Nil) :: Nil)
+ if name == meth && sel.hasAttachment[ForAttachment.type] =>
+ Some(lhs, f)
+ case SyntacticApplied(SyntacticTypeApplied(sel @ Select(lhs, meth), _), (f :: Nil) :: _ :: Nil)
+ if name == meth && sel.hasAttachment[ForAttachment.type] =>
+ Some(lhs, f)
+ case _ => None
+ }
+ }
+ protected object UnMap extends UnForCombination(nme.map)
+ protected object UnForeach extends UnForCombination(nme.foreach)
+ protected object UnFlatMap extends UnForCombination(nme.flatMap)
+
+ // undo desugaring done in gen.mkFor
+ protected object UnFor {
+ def unapply(tree: Tree): Option[(List[Tree], Tree)] = {
+ val interm = tree match {
+ case UnFlatMap(UnFilter(rhs, filters), UnClosure(pat, UnFor(rest, body))) =>
+ Some(((pat, rhs), filters ::: rest, body))
+ case UnForeach(UnFilter(rhs, filters), UnClosure(pat, UnFor(rest, body))) =>
+ Some(((pat, rhs), filters ::: rest, body))
+ case UnMap(UnFilter(rhs, filters), UnClosure(pat, cbody)) =>
+ Some(((pat, rhs), filters, gen.Yield(cbody)))
+ case UnForeach(UnFilter(rhs, filters), UnClosure(pat, cbody)) =>
+ Some(((pat, rhs), filters, cbody))
+ case _ => None
+ }
+ interm.flatMap {
+ case ((Bind(_, SyntacticTuple(_)) | SyntacticTuple(_),
+ UnFor(SyntacticValFrom(pat, rhs) :: innerRest, gen.Yield(UnPatSeqWithRes(pats, elems2)))),
+ outerRest, fbody) =>
+ val valeqs = pats.map { case (pat, rhs) => SyntacticValEq(pat, rhs) }
+ Some((SyntacticValFrom(pat, rhs) :: innerRest ::: valeqs ::: outerRest, fbody))
+ case ((pat, rhs), filters, body) =>
+ Some((SyntacticValFrom(pat, rhs) :: filters, body))
+ }
+ }
+ }
+
+ // check that enumerators are valid
+ protected def mkEnumerators(enums: List[Tree]): List[Tree] = {
+ require(enums.nonEmpty, "enumerators can't be empty")
+ enums.head match {
+ case SyntacticValFrom(_, _) =>
+ case t => throw new IllegalArgumentException(s"$t is not a valid fist enumerator of for loop")
+ }
+ enums.tail.foreach {
+ case SyntacticValEq(_, _) | SyntacticValFrom(_, _) | SyntacticFilter(_) =>
+ case t => throw new IllegalArgumentException(s"$t is not a valid representation of a for loop enumerator")
+ }
+ enums
+ }
+
+ object SyntacticFor extends SyntacticForExtractor {
+ def apply(enums: List[Tree], body: Tree): Tree = gen.mkFor(mkEnumerators(enums), body)
+ def unapply(tree: Tree) = tree match {
+ case UnFor(enums, gen.Yield(body)) => None
+ case UnFor(enums, body) => Some((enums, body))
+ case _ => None
+ }
+ }
+
+ object SyntacticForYield extends SyntacticForExtractor {
+ def apply(enums: List[Tree], body: Tree): Tree = gen.mkFor(mkEnumerators(enums), gen.Yield(body))
+ def unapply(tree: Tree) = tree match {
+ case UnFor(enums, gen.Yield(body)) => Some((enums, body))
+ case _ => None
+ }
+ }
+
+ // use typetree's original instead of typetree itself
+ protected object MaybeTypeTreeOriginal {
+ def unapply(tree: Tree): Some[Tree] = tree match {
+ case tt: TypeTree => Some(tt.original)
+ case _ => Some(tree)
+ }
+ }
+
+ // drop potential extra call to .apply
+ protected object MaybeSelectApply {
+ def unapply(tree: Tree): Some[Tree] = tree match {
+ case Select(f, nme.apply) => Some(f)
+ case other => Some(other)
+ }
+ }
+
+ // drop potential @scala.unchecked annotation
+ protected object MaybeUnchecked {
+ def unapply(tree: Tree): Some[Tree] = tree match {
+ case Annotated(SyntacticNew(Nil, Apply(ScalaDot(tpnme.unchecked), Nil) :: Nil, noSelfType, Nil), annottee) =>
+ Some(annottee)
+ case Typed(annottee, MaybeTypeTreeOriginal(
+ Annotated(SyntacticNew(Nil, Apply(ScalaDot(tpnme.unchecked), Nil) :: Nil, noSelfType, Nil), _))) =>
+ Some(annottee)
+ case annottee => Some(annottee)
+ }
+ }
}
- val build: BuildApi = new BuildImpl
+ val build: BuildImpl = new BuildImpl
}
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 7cb051c63d..19f06894c8 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -16,7 +16,7 @@ import scala.reflect.api.{Universe => ApiUniverse}
trait Definitions extends api.StandardDefinitions {
self: SymbolTable =>
- import rootMirror.{getModule, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule}
+ import rootMirror.{getModuleByName, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageIfDefined, getPackageObjectIfDefined, requiredClass, requiredModule}
object definitions extends DefinitionsClass
@@ -87,7 +87,7 @@ trait Definitions extends api.StandardDefinitions {
lazy val abbrvTag = symbolsMap(ScalaValueClasses, nameToTag) withDefaultValue OBJECT_TAG
lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight)
- lazy val boxedModule = classesMap(x => getModule(boxedName(x)))
+ lazy val boxedModule = classesMap(x => getModuleByName(boxedName(x)))
lazy val boxedClass = classesMap(x => getClassByName(boxedName(x)))
lazy val refClass = classesMap(x => getRequiredClass("scala.runtime." + x + "Ref"))
lazy val volatileRefClass = classesMap(x => getRequiredClass("scala.runtime.Volatile" + x + "Ref"))
@@ -153,18 +153,6 @@ trait Definitions extends api.StandardDefinitions {
private var isInitialized = false
def isDefinitionsInitialized = isInitialized
- @deprecated("Moved to rootMirror.RootPackage", "2.10.0")
- val RootPackage: ModuleSymbol = rootMirror.RootPackage
-
- @deprecated("Moved to rootMirror.RootClass", "2.10.0")
- val RootClass: ClassSymbol = rootMirror.RootClass
-
- @deprecated("Moved to rootMirror.EmptyPackage", "2.10.0")
- val EmptyPackage: ModuleSymbol = rootMirror.EmptyPackage
-
- @deprecated("Moved to rootMirror.EmptyPackageClass", "2.10.0")
- val EmptyPackageClass: ClassSymbol = rootMirror.EmptyPackageClass
-
// It becomes tricky to create dedicated objects for other symbols because
// of initialization order issues.
lazy val JavaLangPackage = getPackage("java.lang")
@@ -495,15 +483,18 @@ trait Definitions extends api.StandardDefinitions {
lazy val TreeCreatorClass = getClassIfDefined("scala.reflect.api.TreeCreator") // defined in scala-reflect.jar, so we need to be careful
lazy val LiftableClass = getClassIfDefined("scala.reflect.api.Liftable") // defined in scala-reflect.jar, so we need to be careful
- lazy val MacroClass = getClassIfDefined("scala.reflect.macros.Macro") // defined in scala-reflect.jar, so we need to be careful
- def MacroContextValue = MacroClass.map(sym => getMemberValue(sym, nme.c))
- lazy val MacroContextClass = getClassIfDefined("scala.reflect.macros.Context") // defined in scala-reflect.jar, so we need to be careful
- def MacroContextPrefix = MacroContextClass.map(sym => getMemberMethod(sym, nme.prefix))
- def MacroContextPrefixType = MacroContextClass.map(sym => getTypeMember(sym, tpnme.PrefixType))
- def MacroContextUniverse = MacroContextClass.map(sym => getMemberMethod(sym, nme.universe))
- def MacroContextExprClass = MacroContextClass.map(sym => getTypeMember(sym, tpnme.Expr))
- def MacroContextWeakTypeTagClass = MacroContextClass.map(sym => getTypeMember(sym, tpnme.WeakTypeTag))
- def MacroContextTreeType = MacroContextClass.map(sym => getTypeMember(sym, tpnme.Tree))
+ 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
+ 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))
+ def MacroContextExprClass = BlackboxContextClass.map(sym => getTypeMember(sym, tpnme.Expr))
+ def MacroContextWeakTypeTagClass = BlackboxContextClass.map(sym => getTypeMember(sym, tpnme.WeakTypeTag))
+ def MacroContextTreeType = BlackboxContextClass.map(sym => getTypeMember(sym, tpnme.Tree))
lazy val MacroImplAnnotation = requiredClass[scala.reflect.macros.internal.macroImpl]
lazy val StringContextClass = requiredClass[scala.StringContext]
@@ -593,18 +584,47 @@ trait Definitions extends api.StandardDefinitions {
def unspecializedTypeArgs(tp: Type): List[Type] =
(tp baseType unspecializedSymbol(tp.typeSymbolDirect)).typeArgs
+ object MacroContextType {
+ def unapply(tp: Type) = {
+ def isOneOfContextTypes(tp: Type) =
+ tp =:= BlackboxContextClass.tpe || tp =:= WhiteboxContextClass.tpe
+ def isPrefix(sym: Symbol) =
+ sym.allOverriddenSymbols.contains(MacroContextPrefixType)
+
+ tp.dealias match {
+ case RefinedType(List(tp), Scope(sym)) if isOneOfContextTypes(tp) && isPrefix(sym) => Some(tp)
+ case tp if isOneOfContextTypes(tp) => Some(tp)
+ case _ => None
+ }
+ }
+ }
+
+ def isMacroContextType(tp: Type) = MacroContextType.unapply(tp).isDefined
+
+ 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
}
+ def isBlackboxMacroBundleType(tp: Type) =
+ isMacroBundleType(tp) && (tp <:< BlackboxMacroClass.tpe) && !(tp <:< WhiteboxMacroClass.tpe)
+
def isMacroBundleProtoType(tp: Type) = {
val sym = tp.typeSymbol
val isNonTrivial = tp != ErrorType && tp != NothingTpe && tp != NullTpe
- val isMacroCompatible = MacroClass != NoSymbol && tp.baseClasses.contains(MacroClass)
- val isBundlePrototype = sym != MacroClass && sym.isTrait && {
+ 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)
- val cIsOk = c.overrideChain.contains(MacroContextValue) && c.isDeferred
+ def overrides(sym: Symbol) = c.overrideChain.contains(sym)
+ val cIsOk = (overrides(BlackboxMacroContextValue) || overrides(WhiteboxMacroContextValue)) && c.isDeferred
cIsOk && sym.isMonomorphicType
}
isNonTrivial && isMacroCompatible && isBundlePrototype
diff --git a/src/reflect/scala/reflect/internal/FreshNames.scala b/src/reflect/scala/reflect/internal/FreshNames.scala
new file mode 100644
index 0000000000..bb488aa2a8
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/FreshNames.scala
@@ -0,0 +1,35 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ */
+
+package scala
+package reflect
+package internal
+
+import scala.reflect.internal.util.FreshNameCreator
+
+trait FreshNames { self: Names =>
+ // default fresh name creator used to abstract over currentUnit.fresh and runtime fresh name creator
+ def currentFreshNameCreator: FreshNameCreator
+
+ // create fresh term/type name using implicit fresh name creator
+ def freshTermName(prefix: String = "x$")(implicit creator: FreshNameCreator): TermName = newTermName(creator.newName(prefix))
+ def freshTypeName(prefix: String)(implicit creator: FreshNameCreator): TypeName = newTypeName(creator.newName(prefix))
+
+ // Extractor that matches names which were generated by some
+ // FreshNameCreator with known prefix. Extracts user-specified
+ // prefix that was used as a parameter to newName by stripping
+ // global creator prefix and unique number in the end of the name.
+ class FreshNameExtractor(creatorPrefix: String = "") {
+ // quote prefix so that it can be used with replaceFirst
+ // which expects regExp rather than simple string
+ val quotedCreatorPrefix = java.util.regex.Pattern.quote(creatorPrefix)
+
+ def unapply(name: Name): Option[String] = {
+ val sname = name.toString
+ // name should start with creatorPrefix and end with number
+ if (!sname.startsWith(creatorPrefix) || !sname.matches("^.*\\d*$")) None
+ else Some(NameTransformer.decode(sname.replaceFirst(quotedCreatorPrefix, "").replaceAll("\\d*$", "")))
+ }
+ }
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index 72c8ccfa62..cc6e55192f 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -8,6 +8,16 @@ import scala.ref.WeakReference
// SI-6241: move importers to a mirror
trait Importers extends api.Importers { to: SymbolTable =>
+ /** Attachment that knows how to import itself into another universe. */
+ trait ImportableAttachment {
+ def importAttachment(importer: Importer): this.type
+ }
+
+ /** Attachment that doesn't contain any reflection artificats and can be imported as-is. */
+ trait PlainAttachment extends ImportableAttachment {
+ def importAttachment(importer: Importer): this.type = this
+ }
+
def mkImporter(from0: api.Universe): Importer { val from: from0.type } = (
if (to eq from0) {
new Importer {
@@ -417,11 +427,15 @@ trait Importers extends api.Importers { to: SymbolTable =>
my.setPos(importPosition(their.pos))
}
}
+ importAttachments(their.attachments.all).foreach { my.updateAttachment(_) }
my
}
// ============== MISCELLANEOUS ==============
+ def importAttachments(attachments: Set[Any]): Set[Any] =
+ attachments.collect { case ia: ImportableAttachment => ia.importAttachment(this) }
+
def importAnnotationInfo(ann: from.AnnotationInfo): AnnotationInfo = {
val atp1 = importType(ann.atp)
val args1 = ann.args map importTree
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala
index e122fa498b..3a630b6a16 100644
--- a/src/reflect/scala/reflect/internal/Mirrors.scala
+++ b/src/reflect/scala/reflect/internal/Mirrors.scala
@@ -96,10 +96,6 @@ trait Mirrors extends api.Mirrors {
}
}
- @deprecated("Use getClassByName", "2.10.0")
- def getClass(fullname: Name): ClassSymbol =
- getClassByName(fullname)
-
def getClassByName(fullname: Name): ClassSymbol =
ensureClassSymbol(fullname.toString, getModuleOrClass(fullname.toTypeName))
@@ -131,15 +127,11 @@ trait Mirrors extends api.Mirrors {
case _ => MissingRequirementError.notFound("object " + fullname)
}
- @deprecated("Use getModuleByName", "2.10.0")
- def getModule(fullname: Name): ModuleSymbol =
- getModuleByName(fullname)
-
def getModuleByName(fullname: Name): ModuleSymbol =
ensureModuleSymbol(fullname.toString, getModuleOrClass(fullname.toTermName), allowPackages = true)
def getRequiredModule(fullname: String): ModuleSymbol =
- getModule(newTermNameCached(fullname))
+ getModuleByName(newTermNameCached(fullname))
// TODO: What syntax do we think should work here? Say you have an object
// like scala.Predef. You can't say requiredModule[scala.Predef] since there's
@@ -155,7 +147,7 @@ trait Mirrors extends api.Mirrors {
getModuleIfDefined(newTermNameCached(fullname))
def getModuleIfDefined(fullname: Name): Symbol =
- wrapMissing(getModule(fullname.toTermName))
+ wrapMissing(getModuleByName(fullname.toTermName))
/** @inheritdoc
*
diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala
index 9eb66db01e..46f241643b 100644
--- a/src/reflect/scala/reflect/internal/StdAttachments.scala
+++ b/src/reflect/scala/reflect/internal/StdAttachments.scala
@@ -14,6 +14,7 @@ trait StdAttachments {
def setAttachments(attachments: scala.reflect.macros.Attachments { type Pos = Position }): this.type = { rawatt = attachments; this }
def updateAttachment[T: ClassTag](attachment: T): this.type = { rawatt = rawatt.update(attachment); this }
def removeAttachment[T: ClassTag]: this.type = { rawatt = rawatt.remove[T]; this }
+ def hasAttachment[T: ClassTag]: Boolean = rawatt.contains[T]
// cannot be final due to SynchronizedSymbols
def pos: Position = rawatt.pos
@@ -21,13 +22,17 @@ trait StdAttachments {
def setPos(newpos: Position): this.type = { pos = newpos; this }
}
- /** When present, indicates that the host `Ident` has been created from a backquoted identifier.
- */
- case object BackquotedIdentifierAttachment
-
/** Stores the trees that give rise to a refined type to be used in reification.
* Unfortunately typed `CompoundTypeTree` is lacking essential info, and the reifier cannot use `CompoundTypeTree.tpe`.
* Therefore we need this hack (see `Reshape.toPreTyperTypeTree` for a detailed explanation).
*/
case class CompoundTypeTreeOriginalAttachment(parents: List[Tree], stats: List[Tree])
+
+ /** When present, indicates that the host `Ident` has been created from a backquoted identifier.
+ */
+ case object BackquotedIdentifierAttachment extends PlainAttachment
+
+ /** Identifies trees are either result or intermidiate value of for loop desugaring.
+ */
+ case object ForAttachment extends PlainAttachment
}
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index 02f22a16f6..c26e815df1 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -229,6 +229,7 @@ trait StdNames {
final val Serializable: NameType = "Serializable"
final val Singleton: NameType = "Singleton"
final val Throwable: NameType = "Throwable"
+ final val unchecked: NameType = "unchecked"
final val api: NameType = "api"
final val Annotation: NameType = "Annotation"
@@ -326,6 +327,7 @@ trait StdNames {
val QUASIQUOTE_FILE: String = "<quasiquote>"
val QUASIQUOTE_TUPLE: NameType = "$quasiquote$tuple$"
val QUASIQUOTE_CASE: NameType = "$quasiquote$case$"
+ val QUASIQUOTE_FOR_ENUM: NameType = "$quasiquote$for$enum$"
val MIXIN_CONSTRUCTOR: NameType = "$init$"
val MODULE_INSTANCE_FIELD: NameType = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$"
val OUTER: NameType = "$outer"
@@ -591,6 +593,9 @@ trait StdNames {
val SyntacticBlock: NameType = "SyntacticBlock"
val SyntacticClassDef: NameType = "SyntacticClassDef"
val SyntacticDefDef: NameType = "SyntacticDefDef"
+ val SyntacticFilter: NameType = "SyntacticFilter"
+ val SyntacticFor: NameType = "SyntacticFor"
+ val SyntacticForYield: NameType = "SyntacticForYield"
val SyntacticFunction: NameType = "SyntacticFunction"
val SyntacticFunctionType: NameType = "SyntacticFunctionType"
val SyntacticPackageObjectDef: NameType = "SyntacticPackageObjectDef"
@@ -601,6 +606,8 @@ trait StdNames {
val SyntacticTupleType: NameType = "SyntacticTupleType"
val SyntacticTypeApplied: NameType = "SyntacticTypeApplied"
val SyntacticValDef: NameType = "SyntacticValDef"
+ val SyntacticValEq: NameType = "SyntacticValEq"
+ val SyntacticValFrom: NameType = "SyntacticValFrom"
val SyntacticVarDef: NameType = "SyntacticVarDef"
val This: NameType = "This"
val ThisType: NameType = "ThisType"
@@ -744,7 +751,6 @@ trait StdNames {
val typedProductIterator: NameType = "typedProductIterator"
val TypeName: NameType = "TypeName"
val typeTagToManifest: NameType = "typeTagToManifest"
-
val unapply: NameType = "unapply"
val unapplySeq: NameType = "unapplySeq"
val unbox: NameType = "unbox"
@@ -763,6 +769,7 @@ trait StdNames {
val tq: NameType = "tq"
val cq: NameType = "cq"
val pq: NameType = "pq"
+ val fq: NameType = "fq"
// unencoded operators
object raw {
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index 4998580a7d..c3f3e35fb3 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -42,6 +42,7 @@ abstract class SymbolTable extends macros.Universe
with BuildUtils
with PrivateWithin
with pickling.Translations
+ with FreshNames
{
val gen = new TreeGen { val global: SymbolTable.this.type = SymbolTable.this }
@@ -398,11 +399,6 @@ abstract class SymbolTable extends macros.Universe
* Adds the `sm` String interpolator to a [[scala.StringContext]].
*/
implicit val StringContextStripMarginOps: StringContext => StringContextStripMarginOps = util.StringContextStripMarginOps
-
- // fresh name creation
- def currentFreshNameCreator: FreshNameCreator
- def freshTermName(prefix: String = "x$")(implicit creator: FreshNameCreator): TermName = newTermName(creator.newName(prefix))
- def freshTypeName(prefix: String)(implicit creator: FreshNameCreator): TypeName = newTypeName(creator.newName(prefix))
}
object SymbolTableStats {
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index bd17c18119..85bc3158f6 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -452,23 +452,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
case _ => new StubTermSymbol(this, name.toTermName, missingMessage)
}
- @deprecated("Use the other signature", "2.10.0")
- def newClass(pos: Position, name: TypeName): Symbol = newClass(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newModuleClass(pos: Position, name: TypeName): Symbol = newModuleClass(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newLabel(pos: Position, name: TermName): MethodSymbol = newLabel(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newValue(pos: Position, name: TermName): TermSymbol = newTermSymbol(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newAliasType(pos: Position, name: TypeName): Symbol = newAliasType(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newAbstractType(pos: Position, name: TypeName): Symbol = newAbstractType(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newExistential(pos: Position, name: TypeName): Symbol = newExistential(name, pos)
- @deprecated("Use the other signature", "2.10.0")
- def newMethod(pos: Position, name: TermName): MethodSymbol = newMethod(name, pos)
-
// ----- locking and unlocking ------------------------------------------------------
// True if the symbol is unlocked.
@@ -2047,10 +2030,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
else if (isMethod || isClass) this
else owner.logicallyEnclosingMember
- /** Kept for source compatibility with 2.9. Scala IDE for Eclipse relies on this. */
- @deprecated("Use enclosingTopLevelClass", "2.10.0")
- def toplevelClass: Symbol = enclosingTopLevelClass
-
/** The top-level class containing this symbol. */
def enclosingTopLevelClass: Symbol =
if (isTopLevel) {
@@ -2365,9 +2344,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def associatedFile: AbstractFile = enclosingTopLevelClass.associatedFile
def associatedFile_=(f: AbstractFile) { abort("associatedFile_= inapplicable for " + this) }
- @deprecated("Use associatedFile_= instead", "2.10.0")
- def sourceFile_=(f: AbstractFile): Unit = associatedFile_=(f)
-
/** If this is a sealed class, its known direct subclasses.
* Otherwise, the empty set.
*/
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index cf7c729a6a..a0bd64f850 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -4,6 +4,7 @@ package internal
import Flags._
import util._
+import scala.collection.mutable.ListBuffer
abstract class TreeGen extends macros.TreeBuilder {
val global: SymbolTable
@@ -279,11 +280,23 @@ abstract class TreeGen extends macros.TreeBuilder {
def mkNamedArg(lhs: Tree, rhs: Tree): Tree = atPos(rhs.pos)(AssignOrNamedArg(lhs, rhs))
/** Builds a tuple */
- def mkTuple(elems: List[Tree]): Tree =
- if (elems.isEmpty) Literal(Constant(()))
- else Apply(
- Select(mkAttributedRef(TupleClass(elems.length).caseModule), nme.apply),
- elems)
+ def mkTuple(elems: List[Tree], flattenUnary: Boolean = true): Tree = elems match {
+ case Nil =>
+ Literal(Constant(()))
+ case tree :: Nil if flattenUnary =>
+ tree
+ case _ =>
+ Apply(scalaDot(TupleClass(elems.length).companionModule.name), elems)
+ }
+
+ def mkTupleType(elems: List[Tree], flattenUnary: Boolean = true): Tree = elems match {
+ case Nil =>
+ scalaDot(tpnme.Unit)
+ case List(tree) if flattenUnary =>
+ tree
+ case _ =>
+ AppliedTypeTree(scalaDot(TupleClass(elems.length).name), elems)
+ }
// tree1 AND tree2
def mkAnd(tree1: Tree, tree2: Tree): Tree =
@@ -299,7 +312,7 @@ abstract class TreeGen extends macros.TreeBuilder {
}
def mkSeqApply(arg: Tree): Apply = {
- val factory = Select(gen.mkAttributedRef(SeqModule), nme.apply)
+ val factory = Select(mkAttributedRef(SeqModule), nme.apply)
Apply(factory, List(arg))
}
@@ -436,17 +449,15 @@ abstract class TreeGen extends macros.TreeBuilder {
else Block(stats.init, stats.last)
def mkTreeOrBlock(stats: List[Tree]) = stats match {
- case Nil => EmptyTree
+ case Nil => EmptyTree
case head :: Nil => head
- case _ => gen.mkBlock(stats)
+ case _ => mkBlock(stats)
}
/** Create a tree representing an assignment <lhs = rhs> */
def mkAssign(lhs: Tree, rhs: Tree): Tree = lhs match {
- case Apply(fn, args) =>
- Apply(atPos(fn.pos)(Select(fn, nme.update)), args :+ rhs)
- case _ =>
- Assign(lhs, rhs)
+ case Apply(fn, args) => Apply(atPos(fn.pos)(Select(fn, nme.update)), args :+ rhs)
+ case _ => Assign(lhs, rhs)
}
def mkPackageObject(defn: ModuleDef, pidPos: Position = NoPosition, pkgPos: Position = NoPosition) = {
@@ -454,4 +465,419 @@ abstract class TreeGen extends macros.TreeBuilder {
val pid = atPos(pidPos)(Ident(defn.name))
atPos(pkgPos)(PackageDef(pid, module :: Nil))
}
+
+ // Following objects represent encoding of for loop enumerators
+ // into the regular trees. Such representations are used for:
+ //
+ // - as intermediate value of enumerators inside of the parser
+ // right before the mkFor desugaring is being called
+ //
+ // - as intermediate value of enumerators obtained after
+ // re-sugaring of for loops through build.SyntacticFor
+ // and build.SyntacticForYield (which are used by quasiquotes)
+ //
+ // The encoding uses regular trees with ForAttachment that helps
+ // to reliably differentiate them from normal trees that can have
+ // similar shape. fq"$pat <- $rhs" for example is represented in
+ // the same way as "`<-`($pat, $rhs)"" but with added attachment to
+ // the `<-` identifier.
+ //
+ // The primary rationale behind such representation in favor of
+ // simple case classes is a wish to re-use the same representation
+ // between quasiquotes and parser without exposing compiler internals.
+ // Opaque tree encoding can be changed/adapted at any time without
+ // breaking end users code.
+
+ /** Encode/decode fq"$pat <- $rhs" enumerator as q"`<-`($pat, $rhs)" */
+ object ValFrom {
+ def apply(pat: Tree, rhs: Tree): Tree =
+ Apply(Ident(nme.LARROWkw).updateAttachment(ForAttachment),
+ List(pat, rhs))
+
+ def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
+ case Apply(id @ Ident(nme.LARROWkw), List(pat, rhs))
+ if id.hasAttachment[ForAttachment.type] =>
+ Some((pat, rhs))
+ case _ => None
+ }
+ }
+
+ /** Encode/decode fq"$pat = $rhs" enumerator as q"$pat = $rhs" */
+ object ValEq {
+ def apply(pat: Tree, rhs: Tree): Tree =
+ Assign(pat, rhs).updateAttachment(ForAttachment)
+
+ def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
+ case Assign(pat, rhs)
+ if tree.hasAttachment[ForAttachment.type] =>
+ Some((pat, rhs))
+ case _ => None
+ }
+ }
+
+ /** Encode/decode fq"if $cond" enumerator as q"`if`($cond)" */
+ object Filter {
+ def apply(tree: Tree) =
+ Apply(Ident(nme.IFkw).updateAttachment(ForAttachment), List(tree))
+
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Apply(id @ Ident(nme.IFkw), List(cond))
+ if id.hasAttachment[ForAttachment.type] =>
+ Some((cond))
+ case _ => None
+ }
+ }
+
+ /** Encode/decode body of for yield loop as q"`yield`($tree)" */
+ object Yield {
+ def apply(tree: Tree): Tree =
+ Apply(Ident(nme.YIELDkw).updateAttachment(ForAttachment), List(tree))
+
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Apply(id @ Ident(nme.YIELDkw), List(tree))
+ if id.hasAttachment[ForAttachment.type] =>
+ Some(tree)
+ case _ => None
+ }
+ }
+
+ /** Create tree for for-comprehension <for (enums) do body> or
+ * <for (enums) yield body> where mapName and flatMapName are chosen
+ * corresponding to whether this is a for-do or a for-yield.
+ * The creation performs the following rewrite rules:
+ *
+ * 1.
+ *
+ * for (P <- G) E ==> G.foreach (P => E)
+ *
+ * Here and in the following (P => E) is interpreted as the function (P => E)
+ * if P is a variable pattern and as the partial function { case P => E } otherwise.
+ *
+ * 2.
+ *
+ * for (P <- G) yield E ==> G.map (P => E)
+ *
+ * 3.
+ *
+ * for (P_1 <- G_1; P_2 <- G_2; ...) ...
+ * ==>
+ * G_1.flatMap (P_1 => for (P_2 <- G_2; ...) ...)
+ *
+ * 4.
+ *
+ * for (P <- G; E; ...) ...
+ * =>
+ * for (P <- G.filter (P => E); ...) ...
+ *
+ * 5. For N < MaxTupleArity:
+ *
+ * for (P_1 <- G; P_2 = E_2; val P_N = E_N; ...)
+ * ==>
+ * for (TupleN(P_1, P_2, ... P_N) <-
+ * for (x_1 @ P_1 <- G) yield {
+ * val x_2 @ P_2 = E_2
+ * ...
+ * val x_N & P_N = E_N
+ * TupleN(x_1, ..., x_N)
+ * } ...)
+ *
+ * If any of the P_i are variable patterns, the corresponding `x_i @ P_i' is not generated
+ * and the variable constituting P_i is used instead of x_i
+ *
+ * @param mapName The name to be used for maps (either map or foreach)
+ * @param flatMapName The name to be used for flatMaps (either flatMap or foreach)
+ * @param enums The enumerators in the for expression
+ * @param body The body of the for expression
+ */
+ def mkFor(enums: List[Tree], sugarBody: Tree)(implicit fresh: FreshNameCreator): Tree = {
+ val (mapName, flatMapName, body) = sugarBody match {
+ case Yield(tree) => (nme.map, nme.flatMap, tree)
+ case _ => (nme.foreach, nme.foreach, sugarBody)
+ }
+
+ /* make a closure pat => body.
+ * The closure is assigned a transparent position with the point at pos.point and
+ * the limits given by pat and body.
+ */
+ def makeClosure(pos: Position, pat: Tree, body: Tree): Tree = {
+ def wrapped = wrappingPos(List(pat, body))
+ def splitpos = (if (pos != NoPosition) wrapped.withPoint(pos.point) else pos).makeTransparent
+ matchVarPattern(pat) match {
+ case Some((name, tpt)) =>
+ Function(
+ List(atPos(pat.pos) { ValDef(Modifiers(PARAM), name.toTermName, tpt, EmptyTree) }),
+ body) setPos splitpos
+ case None =>
+ atPos(splitpos) {
+ mkVisitor(List(CaseDef(pat, EmptyTree, body)), checkExhaustive = false)
+ }
+ }
+ }
+
+ /* Make an application qual.meth(pat => body) positioned at `pos`.
+ */
+ def makeCombination(pos: Position, meth: TermName, qual: Tree, pat: Tree, body: Tree): Tree =
+ // ForAttachment on the method selection is used to differentiate
+ // result of for desugaring from a regular method call
+ Apply(Select(qual, meth) setPos qual.pos updateAttachment ForAttachment,
+ List(makeClosure(pos, pat, body))) setPos pos
+
+ /* If `pat` is not yet a `Bind` wrap it in one with a fresh name */
+ def makeBind(pat: Tree): Tree = pat match {
+ case Bind(_, _) => pat
+ case _ => Bind(freshTermName(), pat) setPos pat.pos
+ }
+
+ /* A reference to the name bound in Bind `pat`. */
+ def makeValue(pat: Tree): Tree = pat match {
+ case Bind(name, _) => Ident(name) setPos pat.pos.focus
+ }
+
+ /* The position of the closure that starts with generator at position `genpos`. */
+ def closurePos(genpos: Position) =
+ if (genpos == NoPosition) NoPosition
+ else {
+ val end = body.pos match {
+ case NoPosition => genpos.point
+ case bodypos => bodypos.end
+ }
+ rangePos(genpos.source, genpos.start, genpos.point, end)
+ }
+
+ enums match {
+ case (t @ ValFrom(pat, rhs)) :: Nil =>
+ makeCombination(closurePos(t.pos), mapName, rhs, pat, body)
+ case (t @ ValFrom(pat, rhs)) :: (rest @ (ValFrom(_, _) :: _)) =>
+ makeCombination(closurePos(t.pos), flatMapName, rhs, pat,
+ mkFor(rest, sugarBody))
+ case (t @ ValFrom(pat, rhs)) :: Filter(test) :: rest =>
+ mkFor(ValFrom(pat, makeCombination(rhs.pos union test.pos, nme.withFilter, rhs, pat.duplicate, test)).setPos(t.pos) :: rest, sugarBody)
+ case (t @ ValFrom(pat, rhs)) :: rest =>
+ val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile { ValEq.unapply(_).nonEmpty }
+ assert(!valeqs.isEmpty)
+ val rest1 = rest.drop(valeqs.length)
+ val pats = valeqs map { case ValEq(pat, _) => pat }
+ val rhss = valeqs map { case ValEq(_, rhs) => rhs }
+ val defpat1 = makeBind(pat)
+ val defpats = pats map makeBind
+ val pdefs = (defpats, rhss).zipped flatMap mkPatDef
+ val ids = (defpat1 :: defpats) map makeValue
+ val rhs1 = mkFor(
+ List(ValFrom(defpat1, rhs).setPos(t.pos)),
+ Yield(Block(pdefs, atPos(wrappingPos(ids)) { mkTuple(ids) }) setPos wrappingPos(pdefs)))
+ val allpats = (pat :: pats) map (_.duplicate)
+ val pos1 =
+ if (t.pos == NoPosition) NoPosition
+ else rangePos(t.pos.source, t.pos.start, t.pos.point, rhs1.pos.end)
+ val vfrom1 = ValFrom(atPos(wrappingPos(allpats)) { mkTuple(allpats) }, rhs1).setPos(pos1)
+ mkFor(vfrom1 :: rest1, sugarBody)
+ case _ =>
+ EmptyTree //may happen for erroneous input
+
+ }
+ }
+
+ /** Create tree for pattern definition <val pat0 = rhs> */
+ def mkPatDef(pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator): List[Tree] =
+ mkPatDef(Modifiers(0), pat, rhs)
+
+ /** Create tree for pattern definition <mods val pat0 = rhs> */
+ def mkPatDef(mods: Modifiers, pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator): List[Tree] = matchVarPattern(pat) match {
+ case Some((name, tpt)) =>
+ List(atPos(pat.pos union rhs.pos) {
+ ValDef(mods, name.toTermName, tpt, rhs)
+ })
+
+ case None =>
+ // in case there is exactly one variable x_1 in pattern
+ // val/var p = e ==> val/var x_1 = e.match (case p => (x_1))
+ //
+ // in case there are zero or more than one variables in pattern
+ // val/var p = e ==> private synthetic val t$ = e.match (case p => (x_1, ..., x_N))
+ // val/var x_1 = t$._1
+ // ...
+ // val/var x_N = t$._N
+
+ val rhsUnchecked = mkUnchecked(rhs)
+
+ // TODO: clean this up -- there is too much information packked into mkPatDef's `pat` argument
+ // when it's a simple identifier (case Some((name, tpt)) -- above),
+ // pat should have the type ascription that was specified by the user
+ // however, in `case None` (here), we must be careful not to generate illegal pattern trees (such as `(a, b): Tuple2[Int, String]`)
+ // i.e., this must hold: pat1 match { case Typed(expr, tp) => assert(expr.isInstanceOf[Ident]) case _ => }
+ // if we encounter such an erroneous pattern, we strip off the type ascription from pat and propagate the type information to rhs
+ val (pat1, rhs1) = patvarTransformer.transform(pat) match {
+ // move the Typed ascription to the rhs
+ case Typed(expr, tpt) if !expr.isInstanceOf[Ident] =>
+ val rhsTypedUnchecked =
+ if (tpt.isEmpty) rhsUnchecked
+ else Typed(rhsUnchecked, tpt) setPos (rhs.pos union tpt.pos)
+ (expr, rhsTypedUnchecked)
+ case ok =>
+ (ok, rhsUnchecked)
+ }
+ val vars = getVariables(pat1)
+ val matchExpr = atPos((pat1.pos union rhs.pos).makeTransparent) {
+ Match(
+ rhs1,
+ List(
+ atPos(pat1.pos) {
+ CaseDef(pat1, EmptyTree, mkTuple(vars map (_._1) map Ident.apply))
+ }
+ ))
+ }
+ vars match {
+ case List((vname, tpt, pos)) =>
+ List(atPos(pat.pos union pos union rhs.pos) {
+ ValDef(mods, vname.toTermName, tpt, matchExpr)
+ })
+ case _ =>
+ val tmp = freshTermName()
+ val firstDef =
+ atPos(matchExpr.pos) {
+ ValDef(Modifiers(PrivateLocal | SYNTHETIC | ARTIFACT | (mods.flags & LAZY)),
+ tmp, TypeTree(), matchExpr)
+ }
+ var cnt = 0
+ val restDefs = for ((vname, tpt, pos) <- vars) yield atPos(pos) {
+ cnt += 1
+ ValDef(mods, vname.toTermName, tpt, Select(Ident(tmp), newTermName("_" + cnt)))
+ }
+ firstDef :: restDefs
+ }
+ }
+
+ /** Create tree for for-comprehension generator <val pat0 <- rhs0> */
+ def mkGenerator(pos: Position, pat: Tree, valeq: Boolean, rhs: Tree)(implicit fresh: FreshNameCreator): Tree = {
+ val pat1 = patvarTransformer.transform(pat)
+ if (valeq) ValEq(pat1, rhs).setPos(pos)
+ else ValFrom(pat1, mkCheckIfRefutable(pat1, rhs)).setPos(pos)
+ }
+
+ def mkCheckIfRefutable(pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator) =
+ if (treeInfo.isVarPatternDeep(pat)) rhs
+ else {
+ val cases = List(
+ CaseDef(pat.duplicate, EmptyTree, Literal(Constant(true))),
+ CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(Constant(false)))
+ )
+ val visitor = mkVisitor(cases, checkExhaustive = false, nme.CHECK_IF_REFUTABLE_STRING)
+ atPos(rhs.pos)(Apply(Select(rhs, nme.withFilter), visitor :: Nil))
+ }
+
+ /** If tree is a variable pattern, return Some("its name and type").
+ * Otherwise return none */
+ private def matchVarPattern(tree: Tree): Option[(Name, Tree)] = {
+ def wildType(t: Tree): Option[Tree] = t match {
+ case Ident(x) if x.toTermName == nme.WILDCARD => Some(TypeTree())
+ case Typed(Ident(x), tpt) if x.toTermName == nme.WILDCARD => Some(tpt)
+ case _ => None
+ }
+ tree match {
+ case Ident(name) => Some((name, TypeTree()))
+ case Bind(name, body) => wildType(body) map (x => (name, x))
+ case Typed(Ident(name), tpt) => Some((name, tpt))
+ case _ => None
+ }
+ }
+
+ /** Create visitor <x => x match cases> */
+ def mkVisitor(cases: List[CaseDef], checkExhaustive: Boolean, prefix: String = "x$")(implicit fresh: FreshNameCreator): Tree = {
+ val x = freshTermName(prefix)
+ val id = Ident(x)
+ val sel = if (checkExhaustive) id else mkUnchecked(id)
+ Function(List(mkSyntheticParam(x)), Match(sel, cases))
+ }
+
+ /** Traverse pattern and collect all variable names with their types in buffer
+ * The variables keep their positions; whereas the pattern is converted to be
+ * synthetic for all nodes that contain a variable position.
+ */
+ class GetVarTraverser extends Traverser {
+ val buf = new ListBuffer[(Name, Tree, Position)]
+
+ def namePos(tree: Tree, name: Name): Position =
+ if (!tree.pos.isRange || name.containsName(nme.raw.DOLLAR)) tree.pos.focus
+ else {
+ val start = tree.pos.start
+ val end = start + name.decode.length
+ rangePos(tree.pos.source, start, start, end)
+ }
+
+ override def traverse(tree: Tree): Unit = {
+ def seenName(name: Name) = buf exists (_._1 == name)
+ def add(name: Name, t: Tree) = if (!seenName(name)) buf += ((name, t, namePos(tree, name)))
+ val bl = buf.length
+
+ tree match {
+ case Bind(nme.WILDCARD, _) =>
+ super.traverse(tree)
+
+ case Bind(name, Typed(tree1, tpt)) =>
+ val newTree = if (treeInfo.mayBeTypePat(tpt)) TypeTree() else tpt.duplicate
+ add(name, newTree)
+ traverse(tree1)
+
+ case Bind(name, tree1) =>
+ // can assume only name range as position, as otherwise might overlap
+ // with binds embedded in pattern tree1
+ add(name, TypeTree())
+ traverse(tree1)
+
+ case _ =>
+ super.traverse(tree)
+ }
+ if (buf.length > bl)
+ tree setPos tree.pos.makeTransparent
+ }
+ def apply(tree: Tree) = {
+ traverse(tree)
+ buf.toList
+ }
+ }
+
+ /** Returns list of all pattern variables, possibly with their types,
+ * without duplicates
+ */
+ private def getVariables(tree: Tree): List[(Name, Tree, Position)] =
+ new GetVarTraverser apply tree
+
+ /** Convert all occurrences of (lower-case) variables in a pattern as follows:
+ * x becomes x @ _
+ * x: T becomes x @ (_: T)
+ */
+ object patvarTransformer extends Transformer {
+ override def transform(tree: Tree): Tree = tree match {
+ case Ident(name) if (treeInfo.isVarPattern(tree) && name != nme.WILDCARD) =>
+ atPos(tree.pos)(Bind(name, atPos(tree.pos.focus) (Ident(nme.WILDCARD))))
+ case Typed(id @ Ident(name), tpt) if (treeInfo.isVarPattern(id) && name != nme.WILDCARD) =>
+ atPos(tree.pos.withPoint(id.pos.point)) {
+ Bind(name, atPos(tree.pos.withStart(tree.pos.point)) {
+ Typed(Ident(nme.WILDCARD), tpt)
+ })
+ }
+ case Apply(fn @ Apply(_, _), args) =>
+ treeCopy.Apply(tree, transform(fn), transformTrees(args))
+ case Apply(fn, args) =>
+ treeCopy.Apply(tree, fn, transformTrees(args))
+ case Typed(expr, tpt) =>
+ treeCopy.Typed(tree, transform(expr), tpt)
+ case Bind(name, body) =>
+ treeCopy.Bind(tree, name, transform(body))
+ case Alternative(_) | Star(_) =>
+ super.transform(tree)
+ case _ =>
+ tree
+ }
+ }
+
+ // annotate the expression with @unchecked
+ def mkUnchecked(expr: Tree): Tree = atPos(expr.pos) {
+ // This can't be "Annotated(New(UncheckedClass), expr)" because annotations
+ // are very picky about things and it crashes the compiler with "unexpected new".
+ Annotated(New(scalaDot(tpnme.unchecked), Nil), expr)
+ }
+
+ def mkSyntheticParam(pname: TermName) =
+ ValDef(Modifiers(PARAM | SYNTHETIC), pname, TypeTree(), EmptyTree)
}
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 025965ad47..a933a5d189 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -18,7 +18,7 @@ abstract class TreeInfo {
val global: SymbolTable
import global._
- import definitions.{ isTupleSymbol, isVarArgsList, isCastSymbol, ThrowableClass, TupleClass, MacroContextClass, MacroContextPrefixType, uncheckedStableClass }
+ import definitions.{ isTupleSymbol, isVarArgsList, isCastSymbol, ThrowableClass, TupleClass, uncheckedStableClass, isBlackboxMacroBundleType, isWhiteboxContextType }
/* Does not seem to be used. Not sure what it does anyway.
def isOwnerDefinition(tree: Tree): Boolean = tree match {
@@ -822,13 +822,19 @@ abstract class TreeInfo {
case ref: RefTree => {
val qual = ref.qualifier
val isBundle = definitions.isMacroBundleType(qual.tpe)
+ val isBlackbox =
+ if (isBundle) isBlackboxMacroBundleType(qual.tpe)
+ else ref.symbol.paramss match {
+ case (c :: Nil) :: _ if isWhiteboxContextType(c.info) => false
+ case _ => true
+ }
val owner =
if (isBundle) qual.tpe.typeSymbol
else {
- val sym = if (qual.hasSymbolField) qual.symbol else NoSymbol
- if (sym.isModule) sym.moduleClass else sym
+ val qualSym = if (qual.hasSymbolField) qual.symbol else NoSymbol
+ if (qualSym.isModule) qualSym.moduleClass else qualSym
}
- Some((isBundle, owner, ref.symbol, dissectApplied(tree).targs))
+ Some((isBundle, isBlackbox, owner, ref.symbol, dissectApplied(tree).targs))
}
case _ => None
}
@@ -842,7 +848,7 @@ abstract class TreeInfo {
})
def isMacroApplication(tree: Tree): Boolean =
- !tree.isDef && tree.symbol != null && tree.symbol.isMacro && !tree.symbol.isErroneous
+ !tree.isDef && tree.symbol != null && tree.symbol.isTermMacro && !tree.symbol.isErroneous
def isMacroApplicationOrBlock(tree: Tree): Boolean = tree match {
case Block(_, expr) => isMacroApplicationOrBlock(expr)
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 743c674eea..d191fbd38f 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -490,7 +490,7 @@ trait Trees extends api.Trees {
case class Ident(name: Name) extends RefTree with IdentContextApi {
def qualifier: Tree = EmptyTree
- def isBackquoted = this.attachments.get[BackquotedIdentifierAttachment.type].isDefined
+ def isBackquoted = this.hasAttachment[BackquotedIdentifierAttachment.type]
}
object Ident extends IdentExtractor
@@ -590,7 +590,7 @@ trait Trees extends api.Trees {
def TypeTree(tp: Type): TypeTree = TypeTree() setType tp
private def TypeTreeMemberType(sym: Symbol): TypeTree = {
// Needed for pos/t4970*.scala. See SI-7853
- val resType = (sym.owner.thisType memberType sym).finalResultType
+ val resType = (if (sym.isLocal) sym.tpe else (sym.owner.thisType memberType sym)).finalResultType
atPos(sym.pos.focus)(TypeTree(resType))
}
@@ -1804,6 +1804,12 @@ trait Trees extends api.Trees {
case t =>
sys.error("Not a LabelDef: " + t + "/" + t.getClass)
}
+ def deriveFunction(func: Tree)(applyToRhs: Tree => Tree): Function = func match {
+ case Function(params0, rhs0) =>
+ treeCopy.Function(func, params0, applyToRhs(rhs0))
+ case t =>
+ sys.error("Not a Function: " + t + "/" + t.getClass)
+ }
// -------------- Classtags --------------------------------------------------------
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index 9a54ad8217..f5aa048e6a 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -717,6 +717,12 @@ private[internal] trait TypeMaps {
else appliedType(tcon.typeConstructor, args)
case SingleType(NoPrefix, sym) =>
substFor(sym)
+ case ClassInfoType(parents, decls, sym) =>
+ val parents1 = parents mapConserve this
+ // We don't touch decls here; they will be touched when an enclosing TreeSubstitutor
+ // transforms the tree that defines them.
+ if (parents1 eq parents) tp
+ else ClassInfoType(parents1, decls, sym)
case _ =>
tp
}
diff --git a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
index 3e54de8e1e..8442c1015f 100644
--- a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
+++ b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala
@@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicLong
import scala.collection.mutable
import scala.reflect.NameTransformer
-class FreshNameCreator {
+class FreshNameCreator(creatorPrefix: String = "") {
protected val counters = new ConcurrentHashMap[String, AtomicLong]()
/**
@@ -21,7 +21,8 @@ class FreshNameCreator {
*/
def newName(prefix: String): String = {
val safePrefix = NameTransformer.encode(prefix)
- counters.putIfAbsent(safePrefix, new AtomicLong(0));
- safePrefix + counters.get(safePrefix).incrementAndGet();
+ counters.putIfAbsent(safePrefix, new AtomicLong(0))
+ val idx = counters.get(safePrefix).incrementAndGet()
+ s"$creatorPrefix$safePrefix$idx"
}
}
diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala
index 9e05f343e6..ca599dbd49 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.Context the Scala macros context]] that defines shorthands for the
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that defines shorthands for the
* most frequently used types and functions of the underlying compiler universe.
*/
trait Aliases {
- self: Context =>
+ self: BlackboxContext =>
/** The type of symbols representing declarations. */
type Symbol = universe.Symbol
diff --git a/src/reflect/scala/reflect/macros/Attachments.scala b/src/reflect/scala/reflect/macros/Attachments.scala
index c1ab269268..039e75fbee 100644
--- a/src/reflect/scala/reflect/macros/Attachments.scala
+++ b/src/reflect/scala/reflect/macros/Attachments.scala
@@ -41,6 +41,10 @@ abstract class Attachments { self =>
def get[T: ClassTag]: Option[T] =
(all filter matchesTag[T]).headOption.asInstanceOf[Option[T]]
+ /** Check underlying payload contains an instance of type `T`. */
+ def contains[T: ClassTag]: Boolean =
+ all exists matchesTag[T]
+
/** Creates a copy of this attachment with the payload slot of T added/updated with the provided value.
* Replaces an existing payload of the same type, if exists.
*/
diff --git a/src/reflect/scala/reflect/macros/Context.scala b/src/reflect/scala/reflect/macros/BlackboxContext.scala
index b0c816f4ad..2c77289866 100644
--- a/src/reflect/scala/reflect/macros/Context.scala
+++ b/src/reflect/scala/reflect/macros/BlackboxContext.scala
@@ -2,14 +2,10 @@ package scala
package reflect
package macros
-// todo. introduce context hierarchy
-// the most lightweight context should just expose the stuff from the SIP
-// the full context should include all traits from scala.reflect.macros (and probably reside in scala-compiler.jar)
-
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * The Scala macros context.
+ * The blackbox Scala macros context.
*
* See [[scala.reflect.macros.package the overview page]] for a description of how macros work. This documentation
* entry provides information on the API available to macro writers.
@@ -27,17 +23,25 @@ package macros
* Other than that, macro contexts provide facilities for typechecking, exploring the compiler's symbol table and
* 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,
+ * 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,
+ * 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`
*/
-trait Context extends Aliases
- with Enclosures
- with Names
- with Reifiers
- with FrontEnds
- with Infrastructure
- with Typers
- with Parsers
- with Evals
- with ExprUtils {
+trait BlackboxContext 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
@@ -59,7 +63,7 @@ trait Context extends Aliases
* scala> class Coll[T] {
* | def filter(p: T => Boolean): Coll[T] = macro M.filter[T]
* | }; object M {
- * | def filter[T](c: Context { type PrefixType = Coll[T] })
+ * | def filter[T](c: BlackboxContext { 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/Macro.scala b/src/reflect/scala/reflect/macros/BlackboxMacro.scala
index 44bedf483d..df142e9238 100644
--- a/src/reflect/scala/reflect/macros/Macro.scala
+++ b/src/reflect/scala/reflect/macros/BlackboxMacro.scala
@@ -6,15 +6,15 @@ package macros
*
* 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.Macro`.
+ * bundles, traits which extend `scala.reflect.macros.BlackboxMacro` or`scala.reflect.macros.WhiteboxMacro` .
*
* Instead of:
*
- * def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int]) = ...
+ * def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[Int]) = ...
*
* One can write:
*
- * trait Impl extends Macro {
+ * trait Impl extends BlackboxMacro {
* def apply[T: c.WeakTypeTag](x: c.Expr[Int]) = ...
* }
*
@@ -24,16 +24,13 @@ package macros
* 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.
*
- * However utility of this approach to writing macros isn't limited to just convenience.
- * When a macro implementation becomes not just a function, but a full-fledged module,
- * it can define callbacks that will be called by the compiler upon interesting events.
- * In subsequent commits I will add support for programmable type inference
+ * @see `scala.reflect.macros.WhiteboxMacro`
*/
-trait Macro {
+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: Context
+ val c: BlackboxContext
}
diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala
index d6ba5f39cd..31905c4739 100644
--- a/src/reflect/scala/reflect/macros/Enclosures.scala
+++ b/src/reflect/scala/reflect/macros/Enclosures.scala
@@ -7,13 +7,13 @@ import scala.language.existentials // SI-6541
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.Context the Scala macros context]] that exposes
+ * A slice of [[scala.reflect.macros.BlackboxContext 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: Context =>
+ self: BlackboxContext =>
/** The tree that undergoes macro expansion.
* Can be useful to get an offset or a range position of the entire tree being processed.
@@ -43,19 +43,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[Context]
-
- /** Information about one of the currently considered implicit candidates.
- * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
- * hence implicit searches can recursively trigger other implicit searches.
- *
- * Can be useful to get information about an application with an implicit parameter that is materialized during current macro expansion.
- * If we're in an implicit macro being expanded, it's included in this list.
- *
- * Unlike `openImplicits`, 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 enclosingImplicits: List[ImplicitCandidate]
+ def enclosingMacros: List[BlackboxContext]
/** 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 70b2ab58d4..eb37e83cad 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.Context the Scala macros context]] that provides
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that provides
* a facility to evaluate trees.
*/
trait Evals {
- self: Context =>
+ self: BlackboxContext =>
/** 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: Context)(x: c.Expr[String]) = {
+ * scala> def impl(c: BlackboxContext)(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: Context)(x: c.Expr[String])c.Expr[String]
+ * impl: (c: BlackboxContext)(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 76a8392b9c..58b61e446a 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.Context the Scala macros context]] that defines shorthands for the
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that defines shorthands for the
* most common `Expr`-creating functions.
*/
trait ExprUtils {
- self: Context =>
+ self: BlackboxContext =>
/** 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 6abd8c335b..3a910d89ad 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.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext 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: Context =>
+ self: BlackboxContext =>
/** 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 eb63fb7b7f..b6585f94d2 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.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
* provides facilities to communicate with the compiler's infrastructure.
*/
trait Infrastructure {
- self: Context =>
+ self: BlackboxContext =>
/** 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 8773175561..6bd3e1a199 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.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
* provides functions that generate unique names.
*/
trait Names {
- self: Context =>
+ self: BlackboxContext =>
/** 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 4232b05f8c..cbfb30f022 100644
--- a/src/reflect/scala/reflect/macros/Parsers.scala
+++ b/src/reflect/scala/reflect/macros/Parsers.scala
@@ -5,12 +5,12 @@ package macros
/**
* <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
*
- * A slice of [[scala.reflect.macros.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
* exposes functions to parse strings with Scala code into trees.
*/
@deprecated("Use quasiquotes instead", "2.11.0")
trait Parsers {
- self: Context =>
+ self: BlackboxContext =>
/** 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 6ebd2db730..67d10dc10a 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.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
* exposes functions to save reflection artifacts for runtime.
*/
trait Reifiers {
- self: Context =>
+ self: BlackboxContext =>
/** 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 d7aec9b3ef..29c1af110b 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.Context the Scala macros context]] that
+ * A slice of [[scala.reflect.macros.BlackboxContext the Scala macros context]] that
* partially exposes the type checker to macro writers.
*/
trait Typers {
- self: Context =>
+ self: BlackboxContext =>
/** 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,28 +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[Context]
-
- /** Information about one of the currently considered implicit candidates.
- * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
- * hence implicit searches can recursively trigger other implicit searches.
- *
- * `pre` and `sym` provide information about the candidate itself.
- * `pt` and `tree` store the parameters of the implicit search the candidate is participating in.
- */
- case class ImplicitCandidate(pre: Type, sym: Symbol, pt: Type, tree: Tree)
-
- /** Information about one of the currently considered implicit candidates.
- * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
- * hence implicit searches can recursively trigger other implicit searches.
- *
- * Can be useful to get information about an application with an implicit parameter that is materialized during current macro expansion.
- * If we're in an implicit macro being expanded, it's included in this list.
- *
- * Unlike `enclosingImplicits`, 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 openImplicits: List[ImplicitCandidate]
+ def openMacros: List[BlackboxContext]
/** Typechecks the provided tree against the expected type `pt` in the macro callsite context.
*
diff --git a/src/reflect/scala/reflect/macros/WhiteboxContext.scala b/src/reflect/scala/reflect/macros/WhiteboxContext.scala
new file mode 100644
index 0000000000..9d65a5c16e
--- /dev/null
+++ b/src/reflect/scala/reflect/macros/WhiteboxContext.scala
@@ -0,0 +1,76 @@
+package scala
+package reflect
+package macros
+
+/**
+ * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
+ *
+ * The whitebox Scala macros context.
+ *
+ * See [[scala.reflect.macros.package the overview page]] for a description of how macros work. This documentation
+ * entry provides information on the API available to macro writers.
+ *
+ * A macro context wraps a compiler universe exposed in `universe` and having type [[scala.reflect.macros.Universe]].
+ * This type is a refinement over the generic reflection API provided in [[scala.reflect.api.Universe]]. The
+ * extended Universe provides mutability for reflection artifacts (e.g. macros can change types of compiler trees,
+ * add annotation to symbols representing definitions, etc) and exposes some internal compiler functionality
+ * such as `Symbol.deSkolemize` or `Tree.attachments`.
+ *
+ * Another fundamental part of a macro context is `macroApplication`, which provides access to the tree undergoing
+ * macro expansion. Parts of this tree can be found in arguments of the corresponding macro implementations and
+ * in `prefix`, but `macroApplication` gives the full picture.
+ *
+ * Other than that, macro contexts provide facilities for typechecking, exploring the compiler's symbol table and
+ * 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,
+ * 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.
+ * 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`
+ */
+trait WhiteboxContext extends BlackboxContext {
+ /** @inheritdoc
+ */
+ def openMacros: List[WhiteboxContext]
+
+ /** @inheritdoc
+ */
+ def enclosingMacros: List[WhiteboxContext]
+
+ /** Information about one of the currently considered implicit candidates.
+ * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
+ * hence implicit searches can recursively trigger other implicit searches.
+ *
+ * `pre` and `sym` provide information about the candidate itself.
+ * `pt` and `tree` store the parameters of the implicit search the candidate is participating in.
+ */
+ case class ImplicitCandidate(pre: Type, sym: Symbol, pt: Type, tree: Tree)
+
+ /** Information about one of the currently considered implicit candidates.
+ * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
+ * hence implicit searches can recursively trigger other implicit searches.
+ *
+ * Can be useful to get information about an application with an implicit parameter that is materialized during current macro expansion.
+ * If we're in an implicit macro being expanded, it's included in this list.
+ *
+ * Unlike `enclosingImplicits`, 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 openImplicits: List[ImplicitCandidate]
+
+ /** Information about one of the currently considered implicit candidates.
+ * Candidates are used in plural form, because implicit parameters may themselves have implicit parameters,
+ * hence implicit searches can recursively trigger other implicit searches.
+ *
+ * Can be useful to get information about an application with an implicit parameter that is materialized during current macro expansion.
+ * If we're in an implicit macro being expanded, it's included in this list.
+ *
+ * Unlike `openImplicits`, 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 enclosingImplicits: List[ImplicitCandidate]
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/macros/WhiteboxMacro.scala b/src/reflect/scala/reflect/macros/WhiteboxMacro.scala
new file mode 100644
index 0000000000..1c581313eb
--- /dev/null
+++ b/src/reflect/scala/reflect/macros/WhiteboxMacro.scala
@@ -0,0 +1,36 @@
+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/package.scala b/src/reflect/scala/reflect/macros/package.scala
index 2e2e8e79f8..6a8434a163 100644
--- a/src/reflect/scala/reflect/macros/package.scala
+++ b/src/reflect/scala/reflect/macros/package.scala
@@ -7,10 +7,22 @@ package reflect
* The base package for Scala macros.
*
* Macros are functions that are called by the compiler during compilation.
- * Within these functions the programmer has access to compiler APIs exposed in [[scala.reflect.macros.Context]].
+ * Within these functions the programmer has access to compiler APIs.
* For example, it is possible to generate, analyze and typecheck code.
*
* See the [[http://docs.scala-lang.org/overviews/macros.html Macros Guide]] on how to get started with Scala macros.
*/
package object macros {
+ /** The Scala macros context.
+ *
+ * In Scala 2.11, macros that were once the one are split into blackbox and whitebox 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,
+ * 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
} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 4d69a6673c..344f7682c1 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -51,10 +51,12 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
// inaccessible: this.SimpleNameOrdering
this.traceSymbols
this.perRunCaches
+ this.FreshNameExtractor
this.FixedMirrorTreeCreator
this.FixedMirrorTypeCreator
- this.BackquotedIdentifierAttachment
this.CompoundTypeTreeOriginalAttachment
+ this.BackquotedIdentifierAttachment
+ this.ForAttachment
this.noPrint
this.typeDebug
// inaccessible: this.maxFree
@@ -314,8 +316,10 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.TypeCreatorClass
definitions.TreeCreatorClass
definitions.LiftableClass
- definitions.MacroClass
- definitions.MacroContextClass
+ definitions.BlackboxMacroClass
+ definitions.WhiteboxMacroClass
+ definitions.BlackboxContextClass
+ definitions.WhiteboxContextClass
definitions.MacroImplAnnotation
definitions.StringContextClass
definitions.QuasiquoteClass
@@ -334,6 +338,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.TupleClass
definitions.FunctionClass
definitions.AbstractFunctionClass
+ definitions.MacroContextType
definitions.ProductRootClass
definitions.Any_$eq$eq
definitions.Any_$bang$eq
diff --git a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala
index 298d0ffebd..1a232c8de1 100644
--- a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala
+++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala
@@ -32,8 +32,15 @@ private[reflect] trait SynchronizedSymbols extends internal.Symbols { self: Symb
trait SynchronizedSymbol extends Symbol {
def gilSynchronizedIfNotInited[T](body: => T): T = {
- if (isFullyInitialized) body
- else gilSynchronized { body }
+ // TODO JZ desired, but prone to race conditions. We need the runtime reflection based
+ // type completers to establish a memory barrier upon initialization. Maybe a volatile
+ // write? We need to consult with the experts here. Until them, lock pessimistically.
+ //
+ // `run/reflection-sync-subtypes.scala` fails about 1/50 times otherwise.
+ //
+ // if (isFullyInitialized) body
+ // else gilSynchronized { body }
+ gilSynchronized { body }
}
override def validTo = gilSynchronizedIfNotInited { super.validTo }
diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala
index 41c1310e17..3a7688aa2c 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.Context): c.Expr[universe.Mirror] = {
+ def currentMirror(c: scala.reflect.macros.BlackboxContext): 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/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala
index 0d55423247..8fba1e538e 100644
--- a/src/repl/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala
@@ -9,10 +9,11 @@ package interpreter
import PartialFunction.cond
import scala.language.implicitConversions
+import scala.beans.BeanProperty
import scala.collection.mutable
import scala.concurrent.{ Future, ExecutionContext }
import scala.reflect.runtime.{ universe => ru }
-import scala.reflect.{ BeanProperty, ClassTag, classTag }
+import scala.reflect.{ ClassTag, classTag }
import scala.reflect.internal.util.{ BatchSourceFile, SourceFile }
import scala.tools.util.PathResolver
import scala.tools.nsc.io.AbstractFile
diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
index 50c90968af..496d5face1 100644
--- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
@@ -180,7 +180,7 @@ class JavapClass(
/** Base class for javap tool adapters for java 6 and 7. */
abstract class JavapTool {
type ByteAry = Array[Byte]
- type Input = Pair[String, Try[ByteAry]]
+ type Input = Tuple2[String, Try[ByteAry]]
/** Run the tool. */
def apply(raw: Boolean, options: Seq[String])(inputs: Seq[Input]): List[JpResult]
diff --git a/src/scaladoc/scala/tools/ant/Scaladoc.scala b/src/scaladoc/scala/tools/ant/Scaladoc.scala
index fd6d637212..36a1405b11 100644
--- a/src/scaladoc/scala/tools/ant/Scaladoc.scala
+++ b/src/scaladoc/scala/tools/ant/Scaladoc.scala
@@ -574,7 +574,7 @@ class Scaladoc extends ScalaMatchingTask {
\*============================================================================*/
/** Initializes settings and source files */
- protected def initialize: Pair[Settings, List[File]] = {
+ protected def initialize: Tuple2[Settings, List[File]] = {
// Tests if all mandatory attributes are set and valid.
if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (getOrigin.isEmpty) buildError("Attribute 'srcdir' is not set.")
@@ -660,14 +660,14 @@ class Scaladoc extends ScalaMatchingTask {
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
docSettings processArgumentString addParams
- Pair(docSettings, sourceFiles)
+ (docSettings, sourceFiles)
}
def safeBuildError(message: String): Unit = if (nofail) log(message) else buildError(message)
/** Performs the compilation. */
override def execute() = {
- val Pair(docSettings, sourceFiles) = initialize
+ val (docSettings, sourceFiles) = initialize
val reporter = new ConsoleReporter(docSettings)
try {
val docProcessor = new scala.tools.nsc.doc.DocFactory(reporter, docSettings)
diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala
index 41346d13c0..cb0a92b6b3 100644
--- a/src/scalap/scala/tools/scalap/Arguments.scala
+++ b/src/scalap/scala/tools/scalap/Arguments.scala
@@ -46,8 +46,8 @@ object Arguments {
}
def parseBinding(str: String, separator: Char): (String, String) = (str indexOf separator) match {
- case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; Pair("", "")
- case idx => Pair((str take idx).trim, (str drop (idx + 1)).trim)
+ case -1 => argumentError("missing '" + separator + "' in binding '" + str + "'") ; ("", "")
+ case idx => ((str take idx).trim, (str drop (idx + 1)).trim)
}
def parse(args: Array[String]): Arguments = {
@@ -141,7 +141,7 @@ class Arguments {
if (key.length > 0)
bindings.getOrElseUpdate(tag, new mutable.HashMap)(key) = value
- def addBinding(tag: String, binding: Pair[String, String]): Unit =
+ def addBinding(tag: String, binding: Tuple2[String, String]): Unit =
addBinding(tag, binding._1, binding._2)
def addOther(arg: String): Unit = others += arg
diff --git a/test/build-partest.xml b/test/build-partest.xml
index 22ad85ac03..e909a09123 100755
--- a/test/build-partest.xml
+++ b/test/build-partest.xml
@@ -7,6 +7,7 @@
<attribute name="srcdir" default="files"/> <!-- TODO: make targets for `pending` and other subdirs -->
<attribute name="colors" default="${partest.colors}"/>
<attribute name="scalacOpts" default="${scalac.args.optimise}"/>
+ <attribute name="pcp" default="${toString:partest.compilation.path}"/>
<attribute name="kinds"/>
<sequential>
<property name="partest.dir" value="@{dir}" />
@@ -14,7 +15,7 @@
kinds="@{kinds}"
colors="@{colors}"
scalacOpts="@{scalacOpts}"
- compilationpathref="partest.compilation.path"/>
+ compilationpath="@{pcp}"/>
</sequential>
</macrodef>
</project>
diff --git a/test/disabled/run/lisp.scala b/test/disabled/run/lisp.scala
index 06e68f508a..73f24da757 100644
--- a/test/disabled/run/lisp.scala
+++ b/test/disabled/run/lisp.scala
@@ -12,11 +12,11 @@ class LispTokenizer(s: String) extends Iterator[String] {
while (i < s.length() && s.charAt(i) <= ' ') i += 1
i < s.length()
}
- def next: String =
+ def next: String =
if (hasNext) {
val start = i
if (isDelimiter(s charAt i)) i += 1
- else
+ else
do i = i + 1
while (!isDelimiter(s charAt i))
s.substring(start, i)
@@ -190,10 +190,10 @@ object LispCaseClasses extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
@@ -381,10 +381,10 @@ object LispAny extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala
index 791b1d3100..1ff7ee516e 100644
--- a/test/files/jvm/non-fatal-tests.scala
+++ b/test/files/jvm/non-fatal-tests.scala
@@ -4,8 +4,7 @@ trait NonFatalTests {
//NonFatals
val nonFatals: Seq[Throwable] =
- Seq(new StackOverflowError,
- new RuntimeException,
+ Seq(new RuntimeException,
new Exception,
new Throwable,
new NotImplementedError)
@@ -13,6 +12,7 @@ trait NonFatalTests {
//Fatals
val fatals: Seq[Throwable] =
Seq(new InterruptedException,
+ new StackOverflowError,
new OutOfMemoryError,
new LinkageError,
new VirtualMachineError {},
diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala
index 1d6f0b7907..4f900d98d7 100644
--- a/test/files/jvm/typerep.scala
+++ b/test/files/jvm/typerep.scala
@@ -86,7 +86,7 @@ object testArrays {
object testTuples {
println(getType((3, "abc")))
- println(getType(Triple('a', 'b', "c")))
+ println(getType(('a', 'b', "c")))
println(getType(((3, "abc"), (4, "xyz"))))
println(getType(((Some('b'), 3), (Some('a'), 4))))
//println(getType(((Some('b'), 3), (None, 4))))
diff --git a/test/files/neg/class-of-double-targs.check b/test/files/neg/class-of-double-targs.check
new file mode 100644
index 0000000000..f7e2094f97
--- /dev/null
+++ b/test/files/neg/class-of-double-targs.check
@@ -0,0 +1,4 @@
+class-of-double-targs.scala:2: error: expression of type Class[Int](classOf[scala.Int]) does not take type parameters.
+ classOf[Int][Int]
+ ^
+one error found
diff --git a/test/files/neg/class-of-double-targs.scala b/test/files/neg/class-of-double-targs.scala
new file mode 100644
index 0000000000..26a2fa8381
--- /dev/null
+++ b/test/files/neg/class-of-double-targs.scala
@@ -0,0 +1,3 @@
+object Test {
+ classOf[Int][Int]
+}
diff --git a/test/files/neg/macro-abort/Macros_1.scala b/test/files/neg/macro-abort/Macros_1.scala
index 676c112098..577e640089 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 97780ef503..ae34815d37 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
diff --git a/test/files/neg/macro-blackbox-dynamic-materialization.check b/test/files/neg/macro-blackbox-dynamic-materialization.check
new file mode 100644
index 0000000000..f6c73f7edb
--- /dev/null
+++ b/test/files/neg/macro-blackbox-dynamic-materialization.check
@@ -0,0 +1,4 @@
+Test_2.scala:2: error: I don't like classes that contain integers
+ println(implicitly[Foo[C1]])
+ ^
+one error found
diff --git a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala
new file mode 100644
index 0000000000..a00d195005
--- /dev/null
+++ b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala
@@ -0,0 +1,25 @@
+import scala.reflect.macros.BlackboxContext
+import scala.language.experimental.macros
+
+trait Foo[T]
+
+class C1(val x: Int)
+class C2(val x: String)
+
+trait LowPriority {
+ implicit def lessSpecific[T]: Foo[T] = null
+}
+
+object Foo extends LowPriority {
+ implicit def moreSpecific[T]: Foo[T] = macro Macros.impl[T]
+}
+
+object Macros {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
+ import c.universe._
+ val tpe = weakTypeOf[T]
+ if (tpe.members.exists(_.typeSignature =:= typeOf[Int]))
+ c.abort(c.enclosingPosition, "I don't like classes that contain integers")
+ q"new Foo[$tpe]{ override def toString = ${tpe.toString} }"
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/macro-blackbox-dynamic-materialization/Test_2.scala b/test/files/neg/macro-blackbox-dynamic-materialization/Test_2.scala
new file mode 100644
index 0000000000..bf19209ab7
--- /dev/null
+++ b/test/files/neg/macro-blackbox-dynamic-materialization/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ println(implicitly[Foo[C1]])
+ println(implicitly[Foo[C2]])
+} \ No newline at end of file
diff --git a/test/files/neg/macro-blackbox-extractor.check b/test/files/neg/macro-blackbox-extractor.check
new file mode 100644
index 0000000000..4c53ff19b8
--- /dev/null
+++ b/test/files/neg/macro-blackbox-extractor.check
@@ -0,0 +1,4 @@
+Test_2.scala:3: error: extractor macros can only be whitebox
+ case Extractor(x) => println(x)
+ ^
+one error found
diff --git a/test/files/neg/macro-blackbox-extractor/Macros_1.scala b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
new file mode 100644
index 0000000000..5c7748bec9
--- /dev/null
+++ b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
@@ -0,0 +1,21 @@
+import scala.reflect.macros.BlackboxContext
+import language.experimental.macros
+
+object Extractor {
+ def unapply(x: Int) = macro Macros.unapplyImpl
+}
+
+object Macros {
+ def unapplyImpl(c: BlackboxContext)(x: c.Tree) = {
+ import c.universe._
+ q"""
+ new {
+ class Match(x: Int) {
+ def isEmpty = false
+ def get = x
+ }
+ def unapply(x: Int) = new Match(x)
+ }.unapply($x)
+ """
+ }
+}
diff --git a/test/files/neg/macro-blackbox-extractor/Test_2.scala b/test/files/neg/macro-blackbox-extractor/Test_2.scala
new file mode 100644
index 0000000000..41be6f9767
--- /dev/null
+++ b/test/files/neg/macro-blackbox-extractor/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ 42 match {
+ case Extractor(x) => println(x)
+ }
+}
diff --git a/test/files/neg/macro-blackbox-fundep-materialization.check b/test/files/neg/macro-blackbox-fundep-materialization.check
new file mode 100644
index 0000000000..3c03064a2d
--- /dev/null
+++ b/test/files/neg/macro-blackbox-fundep-materialization.check
@@ -0,0 +1,8 @@
+Test_2.scala:7: error: type mismatch;
+ found : Iso[Test.Foo,(Int, String, Boolean)]
+ required: Iso[Test.Foo,Nothing]
+Note: (Int, String, Boolean) >: Nothing, but trait Iso is invariant in type U.
+You may wish to define U as -U instead. (SLS 4.5)
+ val equiv = foo(Foo(23, "foo", true))
+ ^
+one error found
diff --git a/test/files/neg/macro-blackbox-fundep-materialization.flags b/test/files/neg/macro-blackbox-fundep-materialization.flags
new file mode 100644
index 0000000000..4c6cdb71e2
--- /dev/null
+++ b/test/files/neg/macro-blackbox-fundep-materialization.flags
@@ -0,0 +1 @@
+-Xlog-implicits \ No newline at end of file
diff --git a/test/files/run/t5923c/Macros_1.scala b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala
index 0b7a3399e2..6bddef4b9d 100644
--- a/test/files/run/t5923c/Macros_1.scala
+++ b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala
@@ -1,5 +1,5 @@
-import language.experimental.macros
-import scala.reflect.macros.Context
+import scala.language.experimental.macros
+import scala.reflect.macros.BlackboxContext
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: Context): c.Expr[Iso[T, U]] = {
+ def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext): c.Expr[Iso[T, U]] = {
import c.universe._
import definitions._
import Flag._
diff --git a/test/files/run/t5923c/Test_2.scala b/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala
index a00f4ed7db..a00f4ed7db 100644
--- a/test/files/run/t5923c/Test_2.scala
+++ b/test/files/neg/macro-blackbox-fundep-materialization/Test_2.scala
diff --git a/test/files/neg/macro-blackbox-structural.check b/test/files/neg/macro-blackbox-structural.check
new file mode 100644
index 0000000000..86a218559c
--- /dev/null
+++ b/test/files/neg/macro-blackbox-structural.check
@@ -0,0 +1,4 @@
+Test_2.scala:4: error: value x is not a member of Any
+ println(Macros.foo.x)
+ ^
+one error found
diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
new file mode 100644
index 0000000000..08f1c21e89
--- /dev/null
+++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: scala.reflect.macros.BlackboxContext) = {
+ import c.universe._
+ q"""
+ trait Foo {
+ def x = 2
+ }
+ new Foo {}
+ """
+ }
+
+ def foo = macro impl
+} \ No newline at end of file
diff --git a/test/files/neg/macro-blackbox-structural/Test_2.scala b/test/files/neg/macro-blackbox-structural/Test_2.scala
new file mode 100644
index 0000000000..ea6a817e34
--- /dev/null
+++ b/test/files/neg/macro-blackbox-structural/Test_2.scala
@@ -0,0 +1,5 @@
+import Macros._
+
+object Test extends App {
+ println(Macros.foo.x)
+} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check
index 4b07adcc95..8ef59106b8 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:5: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined
-trait Bundle extends Macro {
+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 {
^
one error found
diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala
index 2b302045da..f7778d03be 100644
--- a/test/files/neg/macro-bundle-abstract.scala
+++ b/test/files/neg/macro-bundle-abstract.scala
@@ -1,8 +1,7 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxMacro
-trait Bundle extends Macro {
+trait Bundle extends BlackboxMacro {
def deferred: Int
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check
index 92695390ab..8fd04f1303 100644
--- a/test/files/neg/macro-bundle-class.check
+++ b/test/files/neg/macro-bundle-class.check
@@ -1,4 +1,4 @@
-macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member
+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
index 4b92cdd40f..024e2dbaaa 100644
--- a/test/files/neg/macro-bundle-class.scala
+++ b/test/files/neg/macro-bundle-class.scala
@@ -1,8 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.BlackboxContext
-class Bundle(val c: Context) extends Macro {
+class Bundle(val c: BlackboxContext) extends BlackboxMacro {
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-mixbox.check b/test/files/neg/macro-bundle-mixbox.check
new file mode 100644
index 0000000000..4f8cedcece
--- /dev/null
+++ b/test/files/neg/macro-bundle-mixbox.check
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000000..1e36f3d94c
--- /dev/null
+++ b/test/files/neg/macro-bundle-mixbox.scala
@@ -0,0 +1,10 @@
+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-object.check b/test/files/neg/macro-bundle-object.check
index 8c19271b51..e148e86969 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:11: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
+macro-bundle-object.scala:10: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): 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 98c4238a62..105c81f1f5 100644
--- a/test/files/neg/macro-bundle-object.scala
+++ b/test/files/neg/macro-bundle-object.scala
@@ -1,9 +1,8 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-import scala.reflect.macros.Context
+import scala.reflect.macros.{BlackboxMacro, BlackboxContext}
-object Bundle extends Macro {
- val c: Context = ???
+object Bundle extends BlackboxMacro {
+ val c: BlackboxContext = ???
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check
index 204bd30bca..07c5f551b1 100644
--- a/test/files/neg/macro-bundle-polymorphic.check
+++ b/test/files/neg/macro-bundle-polymorphic.check
@@ -1,10 +1,10 @@
-macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member
+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:11: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member
+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:12: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member
+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
index 0468d841bd..faf1e2e9e5 100644
--- a/test/files/neg/macro-bundle-polymorphic.scala
+++ b/test/files/neg/macro-bundle-polymorphic.scala
@@ -1,8 +1,7 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxMacro
-trait Bundle[T] extends Macro {
+trait Bundle[T] extends BlackboxMacro {
def impl = ???
}
diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check
index 972788c577..bf906a5310 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 scala.reflect.macros.Macro and not implementing its `val c: Context` member
+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
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 ddc87f6db3..62ade49953 100644
--- a/test/files/neg/macro-bundle-trait.scala
+++ b/test/files/neg/macro-bundle-trait.scala
@@ -1,9 +1,9 @@
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.BlackboxContext
-trait Bundle extends Macro {
- val c: Context = ???
+trait Bundle extends BlackboxMacro {
+ val c: BlackboxContext = ???
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 ac9b7938db..ba08345bcc 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 3983f590dc..9fb374800b 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.Context
+import scala.reflect.macros.WhiteboxContext
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: Context): c.Expr[Complex[T]] = {
+ def impl[T: c.WeakTypeTag](c: WhiteboxContext): 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 60e4020aec..7bd8415e4f 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 6dc2ea114b..1bd808d55d 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.Context
+import scala.reflect.macros.BlackboxContext
object Helper {
def unapplySeq[T](x: List[T]): Option[Seq[T]] =
}
object Macros {
- def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[List[T]]) = {
c.universe.reify(Helper.unapplySeq(x.splice))
}
diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check
index e39cc8105b..432da4d00b 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.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing
-and method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing
+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
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.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing
-and method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing
+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
match expected type ?
def foo(x: Any, y: Any) = macro Impls5.foo
^
Macros_Test_2.scala:31: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Unit]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (c: scala.reflect.macros.Context)(): c.Expr[Unit]
+ 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]
number of parameter sections differ
def foo1 = macro Impls6.fooEmpty
^
Macros_Test_2.scala:32: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context)(): c.Expr[Unit]
- or : (c: scala.reflect.macros.Context)(): c.Tree
- found : (c: scala.reflect.macros.Context): c.Expr[Unit]
+ 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]
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 9f48ab7ad9..b85ac9ee43 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.Context
+import scala.reflect.macros.BlackboxContext
class Impls1 {
- def foo(c: Context)(x: c.Expr[Any]) = ???
+ def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
}
object Impls2 {
- def foo(c: Context)(x: c.Expr[Any]) = ???
+ def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
}
trait MacroHelpers {
object Impls4 {
- def foo(c: Context)(x: c.Expr[Any]) = x
+ def foo(c: BlackboxContext)(x: c.Expr[Any]) = x
}
}
object Impls5 {
- def foo(c: Context)(x: c.Expr[Any]) = ???
- def foo(c: Context)(x: c.Expr[Any], y: c.Expr[Any]) = ???
+ def foo(c: BlackboxContext)(x: c.Expr[Any]) = ???
+ def foo(c: BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any]) = ???
}
object Impls6 {
- def fooNullary(c: Context) = {
+ def fooNullary(c: BlackboxContext) = {
import c.universe._
c.Expr[Unit](q"""Predef.println("it works")""")
}
- def fooEmpty(c: Context)() = fooNullary(c)
+ def fooEmpty(c: BlackboxContext)() = fooNullary(c)
}
object Impls7 {
- def foo[U <: Int](c: Context) = ???
+ def foo[U <: Int](c: BlackboxContext) = ???
}
package foo {
object Impls8 {
- private[foo] def impl(c: Context) = ???
+ private[foo] def impl(c: BlackboxContext) = ???
}
} \ 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 8aae9553f5..0df7d2e0c5 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros1 {
val impls = new Impls1
@@ -12,7 +12,7 @@ object Macros2 {
class Macros3 {
object Impls3 {
- def foo(c: Context)(x: c.Expr[Any]) = ???
+ def foo(c: BlackboxContext)(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 6cf62c292b..19adc70fb3 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 wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (c: scala.reflect.macros.Context): Int
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext): 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 wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (c: scala.reflect.macros.Context): reflect.runtime.universe.Literal
+ 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
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 a58af1a23c..d957b74512 100644
--- a/test/files/neg/macro-invalidret/Impls_1.scala
+++ b/test/files/neg/macro-invalidret/Impls_1.scala
@@ -1,7 +1,7 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxContext
import scala.reflect.runtime.{universe => ru}
object Impls {
- def foo1(c: Context) = 2
- def foo2(c: Context) = ru.Literal(ru.Constant(42))
+ def foo1(c: BlackboxContext) = 2
+ def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42))
}
diff --git a/test/files/neg/macro-invalidshape/Impls_1.scala b/test/files/neg/macro-invalidshape/Impls_1.scala
index 4467021545..3d5da9a2ed 100644
--- a/test/files/neg/macro-invalidshape/Impls_1.scala
+++ b/test/files/neg/macro-invalidshape/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(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 819844b9f1..8f643ab281 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.Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: scala.reflect.macros.BlackboxContext) = { 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 86aa08291f..e0cd63fbe4 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 wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(x: Int): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext)(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 175683d6d3..5f468424bd 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: Int) = ???
diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check
index 732380d4b3..42b8db5628 100644
--- a/test/files/neg/macro-invalidsig.check
+++ b/test/files/neg/macro-invalidsig.check
@@ -1,77 +1,77 @@
Macros_Test_2.scala:2: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext)(implicit evidence$2: Numeric[U]): c.universe.Literal
macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo[U] = macro Impls1.foo[U]
^
Macros_Test_2.scala:6: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : : Nothing
number of parameter sections differ
def foo = macro Impls2.foo
^
Macros_Test_2.scala:10: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (c: scala.reflect.api.Universe): Nothing
-type mismatch for parameter c: scala.reflect.macros.Context does not conform to scala.reflect.api.Universe
+type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe
def foo = macro Impls3.foo
^
Macros_Test_2.scala:14: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (cs: scala.reflect.macros.Context*): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ found : (cs: scala.reflect.macros.BlackboxContext*): 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 wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Any]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext): Nothing
number of parameter sections differ
def foo(x: Any) = macro Impls5.foo
^
Macros_Test_2.scala:22: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit]
- or : (c: scala.reflect.macros.Context)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Unit]
+ or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext)(implicit x: c.Expr[Int]): c.Expr[Unit]
macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo[U](x: Int) = macro Impls6.foo[T, U]
^
Macros_Test_2.scala:26: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ 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
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 wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(x: c.universe.Symbol): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext)(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 wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree, y: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(xs: c.Expr[Int]*): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ 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
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 wrong shape:
- required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
- or : (c: scala.reflect.macros.Context)(x: c.Tree, y: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ 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
parameter names differ: x != y
def foo(x: Int, y: Int) = macro Impls10.foo
^
Macros_Test_2.scala:42: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context): c.Expr[Any]
- or : (c: scala.reflect.macros.Context): c.Tree
- found : (c: scala.reflect.macros.Context)(U: c.universe.Type): Nothing
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ or : (c: scala.reflect.macros.BlackboxContext): c.Tree
+ found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing
number of parameter sections differ
def foo[U] = macro Impls11.foo[U]
^
@@ -81,13 +81,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: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$4: c.WeakTypeTag[U])Nothing
+Macros_Test_2.scala:54: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.BlackboxContext)(implicit evidence$4: c.WeakTypeTag[U])Nothing
def foo = macro Impls14.foo
^
-Macros_Test_2.scala:59: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(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: wrong number of type parameters 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]
def foo15[V] = macro Impls15.foo
^
-Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(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.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo16[V] = 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 d16ed26386..7c98160925 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls1 {
- def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" }
+ def foo[U: c.WeakTypeTag: Numeric](c: BlackboxContext) = { import c.universe._; q"42" }
}
object Impls2 {
@@ -14,15 +14,15 @@ object Impls3 {
}
object Impls4 {
- def foo(cs: Context*) = ???
+ def foo(cs: BlackboxContext*) = ???
}
object Impls5 {
- def foo(c: Context) = ???
+ def foo(c: BlackboxContext) = ???
}
object Impls6 {
- def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = {
+ def foo[T, U: c.WeakTypeTag](c: BlackboxContext)(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: Context)(x: c.Expr[Int], y: c.Expr[Int]) = ???
+ def foo(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]) = ???
}
object Impls8 {
- def foo(c: Context)(x: c.universe.Symbol) = ???
+ def foo(c: BlackboxContext)(x: c.universe.Symbol) = ???
}
object Impls9 {
- def foo(c: Context)(xs: c.Expr[Int]*) = ???
+ def foo(c: BlackboxContext)(xs: c.Expr[Int]*) = ???
}
object Impls10 {
- def foo(c: Context)(y: c.Expr[Int], x: c.Expr[Int]) = ???
+ def foo(c: BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]) = ???
}
object Impls11 {
- def foo[U](c: Context)(U: c.universe.Type) = ???
+ def foo[U](c: BlackboxContext)(U: c.universe.Type) = ???
}
object Impls12 {
- def foo[U <: String](c: Context) = ???
+ def foo[U <: String](c: BlackboxContext) = ???
}
object Impls13 {
- def foo[U <: String](c: Context) = ???
+ def foo[U <: String](c: BlackboxContext) = ???
}
object Impls14 {
- def foo[U: c.WeakTypeTag](c: Context) = ???
+ def foo[U: c.WeakTypeTag](c: BlackboxContext) = ???
}
object Impls15 {
- def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(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: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(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 52c9f9c3e9..678cb53929 100644
--- a/test/files/neg/macro-invalidusage-badargs/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badargs/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(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 74c163596a..393f7de976 100644
--- a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo[U <: String](c: Ctx) = { 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 52c9f9c3e9..678cb53929 100644
--- a/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(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 11b6a8c3b0..15894efb68 100644
--- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 869a5a41fa..44e508a1c6 100644
--- a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala
+++ b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
diff --git a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala
index c4b57233c9..02c87b5a81 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls {
- def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: BlackboxContext) = { 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 4467021545..3d5da9a2ed 100644
--- a/test/files/neg/macro-noexpand/Impls_1.scala
+++ b/test/files/neg/macro-noexpand/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(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 4467021545..3d5da9a2ed 100644
--- a/test/files/neg/macro-nontypeablebody/Impls_1.scala
+++ b/test/files/neg/macro-nontypeablebody/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(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 e43264f52f..0e8a5f3b01 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl(c: Ctx)(x: c.Expr[Int]) = x
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 f5b2555aa5..c98279b2b8 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
trait T { def t(): Unit }
trait A { def t(): Unit = () }
-object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
+object Macro { def t(c: BlackboxContext)(): 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 64a9299ee6..f2d3f67ccc 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala
index 17c1034720..7f0219e6ac 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.Macro
+import scala.reflect.macros.BlackboxMacro
-trait Impls extends Macro {
+trait Impls extends BlackboxMacro {
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-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
index 868616aace..6b73a96184 100644
--- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
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 868616aace..6b73a96184 100644
--- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala
index aa7dac7d7d..f937197829 100644
--- a/test/files/neg/patmatexhaust.scala
+++ b/test/files/neg/patmatexhaust.scala
@@ -22,9 +22,9 @@ class TestSealedExhaustive { // compile only
def ma3(x:Mult) = (x,x) match { // not exhaustive
case (Kult(_), Qult()) => // Kult missing
- //case Pair(Kult(_), Kult(_)) =>
+ //case (Kult(_), Kult(_)) =>
case (Qult(), Kult(_)) => // Qult missing
- //case Pair(Qult(), Qult()) =>
+ //case (Qult(), Qult()) =>
}
def ma3u(x:Mult) = ((x,x) : @unchecked) match { // not exhaustive, but not checked!
diff --git a/test/files/neg/t414.scala b/test/files/neg/t414.scala
index 1662b9a105..86646d13c2 100644
--- a/test/files/neg/t414.scala
+++ b/test/files/neg/t414.scala
@@ -1,5 +1,5 @@
case class Empty[a]() extends IntMap[a];
-case class Node[a](left: IntMap[a], keyVal: Pair[Int, a], right: IntMap[a]) extends IntMap[a];
+case class Node[a](left: IntMap[a], keyVal: Tuple2[Int, a], right: IntMap[a]) extends IntMap[a];
abstract class IntMap[a] {
def lookup(key: Int): a = this match {
case Empty =>
diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check
index 8cf0534e77..e74de40280 100644
--- a/test/files/neg/t5689.check
+++ b/test/files/neg/t5689.check
@@ -1,7 +1,7 @@
t5689.scala:4: error: macro implementation has wrong shape:
- required: (c: scala.reflect.macros.Context)(i: c.Expr[Double]): c.Expr[String]
- or : (c: scala.reflect.macros.Context)(i: c.Tree): c.Tree
- found : (c: scala.reflect.macros.Context)(i: c.Expr[Double]): c.Expr[Int]
+ 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]
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 3266039c35..d0e468849d 100644
--- a/test/files/neg/t5689.scala
+++ b/test/files/neg/t5689.scala
@@ -1,6 +1,6 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
def returnsString(i: Double): String = macro returnsIntImpl
- def returnsIntImpl(c: Context)(i: c.Expr[Double]): c.Expr[Int] = ???
+ def returnsIntImpl(c: BlackboxContext)(i: c.Expr[Double]): c.Expr[Int] = ???
}
diff --git a/test/files/neg/t5702-neg-bad-and-wild.check b/test/files/neg/t5702-neg-bad-and-wild.check
index ff9e5e5703..a52136dbf8 100644
--- a/test/files/neg/t5702-neg-bad-and-wild.check
+++ b/test/files/neg/t5702-neg-bad-and-wild.check
@@ -23,6 +23,6 @@ t5702-neg-bad-and-wild.scala:23: error: bad simple pattern: bad use of _* (a seq
val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern)
^
t5702-neg-bad-and-wild.scala:24: error: bad simple pattern: bad use of _* (sequence pattern not allowed)
- val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed)
+ val (b, _ * ) = (5,6) // bad use of _* (sequence pattern not allowed)
^
9 errors found
diff --git a/test/files/neg/t5702-neg-bad-and-wild.scala b/test/files/neg/t5702-neg-bad-and-wild.scala
index 3833a002b1..aadda37da7 100644
--- a/test/files/neg/t5702-neg-bad-and-wild.scala
+++ b/test/files/neg/t5702-neg-bad-and-wild.scala
@@ -21,7 +21,7 @@ object Test {
//gowild.scala:14: error: star patterns must correspond with varargs parameters
val K(is @ _*) = k
val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern)
- val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed)
+ val (b, _ * ) = (5,6) // bad use of _* (sequence pattern not allowed)
// no longer complains
//bad-and-wild.scala:15: error: ')' expected but '}' found.
}
diff --git a/test/files/neg/t5753/Impls_Macros_1.scala b/test/files/neg/t5753/Impls_Macros_1.scala
index 1d9c26458c..f93d731d40 100644
--- a/test/files/neg/t5753/Impls_Macros_1.scala
+++ b/test/files/neg/t5753/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
trait Impls {
def impl(c: Ctx)(x: c.Expr[Any]) = x
diff --git a/test/files/neg/t5753/Test_2.scala b/test/files/neg/t5753/Test_2.scala
index 2369b18e76..f1cad67fed 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.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros extends Impls {
def foo(x: Any) = macro impl
diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala
index e82be0fc68..7888b888e1 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
trait Tree
@@ -13,7 +13,7 @@ object NewQuasiquotes {
}
object QuasiquoteMacros {
- def unapplyImpl(c: Context)(t: c.Tree) = {
+ def unapplyImpl(c: WhiteboxContext)(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 b1b875969d..46f0eee0f1 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(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 70efab3101..281a06e93c 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(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.check b/test/files/neg/t5903d.check
index 9b8526b7f5..54a91a7ba6 100644
--- a/test/files/neg/t5903d.check
+++ b/test/files/neg/t5903d.check
@@ -1,4 +1,4 @@
-Test_2.scala:4: error: extractor macros can only expand into extractor calls
+Test_2.scala:4: error: extractor macros can only be whitebox
case t"$x" => println(x)
^
one error found
diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala
index 15ff226cff..5dd6220e1a 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: Context)(x: c.Tree) = {
+ def unapplyImpl(c: BlackboxContext)(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 4e1ce89c9f..997e6fd073 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: Context)(x: c.Tree) = {
+ def unapplyImpl(c: WhiteboxContext)(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 43f8371326..9a0402039b 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 wrong shape:
- required: (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit]
- or : (c: scala.reflect.macros.Context)(format: c.Tree, params: Tree*): c.Tree
- found : (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit]
+ 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]
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 38b8e24444..456e753893 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.Context
+import scala.reflect.macros.BlackboxContext
// explain some macro types to me
object BadMac {
def printf(format: String, params: Any*): Unit = macro printf_impl
- def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ???
+ def printf_impl(c: BlackboxContext)(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 a12c277c86..cdcea34272 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
def printf(format: String, params: Any*): Unit = macro printf_impl
- def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ???
+ def printf_impl(c: BlackboxContext)(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 4f7d289e2e..454489752c 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.Context
+import reflect.macros.BlackboxContext
object M {
def m(a: Any, b: Any): Any = macro mImpl
- def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = a
+ def mImpl(c: BlackboxContext)(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/t7157/Impls_Macros_1.scala b/test/files/neg/t7157/Impls_Macros_1.scala
index 9069d26e6e..16cb001422 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def impl1_0_0(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
- def impl1_1_1(c: Context)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
- def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
+ 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 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: Context)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") }
- def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") }
- 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"()") }
+ 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 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: Context)()() = { import c.universe._; c.Expr[Unit](q"()") }
- def impl2_1_1(c: Context)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
- def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
+ 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 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: Context)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") }
- def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") }
- 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"()") }
+ 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 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/t7605-deprecation.check b/test/files/neg/t7605-deprecation.check
index 9c466c058c..6db94613a1 100644
--- a/test/files/neg/t7605-deprecation.check
+++ b/test/files/neg/t7605-deprecation.check
@@ -1,12 +1,15 @@
-t7605-deprecation.scala:2: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.
- def this(i: Int) { this() }
- ^
-t7605-deprecation.scala:3: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.
+t7605-deprecation.scala:2: warning: Procedure syntax is deprecated. Convert procedure `bar` to method by adding `: Unit =`.
def bar {}
^
-t7605-deprecation.scala:4: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit`.
+t7605-deprecation.scala:3: warning: Procedure syntax is deprecated. Convert procedure `baz` to method by adding `: Unit`.
def baz
^
+t7605-deprecation.scala:4: warning: Procedure syntax is deprecated. Convert procedure `boo` to method by adding `: Unit`.
+ def boo(i: Int, l: Long)
+ ^
+t7605-deprecation.scala:5: warning: Procedure syntax is deprecated. Convert procedure `boz` to method by adding `: Unit =`.
+ def boz(i: Int, l: Long) {}
+ ^
error: No warnings can be incurred under -Xfatal-warnings.
-three warnings found
+four warnings found
one error found
diff --git a/test/files/neg/t7605-deprecation.scala b/test/files/neg/t7605-deprecation.scala
index 4a7dcd26d6..2b3362f94a 100644
--- a/test/files/neg/t7605-deprecation.scala
+++ b/test/files/neg/t7605-deprecation.scala
@@ -1,5 +1,8 @@
abstract class Foo {
- def this(i: Int) { this() }
def bar {}
def baz
-} \ No newline at end of file
+ def boo(i: Int, l: Long)
+ def boz(i: Int, l: Long) {}
+ def this(i: Int) { this() } // Don't complain here!
+ def foz: Unit // Don't complain here!
+}
diff --git a/test/files/neg/t997.scala b/test/files/neg/t997.scala
index e8d10f4317..1198738f24 100644
--- a/test/files/neg/t997.scala
+++ b/test/files/neg/t997.scala
@@ -1,5 +1,5 @@
// An extractor with 2 results
-object Foo { def unapply(x : String) = Some(Pair(x, x)) }
+object Foo { def unapply(x : String) = Some((x, x)) }
object Test extends App {
diff --git a/test/files/neg/wellkinded_wrongarity.check b/test/files/neg/wellkinded_wrongarity.check
index 1dc38db5c1..b9f033b453 100644
--- a/test/files/neg/wellkinded_wrongarity.check
+++ b/test/files/neg/wellkinded_wrongarity.check
@@ -1,4 +1,4 @@
-wellkinded_wrongarity.scala:5: error: Pair takes two type parameters, expected: one
-object mp extends Monad[Pair]
+wellkinded_wrongarity.scala:5: error: Tuple2 takes two type parameters, expected: one
+object mp extends Monad[Tuple2]
^
one error found
diff --git a/test/files/neg/wellkinded_wrongarity.scala b/test/files/neg/wellkinded_wrongarity.scala
index 2bb0e2ce8a..39c7601d53 100644
--- a/test/files/neg/wellkinded_wrongarity.scala
+++ b/test/files/neg/wellkinded_wrongarity.scala
@@ -2,4 +2,4 @@
class Monad[m[x]]
-object mp extends Monad[Pair]
+object mp extends Monad[Tuple2]
diff --git a/test/files/pos/SI-4012-a.scala b/test/files/pos/SI-4012-a.scala
new file mode 100644
index 0000000000..7fceeea3c3
--- /dev/null
+++ b/test/files/pos/SI-4012-a.scala
@@ -0,0 +1,7 @@
+trait C1[+A] {
+ def head: A = sys.error("")
+}
+trait C2[@specialized +A] extends C1[A] {
+ override def head: A = super.head
+}
+class C3 extends C2[Char]
diff --git a/test/files/pos/SI-4012-b.scala b/test/files/pos/SI-4012-b.scala
new file mode 100644
index 0000000000..6bc8592766
--- /dev/null
+++ b/test/files/pos/SI-4012-b.scala
@@ -0,0 +1,15 @@
+trait Super[@specialized(Int) A] {
+ def superb = 0
+}
+
+object Sub extends Super[Int] {
+ // it is expected that super[Super].superb crashes, since
+ // specialization does parent class rewiring, and the super
+ // of Sub becomes Super$mcII$sp and not Super. But I consider
+ // this normal behavior -- if you want, I can modify duplicatiors
+ // to make this work, but I consider it's best to keep this
+ // let the user know Super is not the superclass anymore.
+ // super[Super].superb - Vlad
+ super.superb // okay
+ override def superb: Int = super.superb // okay
+}
diff --git a/test/files/pos/annotated-original/M_1.scala b/test/files/pos/annotated-original/M_1.scala
index 01654e02cf..089a3a13c5 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.Context
+import reflect.macros.BlackboxContext
object M {
- def impl(c: Context)(a: c.Expr[Any]) = c.Expr[Any](c.resetLocalAttrs(a.tree))
+ def impl(c: BlackboxContext)(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 9b7af0c3b8..50c671707d 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context)
+ def tree_impl[T:c.WeakTypeTag,U:c.WeakTypeTag](c: BlackboxContext)
(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 c3f541075e..f84e56d714 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object MyAttachment
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 c382cabc59..11d0f65844 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object MyAttachment
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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/bounds.scala b/test/files/pos/bounds.scala
index cfea4626c3..26bc84a1b9 100644
--- a/test/files/pos/bounds.scala
+++ b/test/files/pos/bounds.scala
@@ -1,11 +1,11 @@
trait Map[A, +C] {
- def ++ [B1 >: C] (kvs: Iterable[Pair[A, B1]]): Map[A, B1] = this
- def ++ [B1 >: C] (kvs: Iterator[Pair[A, B1]]): Map[A, B1] = this
+ def ++ [B1 >: C] (kvs: Iterable[Tuple2[A, B1]]): Map[A, B1] = this
+ def ++ [B1 >: C] (kvs: Iterator[Tuple2[A, B1]]): Map[A, B1] = this
}
class ListMap[A, +B] extends Map[A, B] {}
object ListMap {
def empty[X, Y] = new ListMap[X, Y]
- def apply[A1, B2](elems: Pair[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator)
+ def apply[A1, B2](elems: Tuple2[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator)
}
diff --git a/test/files/pos/macro-implicit-invalidate-on-error.check b/test/files/pos/macro-implicit-invalidate-on-error.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/pos/macro-implicit-invalidate-on-error.check
diff --git a/test/files/pos/macro-implicit-invalidate-on-error.scala b/test/files/pos/macro-implicit-invalidate-on-error.scala
new file mode 100644
index 0000000000..22cd2d34b4
--- /dev/null
+++ b/test/files/pos/macro-implicit-invalidate-on-error.scala
@@ -0,0 +1,28 @@
+package scala.reflect
+package api
+
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+trait Liftable[T] {
+ def apply(universe: api.Universe, value: T): universe.Tree
+}
+
+object Liftable {
+ implicit def liftCaseClass[T <: Product]: Liftable[T] = macro liftCaseClassImpl[T]
+
+ def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[Liftable[T]] = {
+ import c.universe._
+ val tpe = weakTypeOf[T]
+ if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied")
+ val p = List(q"Literal(Constant(1))")
+ c.Expr[Liftable[T]] { q"""
+ new scala.reflect.api.Liftable[$tpe] {
+ def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = {
+ import universe._
+ Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p))
+ }
+ }
+ """ }
+ }
+}
diff --git a/test/files/pos/patmat.scala b/test/files/pos/patmat.scala
index 4e652b146e..51b879abf2 100644
--- a/test/files/pos/patmat.scala
+++ b/test/files/pos/patmat.scala
@@ -3,8 +3,8 @@
object ZipFun {
//just compilation
- def zipFun[a, b](xs: List[a], ys: List[b]): List[Pair[a, b]] = (Pair(xs, ys): @unchecked) match {
- // !!! case Pair(List(), _), Pair(_, List()) => List()
+ def zipFun[a, b](xs: List[a], ys: List[b]): List[Tuple2[a, b]] = ((xs, ys): @unchecked) match {
+ // !!! case (List(), _), (_, List()) => List()
case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
}
diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala
index ad9c6399a5..589ceb33b2 100644
--- a/test/files/pos/spec-doubledef-new.scala
+++ b/test/files/pos/spec-doubledef-new.scala
@@ -19,12 +19,12 @@ abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int)
val u: U
val v: V
- def f(t: T, v2: V): Pair[U, V] = {
+ def f(t: T, v2: V): Tuple2[U, V] = {
val m: Array[U] = null
if (m.isEmpty) {
- Pair(u, v)
+ (u, v)
} else {
- Pair(u, v2)
+ (u, v2)
}
}
} \ No newline at end of file
diff --git a/test/files/pos/spec-doubledef-old.scala b/test/files/pos/spec-doubledef-old.scala
index 86b0d857d3..bde259e4fa 100644
--- a/test/files/pos/spec-doubledef-old.scala
+++ b/test/files/pos/spec-doubledef-old.scala
@@ -17,12 +17,12 @@ abstract class B[T, @specialized(scala.Int) U : Manifest, @specialized(scala.Int
val u: U
val v: V
- def f(t: T, v2: V): Pair[U, V] = {
+ def f(t: T, v2: V): Tuple2[U, V] = {
val m: Array[U] = null
if (m.isEmpty) {
- Pair(u, v)
+ (u, v)
} else {
- Pair(u, v2)
+ (u, v2)
}
}
}
diff --git a/test/files/pos/t0064.scala b/test/files/pos/t0064.scala
index c2ce4bf6d0..1eeca8dcad 100644
--- a/test/files/pos/t0064.scala
+++ b/test/files/pos/t0064.scala
@@ -1,6 +1,6 @@
object B {
def main(Args:Array[String]) = {
- val Pair(_,x) = Pair(1,2);
+ val (_,x) = (1,2);
x + 1;
}
}
diff --git a/test/files/pos/t1014.scala b/test/files/pos/t1014.scala
new file mode 100644
index 0000000000..6fb7f7ba49
--- /dev/null
+++ b/test/files/pos/t1014.scala
@@ -0,0 +1,16 @@
+class NodeSeq
+class Elem extends NodeSeq
+
+class EO extends App with Moo {
+ // return type is Flog, inherited from overridden method.
+ // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`.
+ def cat = (??? : Elem)
+
+ implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in)
+}
+
+trait Moo {
+ def cat: Flog
+}
+
+class Flog(val in: NodeSeq)
diff --git a/test/files/pos/t1203a.scala b/test/files/pos/t1203a.scala
new file mode 100644
index 0000000000..cf5ab9fba0
--- /dev/null
+++ b/test/files/pos/t1203a.scala
@@ -0,0 +1,13 @@
+class Node
+object NodeSeq {
+ implicit def seqToNodeSeq(s: Seq[Node]): NodeSeq = ???
+}
+abstract class NodeSeq extends collection.immutable.Seq[Node]
+
+case class ant(t: String) extends scala.annotation.Annotation
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a: NodeSeq @ant("12") = Nil
+ println(a)
+ }
+}
diff --git a/test/files/pos/t247.scala b/test/files/pos/t247.scala
index e976404e61..fdcafeb2c6 100644
--- a/test/files/pos/t247.scala
+++ b/test/files/pos/t247.scala
@@ -16,11 +16,11 @@ class Tree[KEY,Entry](order:Order[KEY]) {
def size =0;
}
-class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Pair[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] {
+class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Tuple2[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] {
val factory = _factory
val order = _factory.order;
def this(newOrder:Order[KEY]) = this(new TreeMapFactory[KEY](newOrder));
def get(key:KEY) = null;
- def iterator:Iterator[Pair[KEY,VALUE]] = null;
+ def iterator:Iterator[Tuple2[KEY,VALUE]] = null;
override def size = super[Tree].size
}
diff --git a/test/files/pos/t2698.scala b/test/files/pos/t2698.scala
new file mode 100644
index 0000000000..bce02e48b3
--- /dev/null
+++ b/test/files/pos/t2698.scala
@@ -0,0 +1,14 @@
+class WordExp {
+ abstract class Label
+ type _labelT <: Label
+}
+
+import scala.collection._
+
+abstract class S2 {
+ val lang: WordExp
+ type __labelT = lang._labelT
+
+ var deltaq: Array[__labelT] = _
+ def delta1 = immutable.Map(deltaq.zipWithIndex: _*)
+}
diff --git a/test/files/pos/t3160.scala b/test/files/pos/t3160.scala
new file mode 100644
index 0000000000..cc007dc014
--- /dev/null
+++ b/test/files/pos/t3160.scala
@@ -0,0 +1,6 @@
+import scala.collection.mutable._
+class Node
+
+class A {
+ def f(x: Node): Node = ???
+}
diff --git a/test/files/pos/t443.scala b/test/files/pos/t443.scala
index 5b5e3ea828..cdaefe9ecd 100644
--- a/test/files/pos/t443.scala
+++ b/test/files/pos/t443.scala
@@ -1,10 +1,10 @@
object Test {
- def lookup(): Option[Pair[String, String]] =
- ((null: Option[Pair[String, String]]) : @unchecked) match {
- case Some(Pair(_, _)) =>
+ def lookup(): Option[Tuple2[String, String]] =
+ ((null: Option[Tuple2[String, String]]) : @unchecked) match {
+ case Some((_, _)) =>
if (true)
- Some(Pair(null, null))
+ Some((null, null))
else
lookup() match {
case Some(_) => Some(null)
diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala
index 8951ec011f..cd1553f02a 100644
--- a/test/files/pos/t4579.scala
+++ b/test/files/pos/t4579.scala
@@ -190,10 +190,10 @@ object LispCaseClasses extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
@@ -381,10 +381,10 @@ object LispAny extends Lisp {
def extendEnv(env: Environment,
ps: List[String], args: List[Data]): Environment =
- Pair(ps, args) match {
- case Pair(List(), List()) =>
+ (ps, args) match {
+ case (List(), List()) =>
env
- case Pair(p :: ps1, arg :: args1) =>
+ case (p :: ps1, arg :: args1) =>
extendEnv(env.extend(p, arg), ps1, args1)
case _ =>
lispError("wrong number of arguments")
diff --git a/test/files/pos/t5120.scala b/test/files/pos/t5120.scala
index 6731af14e4..86d4470bd5 100644
--- a/test/files/pos/t5120.scala
+++ b/test/files/pos/t5120.scala
@@ -5,9 +5,9 @@ class Test {
class ScopedKey[T]
class Value[T]
- class Compiled[T](val settings: Seq[Pair[T]])
+ class Compiled[T](val settings: Seq[Tuple2[T]])
- case class Pair[T](k: ScopedKey[T], v: ScopedKey[T])
+ case class Tuple2[T](k: ScopedKey[T], v: ScopedKey[T])
def transform[T](x: T) = x
diff --git a/test/files/pos/t5692a/Macros_1.scala b/test/files/pos/t5692a/Macros_1.scala
index e530713bb0..0e91f4d6a0 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl[T](c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl[T](c: BlackboxContext) = { 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 45c672cfce..1034a1ea4a 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl[T, U](c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl[T, U](c: BlackboxContext) = { 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 20a8b255cc..1970f5971f 100644
--- a/test/files/pos/t5706.scala
+++ b/test/files/pos/t5706.scala
@@ -1,10 +1,15 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.WhiteboxContext
class Logger {
- def error(message: String) = macro Impls.error
+ def error1(message: String) = macro Impls.error1
+ def error2(message: String) = macro Impls.error2
}
object Impls {
- type LoggerContext = Context { type PrefixType = Logger }
- def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] = ???
+ type LoggerContext1 = BlackboxContext { type PrefixType = Logger }
+ def error1(c: LoggerContext1)(message: c.Expr[String]): c.Expr[Unit] = ???
+
+ type LoggerContext2 = WhiteboxContext { type PrefixType = Logger }
+ def error2(c: LoggerContext2)(message: c.Expr[String]): c.Expr[Unit] = ???
}
diff --git a/test/files/pos/t5744/Macros_1.scala b/test/files/pos/t5744/Macros_1.scala
index 288a88653d..0fc13c12d7 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]]) = {
+ def foo_impl[U](c: BlackboxContext)(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: Context)(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: BlackboxContext)(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 bc5f856bd2..c5bb44d87e 100644
--- a/test/files/pos/t6047.scala
+++ b/test/files/pos/t6047.scala
@@ -1,10 +1,10 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxContext
import java.io.InputStream
object Macros {
def unpack[A](input: InputStream): A = macro unpack_impl[A]
- def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = {
+ def unpack_impl[A: c.WeakTypeTag](c: BlackboxContext)(input: c.Expr[InputStream]): c.Expr[A] = {
import c.universe._
def unpackcode(tpe: c.Type): c.Expr[_] = {
diff --git a/test/files/pos/t6201.scala b/test/files/pos/t6201.scala
new file mode 100644
index 0000000000..d4e5bce03a
--- /dev/null
+++ b/test/files/pos/t6201.scala
@@ -0,0 +1,19 @@
+// probably needs xml's weirdness to reproduce
+// (specifically, _root_.scala.xml.Null being in the root package)
+class Elem
+
+class Test {
+ def elem: Elem = ???
+
+ class Foo1 {
+ def must(x: Elem) = ()
+ }
+
+ class Foo2 {
+ def must(x: Int) = ()
+ }
+ implicit def toFoo1(s: Elem) = new Foo1()
+ implicit def toFoo2(s: Elem) = new Foo2()
+
+ def is: Unit = { (elem) }
+} \ No newline at end of file
diff --git a/test/files/pos/t6447.scala b/test/files/pos/t6447.scala
index 1c0c0f2a31..8203c0cddd 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.Context
+import scala.reflect.macros.BlackboxContext
class X { type T }
object X {
// this works
def foo(x: X): x.T = macro fooImpl
- def fooImpl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ???
+ def fooImpl(c: BlackboxContext)(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: Context)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ???
+ def barImpl(c: BlackboxContext)(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: Context)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ???
+ def bazImpl(c: BlackboxContext)(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 85c2d5dbdb..c637c2cfee 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def crash(c: Context): c.Expr[Unit] = c.universe.reify(())
+ def crash(c: BlackboxContext): 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 382df1c453..9897987516 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.Context
+import scala.reflect.macros.BlackboxContext
final class Ops[T](val x: T) extends AnyVal {
def f = macro Macros.crash
}
object Macros {
- def crash(c: Context): c.Expr[Unit] = c.universe.reify(())
+ def crash(c: BlackboxContext): 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 c004055de2..aed359976e 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.Context
+import scala.reflect.macros.BlackboxContext
import scala.collection.TraversableLike
// This one compiles
object Test {
- type Alias[T, CC[_]] = Context { type PrefixType = TraversableLike[T, CC[T]] }
+ type Alias[T, CC[_]] = BlackboxContext { 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.Context
+ type Ctx = scala.reflect.macros.BlackboxContext
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 a0ec1d84af..bb7ffb0f10 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.Context
+import reflect.macros.BlackboxContext
object M {
- def noopImpl[A](c: Context)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typeCheck(c.resetLocalAttrs(expr.tree)))
+ def noopImpl[A](c: BlackboxContext)(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 8621650f77..126e9c067a 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 ff3c626fca..fa5d13369f 100644
--- a/test/files/pos/t7649.scala
+++ b/test/files/pos/t7649.scala
@@ -1,5 +1,5 @@
object Test {
- val c: reflect.macros.Context = ???
+ val c: reflect.macros.BlackboxContext = ???
import c.universe._
reify {
// The lookup of the implicit WeakTypeTag[Any]
diff --git a/test/files/pos/t7983.scala b/test/files/pos/t7983.scala
new file mode 100644
index 0000000000..a583e538c5
--- /dev/null
+++ b/test/files/pos/t7983.scala
@@ -0,0 +1,31 @@
+package foo.bar.baz // the package nesting level material to this bug
+
+class DivergenceTest {
+
+ trait ColumnBase[T]
+
+ trait ShapeLevel
+ trait Flat extends ShapeLevel
+ trait Lower extends Flat
+
+ class Shape2[Level <: ShapeLevel, -M, U]
+
+ implicit final def columnBaseShape[Level >: Flat <: ShapeLevel, T, C <: ColumnBase[_]]
+ (implicit ev: C <:< ColumnBase[T]
+ ): Shape2[Level, C, T] = ???
+
+ implicit final def intShape[Level <: ShapeLevel, T]: Shape2[Level, Int, Int] = ???
+ implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2]
+ (implicit u1: Shape2[_ <: Level, M1, U1],
+ u2: Shape2[_ <: Level, M2, U2]
+ ): Shape2[Level, (M1,M2), (U1,U2)] = ???
+
+ def foo {
+ class Coffees extends ColumnBase[Int]
+
+ def map1[F, T](f: F)(implicit shape: Shape2[_ <: Flat, F, T]) = ???
+
+ map1(((1, null: Coffees), 1))
+ map1(((null: Coffees, 1), 1)) // fails with implicit divergence error in 2.11.0-M6, works under 2.10.3
+ }
+}
diff --git a/test/files/pos/t7987/Macro_1.scala b/test/files/pos/t7987/Macro_1.scala
new file mode 100644
index 0000000000..81f717b9c4
--- /dev/null
+++ b/test/files/pos/t7987/Macro_1.scala
@@ -0,0 +1,6 @@
+import scala.language.experimental._
+
+object Macro {
+ def apply[A](a: A): A = macro impl[A]
+ def impl[A](c: reflect.macros.Context)(a: c.Expr[A]): c.Expr[A] = a
+}
diff --git a/test/files/pos/t7987/Test_2.scala b/test/files/pos/t7987/Test_2.scala
new file mode 100644
index 0000000000..5896fdb517
--- /dev/null
+++ b/test/files/pos/t7987/Test_2.scala
@@ -0,0 +1,12 @@
+class C[T] {
+ def foo = 0
+}
+
+object Test {
+ implicit def AnyToC[T](a: Any): C[T] = new C[T]
+ // was: "macro not expanded"
+ Macro {
+ "".foo
+ ()
+ }
+}
diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala
index 5874cc664d..63263cb152 100644
--- a/test/files/pos/tcpoly_bounds1.scala
+++ b/test/files/pos/tcpoly_bounds1.scala
@@ -1,7 +1,7 @@
-class Foo[t[x]<: Pair[Int, x]]
+class Foo[t[x]<: Tuple2[Int, x]]
//
-class MyPair[z](a: Int, b: z) extends Pair[Int, z](a,b)
+class MyPair[z](a: Int, b: z) extends Tuple2[Int, z](a,b)
object foo extends Foo[MyPair]
diff --git a/test/files/pos/typealiases.scala b/test/files/pos/typealiases.scala
index d03b521f77..93d1dce4dc 100644
--- a/test/files/pos/typealiases.scala
+++ b/test/files/pos/typealiases.scala
@@ -14,7 +14,7 @@ trait Test[T] {
object main extends Test[Int] {
val pair1 = (1,1)
- implicit def topair(x: Int): Pair[Int, Int] = (x,x)
+ implicit def topair(x: Int): Tuple2[Int, Int] = (x,x)
val pair2: MyPair[Int] = 1
val x: Short = 1
}
diff --git a/test/files/pos/unapplyNeedsMemberType.scala b/test/files/pos/unapplyNeedsMemberType.scala
index b423257e04..3a96e189af 100644
--- a/test/files/pos/unapplyNeedsMemberType.scala
+++ b/test/files/pos/unapplyNeedsMemberType.scala
@@ -19,7 +19,7 @@ class Join[a] extends Gunk[a] {
def append(s1: Seq, s2: Seq): Seq = s1 // mock implementation
def unapply_Cons(s: Any) = s match {
- case App(Cons(x, xs), ys) => Some(Pair(x, append(xs, ys)))
+ case App(Cons(x, xs), ys) => Some((x, append(xs, ys)))
case _ => null
}
}
diff --git a/test/files/pos/valdefs.scala b/test/files/pos/valdefs.scala
index 85ffa132b7..c8f78cd2bf 100644
--- a/test/files/pos/valdefs.scala
+++ b/test/files/pos/valdefs.scala
@@ -11,6 +11,6 @@ object test {
}
abstract class Sub2() extends Base() {
- override val Pair(x, y) = Pair("abc", 2.0);
+ override val (x, y) = ("abc", 2.0);
}
}
diff --git a/test/files/positions/ExcludedPrefix1.scala b/test/files/positions/ExcludedPrefix1.scala
index f3562c37f0..b3182eae78 100644
--- a/test/files/positions/ExcludedPrefix1.scala
+++ b/test/files/positions/ExcludedPrefix1.scala
@@ -35,7 +35,7 @@ object ExcludedPrefix1 {
(i,
j) = (0, 0)
- val Pair(
+ val (
k,
l) = (0, 0)
}
diff --git a/test/files/positions/Overlap4.scala b/test/files/positions/Overlap4.scala
index 0049293954..f54837295b 100644
--- a/test/files/positions/Overlap4.scala
+++ b/test/files/positions/Overlap4.scala
@@ -1,3 +1,3 @@
object Overlap4 {
- val Pair(a, b) = (0, 0)
+ val (a, b) = (0, 0)
}
diff --git a/test/files/positions/Scaladoc7.scala b/test/files/positions/Scaladoc7.scala
index 6175222e3f..0198d4d6ac 100644
--- a/test/files/positions/Scaladoc7.scala
+++ b/test/files/positions/Scaladoc7.scala
@@ -2,5 +2,5 @@ object Scaladoc7 {
/**
* Foo
*/
- val Pair(i, j) = (1, 2)
+ val (i, j) = (1, 2)
}
diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check
index d41b982614..1f868097ca 100644
--- a/test/files/presentation/callcc-interpreter.check
+++ b/test/files/presentation/callcc-interpreter.check
@@ -1,8 +1,8 @@
reload: CallccInterpreter.scala
-askTypeCompletion at CallccInterpreter.scala(51,38)
+askTypeCompletion at CallccInterpreter.scala(51,34)
================================================================================
-[response] askCompletionAt (51,38)
+[response] askTypeCompletion at (51,34)
retrieved 59 members
abstract trait Term extends AnyRef
abstract trait Value extends AnyRef
@@ -83,8 +83,8 @@ def showM(m: callccInterpreter.M[callccInterpreter.Value]): String = m.in.apply(
askType at CallccInterpreter.scala(50,30)
================================================================================
[response] askTypeAt (50,30)
-def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
- case scala.this.Predef.Pair.unapply[callccInterpreter.Value, callccInterpreter.Value](<unapply-selector>) <unapply> ((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n)))
+def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.Tuple2.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
+ case (_1: callccInterpreter.Value, _2: callccInterpreter.Value)(callccInterpreter.Value, callccInterpreter.Value)((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n)))
case _ => callccInterpreter.this.unitM[callccInterpreter.Wrong.type](callccInterpreter.this.Wrong)
}
================================================================================
diff --git a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
index ce3b996b96..d498fe0b17 100644
--- a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
+++ b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
@@ -40,15 +40,15 @@ object callccInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value) /*?*/ = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => this./*!*/unitM(Num(m + n))
+ def add(a: Value, b: Value) /*?*/ = (a, b) match {
+ case (Num(m), Num(n)) => this./*!*/unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -60,16 +60,20 @@ object callccInterpreter {
def interp(t: Term, e: Environment): M[Value] = t match {
case Var(x) => lookup(x, e)
case Con(n) => unitM(Num(n))
- case Add(l, r) => for (val a <- interp(l, e);
- val b <- interp(r, e);
- val c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
- case App(f, t) => for (val a <- interp(f, e);
- val b <- interp(t, e);
- val c <- apply(a, b))
- yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Add(l, r) =>
+ for {
+ a <- interp(l, e)
+ b <- interp(r, e)
+ c <- add(a, b)
+ } yield c
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
+ case App(f, t) =>
+ for {
+ a <- interp(f, e)
+ b <- interp(t, e)
+ c <- apply(a, b)
+ } yield c
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
def test(t: Term): String = showM(interp(t, List()))
diff --git a/test/files/presentation/completion-implicit-chained.check b/test/files/presentation/completion-implicit-chained.check
new file mode 100644
index 0000000000..f9d77f7a53
--- /dev/null
+++ b/test/files/presentation/completion-implicit-chained.check
@@ -0,0 +1,29 @@
+reload: Completions.scala
+
+askTypeCompletion at Completions.scala(11,16)
+================================================================================
+[response] askTypeCompletion at (11,16)
+retrieved 24 members
+[inaccessible] protected[package lang] def clone(): Object
+[inaccessible] protected[package lang] def finalize(): Unit
+def equals(x$1: Any): Boolean
+def hashCode(): Int
+def map(x: Int => Int)(implicit a: DummyImplicit): test.O.type
+def toString(): String
+final def !=(x$1: Any): Boolean
+final def !=(x$1: AnyRef): Boolean
+final def ##(): Int
+final def ==(x$1: Any): Boolean
+final def ==(x$1: AnyRef): Boolean
+final def asInstanceOf[T0]: T0
+final def eq(x$1: AnyRef): Boolean
+final def isInstanceOf[T0]: Boolean
+final def ne(x$1: AnyRef): Boolean
+final def notify(): Unit
+final def notifyAll(): Unit
+final def synchronized[T0](x$1: T0): T0
+final def wait(): Unit
+final def wait(x$1: Long): Unit
+final def wait(x$1: Long,x$2: Int): Unit
+private[this] val prefix123: Int
+================================================================================
diff --git a/test/files/presentation/completion-implicit-chained/Test.scala b/test/files/presentation/completion-implicit-chained/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/completion-implicit-chained/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/completion-implicit-chained/src/Completions.scala b/test/files/presentation/completion-implicit-chained/src/Completions.scala
new file mode 100644
index 0000000000..67922dfec0
--- /dev/null
+++ b/test/files/presentation/completion-implicit-chained/src/Completions.scala
@@ -0,0 +1,12 @@
+package test
+
+import scala.Predef.DummyImplicit // turn off other predef implicits for a cleaner .check file.
+
+object O {
+ def map(x: Int => Int)(implicit a: DummyImplicit): O.type = this
+ val prefix123 : Int = 0
+}
+
+class Foo {
+ O.map(x => x)./*!*/ // we want the presentation compiler to apply the implicit argument list.
+}
diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check
index aa6660cec5..c59fa6843f 100644
--- a/test/files/presentation/ide-bug-1000349.check
+++ b/test/files/presentation/ide-bug-1000349.check
@@ -2,7 +2,7 @@ reload: CompletionOnEmptyArgMethod.scala
askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17)
================================================================================
-[response] askCompletionAt (2,17)
+[response] askTypeCompletion at (2,17)
retrieved 32 members
def +(other: String): String
def ->[B](y: B): (Foo, B)
diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check
index cb7de6d34a..f5b4253e1a 100644
--- a/test/files/presentation/ide-bug-1000475.check
+++ b/test/files/presentation/ide-bug-1000475.check
@@ -2,7 +2,7 @@ reload: Foo.scala
askTypeCompletion at Foo.scala(3,7)
================================================================================
-[response] askCompletionAt (3,7)
+[response] askTypeCompletion at (3,7)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
@@ -36,7 +36,7 @@ final def wait(x$1: Long,x$2: Int): Unit
askTypeCompletion at Foo.scala(6,10)
================================================================================
-[response] askCompletionAt (6,10)
+[response] askTypeCompletion at (6,10)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
@@ -70,7 +70,7 @@ final def wait(x$1: Long,x$2: Int): Unit
askTypeCompletion at Foo.scala(7,7)
================================================================================
-[response] askCompletionAt (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 31 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check
index 9a2cad5fd2..dff89b155b 100644
--- a/test/files/presentation/ide-bug-1000531.check
+++ b/test/files/presentation/ide-bug-1000531.check
@@ -2,7 +2,7 @@ reload: CrashOnLoad.scala
askTypeCompletion at CrashOnLoad.scala(6,12)
================================================================================
-[response] askCompletionAt (6,12)
+[response] askTypeCompletion at (6,12)
retrieved 120 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check
index ef361599c5..5ad52b4dd3 100644
--- a/test/files/presentation/implicit-member.check
+++ b/test/files/presentation/implicit-member.check
@@ -2,7 +2,7 @@ reload: ImplicitMember.scala
askTypeCompletion at ImplicitMember.scala(7,7)
================================================================================
-[response] askCompletionAt (7,7)
+[response] askTypeCompletion at (7,7)
retrieved 34 members
def +(other: String): String
def ->[B](y: B): (Implicit.type, B)
diff --git a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
index 1ddeb6ac4a..f09c6f8e2c 100644
--- a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
+++ b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
@@ -3,6 +3,7 @@ import java.io.FileOutputStream
import java.util.Calendar
import scala.reflect.internal.util.BatchSourceFile
+import scala.tools.nsc.interactive
import scala.tools.nsc.interactive.tests._
import scala.tools.nsc.io._
import scala.tools.nsc.doc
@@ -25,7 +26,21 @@ import scala.tools.nsc.doc
object Test extends InteractiveTest {
final val mega = 1024 * 1024
- override val withDocComments = true
+ import interactive.Global
+ trait InteractiveScaladocAnalyzer extends interactive.InteractiveAnalyzer with doc.ScaladocAnalyzer {
+ val global : Global
+ override def newTyper(context: Context) = new Typer(context) with InteractiveTyper with ScaladocTyper {
+ override def canAdaptConstantTypeToLiteral = false
+ }
+ }
+
+ private class ScaladocEnabledGlobal extends Global(settings, compilerReporter) {
+ override lazy val analyzer = new {
+ val global: ScaladocEnabledGlobal.this.type = ScaladocEnabledGlobal.this
+ } with InteractiveScaladocAnalyzer
+ }
+
+ override def createGlobal: Global = new ScaladocEnabledGlobal
override def execute(): Unit = memoryConsumptionTest()
diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check
index 10d29bfed6..20f17aa7d0 100644
--- a/test/files/presentation/ping-pong.check
+++ b/test/files/presentation/ping-pong.check
@@ -2,7 +2,7 @@ reload: PingPong.scala
askTypeCompletion at PingPong.scala(10,23)
================================================================================
-[response] askCompletionAt (10,23)
+[response] askTypeCompletion at (10,23)
retrieved 35 members
[inaccessible] private[this] val ping: Ping
[inaccessible] protected[package lang] def clone(): Object
@@ -39,7 +39,7 @@ private[this] val name: String
askTypeCompletion at PingPong.scala(19,20)
================================================================================
-[response] askCompletionAt (19,20)
+[response] askTypeCompletion at (19,20)
retrieved 35 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
diff --git a/test/files/presentation/scope-completion-1.check b/test/files/presentation/scope-completion-1.check
new file mode 100644
index 0000000000..63f956b239
--- /dev/null
+++ b/test/files/presentation/scope-completion-1.check
@@ -0,0 +1,19 @@
+reload: Completions.scala
+
+askScopeCompletion at Completions.scala(6,2)
+================================================================================
+[response] askScopeCompletion at (6,2)
+retrieved 3 members
+class Completion1 extends AnyRef
+def <init>(): test.Completion1
+object Completion2
+================================================================================
+
+askScopeCompletion at Completions.scala(10,2)
+================================================================================
+[response] askScopeCompletion at (10,2)
+retrieved 3 members
+class Completion1 extends AnyRef
+def <init>(): test.Completion2.type
+object Completion2
+================================================================================
diff --git a/test/files/presentation/scope-completion-1/Test.scala b/test/files/presentation/scope-completion-1/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/scope-completion-1/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/scope-completion-1/src/Completions.scala b/test/files/presentation/scope-completion-1/src/Completions.scala
new file mode 100644
index 0000000000..c4eea6b261
--- /dev/null
+++ b/test/files/presentation/scope-completion-1/src/Completions.scala
@@ -0,0 +1,12 @@
+package test
+
+/* completion on empty class and object */
+
+class Completion1 {
+ /*_*/
+}
+
+object Completion2 {
+ /*_*/
+}
+
diff --git a/test/files/presentation/scope-completion-2.check b/test/files/presentation/scope-completion-2.check
new file mode 100644
index 0000000000..3a1dbd7cff
--- /dev/null
+++ b/test/files/presentation/scope-completion-2.check
@@ -0,0 +1,35 @@
+reload: Completions.scala
+
+askScopeCompletion at Completions.scala(16,4)
+================================================================================
+[response] askScopeCompletion at (16,4)
+retrieved 11 members
+class Completion1 extends AnyRef
+def <init>(): test.Completion1
+def test: Unit
+object Completion1
+private class Cc1 extends AnyRef
+private class Co1 extends AnyRef
+private def fc1: Int
+private def fo1: Int
+private[this] val c: test.Completion1
+private[this] val vc1: Int
+private[this] val vo1: Int
+================================================================================
+
+askScopeCompletion at Completions.scala(32,4)
+================================================================================
+[response] askScopeCompletion at (32,4)
+retrieved 11 members
+[inaccessible] private[this] val vc1: Int
+class Completion1 extends AnyRef
+def <init>(): test.Completion1.type
+def test: Unit
+object Completion1
+private class Cc1 extends AnyRef
+private class Co1 extends AnyRef
+private def fc1: Int
+private def fo1: Int
+private[this] val c: test.Completion1
+private[this] val vo1: Int
+================================================================================
diff --git a/test/files/presentation/scope-completion-2/Test.scala b/test/files/presentation/scope-completion-2/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/scope-completion-2/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/scope-completion-2/src/Completions.scala b/test/files/presentation/scope-completion-2/src/Completions.scala
new file mode 100644
index 0000000000..96d38f1b85
--- /dev/null
+++ b/test/files/presentation/scope-completion-2/src/Completions.scala
@@ -0,0 +1,35 @@
+package test
+
+/* private elements are visible in the companion class/object */
+
+class Completion1 {
+
+ import Completion1._
+
+ private val vc1 = 0
+ private def fc1 = 0
+
+ private class Cc1
+
+ def test {
+ // needs to be done in a method, because of SI-7280
+ /*_*/
+ }
+}
+
+object Completion1 {
+
+ val c = new Completion1()
+ import c._
+
+ private val vo1 = 0
+ private def fo1 = 0
+
+ private class Co1
+
+ def test {
+ // needs to be done in a method, because of SI-7280
+ /*_*/
+ }
+}
+
diff --git a/test/files/presentation/scope-completion-3.check b/test/files/presentation/scope-completion-3.check
new file mode 100644
index 0000000000..cf73e89a3b
--- /dev/null
+++ b/test/files/presentation/scope-completion-3.check
@@ -0,0 +1,111 @@
+reload: Completions.scala
+
+askScopeCompletion at Completions.scala(75,2)
+================================================================================
+[response] askScopeCompletion at (75,2)
+retrieved 49 members
+[inaccessible] private class Cb2 extends AnyRef
+[inaccessible] private class Ct2 extends AnyRef
+[inaccessible] private def fb2: Int
+[inaccessible] private def ft2: Int
+[inaccessible] private object Ob2
+[inaccessible] private object Ot2
+[inaccessible] private type tb2 = Completion1.this.tb2
+[inaccessible] private type tt2 = Completion1.this.tt2
+[inaccessible] private[this] val vb1: Int
+[inaccessible] private[this] val vb2: Int
+[inaccessible] private[this] val vt1: Int
+[inaccessible] private[this] val vt2: Int
+[inaccessible] private[this] var rb1: Int
+[inaccessible] private[this] var rb2: Int
+[inaccessible] private[this] var rt1: Int
+[inaccessible] private[this] var rt2: Int
+abstract class Base1 extends AnyRef
+abstract trait Trait1 extends AnyRef
+class Cb1 extends AnyRef
+class Cc1 extends AnyRef
+class Completion1 extends Base1 with Trait1
+class Ct1 extends AnyRef
+def <init>(): test.Completion1
+def fb1: Int
+def fc1: Int
+def ft1: Int
+object Completion2
+object Ob1
+object Oc1
+object Ot1
+override def fb3: Int
+override def ft3: Int
+override type tb3 = Completion1.this.tb3
+override type tt3 = Completion1.this.tt3
+private class Cc2 extends AnyRef
+private def fc2: Int
+private object Oc2
+private type tc2 = Completion1.this.tc2
+private[this] val vb3: Int
+private[this] val vc1: Int
+private[this] val vc2: Int
+private[this] val vt3: Int
+private[this] var rb3: Int
+private[this] var rc1: Int
+private[this] var rc2: Int
+private[this] var rt3: Int
+type tb1 = Completion1.this.tb1
+type tc1 = Completion1.this.tc1
+type tt1 = Completion1.this.tt1
+================================================================================
+
+askScopeCompletion at Completions.scala(104,2)
+================================================================================
+[response] askScopeCompletion at (104,2)
+retrieved 49 members
+[inaccessible] private class Cb2 extends AnyRef
+[inaccessible] private class Ct2 extends AnyRef
+[inaccessible] private def fb2: Int
+[inaccessible] private def ft2: Int
+[inaccessible] private object Ob2
+[inaccessible] private object Ot2
+[inaccessible] private type tb2 = test.Completion2.tb2
+[inaccessible] private type tt2 = test.Completion2.tt2
+[inaccessible] private[this] val vb1: Int
+[inaccessible] private[this] val vb2: Int
+[inaccessible] private[this] val vt1: Int
+[inaccessible] private[this] val vt2: Int
+[inaccessible] private[this] var rb1: Int
+[inaccessible] private[this] var rb2: Int
+[inaccessible] private[this] var rt1: Int
+[inaccessible] private[this] var rt2: Int
+abstract class Base1 extends AnyRef
+abstract trait Trait1 extends AnyRef
+class Cb1 extends AnyRef
+class Co1 extends AnyRef
+class Completion1 extends Base1 with Trait1
+class Ct1 extends AnyRef
+def <init>(): test.Completion2.type
+def fb1: Int
+def fo1: Int
+def ft1: Int
+object Completion2
+object Ob1
+object Oo1
+object Ot1
+override def fb3: Int
+override def ft3: Int
+override type tb3 = test.Completion2.tb3
+override type tt3 = test.Completion2.tt3
+private class Co2 extends AnyRef
+private def fo2: Int
+private object Oo2
+private type to2 = test.Completion2.to2
+private[this] val vb3: Int
+private[this] val vo1: Int
+private[this] val vo2: Int
+private[this] val vt3: Int
+private[this] var rb3: Int
+private[this] var ro1: Int
+private[this] var ro2: Int
+private[this] var rt3: Int
+type tb1 = test.Completion2.tb1
+type to1 = test.Completion2.to1
+type tt1 = test.Completion2.tt1
+================================================================================
diff --git a/test/files/presentation/scope-completion-3/Test.scala b/test/files/presentation/scope-completion-3/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/scope-completion-3/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/scope-completion-3/src/Completions.scala b/test/files/presentation/scope-completion-3/src/Completions.scala
new file mode 100644
index 0000000000..18cef1cefa
--- /dev/null
+++ b/test/files/presentation/scope-completion-3/src/Completions.scala
@@ -0,0 +1,106 @@
+package test
+
+/* check availability of members defined locally and in hierachy */
+
+abstract class Base1 {
+
+ type tb1 = Int
+ val vb1 = 0
+ var rb1 = 0
+ def fb1 = 0
+ class Cb1
+ object Ob1
+
+ private type tb2 = Int
+ private val vb2 = 0
+ private var rb2 = 0
+ private def fb2 = 0
+ private class Cb2
+ private object Ob2
+
+ type tb3
+ val vb3: Int
+ var rb3: Int
+ def fb3: Int
+}
+
+trait Trait1 {
+
+ type tt1 = Int
+ val vt1 = 0
+ var rt1 = 0
+ def ft1 = 0
+ class Ct1
+ object Ot1
+
+ private type tt2 = Int
+ private val vt2 = 0
+ private var rt2 = 0
+ private def ft2 = 0
+ private class Ct2
+ private object Ot2
+
+ type tt3
+ val vt3: Int
+ var rt3: Int
+ def ft3: Int
+}
+
+class Completion1 extends Base1 with Trait1 {
+
+ type tc1 = Int
+ val vc1 = 0
+ var rc1 = 0
+ def fc1 = 0
+ class Cc1
+ object Oc1
+
+ private type tc2 = Int
+ private val vc2 = 0
+ private var rc2 = 0
+ private def fc2 = 0
+ private class Cc2
+ private object Oc2
+
+ override type tb3 = Int
+ override val vb3 = 12
+ override var rb3 = 12
+ override def fb3 = 12
+
+ override type tt3 = Int
+ override val vt3 = 12
+ override var rt3 = 12
+ override def ft3 = 12
+
+ /*_*/
+}
+
+object Completion2 extends Base1 with Trait1 {
+
+ type to1 = Int
+ val vo1 = 0
+ var ro1 = 0
+ def fo1 = 0
+ class Co1
+ object Oo1
+
+ private type to2 = Int
+ private val vo2 = 0
+ private var ro2 = 0
+ private def fo2 = 0
+ private class Co2
+ private object Oo2
+
+ override type tb3 = Int
+ override val vb3 = 12
+ override var rb3 = 12
+ override def fb3 = 12
+
+ override type tt3 = Int
+ override val vt3 = 12
+ override var rt3 = 12
+ override def ft3 = 12
+
+ /*_*/
+}
+
diff --git a/test/files/presentation/scope-completion-4.check b/test/files/presentation/scope-completion-4.check
new file mode 100644
index 0000000000..59c47464c4
--- /dev/null
+++ b/test/files/presentation/scope-completion-4.check
@@ -0,0 +1,293 @@
+reload: Completions.scala
+
+askScopeCompletion at Completions.scala(12,8)
+================================================================================
+[response] askScopeCompletion at (12,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class ffc extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+def ff: Unit
+def fff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(15,6)
+================================================================================
+[response] askScopeCompletion at (15,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class ffc extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+def ff: Unit
+def fff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(18,8)
+================================================================================
+[response] askScopeCompletion at (18,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class ffc extends AnyRef
+def <init>(): ffc
+def f: Unit
+def ff: Unit
+def fff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(21,6)
+================================================================================
+[response] askScopeCompletion at (21,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class ffc extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+def ff: Unit
+def fff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(24,4)
+================================================================================
+[response] askScopeCompletion at (24,4)
+retrieved 6 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(29,8)
+================================================================================
+[response] askScopeCompletion at (29,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class fcc extends AnyRef
+def <init>(): fc
+def f: Unit
+def fcf: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(32,6)
+================================================================================
+[response] askScopeCompletion at (32,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class fcc extends AnyRef
+def <init>(): fc
+def f: Unit
+def fcf: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(35,8)
+================================================================================
+[response] askScopeCompletion at (35,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class fcc extends AnyRef
+def <init>(): fc.this.fcc
+def f: Unit
+def fcf: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(38,6)
+================================================================================
+[response] askScopeCompletion at (38,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+class fcc extends AnyRef
+def <init>(): fc
+def f: Unit
+def fcf: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(41,4)
+================================================================================
+[response] askScopeCompletion at (41,4)
+retrieved 6 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class fc extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+def ff: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(44,2)
+================================================================================
+[response] askScopeCompletion at (44,2)
+retrieved 4 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(51,8)
+================================================================================
+[response] askScopeCompletion at (51,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class ccc extends AnyRef
+def <init>(): cc.this.ccc
+def ccf: Unit
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(54,6)
+================================================================================
+[response] askScopeCompletion at (54,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class ccc extends AnyRef
+def <init>(): c.this.cc
+def ccf: Unit
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(57,8)
+================================================================================
+[response] askScopeCompletion at (57,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class ccc extends AnyRef
+def <init>(): c.this.cc
+def ccf: Unit
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(60,6)
+================================================================================
+[response] askScopeCompletion at (60,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class ccc extends AnyRef
+def <init>(): c.this.cc
+def ccf: Unit
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(63,4)
+================================================================================
+[response] askScopeCompletion at (63,4)
+retrieved 6 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+def <init>(): Completion1.this.c
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(68,8)
+================================================================================
+[response] askScopeCompletion at (68,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class cfc extends AnyRef
+def <init>(): cfc
+def cf: Unit
+def cff: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(71,6)
+================================================================================
+[response] askScopeCompletion at (71,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class cfc extends AnyRef
+def <init>(): Completion1.this.c
+def cf: Unit
+def cff: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(74,8)
+================================================================================
+[response] askScopeCompletion at (74,8)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class cfc extends AnyRef
+def <init>(): Completion1.this.c
+def cf: Unit
+def cff: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(77,6)
+================================================================================
+[response] askScopeCompletion at (77,6)
+retrieved 8 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+class cfc extends AnyRef
+def <init>(): Completion1.this.c
+def cf: Unit
+def cff: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(80,4)
+================================================================================
+[response] askScopeCompletion at (80,4)
+retrieved 6 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+class cc extends AnyRef
+def <init>(): Completion1.this.c
+def cf: Unit
+def f: Unit
+================================================================================
+
+askScopeCompletion at Completions.scala(83,2)
+================================================================================
+[response] askScopeCompletion at (83,2)
+retrieved 4 members
+class Completion1 extends AnyRef
+class c extends AnyRef
+def <init>(): test.Completion1
+def f: Unit
+================================================================================
diff --git a/test/files/presentation/scope-completion-4/Test.scala b/test/files/presentation/scope-completion-4/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/scope-completion-4/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/scope-completion-4/src/Completions.scala b/test/files/presentation/scope-completion-4/src/Completions.scala
new file mode 100644
index 0000000000..d11315720a
--- /dev/null
+++ b/test/files/presentation/scope-completion-4/src/Completions.scala
@@ -0,0 +1,84 @@
+package test
+
+/* check that members defined in sub-block are not visible*/
+
+class Completion1 {
+
+ def f {
+
+ def ff {
+
+ def fff {
+ /*_*/
+ }
+
+ /*_*/
+
+ class ffc {
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+
+ class fc {
+
+ def fcf {
+ /*_*/
+ }
+
+ /*_*/
+
+ class fcc {
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+
+ class c {
+
+ class cc {
+
+ class ccc {
+ /*_*/
+ }
+
+ /*_*/
+
+ def ccf {
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+
+ def cf {
+
+ class cfc {
+ /*_*/
+ }
+
+ /*_*/
+
+ def cff {
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+ }
+
+ /*_*/
+}
diff --git a/test/files/presentation/scope-completion-import.check b/test/files/presentation/scope-completion-import.check
new file mode 100644
index 0000000000..d518b0c37a
--- /dev/null
+++ b/test/files/presentation/scope-completion-import.check
@@ -0,0 +1,141 @@
+reload: Completions.scala
+
+askScopeCompletion at Completions.scala(15,4)
+================================================================================
+[response] askScopeCompletion at (15,4)
+retrieved 10 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+def fCCC: Int
+def fOOO: Int
+object O
+val o: test.O.type
+================================================================================
+
+askScopeCompletion at Completions.scala(19,4)
+================================================================================
+[response] askScopeCompletion at (19,4)
+retrieved 9 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+def fCCC: Int
+def fOOO: Int
+object O
+================================================================================
+
+askScopeCompletion at Completions.scala(24,4)
+================================================================================
+[response] askScopeCompletion at (24,4)
+retrieved 9 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+def fCCC: Int
+object O
+val c: test.C
+================================================================================
+
+askScopeCompletion at Completions.scala(27,5)
+================================================================================
+[response] askScopeCompletion at (27,5)
+retrieved 8 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+object O
+val c: test.C
+================================================================================
+
+askScopeCompletion at Completions.scala(30,5)
+================================================================================
+[response] askScopeCompletion at (30,5)
+retrieved 9 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+def fCCC: Int
+object O
+val c: test.C
+================================================================================
+
+askScopeCompletion at Completions.scala(32,5)
+================================================================================
+[response] askScopeCompletion at (32,5)
+retrieved 10 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo
+def fCCC: Int
+def fOOO: Int
+object O
+val c: test.C
+================================================================================
+
+askScopeCompletion at Completions.scala(41,4)
+================================================================================
+[response] askScopeCompletion at (41,4)
+retrieved 10 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo_1
+def bar: Unit
+def fCCC: Int
+def fOOO: Int
+object O
+================================================================================
+
+askScopeCompletion at Completions.scala(51,4)
+================================================================================
+[response] askScopeCompletion at (51,4)
+retrieved 11 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo_2
+def bar: Unit
+def fCCC: Int
+def fOOO: Int
+object O
+private[this] val o: test.O.type
+================================================================================
+
+askScopeCompletion at Completions.scala(61,4)
+================================================================================
+[response] askScopeCompletion at (61,4)
+retrieved 10 members
+class C extends AnyRef
+class Foo extends AnyRef
+class Foo_1 extends AnyRef
+class Foo_2 extends AnyRef
+class Foo_3 extends AnyRef
+def <init>(): test.Foo_3
+def bar: Unit
+def fCCC: Int
+object O
+private[this] val c: test.C
+================================================================================
diff --git a/test/files/presentation/scope-completion-import/Test.scala b/test/files/presentation/scope-completion-import/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/scope-completion-import/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/scope-completion-import/src/Completions.scala b/test/files/presentation/scope-completion-import/src/Completions.scala
new file mode 100644
index 0000000000..6e08321283
--- /dev/null
+++ b/test/files/presentation/scope-completion-import/src/Completions.scala
@@ -0,0 +1,64 @@
+package test
+
+class C {
+ def fCCC : Int = 0
+}
+
+object O extends C {
+ def fOOO : Int = 0
+}
+
+class Foo {
+ {
+ val o = O
+ import o._
+ /*_*/
+ }
+ {
+ import O._
+ /*_*/
+ }
+ {
+ val c = new C
+ import c._
+ /*_*/
+ }
+ {
+ f/*_*/
+ val c = new C
+ import c._
+ f/*_*/
+ import O._
+ f/*_*/
+ }
+}
+
+class Foo_1 {
+
+ import O._
+
+ def bar {
+ /*_*/
+ }
+}
+
+class Foo_2 {
+
+ val o = O
+ import o._
+
+ def bar {
+ /*_*/
+ }
+}
+
+class Foo_3 {
+
+ val c = new C
+ import c._
+
+ def bar {
+ /*_*/
+ }
+}
+
diff --git a/test/files/presentation/t1207.check b/test/files/presentation/t1207.check
index 84bfd79d75..0eed4ece04 100644
--- a/test/files/presentation/t1207.check
+++ b/test/files/presentation/t1207.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(10,15)
================================================================================
-[response] askCompletionAt (10,15)
+[response] askTypeCompletion at (10,15)
retrieved 3 members
final package bongo
final package lang
@@ -11,7 +11,7 @@ final package util
askTypeCompletion at Completions.scala(11,16)
================================================================================
-[response] askCompletionAt (11,16)
+[response] askTypeCompletion at (11,16)
retrieved 3 members
final package bongo
final package lang
@@ -20,7 +20,7 @@ final package util
askTypeCompletion at Completions.scala(12,19)
================================================================================
-[response] askCompletionAt (12,19)
+[response] askTypeCompletion at (12,19)
retrieved 3 members
final package bongo
final package lang
@@ -29,7 +29,7 @@ final package util
askTypeCompletion at Completions.scala(13,19)
================================================================================
-[response] askCompletionAt (13,19)
+[response] askTypeCompletion at (13,19)
retrieved 3 members
final package bongo
final package lang
@@ -38,7 +38,7 @@ final package util
askTypeCompletion at Completions.scala(14,23)
================================================================================
-[response] askCompletionAt (14,23)
+[response] askTypeCompletion at (14,23)
retrieved 3 members
final package bongo
final package lang
@@ -47,7 +47,7 @@ final package util
askTypeCompletion at Completions.scala(15,10)
================================================================================
-[response] askCompletionAt (15,10)
+[response] askTypeCompletion at (15,10)
retrieved 0 members
================================================================================
diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check
index 5f17c0b762..04806b5867 100644
--- a/test/files/presentation/t5708.check
+++ b/test/files/presentation/t5708.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(17,9)
================================================================================
-[response] askCompletionAt (17,9)
+[response] askTypeCompletion at (17,9)
retrieved 39 members
[inaccessible] private def privateM: String
[inaccessible] private[this] val privateV: String
diff --git a/test/files/presentation/t7915.check b/test/files/presentation/t7915.check
new file mode 100644
index 0000000000..b18b4ddb55
--- /dev/null
+++ b/test/files/presentation/t7915.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `Bar` at (7,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala
+================================================================================
+
+askHyperlinkPos for `bar` at (7,22) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `bar` at (2,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t7915/Test.scala b/test/files/presentation/t7915/Test.scala
new file mode 100644
index 0000000000..c2f89bdb17
--- /dev/null
+++ b/test/files/presentation/t7915/Test.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/t7915/src/Foo.scala b/test/files/presentation/t7915/src/Foo.scala
new file mode 100644
index 0000000000..a4166ae5b4
--- /dev/null
+++ b/test/files/presentation/t7915/src/Foo.scala
@@ -0,0 +1,9 @@
+class Bar {
+ def bar(b: Int = 2) {}
+}
+
+class Foo {
+ def foo() {
+ new Bar/*#*/().bar/*#*/()
+ }
+}
diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check
index 078e0a2342..217da34b9c 100644
--- a/test/files/presentation/visibility.check
+++ b/test/files/presentation/visibility.check
@@ -2,7 +2,7 @@ reload: Completions.scala
askTypeCompletion at Completions.scala(14,12)
================================================================================
-[response] askCompletionAt (14,12)
+[response] askTypeCompletion at (14,12)
retrieved 37 members
[inaccessible] private[this] def secretPrivateThis(): Unit
def +(other: String): String
@@ -42,7 +42,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(16,11)
================================================================================
-[response] askCompletionAt (16,11)
+[response] askTypeCompletion at (16,11)
retrieved 37 members
def +(other: String): String
def ->[B](y: B): (accessibility.Foo, B)
@@ -82,7 +82,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(22,11)
================================================================================
-[response] askCompletionAt (22,11)
+[response] askTypeCompletion at (22,11)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
def +(other: String): String
@@ -122,7 +122,7 @@ protected[package lang] def finalize(): Unit
askTypeCompletion at Completions.scala(28,10)
================================================================================
-[response] askCompletionAt (28,10)
+[response] askTypeCompletion at (28,10)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
[inaccessible] private[this] def secretPrivateThis(): Unit
@@ -162,7 +162,7 @@ protected[package accessibility] def secretProtectedInPackage(): Unit
askTypeCompletion at Completions.scala(37,8)
================================================================================
-[response] askCompletionAt (37,8)
+[response] askTypeCompletion at (37,8)
retrieved 37 members
[inaccessible] private def secretPrivate(): Unit
[inaccessible] private[this] def secretPrivateThis(): Unit
diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala
index e6764b92c8..80317bc757 100644
--- a/test/files/run/Course-2002-05.scala
+++ b/test/files/run/Course-2002-05.scala
@@ -3,15 +3,15 @@
//############################################################################
object M0 {
- def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = {
+ def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = {
if (xs.isEmpty)
- Pair(List(),List())
+ (List(),List())
else {
val tailPartition = partition(xs.tail, pred);
if (pred(xs.head))
- Pair(xs.head :: tailPartition._1, tailPartition._2)
+ (xs.head :: tailPartition._1, tailPartition._2)
else
- Pair(tailPartition._1, xs.head :: tailPartition._2)
+ (tailPartition._1, xs.head :: tailPartition._2)
}
}
@@ -49,9 +49,9 @@ object M0 {
//############################################################################
object M1 {
- def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = {
- xs.foldRight[Pair[List[a], List[a]]](Pair(List(), List())) {
- (x, p) => if (pred (x)) Pair(x :: p._1, p._2) else Pair(p._1, x :: p._2)
+ def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = {
+ xs.foldRight[Tuple2[List[a], List[a]]]((List(), List())) {
+ (x, p) => if (pred (x)) (x :: p._1, p._2) else (p._1, x :: p._2)
}
}
@@ -136,7 +136,7 @@ object M3 {
def adjoinRow(placement: Placement): List[Placement] =
range(1, n)
.filter (column => isSafe(column, placement))
- .map (column => Pair(row, column) :: placement);
+ .map (column => (row, column) :: placement);
placeQueens(row - 1) flatMap adjoinRow
}
diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala
index e4fb86a966..908a934041 100644
--- a/test/files/run/Course-2002-06.scala
+++ b/test/files/run/Course-2002-06.scala
@@ -55,7 +55,7 @@ abstract class Graphics(_width: Double, _height: Double) {
}
/** Draw a list of segments on the picture.*/
- def drawSegments(frm: Frame)(segments: List[Pair[Vector, Vector]]): Unit =
+ def drawSegments(frm: Frame)(segments: List[Tuple2[Vector, Vector]]): Unit =
if (segments.isEmpty) ()
else {
drawSegment(frm)(segments.head._1, segments.head._2);
diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala
index 055ff74d81..2d9457653f 100644
--- a/test/files/run/Course-2002-07.scala
+++ b/test/files/run/Course-2002-07.scala
@@ -181,10 +181,10 @@ object M4 {
object M5 {
- def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match {
- case Pair(List(), _) => List()
- case Pair(_, List()) => List()
- case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1)
+ def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = (xs,ys) match {
+ case (List(), _) => List()
+ case (_, List()) => List()
+ case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
def test_zipFun[a,b](xs: List[a], ys: List[b]) = {
@@ -216,9 +216,9 @@ object M5 {
object M6 {
- def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = (Pair(xs,ys): @unchecked) match {
- // !!! case Pair(List(), _), Pair(_, List()) => List()
- case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1)
+ def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = ((xs,ys): @unchecked) match {
+ // !!! case (List(), _), (_, List()) => List()
+ case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1)
}
def test_zipFun[a,b](xs: List[a], ys: List[b]) = {
@@ -374,9 +374,9 @@ object M9 {
object MA {
- def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match {
+ def lookup[k,v](xs: List[Tuple2[k,v]], k: k): v = xs match {
case List() => sys.error("no value for " + k)
- case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k)
+ case (k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k)
}
trait Expr {
@@ -437,8 +437,8 @@ object MA {
val g1 = g0 derive x;
Console.println("g (x) = " + g0);
Console.println("g'(x) = " + g1);
- Console.println("g (3) = " + evalvars(List(Pair("x",3)))(g0));
- Console.println("g'(3) = " + evalvars(List(Pair("x",3)))(g1));
+ Console.println("g (3) = " + evalvars(List(("x",3)))(g0));
+ Console.println("g'(3) = " + evalvars(List(("x",3)))(g1));
Console.println;
}
@@ -453,26 +453,26 @@ object Utils {
if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1);
def power(x: Int, y: Int): Int = (x,y) match {
- case Pair(0,0) => sys.error("power(0,0)")
- case Pair(0,_) => 0
- case Pair(1,_) => 1
- case Pair(_,0) => 1
- case Pair(_,1) => x
- case Pair(_,2) => x*x
- case Pair(_,_) => if (y < 0) 1/power0(x,y) else power0(x,y)
+ case (0,0) => sys.error("power(0,0)")
+ case (0,_) => 0
+ case (1,_) => 1
+ case (_,0) => 1
+ case (_,1) => x
+ case (_,2) => x*x
+ case (_,_) => if (y < 0) 1/power0(x,y) else power0(x,y)
}
def lookup(entries: List[(String,Int)], key: String): Int = entries match {
case List() => sys.error("no value for " + key)
- case Pair(k,v) :: _ if (k == key) => v
+ case (k,v) :: _ if (k == key) => v
case _ :: rest => lookup(rest, key)
}
def compare(xs: List[String], ys: List[String]): Int = (xs, ys) match {
- case Pair(List(), List()) => 0
- case Pair(List(), _ ) => -1
- case Pair(_ , List()) => +1
- case Pair(x::xs , y::ys ) => {
+ case (List(), List()) => 0
+ case (List(), _ ) => -1
+ case (_ , List()) => +1
+ case (x::xs , y::ys ) => {
val diff = x.compareTo(y);
if (diff != 0) diff else compare(xs,ys)
}
@@ -508,18 +508,18 @@ object MB {
private def +< (that: Expr): Boolean = (this +<? that) < 0;
private def +<= (that: Expr): Boolean = (this +<? that) <= 0;
- private def +<? (that: Expr): Int = Pair(this,that) match {
- case Pair(Add(_,_), _ ) => 0
- case Pair(_ , Add(_,_)) => 0
- case Pair(_ , _ ) => compare(this.vars,that.vars)
+ private def +<? (that: Expr): Int = (this,that) match {
+ case (Add(_,_), _ ) => 0
+ case (_ , Add(_,_)) => 0
+ case (_ , _ ) => compare(this.vars,that.vars)
}
- def + (that: Expr): Expr = if (that +<= this) Pair(this,that) match {
- case Pair(_ , Lit(0) ) => this
- case Pair(Lit(l) , Lit(r) ) => Lit(l + r)
- case Pair(_ , Add(rl,rr)) => (this + rl) + rr
- case Pair(Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr)
- case Pair(_ , _ ) => {
+ def + (that: Expr): Expr = if (that +<= this) (this,that) match {
+ case (_ , Lit(0) ) => this
+ case (Lit(l) , Lit(r) ) => Lit(l + r)
+ case (_ , Add(rl,rr)) => (this + rl) + rr
+ case (Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr)
+ case (_ , _ ) => {
val l = this.term;
val r = that.term;
if (l equ r) Lit(this.count + that.count) * r else Add(this, that)
@@ -528,41 +528,41 @@ object MB {
private def *< (that: Expr): Boolean = (this *<? that) < 0;
private def *<= (that: Expr): Boolean = (this *<? that) <= 0;
- private def *<? (that: Expr): Int = Pair(this,that) match {
- case Pair(Mul(_,_), _ ) => 0
- case Pair(_ , Mul(_,_)) => 0
- case Pair(Add(_,_), Add(_,_)) => 0
- case Pair(Add(_,_), _ ) => -1
- case Pair(_ , Add(_,_)) => +1
- case Pair(Lit(_) , Lit(_) ) => 0
- case Pair(Lit(_) , _ ) => -1
- case Pair(_ , Lit(_) ) => +1
- case Pair(Var(l) , Var(r) ) => l.compareTo(r)
- case Pair(Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1
- case Pair(Pow(l,_), Var(_) ) => if (l *< that) -1 else +1
- case Pair(Pow(l,_), Pow(r,_)) => l *<? r
+ private def *<? (that: Expr): Int = (this,that) match {
+ case (Mul(_,_), _ ) => 0
+ case (_ , Mul(_,_)) => 0
+ case (Add(_,_), Add(_,_)) => 0
+ case (Add(_,_), _ ) => -1
+ case (_ , Add(_,_)) => +1
+ case (Lit(_) , Lit(_) ) => 0
+ case (Lit(_) , _ ) => -1
+ case (_ , Lit(_) ) => +1
+ case (Var(l) , Var(r) ) => l.compareTo(r)
+ case (Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1
+ case (Pow(l,_), Var(_) ) => if (l *< that) -1 else +1
+ case (Pow(l,_), Pow(r,_)) => l *<? r
}
- def * (that: Expr): Expr = if (this *<= that) Pair(this,that) match {
- case Pair(Lit(0) , _ ) => this
- case Pair(Lit(1) , _ ) => that
- case Pair(Mul(ll,lr), r ) => ll * (lr * r)
- case Pair(Add(ll,lr), r ) => ll * r + lr * r
- case Pair(Lit(l) , Lit(r) ) => Lit(l * r)
- case Pair(Var(_) , Var(_) ) if (this equ that) => Pow(this,2)
- case Pair(Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1)
- case Pair(Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr)
- case Pair(l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr
- case Pair(_ , _ ) => Mul(this,that)
+ def * (that: Expr): Expr = if (this *<= that) (this,that) match {
+ case (Lit(0) , _ ) => this
+ case (Lit(1) , _ ) => that
+ case (Mul(ll,lr), r ) => ll * (lr * r)
+ case (Add(ll,lr), r ) => ll * r + lr * r
+ case (Lit(l) , Lit(r) ) => Lit(l * r)
+ case (Var(_) , Var(_) ) if (this equ that) => Pow(this,2)
+ case (Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1)
+ case (Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr)
+ case (l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr
+ case (_ , _ ) => Mul(this,that)
} else that * this;
def ^ (that: Int): Expr = (this,that) match {
- case Pair(_ ,1) => this
- case Pair(Lit(i) ,n) => Lit(power(i,n))
- case Pair(Var(_) ,n) => Pow(this,n)
- case Pair(Add(_,_),n) => this * (this ^ (n - 1))
- case Pair(Mul(l,r),n) => (l ^ n) * (r ^ n)
- case Pair(Pow(e,m),n) => Pow(e,m + n)
+ case (_ ,1) => this
+ case (Lit(i) ,n) => Lit(power(i,n))
+ case (Var(_) ,n) => Pow(this,n)
+ case (Add(_,_),n) => this * (this ^ (n - 1))
+ case (Mul(l,r),n) => (l ^ n) * (r ^ n)
+ case (Pow(e,m),n) => Pow(e,m + n)
}
def derive(v: Var): Expr = this match {
@@ -581,12 +581,12 @@ object MB {
case Pow(l, r) => power(l.evaluate(vars), r)
}
- def equ(that: Expr): Boolean = Pair(this,that) match {
- case Pair(Lit(l) ,Lit(r)) => l == r
- case Pair(Var(l) ,Var(r)) => l == r
- case Pair(Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr)
- case Pair(Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr)
- case Pair(Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr)
+ def equ(that: Expr): Boolean = (this,that) match {
+ case (Lit(l) ,Lit(r)) => l == r
+ case (Var(l) ,Var(r)) => l == r
+ case (Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr)
+ case (Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr)
+ case (Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr)
case _ => false
}
@@ -667,7 +667,7 @@ object MB {
Console.println;
def check(n: String, f: Expr, x: Int, e: Int) {
- val a: Int = f.evaluate(List(Pair("x",x)));
+ val a: Int = f.evaluate(List(("x",x)));
val s: String = if (a == e) "ok" else "KO(" + e + ")";
Console.println(n + "(" + x + ") = " + a + " " + s);
}
diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala
index 38b8363661..5e21edaba3 100644
--- a/test/files/run/Course-2002-08.scala
+++ b/test/files/run/Course-2002-08.scala
@@ -163,7 +163,7 @@ object M5 {
}
abstract class Simulation() {
- private type Agenda = List[Pair[Int, Action]];
+ private type Agenda = List[Tuple2[Int, Action]];
private var agenda: Agenda = List();
private var curtime = 0;
def currentTime: Int = curtime;
@@ -171,17 +171,17 @@ object M5 {
def afterDelay(delay: Int)(action: Action): Unit = {
def insert(ag: Agenda, time: Int): Agenda = ag match {
case List() =>
- List(Pair(time, action))
- case Pair(t, act) :: ag1 =>
- if (time < t) Pair(time, action) :: ag
- else Pair(t, act) :: insert(ag1, time)
+ List((time, action))
+ case (t, act) :: ag1 =>
+ if (time < t) (time, action) :: ag
+ else (t, act) :: insert(ag1, time)
}
agenda = insert(agenda, curtime + delay)
}
private def next: Unit = agenda match {
case List() => ()
- case Pair(time, action) :: ag1 => {
+ case (time, action) :: ag1 => {
agenda = ag1;
curtime = time;
action();
@@ -413,7 +413,7 @@ object M5 {
class Simulator() {
type Action = () => Unit;
- type Agenda = List[Pair[Int, Action]];
+ type Agenda = List[Tuple2[Int, Action]];
private var agenda: Agenda = List();
private var curtime = 0;
@@ -421,17 +421,17 @@ class Simulator() {
def afterDelay(delay: Int)(action: Action) = {
def insert(ag: Agenda, time: Int): Agenda = ag match {
case List() =>
- List(Pair(time, action))
- case Pair(t, act) :: ag1 =>
- if (time < t) Pair(time, action) :: ag
- else Pair(t, act) :: insert(ag1, time)
+ List((time, action))
+ case (t, act) :: ag1 =>
+ if (time < t) (time, action) :: ag
+ else (t, act) :: insert(ag1, time)
}
agenda = insert(agenda, curtime + delay)
}
def next: Unit = agenda match {
case List() => ()
- case Pair(time, action) :: rest => {
+ case (time, action) :: rest => {
agenda = rest;
curtime = time;
action();
@@ -567,8 +567,8 @@ class Main() extends CircuitSimulator() {
demux(in, ctrl.reverse, out.reverse);
probe("in", in);
- for (Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
- for (Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
+ for ((x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
+ for ((x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
in.setSignal(true);
run;
diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala
index 87f91111d8..704f2ec0aa 100644
--- a/test/files/run/Course-2002-09.scala
+++ b/test/files/run/Course-2002-09.scala
@@ -13,11 +13,11 @@ object NoConstraint extends Constraint {
}
class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint {
- def newValue = Triple(a1.getValue, a2.getValue, sum.getValue) match {
- case Triple(Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this)
- case Triple(Some(x1), _ , Some(r)) => a2.setValue(r - x1, this)
- case Triple(_ , Some(x2), Some(r)) => a1.setValue(r - x2, this)
- case _ =>
+ def newValue = (a1.getValue, a2.getValue, sum.getValue) match {
+ case (Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this)
+ case (Some(x1), _ , Some(r)) => a2.setValue(r - x1, this)
+ case (_ , Some(x2), Some(r)) => a1.setValue(r - x2, this)
+ case _ =>
}
def dropValue: Unit = {
a1.forgetValue(this); a2.forgetValue(this); sum.forgetValue(this);
@@ -29,13 +29,13 @@ class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint {
class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity)
extends Constraint {
- def newValue = Triple(m1.getValue, m2.getValue, prod.getValue) match {
- case Triple(Some(0d), _ , _ ) => prod.setValue(0, this);
- case Triple(_ , Some(0d), _ ) => prod.setValue(0, this);
- case Triple(Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this)
- case Triple(Some(x1), _ , Some(r)) => m2.setValue(r / x1, this)
- case Triple(_, Some(x2), Some(r)) => m1.setValue(r / x2, this)
- case _ =>
+ def newValue = (m1.getValue, m2.getValue, prod.getValue) match {
+ case (Some(0d), _ , _ ) => prod.setValue(0, this);
+ case (_ , Some(0d), _ ) => prod.setValue(0, this);
+ case (Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this)
+ case (Some(x1), _ , Some(r)) => m2.setValue(r / x1, this)
+ case (_, Some(x2), Some(r)) => m1.setValue(r / x2, this)
+ case _ =>
}
def dropValue: Unit = {
m1.forgetValue(this); m2.forgetValue(this); prod.forgetValue(this);
@@ -46,11 +46,11 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity)
}
class Squarer(square: Quantity, root: Quantity) extends Constraint {
- def newValue: Unit = Pair(square.getValue, root.getValue) match {
- case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number")
- case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this)
- case Pair(_ , Some(x)) => square.setValue(x*x, this)
- case _ =>
+ def newValue: Unit = (square.getValue, root.getValue) match {
+ case (Some(x), _ )if (x < 0) => sys.error("Square of negative number")
+ case (Some(x), _ ) => root.setValue(Math.sqrt(x), this)
+ case (_ , Some(x)) => square.setValue(x*x, this)
+ case _ =>
}
def dropValue: Unit = {
square.forgetValue(this); root.forgetValue(this);
@@ -60,9 +60,9 @@ class Squarer(square: Quantity, root: Quantity) extends Constraint {
}
class Eq(a: Quantity, b: Quantity) extends Constraint {
- def newValue = (Pair(a.getValue, b.getValue): @unchecked) match {
- case Pair(Some(x), _ ) => b.setValue(x, this);
- case Pair(_ , Some(y)) => a.setValue(y, this);
+ def newValue = ((a.getValue, b.getValue): @unchecked) match {
+ case (Some(x), _ ) => b.setValue(x, this);
+ case (_ , Some(y)) => a.setValue(y, this);
}
def dropValue {
a.forgetValue(this); b.forgetValue(this);
diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala
index 4bd3614fb0..a596a33873 100644
--- a/test/files/run/Course-2002-13.scala
+++ b/test/files/run/Course-2002-13.scala
@@ -74,18 +74,18 @@ object Terms {
val NoTerm = Con("<none>", List());
- def unify1(x: Term, y: Term, s: Subst): Option[Subst] = Pair(x, y) match {
- case Pair(Var(a), Var(b)) if (a == b) =>
+ def unify1(x: Term, y: Term, s: Subst): Option[Subst] = (x, y) match {
+ case (Var(a), Var(b)) if (a == b) =>
Some(s)
- case Pair(Var(a), _) => lookup(s, a) match {
+ case (Var(a), _) => lookup(s, a) match {
case Some(x1) => unify(x1, y, s)
case None => if (y.tyvars contains a) None else Some(Binding(a, y) :: s)
}
- case Pair(_, Var(b)) => lookup(s, b) match {
+ case (_, Var(b)) => lookup(s, b) match {
case Some(y1) => unify(x, y1, s)
case None => if (x.tyvars contains b) None else Some(Binding(b, x) :: s)
}
- case Pair(Con(a, xs), Con(b, ys)) if (a == b) =>
+ case (Con(a, xs), Con(b, ys)) if (a == b) =>
unify(xs, ys, s)
case _ => None
}
@@ -96,9 +96,9 @@ object Terms {
ss
}
- def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = Pair(xs, ys) match {
- case Pair(List(), List()) => Some(s)
- case Pair(x :: xs1, y :: ys1) =>
+ def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = (xs, ys) match {
+ case (List(), List()) => Some(s)
+ case (x :: xs1, y :: ys1) =>
unify(x, y, s) match {
case Some(s1) => unify(xs1, ys1, s1)
case None => None
diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala
index ba8449c299..02849b5817 100644
--- a/test/files/run/bugs.scala
+++ b/test/files/run/bugs.scala
@@ -46,7 +46,7 @@ object Bug135Test {
def test(args: Array[String]) {
val myMap:TreeMap[Int, String] = new TreeMap
- val map1 = myMap + Pair(42, "The answer")
+ val map1 = myMap + ((42, "The answer"))
println(map1.get(42))
}
diff --git a/test/files/run/ctries-old/main.scala b/test/files/run/ctries-old/main.scala
index f714bcdcdc..77161fed2f 100644
--- a/test/files/run/ctries-old/main.scala
+++ b/test/files/run/ctries-old/main.scala
@@ -38,7 +38,7 @@ trait Spec {
var produced = false
try body
catch {
- case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true
+ case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].runtimeClass) produced = true
} finally {
assert(produced, "Did not produce exception of type: " + implicitly[ClassManifest[T]])
}
diff --git a/test/files/run/delambdafy-dependent-on-param-subst-2.scala b/test/files/run/delambdafy-dependent-on-param-subst-2.scala
new file mode 100644
index 0000000000..7b6fc597e8
--- /dev/null
+++ b/test/files/run/delambdafy-dependent-on-param-subst-2.scala
@@ -0,0 +1,20 @@
+trait M[-X] {
+ def m(x: X): Boolean
+}
+
+class C
+class A { class C }
+
+object Test {
+ def main(args: Array[String]) {
+ val a = new A
+
+ // class O extends M[a.C] { def m(x: a.C) = true }
+ // (new O: M[Null]).m(null) // Okay
+
+ ((a: A) => {
+ class N extends M[a.C] { def m(x: a.C) = true }
+ new N: M[Null]
+ }).apply(a).m(null) // NPE, missing bridge
+ }
+}
diff --git a/test/files/run/delambdafy-dependent-on-param-subst.flags b/test/files/run/delambdafy-dependent-on-param-subst.flags
new file mode 100644
index 0000000000..2b27e19830
--- /dev/null
+++ b/test/files/run/delambdafy-dependent-on-param-subst.flags
@@ -0,0 +1 @@
+-Ydelambdafy:method \ No newline at end of file
diff --git a/test/files/run/delambdafy-dependent-on-param-subst.scala b/test/files/run/delambdafy-dependent-on-param-subst.scala
new file mode 100644
index 0000000000..7b6fc597e8
--- /dev/null
+++ b/test/files/run/delambdafy-dependent-on-param-subst.scala
@@ -0,0 +1,20 @@
+trait M[-X] {
+ def m(x: X): Boolean
+}
+
+class C
+class A { class C }
+
+object Test {
+ def main(args: Array[String]) {
+ val a = new A
+
+ // class O extends M[a.C] { def m(x: a.C) = true }
+ // (new O: M[Null]).m(null) // Okay
+
+ ((a: A) => {
+ class N extends M[a.C] { def m(x: a.C) = true }
+ new N: M[Null]
+ }).apply(a).m(null) // NPE, missing bridge
+ }
+}
diff --git a/test/files/run/fors.check b/test/files/run/fors.check
new file mode 100644
index 0000000000..b459f00b49
--- /dev/null
+++ b/test/files/run/fors.check
@@ -0,0 +1,28 @@
+
+testOld
+1 2 3
+2
+2
+3
+1 2 3
+1 2 3
+0 1 2 3 4 5 6 7 8 9
+0 2 4 6 8
+0 2 4 6 8
+a b c
+b c
+b c
+
+testNew
+3
+1 2 3
+1 2 3
+0 1 2 3 4 5 6 7 8 9
+0 2 4 6 8
+0 2 4 6 8
+0 2 4 6 8
+0 2 4 6 8
+0 2 4 6 8
+0 2 4 6 8
+0 2 4 6 8
+a b c
diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala
new file mode 100644
index 0000000000..c778df3e24
--- /dev/null
+++ b/test/files/run/fors.scala
@@ -0,0 +1,84 @@
+//############################################################################
+// for-comprehensions (old and new syntax)
+//############################################################################
+
+//############################################################################
+
+object Test extends App {
+ val xs = List(1, 2, 3)
+ val ys = List('a, 'b, 'c)
+
+ def it = 0 until 10
+
+ val ar = "abc".toCharArray
+
+ /////////////////// old syntax ///////////////////
+
+ def testOld {
+ println("\ntestOld")
+
+ // lists
+ for (x <- xs) print(x + " "); println
+ for (x <- xs;
+ if x % 2 == 0) print(x + " "); println
+ for {x <- xs
+ if x % 2 == 0} print(x + " "); println
+ var n = 0
+ for (_ <- xs) n += 1; println(n)
+ for ((x, y) <- xs zip ys) print(x + " "); println
+ for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println
+
+ // iterators
+ for (x <- it) print(x + " "); println
+ for (x <- it;
+ if x % 2 == 0) print(x + " "); println
+ for {x <- it
+ if x % 2 == 0} print(x + " "); println
+
+ // arrays
+ for (x <- ar) print(x + " "); println
+ for (x <- ar;
+ if x.toInt > 97) print(x + " "); println
+ for {x <- ar
+ if x.toInt > 97} print(x + " "); println
+
+ }
+
+ /////////////////// new syntax ///////////////////
+
+ def testNew {
+ println("\ntestNew")
+
+ // lists
+ var n = 0
+ for (_ <- xs) n += 1; println(n)
+ for ((x, y) <- xs zip ys) print(x + " "); println
+ for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println
+
+ // iterators
+ for (x <- it) print(x + " "); println
+ for (x <- it if x % 2 == 0) print(x + " "); println
+ for (x <- it; if x % 2 == 0) print(x + " "); println
+ for (x <- it;
+ if x % 2 == 0) print(x + " "); println
+ for (x <- it
+ if x % 2 == 0) print(x + " "); println
+ for {x <- it
+ if x % 2 == 0} print(x + " "); println
+ for (x <- it;
+ y = 2
+ if x % y == 0) print(x + " "); println
+ for {x <- it
+ y = 2
+ if x % y == 0} print(x + " "); println
+
+ // arrays
+ for (x <- ar) print(x + " "); println
+
+ }
+
+ ////////////////////////////////////////////////////
+
+ testOld
+ testNew
+}
diff --git a/test/files/run/getClassTest-old.scala b/test/files/run/getClassTest-old.scala
index 789dd4d162..cd1b6b07f6 100644
--- a/test/files/run/getClassTest-old.scala
+++ b/test/files/run/getClassTest-old.scala
@@ -53,7 +53,7 @@ class MoreAnyRefs {
@deprecated("Suppress warnings", since="2.11")
object Test {
def returnTypes[T: Manifest] = (
- manifest[T].erasure.getMethods.toList
+ manifest[T].runtimeClass.getMethods.toList
filter (_.getName startsWith "f")
sortBy (_.getName)
map (m => m.getName + ": " + m.getGenericReturnType.toString)
diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala
index 415b76852f..350d7b41aa 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 e3df05ba50..255dafd47e 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 ce30366c61..c63353164e 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
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 a601af6dde..3cdd531316 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
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 6e5983bdec..3feddd2786 100644
--- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala
+++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
diff --git a/test/files/run/macro-blackbox-materialization.check b/test/files/run/macro-blackbox-materialization.check
new file mode 100644
index 0000000000..7165b734ac
--- /dev/null
+++ b/test/files/run/macro-blackbox-materialization.check
@@ -0,0 +1,3 @@
+C(Int)
+C(String)
+C(Nothing)
diff --git a/test/files/run/macro-blackbox-materialization/Macros_1.scala b/test/files/run/macro-blackbox-materialization/Macros_1.scala
new file mode 100644
index 0000000000..7c31dd7dc2
--- /dev/null
+++ b/test/files/run/macro-blackbox-materialization/Macros_1.scala
@@ -0,0 +1,16 @@
+// For the full version of the test, take a look at run/t5923a
+
+import scala.reflect.macros.BlackboxContext
+import language.experimental.macros
+
+case class C[T](t: String)
+object C {
+ implicit def foo[T]: C[T] = macro Macros.impl[T]
+}
+
+object Macros {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
+ import c.universe._
+ reify(C[T](c.literal(weakTypeOf[T].toString).splice))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-blackbox-materialization/Test_2.scala b/test/files/run/macro-blackbox-materialization/Test_2.scala
new file mode 100644
index 0000000000..001ff9aea8
--- /dev/null
+++ b/test/files/run/macro-blackbox-materialization/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ println(implicitly[C[Int]])
+ println(implicitly[C[String]])
+ println(implicitly[C[Nothing]])
+} \ No newline at end of file
diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
index 56c5252f31..0a9f9a0ced 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
@@ -1,10 +1,11 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.language.experimental.macros
+import scala.reflect.macros.{BlackboxContext, WhiteboxContext}
object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = x
+ def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
def refToFoo(dummy: Int) = macro refToFoo_impl
- def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = {
+ def refToFoo_impl(c: WhiteboxContext)(dummy: c.Expr[Int]) = {
import c.universe._
val body = Select(Ident(TermName("Impls")), TermName("foo"))
val global = c.universe.asInstanceOf[scala.tools.nsc.Global]
diff --git a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
index b589d4be03..cfcb59c17b 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.language.experimental.macros
object Macros {
def foo(x: Int) = macro Impls.refToFoo(42)
diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check
index c11c48dc55..795debded7 100644
--- a/test/files/run/macro-bundle-repl.check
+++ b/test/files/run/macro-bundle-repl.check
@@ -4,16 +4,16 @@ Type :help for more information.
scala> import scala.language.experimental.macros
import scala.language.experimental.macros
-scala> import scala.reflect.macros.Macro
-import scala.reflect.macros.Macro
+scala> import scala.reflect.macros.BlackboxMacro
+import scala.reflect.macros.BlackboxMacro
-scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
defined trait Bar
defined term macro bar: Unit
scala> bar
-scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
+scala> trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
defined trait Foo
scala> def foo = macro Foo.impl
diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala
index 3171aaacc2..50811cdb65 100644
--- a/test/files/run/macro-bundle-repl.scala
+++ b/test/files/run/macro-bundle-repl.scala
@@ -3,11 +3,11 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
import scala.language.experimental.macros
-import scala.reflect.macros.Macro
-trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+import scala.reflect.macros.BlackboxMacro
+trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
bar
-trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
+trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
def foo = macro Foo.impl
foo
"""
-} \ No newline at end of file
+}
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 e81fd0dbd6..b859411325 100644
--- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala
@@ -1,9 +1,8 @@
-import scala.reflect.macros.Context
-import scala.reflect.macros.Macro
+import scala.reflect.macros.BlackboxMacro
import scala.language.experimental.macros
object Enclosing {
- trait Impl extends Macro {
+ trait Impl extends BlackboxMacro {
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
@@ -17,7 +16,7 @@ object Macros {
package pkg {
object Enclosing {
- trait Impl extends Macro {
+ trait Impl extends BlackboxMacro {
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/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
index 8c7df2cdc5..e026768642 100644
--- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
@@ -1,7 +1,6 @@
-import scala.reflect.macros.Context
-import scala.reflect.macros.Macro
+import scala.reflect.macros.BlackboxMacro
-trait Impl extends Macro {
+trait Impl extends BlackboxMacro {
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
@@ -13,7 +12,7 @@ object Macros {
}
package pkg {
- trait Impl extends Macro {
+ trait Impl extends BlackboxMacro {
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-def-infer-return-type/Impls_1.scala b/test/files/run/macro-def-infer-return-type/Impls_1.scala
index f8636fe725..c670b1e57e 100644
--- a/test/files/run/macro-def-infer-return-type/Impls_1.scala
+++ b/test/files/run/macro-def-infer-return-type/Impls_1.scala
@@ -1,14 +1,14 @@
-import scala.reflect.macros.Context
+import scala.reflect.macros.BlackboxContext
object Impls1 {
- def foo(c: Context)(x: c.Expr[Int]) = x
+ def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
}
object Impls2 {
- def foo[T](c: Context)(x: c.Expr[T]) =
+ def foo[T](c: BlackboxContext)(x: c.Expr[T]) =
throw new Error("an implementation is missing")
}
object Impls3 {
- def foo[T](c: Context)(x: c.Expr[T]): c.Expr[T] = x
+ def foo[T](c: BlackboxContext)(x: c.Expr[T]): c.Expr[T] = x
}
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 06c15e16c9..f9aa13c334 100644
--- a/test/files/run/macro-def-path-dependent/Test_1.scala
+++ b/test/files/run/macro-def-path-dependent/Test_1.scala
@@ -1,6 +1,6 @@
package test1
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
trait Exprs {
self: Universe =>
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 f1e9909981..cdedaf2732 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.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
trait Exprs {
self: Universe =>
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 9f5efe5e47..6d856d1450 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.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
trait Exprs {
self: Universe =>
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 3af920d739..e8a8cf3909 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.Context
+import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Test {
def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T]
- def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
+ def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(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 bc32fb92de..22407b850c 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.Context
+import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Impls {
- def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
+ def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(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 6267743473..c8ddffc143 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.Context
+import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Macros {
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 53511ebc72..4bafa84128 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context): c.Expr[Complex[T]] = {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext): 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 7791df8fa4..ab852c9e46 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 68f1920cdd..dfffb48e73 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 b2c7b4d6ca..7ac30e3ff2 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.Context
+import scala.reflect.macros.BlackboxContext
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:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = {
+ def arrayMacro[A:c.WeakTypeTag](c:BlackboxContext)(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 ac1e55c9b2..c56489e61c 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
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 aa1fc7a358..f93d9100e8 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
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 fa717b2327..a8b478e9f2 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 aa1fc7a358..f93d9100e8 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
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 4fddc13d68..bc3d768a67 100644
--- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
+++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
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 5dfdd5c539..e0a048046f 100644
--- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl[T: c.WeakTypeTag](c: Ctx)(meth: String) = {
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 d23c671c84..5da33babd3 100644
--- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl(c: Ctx)(meth: String) = {
diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala
index 1c672f6040..ea68e9eb93 100644
--- a/test/files/run/macro-expand-overload/Impls_1.scala
+++ b/test/files/run/macro-expand-overload/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala
index 69ef57d18d..648641f578 100644
--- a/test/files/run/macro-expand-override/Impls_1.scala
+++ b/test/files/run/macro-expand-override/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala
index 47dd398454..8ba1a24540 100644
--- a/test/files/run/macro-expand-recursive/Impls_1.scala
+++ b/test/files/run/macro-expand-recursive/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
diff --git a/test/files/run/macro-expand-tparams-bounds.check b/test/files/run/macro-expand-tparams-bounds.check
new file mode 100644
index 0000000000..317e9677c3
--- /dev/null
+++ b/test/files/run/macro-expand-tparams-bounds.check
@@ -0,0 +1,2 @@
+hello
+hello
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 d63f034e9b..a255072774 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls1 {
- def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
+ def foo[U <: String](c: BlackboxContext): 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: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
+ def foo[U <: C](c: BlackboxContext): 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 f748ab855f..e95d61a36a 100644
--- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo[U: c.WeakTypeTag](c: Ctx) = {
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 c729aada51..37cf785c0d 100644
--- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = {
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 a98c4abe78..8f85ffff4a 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls1 {
- def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = {
+ def foo[U: c.WeakTypeTag](c: BlackboxContext)(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: Context)(x: c.Expr[U]) = {
+ def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext)(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: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
+ def foo[T, U: c.WeakTypeTag, V](c: BlackboxContext)(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 61d6345f16..7bfff374e2 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.Context
+import scala.reflect.macros.WhiteboxContext
object Helper {
def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x)
}
object Macros {
- def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = {
+ def impl[T: c.WeakTypeTag](c: WhiteboxContext)(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 f6c1d27d54..2480af61ad 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
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 363ff0e0aa..a31c92a01c 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
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 0b61ab2f9b..889240d628 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def myprintln(xs: Int*) = {
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 f6c1d27d54..2480af61ad 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
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 0b61ab2f9b..889240d628 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def myprintln(xs: Int*) = {
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 043675ec00..aa76a410ea 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,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
diff --git a/test/files/run/macro-impl-relaxed/Macros_1.scala b/test/files/run/macro-impl-relaxed/Macros_1.scala
index af62646b4e..3cf5090ec8 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- 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 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 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 5f3bbac719..c79fc30628 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = {
diff --git a/test/files/run/macro-impl-tparam-only-in-impl.check b/test/files/run/macro-impl-tparam-only-in-impl.check
new file mode 100644
index 0000000000..3b18e512db
--- /dev/null
+++ b/test/files/run/macro-impl-tparam-only-in-impl.check
@@ -0,0 +1 @@
+hello world
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 24eacb36de..55cf0dcafa 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.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
- def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
+ def foo[U <: String](c: Ctx): 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 ace7a6cd26..bcc746e39a 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo[U](c: Ctx) = {
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 b3babd8848..5a51d27b24 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx): c.Expr[Int] = {
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 869a5a41fa..44e508a1c6 100644
--- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
diff --git a/test/files/run/macro-invalidusage-badret.check b/test/files/run/macro-invalidusage-badret.check
index 9225b716d6..e79550043f 100644
--- a/test/files/run/macro-invalidusage-badret.check
+++ b/test/files/run/macro-invalidusage-badret.check
@@ -1,5 +1,5 @@
reflective compilation has failed:
type mismatch;
- found : Int(42)
+ found : Int
required: String
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 0d840eed3f..a54eaa4001 100644
--- a/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = x
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 8a93161af5..a67a296335 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = {
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 3ac9cd2a8d..88929df27a 100644
--- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala
index 884d7f8825..22e94f32cd 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context): c.Expr[Unit] = {
+ def impl(c: BlackboxContext): 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/Impls_Macros_1.scala b/test/files/run/macro-parse-position/Impls_Macros_1.scala
index b6f1ebbcd5..92f64a8e70 100644
--- a/test/files/run/macro-parse-position/Impls_Macros_1.scala
+++ b/test/files/run/macro-parse-position/Impls_Macros_1.scala
@@ -1,5 +1,5 @@
import scala.language.experimental.macros
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def impl(c: Ctx)() = {
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 6c14428437..04aa11b8fe 100644
--- a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala
+++ b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
object Impls {
diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala
index b64eec8743..c42baafdf4 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.Macro
+import scala.reflect.macros.BlackboxMacro
-trait Impls extends Macro {
+trait Impls extends BlackboxMacro {
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 4083e6126e..1ad2a6c6eb 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.Context
+import reflect.macros.BlackboxContext
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: Context
+ val context: BlackboxContext
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 ca0db48822..fa869a2569 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.Context
+import reflect.macros.BlackboxContext
object Impls {
- def foreach(c: Context)(f: c.Expr[Int => Unit]): c.Expr[Unit] = {
+ def foreach(c: BlackboxContext)(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 51e0264ed5..53b96691e9 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
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 4261a6d45d..81ad5cae0b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
diff --git a/test/files/run/macro-reify-basic/Macros_1.scala b/test/files/run/macro-reify-basic/Macros_1.scala
index 3f6720f10a..e1a6d8abfb 100644
--- a/test/files/run/macro-reify-basic/Macros_1.scala
+++ b/test/files/run/macro-reify-basic/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def foo(s: String) = macro Impls.foo
diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala
index 20f80c06d1..2cd94f600a 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.Context)
+ (c: scala.reflect.macros.BlackboxContext)
(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 bb6a45e11e..ebd80c02ba 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.Context
+import scala.reflect.macros.BlackboxContext
-case class Utils[C <: Context]( c:C ) {
+case class Utils[C <: BlackboxContext]( c:C ) {
import c.universe._
import c.{Tree=>_}
object removeDoubleReify extends c.universe.Transformer {
@@ -21,7 +21,7 @@ case class Utils[C <: Context]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ def _helper[C <: BlackboxContext,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.Context)
+ (c: scala.reflect.macros.BlackboxContext)
(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 bb6a45e11e..ebd80c02ba 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.Context
+import scala.reflect.macros.BlackboxContext
-case class Utils[C <: Context]( c:C ) {
+case class Utils[C <: BlackboxContext]( c:C ) {
import c.universe._
import c.{Tree=>_}
object removeDoubleReify extends c.universe.Transformer {
@@ -21,7 +21,7 @@ case class Utils[C <: Context]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ def _helper[C <: BlackboxContext,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.Context)
+ (c: scala.reflect.macros.BlackboxContext)
(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 f19fd239f9..bc0015774e 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
val `Answer to the Ultimate Question of Life, the Universe, and Everything` = 42
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 f454fc430a..d89a5e380d 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
diff --git a/test/files/run/macro-reify-splice-splice/Macros_1.scala b/test/files/run/macro-reify-splice-splice/Macros_1.scala
index efdd5dbaa2..691f22ad07 100644
--- a/test/files/run/macro-reify-splice-splice/Macros_1.scala
+++ b/test/files/run/macro-reify-splice-splice/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def foo = macro Impls.foo
diff --git a/test/files/run/macro-reify-staticXXX/Macros_1.scala b/test/files/run/macro-reify-staticXXX/Macros_1.scala
index f12c8f7dcc..077271d582 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.Context
+import scala.reflect.macros.BlackboxContext
object B { override def toString = "object" }
class C { override def toString = "class" }
@@ -14,7 +14,7 @@ object foo {
}
object packageless {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
import c.universe._
reify {
println(B)
@@ -31,7 +31,7 @@ object packageless {
package packageful {
object Test {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 f2512dcfaf..56d43c1c53 100644
--- a/test/files/run/macro-reify-tagful-a/Macros_1.scala
+++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.runtime.universe._
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def foo[T](s: T) = macro Impls.foo[T]
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 96cfb75852..27acaa1626 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def foo[T](s: T) = macro Impls.foo[T]
diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala
index c4d1d9f8ad..04634b649a 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.Context
+import scala.reflect.macros.BlackboxContext
import scala.reflect.runtime.{universe => ru}
object StaticReflect {
def method[A](name: String): ru.Type = macro methodImpl[A]
- def methodImpl[A: c.WeakTypeTag](c: Context)(name: c.Expr[String]): c.Expr[ru.Type] = {
+ def methodImpl[A: c.WeakTypeTag](c: BlackboxContext)(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 25ed352cca..d1e71b3311 100644
--- a/test/files/run/macro-reify-unreify/Macros_1.scala
+++ b/test/files/run/macro-reify-unreify/Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros {
def foo(s: String) = macro Impls.foo
diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check
index 46ea1f6405..cc974897f2 100644
--- a/test/files/run/macro-repl-basic.check
+++ b/test/files/run/macro-repl-basic.check
@@ -4,8 +4,8 @@ Type :help for more information.
scala> import language.experimental.macros
import language.experimental.macros
-scala> import scala.reflect.macros.{Context => Ctx}
-import scala.reflect.macros.{Context=>Ctx}
+scala> import scala.reflect.macros.{BlackboxContext => Ctx}
+import scala.reflect.macros.{BlackboxContext=>Ctx}
scala>
diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala
index 3c22c13dc7..dea36c481c 100644
--- a/test/files/run/macro-repl-basic.scala
+++ b/test/files/run/macro-repl-basic.scala
@@ -3,7 +3,7 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
|import language.experimental.macros
- |import scala.reflect.macros.{Context => Ctx}
+ |import scala.reflect.macros.{BlackboxContext => Ctx}
|
|object Impls {
| def foo(c: Ctx)(x: c.Expr[Int]) = {
diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check
index 9c35aad6b1..3ba877b59d 100644
--- a/test/files/run/macro-repl-dontexpand.check
+++ b/test/files/run/macro-repl-dontexpand.check
@@ -1,10 +1,16 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> def bar(c: scala.reflect.macros.Context) = ???
-bar: (c: scala.reflect.macros.Context)Nothing
+scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ???
+bar1: (c: scala.reflect.macros.BlackboxContext)Nothing
-scala> def foo = macro bar
-defined term macro foo: Any
+scala> def foo1 = macro bar1
+defined term macro foo1: Any
+
+scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
+bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing
+
+scala> def foo2 = macro bar2
+defined term macro foo2: Any
scala>
diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala
index f3422d88de..733288e513 100644
--- a/test/files/run/macro-repl-dontexpand.scala
+++ b/test/files/run/macro-repl-dontexpand.scala
@@ -3,7 +3,9 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-language:experimental.macros"
def code = """
- |def bar(c: scala.reflect.macros.Context) = ???
- |def foo = macro bar
+ |def bar1(c: scala.reflect.macros.BlackboxContext) = ???
+ |def foo1 = macro bar1
+ |def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
+ |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 9257784cf2..c9cecfa99f 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.Context
+import scala.reflect.macros.BlackboxContext
object Impls {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 1b914ac797..3acc52dbe0 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.Context
+import scala.reflect.macros.WhiteboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: WhiteboxContext) = {
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 95e19c4fd1..f830d2af0d 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.Context
+import scala.reflect.macros.WhiteboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: WhiteboxContext) = {
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-system-properties.check b/test/files/run/macro-system-properties.check
index c61fe7f2cf..b102d319ec 100644
--- a/test/files/run/macro-system-properties.check
+++ b/test/files/run/macro-system-properties.check
@@ -1,22 +1,28 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala> import language.experimental._, reflect.macros.Context
+scala> import language.experimental._, reflect.macros.BlackboxContext
import language.experimental._
-import reflect.macros.Context
+import reflect.macros.BlackboxContext
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: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
+ def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab() = macro impl
}
defined object GrabContext
scala> object Test { class C(implicit a: Any) { GrabContext.grab } }
+<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
+ object Test { class C(implicit a: Any) { GrabContext.grab } }
+ ^
defined object Test
scala> object Test { class C(implicit a: Any) { GrabContext.grab } }
+<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
+ object Test { class C(implicit a: Any) { GrabContext.grab } }
+ ^
defined object Test
scala>
diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala
index 9dcd044dbd..73a3ef5910 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.Context
+ import language.experimental._, reflect.macros.BlackboxContext
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: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
+ def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab() = 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 1ea06de679..df3509731b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 4380f40b04..4fae9b200f 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 4c009cc367..053af625a2 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def toOptionOfInt(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 348f3420f2..d69422872b 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,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
object Impls {
def foo(c: Ctx) = {
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 cd37c269b5..9f7d6f641c 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl_with_implicits_enabled(c: Context) = {
+ def impl_with_implicits_enabled(c: BlackboxContext) = {
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: Context) = {
+ def impl_with_implicits_disabled(c: BlackboxContext) = {
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 2532cfd2b9..41e58e0e4d 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl_with_macros_enabled(c: Context) = {
+ def impl_with_macros_enabled(c: BlackboxContext) = {
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: Context) = {
+ def impl_with_macros_disabled(c: BlackboxContext) = {
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 7b22793df9..3d12020109 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl_with_macros_enabled(c: Context) = {
+ def impl_with_macros_enabled(c: BlackboxContext) = {
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: Context) = {
+ def impl_with_macros_disabled(c: BlackboxContext) = {
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 6695a297ea..1af0579abc 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = {
+ def cons_impl[A: c.WeakTypeTag](c: BlackboxContext)(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: Context): c.Expr[List[B]] = {
+ def nil_impl[B: c.WeakTypeTag](c: BlackboxContext): 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 85877b3f13..f698320579 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext)(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 2d384fbb85..5907461c84 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.Context
+import scala.reflect.macros.WhiteboxContext
import scala.language.experimental.macros
class body(tree: Any) extends StaticAnnotation
object Macros {
- def selFieldImpl(c: Context) = {
+ def selFieldImpl(c: WhiteboxContext) = {
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: Context)(xs: c.Expr[Any]*) = {
+ def mkObjectImpl(c: WhiteboxContext)(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.check b/test/files/run/macro-whitebox-dynamic-materialization.check
new file mode 100644
index 0000000000..ccec8e5b25
--- /dev/null
+++ b/test/files/run/macro-whitebox-dynamic-materialization.check
@@ -0,0 +1,2 @@
+null
+C2
diff --git a/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala
new file mode 100644
index 0000000000..87cd310b09
--- /dev/null
+++ b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala
@@ -0,0 +1,25 @@
+import scala.reflect.macros.WhiteboxContext
+import scala.language.experimental.macros
+
+trait Foo[T]
+
+class C1(val x: Int)
+class C2(val x: String)
+
+trait LowPriority {
+ implicit def lessSpecific[T]: Foo[T] = null
+}
+
+object Foo extends LowPriority {
+ implicit def moreSpecific[T]: Foo[T] = macro Macros.impl[T]
+}
+
+object Macros {
+ def impl[T: c.WeakTypeTag](c: WhiteboxContext) = {
+ import c.universe._
+ val tpe = weakTypeOf[T]
+ if (tpe.members.exists(_.typeSignature =:= typeOf[Int]))
+ c.abort(c.enclosingPosition, "I don't like classes that contain integers")
+ q"new Foo[$tpe]{ override def toString = ${tpe.toString} }"
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-whitebox-dynamic-materialization/Test_2.scala b/test/files/run/macro-whitebox-dynamic-materialization/Test_2.scala
new file mode 100644
index 0000000000..bf19209ab7
--- /dev/null
+++ b/test/files/run/macro-whitebox-dynamic-materialization/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ println(implicitly[Foo[C1]])
+ println(implicitly[Foo[C2]])
+} \ No newline at end of file
diff --git a/test/files/run/macro-whitebox-extractor.check b/test/files/run/macro-whitebox-extractor.check
new file mode 100644
index 0000000000..d81cc0710e
--- /dev/null
+++ b/test/files/run/macro-whitebox-extractor.check
@@ -0,0 +1 @@
+42
diff --git a/test/files/run/macro-whitebox-extractor/Macros_1.scala b/test/files/run/macro-whitebox-extractor/Macros_1.scala
new file mode 100644
index 0000000000..4a1138fc9d
--- /dev/null
+++ b/test/files/run/macro-whitebox-extractor/Macros_1.scala
@@ -0,0 +1,21 @@
+import scala.reflect.macros.WhiteboxContext
+import language.experimental.macros
+
+object Extractor {
+ def unapply(x: Int) = macro Macros.unapplyImpl
+}
+
+object Macros {
+ def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ import c.universe._
+ q"""
+ new {
+ class Match(x: Int) {
+ def isEmpty = false
+ def get = x
+ }
+ def unapply(x: Int) = new Match(x)
+ }.unapply($x)
+ """
+ }
+}
diff --git a/test/files/run/macro-whitebox-extractor/Test_2.scala b/test/files/run/macro-whitebox-extractor/Test_2.scala
new file mode 100644
index 0000000000..41be6f9767
--- /dev/null
+++ b/test/files/run/macro-whitebox-extractor/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ 42 match {
+ case Extractor(x) => println(x)
+ }
+}
diff --git a/test/files/run/t5923c.check b/test/files/run/macro-whitebox-fundep-materialization.check
index bed7429108..bed7429108 100644
--- a/test/files/run/t5923c.check
+++ b/test/files/run/macro-whitebox-fundep-materialization.check
diff --git a/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala
new file mode 100644
index 0000000000..671a4fff4e
--- /dev/null
+++ b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala
@@ -0,0 +1,39 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.WhiteboxContext
+
+trait Iso[T, U] {
+ def to(t : T) : U
+ // def from(u : U) : T
+}
+
+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]] = {
+ import c.universe._
+ import definitions._
+ import Flag._
+
+ val sym = c.weakTypeOf[T].typeSymbol
+ if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class")
+ val fields = sym.typeSignature.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+
+ def mkTpt() = {
+ val core = Ident(TupleClass(fields.length) orElse UnitClass)
+ if (fields.length == 0) core
+ else AppliedTypeTree(core, fields map (f => TypeTree(f.typeSignature)))
+ }
+
+ def mkFrom() = {
+ if (fields.length == 0) Literal(Constant(Unit))
+ else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim))))
+ }
+
+ val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template(
+ List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))),
+ emptyValDef,
+ List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))),
+ DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom()))))
+ c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List())))
+ }
+}
diff --git a/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala
new file mode 100644
index 0000000000..a00f4ed7db
--- /dev/null
+++ b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala
@@ -0,0 +1,12 @@
+// see the comments for macroExpandApply.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)
+
+ {
+ val equiv = foo(Foo(23, "foo", true))
+ def typed[T](t: => T) {}
+ typed[(Int, String, Boolean)](equiv)
+ println(equiv)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-whitebox-structural.check b/test/files/run/macro-whitebox-structural.check
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/test/files/run/macro-whitebox-structural.check
@@ -0,0 +1 @@
+2
diff --git a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
new file mode 100644
index 0000000000..1b975ca850
--- /dev/null
+++ b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
@@ -0,0 +1,16 @@
+import scala.reflect.macros.WhiteboxContext
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: WhiteboxContext) = {
+ import c.universe._
+ q"""
+ trait Foo {
+ def x = 2
+ }
+ new Foo {}
+ """
+ }
+
+ def foo = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macro-whitebox-structural/Test_2.scala b/test/files/run/macro-whitebox-structural/Test_2.scala
new file mode 100644
index 0000000000..ea6a817e34
--- /dev/null
+++ b/test/files/run/macro-whitebox-structural/Test_2.scala
@@ -0,0 +1,5 @@
+import Macros._
+
+object Test extends App {
+ println(Macros.foo.x)
+} \ No newline at end of file
diff --git a/test/files/run/map_test.scala b/test/files/run/map_test.scala
index 1ea864ed58..b76dfb4577 100644
--- a/test/files/run/map_test.scala
+++ b/test/files/run/map_test.scala
@@ -20,7 +20,7 @@ object Test extends App {
val map2 = map1.updated(17,"A small random number")
val map3 = map2.updated(666,"A bigger random number")
val map4 = map3.updated(4711,"A big random number")
- map1 == myMap + Pair(42, "The answer")
+ map1 == myMap + ((42, "The answer"))
var i = 0
var map = map4
while(i < 43) {
diff --git a/test/files/run/mutable-anyrefmap.scala b/test/files/run/mutable-anyrefmap.scala
new file mode 100644
index 0000000000..ff615d0daf
--- /dev/null
+++ b/test/files/run/mutable-anyrefmap.scala
@@ -0,0 +1,91 @@
+object Test extends App {
+
+ import scala.collection.mutable.HashMap;
+ import scala.collection.mutable.AnyRefMap;
+
+ val keys = Array(
+ null, "perch", "herring", "salmon", "pike", "cod", ""
+ )
+
+ val rn = new scala.util.Random(42L)
+ var arm = AnyRefMap.empty[String, Int]
+ val hm = HashMap.empty[String, Int]
+
+ def checkConsistent = hm.forall{ case (k,v) => arm.get(k).exists(_ == v) }
+
+ assert {
+ (0 to 10000).forall{ i =>
+ val k = keys(rn.nextInt(keys.length))
+ if (rn.nextInt(100) < 2) arm = arm.clone()
+ if (rn.nextInt(100) < 5) arm.repack()
+ if (rn.nextBoolean) {
+ hm += ((k, i))
+ rn.nextInt(6) match {
+ case 0 => arm += ((k, i))
+ case 1 => arm += (k, i)
+ case 2 => arm(k) = i
+ case 3 => arm.put(k,i)
+ case 4 => arm ++= List((k,i))
+ case _ => if (!arm.contains(k)) arm.getOrElseUpdate(k,i)
+ else arm += (k,i)
+ }
+ }
+ else {
+ hm -= k
+ rn.nextInt(2) match {
+ case 0 => arm -= k
+ case _ => arm --= List(k)
+ }
+ }
+ checkConsistent
+ }
+ }
+
+ assert {
+ val mapped =
+ arm.map{ case (k,v) => (if (k==null) "" else k+k) -> v.toString }
+ mapped.getClass == arm.getClass
+ }
+
+ assert {
+ val arm2 = new AnyRefMap[java.lang.Integer,Unit](2000000)
+ for (i <- 0 until 1000000) arm2(java.lang.Integer.valueOf(i)) = ()
+
+ arm2.size == 1000000 &&
+ (0 to 1100000 by 100000).map(java.lang.Integer.valueOf).forall(i => (arm2 contains i) == i < 1000000)
+ }
+
+ arm = AnyRefMap("heron" -> 22, "dove" -> 5, "budgie" -> 0)
+
+ assert{
+ var s = ""
+ arm.foreachKey(s += _)
+
+ s.length == "herondovebudgie".length &&
+ s.contains("heron") &&
+ s.contains("dove") &&
+ s.contains("budgie")
+ }
+
+ assert{ var s = 0L; arm.foreachValue(s += _); s == 27L }
+
+ assert {
+ val m2 = arm.mapValuesNow(_+2)
+ arm.transformValues(_+2)
+ m2 == arm && !(m2 eq arm) && (for ((_,v) <- arm) yield v).sum == 33L
+ }
+
+ assert {
+ val arm2 = new AnyRefMap[String, String](x => if (x==null) "null" else x)
+ arm2 += ("cod" -> "fish", "Rarity" -> "unicorn")
+ val hm2 = (new HashMap[String,String]) ++= arm2
+
+ List(null, "cod", "sparrow", "Rarity").forall(i =>
+ arm2.get(i) == hm2.get(i) &&
+ arm2.getOrElse(i, "") == hm2.getOrElse(i, "") &&
+ arm2(i) == hm2.get(i).getOrElse(if (i==null) "null" else i.toString) &&
+ arm2.getOrNull(i) == hm2.get(i).orNull
+ )
+ }
+}
+
diff --git a/test/files/run/mutable-longmap.scala b/test/files/run/mutable-longmap.scala
new file mode 100644
index 0000000000..07fd80f6f0
--- /dev/null
+++ b/test/files/run/mutable-longmap.scala
@@ -0,0 +1,79 @@
+object Test extends App {
+
+ import scala.collection.mutable.HashMap;
+ import scala.collection.mutable.LongMap;
+
+ val keys = Array(
+ Long.MinValue, Int.MinValue - 1L, Int.MinValue, -9127, -1,
+ 0, 1, 9127, Int.MaxValue, Long.MaxValue
+ )
+
+ val rn = new scala.util.Random(42L)
+ var lm = LongMap.empty[Long]
+ val hm = HashMap.empty[Long,Long]
+
+ def checkConsistent = hm.forall{ case (k,v) => lm.get(k).exists(_ == v) }
+
+ assert {
+ (0 to 10000).forall{ i =>
+ val k = keys(rn.nextInt(keys.length))
+ if (rn.nextInt(100) < 2) lm = lm.clone()
+ if (rn.nextInt(100) < 5) lm.repack()
+ if (rn.nextBoolean) {
+ hm += ((k, i))
+ rn.nextInt(6) match {
+ case 0 => lm += ((k, i))
+ case 1 => lm += (k, i)
+ case 2 => lm(k) = i
+ case 3 => lm.put(k,i)
+ case 4 => lm ++= List((k,i))
+ case _ => if (!lm.contains(k)) lm.getOrElseUpdate(k,i)
+ else lm += (k,i)
+ }
+ }
+ else {
+ hm -= k
+ rn.nextInt(2) match {
+ case 0 => lm -= k
+ case _ => lm --= List(k)
+ }
+ }
+ checkConsistent
+ }
+ }
+
+ assert {
+ lm.map{ case (k,v) => -k*k -> v.toString }.getClass == lm.getClass
+ }
+
+ assert {
+ val lm2 = new LongMap[Unit](2000000)
+ for (i <- 0 until 1000000) lm2(i) = ()
+
+ lm2.size == 1000000 &&
+ (0 to 1100000 by 100000).forall(i => (lm2 contains i) == i < 1000000)
+ }
+
+ lm = LongMap(8L -> 22L, -5L -> 5L, Long.MinValue -> 0L)
+
+ assert{ var s = 0L; lm.foreachKey(s += _); s == Long.MinValue + 3 }
+ assert{ var s = 0L; lm.foreachValue(s += _); s == 27L }
+ assert {
+ val m2 = lm.mapValuesNow(_+2)
+ lm.transformValues(_+2)
+ m2 == lm && !(m2 eq lm) && (for ((_,v) <- lm) yield v).sum == 33L
+ }
+
+ assert {
+ val lm2 = new LongMap[String](_.toString)
+ lm2 += (5L -> "fish", 0L -> "unicorn")
+ val hm2 = (new HashMap[Long,String]) ++= lm2
+
+ List(Long.MinValue, 0L, 1L, 5L).forall(i =>
+ lm2.get(i) == hm2.get(i) &&
+ lm2.getOrElse(i, "") == hm2.getOrElse(i, "") &&
+ lm2(i) == hm2.get(i).getOrElse(i.toString) &&
+ lm2.getOrNull(i) == hm2.get(i).orNull
+ )
+ }
+}
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index b212e10f8d..3c0d00dc6c 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -46,7 +46,7 @@ object Test {
object SimpleUnapply {
def run() { // from sortedmap, old version
List((1, 2)).head match {
- case kv@Pair(key, _) => kv.toString + " " + key.toString
+ case kv@(key, _) => kv.toString + " " + key.toString
}
}
@@ -400,9 +400,9 @@ object Test {
// these are exhaustive matches
// should not generate any warnings
def f[A](z: (Option[A], Option[A])) = z match {
- case Pair(None, Some(x)) => 1
- case Pair(Some(x), None) => 2
- case Pair(Some(x), Some(y)) => 3
+ case (None, Some(x)) => 1
+ case (Some(x), None) => 2
+ case (Some(x), Some(y)) => 3
case _ => 4
}
@@ -419,9 +419,9 @@ object Test {
}
def h[A](x: (Option[A], Option[A])) = x match {
- case Pair(None, _: Some[_]) => 1
- case Pair(_: Some[_], None) => 2
- case Pair(_: Some[_], _: Some[_]) => 3
+ case (None, _: Some[_]) => 1
+ case (_: Some[_], None) => 2
+ case (_: Some[_], _: Some[_]) => 3
case _ => 4
}
@@ -539,17 +539,17 @@ object Test {
case class Operator(x: Int);
val EQ = new Operator(2);
- def analyze(x: Pair[Operator, Int]) = x match {
- case Pair(EQ, 0) => "0"
- case Pair(EQ, 1) => "1"
- case Pair(EQ, 2) => "2"
+ def analyze(x: Tuple2[Operator, Int]) = x match {
+ case (EQ, 0) => "0"
+ case (EQ, 1) => "1"
+ case (EQ, 2) => "2"
}
def run() {
- val x = Pair(EQ, 0);
+ val x = (EQ, 0);
assertEquals("0", analyze(x)); // should print "0"
- val y = Pair(EQ, 1);
+ val y = (EQ, 1);
assertEquals("1", analyze(y)); // should print "1"
- val z = Pair(EQ, 2);
+ val z = (EQ, 2);
assertEquals("2", analyze(z)); // should print "2"
}
}
diff --git a/test/files/run/reflection-sync-subtypes.check b/test/files/run/reflection-sync-subtypes.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/run/reflection-sync-subtypes.check
diff --git a/test/disabled/run/reflection-sync-subtypes.scala b/test/files/run/reflection-sync-subtypes.scala
index 7f75a464ac..7f75a464ac 100644
--- a/test/disabled/run/reflection-sync-subtypes.scala
+++ b/test/files/run/reflection-sync-subtypes.scala
diff --git a/test/files/run/repl-backticks.check b/test/files/run/repl-backticks.check
new file mode 100644
index 0000000000..c0561abd7c
--- /dev/null
+++ b/test/files/run/repl-backticks.check
@@ -0,0 +1,2 @@
+import java.lang.Thread.`yield`
+import scala.`package`.Throwable
diff --git a/test/files/run/repl-backticks.scala b/test/files/run/repl-backticks.scala
new file mode 100644
index 0000000000..e40a8bc662
--- /dev/null
+++ b/test/files/run/repl-backticks.scala
@@ -0,0 +1,18 @@
+import scala.tools.nsc._
+
+object Test {
+ val testCode = """
+ import java.lang.Thread.`yield`
+ import scala.`package`.Throwable
+
+ `yield`
+ """
+
+ def main(args: Array[String]) {
+ val settings = new Settings()
+ settings.classpath.value = System.getProperty("java.class.path")
+ val repl = new interpreter.IMain(settings)
+ repl.interpret(testCode)
+ }
+}
+
diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check
index 63bafe401b..64c46392a3 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.Context
-import scala.reflect.macros.Context
+scala> import scala.reflect.macros.BlackboxContext
+import scala.reflect.macros.BlackboxContext
scala> import language.experimental.macros
import language.experimental.macros
scala>
-scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
-impl1: (c: scala.reflect.macros.Context)c.Expr[Unit]
+scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
+impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit]
scala> def foo1 = macro impl1
defined term macro foo1: Unit
@@ -19,8 +19,8 @@ scala> foo1
scala>
-scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
-impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit]
+scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
+impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit]
scala> def foo2() = macro impl2
defined term macro foo2: ()Unit
@@ -29,8 +29,8 @@ scala> foo2()
scala>
-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.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
+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 foo3(x: Int)(y: Int) = 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 125e397b22..a779638c00 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.Context
+ import scala.reflect.macros.BlackboxContext
import language.experimental.macros
-def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
def foo1 = macro impl1
foo1
-def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
+def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
def foo2() = macro impl2
foo2()
-def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
+def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
def foo3(x: Int)(y: Int) = macro impl3
foo3(2)(3)
"""
diff --git a/test/files/run/t1500.check b/test/files/run/t1500.check
new file mode 100644
index 0000000000..94a169333b
--- /dev/null
+++ b/test/files/run/t1500.check
@@ -0,0 +1,3 @@
+defined class posingAs
+resolve: [A, B](x: A @posingAs[B])B
+x: Any = 7
diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala
new file mode 100644
index 0000000000..30c026f70f
--- /dev/null
+++ b/test/files/run/t1500.scala
@@ -0,0 +1,46 @@
+import scala.tools.nsc._
+
+object Test {
+
+ /**
+ * Type inference overlooks constraints posed by type parameters in annotations on types.
+ */
+
+ val testCode = """
+
+ class posingAs[A] extends annotation.TypeConstraint
+
+ def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B]
+
+ val x = resolve(7: @posingAs[Any])
+
+ """
+
+ def main(args: Array[String]) {
+
+ val settings = new Settings()
+ settings.classpath.value = System.getProperty("java.class.path")
+ val tool = new interpreter.IMain(settings)
+ val global = tool.global
+
+ import global._
+ import definitions._
+
+ object checker extends AnnotationChecker {
+
+ /** Check annotations to decide whether tpe1 <:< tpe2 */
+ def annotationsConform(tpe1: Type, tpe2: Type): Boolean = {
+
+ tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp))
+
+ }
+ }
+
+ global.addAnnotationChecker(checker)
+
+ tool.interpret(testCode)
+
+ }
+
+}
+
diff --git a/test/files/run/t1501.check b/test/files/run/t1501.check
new file mode 100644
index 0000000000..f0fa9112a5
--- /dev/null
+++ b/test/files/run/t1501.check
@@ -0,0 +1,3 @@
+defined class xyz
+loopWhile: [T](cond: => Boolean)(body: => Unit @xyz[T])Unit @xyz[T]
+test: ()Unit @xyz[Int]
diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala
new file mode 100644
index 0000000000..ca6bf357fb
--- /dev/null
+++ b/test/files/run/t1501.scala
@@ -0,0 +1,56 @@
+import scala.tools.nsc._
+
+object Test {
+
+ /**
+ * ...
+ */
+
+ val testCode = """
+
+ class xyz[A] extends annotation.TypeConstraint
+
+ def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{
+ if (cond) {{
+ body
+ loopWhile[T](cond)(body)
+ }}
+ }}
+
+ def test() = {{
+ var x = 7
+ loopWhile(x != 0) {{
+ x = x - 1
+ (): @xyz[Int]
+ }}
+ }}
+
+ """
+
+ def main(args: Array[String]) {
+ val settings = new Settings()
+ settings.classpath.value = System.getProperty("java.class.path")
+ val tool = new interpreter.IMain(settings)
+ val global = tool.global
+
+ import global._
+ import definitions._
+
+ object checker extends AnnotationChecker {
+
+ /** Check annotations to decide whether tpe1 <:< tpe2 */
+ def annotationsConform(tpe1: Type, tpe2: Type): Boolean = {
+
+ tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp))
+
+ }
+ }
+
+ global.addAnnotationChecker(checker)
+
+ tool.interpret(testCode)
+
+ }
+
+}
+
diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala
index 19771041fc..8701b42ff0 100644
--- a/test/files/run/t3888.scala
+++ b/test/files/run/t3888.scala
@@ -24,6 +24,6 @@ object Test {
}
}
-class P extends Pair(1, 1) {
+class P extends Tuple2(1, 1) {
override def equals(x: Any) = true
}
diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check
new file mode 100644
index 0000000000..66a0092d93
--- /dev/null
+++ b/test/files/run/t4124.check
@@ -0,0 +1,4 @@
+hi
+hi
+bye
+bye
diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala
new file mode 100644
index 0000000000..9f35b57ce3
--- /dev/null
+++ b/test/files/run/t4124.scala
@@ -0,0 +1,24 @@
+import xml.Node
+
+object Test extends App {
+ val body: Node = <elem>hi</elem>
+ println ((body: AnyRef, "foo") match {
+ case (node: Node, "bar") => "bye"
+ case (ser: Serializable, "foo") => "hi"
+ })
+
+ println ((body, "foo") match {
+ case (node: Node, "bar") => "bye"
+ case (ser: Serializable, "foo") => "hi"
+ })
+
+ println ((body: AnyRef, "foo") match {
+ case (node: Node, "foo") => "bye"
+ case (ser: Serializable, "foo") => "hi"
+ })
+
+ println ((body: AnyRef, "foo") match {
+ case (node: Node, "foo") => "bye"
+ case (ser: Serializable, "foo") => "hi"
+ })
+}
diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala
index 12c3da2ff0..bfe2fc4efd 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.Context
+import scala.reflect.macros.BlackboxContext
object Level extends Enumeration {
val Error = Value(5)
@@ -13,7 +13,7 @@ object Logger {
private object LoggerMacros {
- type LoggerContext = Context { type PrefixType = Logger.type }
+ type LoggerContext = BlackboxContext { 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 1664301f5f..3ddff56c38 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
trait Impls {
- def impl(c: Context)(x: c.Expr[Any]) = x
+ def impl(c: BlackboxContext)(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 41d584d0ac..c95c9a41b3 100644
--- a/test/files/run/t5753_2/Impls_Macros_1.scala
+++ b/test/files/run/t5753_2/Impls_Macros_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.macros.{Context => Ctx}
+import scala.reflect.macros.{BlackboxContext => Ctx}
trait Macro_T {
def foo[T](c: Ctx)(s: c.Expr[T]) = s
diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala
index 5deda34489..55767d8889 100644
--- a/test/files/run/t5894.scala
+++ b/test/files/run/t5894.scala
@@ -4,7 +4,7 @@ class Test
object Test {
def foo = macro fooImpl
- def fooImpl(c: reflect.macros.Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def fooImpl(c: reflect.macros.BlackboxContext) = { 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 e82be0fc68..7888b888e1 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
trait Tree
@@ -13,7 +13,7 @@ object NewQuasiquotes {
}
object QuasiquoteMacros {
- def unapplyImpl(c: Context)(t: c.Tree) = {
+ def unapplyImpl(c: WhiteboxContext)(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 c0124850b8..8c03e5579d 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: WhiteboxContext)(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 f8baa2275b..c9dfe9d60c 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = {
+ def unapplyImpl[T: c.WeakTypeTag](c: WhiteboxContext)(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 88d714e17b..8a57e27602 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Interpolation {
@@ -10,7 +10,7 @@ object Interpolation {
}
object Macros {
- def unapplyImpl(c: Context)(x: c.Tree) = {
+ def unapplyImpl(c: WhiteboxContext)(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 741379cf34..445392ff95 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.Context
+import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
case class C[T](t: String)
@@ -7,7 +7,7 @@ object C {
}
object Macros {
- def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = {
+ def impl[T](c: WhiteboxContext)(ttag: c.WeakTypeTag[T]) = {
import c.universe._
val ttag0 = ttag;
{
diff --git a/test/files/run/t5923c.scala b/test/files/run/t5923c.scala
new file mode 100644
index 0000000000..956b256785
--- /dev/null
+++ b/test/files/run/t5923c.scala
@@ -0,0 +1,4 @@
+// see neg/macro-blackbox-fundep-materialization and run/macro-whitebox-fundep-materialization
+object Test extends App {
+ // do nothing
+} \ No newline at end of file
diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala
index f32d1af704..b6e7134b95 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context) = c.universe.reify(new RowMapper[T]{})
+ def impl[T <: MappedRow : c.WeakTypeTag](c: BlackboxContext) = 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 9c8f702c68..d98f267123 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.Context
+ import scala.reflect.macros.BlackboxContext
object Impls {
- def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
}
object Macros {
//import Impls._
- def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
+ def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
def foo = macro impl
}
"""
diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check
index 621306b2ef..c833b45443 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.Context
+scala> import language.experimental.macros, reflect.macros.BlackboxContext
import language.experimental.macros
-import reflect.macros.Context
+import reflect.macros.BlackboxContext
-scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
+scala> def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(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.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]]
+macroImpl: [T](c: scala.reflect.macros.BlackboxContext)(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 ae642917e7..fc6fa6e9a7 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.Context
-def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
+import language.experimental.macros, reflect.macros.BlackboxContext
+def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(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 c9500626d8..60ed0aa3e3 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = {
+ def reflectiveClosureImpl[A, B](c: BlackboxContext)(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/t6329_repl_bug.check b/test/files/run/t6329_repl_bug.check
new file mode 100644
index 0000000000..44c41cfd03
--- /dev/null
+++ b/test/files/run/t6329_repl_bug.check
@@ -0,0 +1,17 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.reflect.runtime._
+import scala.reflect.runtime._
+
+scala> classManifest[List[_]]
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
+res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>]
+
+scala> scala.reflect.classTag[List[_]]
+res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List
+
+scala>
diff --git a/test/files/run/t6329_repl_bug.pending b/test/files/run/t6329_repl_bug.scala
index 9997d1771e..9997d1771e 100644
--- a/test/files/run/t6329_repl_bug.pending
+++ b/test/files/run/t6329_repl_bug.scala
diff --git a/test/files/run/t6329_vanilla_bug.check b/test/files/run/t6329_vanilla_bug.check
new file mode 100644
index 0000000000..640d168a8a
--- /dev/null
+++ b/test/files/run/t6329_vanilla_bug.check
@@ -0,0 +1,3 @@
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
+scala.collection.immutable.List[<?>]
+scala.collection.immutable.List
diff --git a/test/files/run/t6329_vanilla_bug.pending b/test/files/run/t6329_vanilla_bug.scala
index 404f90bf6e..404f90bf6e 100644
--- a/test/files/run/t6329_vanilla_bug.pending
+++ b/test/files/run/t6329_vanilla_bug.scala
diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check
index c9d4713aa8..dfc9d44850 100644
--- a/test/files/run/t6381.check
+++ b/test/files/run/t6381.check
@@ -4,11 +4,11 @@ Type :help for more information.
scala> import language.experimental.macros
import language.experimental.macros
-scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = {
+scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = {
import c.universe._
c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString)))
}
-pos_impl: (c: scala.reflect.macros.Context)c.Expr[String]
+pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String]
scala> def pos = macro pos_impl
defined term macro pos: String
diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala
index 4c2a40fe87..0e2264d8fa 100644
--- a/test/files/run/t6381.scala
+++ b/test/files/run/t6381.scala
@@ -3,7 +3,7 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
|import language.experimental.macros
- |def pos_impl(c: reflect.macros.Context): c.Expr[String] = {
+ |def pos_impl(c: reflect.macros.BlackboxContext): 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 5aa07e7f41..b934b5ebb1 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c:Context): c.Expr[Any] = {
+ def impl(c:BlackboxContext): 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 5d93e1cda8..01fbc4f09e 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c:Context): c.Expr[Any] = {
+ def impl(c:BlackboxContext): c.Expr[Any] = {
import c.universe._
val selfTree = This(tpnme.EMPTY)
diff --git a/test/files/run/t6546.flags b/test/files/run/t6546.flags
new file mode 100644
index 0000000000..eb4d19bcb9
--- /dev/null
+++ b/test/files/run/t6546.flags
@@ -0,0 +1 @@
+-optimise \ No newline at end of file
diff --git a/test/files/run/t6546/A_1.scala b/test/files/run/t6546/A_1.scala
new file mode 100644
index 0000000000..bd086c08f8
--- /dev/null
+++ b/test/files/run/t6546/A_1.scala
@@ -0,0 +1,6 @@
+final class Opt {
+ @inline def getOrElse(x: => String): String = ""
+}
+class A_1 {
+ def f(x: Opt): String = x getOrElse null
+}
diff --git a/test/files/run/t6546/B_2.scala b/test/files/run/t6546/B_2.scala
new file mode 100644
index 0000000000..64ec966f75
--- /dev/null
+++ b/test/files/run/t6546/B_2.scala
@@ -0,0 +1,8 @@
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val node = loadClassNode("A_1")
+ assert(node.innerClasses.isEmpty, node.innerClasses)
+ }
+}
diff --git a/test/files/run/t6662/Macro_1.scala b/test/files/run/t6662/Macro_1.scala
index f373eaaf94..cecf242f66 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.Context
+import scala.reflect.macros.BlackboxContext
object Demo {
def id[T](a: T): T = macro idImpl[T]
- def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a
+ def idImpl[T: c.WeakTypeTag](c: BlackboxContext)(a: c.Expr[T]): c.Expr[T] = a
}
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 477829f200..0ce5daf0d0 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 63c3f9d696..6da9dca913 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 a5d55c3a42..0d64729791 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
class Foo
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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 ad3d96eb85..e48fbcaed3 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
object AImpl {
- def a(ctx: Context)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = {
+ def a(ctx: BlackboxContext)(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 6465e18760..84ad231043 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.Context
+import scala.reflect.macros.BlackboxContext
trait FailureCake {
implicit def liftAnyFails[T: Manifest]: Any = ???
@@ -13,7 +13,7 @@ trait FailureCake {
object Bakery {
def failure: Any = macro failureImpl
- def failureImpl(c: Context): c.Expr[Any] = {
+ def failureImpl(c: BlackboxContext): c.Expr[Any] = {
import c.universe._
def dslTrait(dslName: String) = {
diff --git a/test/files/run/t7375b/Macros_1.scala b/test/files/run/t7375b/Macros_1.scala
index 7a307805db..bcd8e52172 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.Context
+import scala.reflect.macros.BlackboxContext
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: Context) = {
+ def impl(c: BlackboxContext) = {
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 f9772c83c0..d19f112bf4 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def getValueImpl[T](c: Context): c.Expr[T] = {
+ def getValueImpl[T](c: BlackboxContext): c.Expr[T] = {
import c.universe._
c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil))
}
- def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = {
+ def setValueImpl[T](c: BlackboxContext)(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 bc919935c9..b1406f30bb 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.Context
+import scala.reflect.macros.BlackboxContext
object Macros {
- def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = {
+ def impl(c: BlackboxContext)(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 b1e31aa2dd..9aac02031d 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
trait T { def t(): Unit }
abstract class A extends T { override def t(): Unit = () }
-object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
+object Macro { def t(c: BlackboxContext)(): c.Expr[Unit] = c.universe.reify(()) }
class C extends A { override def t(): Unit = macro Macro.t }
diff --git a/test/files/run/t7985.scala b/test/files/run/t7985.scala
new file mode 100644
index 0000000000..5fe270f9c0
--- /dev/null
+++ b/test/files/run/t7985.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ Array(1) match { case _: Array[scala.Int] => }
+}
diff --git a/test/files/run/t7985b.scala b/test/files/run/t7985b.scala
new file mode 100644
index 0000000000..aaf649eb28
--- /dev/null
+++ b/test/files/run/t7985b.scala
@@ -0,0 +1,5 @@
+class a { type X = Int }
+
+object Test extends App {
+ Array(1) match { case _: Array[a#X] => }
+}
diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala
index e5d8891cc7..1653b14de9 100644
--- a/test/files/run/tailcalls.scala
+++ b/test/files/run/tailcalls.scala
@@ -169,7 +169,7 @@ class TailCall[S](s: S) {
aux[T](x, y);
}
final def g3[T](x: Int, y: Int, zs: List[T]): Int = {
- def aux[U](n: Int, v: Int, ls: List[Pair[T,U]]): Int =
+ def aux[U](n: Int, v: Int, ls: List[Tuple2[T,U]]): Int =
if (n == 0) v else aux(n - 1, v - 1, ls);
aux(x, y, Nil);
}
diff --git a/test/files/run/tcpoly_parseridioms.check b/test/files/run/tcpoly_parseridioms.check
index ab829e0a0e..8bd0a086d6 100644
--- a/test/files/run/tcpoly_parseridioms.check
+++ b/test/files/run/tcpoly_parseridioms.check
@@ -4,8 +4,8 @@ It would fail on the following input: ParseResult()
^
tcpoly_parseridioms.scala:17: warning: match may not be exhaustive.
It would fail on the following input: ParseResult()
- def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match {
- ^
+ def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match {
+ ^
tcpoly_parseridioms.scala:30: warning: match may not be exhaustive.
It would fail on the following input: ParseResult()
case Failure(_, _) => b(in) match {
diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala
index c8bcf693a1..d22f68b558 100644
--- a/test/files/run/tcpoly_parseridioms.scala
+++ b/test/files/run/tcpoly_parseridioms.scala
@@ -13,10 +13,10 @@ trait Parsers {
}
// sequence
- def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Pair[T, U]] = new Parser[Pair[T, U]] {
- def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match {
+ def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Tuple2[T, U]] = new Parser[Tuple2[T, U]] {
+ def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match {
case Success(next, x) => b(next) match {
- case Success(next2, y) => Success(next2, Pair(x,y))
+ case Success(next2, y) => Success(next2, (x,y))
case Failure(_, msg) => Failure(in, msg)
}
case Failure(_, msg) => Failure(in, msg)
@@ -49,7 +49,7 @@ trait Parsers {
}
}
- def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg))
+ def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Tuple2[s=>tt, s], tt]({case (f, a) => f(a)})(sq(fun, arg))
def success[u](v: u): Parser[u] = new Parser[u] {
def apply(in: Input) = Success(in, v)
diff --git a/test/files/run/toolbox_current_run_compiles.scala b/test/files/run/toolbox_current_run_compiles.scala
index b48c998e64..bc6a9d343e 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.Context
+ import scala.reflect.macros.BlackboxContext
import scala.language.experimental.macros
object Macros {
- def impl[T: c.WeakTypeTag](c: Context) = {
+ def impl[T: c.WeakTypeTag](c: BlackboxContext) = {
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 dd18c63d90..42478cb988 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.Context
+import scala.reflect.macros.BlackboxContext
import language.experimental.macros
class ann extends scala.annotation.StaticAnnotation
object Macros {
- def impl(c: Context) = {
+ def impl(c: BlackboxContext) = {
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/run/value-class-partial-func-depmet.scala b/test/files/run/value-class-partial-func-depmet.scala
new file mode 100644
index 0000000000..12ff64ed36
--- /dev/null
+++ b/test/files/run/value-class-partial-func-depmet.scala
@@ -0,0 +1,24 @@
+class C
+class A { class C }
+
+object Test {
+ def main(args: Array[String]) {
+ val a = new A
+
+ new VC("").foo(a)
+ }
+}
+
+class VC(val a: Any) extends AnyVal {
+ def foo(a: A) = {
+ val pf: PartialFunction[a.C, Any] = { case x => x }
+ (pf: PartialFunction[Null, Any]).isDefinedAt(null)
+ }
+}
+
+// 2.11.0-M6
+// test/files/run/value-class-partial-func-depmet.scala:14: error: overriding method applyOrElse in trait PartialFunction of type [A1 <: a.C, B1 >: Any](x: A1, default: A1 => B1)B1;
+// method applyOrElse has incompatible type
+// val pf: PartialFunction[a.C, Any] = { case x => x }
+// ^
+// one error found
diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala
index 910b1f1f9e..ebf1941c95 100644
--- a/test/files/run/withIndex.scala
+++ b/test/files/run/withIndex.scala
@@ -11,7 +11,7 @@ object Test {
Console.println(str.zipWithIndex.toList)
assert {
ary.zipWithIndex match {
- case _: Array[Pair[_,_]] => true
+ case _: Array[Tuple2[_,_]] => true
case _ => false
}
}
diff --git a/test/files/scalacheck/CheckCollections.scala b/test/files/scalacheck/CheckCollections.scala
index 108040b900..329d505b47 100644
--- a/test/files/scalacheck/CheckCollections.scala
+++ b/test/files/scalacheck/CheckCollections.scala
@@ -1,4 +1,4 @@
-import org.scalacheck.{ ConsoleReporter, Properties }
+import org.scalacheck.Properties
import org.scalacheck.Prop._
import scala.reflect.internal.util.Collections._
@@ -49,11 +49,4 @@ object Test extends Properties("reflect.internal.util.Collections") {
for {
(label, prop) <- tests
} property(label) = prop
-
- import org.scalacheck.{ Test => STest }
-
- def runTests() =
- STest.checkProperties(
- STest.Params(testCallback = ConsoleReporter(0)), this)
-
}
diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala
index 4d0cab4693..48f732a22d 100644
--- a/test/files/scalacheck/CheckEither.scala
+++ b/test/files/scalacheck/CheckEither.scala
@@ -1,10 +1,8 @@
-import org.scalacheck.{ Arbitrary, ConsoleReporter, Prop, Properties }
+import org.scalacheck.{ Arbitrary, Prop, Properties }
import org.scalacheck.Arbitrary.{arbitrary, arbThrowable}
import org.scalacheck.Gen.oneOf
-import org.scalacheck.util.StdRand
import org.scalacheck.Prop._
-import org.scalacheck.Test.{Params, check}
-import org.scalacheck.ConsoleReporter.testStatsEx
+import org.scalacheck.Test.check
import Function.tupled
object Test extends Properties("Either") {
@@ -178,10 +176,4 @@ object Test extends Properties("Either") {
for ((label, prop) <- tests) {
property(label) = prop
}
-
- import org.scalacheck.{ Test => STest }
-
- def runTests() = {
- STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this)
- }
}
diff --git a/test/files/scalacheck/array-new.scala b/test/files/scalacheck/array-new.scala
index e13a47a5d5..d8c69ead78 100644
--- a/test/files/scalacheck/array-new.scala
+++ b/test/files/scalacheck/array-new.scala
@@ -1,4 +1,4 @@
-import scala.reflect.{ClassTag, classTag}
+import scala.reflect.ClassTag // new style: use ClassTag
import org.scalacheck._
import Prop._
import Gen._
diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
index 4118d92076..7905a2ca15 100644
--- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
+++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
@@ -1,11 +1,6 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.api._
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe.Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.api.{Liftable, Universe}
+import scala.reflect.runtime.universe._, Flag._
trait ArbitraryTreesAndNames {
def smallList[T](size: Int, g: Gen[T]) = {
@@ -227,7 +222,7 @@ trait ArbitraryTreesAndNames {
yield ValDef(mods, name, tpt, rhs)
def genTree(size: Int): Gen[Tree] =
- if (size <= 1) oneOf(EmptyTree, genTreeIsTerm(size), genTreeIsType(size))
+ if (size <= 1) oneOf(EmptyTree: Gen[Tree], genTreeIsTerm(size), genTreeIsType(size))
else oneOf(genTree(1),
// these trees are neither terms nor types
genPackageDef(size - 1), genModuleDef(size - 1),
@@ -278,8 +273,8 @@ trait ArbitraryTreesAndNames {
def apply(universe: Universe, value: TreeIsType): universe.Tree =
value.tree.asInstanceOf[universe.Tree]
}
- implicit def treeIsTerm2tree(tit: TreeIsTerm) = tit.tree
- implicit def treeIsType2tree(tit: TreeIsType) = tit.tree
+ implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree
+ implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree
implicit val arbConstant: Arbitrary[Constant] = Arbitrary(genConstant)
implicit val arbModifiers: Arbitrary[Modifiers] = Arbitrary(genModifiers)
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
index e8ddb4b72a..2ec679e78b 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
@@ -1,11 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe.build.ScalaDot
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._, build.ScalaDot
object DefinitionConstructionProps
extends QuasiquoteProperties("definition construction")
diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
index 993ef899b0..dbd26bf72a 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object DefinitionDeconstructionProps
extends QuasiquoteProperties("definition deconstruction")
diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala
index b0a7641577..cb46a60dbe 100644
--- a/test/files/scalacheck/quasiquotes/ErrorProps.scala
+++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala
@@ -1,10 +1,4 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
object ErrorProps extends QuasiquoteProperties("errors") {
property("can't extract two .. cardinalities in a row") = fails(
diff --git a/test/files/scalacheck/quasiquotes/ForProps.scala b/test/files/scalacheck/quasiquotes/ForProps.scala
new file mode 100644
index 0000000000..e71822aaea
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/ForProps.scala
@@ -0,0 +1,70 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._, build.{Ident => _, _}
+
+object ForProps extends QuasiquoteProperties("for") {
+ case class ForEnums(val value: List[Tree])
+
+ def genSimpleBind: Gen[Bind] =
+ for(name <- genTermName)
+ yield pq"$name @ _"
+
+ def genForFilter: Gen[Tree] =
+ for(cond <- genIdent(genTermName))
+ yield fq"if $cond"
+
+ def genForFrom: Gen[Tree] =
+ for(lhs <- genSimpleBind; rhs <- genIdent(genTermName))
+ yield fq"$lhs <- $rhs"
+
+ def genForEq: Gen[Tree] =
+ for(lhs <- genSimpleBind; rhs <- genIdent(genTermName))
+ yield fq"$lhs = $rhs"
+
+ def genForEnums(size: Int): Gen[ForEnums] =
+ for(first <- genForFrom; rest <- listOfN(size, oneOf(genForFrom, genForFilter, genForEq)))
+ yield new ForEnums(first :: rest)
+
+ implicit val arbForEnums: Arbitrary[ForEnums] = arbitrarySized(genForEnums)
+
+ property("construct-reconstruct for") = forAll { (enums: ForEnums, body: Tree) =>
+ val SyntacticFor(recoveredEnums, recoveredBody) = SyntacticFor(enums.value, body)
+ recoveredEnums ≈ enums.value && recoveredBody ≈ body
+ }
+
+ property("construct-reconstruct for-yield") = forAll { (enums: ForEnums, body: Tree) =>
+ val SyntacticForYield(recoveredEnums, recoveredBody) = SyntacticForYield(enums.value, body)
+ recoveredEnums ≈ enums.value && recoveredBody ≈ body
+ }
+
+ val abcde = List(fq"a <-b", fq"if c", fq"d = e")
+ val foobarbaz = pq"foo @ Bar(baz)"
+ val fv = q"f(v)"
+
+ property("construct/deconstruct for loop with fq") = test {
+ val for0 = q"for(..$abcde) $fv"
+ assertEqAst(for0, "for(a <- b; if c; d = e) f(v)")
+ val q"for(..$enums) $body" = for0
+ assert(enums ≈ abcde)
+ assert(body ≈ fv)
+ }
+
+ property("construct/deconstruct valfrom with fq") = test {
+ assert(fq"$foobarbaz <- $fv" ≈ fq"foo @ Bar(baz) <- f(v)")
+ val fq"$lhs <- $rhs" = fq"$foobarbaz <- $fv"
+ assert(lhs ≈ foobarbaz)
+ assert(rhs ≈ fv)
+ }
+
+ property("construct/deconstruct valeq with fq") = test {
+ assert(fq"$foobarbaz = $fv" ≈ fq"foo @ Bar(baz) = f(v)")
+ val fq"$lhs = $rhs" = fq"$foobarbaz = $fv"
+ assert(lhs ≈ foobarbaz)
+ assert(rhs ≈ fv)
+ }
+
+ property("construct/deconstruct filter with fq") = test {
+ assert(fq"if $fv" ≈ fq"if f(v)")
+ val fq"if $cond" = fq"if $fv"
+ assert(cond ≈ fv)
+ }
+} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/LiftableProps.scala b/test/files/scalacheck/quasiquotes/LiftableProps.scala
index 510ab99068..1271e1accd 100644
--- a/test/files/scalacheck/quasiquotes/LiftableProps.scala
+++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object LiftableProps extends QuasiquoteProperties("liftable") {
property("splice byte") = test {
diff --git a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
index 504cb2a77d..582e915258 100644
--- a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object PatternConstructionProps extends QuasiquoteProperties("pattern construction") {
property("splice bind") = forAll { (bind: Bind) =>
diff --git a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
index f73fd29b22..cccf8095db 100644
--- a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala
@@ -1,11 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
-import definitions._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object PatternDeconstructionProps extends QuasiquoteProperties("pattern deconstruction") {
property("extract bind") = forAll { (bind: Bind) =>
diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
index 6a531071bf..b331c4b6b6 100644
--- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
+++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
@@ -1,15 +1,7 @@
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe.definitions._
-import scala.reflect.runtime.universe.Flag._
-import scala.reflect.runtime.currentMirror
-import scala.reflect.api.{Liftable, Universe}
-import scala.reflect.macros.TypecheckException
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
import scala.tools.reflect.{ToolBox, ToolBoxError}
-
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
+import scala.reflect.runtime.currentMirror
+import scala.reflect.runtime.universe._, Flag._
class QuasiquoteProperties(name: String) extends Properties(name) with ArbitraryTreesAndNames with Helpers
@@ -18,14 +10,35 @@ trait Helpers {
* if no exception has been thrown while executing code
* block. This is useful for simple one-off tests.
*/
- def test[T](block: => T)=
- Prop { (params) =>
+ def test[T](block: => T) =
+ Prop { params =>
block
Result(Prop.Proof)
}
+ object simplify extends Transformer {
+ object SimplifiedName {
+ val st = scala.reflect.runtime.universe.asInstanceOf[scala.reflect.internal.SymbolTable]
+ val FreshName = new st.FreshNameExtractor
+ def unapply[T <: Name](name: T): Option[T] = name.asInstanceOf[st.Name] match {
+ case FreshName(prefix) =>
+ Some((if (name.isTermName) TermName(prefix) else TypeName(prefix)).asInstanceOf[T])
+ }
+ }
+
+ override def transform(tree: Tree): Tree = tree match {
+ case Ident(SimplifiedName(name)) => Ident(name)
+ case ValDef(mods, SimplifiedName(name), tpt, rhs) => ValDef(mods, name, tpt, rhs)
+ case Bind(SimplifiedName(name), rhs) => Bind(name, rhs)
+ case _ =>
+ super.transform(tree)
+ }
+
+ def apply(tree: Tree): Tree = transform(tree)
+ }
+
implicit class TestSimilarTree(tree1: Tree) {
- def ≈(tree2: Tree) = tree1.equalsStructure(tree2)
+ def ≈(tree2: Tree) = simplify(tree1).equalsStructure(simplify(tree2))
}
implicit class TestSimilarListTree(lst: List[Tree]) {
@@ -45,7 +58,7 @@ trait Helpers {
}
def assertThrows[T <: AnyRef](f: => Any)(implicit manifest: Manifest[T]): Unit = {
- val clazz = manifest.erasure.asInstanceOf[Class[T]]
+ val clazz = manifest.runtimeClass.asInstanceOf[Class[T]]
val thrown =
try {
f
@@ -68,6 +81,18 @@ trait Helpers {
val compile = toolbox.compile(_)
val eval = toolbox.eval(_)
+ def typecheck(tree: Tree) = toolbox.typeCheck(tree)
+
+ def typecheckTyp(tree: Tree) = {
+ val q"type $_ = $res" = typecheck(q"type T = $tree")
+ res
+ }
+
+ def typecheckPat(tree: Tree) = {
+ val q"$_ match { case $res => }" = typecheck(q"((): Any) match { case $tree => }")
+ res
+ }
+
def fails(msg: String, block: String) = {
def result(ok: Boolean, description: String = "") = {
val status = if (ok) Prop.Proof else Prop.False
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index f68656d0f7..cdd96205de 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object TermConstructionProps extends QuasiquoteProperties("term construction") {
property("splice single tree return tree itself") = forAll { (t: Tree) =>
@@ -148,8 +143,8 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
val a1 = q"a1"
val a2 = q"a2"
val as = List(a1, a2)
- assert(q"(..$as)" ≈ q"Tuple2($a1, $a2)")
- assert(q"(a0, ..$as)" ≈ q"Tuple3(a0, $a1, $a2)")
+ assert(q"(..$as)" ≈ q"scala.Tuple2($a1, $a2)")
+ assert(q"(a0, ..$as)" ≈ q"scala.Tuple3(a0, $a1, $a2)")
}
property("splice empty list into tuple") = test {
@@ -193,11 +188,11 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
property("fresh names are regenerated at each evaluation") = test {
def plusOne = q"{ _ + 1 }"
- assert(!(plusOne ≈ plusOne))
+ assert(!plusOne.equalsStructure(plusOne))
def whileTrue = q"while(true) false"
- assert(!(whileTrue ≈ whileTrue))
+ assert(!whileTrue.equalsStructure(whileTrue))
def withEvidence = q"def foo[T: X]"
- assert(!(withEvidence ≈ withEvidence))
+ assert(!withEvidence.equalsStructure(withEvidence))
}
property("make sure inference doesn't infer any") = test {
diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
index f37e4d9975..bd81afa125 100644
--- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") {
property("f(..x) = f") = test {
diff --git a/test/files/scalacheck/quasiquotes/Test.scala b/test/files/scalacheck/quasiquotes/Test.scala
index f41d961888..8b1e779ab2 100644
--- a/test/files/scalacheck/quasiquotes/Test.scala
+++ b/test/files/scalacheck/quasiquotes/Test.scala
@@ -12,4 +12,6 @@ object Test extends Properties("quasiquotes") {
include(DefinitionConstructionProps)
include(DefinitionDeconstructionProps)
include(DeprecationProps)
+ include(ForProps)
+ include(TypecheckedProps)
}
diff --git a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
index cac83ff8ac..be7a96d91e 100644
--- a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object TypeConstructionProps extends QuasiquoteProperties("type construction") {
property("bare idents contain type names") = test {
@@ -18,9 +13,9 @@ object TypeConstructionProps extends QuasiquoteProperties("type construction")
property("tuple type") = test {
val empty = List[Tree]()
val ts = List(tq"t1", tq"t2")
- assert(tq"(..$empty)" ≈ tq"scala.Unit")
- assert(tq"(..$ts)" ≈ tq"Tuple2[t1, t2]")
- assert(tq"(t0, ..$ts)" ≈ tq"Tuple3[t0, t1, t2]")
+ assert(tq"(..$empty)" ≈ build.ScalaDot(TypeName("Unit")))
+ assert(tq"(..$ts)" ≈ tq"scala.Tuple2[t1, t2]")
+ assert(tq"(t0, ..$ts)" ≈ tq"scala.Tuple3[t0, t1, t2]")
}
property("refined type") = test {
diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
index e1d5f4df96..499f5d6d8e 100644
--- a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
@@ -1,10 +1,5 @@
-import org.scalacheck._
-import Prop._
-import Gen._
-import Arbitrary._
-
-import scala.reflect.runtime.universe._
-import Flag._
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction") {
property("ident(type name)") = forAll { (name: TypeName) =>
diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
new file mode 100644
index 0000000000..f443330e0b
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
@@ -0,0 +1,53 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._, build.{Ident => _, _}
+
+object TypecheckedProps extends QuasiquoteProperties("typechecked") {
+ def original(tree: Tree) = tree match {
+ case tt: TypeTree => Some(tt.original)
+ case _ => None
+ }
+ def originals(trees: List[Tree]) = trees.flatMap(original)
+ val int = ScalaDot(TypeName("Int"))
+ val intint = List(int, int)
+
+ property("tuple term") = test {
+ val q"(..$elements)" = typecheck(q"(1, 2)")
+ assert(elements ≈ List(q"1", q"2"))
+ }
+
+ property("tuple type") = test {
+ val tq"(..$els0)" = typecheckTyp(tq"Unit")
+ assert(els0.isEmpty)
+ val tq"(..$els1)" = typecheckTyp(tq"(Int, Int)")
+ assert(originals(els1) ≈ intint)
+ }
+
+ property("function type") = test {
+ val tq"(..$argtpes) => $restpe" = typecheckTyp(tq"(Int, Int) => Int")
+ assert(originals(argtpes) ≈ intint)
+ assert(original(restpe).get ≈ int)
+ }
+
+ property("for/for-yield") = test {
+ val enums = fq"x <- xs" :: fq"x1 = x + 1" :: fq"if x1 % 2 == 0" :: Nil
+ val body = q"x1"
+ val xs = q"val xs = List(1, 2, 3)"
+ val q"$_; for(..$enums0) yield $body0" = typecheck(q"$xs; for(..$enums) yield $body")
+ assert(enums0 ≈ enums)
+ assert(body0 ≈ body)
+ val q"$_; for(..$enums1) $body1" = typecheck(q"$xs; for(..$enums) $body")
+ assert(enums1 ≈ enums)
+ assert(body1 ≈ body)
+ }
+
+ property("for .filter instead of .withFilter") = test {
+ val enums = fq"foo <- new Foo" :: fq"if foo != null" :: Nil
+ val body = q"foo"
+ val q"$_; for(..$enums1) yield $body1" = typecheck(q"""
+ class Foo { def map(f: Any => Any) = this; def filter(cond: Any => Boolean) = this }
+ for(..$enums) yield $body
+ """)
+ assert(enums1 ≈ enums)
+ assert(body1 ≈ body)
+ }
+} \ No newline at end of file
diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala
index 05507b1b18..72f6e9afd5 100644
--- a/test/files/scalacheck/si4147.scala
+++ b/test/files/scalacheck/si4147.scala
@@ -1,8 +1,6 @@
import org.scalacheck.Prop.{forAll, throws}
import org.scalacheck.Properties
-import org.scalacheck.ConsoleReporter.testStatsEx
import org.scalacheck.Gen
-import org.scalacheck.ConsoleReporter
import collection.mutable
@@ -66,5 +64,5 @@ object Test extends Properties("Mutable TreeSet") {
}
property("ordering must not be null") =
- throws(mutable.TreeSet.empty[Int](null), classOf[NullPointerException])
+ throws(classOf[NullPointerException])(mutable.TreeSet.empty[Int](null))
}
diff --git a/test/files/scalacheck/t2460.scala b/test/files/scalacheck/t2460.scala
index 196b43789f..ab2911447a 100644
--- a/test/files/scalacheck/t2460.scala
+++ b/test/files/scalacheck/t2460.scala
@@ -1,6 +1,5 @@
import org.scalacheck.Prop.forAll
import org.scalacheck.Properties
-import org.scalacheck.ConsoleReporter.testStatsEx
import org.scalacheck.{Test => SCTest}
import org.scalacheck.Gen
@@ -25,8 +24,4 @@ object Test extends Properties("Regex : Ticket 2460") {
("numberOfGroup", numberOfGroup),
("nameOfGroup", nameOfGroup)
)
-
- /*tests foreach {
- case (name, p) => testStatsEx(name, SCTest.check(p))
- }*/
}
diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala
index 7fca3ed5e4..4b9b77dd7e 100644
--- a/test/files/scalacheck/treeset.scala
+++ b/test/files/scalacheck/treeset.scala
@@ -151,5 +151,5 @@ object Test extends Properties("TreeSet") {
}
property("ordering must not be null") =
- throws(TreeSet.empty[Int](null), classOf[NullPointerException])
+ throws(classOf[NullPointerException])(TreeSet.empty[Int](null))
}
diff --git a/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala b/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala
new file mode 100644
index 0000000000..cf09abdfff
--- /dev/null
+++ b/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala
@@ -0,0 +1,47 @@
+package scala.tools.nsc
+package symtab
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.tools.testing.AssertUtil.assertThrows
+import scala.reflect.internal.util.FreshNameCreator
+
+@RunWith(classOf[JUnit4])
+class FreshNameExtractorTest {
+ object symbolTable extends SymbolTableForUnitTesting
+ import symbolTable._
+
+ val prefixes = List("foo$", "x$", "bar", "bippy$baz$")
+
+ @Test
+ def extractionPreservesPrefix =
+ ("" :: prefixes).foreach { creatorPrefix =>
+ prefixes.foreach { newPrefix =>
+ val Creator = new FreshNameCreator(creatorPrefix)
+ val Extractor = new FreshNameExtractor(creatorPrefix)
+ val Extractor(extractedPrefix) = TermName(Creator.newName(newPrefix))
+ assertEquals(newPrefix, extractedPrefix)
+ }
+ }
+
+ @Test
+ def extractionFailsOnCreatorPrefixMismatch = {
+ val Creator = new FreshNameCreator(prefixes.head)
+ val Extractor = new FreshNameExtractor(prefixes.tail.head)
+ assertThrows[MatchError] {
+ val Extractor(_) = TermName(Creator.newName("foo"))
+ }
+ }
+
+ @Test
+ def extractionsFailsIfNameDoesntEndWithNumber = {
+ val Creator = new FreshNameCreator(prefixes.head)
+ val Extractor = new FreshNameExtractor(prefixes.head)
+ assertThrows[MatchError] {
+ val Extractor(_) = TermName(Creator.newName("foo") + "bar")
+ }
+ }
+} \ No newline at end of file
diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala
index d9f7736769..82c70da28f 100644
--- a/test/pending/run/reify_callccinterpreter.scala
+++ b/test/pending/run/reify_callccinterpreter.scala
@@ -43,15 +43,15 @@ object Test extends App {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -67,12 +67,12 @@ object Test extends App {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
def test(t: Term): String = showM(interp(t, List()))
diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala
index 6cf87ea7c5..1f6d6c8da7 100644
--- a/test/pending/run/reify_simpleinterpreter.scala
+++ b/test/pending/run/reify_simpleinterpreter.scala
@@ -32,15 +32,15 @@ object Test extends App {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -56,7 +56,7 @@ object Test extends App {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
diff --git a/test/pending/shootout/fasta.scala b/test/pending/shootout/fasta.scala
index 8b711083a5..ae99ba5936 100644
--- a/test/pending/shootout/fasta.scala
+++ b/test/pending/shootout/fasta.scala
@@ -5,7 +5,7 @@
import java.io._
-object fasta {
+object fasta {
def main(args: Array[String]) = {
val ALU =
@@ -18,31 +18,31 @@ object fasta {
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
val _IUB = Array(
- Pair('a', 0.27),
- Pair('c', 0.12),
- Pair('g', 0.12),
- Pair('t', 0.27),
-
- Pair('B', 0.02),
- Pair('D', 0.02),
- Pair('H', 0.02),
- Pair('K', 0.02),
- Pair('M', 0.02),
- Pair('N', 0.02),
- Pair('R', 0.02),
- Pair('S', 0.02),
- Pair('V', 0.02),
- Pair('W', 0.02),
- Pair('Y', 0.02)
+ ('a', 0.27),
+ ('c', 0.12),
+ ('g', 0.12),
+ ('t', 0.27),
+
+ ('B', 0.02),
+ ('D', 0.02),
+ ('H', 0.02),
+ ('K', 0.02),
+ ('M', 0.02),
+ ('N', 0.02),
+ ('R', 0.02),
+ ('S', 0.02),
+ ('V', 0.02),
+ ('W', 0.02),
+ ('Y', 0.02)
)
val IUB = makeCumulative(_IUB)
val _HomoSapiens = Array(
- Pair('a', 0.3029549426680),
- Pair('c', 0.1979883004921),
- Pair('g', 0.1975473066391),
- Pair('t', 0.3015094502008)
+ ('a', 0.3029549426680),
+ ('c', 0.1979883004921),
+ ('g', 0.1975473066391),
+ ('t', 0.3015094502008)
)
val HomoSapiens = makeCumulative(_HomoSapiens)
@@ -61,15 +61,15 @@ object fasta {
s.writeRandomSequence(HomoSapiens,n*5)
s.close
- }
+ }
- def makeCumulative(a: Array[Pair[Char,Double]]) = {
+ def makeCumulative(a: Array[Tuple2[Char,Double]]) = {
var cp = 0.0
a map (frequency =>
- frequency match {
- case Pair(code,percent) =>
- cp = cp + percent; new Frequency(code.toByte,cp)
- }
+ frequency match {
+ case (code,percent) =>
+ cp = cp + percent; new Frequency(code.toByte,cp)
+ }
)
}
@@ -79,7 +79,7 @@ object fasta {
// We could use instances of Pair or Tuple2 but specific labels
// make the code more readable than index numbers
-class Frequency(_code: Byte, _percent: Double){
+class Frequency(_code: Byte, _percent: Double){
var code = _code; var percent = _percent;
}
@@ -101,13 +101,13 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) {
val m = if (n < LineLength) n else LineLength
var i = 0
- while (i < m){
+ while (i < m){
if (k == kn) k = 0
val b = alu(k)
if (count < buf.length){ buf(count) = b; count = count + 1 }
else { write(b) } // flush buffer
k = k+1
- i = i+1
+ i = i+1
}
write(nl)
@@ -122,11 +122,11 @@ class FastaOutputStream(out: OutputStream) extends BufferedOutputStream(out) {
val m = if (n < LineLength) n else LineLength
var i = 0
- while (i < m){
+ while (i < m){
val b = selectRandom(distribution)
if (count < buf.length){ buf(count) = b; count = count + 1 }
else { write(b) } // flush buffer
- i = i+1
+ i = i+1
}
if (count < buf.length){ buf(count) = nl; count = count + 1 }
diff --git a/test/pending/shootout/revcomp.scala-2.scala b/test/pending/shootout/revcomp.scala-2.scala
index 92260ad021..03fb25af1b 100644
--- a/test/pending/shootout/revcomp.scala-2.scala
+++ b/test/pending/shootout/revcomp.scala-2.scala
@@ -6,7 +6,7 @@
import java.io._
import scala.collection.mutable.Stack
-object revcomp {
+object revcomp {
val IUB = IUBCodeComplements
@@ -16,7 +16,7 @@ object revcomp {
val a: Array[Byte] = new Array( 'z'.toByte )
for (indexValue <- code zip comp)
- indexValue match { case Pair(i,v) => a(i) = v }
+ indexValue match { case (i,v) => a(i) = v }
a
}
@@ -49,18 +49,18 @@ object revcomp {
if (desc.length > 0) complementReverseWrite(desc, lines, w)
w.close
- }
+ }
- def complementReverseWrite(desc: String, lines: LineStack,
+ def complementReverseWrite(desc: String, lines: LineStack,
w: BufferedOutputStream) = {
def inplaceComplementReverse(b: Array[Byte]) = {
- var i = 0
+ var i = 0
var j = b.length - 1
while (i < j){
- val swap = b(i)
- b(i) = IUB( b(j) )
+ val swap = b(i)
+ b(i) = IUB( b(j) )
b(j) = IUB( swap )
i = i + 1
j = j - 1
@@ -79,11 +79,11 @@ object revcomp {
while (!lines.isEmpty) {
val line = lines.pop
inplaceComplementReverse(line)
-
+
if (isSplitLine){
if (isFirstLine){ w.write(line); isFirstLine = false }
else { w.write(line,0,n-k); w.write(nl); w.write(line,n-k,k) }
- }
+ }
else { w.write(line); w.write(nl) }
}
if (isSplitLine && !isFirstLine) w.write(nl)
diff --git a/test/pending/shootout/revcomp.scala-3.scala b/test/pending/shootout/revcomp.scala-3.scala
index ae12f0499b..39a0409127 100644
--- a/test/pending/shootout/revcomp.scala-3.scala
+++ b/test/pending/shootout/revcomp.scala-3.scala
@@ -6,7 +6,7 @@
import java.io._
import scala.collection.mutable.Stack
-object revcomp {
+object revcomp {
def main(args: Array[String]) = {
val out = new FastaOutputStream(System.out)
val in = new FastaInputStream(System.in)
@@ -17,12 +17,12 @@ object revcomp {
in.close
out.close
- }
+ }
}
trait FastaByteStream {
- val nl = '\n'.toByte
+ val nl = '\n'.toByte
type Line = Array[Byte]
type LineStack = Stack[Line]
@@ -31,13 +31,13 @@ trait FastaByteStream {
// extend the Java BufferedInputStream class
-final class FastaInputStream(in: InputStream)
+final class FastaInputStream(in: InputStream)
extends BufferedInputStream(in) with FastaByteStream {
val gt = '>'.toByte
val sc = ';'.toByte
- def readSequenceStack(): Pair[Line,LineStack] = {
+ def readSequenceStack(): Tuple2[Line,LineStack] = {
var header: Line = null
val lines: LineStack = new Stack
@@ -49,14 +49,14 @@ final class FastaInputStream(in: InputStream)
header = line
} else {
pos = pos - line.length - 1 // reposition to start of line
- return Pair(header,lines)
+ return (header,lines)
}
} else {
if (c != sc) lines push line // ';'
}
line = readLine()
}
- return Pair(header,lines)
+ return (header,lines)
}
def readLine() = {
@@ -65,7 +65,7 @@ final class FastaInputStream(in: InputStream)
else {
mark(128) // mark the start of the line
if (count == 0) read() // fill buffer
-
+
var i = markpos
while (i < count && buf(i) != nl) i = i + 1
@@ -74,11 +74,11 @@ final class FastaInputStream(in: InputStream)
while (i < count && buf(i) != nl) i = i + 1
}
- if (i < count){
+ if (i < count){
bytes = new Array(i - markpos)
System.arraycopy(buf, markpos, bytes, 0, i - markpos);
pos = i+1
- }
+ }
}
bytes
}
@@ -87,7 +87,7 @@ final class FastaInputStream(in: InputStream)
// extend the Java BufferedOutputStream class
-final class FastaOutputStream(in: OutputStream)
+final class FastaOutputStream(in: OutputStream)
extends BufferedOutputStream(in) with FastaByteStream {
private val IUB = IUBCodeComplements
@@ -98,19 +98,19 @@ final class FastaOutputStream(in: OutputStream)
val iub: Array[Byte] = new Array( 'z'.toByte )
for (indexValue <- code zip comp)
- indexValue match { case Pair(i,v) => iub(i) = v }
+ indexValue match { case (i,v) => iub(i) = v }
iub
}
- def writeReverseComplement(sequence: Pair[Line,LineStack]) = {
+ def writeReverseComplement(sequence: Tuple2[Line,LineStack]) = {
def inplaceComplementReverse(b: Array[Byte]) = {
- var i = 0
+ var i = 0
var j = b.length - 1
while (i < j){
- val swap = b(i)
- b(i) = IUB( b(j) )
+ val swap = b(i)
+ b(i) = IUB( b(j) )
b(j) = IUB( swap )
i = i + 1
j = j - 1
@@ -119,7 +119,7 @@ final class FastaOutputStream(in: OutputStream)
}
sequence match {
- case Pair(header,lines) => {
+ case (header,lines) => {
write(header); write(nl)
@@ -131,11 +131,11 @@ final class FastaOutputStream(in: OutputStream)
while (!lines.isEmpty) {
val line = lines.pop
inplaceComplementReverse(line)
-
+
if (isSplitLine){
- if (isFirstLine){ write(line); isFirstLine = false }
+ if (isFirstLine){ write(line); isFirstLine = false }
else { write(line,0,LineLength-k); write(nl); write(line,LineLength-k,k) }
- }
+ }
else { write(line); write(nl) }
}
diff --git a/versions.properties b/versions.properties
index f4eed9d058..76eea52681 100644
--- a/versions.properties
+++ b/versions.properties
@@ -1,9 +1,14 @@
-starr.version=2.11.0-M6
+starr.version=2.11.0-M7
starr.use.released=1
-# the below is used for depending on dependencies like partest
-scala.binary.version=2.11.0-M6
-partest.version.number=1.0.0-RC7
-scala-xml.version.number=1.0.0-RC6
-scala-parser-combinators.version.number=1.0.0-RC4
-scalacheck.version.number=1.10.1 \ No newline at end of file
+# These are the versions of the modules that go with this release.
+# These properties are used during PR validation and in dbuild builds.
+scala.binary.version=2.11.0-M7
+partest.version.number=1.0.0-RC8
+scala-xml.version.number=1.0.0-RC7
+scala-parser-combinators.version.number=1.0.0-RC5
+scalacheck.version.number=1.11.1
+
+# TODO: modularize the compiler
+#scala-compiler-doc.version.number=1.0.0-RC1
+#scala-compiler-interactive.version.number=1.0.0-RC1