summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml239
-rw-r--r--lib/scala-compiler.jar.desired.sha12
-rw-r--r--lib/scala-library.jar.desired.sha12
-rw-r--r--lib/scala-reflect.jar.desired.sha11
-rw-r--r--src/build/maven/maven-deploy.xml3
-rw-r--r--src/build/maven/scala-compiler-pom.xml5
-rw-r--r--src/build/maven/scala-reflect-pom.xml62
-rw-r--r--src/build/pack.xml3
-rw-r--r--src/compiler/scala/reflect/internal/FreeVars.scala60
-rw-r--r--src/compiler/scala/reflect/internal/StdAttachments.scala10
-rw-r--r--src/compiler/scala/reflect/internal/TreeBuildUtil.scala66
-rw-r--r--src/compiler/scala/reflect/internal/Trees.scala435
-rw-r--r--src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala2
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Aliases.scala31
-rw-r--r--src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala7
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Context.scala16
-rw-r--r--src/compiler/scala/reflect/makro/runtime/ContextReifiers.scala26
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Enclosures.scala3
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Evals.scala18
-rw-r--r--src/compiler/scala/reflect/makro/runtime/ExprUtils.scala (renamed from src/compiler/scala/reflect/makro/runtime/Util.scala)3
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Exprs.scala8
-rw-r--r--src/compiler/scala/reflect/makro/runtime/FrontEnds.scala23
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Infrastructure.scala36
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Mirrors.scala40
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Names.scala11
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Parsers.scala25
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Reifiers.scala65
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Settings.scala6
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Symbols.scala10
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Traces.scala2
-rw-r--r--src/compiler/scala/reflect/makro/runtime/TypeTags.scala9
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Typers.scala40
-rw-r--r--src/compiler/scala/reflect/reify/Errors.scala31
-rw-r--r--src/compiler/scala/reflect/reify/NodePrinters.scala111
-rw-r--r--src/compiler/scala/reflect/reify/Phases.scala24
-rw-r--r--src/compiler/scala/reflect/reify/Reifier.scala115
-rw-r--r--src/compiler/scala/reflect/reify/States.scala65
-rw-r--r--src/compiler/scala/reflect/reify/Taggers.scala103
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala (renamed from src/compiler/scala/reflect/reify/codegen/AnnotationInfos.scala)13
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenNames.scala (renamed from src/compiler/scala/reflect/reify/codegen/Names.scala)5
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenPositions.scala (renamed from src/compiler/scala/reflect/reify/codegen/Positions.scala)5
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenSymbols.scala109
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTrees.scala (renamed from src/compiler/scala/reflect/reify/codegen/Trees.scala)145
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTypes.scala203
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenUtils.scala (renamed from src/compiler/scala/reflect/reify/codegen/Util.scala)53
-rw-r--r--src/compiler/scala/reflect/reify/codegen/Symbols.scala184
-rw-r--r--src/compiler/scala/reflect/reify/codegen/Types.scala168
-rw-r--r--src/compiler/scala/reflect/reify/package.scala81
-rw-r--r--src/compiler/scala/reflect/reify/phases/Calculate.scala17
-rw-r--r--src/compiler/scala/reflect/reify/phases/Metalevels.scala82
-rw-r--r--src/compiler/scala/reflect/reify/phases/Reify.scala32
-rw-r--r--src/compiler/scala/reflect/reify/phases/Reshape.scala51
-rw-r--r--src/compiler/scala/reflect/reify/utils/Extractors.scala302
-rw-r--r--src/compiler/scala/reflect/reify/utils/NodePrinters.scala144
-rw-r--r--src/compiler/scala/reflect/reify/utils/StdAttachments.scala12
-rw-r--r--src/compiler/scala/reflect/reify/utils/SymbolTables.scala223
-rw-r--r--src/compiler/scala/reflect/reify/utils/Utils.scala21
-rw-r--r--src/compiler/scala/reflect/runtime/ClassLoaders.scala25
-rw-r--r--src/compiler/scala/reflect/runtime/ConversionUtil.scala92
-rw-r--r--src/compiler/scala/reflect/runtime/JavaToScala.scala697
-rw-r--r--src/compiler/scala/reflect/runtime/Mirror.scala85
-rw-r--r--src/compiler/scala/reflect/runtime/ScalaToJava.scala87
-rw-r--r--src/compiler/scala/reflect/runtime/Universe.scala43
-rw-r--r--src/compiler/scala/reflect/runtime/package.scala5
-rw-r--r--src/compiler/scala/tools/ant/FastScalac.scala2
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala2
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl21
-rw-r--r--src/compiler/scala/tools/cmd/CommandLine.scala1
-rw-r--r--src/compiler/scala/tools/cmd/FromString.scala17
-rw-r--r--src/compiler/scala/tools/cmd/gen/AnyVals.scala33
-rw-r--r--src/compiler/scala/tools/cmd/gen/Codegen.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ClassLoaders.scala64
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala3
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Driver.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala288
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Phases.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ReflectGlobal.scala28
-rw-r--r--src/compiler/scala/tools/nsc/ReflectMain.scala7
-rw-r--r--src/compiler/scala/tools/nsc/ReflectSetup.scala7
-rw-r--r--src/compiler/scala/tools/nsc/ScalaDoc.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ToolBoxes.scala84
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ast/FreeVars.scala26
-rw-r--r--src/compiler/scala/tools/nsc/ast/NodePrinters.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/Positions.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala5
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala3
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala123
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala5
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala5
-rw-r--r--src/compiler/scala/tools/nsc/backend/JavaPlatform.scala14
-rw-r--r--src/compiler/scala/tools/nsc/backend/MSILPlatform.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/Platform.scala3
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Members.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Printers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala68
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala21
-rw-r--r--src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala4
-rw-r--r--src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocParser.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/Settings.scala18
-rw-r--r--src/compiler/scala/tools/nsc/doc/Uncompilable.scala3
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala4
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala4
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala5
-rwxr-xr-xsrc/compiler/scala/tools/nsc/doc/model/TreeFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/BuildManager.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala3
-rw-r--r--src/compiler/scala/tools/nsc/interactive/ContextTrees.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala3
-rw-r--r--src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Picklers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/interactive/REPL.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RangePositions.scala5
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala3
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/Tester.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/TestResources.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala15
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala34
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala69
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ISettings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala3
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/NamedParam.scala12
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Power.scala47
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ReplProps.scala12
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ReplVals.scala9
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/RichClass.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala26
-rw-r--r--src/compiler/scala/tools/nsc/io/Pickler.scala1
-rw-r--r--src/compiler/scala/tools/nsc/io/SourceReader.scala2
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaScanners.scala3
-rw-r--r--src/compiler/scala/tools/nsc/matching/ParallelMatching.scala2
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala5
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala3
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala9
-rw-r--r--src/compiler/scala/tools/nsc/reporters/StoreReporter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/Executor.scala2
-rw-r--r--src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala10
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala5
-rw-r--r--src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala74
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala14
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala3
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala9
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala38
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala21
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala18
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala68
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala68
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala530
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala50
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala28
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala1196
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala16
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Taggings.scala71
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Tags.scala69
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala217
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Unapplies.scala11
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala10
-rw-r--r--src/compiler/scala/tools/nsc/util/Exceptional.scala2
-rw-r--r--src/compiler/scala/tools/nsc/util/FreshNameCreator.scala4
-rw-r--r--src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala7
-rw-r--r--src/compiler/scala/tools/nsc/util/Statistics.scala32
-rw-r--r--src/compiler/scala/tools/nsc/util/package.scala53
-rw-r--r--src/compiler/scala/tools/reflect/FastTrack.scala47
-rw-r--r--src/compiler/scala/tools/reflect/FrontEnds.scala (renamed from src/compiler/scala/reflect/internal/FrontEnds.scala)13
-rw-r--r--src/compiler/scala/tools/reflect/StdTags.scala42
-rw-r--r--src/compiler/scala/tools/reflect/ToolBox.scala93
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala (renamed from src/compiler/scala/reflect/runtime/ToolBoxes.scala)223
-rw-r--r--src/compiler/scala/tools/reflect/WrappedProperties.scala4
-rw-r--r--src/compiler/scala/tools/reflect/package.scala33
-rw-r--r--src/compiler/scala/tools/util/Javap.scala1
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala11
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala16
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala2
-rw-r--r--src/forkjoin/scala/concurrent/forkjoin/ForkJoinPool.java19
-rw-r--r--src/forkjoin/scala/concurrent/forkjoin/ForkJoinTask.java19
-rw-r--r--src/forkjoin/scala/concurrent/forkjoin/LinkedTransferQueue.java19
-rw-r--r--src/library/scala/AnyVal.scala4
-rw-r--r--src/library/scala/Array.scala46
-rw-r--r--src/library/scala/Boolean.scala29
-rw-r--r--src/library/scala/Byte.scala229
-rw-r--r--src/library/scala/Char.scala229
-rw-r--r--src/library/scala/Double.scala182
-rw-r--r--src/library/scala/Float.scala185
-rw-r--r--src/library/scala/Int.scala229
-rw-r--r--src/library/scala/Long.scala229
-rw-r--r--src/library/scala/Predef.scala20
-rw-r--r--src/library/scala/Short.scala229
-rw-r--r--src/library/scala/Unit.scala8
-rw-r--r--src/library/scala/collection/GenMapLike.scala2
-rw-r--r--src/library/scala/collection/GenSeqLike.scala2
-rw-r--r--src/library/scala/collection/GenSetLike.scala2
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala8
-rw-r--r--src/library/scala/collection/IndexedSeqLike.scala2
-rw-r--r--src/library/scala/collection/LinearSeqLike.scala2
-rw-r--r--src/library/scala/collection/Traversable.scala2
-rw-r--r--src/library/scala/collection/TraversableOnce.scala3
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala3
-rw-r--r--src/library/scala/collection/concurrent/TrieMap.scala72
-rw-r--r--src/library/scala/collection/convert/Wrappers.scala5
-rw-r--r--src/library/scala/collection/generic/ClassTagTraversableFactory.scala (renamed from src/library/scala/collection/generic/ArrayTagTraversableFactory.scala)9
-rw-r--r--src/library/scala/collection/generic/GenericClassTagCompanion.scala (renamed from src/library/scala/collection/generic/GenericArrayTagCompanion.scala)11
-rw-r--r--src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala (renamed from src/library/scala/collection/generic/GenericArrayTagTraversableTemplate.scala)19
-rw-r--r--src/library/scala/collection/generic/TraversableForwarder.scala3
-rw-r--r--src/library/scala/collection/generic/package.scala14
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala67
-rw-r--r--src/library/scala/collection/immutable/NumericRange.scala30
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala11
-rw-r--r--src/library/scala/collection/immutable/Range.scala14
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala3
-rw-r--r--src/library/scala/collection/mutable/ArrayBuilder.scala17
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala8
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala3
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala4
-rw-r--r--src/library/scala/collection/mutable/HashTable.scala7
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala26
-rw-r--r--src/library/scala/collection/mutable/StackProxy.scala5
-rw-r--r--src/library/scala/collection/mutable/UnrolledBuffer.scala17
-rw-r--r--src/library/scala/collection/mutable/WrappedArray.scala10
-rw-r--r--src/library/scala/collection/mutable/WrappedArrayBuilder.scala10
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala21
-rw-r--r--src/library/scala/collection/parallel/mutable/ParArray.scala4
-rw-r--r--src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala4
-rw-r--r--src/library/scala/concurrent/Future.scala105
-rw-r--r--src/library/scala/concurrent/Promise.scala14
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala28
-rw-r--r--src/library/scala/concurrent/impl/Future.scala2
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala21
-rw-r--r--src/library/scala/languageFeature.scala14
-rw-r--r--src/library/scala/math/Equiv.scala2
-rw-r--r--src/library/scala/math/Ordered.scala11
-rw-r--r--src/library/scala/ref/WeakReference.scala16
-rw-r--r--src/library/scala/reflect/ArrayTag.scala25
-rw-r--r--src/library/scala/reflect/ClassManifest.scala1
-rw-r--r--src/library/scala/reflect/ClassTag.scala80
-rw-r--r--src/library/scala/reflect/DummyMirror.scala783
-rw-r--r--src/library/scala/reflect/DynamicProxy.scala74
-rw-r--r--src/library/scala/reflect/ErasureTag.scala23
-rw-r--r--src/library/scala/reflect/Manifest.scala5
-rwxr-xr-xsrc/library/scala/reflect/NameTransformer.scala4
-rw-r--r--src/library/scala/reflect/ScalaLongSignature.java4
-rw-r--r--src/library/scala/reflect/ScalaSignature.java3
-rw-r--r--src/library/scala/reflect/TagInterop.scala34
-rw-r--r--src/library/scala/reflect/api/Attachment.scala29
-rw-r--r--src/library/scala/reflect/api/ClassLoaders.scala16
-rw-r--r--src/library/scala/reflect/api/Exprs.scala19
-rw-r--r--src/library/scala/reflect/api/FreeVars.scala42
-rw-r--r--src/library/scala/reflect/api/Mirror.scala100
-rw-r--r--src/library/scala/reflect/api/Modifier.scala82
-rwxr-xr-xsrc/library/scala/reflect/api/StandardDefinitions.scala145
-rw-r--r--src/library/scala/reflect/api/ToolBoxes.scala90
-rw-r--r--src/library/scala/reflect/api/TreeBuildUtil.scala159
-rw-r--r--src/library/scala/reflect/api/TypeTags.scala254
-rw-r--r--[-rwxr-xr-x]src/library/scala/reflect/base/AnnotationInfos.scala (renamed from src/library/scala/reflect/api/AnnotationInfos.scala)34
-rw-r--r--src/library/scala/reflect/base/Attachments.scala42
-rw-r--r--src/library/scala/reflect/base/Base.scala763
-rw-r--r--src/library/scala/reflect/base/BuildUtils.scala90
-rw-r--r--src/library/scala/reflect/base/Constants.scala20
-rw-r--r--src/library/scala/reflect/base/FlagSets.scala17
-rw-r--r--src/library/scala/reflect/base/MirrorOf.scala25
-rw-r--r--src/library/scala/reflect/base/Mirrors.scala12
-rw-r--r--[-rwxr-xr-x]src/library/scala/reflect/base/Names.scala (renamed from src/library/scala/reflect/api/Names.scala)33
-rw-r--r--src/library/scala/reflect/base/Positions.scala22
-rw-r--r--[-rwxr-xr-x]src/library/scala/reflect/base/Scopes.scala (renamed from src/library/scala/reflect/api/Scopes.scala)9
-rw-r--r--src/library/scala/reflect/base/StandardDefinitions.scala75
-rw-r--r--src/library/scala/reflect/base/StandardNames.scala29
-rw-r--r--src/library/scala/reflect/base/Symbols.scala272
-rw-r--r--src/library/scala/reflect/base/TagInterop.scala29
-rw-r--r--src/library/scala/reflect/base/TreeCreator.scala6
-rw-r--r--src/library/scala/reflect/base/Trees.scala1459
-rw-r--r--src/library/scala/reflect/base/TypeCreator.scala6
-rw-r--r--src/library/scala/reflect/base/TypeTags.scala246
-rw-r--r--[-rwxr-xr-x]src/library/scala/reflect/base/Types.scala (renamed from src/library/scala/reflect/api/Types.scala)562
-rw-r--r--src/library/scala/reflect/base/Universe.scala18
-rw-r--r--src/library/scala/reflect/compat.scala33
-rw-r--r--src/library/scala/reflect/makro/Aliases.scala26
-rw-r--r--src/library/scala/reflect/makro/Context.scala44
-rw-r--r--src/library/scala/reflect/makro/Symbols.scala24
-rw-r--r--src/library/scala/reflect/makro/internal/Utils.scala146
-rw-r--r--src/library/scala/reflect/makro/internal/macroImpl.scala17
-rw-r--r--src/library/scala/reflect/makro/internal/package.scala16
-rw-r--r--src/library/scala/reflect/package.scala56
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala8
-rw-r--r--src/library/scala/text/Document.scala2
-rw-r--r--src/library/scala/util/Marshal.scala2
-rw-r--r--src/library/scala/util/Sorting.scala16
-rw-r--r--src/library/scala/util/control/Exception.scala3
-rw-r--r--src/library/scala/util/hashing/ByteswapHashing.scala35
-rw-r--r--src/library/scala/util/hashing/Hashing.scala42
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala (renamed from src/library/scala/util/MurmurHash3.scala)78
-rw-r--r--src/library/scala/util/hashing/package.scala35
-rw-r--r--src/library/scala/xml/Attribute.scala4
-rwxr-xr-xsrc/library/scala/xml/Utility.scala2
-rw-r--r--src/partest/scala/tools/partest/CompilerTest.scala6
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala11
-rw-r--r--src/partest/scala/tools/partest/SigTest.scala7
-rw-r--r--src/partest/scala/tools/partest/nest/AntRunner.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala17
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala3
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/SBTRunner.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala2
-rw-r--r--src/reflect/scala/reflect/api/AnnotationInfos.scala27
-rw-r--r--[-rwxr-xr-x]src/reflect/scala/reflect/api/Constants.scala (renamed from src/library/scala/reflect/api/Constants.scala)18
-rw-r--r--src/reflect/scala/reflect/api/Exprs.scala62
-rw-r--r--src/reflect/scala/reflect/api/FlagSets.scala112
-rw-r--r--src/reflect/scala/reflect/api/FrontEnds.scala (renamed from src/library/scala/reflect/api/FrontEnds.scala)6
-rw-r--r--src/reflect/scala/reflect/api/Importers.scala (renamed from src/library/scala/reflect/api/Importers.scala)2
-rw-r--r--src/reflect/scala/reflect/api/JavaUniverse.scala19
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala208
-rw-r--r--src/reflect/scala/reflect/api/Names.scala44
-rw-r--r--src/reflect/scala/reflect/api/Positions.scala (renamed from src/library/scala/reflect/api/Positions.scala)62
-rw-r--r--src/reflect/scala/reflect/api/StandardDefinitions.scala48
-rw-r--r--src/reflect/scala/reflect/api/StandardNames.scala (renamed from src/library/scala/reflect/api/StandardNames.scala)38
-rw-r--r--[-rwxr-xr-x]src/reflect/scala/reflect/api/Symbols.scala (renamed from src/library/scala/reflect/api/Symbols.scala)330
-rw-r--r--src/reflect/scala/reflect/api/TagInterop.scala38
-rw-r--r--src/reflect/scala/reflect/api/TreePrinters.scala (renamed from src/library/scala/reflect/api/TreePrinters.scala)27
-rw-r--r--src/reflect/scala/reflect/api/Trees.scala689
-rw-r--r--src/reflect/scala/reflect/api/Types.scala368
-rw-r--r--[-rwxr-xr-x]src/reflect/scala/reflect/api/Universe.scala (renamed from src/library/scala/reflect/api/Universe.scala)47
-rw-r--r--src/reflect/scala/reflect/api/package.scala12
-rw-r--r--src/reflect/scala/reflect/internal/AbstractFileApi.scala (renamed from src/library/scala/reflect/api/RequiredFile.scala)4
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationCheckers.scala (renamed from src/compiler/scala/reflect/internal/AnnotationCheckers.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationInfos.scala (renamed from src/compiler/scala/reflect/internal/AnnotationInfos.scala)16
-rw-r--r--src/reflect/scala/reflect/internal/BaseTypeSeqs.scala (renamed from src/compiler/scala/reflect/internal/BaseTypeSeqs.scala)39
-rw-r--r--src/reflect/scala/reflect/internal/BuildUtils.scala69
-rw-r--r--src/reflect/scala/reflect/internal/CapturedVariables.scala (renamed from src/compiler/scala/reflect/internal/CapturedVariables.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/Chars.scala (renamed from src/compiler/scala/reflect/internal/Chars.scala)4
-rw-r--r--src/reflect/scala/reflect/internal/ClassfileConstants.scala (renamed from src/compiler/scala/reflect/internal/ClassfileConstants.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/Constants.scala (renamed from src/compiler/scala/reflect/internal/Constants.scala)4
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala (renamed from src/compiler/scala/reflect/internal/Definitions.scala)547
-rw-r--r--src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala (renamed from src/compiler/scala/reflect/internal/ExistentialsAndSkolems.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/FatalError.scala (renamed from src/compiler/scala/reflect/internal/FatalError.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/FlagSets.scala66
-rw-r--r--src/reflect/scala/reflect/internal/Flags.scala (renamed from src/compiler/scala/reflect/internal/Flags.scala)41
-rw-r--r--src/reflect/scala/reflect/internal/HasFlags.scala (renamed from src/compiler/scala/reflect/internal/HasFlags.scala)1
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala (renamed from src/compiler/scala/reflect/internal/Importers.scala)15
-rw-r--r--src/reflect/scala/reflect/internal/InfoTransformers.scala (renamed from src/compiler/scala/reflect/internal/InfoTransformers.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/Kinds.scala (renamed from src/compiler/scala/reflect/internal/Kinds.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/Mirrors.scala243
-rw-r--r--src/reflect/scala/reflect/internal/MissingRequirementError.scala (renamed from src/compiler/scala/reflect/internal/MissingRequirementError.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/Names.scala (renamed from src/compiler/scala/reflect/internal/Names.scala)25
-rw-r--r--src/reflect/scala/reflect/internal/Phase.scala (renamed from src/compiler/scala/reflect/internal/Phase.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/Positions.scala (renamed from src/compiler/scala/reflect/internal/Positions.scala)5
-rw-r--r--src/reflect/scala/reflect/internal/Required.scala (renamed from src/compiler/scala/reflect/internal/Required.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/Scopes.scala (renamed from src/compiler/scala/reflect/internal/Scopes.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/StdAttachments.scala12
-rw-r--r--src/reflect/scala/reflect/internal/StdCreators.scala21
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala (renamed from src/compiler/scala/reflect/internal/StdNames.scala)327
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala (renamed from src/compiler/scala/reflect/internal/SymbolTable.scala)24
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala (renamed from src/compiler/scala/reflect/internal/Symbols.scala)173
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala (renamed from src/compiler/scala/reflect/internal/TreeGen.scala)10
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala (renamed from src/compiler/scala/reflect/internal/TreeInfo.scala)202
-rw-r--r--src/reflect/scala/reflect/internal/TreePrinters.scala (renamed from src/compiler/scala/reflect/internal/TreePrinters.scala)14
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala (renamed from src/library/scala/reflect/api/Trees.scala)1865
-rw-r--r--src/reflect/scala/reflect/internal/TypeDebugging.scala (renamed from src/compiler/scala/reflect/internal/TypeDebugging.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala (renamed from src/compiler/scala/reflect/internal/Types.scala)314
-rw-r--r--src/reflect/scala/reflect/internal/package.scala6
-rw-r--r--src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala (renamed from src/compiler/scala/reflect/internal/pickling/ByteCodecs.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala (renamed from src/compiler/scala/reflect/internal/pickling/PickleBuffer.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/pickling/PickleFormat.scala (renamed from src/compiler/scala/reflect/internal/pickling/PickleFormat.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala (renamed from src/compiler/scala/reflect/internal/pickling/UnPickler.scala)17
-rw-r--r--src/reflect/scala/reflect/internal/settings/AbsSettings.scala (renamed from src/compiler/scala/reflect/internal/settings/AbsSettings.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/settings/MutableSettings.scala (renamed from src/compiler/scala/reflect/internal/settings/MutableSettings.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/transform/Erasure.scala (renamed from src/compiler/scala/reflect/internal/transform/Erasure.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/transform/RefChecks.scala (renamed from src/compiler/scala/reflect/internal/transform/RefChecks.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/transform/Transforms.scala (renamed from src/compiler/scala/reflect/internal/transform/Transforms.scala)2
-rw-r--r--src/reflect/scala/reflect/internal/transform/UnCurry.scala (renamed from src/compiler/scala/reflect/internal/transform/UnCurry.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/util/Collections.scala (renamed from src/compiler/scala/reflect/internal/util/Collections.scala)6
-rw-r--r--src/reflect/scala/reflect/internal/util/HashSet.scala (renamed from src/compiler/scala/reflect/internal/util/HashSet.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/util/Origins.scala (renamed from src/compiler/scala/reflect/internal/util/Origins.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/util/Position.scala (renamed from src/compiler/scala/tools/nsc/util/Position.scala)47
-rw-r--r--src/reflect/scala/reflect/internal/util/Set.scala (renamed from src/compiler/scala/reflect/internal/util/Set.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/util/SourceFile.scala (renamed from src/compiler/scala/tools/nsc/util/SourceFile.scala)5
-rw-r--r--src/reflect/scala/reflect/internal/util/StatBase.scala (renamed from src/compiler/scala/reflect/internal/util/StatBase.scala)0
-rw-r--r--src/reflect/scala/reflect/internal/util/Statistics.scala (renamed from src/compiler/scala/reflect/internal/util/Statistics.scala)3
-rw-r--r--src/reflect/scala/reflect/internal/util/StringOps.scala (renamed from src/compiler/scala/tools/util/StringOps.scala)3
-rw-r--r--src/reflect/scala/reflect/internal/util/TableDef.scala (renamed from src/compiler/scala/tools/nsc/util/TableDef.scala)3
-rw-r--r--src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala (renamed from src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala)3
-rw-r--r--src/reflect/scala/reflect/internal/util/WeakHashSet.scala (renamed from src/compiler/scala/tools/nsc/util/WeakHashSet.scala)2
-rw-r--r--src/reflect/scala/reflect/makro/Aliases.scala26
-rw-r--r--src/reflect/scala/reflect/makro/CapturedVariables.scala (renamed from src/library/scala/reflect/makro/CapturedVariables.scala)3
-rw-r--r--src/reflect/scala/reflect/makro/Context.scala40
-rw-r--r--src/reflect/scala/reflect/makro/Enclosures.scala (renamed from src/library/scala/reflect/makro/Enclosures.scala)3
-rw-r--r--src/reflect/scala/reflect/makro/Evals.scala9
-rw-r--r--src/reflect/scala/reflect/makro/ExprUtils.scala (renamed from src/library/scala/reflect/makro/Util.scala)5
-rw-r--r--src/reflect/scala/reflect/makro/Exprs.scala8
-rw-r--r--src/reflect/scala/reflect/makro/FrontEnds.scala (renamed from src/library/scala/reflect/makro/FrontEnds.scala)7
-rw-r--r--src/reflect/scala/reflect/makro/Infrastructure.scala (renamed from src/library/scala/reflect/makro/Infrastructure.scala)32
-rw-r--r--src/reflect/scala/reflect/makro/Names.scala (renamed from src/library/scala/reflect/makro/Names.scala)5
-rw-r--r--src/reflect/scala/reflect/makro/Parsers.scala18
-rw-r--r--src/reflect/scala/reflect/makro/Reifiers.scala (renamed from src/library/scala/reflect/makro/Reifiers.scala)38
-rw-r--r--src/reflect/scala/reflect/makro/Settings.scala (renamed from src/library/scala/reflect/makro/Settings.scala)4
-rw-r--r--src/reflect/scala/reflect/makro/TreeBuilder.scala60
-rw-r--r--src/reflect/scala/reflect/makro/TypeTags.scala9
-rw-r--r--src/reflect/scala/reflect/makro/Typers.scala (renamed from src/library/scala/reflect/makro/Typers.scala)5
-rw-r--r--src/reflect/scala/reflect/makro/Universe.scala118
-rw-r--r--src/reflect/scala/reflect/makro/package.scala6
-rw-r--r--src/reflect/scala/reflect/runtime/AbstractFile.scala (renamed from src/compiler/scala/reflect/runtime/AbstractFile.scala)2
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala1037
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverse.scala33
-rw-r--r--src/reflect/scala/reflect/runtime/ReflectSetup.scala12
-rw-r--r--src/reflect/scala/reflect/runtime/ReflectionUtils.scala (renamed from src/library/scala/reflect/ReflectionUtils.scala)28
-rw-r--r--src/reflect/scala/reflect/runtime/Settings.scala (renamed from src/compiler/scala/reflect/runtime/Settings.scala)2
-rw-r--r--src/reflect/scala/reflect/runtime/SymbolLoaders.scala (renamed from src/compiler/scala/reflect/runtime/SymbolLoaders.scala)55
-rw-r--r--src/reflect/scala/reflect/runtime/SymbolTable.scala (renamed from src/compiler/scala/reflect/runtime/SymbolTable.scala)5
-rw-r--r--src/reflect/scala/reflect/runtime/SynchronizedOps.scala (renamed from src/compiler/scala/reflect/runtime/SynchronizedOps.scala)0
-rw-r--r--src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala (renamed from src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala)14
-rw-r--r--src/reflect/scala/reflect/runtime/SynchronizedTypes.scala (renamed from src/compiler/scala/reflect/runtime/SynchronizedTypes.scala)13
-rw-r--r--src/reflect/scala/reflect/runtime/TwoWayCache.scala52
-rw-r--r--src/reflect/scala/reflect/runtime/package.scala26
-rw-r--r--src/reflect/scala/tools/nsc/io/AbstractFile.scala (renamed from src/compiler/scala/tools/nsc/io/AbstractFile.scala)4
-rw-r--r--src/reflect/scala/tools/nsc/io/Directory.scala (renamed from src/compiler/scala/tools/nsc/io/Directory.scala)2
-rw-r--r--src/reflect/scala/tools/nsc/io/File.scala (renamed from src/compiler/scala/tools/nsc/io/File.scala)1
-rw-r--r--src/reflect/scala/tools/nsc/io/FileOperationException.scala (renamed from src/compiler/scala/tools/nsc/io/FileOperationException.scala)0
-rw-r--r--src/reflect/scala/tools/nsc/io/NoAbstractFile.scala (renamed from src/compiler/scala/tools/nsc/io/NoAbstractFile.scala)1
-rw-r--r--src/reflect/scala/tools/nsc/io/Path.scala (renamed from src/compiler/scala/tools/nsc/io/Path.scala)4
-rw-r--r--src/reflect/scala/tools/nsc/io/PlainFile.scala (renamed from src/compiler/scala/tools/nsc/io/PlainFile.scala)0
-rw-r--r--src/reflect/scala/tools/nsc/io/Streamable.scala (renamed from src/compiler/scala/tools/nsc/io/Streamable.scala)0
-rw-r--r--src/reflect/scala/tools/nsc/io/VirtualDirectory.scala (renamed from src/compiler/scala/tools/nsc/io/VirtualDirectory.scala)0
-rw-r--r--src/reflect/scala/tools/nsc/io/VirtualFile.scala (renamed from src/compiler/scala/tools/nsc/io/VirtualFile.scala)1
-rw-r--r--src/reflect/scala/tools/nsc/io/ZipArchive.scala (renamed from src/compiler/scala/tools/nsc/io/ZipArchive.scala)1
-rw-r--r--src/scalacheck/org/scalacheck/Arbitrary.scala1
-rw-r--r--src/scalacheck/org/scalacheck/util/Buildable.scala1
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala2
l---------test/disabled/lib1
-rw-r--r--test/disabled/run/code.check18
-rw-r--r--test/files/buildmanager/t2792/t2792.check3
-rw-r--r--test/files/codelib/code.jar.desired.sha12
-rw-r--r--test/files/jvm/actmig-PinS.check18
-rw-r--r--test/files/jvm/actmig-PinS.scala118
-rw-r--r--test/files/jvm/actmig-PinS_1.check18
-rw-r--r--test/files/jvm/actmig-PinS_1.scala130
-rw-r--r--test/files/jvm/actmig-PinS_2.check18
-rw-r--r--test/files/jvm/actmig-PinS_2.scala150
-rw-r--r--test/files/jvm/actmig-PinS_3.check19
-rw-r--r--test/files/jvm/actmig-PinS_3.scala159
-rw-r--r--test/files/jvm/actmig-hierarchy.check2
-rw-r--r--test/files/jvm/actmig-hierarchy.scala44
-rw-r--r--test/files/jvm/actmig-hierarchy_1.check2
-rw-r--r--test/files/jvm/actmig-hierarchy_1.scala41
-rw-r--r--test/files/jvm/actmig-instantiation.check8
-rw-r--r--test/files/jvm/actmig-instantiation.scala91
-rw-r--r--test/files/jvm/actmig-loop-react.check16
-rw-r--r--test/files/jvm/actmig-loop-react.scala170
-rw-r--r--test/files/jvm/actmig-public-methods.check6
-rw-r--r--test/files/jvm/actmig-public-methods.scala69
-rw-r--r--test/files/jvm/actmig-public-methods_1.check6
-rw-r--r--test/files/jvm/actmig-public-methods_1.scala88
-rw-r--r--test/files/jvm/actmig-react-receive.check16
-rw-r--r--test/files/jvm/actmig-react-receive.scala104
-rw-r--r--test/files/jvm/manifests-new.check70
-rw-r--r--test/files/jvm/manifests-new.scala18
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala121
-rw-r--r--test/files/jvm/serialization-new.scala8
-rw-r--r--test/files/jvm/t1652.check2
-rw-r--r--test/files/neg/classtags_contextbound_a.check2
-rw-r--r--test/files/neg/classtags_contextbound_b.check2
-rw-r--r--test/files/neg/classtags_contextbound_b.scala2
-rw-r--r--test/files/neg/classtags_contextbound_c.check2
-rw-r--r--test/files/neg/classtags_contextbound_c.scala2
-rw-r--r--test/files/neg/classtags_dont_use_typetags.check2
-rw-r--r--test/files/neg/classtags_dont_use_typetags.scala2
-rw-r--r--test/files/neg/interop_abstypetags_arenot_classmanifests.check (renamed from test/files/neg/interop_erasuretags_arenot_classmanifests.check)2
-rw-r--r--test/files/neg/interop_abstypetags_arenot_classmanifests.scala11
-rw-r--r--test/files/neg/interop_abstypetags_arenot_classtags.check4
-rw-r--r--test/files/neg/interop_abstypetags_arenot_classtags.scala12
-rw-r--r--test/files/neg/interop_abstypetags_arenot_manifests.check (renamed from test/files/neg/interop_erasuretags_arenot_manifests.check)2
-rw-r--r--test/files/neg/interop_abstypetags_arenot_manifests.scala11
-rw-r--r--test/files/neg/interop_classmanifests_arenot_concretetypetags.check4
-rw-r--r--test/files/neg/interop_classmanifests_arenot_concretetypetags.scala9
-rw-r--r--test/files/neg/interop_classmanifests_arenot_typetags.check4
-rw-r--r--test/files/neg/interop_classmanifests_arenot_typetags.scala11
-rw-r--r--test/files/neg/interop_classtags_arenot_manifests.check7
-rw-r--r--test/files/neg/interop_classtags_arenot_manifests.scala10
-rw-r--r--test/files/neg/interop_erasuretags_arenot_classmanifests.scala9
-rw-r--r--test/files/neg/interop_erasuretags_arenot_manifests.scala9
-rw-r--r--test/files/neg/interop_typetags_arenot_classmanifests.check2
-rw-r--r--test/files/neg/interop_typetags_arenot_classmanifests.scala2
-rw-r--r--test/files/neg/interop_typetags_arenot_classtags.check4
-rw-r--r--test/files/neg/interop_typetags_arenot_classtags.scala12
-rw-r--r--test/files/neg/interop_typetags_arenot_manifests.check4
-rw-r--r--test/files/neg/interop_typetags_arenot_manifests.scala9
-rw-r--r--test/files/neg/interop_typetags_without_classtags_arenot_manifests.check6
-rw-r--r--test/files/neg/interop_typetags_without_classtags_arenot_manifests.scala12
-rw-r--r--test/files/neg/macro-argtype-mismatch.check6
-rw-r--r--test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala12
-rw-r--r--test/files/neg/macro-invalidimpl-f/Impls_1.scala6
-rw-r--r--test/files/neg/macro-invalidimpl-g/Impls_1.scala6
-rw-r--r--test/files/neg/macro-invalidsig-context-bounds.check8
-rw-r--r--test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala5
-rw-r--r--test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidsig-ctx-badtype.check14
-rw-r--r--test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidsig-implicit-params.check2
-rw-r--r--test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala9
-rw-r--r--test/files/neg/macro-invalidsig-params-badtype.check14
-rw-r--r--test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/macro-invalidsig-tparams-badtype.check2
-rw-r--r--test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala2
-rw-r--r--test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala3
-rw-r--r--test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala3
-rw-r--r--test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala5
-rw-r--r--test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala6
-rw-r--r--test/files/neg/macro-noncompilertree.check6
-rw-r--r--test/files/neg/macro-nontree.check6
-rw-r--r--test/files/neg/macro-override-method-overrides-macro/Impls_1.scala6
-rw-r--r--test/files/neg/macro-reify-groundtypetag-hktypeparams-notags.check7
-rw-r--r--test/files/neg/macro-reify-groundtypetag-hktypeparams-notags/Test.scala9
-rw-r--r--test/files/neg/macro-reify-groundtypetag-typeparams-notags.check7
-rw-r--r--test/files/neg/macro-reify-groundtypetag-typeparams-notags/Test.scala9
-rw-r--r--test/files/neg/macro-reify-groundtypetag-usetypetag.check7
-rw-r--r--test/files/neg/macro-reify-groundtypetag-usetypetag/Test.scala9
-rw-r--r--test/files/neg/macro-reify-typetag-hktypeparams-notags.check7
-rw-r--r--test/files/neg/macro-reify-typetag-hktypeparams-notags/Test.scala9
-rw-r--r--test/files/neg/macro-reify-typetag-typeparams-notags.check7
-rw-r--r--test/files/neg/macro-reify-typetag-typeparams-notags/Test.scala (renamed from test/files/run/macro-reify-typetag-typeparams-notags/Test.scala)2
-rw-r--r--test/files/neg/macro-reify-typetag-useabstypetag.check7
-rw-r--r--test/files/neg/macro-reify-typetag-useabstypetag/Test.scala (renamed from test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala)4
-rw-r--r--test/files/neg/macro-without-xmacros-a/Impls_1.scala14
-rw-r--r--test/files/neg/macro-without-xmacros-b/Impls_1.scala14
-rw-r--r--test/files/neg/patmatexhaust.check7
-rw-r--r--test/files/neg/reify_ann2b.check8
-rw-r--r--test/files/neg/reify_ann2b.scala7
-rw-r--r--test/files/neg/reify_metalevel_breach_+0_refers_to_1.check7
-rw-r--r--test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala16
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.check7
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala14
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.check7
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala18
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_1.check7
-rw-r--r--test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala16
-rw-r--r--test/files/neg/reify_nested_inner_refers_to_local.check7
-rw-r--r--test/files/neg/reify_nested_inner_refers_to_local.scala15
-rw-r--r--test/files/neg/switch.flags1
-rw-r--r--test/files/neg/t2775.check8
-rw-r--r--test/files/neg/t3692-new.check2
-rw-r--r--test/files/neg/t3692-new.scala1
-rw-r--r--test/files/neg/t3692-old.check2
-rw-r--r--test/files/neg/t4818.check6
-rw-r--r--test/files/neg/t4818.scala7
-rw-r--r--test/files/neg/t5318.check5
-rw-r--r--test/files/neg/t5318.scala8
-rw-r--r--test/files/neg/t5318b.check5
-rw-r--r--test/files/neg/t5318b.scala8
-rw-r--r--test/files/neg/t5318c.check5
-rw-r--r--test/files/neg/t5318c.scala14
-rw-r--r--test/files/neg/t5334_1.check2
-rw-r--r--test/files/neg/t5334_1.scala5
-rw-r--r--test/files/neg/t5334_2.check2
-rw-r--r--test/files/neg/t5334_2.scala5
-rw-r--r--test/files/neg/t5452-new.check6
-rw-r--r--test/files/neg/t5452-new.scala6
-rw-r--r--test/files/neg/t5452-old.scala2
-rw-r--r--test/files/neg/t5666.check36
-rw-r--r--test/files/neg/t5683.check16
-rw-r--r--test/files/neg/t5683.scala23
-rw-r--r--test/files/neg/t5821.check4
-rw-r--r--test/files/neg/t5821.scala8
-rw-r--r--test/files/neg/t5845.check7
-rw-r--r--test/files/neg/t5845.scala16
-rw-r--r--test/files/neg/t639.check5
-rw-r--r--test/files/neg/virtpatmat_reach_null.check4
-rw-r--r--test/files/neg/virtpatmat_reach_null.flags1
-rw-r--r--test/files/neg/virtpatmat_reach_null.scala19
-rw-r--r--test/files/neg/virtpatmat_reach_sealed_unsealed.check14
-rw-r--r--test/files/neg/virtpatmat_reach_sealed_unsealed.flags1
-rw-r--r--test/files/neg/virtpatmat_reach_sealed_unsealed.scala21
-rw-r--r--test/files/pos/anyval-children.flags1
-rw-r--r--test/files/pos/contextbounds-implicits-new.scala4
-rw-r--r--test/files/pos/exhaustive_heuristics.scala12
-rw-r--r--test/files/pos/implicits-new.scala9
-rw-r--r--test/files/pos/liftcode_polymorphic.scala25
-rw-r--r--test/files/pos/manifest1-new.scala4
-rw-r--r--test/files/pos/nothing_manifest_disambig-new.scala2
-rw-r--r--test/files/pos/spec-constr-new.scala6
-rw-r--r--test/files/pos/spec-doubledef-new.scala4
-rw-r--r--test/files/pos/spec-fields-new.scala6
-rw-r--r--test/files/pos/spec-params-new.scala6
-rw-r--r--test/files/pos/spec-sparsearray-new.scala5
-rw-r--r--test/files/pos/t1381-new.scala4
-rw-r--r--test/files/pos/t2795-new.scala6
-rw-r--r--test/files/pos/t3097.flags1
-rw-r--r--test/files/pos/t3363-new.scala4
-rw-r--r--test/files/pos/t3498-new.scala4
-rw-r--r--test/files/pos/t4579.flags1
-rw-r--r--test/files/pos/t4579.scala518
-rw-r--r--test/files/pos/t4911.flags1
-rw-r--r--test/files/pos/t4911.scala16
-rw-r--r--test/files/pos/t5041.scala9
-rw-r--r--test/files/pos/t5223.scala4
-rw-r--r--test/files/pos/t5305.scala2
-rw-r--r--test/files/pos/t531.scala4
-rw-r--r--test/files/pos/t5313.scala30
-rw-r--r--test/files/pos/t532.scala4
-rw-r--r--test/files/pos/t5399.scala45
-rw-r--r--test/files/pos/t5769.scala5
-rw-r--r--test/files/pos/t5809.scala11
-rw-r--r--test/files/pos/t5829.scala18
-rw-r--r--test/files/pos/t5853.scala55
-rw-r--r--test/files/pos/t5862.scala38
-rw-r--r--test/files/pos/typetags.scala12
-rw-r--r--test/files/pos/value-class-override-no-spec.flags1
-rw-r--r--test/files/pos/value-class-override-no-spec.scala9
-rw-r--r--test/files/pos/value-class-override-spec.scala9
-rw-r--r--test/files/pos/virtpatmat_reach_const.scala11
-rw-r--r--test/files/presentation/ide-bug-1000531.check2
-rw-r--r--test/files/presentation/memory-leaks/MemoryLeaksTest.scala44
-rw-r--r--test/files/run/Course-2002-01-msil.check34
-rw-r--r--test/files/run/Course-2002-02-msil.check187
-rw-r--r--test/files/run/Course-2002-03-msil.check67
-rw-r--r--test/files/run/Course-2002-04-msil.check64
-rw-r--r--test/files/run/Course-2002-08-msil.check171
-rw-r--r--test/files/run/Course-2002-09-msil.check50
-rw-r--r--test/files/run/Course-2002-10-msil.check46
-rw-r--r--test/files/run/absoverride-msil.check20
-rw-r--r--test/files/run/abstypetags_core.check28
-rw-r--r--test/files/run/abstypetags_core.scala32
-rw-r--r--test/files/run/arrayclone-new.scala6
-rw-r--r--test/files/run/arraytags_basic.check36
-rw-r--r--test/files/run/arraytags_basic.scala22
-rw-r--r--test/files/run/arraytags_core.check48
-rw-r--r--test/files/run/arraytags_core.scala50
-rw-r--r--test/files/run/arraytags_usage.check3
-rw-r--r--test/files/run/arraytags_usage.scala15
-rw-r--r--test/files/run/bitsets-msil.check33
-rw-r--r--test/files/run/boolord-msil.check4
-rw-r--r--test/files/run/bugs-msil.check96
-rw-r--r--test/files/run/caseClassHash.scala4
-rw-r--r--test/files/run/classtags_contextbound.scala2
-rw-r--r--test/files/run/classtags_core.check60
-rw-r--r--test/files/run/classtags_core.scala6
-rw-r--r--test/files/run/classtags_multi.scala2
-rw-r--r--test/files/run/classtags_use_concretetypetags.scala3
-rw-r--r--test/files/run/concretetypetags_core.check60
-rw-r--r--test/files/run/concretetypetags_core.scala62
-rw-r--r--test/files/run/concretetypetags_multi.check10
-rw-r--r--test/files/run/concretetypetags_multi.scala12
-rw-r--r--test/files/run/ctries-new/main.scala6
-rw-r--r--test/files/run/ctries-old/main.scala12
-rw-r--r--test/files/run/dynamic-proxy.check20
-rw-r--r--test/files/run/dynamic-proxy.flags1
-rw-r--r--test/files/run/dynamic-proxy.scala72
-rw-r--r--test/files/run/erasuretags_abstract.check4
-rw-r--r--test/files/run/erasuretags_abstract.scala9
-rw-r--r--test/files/run/erasuretags_basic.check24
-rw-r--r--test/files/run/erasuretags_basic.scala21
-rw-r--r--test/files/run/erasuretags_core.check32
-rw-r--r--test/files/run/erasuretags_core.scala34
-rw-r--r--test/files/run/erasuretags_usage.scala12
-rw-r--r--test/files/run/existentials-in-compiler.scala9
-rw-r--r--test/files/run/existentials3-new.check48
-rw-r--r--test/files/run/existentials3-new.scala14
-rw-r--r--test/files/run/freetypes_false_alarm1.check1
-rw-r--r--test/files/run/freetypes_false_alarm1.scala10
-rw-r--r--test/files/run/freetypes_false_alarm2.check1
-rw-r--r--test/files/run/freetypes_false_alarm2.scala8
-rw-r--r--test/files/run/getClassTest-new.scala6
-rw-r--r--test/files/run/impconvtimes-msil.check1
-rw-r--r--test/files/run/infix-msil.check2
-rw-r--r--test/files/run/interop_classmanifests_arepartially_typetags.check6
-rw-r--r--test/files/run/interop_classmanifests_arepartially_typetags.scala10
-rw-r--r--test/files/run/interop_classtags_are_classmanifests.check3
-rw-r--r--test/files/run/interop_classtags_are_classmanifests.scala10
-rw-r--r--test/files/run/interop_concretetypetags_are_classmanifests.scala9
-rw-r--r--test/files/run/interop_concretetypetags_are_manifests.scala9
-rw-r--r--test/files/run/interop_manifests_are_abstypetags.check (renamed from test/files/run/interop_concretetypetags_are_classmanifests.check)0
-rw-r--r--test/files/run/interop_manifests_are_abstypetags.scala11
-rw-r--r--test/files/run/interop_manifests_are_classtags.check6
-rw-r--r--test/files/run/interop_manifests_are_classtags.scala8
-rw-r--r--test/files/run/interop_manifests_are_concretetypetags.check6
-rw-r--r--test/files/run/interop_manifests_are_concretetypetags.scala10
-rw-r--r--test/files/run/interop_manifests_are_typetags.check9
-rw-r--r--test/files/run/interop_manifests_are_typetags.scala5
-rw-r--r--test/files/run/interop_typetags_are_manifests.check (renamed from test/files/run/interop_concretetypetags_are_manifests.check)2
-rw-r--r--test/files/run/interop_typetags_are_manifests.scala12
-rw-r--r--test/files/run/iq-msil.check12
-rw-r--r--test/files/run/macro-abort-fresh/Macros_1.scala2
-rw-r--r--test/files/run/macro-abort-fresh/Test_2.scala6
-rw-r--r--test/files/run/macro-basic-ma-md-mi/Impls_1.scala14
-rw-r--r--test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala12
-rw-r--r--test/files/run/macro-basic-mamd-mi/Impls_1.scala14
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Impls_1.scala4
-rw-r--r--test/files/run/macro-declared-in-annotation/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-anonymous/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-block/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-class-class/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-class-object/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-class/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-default-param/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-declared-in-method/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-object-class/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-object-object/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-object/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-package-object/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-refinement/Impls_1.scala6
-rw-r--r--test/files/run/macro-declared-in-trait/Impls_1.scala6
-rw-r--r--test/files/run/macro-def-infer-return-type-b/Test_2.scala8
-rw-r--r--test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala3
-rw-r--r--test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-multiple-arglists/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-nullary-generic.check10
-rw-r--r--test/files/run/macro-expand-nullary-generic/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-overload/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-override/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-recursive/Impls_1.scala10
-rw-r--r--test/files/run/macro-expand-tparams-explicit.check2
-rw-r--r--test/files/run/macro-expand-tparams-explicit/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-implicit.check4
-rw-r--r--test/files/run/macro-expand-tparams-implicit/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-optional/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-tparams-prefix-a.check8
-rw-r--r--test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-prefix-b.check4
-rw-r--r--test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-prefix-c1.check6
-rw-r--r--test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-prefix-c2.check6
-rw-r--r--test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala7
-rw-r--r--test/files/run/macro-expand-tparams-prefix-d1.check6
-rw-r--r--test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala11
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala6
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala6
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala6
-rw-r--r--test/files/run/macro-impl-default-params/Impls_Macros_1.scala9
-rw-r--r--test/files/run/macro-impl-rename-context/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala6
-rw-r--r--test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-invalidret-nontypeable/Test_2.scala6
-rw-r--r--test/files/run/macro-invalidusage-badret/Test_2.scala8
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams.check3
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams.flags (renamed from test/files/neg/macro-argtype-mismatch.flags)0
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala13
-rw-r--r--test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala8
-rw-r--r--test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-invalidusage-partialapplication/Test_2.scala6
-rw-r--r--test/files/run/macro-openmacros/Impls_Macros_1.scala12
-rw-r--r--test/files/run/macro-range/Common_1.scala3
-rw-r--r--test/files/run/macro-range/Expansion_Impossible_2.scala10
-rw-r--r--test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala6
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala6
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala9
-rw-r--r--test/files/run/macro-reify-abstypetag-notypeparams.check2
-rw-r--r--test/files/run/macro-reify-abstypetag-notypeparams/Test.scala6
-rw-r--r--test/files/run/macro-reify-abstypetag-typeparams-notags.check2
-rw-r--r--test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala9
-rw-r--r--test/files/run/macro-reify-abstypetag-typeparams-tags.check2
-rw-r--r--test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala9
-rw-r--r--test/files/run/macro-reify-abstypetag-usetypetag.check2
-rw-r--r--test/files/run/macro-reify-abstypetag-usetypetag/Test.scala9
-rw-r--r--test/files/run/macro-reify-basic/Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-eval-eval.flags1
-rw-r--r--test/files/run/macro-reify-eval-outside-reify.flags1
-rw-r--r--test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala12
-rw-r--r--test/files/run/macro-reify-eval-outside-reify/Test_2.scala5
-rw-r--r--test/files/run/macro-reify-freevars.check6
-rw-r--r--test/files/run/macro-reify-freevars/Macros_1.scala11
-rw-r--r--test/files/run/macro-reify-freevars/Test_2.scala6
-rw-r--r--test/files/run/macro-reify-groundtypetag-notypeparams.check2
-rw-r--r--test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala6
-rw-r--r--test/files/run/macro-reify-groundtypetag-typeparams-tags.check2
-rw-r--r--test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala9
-rw-r--r--test/files/run/macro-reify-nested-a/Impls_Macros_1.scala30
-rw-r--r--test/files/run/macro-reify-nested-b/Impls_Macros_1.scala30
-rw-r--r--test/files/run/macro-reify-splice-outside-reify.check (renamed from test/files/run/macro-reify-eval-outside-reify.check)0
-rw-r--r--test/files/run/macro-reify-splice-outside-reify.flags (renamed from test/files/neg/macro-noncompilertree.flags)0
-rw-r--r--test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala24
-rw-r--r--test/files/run/macro-reify-splice-outside-reify/Test_2.scala (renamed from test/files/run/macro-reify-value-outside-reify/Test_2.scala)6
-rw-r--r--test/files/run/macro-reify-splice-splice.check (renamed from test/files/run/macro-reify-eval-eval.check)0
-rw-r--r--test/files/run/macro-reify-splice-splice.flags (renamed from test/files/neg/macro-nontree.flags)0
-rw-r--r--test/files/run/macro-reify-splice-splice/Macros_1.scala (renamed from test/files/run/macro-reify-eval-eval/Macros_1.scala)2
-rw-r--r--test/files/run/macro-reify-splice-splice/Test_2.scala (renamed from test/files/run/macro-reify-eval-eval/Test_2.scala)0
-rw-r--r--test/files/run/macro-reify-tagful-a/Macros_1.scala3
-rw-r--r--test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-tagless-a/Test_2.scala6
-rw-r--r--test/files/run/macro-reify-typetag-notypeparams.check4
-rw-r--r--test/files/run/macro-reify-typetag-notypeparams/Test.scala2
-rw-r--r--test/files/run/macro-reify-typetag-typeparams-notags.check2
-rw-r--r--test/files/run/macro-reify-typetag-typeparams-tags.check4
-rw-r--r--test/files/run/macro-reify-typetag-typeparams-tags/Test.scala2
-rw-r--r--test/files/run/macro-reify-typetag-usegroundtypetag.check2
-rw-r--r--test/files/run/macro-reify-unreify.check2
-rw-r--r--test/files/run/macro-reify-unreify/Macros_1.scala10
-rw-r--r--test/files/run/macro-reify-value-outside-reify.check1
-rw-r--r--test/files/run/macro-reify-value-outside-reify.flags1
-rw-r--r--test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala12
-rw-r--r--test/files/run/macro-repl-basic.check108
-rw-r--r--test/files/run/macro-repl-basic.scala12
-rw-r--r--test/files/run/macro-rettype-mismatch.check5
-rw-r--r--test/files/run/macro-rettype-mismatch.flags1
-rw-r--r--test/files/run/macro-settings/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-sip19-revised/Impls_Macros_1.scala10
-rw-r--r--test/files/run/macro-sip19/Impls_Macros_1.scala6
-rw-r--r--test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled.check38
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala18
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.check38
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala20
-rw-r--r--test/files/run/macro-undetparams-consfromsls.check6
-rw-r--r--test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala11
-rw-r--r--test/files/run/macro-undetparams-implicitval.check2
-rw-r--r--test/files/run/macro-undetparams-implicitval/Test.scala2
-rw-r--r--test/files/run/macro-undetparams-macroitself.check4
-rw-r--r--test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala3
-rw-r--r--test/files/run/manifests-new.scala16
-rw-r--r--test/files/run/misc-msil.check33
-rw-r--r--test/files/run/newTags.check5
-rw-r--r--test/files/run/newTags.scala14
-rw-r--r--test/files/run/patmat_unapp_abstype-new.scala21
-rw-r--r--test/files/run/primitive-sigs-2-new.check2
-rw-r--r--test/files/run/primitive-sigs-2-new.scala5
-rw-r--r--test/files/run/promotion-msil.check4
-rw-r--r--test/files/run/reflect-overload.scala21
-rw-r--r--test/files/run/reflection-constructormirror-inner-badpath.check2
-rw-r--r--test/files/run/reflection-constructormirror-inner-badpath.scala32
-rw-r--r--test/files/run/reflection-constructormirror-inner-good.check1
-rw-r--r--test/files/run/reflection-constructormirror-inner-good.scala26
-rw-r--r--test/files/run/reflection-constructormirror-nested-badpath.check2
-rw-r--r--test/files/run/reflection-constructormirror-nested-badpath.scala32
-rw-r--r--test/files/run/reflection-constructormirror-nested-good.check1
-rw-r--r--test/files/run/reflection-constructormirror-nested-good.scala26
-rw-r--r--test/files/run/reflection-constructormirror-toplevel-badpath.check2
-rw-r--r--test/files/run/reflection-constructormirror-toplevel-badpath.scala33
-rw-r--r--test/files/run/reflection-constructormirror-toplevel-good.check1
-rw-r--r--test/files/run/reflection-constructormirror-toplevel-good.scala27
-rw-r--r--test/files/run/reflection-fieldmirror-ctorparam.check1
-rw-r--r--test/files/run/reflection-fieldmirror-ctorparam.scala21
-rw-r--r--test/files/run/reflection-fieldmirror-getsetval.check2
-rw-r--r--test/files/run/reflection-fieldmirror-getsetval.scala24
-rw-r--r--test/files/run/reflection-fieldmirror-getsetvar.check2
-rw-r--r--test/files/run/reflection-fieldmirror-getsetvar.scala18
-rw-r--r--test/files/run/reflection-fieldmirror-nmelocalsuffixstring.check1
-rw-r--r--test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala16
-rw-r--r--test/files/run/reflection-fieldmirror-privatethis.check3
-rw-r--r--test/files/run/reflection-fieldmirror-privatethis.scala19
-rw-r--r--test/files/run/reflection-fieldmirror-sanitycheck.check6
-rw-r--r--test/files/run/reflection-fieldmirror-sanitycheck.scala22
-rw-r--r--test/files/run/reflection-implClass-new.scala38
-rw-r--r--test/files/run/reflection-implClass-old.scala38
-rw-r--r--test/files/run/reflection-implClass.scala40
-rw-r--r--test/files/run/reflection-modulemirror-inner-badpath.check2
-rw-r--r--test/files/run/reflection-modulemirror-inner-badpath.scala24
-rw-r--r--test/files/run/reflection-modulemirror-inner-good.check2
-rw-r--r--test/files/run/reflection-modulemirror-inner-good.scala23
-rw-r--r--test/files/run/reflection-modulemirror-nested-badpath.check2
-rw-r--r--test/files/run/reflection-modulemirror-nested-badpath.scala26
-rw-r--r--test/files/run/reflection-modulemirror-nested-good.check2
-rw-r--r--test/files/run/reflection-modulemirror-nested-good.scala24
-rw-r--r--test/files/run/reflection-modulemirror-toplevel-badpath.check2
-rw-r--r--test/files/run/reflection-modulemirror-toplevel-badpath.scala26
-rw-r--r--test/files/run/reflection-modulemirror-toplevel-good.check1
-rw-r--r--test/files/run/reflection-modulemirror-toplevel-good.scala20
-rw-r--r--test/files/run/reflection-repl.check9
-rw-r--r--test/files/run/reflection-repl.scala7
-rw-r--r--test/files/run/reflection-simple.scala3
-rw-r--r--test/files/run/reflinit.check1
-rw-r--r--test/files/run/reflinit.scala6
-rw-r--r--test/files/run/reify-repl-fail-gracefully.check42
-rw-r--r--test/files/run/reify-repl-fail-gracefully.scala2
-rw-r--r--test/files/run/reify_ann1a.check12
-rw-r--r--test/files/run/reify_ann1a.scala7
-rw-r--r--test/files/run/reify_ann1b.scala7
-rw-r--r--test/files/run/reify_ann2a.check16
-rw-r--r--test/files/run/reify_ann2a.scala7
-rw-r--r--test/files/run/reify_ann3.scala9
-rw-r--r--test/files/run/reify_ann4.scala9
-rw-r--r--test/files/run/reify_ann5.scala9
-rw-r--r--test/files/run/reify_anonymous.scala5
-rw-r--r--test/files/run/reify_classfileann_a.scala7
-rw-r--r--test/files/run/reify_classfileann_b.scala7
-rw-r--r--test/files/run/reify_closure1.scala9
-rw-r--r--test/files/run/reify_closure2a.scala9
-rw-r--r--test/files/run/reify_closure3a.scala9
-rw-r--r--test/files/run/reify_closure4a.scala9
-rw-r--r--test/files/run/reify_closure5a.scala9
-rw-r--r--test/files/run/reify_closure6.scala7
-rw-r--r--test/files/run/reify_closure7.scala9
-rw-r--r--test/files/run/reify_closure8a.scala9
-rw-r--r--test/files/run/reify_closure8b.check2
-rw-r--r--test/files/run/reify_closure8b.scala9
-rw-r--r--test/files/run/reify_closures10.scala9
-rw-r--r--test/files/run/reify_complex.scala5
-rw-r--r--test/files/run/reify_copypaste1.check2
-rw-r--r--test/files/run/reify_copypaste1.scala19
-rw-r--r--test/files/run/reify_copypaste2.check1
-rw-r--r--test/files/run/reify_copypaste2.scala10
-rw-r--r--test/files/run/reify_csv.scala3
-rw-r--r--test/files/run/reify_extendbuiltins.scala5
-rw-r--r--test/files/run/reify_for1.scala5
-rw-r--r--test/files/run/reify_fors_newpatmat.check (renamed from test/files/run/reify_fors.check)0
-rw-r--r--test/files/run/reify_fors_newpatmat.scala (renamed from test/files/run/reify_fors.scala)5
-rw-r--r--test/files/run/reify_fors_oldpatmat.check5
-rw-r--r--test/files/run/reify_fors_oldpatmat.flags (renamed from test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check)0
-rw-r--r--test/files/run/reify_fors_oldpatmat.scala101
-rw-r--r--test/files/run/reify_generic.scala5
-rw-r--r--test/files/run/reify_generic2.scala5
-rw-r--r--test/files/run/reify_getter.scala9
-rw-r--r--test/files/run/reify_implicits-new.scala8
-rw-r--r--test/files/run/reify_implicits-old.scala5
-rw-r--r--test/files/run/reify_inheritance.scala5
-rw-r--r--test/files/run/reify_inner1.scala5
-rw-r--r--test/files/run/reify_inner2.scala5
-rw-r--r--test/files/run/reify_inner3.scala5
-rw-r--r--test/files/run/reify_inner4.scala5
-rw-r--r--test/files/run/reify_lazyevaluation.scala3
-rw-r--r--test/files/run/reify_maps_newpatmat.check (renamed from test/files/run/reify_maps.check)0
-rw-r--r--test/files/run/reify_maps_newpatmat.scala (renamed from test/files/run/reify_maps.scala)5
-rw-r--r--test/files/run/reify_maps_oldpatmat.check4
-rw-r--r--test/files/run/reify_maps_oldpatmat.flags (renamed from test/files/run/reify_fors.flags)0
-rw-r--r--test/files/run/reify_maps_oldpatmat.scala20
-rw-r--r--test/files/run/reify_metalevel_breach_+0_refers_to_1.scala11
-rw-r--r--test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala11
-rw-r--r--test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala12
-rw-r--r--test/files/run/reify_metalevel_breach_-1_refers_to_1.scala11
-rw-r--r--test/files/run/reify_nested_inner_refers_to_global.scala11
-rw-r--r--test/files/run/reify_nested_inner_refers_to_local.scala11
-rw-r--r--test/files/run/reify_nested_outer_refers_to_global.scala11
-rw-r--r--test/files/run/reify_nested_outer_refers_to_local.scala11
-rw-r--r--test/files/run/reify_newimpl_01.scala4
-rw-r--r--test/files/run/reify_newimpl_02.scala4
-rw-r--r--test/files/run/reify_newimpl_03.scala4
-rw-r--r--test/files/run/reify_newimpl_04.scala4
-rw-r--r--test/files/run/reify_newimpl_05.scala4
-rw-r--r--test/files/run/reify_newimpl_06.scala4
-rw-r--r--test/files/run/reify_newimpl_09.scala4
-rw-r--r--test/files/run/reify_newimpl_10.scala4
-rw-r--r--test/files/run/reify_newimpl_11.check4
-rw-r--r--test/files/run/reify_newimpl_11.scala4
-rw-r--r--test/files/run/reify_newimpl_12.scala4
-rw-r--r--test/files/run/reify_newimpl_13.check4
-rw-r--r--test/files/run/reify_newimpl_13.scala4
-rw-r--r--test/files/run/reify_newimpl_14.scala4
-rw-r--r--test/files/run/reify_newimpl_15.scala4
-rw-r--r--test/files/run/reify_newimpl_16.scala4
-rw-r--r--test/files/run/reify_newimpl_17.check4
-rw-r--r--test/files/run/reify_newimpl_17.scala4
-rw-r--r--test/files/run/reify_newimpl_18.scala4
-rw-r--r--test/files/run/reify_newimpl_19.check4
-rw-r--r--test/files/run/reify_newimpl_19.scala4
-rw-r--r--test/files/run/reify_newimpl_20.scala4
-rw-r--r--test/files/run/reify_newimpl_21.scala4
-rw-r--r--test/files/run/reify_newimpl_22.check12
-rw-r--r--test/files/run/reify_newimpl_22.scala6
-rw-r--r--test/files/run/reify_newimpl_23.check12
-rw-r--r--test/files/run/reify_newimpl_23.scala6
-rw-r--r--test/files/run/reify_newimpl_24.check24
-rw-r--r--test/files/run/reify_newimpl_24.scala16
-rw-r--r--test/files/run/reify_newimpl_25.check8
-rw-r--r--test/files/run/reify_newimpl_25.scala4
-rw-r--r--test/files/run/reify_newimpl_26.check12
-rw-r--r--test/files/run/reify_newimpl_26.scala6
-rw-r--r--test/files/run/reify_newimpl_27.scala4
-rw-r--r--test/files/run/reify_newimpl_28.scala4
-rw-r--r--test/files/run/reify_newimpl_29.scala4
-rw-r--r--test/files/run/reify_newimpl_30.scala4
-rw-r--r--test/files/run/reify_newimpl_31.scala4
-rw-r--r--test/files/run/reify_newimpl_32.scala4
-rw-r--r--test/files/run/reify_newimpl_33.scala4
-rw-r--r--test/files/run/reify_newimpl_34.scala4
-rw-r--r--test/files/run/reify_newimpl_35.check17
-rw-r--r--test/files/run/reify_newimpl_35.scala (renamed from test/pending/run/reify_newimpl_35.scala)2
-rw-r--r--test/files/run/reify_newimpl_36.scala3
-rw-r--r--test/files/run/reify_newimpl_37.scala3
-rw-r--r--test/files/run/reify_newimpl_38.scala3
-rw-r--r--test/files/run/reify_newimpl_39.scala3
-rw-r--r--test/files/run/reify_newimpl_40.scala3
-rw-r--r--test/files/run/reify_newimpl_41.scala3
-rw-r--r--test/files/run/reify_newimpl_42.scala3
-rw-r--r--test/files/run/reify_newimpl_43.scala3
-rw-r--r--test/files/run/reify_newimpl_44.scala3
-rw-r--r--test/files/run/reify_newimpl_45.scala11
-rw-r--r--test/files/run/reify_newimpl_47.scala8
-rw-r--r--test/files/run/reify_newimpl_48.scala8
-rw-r--r--test/files/run/reify_newimpl_49.scala3
-rw-r--r--test/files/run/reify_newimpl_50.scala3
-rw-r--r--test/files/run/reify_newimpl_51.scala3
-rw-r--r--test/files/run/reify_newimpl_52.scala3
-rw-r--r--test/files/run/reify_printf.scala24
-rw-r--r--test/files/run/reify_properties.scala3
-rw-r--r--test/files/run/reify_sort.scala5
-rw-r--r--test/files/run/reify_sort1.scala5
-rw-r--r--test/files/run/reify_this.scala5
-rw-r--r--test/files/run/reify_timeofday.scala5
-rw-r--r--test/files/run/reify_typerefs_1a.scala9
-rw-r--r--test/files/run/reify_typerefs_1b.scala9
-rw-r--r--test/files/run/reify_typerefs_2a.scala9
-rw-r--r--test/files/run/reify_typerefs_2b.scala9
-rw-r--r--test/files/run/reify_typerefs_3a.scala9
-rw-r--r--test/files/run/reify_typerefs_3b.scala9
-rw-r--r--test/files/run/reify_varargs.scala5
-rw-r--r--test/files/run/repl-colon-type.check16
-rw-r--r--test/files/run/repl-type-verbose.check32
-rw-r--r--test/files/run/richs-msil.check66
-rw-r--r--test/files/run/runtime-msil.check64
-rw-r--r--test/files/run/runtimeEval1.check (renamed from test/files/run/t5273_2a.check)0
-rw-r--r--test/files/run/runtimeEval1.scala9
-rw-r--r--test/files/run/runtimeEval2.check1
-rw-r--r--test/files/run/runtimeEval2.scala11
-rw-r--r--test/files/run/t0421-new.scala6
-rw-r--r--test/files/run/t0677-new.scala6
-rw-r--r--test/files/run/t1195-new.check12
-rw-r--r--test/files/run/t1195-new.scala6
-rw-r--r--test/files/run/t2236-new.scala4
-rw-r--r--test/files/run/t2886.scala4
-rw-r--r--test/files/run/t3507-new.check2
-rw-r--r--test/files/run/t3507-new.scala4
-rw-r--r--test/files/run/t4110-new.check4
-rw-r--r--test/files/run/t4110-new.scala4
-rw-r--r--test/files/run/t4216.check71
-rw-r--r--test/files/run/t4216.scala3
-rw-r--r--test/files/run/t5224.scala2
-rw-r--r--test/files/run/t5225_1.scala2
-rw-r--r--test/files/run/t5225_2.scala2
-rw-r--r--test/files/run/t5229_1.scala5
-rw-r--r--test/files/run/t5229_2.scala9
-rw-r--r--test/files/run/t5230.scala9
-rw-r--r--test/files/run/t5256a.check8
-rw-r--r--test/files/run/t5256a.scala12
-rw-r--r--test/files/run/t5256b.check6
-rw-r--r--test/files/run/t5256b.scala12
-rw-r--r--test/files/run/t5256c.check6
-rw-r--r--test/files/run/t5256c.scala12
-rw-r--r--test/files/run/t5256d.check26
-rw-r--r--test/files/run/t5256d.scala13
-rw-r--r--test/files/run/t5256e.check8
-rw-r--r--test/files/run/t5256e.scala13
-rw-r--r--test/files/run/t5256f.check14
-rw-r--r--test/files/run/t5256f.scala17
-rw-r--r--test/files/run/t5256g.check3
-rw-r--r--test/files/run/t5256g.scala13
-rw-r--r--test/files/run/t5256h.check7
-rw-r--r--test/files/run/t5256h.scala10
-rw-r--r--test/files/run/t5258a.scala3
-rw-r--r--test/files/run/t5266_1.scala7
-rw-r--r--test/files/run/t5266_2.scala9
-rw-r--r--test/files/run/t5269.scala5
-rw-r--r--test/files/run/t5270.scala5
-rw-r--r--test/files/run/t5271_1.scala10
-rw-r--r--test/files/run/t5271_2.scala10
-rw-r--r--test/files/run/t5271_3.scala10
-rw-r--r--test/files/run/t5271_4.scala5
-rw-r--r--test/files/run/t5272_1_newpatmat.check (renamed from test/files/run/t5272_1.check)0
-rw-r--r--test/files/run/t5272_1_newpatmat.scala (renamed from test/files/run/t5272_1.scala)5
-rw-r--r--test/files/run/t5272_1_oldpatmat.check1
-rw-r--r--test/files/run/t5272_1_oldpatmat.flags (renamed from test/files/run/reify_maps.flags)0
-rw-r--r--test/files/run/t5272_1_oldpatmat.scala11
-rw-r--r--test/files/run/t5272_2_newpatmat.check (renamed from test/files/run/t5272_2.check)0
-rw-r--r--test/files/run/t5272_2_newpatmat.scala (renamed from test/files/run/t5272_2.scala)5
-rw-r--r--test/files/run/t5272_2_oldpatmat.check1
-rw-r--r--test/files/run/t5272_2_oldpatmat.flags (renamed from test/files/run/t5272_1.flags)0
-rw-r--r--test/files/run/t5272_2_oldpatmat.scala10
-rw-r--r--test/files/run/t5273_1_newpatmat.check (renamed from test/files/run/t5273_1.check)0
-rw-r--r--test/files/run/t5273_1_newpatmat.scala (renamed from test/files/run/t5273_1.scala)5
-rw-r--r--test/files/run/t5273_1_oldpatmat.check1
-rw-r--r--test/files/run/t5273_1_oldpatmat.flags (renamed from test/files/run/t5272_2.flags)0
-rw-r--r--test/files/run/t5273_1_oldpatmat.scala11
-rw-r--r--test/files/run/t5273_2a_newpatmat.check1
-rw-r--r--test/files/run/t5273_2a_newpatmat.scala (renamed from test/files/run/t5273_2a.scala)5
-rw-r--r--test/files/run/t5273_2a_oldpatmat.check1
-rw-r--r--test/files/run/t5273_2a_oldpatmat.flags (renamed from test/files/run/t5273_1.flags)0
-rw-r--r--test/files/run/t5273_2a_oldpatmat.scala9
-rw-r--r--test/files/run/t5273_2b.flags0
-rw-r--r--test/files/run/t5273_2b_newpatmat.check (renamed from test/files/run/t5273_2b.check)0
-rw-r--r--test/files/run/t5273_2b_newpatmat.scala (renamed from test/files/run/t5273_2b.scala)5
-rw-r--r--test/files/run/t5273_2b_oldpatmat.check1
-rw-r--r--test/files/run/t5273_2b_oldpatmat.flags (renamed from test/files/run/t5273_2a.flags)0
-rw-r--r--test/files/run/t5273_2b_oldpatmat.scala10
-rw-r--r--test/files/run/t5274_1.scala5
-rw-r--r--test/files/run/t5274_2.scala5
-rw-r--r--test/files/run/t5275.scala5
-rw-r--r--test/files/run/t5276_1a.scala5
-rw-r--r--test/files/run/t5276_1b.scala5
-rw-r--r--test/files/run/t5276_2a.scala5
-rw-r--r--test/files/run/t5276_2b.scala5
-rw-r--r--test/files/run/t5277_1.scala5
-rw-r--r--test/files/run/t5277_2.scala5
-rw-r--r--test/files/run/t5279.scala5
-rw-r--r--test/files/run/t5334_1.scala9
-rw-r--r--test/files/run/t5334_2.scala9
-rw-r--r--test/files/run/t5335.scala5
-rw-r--r--test/files/run/t5415.scala8
-rw-r--r--test/files/run/t5419.scala2
-rw-r--r--test/files/run/t5423.scala10
-rw-r--r--test/files/run/t5428.check1
-rw-r--r--test/files/run/t5428.scala29
-rw-r--r--test/files/run/t5704.check2
-rw-r--r--test/files/run/t5704.scala9
-rw-r--r--test/files/run/t5713/Impls_Macros_1.scala5
-rw-r--r--test/files/run/t5843.check9
-rw-r--r--test/files/run/t5843.scala15
-rw-r--r--test/files/run/t5857.scala45
-rw-r--r--test/files/run/t5867.check1
-rw-r--r--test/files/run/t5867.scala14
-rw-r--r--test/files/run/t5879.check16
-rw-r--r--test/files/run/t5879.scala74
-rw-r--r--test/files/run/t5880.scala41
-rw-r--r--test/files/run/toolbox_console_reporter.scala4
-rw-r--r--test/files/run/toolbox_default_reporter_is_silent.scala9
-rw-r--r--test/files/run/toolbox_silent_reporter.scala7
-rw-r--r--test/files/run/toolbox_typecheck_implicitsdisabled.check2
-rw-r--r--test/files/run/toolbox_typecheck_implicitsdisabled.scala7
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.check38
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.scala21
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.check38
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.scala19
-rw-r--r--test/files/run/triemap-hash.scala46
-rw-r--r--test/files/run/tuples-msil.check2
-rw-r--r--test/files/run/typetags_core.check32
-rw-r--r--test/files/run/typetags_core.scala34
-rw-r--r--test/files/run/typetags_multi.check5
-rw-r--r--test/files/run/typetags_multi.scala7
-rw-r--r--test/files/run/virtpatmat_typetag.check10
-rw-r--r--test/files/run/virtpatmat_typetag.flags1
-rw-r--r--test/files/run/virtpatmat_typetag.scala36
-rw-r--r--test/files/scalacheck/array-new.scala5
-rw-r--r--test/files/specialized/spec-matrix-new.scala8
-rw-r--r--test/files/speclib/instrumented.jar.desired.sha12
-rw-r--r--test/instrumented/library/scala/runtime/ScalaRunTime.scala33
-rw-r--r--test/instrumented/srt.patch69
-rwxr-xr-xtest/partest2
-rw-r--r--test/pending/jvm/t1464.check1
-rw-r--r--test/pending/neg/reify_packed.scala9
-rw-r--r--test/pending/pos/inference.scala20
-rw-r--r--test/pending/run/macro-expand-default.flags2
-rw-r--r--test/pending/run/macro-expand-default/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-implicit-macro-defeats-type-inference.check4
-rw-r--r--test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala6
-rw-r--r--test/pending/run/macro-expand-implicit-macro-has-context-bound.flags1
-rw-r--r--test/pending/run/macro-expand-macro-has-context-bound.check (renamed from test/pending/run/macro-expand-implicit-macro-has-context-bound.check)0
-rw-r--r--test/pending/run/macro-expand-macro-has-context-bound.flags (renamed from test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags)0
-rw-r--r--test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala (renamed from test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala)4
-rw-r--r--test/pending/run/macro-expand-macro-has-context-bound/Macros_Test_2.scala (renamed from test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala)0
-rw-r--r--test/pending/run/macro-expand-named.flags2
-rw-r--r--test/pending/run/macro-expand-named/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-e1.flags2
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala2
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-f1.flags2
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala4
-rw-r--r--test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala2
-rw-r--r--test/pending/run/macro-quasiinvalidbody-a.flags2
-rw-r--r--test/pending/run/macro-quasiinvalidbody-b.flags2
-rw-r--r--test/pending/run/macro-reify-array.flags2
-rw-r--r--test/pending/run/macro-reify-array/Macros_1.scala2
-rw-r--r--test/pending/run/macro-reify-eval-vs-value.flags1
-rw-r--r--test/pending/run/macro-reify-eval-vs-value/Macros_1.scala25
-rw-r--r--test/pending/run/macro-reify-eval-vs-value/Test_2.scala5
-rw-r--r--test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala8
-rw-r--r--test/pending/run/macro-reify-tagful-b.flags2
-rw-r--r--test/pending/run/macro-reify-tagful-b/Macros_1.scala2
-rw-r--r--test/pending/run/macro-reify-tagless-b.flags2
-rw-r--r--test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala2
-rw-r--r--test/pending/run/macro-reify-tagless-b/Test_2.scala6
-rw-r--r--test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala2
-rw-r--r--test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala2
-rw-r--r--test/pending/run/reify_addressbook.scala3
-rw-r--r--test/pending/run/reify_brainf_ck.scala3
-rw-r--r--test/pending/run/reify_callccinterpreter.scala3
-rw-r--r--test/pending/run/reify_closure2b.scala11
-rw-r--r--test/pending/run/reify_closure3b.scala11
-rw-r--r--test/pending/run/reify_closure4b.scala11
-rw-r--r--test/pending/run/reify_closure5b.scala11
-rw-r--r--test/pending/run/reify_closure9a.scala10
-rw-r--r--test/pending/run/reify_closure9b.scala10
-rw-r--r--test/pending/run/reify_closures11.scala10
-rw-r--r--test/pending/run/reify_gadts.scala3
-rw-r--r--test/pending/run/reify_newimpl_07.scala5
-rw-r--r--test/pending/run/reify_newimpl_08.scala7
-rw-r--r--test/pending/run/reify_newimpl_46.scala13
-rw-r--r--test/pending/run/reify_newimpl_53.scala13
-rw-r--r--test/pending/run/reify_simpleinterpreter.scala2
-rw-r--r--test/pending/run/subarray.check2
-rw-r--r--test/pending/run/t0446.check2
-rw-r--r--test/pending/run/t5256c.check0
-rw-r--r--test/pending/run/t5256c.scala10
-rw-r--r--test/pending/run/t5256g.check0
-rw-r--r--test/pending/run/t5256g.scala11
-rw-r--r--test/pending/run/t5256h.check8
-rw-r--r--test/pending/run/t5256h.scala8
-rw-r--r--test/pending/run/t5258b.scala3
-rw-r--r--test/pending/run/t5258c.scala3
-rw-r--r--test/pending/run/t5418.scala3
-rw-r--r--test/pending/run/t5427a.scala2
-rw-r--r--test/pending/run/t5427b.scala2
-rw-r--r--test/pending/run/t5427c.scala2
-rw-r--r--test/pending/run/t5427d.scala2
-rw-r--r--test/pending/run/t5629.check2
-rw-r--r--test/pending/shootout/meteor.scala3
-rw-r--r--test/pending/specialized/SI-5005.check (renamed from test/files/specialized/SI-5005.check)0
-rw-r--r--test/pending/specialized/SI-5005.scala (renamed from test/files/specialized/SI-5005.scala)9
-rwxr-xr-xtools/buildcp11
-rwxr-xr-xtools/cpof28
-rwxr-xr-xtools/lockercp8
-rwxr-xr-xtools/packcp4
-rwxr-xr-xtools/quickcp8
-rwxr-xr-xtools/rm-orphan-checkfiles18
-rwxr-xr-xtools/starrcp4
-rwxr-xr-xtools/strapcp12
1250 files changed, 20387 insertions, 15011 deletions
diff --git a/build.xml b/build.xml
index 35cc4f3004..c0382cdce4 100644
--- a/build.xml
+++ b/build.xml
@@ -175,6 +175,7 @@ PROPERTIES
<!-- Sets location of pre-compiled libraries -->
<property name="lib.starr.jar" value="${lib.dir}/scala-library.jar"/>
+ <property name="reflect.starr.jar" value="${lib.dir}/scala-reflect.jar"/>
<property name="comp.starr.jar" value="${lib.dir}/scala-compiler.jar"/>
<property name="jline.jar" value="${lib.dir}/jline.jar"/>
<property name="ant.jar" value="${ant.home}/lib/ant.jar"/>
@@ -334,7 +335,7 @@ INITIALISATION
<target name="init.version.done" depends="init.version.release, init.version.snapshot"/>
<target name="init" depends="init.jars, init.maven.jars, init.version.done">
- <property name="scalac.args.always" value="-Xmacros" />
+ <property name="scalac.args.always" value="" />
<!-- scalac.args.optimise is selectively overridden in certain antcall tasks. -->
<property name="scalac.args.optimise" value=""/>
<!-- scalac.args.quickonly are added to quick.* targets but not others (particularly, locker.)
@@ -396,6 +397,7 @@ INITIALISATION
<!-- Define tasks that can be run with Starr -->
<path id="starr.classpath">
<pathelement location="${lib.starr.jar}"/>
+ <pathelement location="${reflect.starr.jar}"/>
<pathelement location="${comp.starr.jar}"/>
<path refid="aux.libs"/>
</path>
@@ -507,12 +509,61 @@ LOCAL REFERENCE BUILD (LOCKER)
<stopwatch name="locker.lib.timer" action="total"/>
</target>
- <target name="locker.pre-comp" depends="locker.lib" unless="locker.available">
+
+ <target name="locker.pre-reflect" depends="locker.lib" unless="locker.available">
+ <condition property="locker.reflect.needed">
+ <not><available file="${build-locker.dir}/reflect.complete"/></not>
+ </condition>
+ </target>
+
+ <target name="locker.reflect" depends="locker.pre-reflect" if="locker.reflect.needed">
+ <stopwatch name="locker.reflect.timer"/>
+ <mkdir dir="${build-locker.dir}/classes/reflect"/>
+ <scalacfork
+ destdir="${build-locker.dir}/classes/reflect"
+ compilerpathref="starr.classpath"
+ params="${scalac.args.all}"
+ srcdir="${src.dir}/reflect"
+ jvmargs="${scalacfork.jvmargs}">
+ <include name="**/*.scala"/>
+ <compilationpath>
+ <pathelement location="${build-locker.dir}/classes/library"/>
+ <pathelement location="${build-locker.dir}/classes/reflect"/>
+ <path refid="aux.libs"/>
+ <pathelement location="${jline.jar}"/>
+ </compilationpath>
+ </scalacfork>
+ <!-- TODO - needed? -->
+ <propertyfile file="${build-locker.dir}/classes/reflect/reflect.properties">
+ <entry key="version.number" value="${version.number}"/>
+ <entry key="maven.version.number" value="${maven.version.number}"/>
+ <entry key="osgi.version.number" value="${osgi.version.number}"/>
+ <entry key="copyright.string" value="${copyright.string}"/>
+ </propertyfile>
+ <copy todir="${build-locker.dir}/classes/reflect">
+ <fileset dir="${src.dir}/reflect">
+ <include name="**/*.tmpl"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.js"/>
+ <include name="**/*.html"/>
+ <include name="**/*.css"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.swf"/>
+ <include name="**/*.png"/>
+ <include name="**/*.gif"/>
+ </fileset>
+ </copy>
+ <touch file="${build-locker.dir}/reflect.complete" verbose="no"/>
+ <stopwatch name="locker.reflect.timer" action="total"/>
+ </target>
+
+ <target name="locker.pre-comp" depends="locker.reflect" unless="locker.available">
<condition property="locker.comp.needed">
<not><available file="${build-locker.dir}/compiler.complete"/></not>
</condition>
</target>
+
<target name="locker.comp" depends="locker.pre-comp" if="locker.comp.needed">
<stopwatch name="locker.comp.timer"/>
<mkdir dir="${build-locker.dir}/classes/compiler"/>
@@ -525,6 +576,7 @@ LOCAL REFERENCE BUILD (LOCKER)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-locker.dir}/classes/library"/>
+ <pathelement location="${build-locker.dir}/classes/reflect"/>
<pathelement location="${build-locker.dir}/classes/compiler"/>
<path refid="aux.libs"/>
<path refid="asm.classpath"/>
@@ -558,12 +610,15 @@ LOCAL REFERENCE BUILD (LOCKER)
<touch file="${build-locker.dir}/all.complete" verbose="no"/>
<path id="locker.classpath">
<pathelement location="${build-locker.dir}/classes/library"/>
+ <pathelement location="${build-locker.dir}/classes/reflect"/>
<pathelement location="${build-locker.dir}/classes/compiler"/>
<path refid="asm.classpath"/>
<path refid="aux.libs"/>
</path>
+ <!-- TODO - Why is this *here* ? -->
<path id="quick.classpath">
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<path refid="asm.classpath"/>
<path refid="aux.libs"/>
@@ -586,7 +641,19 @@ LOCAL REFERENCE BUILD (LOCKER)
<delete file="${build-locker.dir}/library.complete"/>
</target>
- <target name="locker.unlock.pre-comp" depends="locker.unlock.lib">
+ <target name="locker.unlock.pre-reflect" depends="locker.unlock.lib">
+ <uptodate property="locker.reflect.available" targetfile="${build-locker.dir}/reflect.complete">
+ <srcfiles dir="${src.dir}">
+ <include name="reflect/**"/>
+ </srcfiles>
+ </uptodate>
+ </target>
+
+ <target name="locker.unlock.reflect" depends="locker.unlock.pre-reflect" unless="locker.reflect.available">
+ <delete file="${build-locker.dir}/reflect.complete"/>
+ </target>
+
+ <target name="locker.unlock.pre-comp" depends="locker.unlock.reflect">
<uptodate property="locker.comp.available" targetfile="${build-locker.dir}/compiler.complete">
<srcfiles dir="${src.dir}">
<include name="compiler/**"/>
@@ -622,7 +689,21 @@ PACKED LOCKER BUILD (PALO)
</jar>
</target>
- <target name="palo.pre-comp" depends="palo.lib">
+ <target name="palo.pre-reflect" depends="palo.lib">
+ <uptodate
+ property="palo.reflect.available"
+ targetfile="${build-palo.dir}/lib/scala-reflect.jar"
+ srcfile="${build-locker.dir}/reflect.complete"/>
+ </target>
+
+ <target name="palo.reflect" depends="palo.pre-reflect" unless="palo.reflect.available">
+ <mkdir dir="${build-palo.dir}/lib"/>
+ <jar destfile="${build-palo.dir}/lib/scala-reflect.jar" manifest="${basedir}/META-INF/MANIFEST.MF">
+ <fileset dir="${build-locker.dir}/classes/reflect"/>
+ </jar>
+ </target>
+
+ <target name="palo.pre-comp" depends="palo.reflect">
<uptodate
property="palo.comp.available"
targetfile="${build-palo.dir}/lib/scala-compiler.jar"
@@ -660,6 +741,7 @@ PACKED LOCKER BUILD (PALO)
<taskdef name="palo-bin" classname="scala.tools.ant.ScalaTool">
<classpath>
<pathelement location="${build-palo.dir}/lib/scala-library.jar"/>
+ <pathelement location="${build-palo.dir}/lib/scala-reflect.jar"/>
<pathelement location="${build-palo.dir}/lib/scala-compiler.jar"/>
<pathelement location="${build-palo.dir}/lib/jline.jar"/>
</classpath>
@@ -776,7 +858,57 @@ QUICK BUILD (QUICK)
<stopwatch name="quick.lib.timer" action="total"/>
</target>
- <target name="quick.newlibs" depends="quick.lib" if="libs.outdated">
+
+ <target name="quick.pre-reflect" depends="quick.lib">
+ <uptodate property="quick.reflect.available" targetfile="${build-quick.dir}/reflect.complete">
+ <srcfiles dir="${src.dir}">
+ <include name="reflect/**"/>
+ </srcfiles>
+ </uptodate>
+ </target>
+
+ <target name="quick.reflect" depends="quick.pre-reflect" unless="quick.reflect.available">
+ <stopwatch name="quick.reflect.timer"/>
+ <mkdir dir="${build-quick.dir}/classes/reflect"/>
+ <scalacfork
+ destdir="${build-quick.dir}/classes/reflect"
+ compilerpathref="locker.classpath"
+ params="${scalac.args.all}"
+ srcdir="${src.dir}/reflect"
+ jvmargs="${scalacfork.jvmargs}">
+ <include name="**/*.scala"/>
+ <compilationpath>
+ <pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
+ <path refid="aux.libs"/>
+ <pathelement location="${jline.jar}"/>
+ </compilationpath>
+ </scalacfork>
+ <!-- TODO - needed? -->
+ <propertyfile file="${build-quick.dir}/classes/reflect/reflect.properties">
+ <entry key="version.number" value="${version.number}"/>
+ <entry key="maven.version.number" value="${maven.version.number}"/>
+ <entry key="osgi.version.number" value="${osgi.version.number}"/>
+ <entry key="copyright.string" value="${copyright.string}"/>
+ </propertyfile>
+ <copy todir="${build-quick.dir}/classes/reflect">
+ <fileset dir="${src.dir}/reflect">
+ <include name="**/*.tmpl"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.js"/>
+ <include name="**/*.html"/>
+ <include name="**/*.css"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.swf"/>
+ <include name="**/*.png"/>
+ <include name="**/*.gif"/>
+ </fileset>
+ </copy>
+ <touch file="${build-quick.dir}/reflect.complete" verbose="no"/>
+ <stopwatch name="quick.reflect.timer" action="total"/>
+ </target>
+
+ <target name="quick.newlibs" depends="quick.reflect" if="libs.outdated">
<antcall target="libs.done" inheritRefs="true"/>
<property name="fjbg.jar" value="${build-libs.dir}/fjbg.jar"/>
<property name="msil.jar" value="${build-libs.dir}/msil.jar"/>
@@ -814,6 +946,7 @@ QUICK BUILD (QUICK)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<path refid="aux.libs"/>
<path refid="asm.classpath"/>
@@ -862,6 +995,7 @@ QUICK BUILD (QUICK)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<pathelement location="${build-quick.dir}/classes/continuations-plugin"/>
<path refid="aux.libs"/>
@@ -959,6 +1093,7 @@ QUICK BUILD (QUICK)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
<pathelement location="${build-quick.dir}/classes/partest"/>
@@ -985,6 +1120,7 @@ QUICK BUILD (QUICK)
target="1.5" source="1.5">
<classpath>
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
<pathelement location="${build-quick.dir}/classes/partest"/>
@@ -1001,6 +1137,7 @@ QUICK BUILD (QUICK)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
<pathelement location="${build-quick.dir}/classes/partest"/>
@@ -1031,6 +1168,7 @@ QUICK BUILD (QUICK)
<target name="quick.bin" depends="quick.pre-bin" unless="quick.bin.available">
<path id="quick.bin.classpath">
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
<path refid="aux.libs"/>
@@ -1074,6 +1212,7 @@ QUICK BUILD (QUICK)
<target name="quick.done" depends="quick.bin">
<path id="quick.classpath">
<pathelement location="${build-quick.dir}/classes/library"/>
+ <pathelement location="${build-quick.dir}/classes/reflect"/>
<pathelement location="${build-quick.dir}/classes/compiler"/>
<path refid="asm.classpath"/>
<path refid="aux.libs"/>
@@ -1126,7 +1265,21 @@ PACKED QUICK BUILD (PACK)
</jar>
</target>
- <target name="pack.pre-comp" depends="pack.lib">
+ <target name="pack.pre-reflect" depends="pack.lib">
+ <uptodate
+ property="pack.reflect.available"
+ targetfile="${build-pack.dir}/lib/scala-reflect.jar"
+ srcfile="${build-quick.dir}/reflect.complete"/>
+ </target>
+
+ <target name="pack.reflect" depends="pack.pre-reflect" unless="pack.reflect.available">
+ <mkdir dir="${build-pack.dir}/lib"/>
+ <jar destfile="${build-pack.dir}/lib/scala-reflect.jar">
+ <fileset dir="${build-quick.dir}/classes/reflect" />
+ </jar>
+ </target>
+
+ <target name="pack.pre-comp" depends="pack.reflect">
<uptodate
property="pack.comp.available"
targetfile="${build-pack.dir}/lib/scala-compiler.jar"
@@ -1215,6 +1368,7 @@ PACKED QUICK BUILD (PACK)
<taskdef name="pack-bin" classname="scala.tools.ant.ScalaTool">
<classpath>
<pathelement location="${build-pack.dir}/lib/scala-library.jar"/>
+ <pathelement location="${build-pack.dir}/lib/scala-reflect.jar"/>
<pathelement location="${build-pack.dir}/lib/scala-compiler.jar"/>
<pathelement location="${build-pack.dir}/lib/jline.jar"/>
</classpath>
@@ -1251,6 +1405,7 @@ PACKED QUICK BUILD (PACK)
<target name="pack.done" depends="pack.bin">
<path id="pack.classpath">
<pathelement location="${build-pack.dir}/lib/scala-library.jar"/>
+ <pathelement location="${build-pack.dir}/lib/scala-reflect.jar"/>
<pathelement location="${build-pack.dir}/lib/scala-compiler.jar"/>
<pathelement location="${build-pack.dir}/lib/scala-partest.jar"/>
<pathelement location="${build-pack.dir}/lib/scalap.jar"/>
@@ -1349,7 +1504,54 @@ BOOTSTRAPPING BUILD (STRAP)
<stopwatch name="strap.lib.timer" action="total"/>
</target>
- <target name="strap.pre-comp" depends="strap.lib">
+ <target name="strap.pre-reflect" depends="strap.lib">
+ <uptodate property="strap.reflect.available" targetfile="${build-strap.dir}/reflect.complete">
+ <srcfiles dir="${src.dir}/reflect"/>
+ </uptodate>
+ </target>
+
+ <target name="strap.reflect" depends="strap.pre-reflect" unless="strap.reflect.available">
+ <stopwatch name="strap.reflect.timer"/>
+ <mkdir dir="${build-strap.dir}/classes/reflect"/>
+ <scalacfork
+ destdir="${build-strap.dir}/classes/reflect"
+ compilerpathref="pack.classpath"
+ params="${scalac.args.all}"
+ srcdir="${src.dir}/reflect"
+ jvmargs="${scalacfork.jvmargs}">
+ <include name="**/*.scala"/>
+ <compilationpath>
+ <pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
+ <path refid="aux.libs"/>
+ <pathelement location="${jline.jar}"/>
+ </compilationpath>
+ </scalacfork>
+ <propertyfile file="${build-strap.dir}/classes/reflect/reflect.properties">
+ <entry key="version.number" value="${version.number}"/>
+ <entry key="maven.version.number" value="${maven.version.number}"/>
+ <entry key="osgi.version.number" value="${osgi.version.number}"/>
+ <entry key="copyright.string" value="${copyright.string}"/>
+ </propertyfile>
+ <copy todir="${build-strap.dir}/classes/reflect">
+ <fileset dir="${src.dir}/reflect">
+ <include name="**/*.tmpl"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.js"/>
+ <include name="**/*.css"/>
+ <include name="**/*.html"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.swf"/>
+ <include name="**/*.png"/>
+ <include name="**/*.gif"/>
+ <include name="**/*.txt"/>
+ </fileset>
+ </copy>
+ <touch file="${build-strap.dir}/reflect.complete" verbose="no"/>
+ <stopwatch name="strap.comp.timer" action="total"/>
+ </target>
+
+ <target name="strap.pre-comp" depends="strap.reflect">
<uptodate property="strap.comp.available" targetfile="${build-strap.dir}/compiler.complete">
<srcfiles dir="${src.dir}/compiler"/>
</uptodate>
@@ -1368,6 +1570,7 @@ BOOTSTRAPPING BUILD (STRAP)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
<pathelement location="${build-strap.dir}/classes/compiler"/>
<path refid="aux.libs"/>
<path refid="asm.classpath"/>
@@ -1416,6 +1619,7 @@ BOOTSTRAPPING BUILD (STRAP)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
<pathelement location="${build-strap.dir}/classes/compiler"/>
<pathelement location="${build-strap.dir}/classes/continuations-plugin"/>
<path refid="aux.libs"/>
@@ -1478,6 +1682,7 @@ BOOTSTRAPPING BUILD (STRAP)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
<pathelement location="${build-strap.dir}/classes/compiler"/>
<pathelement location="${build-strap.dir}/classes/scalap"/>
<pathelement location="${build-strap.dir}/classes/partest"/>
@@ -1504,6 +1709,7 @@ BOOTSTRAPPING BUILD (STRAP)
target="1.5" source="1.5">
<classpath>
<pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
<pathelement location="${build-strap.dir}/classes/compiler"/>
<pathelement location="${build-strap.dir}/classes/scalap"/>
<pathelement location="${build-strap.dir}/classes/partest"/>
@@ -1520,6 +1726,7 @@ BOOTSTRAPPING BUILD (STRAP)
<include name="**/*.scala"/>
<compilationpath>
<pathelement location="${build-strap.dir}/classes/library"/>
+ <pathelement location="${build-strap.dir}/classes/reflect"/>
<pathelement location="${build-strap.dir}/classes/compiler"/>
<pathelement location="${build-strap.dir}/classes/scalap"/>
<pathelement location="${build-strap.dir}/classes/partest"/>
@@ -1739,7 +1946,8 @@ DOCUMENTATION
<src>
<files includes="${src.dir}/actors-migration"/>
<files includes="${src.dir}/actors"/>
- <files includes="${src.dir}/library/scala"/>
+ <files includes="${src.dir}/library"/>
+ <files includes="${src.dir}/reflect"/>
<files includes="${src.dir}/swing"/>
<files includes="${src.dir}/continuations/library"/>
</src>
@@ -1961,6 +2169,7 @@ BOOTRAPING TEST AND TEST SUITE
</target>
<target name="test.classload" depends="pack.done">
+ <!-- TODO - Add actors + reflect to this -->
<classloadVerify classpath="${build-pack.dir}/lib/scala-library.jar" />
</target>
@@ -2126,6 +2335,9 @@ DISTRIBUTION
<fileset dir="${src.dir}/library"/>
<fileset dir="${src.dir}/continuations/library"/>
</jar>
+ <jar destfile="${dist.dir}/src/scala-reflect-src.jar">
+ <fileset dir="${src.dir}/reflect"/>
+ </jar>
<jar destfile="${dist.dir}/src/scala-swing-src.jar">
<fileset dir="${src.dir}/swing"/>
</jar>
@@ -2195,6 +2407,7 @@ STABLE REFERENCE (STARR)
<target name="starr.clean" depends="starr.start">
<delete file="${basedir}/lib/scala-library.jar"/>
+ <delete file="${basedir}/lib/scala-reflect.jar"/>
<delete file="${basedir}/lib/scala-compiler.jar"/>
<delete file="${basedir}/lib/scala-library-src.jar"/>
</target>
@@ -2205,7 +2418,13 @@ STABLE REFERENCE (STARR)
</jar>
</target>
- <target name="starr.comp" depends="starr.lib">
+ <target name="starr.reflect" depends="starr.lib">
+ <jar destfile="${basedir}/lib/scala-reflect.jar">
+ <fileset dir="${basedir}/build/quick/classes/reflect"/>
+ </jar>
+ </target>
+
+ <target name="starr.comp" depends="starr.reflect">
<jar destfile="${basedir}/lib/scala-compiler.jar">
<fileset dir="${basedir}/build/quick/classes/compiler"/>
</jar>
@@ -2242,6 +2461,7 @@ STABLE REFERENCE (STARR)
<delete>
<fileset dir="${lib.dir}">
<include name="scala-compiler.jar.desired.sha1"/>
+ <include name="scala-reflect.jar.desired.sha1"/>
<include name="scala-library.jar.desired.sha1"/>
<include name="scala-library-src.jar.desired.sha1"/>
</fileset>
@@ -2390,6 +2610,7 @@ POSITIONS
MISCELLANEOUS
============================================================================ -->
+
<target name="graph.init">
<taskdef name="vizant" classname="vizant.Vizant" classpath="${lib-ant.dir}/vizant.jar"/>
</target>
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1
index b2d1ae35eb..72eacf4fc3 100644
--- a/lib/scala-compiler.jar.desired.sha1
+++ b/lib/scala-compiler.jar.desired.sha1
@@ -1 +1 @@
-0939b5f357e4b0a6ecb3b6218a1a53841aae258d ?scala-compiler.jar
+043cf67f1a3769fb40d058693572058c5a7bf831 ?scala-compiler.jar
diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1
index ebc617f19a..aca99c9680 100644
--- a/lib/scala-library.jar.desired.sha1
+++ b/lib/scala-library.jar.desired.sha1
@@ -1 +1 @@
-2abaea76bd10ccb7afe29604b1156fb7f8c6c36e ?scala-library.jar
+410e7a0afc217532efe48c1c71684e08428bc211 ?scala-library.jar
diff --git a/lib/scala-reflect.jar.desired.sha1 b/lib/scala-reflect.jar.desired.sha1
new file mode 100644
index 0000000000..5878201d78
--- /dev/null
+++ b/lib/scala-reflect.jar.desired.sha1
@@ -0,0 +1 @@
+c4d6c4bd4c1a2d7b34a940ab935673a73dfb8630 ?scala-reflect.jar
diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml
index 7ab54f81c3..131358f0f3 100644
--- a/src/build/maven/maven-deploy.xml
+++ b/src/build/maven/maven-deploy.xml
@@ -111,6 +111,7 @@
<deploy-local name="scala-library" version="@{version}" repository="@{repository}" />
<deploy-local name="scala-compiler" version="@{version}" repository="@{repository}" />
<deploy-local-plugin name="continuations" version="@{version}" repository="@{repository}"/>
+ <deploy-local name="scala-reflect" version="@{version}" repository="@{repository}" />
<deploy-local name="scala-actors" version="@{version}" repository="@{repository}" />
<deploy-local name="scala-actors-migration" version="@{version}" repository="@{repository}" />
<deploy-local name="scala-swing" version="@{version}" repository="@{repository}"/>
@@ -170,6 +171,7 @@
</extra-attachments>
</deploy-remote>
<deploy-remote name="jline" version="@{version}" repository="@{repository}"/>
+ <deploy-remote name="scala-reflect" version="@{version}" repository="@{repository}"/>
<deploy-remote name="scala-compiler" version="@{version}" repository="@{repository}" />
<deploy-remote name="scala-swing" version="@{version}" repository="@{repository}"/>
<deploy-remote name="scala-actors" version="@{version}" repository="@{repository}"/>
@@ -238,6 +240,7 @@
<deploy-remote-plugin-signed name="continuations" version="@{version}" repository="@{repository}"/>
<deploy-remote-signed name="scala-library" version="@{version}" repository="@{repository}"/>
<deploy-remote-signed name="jline" version="@{version}" repository="@{repository}"/>
+ <deploy-remote-signed name="scala-reflect" version="@{version}" repository="@{repository}"/>
<deploy-remote-signed name="scala-compiler" version="@{version}" repository="@{repository}" />
<deploy-remote-signed name="scala-swing" version="@{version}" repository="@{repository}"/>
<deploy-remote-signed name="scala-actors" version="@{version}" repository="@{repository}"/>
diff --git a/src/build/maven/scala-compiler-pom.xml b/src/build/maven/scala-compiler-pom.xml
index 82d0ed7c91..fedc34a5d5 100644
--- a/src/build/maven/scala-compiler-pom.xml
+++ b/src/build/maven/scala-compiler-pom.xml
@@ -37,6 +37,11 @@
<artifactId>scala-library</artifactId>
<version>@VERSION@</version>
</dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-reflect</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>jline</artifactId>
diff --git a/src/build/maven/scala-reflect-pom.xml b/src/build/maven/scala-reflect-pom.xml
new file mode 100644
index 0000000000..7a1613f42c
--- /dev/null
+++ b/src/build/maven/scala-reflect-pom.xml
@@ -0,0 +1,62 @@
+<project
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-reflect</artifactId>
+ <packaging>jar</packaging>
+ <version>@VERSION@</version>
+ <name>Scala Compiler</name>
+ <description>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-like</name>
+ <url>http://www.scala-lang.org/downloads/license.html
+ </url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:git://github.com/scala/scala.git</connection>
+ <url>https://github.com/scala/scala.git</url>
+ </scm>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.scala-lang.org/</url>
+ </issueManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ </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/pack.xml b/src/build/pack.xml
index 956beaef88..564d290967 100644
--- a/src/build/pack.xml
+++ b/src/build/pack.xml
@@ -136,6 +136,7 @@ MAIN DISTRIBUTION PACKAGING
</macrodef>
<mvn-copy-lib mvn.artifact.name="jline"/>
<mvn-copy-lib mvn.artifact.name="scala-library"/>
+ <mvn-copy-lib mvn.artifact.name="scala-reflect"/>
<mvn-copy-lib mvn.artifact.name="scala-compiler"/>
<mvn-copy-lib mvn.artifact.name="scala-swing"/>
<mvn-copy-lib mvn.artifact.name="scala-actors"/>
@@ -212,6 +213,8 @@ MAIN DISTRIBUTION PACKAGING
file="${dists.dir}/maven/${version.number}/scala-library/scala-library-docs.jar"/>
<copy tofile="${dists.dir}/maven/${version.number}/scala-actors/scala-actors-docs.jar"
file="${dists.dir}/maven/${version.number}/scala-library/scala-library-docs.jar"/>
+ <copy tofile="${dists.dir}/maven/${version.number}/scala-reflect/scala-reflect-docs.jar"
+ file="${dists.dir}/maven/${version.number}/scala-library/scala-library-docs.jar"/>
</target>
<target name="pack-maven.latest.unix" depends="pack-maven.docs" unless="os.win">
diff --git a/src/compiler/scala/reflect/internal/FreeVars.scala b/src/compiler/scala/reflect/internal/FreeVars.scala
deleted file mode 100644
index 8b6e8b61f3..0000000000
--- a/src/compiler/scala/reflect/internal/FreeVars.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-package scala.reflect
-package internal
-
-trait FreeVars extends api.FreeVars {
- self: SymbolTable =>
-
- object FreeTerm extends FreeTermExtractor {
- def unapply(freeTerm: FreeTerm): Option[(TermName, Type, Any, String)] =
- Some(freeTerm.name, freeTerm.info, freeTerm.value, freeTerm.origin)
- }
-
- object FreeType extends FreeTypeExtractor {
- def unapply(freeType: FreeType): Option[(TypeName, Type, String)] =
- Some(freeType.name, freeType.info, freeType.origin)
- }
-
- // [Eugene] am I doing this right?
- def freeTerms(tree: Tree): List[FreeTerm] = {
- def isFreeTermSym(sym: Symbol) = sym != null && sym.isFreeTerm
- def isFreeTermTpe(t: Type) = t != null && isFreeTermSym(t.termSymbol)
-
- val buf = collection.mutable.Set[Symbol]()
- tree foreach (sub => {
- if (sub.tpe != null) buf ++= (sub.tpe collect { case tpe if isFreeTermTpe(tpe) => tpe.typeSymbol })
- if (sub.symbol != null && isFreeTermSym(sub.symbol)) buf += sub.symbol
- })
-
- buf.toList.collect{ case fty: FreeTerm => fty }
- }
-
- // [Eugene] am I doing this right?
- def freeTypes(tree: Tree): List[FreeType] = {
- def isFreeTypeSym(sym: Symbol) = sym != null && sym.isFreeType
- def isFreeTypeTpe(t: Type) = t != null && isFreeTypeSym(t.typeSymbol)
-
- val buf = collection.mutable.Set[Symbol]()
- tree foreach (sub => {
- if (sub.tpe != null) buf ++= (sub.tpe collect { case tpe if isFreeTypeTpe(tpe) => tpe.typeSymbol })
- if (sub.symbol != null && isFreeTypeSym(sub.symbol)) buf += sub.symbol
- })
-
- buf.toList.collect{ case fty: FreeType => fty }
- }
-
- // todo. also update tpe's of dependent free vars
- // e.g. if we substitute free$C, then free$C$this should have its info updated
- // todo. should also transform typetags of types dependent on that free type?
- // [Eugene] how do I check that the substitution is legal w.r.t fty.info?
- def substituteFreeTypes(tree0: Tree, subs: Map[FreeType, Type]): Tree = {
- val tree = tree0.duplicate
- new TreeTypeSubstituter(subs.keys.toList, subs.values.toList).traverse(tree)
- tree
- }
-
- // [Eugene] how do I check that the substitution is legal w.r.t fty.info?
- def substituteFreeTypes(tpe0: Type, subs: Map[FreeType, Type]): Type = {
- val tpe = tpe0 // [Eugene] tpe0.duplicate?
- tpe.subst(subs.keys.toList, subs.values.toList)
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/StdAttachments.scala b/src/compiler/scala/reflect/internal/StdAttachments.scala
deleted file mode 100644
index ae2ad87deb..0000000000
--- a/src/compiler/scala/reflect/internal/StdAttachments.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-package scala.reflect
-package internal
-
-import scala.reflect.makro.runtime.{Context => MacroContext}
-
-trait StdAttachments {
- self: SymbolTable =>
-
- case class ReifyAttachment(original: Symbol)
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/TreeBuildUtil.scala b/src/compiler/scala/reflect/internal/TreeBuildUtil.scala
deleted file mode 100644
index d4d4652e91..0000000000
--- a/src/compiler/scala/reflect/internal/TreeBuildUtil.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-package scala.reflect
-package internal
-
-import Flags._
-
-trait TreeBuildUtil extends api.TreeBuildUtil { self: SymbolTable =>
-
- // ``staticClass'' and ``staticModule'' rely on ClassLoaders
- // which are implementation-specific for different Universes
-
- def staticClassIfDefined(fullName: String): Symbol =
- try staticClass(fullName)
- catch { case _: MissingRequirementError => NoSymbol }
-
- def staticModuleIfDefined(fullName: String): Symbol =
- try staticModule(fullName)
- catch { case _: MissingRequirementError => NoSymbol }
-
- def thisModuleType(fullname: String) = staticModule(fullname).moduleClass.thisType
-
- def selectType(owner: Symbol, name: String): Symbol =
- owner.info.decl(newTypeName(name)) orElse {
- MissingRequirementError.notFound("type %s in %s".format(name, owner.fullName))
- }
-
- def selectTypeIfDefined(owner: Symbol, name: String): Symbol =
- try selectType(owner, name)
- catch { case _: MissingRequirementError => NoSymbol }
-
-// try getModule(fullname.toTermName)
-// catch { case _: MissingRequirementError => NoSymbol }
-
- def selectTerm(owner: Symbol, name: String): Symbol = {
- val sym = owner.info.decl(newTermName(name))
- val result =
- if (sym.isOverloaded) sym suchThat (!_.isMethod)
- else sym
- result orElse {
- MissingRequirementError.notFound("term %s in %s".format(name, owner.fullName))
- }
- }
-
- def selectTermIfDefined(owner: Symbol, name: String): Symbol =
- try selectTerm(owner, name)
- catch { case _: MissingRequirementError => NoSymbol }
-
- def selectOverloadedMethod(owner: Symbol, name: String, index: Int): Symbol =
- owner.info.decl(newTermName(name)).alternatives(index) orElse {
- MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName))
- }
-
- def selectOverloadedMethodIfDefined(owner: Symbol, name: String, index: Int): Symbol =
- try selectOverloadedMethod(owner, name, index)
- catch { case _: MissingRequirementError => NoSymbol }
-
- def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null) = newFreeTermSymbol(newTermName(name), info, value, flags, origin)
-
- def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null) = newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) PARAM else flags) | DEFERRED, origin)
-
- def newFreeExistential(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null) = newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) EXISTENTIAL else flags) | DEFERRED, origin)
-
- def modifiersFromInternalFlags(flags: Long, privateWithin: Name, annotations: List[Tree]): Modifiers =
- Modifiers(flags, privateWithin, annotations)
-
- val gen: TreeGen { val global: TreeBuildUtil.this.type }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala
deleted file mode 100644
index 3e7f23800c..0000000000
--- a/src/compiler/scala/reflect/internal/Trees.scala
+++ /dev/null
@@ -1,435 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Martin Odersky
- */
-
-package scala.reflect
-package internal
-
-import Flags._
-import api.Modifier
-
-trait Trees extends api.Trees { self: SymbolTable =>
-
- // Belongs in TreeInfo but then I can't reach it from TreePrinters.
- def isReferenceToScalaMember(t: Tree, Id: Name) = t match {
- case Ident(Id) => true
- case Select(Ident(nme.scala_), Id) => true
- case Select(Select(Ident(nme.ROOTPKG), nme.scala_), Id) => true
- case _ => false
- }
- /** Is the tree Predef, scala.Predef, or _root_.scala.Predef?
- */
- def isReferenceToPredef(t: Tree) = isReferenceToScalaMember(t, nme.Predef)
- def isReferenceToAnyVal(t: Tree) = isReferenceToScalaMember(t, tpnme.AnyVal)
-
- // --- modifiers implementation ---------------------------------------
-
- /** @param privateWithin the qualifier for a private (a type name)
- * or tpnme.EMPTY, if none is given.
- * @param annotations the annotations for the definition.
- * '''Note:''' the typechecker drops these annotations,
- * use the AnnotationInfo's (Symbol.annotations) in later phases.
- */
- case class Modifiers(flags: Long,
- privateWithin: Name,
- annotations: List[Tree]) extends AbsModifiers with HasFlags {
-
- var positions: Map[Long, Position] = Map()
-
- def setPositions(poss: Map[Long, Position]): this.type = {
- positions = poss; this
- }
-
- /* Abstract types from HasFlags. */
- type AccessBoundaryType = Name
- type AnnotationType = Tree
-
- def hasAnnotationNamed(name: TypeName) = {
- annotations exists {
- case Apply(Select(New(Ident(`name`)), _), _) => true
- case Apply(Select(New(Select(_, `name`)), _), _) => true
- case _ => false
- }
- }
-
- def hasAccessBoundary = privateWithin != tpnme.EMPTY
- def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
- def hasFlag(flag: Long) = (flag & flags) != 0L
-
- def & (flag: Long): Modifiers = {
- val flags1 = flags & flag
- if (flags1 == flags) this
- else Modifiers(flags1, privateWithin, annotations) setPositions positions
- }
- def &~ (flag: Long): Modifiers = {
- val flags1 = flags & (~flag)
- if (flags1 == flags) this
- else Modifiers(flags1, privateWithin, annotations) setPositions positions
- }
- def | (flag: Long): Modifiers = {
- val flags1 = flags | flag
- if (flags1 == flags) this
- else Modifiers(flags1, privateWithin, annotations) setPositions positions
- }
- def withAnnotations(annots: List[Tree]) =
- if (annots.isEmpty) this
- else copy(annotations = annotations ::: annots) setPositions positions
-
- def withPosition(flag: Long, position: Position) =
- copy() setPositions positions + (flag -> position)
-
- override def hasModifier(mod: Modifier) =
- hasFlag(flagOfModifier(mod))
- override def modifiers: Set[Modifier] =
- Modifier.values filter hasModifier
- override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers =
- Modifiers(flags, privateWithin, f(annotations)) setPositions positions
-
- override def toString = "Modifiers(%s, %s, %s)".format(flagString, annotations mkString ", ", positions)
- }
-
- def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List())
- def Modifiers(flags: Long): Modifiers = Modifiers(flags, tpnme.EMPTY)
-
- def Modifiers(mods: Set[Modifier],
- privateWithin: Name,
- annotations: List[Tree]): Modifiers = {
- val flagSet = mods map flagOfModifier
- Modifiers((0L /: flagSet)(_ | _), privateWithin, annotations)
- }
-
- lazy val NoMods = Modifiers(0)
-
- // --- extension methods --------------------------------------------------------
-
- implicit class TreeOps(tree: Tree) {
- def isErroneous = (tree.tpe ne null) && tree.tpe.isErroneous
- def isTyped = (tree.tpe ne null) && !tree.tpe.isErroneous
-
- /** Sets the tree's type to the result of the given function.
- * If the type is null, it remains null - the function is not called.
- */
- def modifyType(f: Type => Type): Tree =
- if (tree.tpe eq null) tree
- else tree setType f(tree.tpe)
-
- /** If `pf` is defined for a given subtree, call super.traverse(pf(tree)),
- * otherwise super.traverse(tree).
- */
- def foreachPartial(pf: PartialFunction[Tree, Tree]) {
- new ForeachPartialTreeTraverser(pf).traverse(tree)
- }
-
- def changeOwner(pairs: (Symbol, Symbol)*): Tree = {
- pairs.foldLeft(tree) { case (t, (oldOwner, newOwner)) =>
- new ChangeOwnerTraverser(oldOwner, newOwner) apply t
- }
- }
-
- def substTreeSyms(pairs: (Symbol, Symbol)*): Tree =
- substTreeSyms(pairs.map(_._1).toList, pairs.map(_._2).toList)
-
- def substTreeSyms(from: List[Symbol], to: List[Symbol]): Tree =
- new TreeSymSubstituter(from, to)(tree)
-
- def substTreeThis(clazz: Symbol, to: Tree): Tree = new ThisSubstituter(clazz, to) transform tree
-
- def shallowDuplicate: Tree = new ShallowDuplicator(tree) transform tree
- def shortClass: String = tree.getClass.getName split "[.$]" last
-
- def isErrorTyped = (tree.tpe ne null) && tree.tpe.isError
-
- /** When you want to know a little more than the class, but a lot
- * less than the whole tree.
- */
- def summaryString: String = tree match {
- case Literal(const) => "Literal(" + const + ")"
- case Ident(name) => "Ident(%s)".format(name.decode)
- case Select(qual, name) => "Select(%s, %s)".format(qual.summaryString, name.decode)
- case t: NameTree => t.name.longString
- case t =>
- t.shortClass + (
- if (t.symbol != null && t.symbol != NoSymbol) "(" + t.symbol + ")"
- else ""
- )
- }
- }
-
- // ---- values and creators ---------------------------------------
-
- /** @param sym the class symbol
- * @return the implementation template
- */
- def ClassDef(sym: Symbol, impl: Template): ClassDef =
- atPos(sym.pos) {
- ClassDef(Modifiers(sym.flags),
- sym.name.toTypeName,
- sym.typeParams map TypeDef,
- impl) setSymbol sym
- }
-
- /**
- * @param sym the class symbol
- * @param impl the implementation template
- */
- def ModuleDef(sym: Symbol, impl: Template): ModuleDef =
- atPos(sym.pos) {
- ModuleDef(Modifiers(sym.flags), sym.name.toTermName, impl) setSymbol sym
- }
-
- def ValDef(sym: Symbol, rhs: Tree): ValDef =
- atPos(sym.pos) {
- ValDef(Modifiers(sym.flags), sym.name.toTermName,
- TypeTree(sym.tpe) setPos sym.pos.focus,
- rhs) setSymbol sym
- }
-
- def ValDef(sym: Symbol): ValDef = ValDef(sym, EmptyTree)
-
- object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) {
- override def isEmpty = true
- super.setPos(NoPosition)
- override def setPos(pos: Position) = { assert(false); this }
- }
-
- def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef =
- atPos(sym.pos) {
- assert(sym != NoSymbol)
- DefDef(mods,
- sym.name.toTermName,
- sym.typeParams map TypeDef,
- vparamss,
- TypeTree(sym.tpe.finalResultType) setPos sym.pos.focus,
- rhs) setSymbol sym
- }
-
- def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef =
- DefDef(sym, Modifiers(sym.flags), vparamss, rhs)
-
- def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef =
- DefDef(sym, mods, mapParamss(sym)(ValDef), rhs)
-
- def DefDef(sym: Symbol, rhs: Tree): DefDef =
- DefDef(sym, Modifiers(sym.flags), rhs)
-
- def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef =
- DefDef(sym, rhs(sym.info.paramss))
-
- /** A TypeDef node which defines given `sym` with given tight hand side `rhs`. */
- def TypeDef(sym: Symbol, rhs: Tree): TypeDef =
- atPos(sym.pos) {
- TypeDef(Modifiers(sym.flags), sym.name.toTypeName, sym.typeParams map TypeDef, rhs) setSymbol sym
- }
-
- /** A TypeDef node which defines abstract type or type parameter for given `sym` */
- def TypeDef(sym: Symbol): TypeDef =
- TypeDef(sym, TypeBoundsTree(TypeTree(sym.info.bounds.lo), TypeTree(sym.info.bounds.hi)))
-
- def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef =
- atPos(sym.pos) {
- LabelDef(sym.name.toTermName, params map Ident, rhs) setSymbol sym
- }
-
- /** casedef shorthand */
- def CaseDef(pat: Tree, body: Tree): CaseDef =
- CaseDef(pat, EmptyTree, body)
-
- def Bind(sym: Symbol, body: Tree): Bind =
- Bind(sym.name, body) setSymbol sym
-
- def Try(body: Tree, cases: (Tree, Tree)*): Try =
- Try(body, cases.toList map { case (pat, rhs) => CaseDef(pat, EmptyTree, rhs) }, EmptyTree)
-
- def Throw(tpe: Type, args: Tree*): Throw =
- Throw(New(tpe, args: _*))
-
- def Apply(sym: Symbol, args: Tree*): Tree =
- Apply(Ident(sym), args.toList)
-
- /** Factory method for object creation `new tpt(args_1)...(args_n)`
- * A `New(t, as)` is expanded to: `(new t).<init>(as)`
- */
- def New(tpt: Tree, argss: List[List[Tree]]): Tree = argss match {
- case Nil => new ApplyConstructor(tpt, Nil)
- case xs :: rest => rest.foldLeft(new ApplyConstructor(tpt, xs): Tree)(Apply)
- }
-
- /** 0-1 argument list new, based on a type.
- */
- def New(tpe: Type, args: Tree*): Tree =
- new ApplyConstructor(TypeTree(tpe), args.toList)
-
- def New(sym: Symbol, args: Tree*): Tree =
- New(sym.tpe, args: _*)
-
- def Super(sym: Symbol, mix: TypeName): Tree =
- Super(This(sym), mix)
-
- def This(sym: Symbol): Tree =
- This(sym.name.toTypeName) setSymbol sym
-
- def Select(qualifier: Tree, name: String): Select =
- Select(qualifier, newTermName(name))
-
- def Select(qualifier: Tree, sym: Symbol): Select =
- Select(qualifier, sym.name) setSymbol sym
-
- def Ident(name: String): Ident =
- Ident(newTermName(name))
-
- def Ident(sym: Symbol): Ident =
- Ident(sym.name) setSymbol sym
-
- /** Block factory that flattens directly nested blocks.
- */
- def Block(stats: Tree*): Block = {
- if (stats.isEmpty) Block(Nil, Literal(Constant(())))
- else stats match {
- case Seq(b @ Block(_, _)) => b
- case Seq(stat) => Block(stats.toList, Literal(Constant(())))
- case Seq(_, rest @ _*) => Block(stats.init.toList, stats.last)
- }
- }
-
- // --- specific traversers and transformers
- // todo. move these into scala.reflect.api
-
- protected[scala] def duplicateTree(tree: Tree): Tree = duplicator transform tree
-
- private lazy val duplicator = new Transformer {
- override val treeCopy = newStrictTreeCopier
- override def transform(t: Tree) = {
- val t1 = super.transform(t)
- if ((t1 ne t) && t1.pos.isRange) t1 setPos t.pos.focus
- t1
- }
- }
-
- class ForeachPartialTreeTraverser(pf: PartialFunction[Tree, Tree]) extends Traverser {
- override def traverse(tree: Tree) {
- val t = if (pf isDefinedAt tree) pf(tree) else tree
- super.traverse(t)
- }
- }
-
- class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser {
- def changeOwner(tree: Tree) = tree match {
- case Return(expr) =>
- if (tree.symbol == oldowner) {
- // SI-5612
- if (newowner hasTransOwner oldowner)
- log("NOT changing owner of %s because %s is nested in %s".format(tree, newowner, oldowner))
- else {
- log("changing owner of %s: %s => %s".format(tree, oldowner, newowner))
- tree.symbol = newowner
- }
- }
- case _: DefTree | _: Function =>
- if (tree.symbol != NoSymbol && tree.symbol.owner == oldowner) {
- tree.symbol.owner = newowner
- }
- case _ =>
- }
- override def traverse(tree: Tree) {
- changeOwner(tree)
- super.traverse(tree)
- }
- }
-
- private class ShallowDuplicator(orig: Tree) extends Transformer {
- override val treeCopy = newStrictTreeCopier
- override def transform(tree: Tree) =
- if (tree eq orig) super.transform(tree)
- else tree
- }
- // Create a readable string describing a substitution.
- private def substituterString(fromStr: String, toStr: String, from: List[Any], to: List[Any]): String = {
- "subst[%s, %s](%s)".format(fromStr, toStr, (from, to).zipped map (_ + " -> " + _) mkString ", ")
- }
-
- // NOTE: calls shallowDuplicate on trees in `to` to avoid problems when symbols in `from`
- // occur multiple times in the `tree` passed to `transform`,
- // otherwise, the resulting Tree would be a graph, not a tree... this breaks all sorts of stuff,
- // notably concerning the mutable aspects of Trees (such as setting their .tpe)
- class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer {
- override def transform(tree: Tree): Tree = tree match {
- case Ident(_) =>
- def subst(from: List[Symbol], to: List[Tree]): Tree =
- if (from.isEmpty) tree
- else if (tree.symbol == from.head) to.head.shallowDuplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`?
- else subst(from.tail, to.tail);
- subst(from, to)
- case _ =>
- super.transform(tree)
- }
- override def toString = substituterString("Symbol", "Tree", from, to)
- }
-
- /** Substitute clazz.this with `to`. `to` must be an attributed tree.
- */
- class ThisSubstituter(clazz: Symbol, to: => Tree) extends Transformer {
- val newtpe = to.tpe
- override def transform(tree: Tree) = {
- if (tree.tpe ne null) tree.tpe = tree.tpe.substThis(clazz, newtpe)
- tree match {
- case This(_) if tree.symbol == clazz => to
- case _ => super.transform(tree)
- }
- }
- }
-
- class TypeMapTreeSubstituter(val typeMap: TypeMap) extends Traverser {
- override def traverse(tree: Tree) {
- if (tree.tpe ne null)
- tree.tpe = typeMap(tree.tpe)
- if (tree.isDef)
- tree.symbol modifyInfo typeMap
-
- super.traverse(tree)
- }
- override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
- }
-
- class TreeTypeSubstituter(val from: List[Symbol], val to: List[Type]) extends TypeMapTreeSubstituter(new SubstTypeMap(from, to)) {
- def isEmpty = from.isEmpty && to.isEmpty
- override def toString() = "TreeTypeSubstituter("+from+","+to+")"
- }
-
- lazy val EmptyTreeTypeSubstituter = new TreeTypeSubstituter(List(), List())
-
- class TreeSymSubstTraverser(val from: List[Symbol], val to: List[Symbol]) extends TypeMapTreeSubstituter(new SubstSymMap(from, to)) {
- override def toString() = "TreeSymSubstTraverser/" + substituterString("Symbol", "Symbol", from, to)
- }
-
- /** Substitute symbols in `from` with symbols in `to`. Returns a new
- * tree using the new symbols and whose Ident and Select nodes are
- * name-consistent with the new symbols.
- */
- class TreeSymSubstituter(from: List[Symbol], to: List[Symbol]) extends Transformer {
- val symSubst = new SubstSymMap(from, to)
- override def transform(tree: Tree): Tree = {
- def subst(from: List[Symbol], to: List[Symbol]) {
- if (!from.isEmpty)
- if (tree.symbol == from.head) tree setSymbol to.head
- else subst(from.tail, to.tail)
- }
-
- if (tree.tpe ne null) tree.tpe = symSubst(tree.tpe)
- if (tree.hasSymbol) {
- subst(from, to)
- tree match {
- case Ident(name0) if tree.symbol != NoSymbol =>
- treeCopy.Ident(tree, tree.symbol.name)
- case Select(qual, name0) if tree.symbol != NoSymbol =>
- treeCopy.Select(tree, transform(qual), tree.symbol.name)
- case _ =>
- super.transform(tree)
- }
- } else
- super.transform(tree)
- }
- def apply[T <: Tree](tree: T): T = transform(tree).asInstanceOf[T]
- override def toString() = "TreeSymSubstituter/" + substituterString("Symbol", "Symbol", from, to)
- }
-}
diff --git a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala b/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala
index d78eae9237..a68910859d 100644
--- a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala
+++ b/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala
@@ -1,6 +1,6 @@
package scala.reflect.makro
package runtime
-import scala.reflect.api.Position
+import scala.reflect.internal.util.Position
class AbortMacroException(val pos: Position, val msg: String) extends Throwable(msg)
diff --git a/src/compiler/scala/reflect/makro/runtime/Aliases.scala b/src/compiler/scala/reflect/makro/runtime/Aliases.scala
index a4f208ca34..760f7fc54d 100644
--- a/src/compiler/scala/reflect/makro/runtime/Aliases.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Aliases.scala
@@ -4,18 +4,23 @@ package runtime
trait Aliases {
self: Context =>
- /** Aliases of mirror types */
- override type Symbol = mirror.Symbol
- override type Type = mirror.Type
- override type Name = mirror.Name
- override type Tree = mirror.Tree
- override type Position = mirror.Position
- override type Scope = mirror.Scope
- override type Modifiers = mirror.Modifiers
- override type Expr[+T] = mirror.Expr[T]
- override type TypeTag[T] = mirror.TypeTag[T]
+ override type Symbol = universe.Symbol
+ override type Type = universe.Type
+ override type Name = universe.Name
+ override type TermName = universe.TermName
+ override type TypeName = universe.TypeName
+ override type Tree = universe.Tree
+ // override type Position = universe.Position
+ override type Scope = universe.Scope
+ override type Modifiers = universe.Modifiers
- /** Creator/extractor objects for Expr and TypeTag values */
- override val TypeTag = mirror.TypeTag
- override val Expr = mirror.Expr
+ override type Expr[+T] = universe.Expr[T]
+ override val Expr = universe.Expr
+
+ override type AbsTypeTag[T] = universe.AbsTypeTag[T]
+ override type TypeTag[T] = universe.TypeTag[T]
+ override val AbsTypeTag = universe.AbsTypeTag
+ override val TypeTag = universe.TypeTag
+ override def typeTag[T](implicit ttag: TypeTag[T]) = ttag
+ override def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala b/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala
index 4e93d4e06d..021b93ceee 100644
--- a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala
+++ b/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala
@@ -5,10 +5,11 @@ trait CapturedVariables {
self: Context =>
import mirror._
+ import universe._
- def captureVariable(vble: Symbol): Unit = mirror.captureVariable(vble)
+ def captureVariable(vble: Symbol): Unit = universe.captureVariable(vble)
- def referenceCapturedVariable(vble: Symbol): Tree = mirror.referenceCapturedVariable(vble)
+ def referenceCapturedVariable(vble: Symbol): Tree = universe.referenceCapturedVariable(vble)
- def capturedVariableType(vble: Symbol): Type = mirror.capturedVariableType(vble)
+ def capturedVariableType(vble: Symbol): Type = universe.capturedVariableType(vble)
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Context.scala b/src/compiler/scala/reflect/makro/runtime/Context.scala
index ca02822788..c7563e7b67 100644
--- a/src/compiler/scala/reflect/makro/runtime/Context.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Context.scala
@@ -8,20 +8,26 @@ abstract class Context extends scala.reflect.makro.Context
with CapturedVariables
with Infrastructure
with Enclosures
+ with Mirrors
with Names
with Reifiers
with FrontEnds
with Settings
- with Symbols
with Typers
- with Util
+ with Parsers
+ with Exprs
+ with TypeTags
+ with Evals
+ with ExprUtils
with Traces {
- val mirror: Global
+ val universe: Global
- val callsiteTyper: mirror.analyzer.Typer
+ val mirror: MirrorOf[universe.type] = new ContextMirror
+
+ val callsiteTyper: universe.analyzer.Typer
val prefix: Expr[PrefixType]
val expandee: Tree
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/reflect/makro/runtime/ContextReifiers.scala b/src/compiler/scala/reflect/makro/runtime/ContextReifiers.scala
new file mode 100644
index 0000000000..564148fe6c
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/ContextReifiers.scala
@@ -0,0 +1,26 @@
+package scala.reflect.makro
+package runtime
+
+abstract class ContextReifiers { self =>
+ val c: Context
+
+ import c.universe._
+ import definitions._
+ import treeBuild._
+
+ import scala.reflect.reify.Taggers
+ import language.implicitConversions
+ private implicit def context2taggers(c0: Context) : Taggers { val c: c0.type } = new { val c: c0.type = c0 } with Taggers
+
+ private def forMacroContext[T](prefix: Tree)(op: (Tree, Tree) => T): T = {
+ val universe = gen.mkAttributedSelect(prefix.duplicate, MacroContextUniverse) setType SingleType(prefix.tpe, MacroContextUniverse)
+ val mirror = TypeApply(Select(Select(prefix.duplicate, nme.mirror), nme.asInstanceOf_), List(Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror)))
+ op(universe, mirror)
+ }
+
+ def materializeExprForMacroContext(prefix: Tree, expr: Tree): Tree =
+ forMacroContext(prefix)((universe, mirror) => c.materializeExpr(universe, mirror, expr))
+
+ def materializeTypeTagForMacroContext(prefix: Tree, tpe: Type, concrete: Boolean): Tree =
+ forMacroContext(prefix)((universe, mirror) => c.materializeTypeTag(universe, mirror, tpe, concrete))
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala b/src/compiler/scala/reflect/makro/runtime/Enclosures.scala
index ab38fc024d..80c35d22ff 100644
--- a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Enclosures.scala
@@ -4,6 +4,7 @@ package runtime
trait Enclosures {
self: Context =>
+ import universe._
import mirror._
private def site = callsiteTyper.context
@@ -16,7 +17,7 @@ trait Enclosures {
val enclosingApplication: Tree = enclTrees collectFirst { case t: Apply => t } getOrElse EmptyTree
val enclosingClass: Tree = site.enclClass.tree
val enclosingImplicits: List[(Type, Tree)] = site.openImplicits
- val enclosingMacros: List[Context] = this :: mirror.analyzer.openMacros // include self
+ val enclosingMacros: List[Context] = this :: universe.analyzer.openMacros // include self
val enclosingMethod: Tree = site.enclMethod.tree
val enclosingPosition: Position = if (enclPoses.isEmpty) NoPosition else enclPoses.head.pos
val enclosingUnit: CompilationUnit = currentRun.currentUnit
diff --git a/src/compiler/scala/reflect/makro/runtime/Evals.scala b/src/compiler/scala/reflect/makro/runtime/Evals.scala
new file mode 100644
index 0000000000..0574359a19
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/Evals.scala
@@ -0,0 +1,18 @@
+package scala.reflect.makro
+package runtime
+
+import scala.reflect.runtime.{universe => ru}
+import scala.tools.reflect.ToolBox
+
+trait Evals {
+ self: Context =>
+
+ private lazy val evalMirror = ru.runtimeMirror(libraryClassLoader)
+ private lazy val evalToolBox = evalMirror.mkToolBox()
+ private lazy val evalImporter = ru.mkImporter(universe).asInstanceOf[ru.Importer { val from: universe.type }]
+
+ def eval[T](expr: Expr[T]): T = {
+ val imported = evalImporter.importTree(expr.tree)
+ evalToolBox.runExpr(imported).asInstanceOf[T]
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Util.scala b/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala
index 2671155721..4775138e5a 100644
--- a/src/compiler/scala/reflect/makro/runtime/Util.scala
+++ b/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala
@@ -1,9 +1,10 @@
package scala.reflect.makro
package runtime
-trait Util {
+trait ExprUtils {
self: Context =>
+ import universe._
import mirror._
def literalNull = Expr[Null](Literal(Constant(null)))(TypeTag.Null)
diff --git a/src/compiler/scala/reflect/makro/runtime/Exprs.scala b/src/compiler/scala/reflect/makro/runtime/Exprs.scala
new file mode 100644
index 0000000000..b680b56bab
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/Exprs.scala
@@ -0,0 +1,8 @@
+package scala.reflect.makro
+package runtime
+
+trait Exprs {
+ self: Context =>
+
+ def Expr[T: AbsTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree))
+}
diff --git a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala b/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala
index 7cfa8e80f3..6644c579ac 100644
--- a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala
+++ b/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala
@@ -1,32 +1,35 @@
package scala.reflect.makro
package runtime
-trait FrontEnds {
+trait FrontEnds extends scala.tools.reflect.FrontEnds {
self: Context =>
+ import universe._
import mirror._
- def frontEnd: FrontEnd = wrapReporter(mirror.reporter)
+ override type Position = universe.Position
+
+ def frontEnd: FrontEnd = wrapReporter(universe.reporter)
def setFrontEnd(frontEnd: FrontEnd): this.type = {
- mirror.reporter = wrapFrontEnd(frontEnd)
+ universe.reporter = wrapFrontEnd(frontEnd)
this
}
def withFrontEnd[T](frontEnd: FrontEnd)(op: => T): T = {
- val old = mirror.reporter
+ val old = universe.reporter
setFrontEnd(frontEnd)
try op
- finally mirror.reporter = old
+ finally universe.reporter = old
}
- def echo(pos: Position, msg: String): Unit = mirror.reporter.echo(pos, msg)
+ def echo(pos: Position, msg: String): Unit = universe.reporter.echo(pos, msg)
- def info(pos: Position, msg: String, force: Boolean): Unit = mirror.reporter.info(pos, msg, force)
+ def info(pos: Position, msg: String, force: Boolean): Unit = universe.reporter.info(pos, msg, force)
- def hasWarnings: Boolean = mirror.reporter.hasErrors
+ def hasWarnings: Boolean = universe.reporter.hasErrors
- def hasErrors: Boolean = mirror.reporter.hasErrors
+ def hasErrors: Boolean = universe.reporter.hasErrors
def warning(pos: Position, msg: String): Unit = callsiteTyper.context.warning(pos, msg)
@@ -37,7 +40,7 @@ trait FrontEnds {
throw new AbortMacroException(pos, msg)
}
- def interactive(): Unit = mirror.reporter match {
+ def interactive(): Unit = universe.reporter match {
case reporter: tools.nsc.reporters.AbstractReporter => reporter.displayPrompt()
case _ => ()
}
diff --git a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala b/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
index 6d8e55cc35..76c4b21731 100644
--- a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
@@ -1,26 +1,44 @@
package scala.reflect.makro
package runtime
+import scala.tools.nsc.util.ScalaClassLoader
+
trait Infrastructure {
self: Context =>
- val forJVM: Boolean = mirror.forJVM
+ val forJVM: Boolean = universe.forJVM
+
+ val forMSIL: Boolean = universe.forMSIL
+
+ val forInteractive: Boolean = universe.forInteractive
- val forMSIL: Boolean = mirror.forMSIL
+ val forScaladoc: Boolean = universe.forScaladoc
- val forInteractive: Boolean = mirror.forInteractive
+ val currentRun: Run = universe.currentRun
- val forScaladoc: Boolean = mirror.forScaladoc
+ val libraryClassPath: List[java.net.URL] = universe.classPath.asURLs
- val currentRun: Run = mirror.currentRun
+ lazy val libraryClassLoader: ClassLoader = {
+ val classpath = libraryClassPath
+ var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
+
+ // [Eugene] a heuristic to detect REPL
+ if (universe.settings.exposeEmptyPackage.value) {
+ import scala.tools.nsc.interpreter._
+ val virtualDirectory = universe.settings.outputDirs.getSingleOutput.get
+ loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
+ }
+
+ loader
+ }
- type Run = mirror.Run
+ type Run = universe.Run
object Run extends RunExtractor {
def unapply(run: Run): Option[(CompilationUnit, List[CompilationUnit])] = Some(run.currentUnit, run.units.toList)
}
- type CompilationUnit = mirror.CompilationUnit
+ type CompilationUnit = universe.CompilationUnit
object CompilationUnit extends CompilationUnitExtractor {
def unapply(compilationUnit: CompilationUnit): Option[(java.io.File, Array[Char], Tree)] = Some(compilationUnit.source.file.file, compilationUnit.source.content, compilationUnit.body)
@@ -28,7 +46,7 @@ trait Infrastructure {
val currentMacro: Symbol = expandee.symbol
- val globalCache: collection.mutable.Map[Any, Any] = mirror.analyzer.globalMacroCache
+ val globalCache: collection.mutable.Map[Any, Any] = universe.analyzer.globalMacroCache
- val cache: collection.mutable.Map[Any, Any] = mirror.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]())
+ val cache: collection.mutable.Map[Any, Any] = universe.analyzer.perRunMacroCache.getOrElseUpdate(currentMacro, collection.mutable.Map[Any, Any]())
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Mirrors.scala b/src/compiler/scala/reflect/makro/runtime/Mirrors.scala
new file mode 100644
index 0000000000..79fa07fdb4
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/Mirrors.scala
@@ -0,0 +1,40 @@
+package scala.reflect.makro
+package runtime
+
+import scala.tools.nsc.util.ScalaClassLoader
+
+trait Mirrors {
+ self: Context =>
+
+ import universe._
+ import definitions._
+
+ class ContextMirror extends RootsBase(NoSymbol) {
+ val universe: self.universe.type = self.universe
+ def rootLoader: LazyType = rootMirror.rootLoader
+
+ val RootPackage = rootMirror.RootPackage
+ val RootClass = rootMirror.RootClass
+ val EmptyPackage = rootMirror.EmptyPackage
+ val EmptyPackageClass = rootMirror.EmptyPackageClass
+
+ // [Eugene++] this still doesn't solve the problem of invoking `c.typeCheck` on the code that refers to packageless symbols
+ override protected def mirrorMissingHook(owner: Symbol, name: Name): Symbol = {
+ if (owner.isRoot && isJavaClass(name.toString)) EmptyPackageClass.info decl name
+ else NoSymbol
+ }
+
+ private def isJavaClass(path: String): Boolean =
+ try {
+ val classpath = platform.classPath.asURLs
+ var classLoader = ScalaClassLoader.fromURLs(classpath)
+ Class.forName(path, true, classLoader)
+ true
+ } catch {
+ case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
+ false
+ }
+
+ override def toString = "macro context mirror"
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Names.scala b/src/compiler/scala/reflect/makro/runtime/Names.scala
index d8ecc2b89e..3f43b15d90 100644
--- a/src/compiler/scala/reflect/makro/runtime/Names.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Names.scala
@@ -6,15 +6,12 @@ trait Names {
lazy val freshNameCreator = callsiteTyper.context.unit.fresh
- def fresh(): String = {
+ def fresh(): String =
freshNameCreator.newName()
- }
- def fresh(name: String): String = {
+ def fresh(name: String): String =
freshNameCreator.newName(name)
- }
- def fresh(name: Name): Name = {
- name.mapName(freshNameCreator.newName(_))
- }
+ def fresh[NameType <: Name](name: NameType): NameType =
+ name.mapName(freshNameCreator.newName(_)).asInstanceOf[NameType]
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Parsers.scala b/src/compiler/scala/reflect/makro/runtime/Parsers.scala
new file mode 100644
index 0000000000..ac8d09f592
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/Parsers.scala
@@ -0,0 +1,25 @@
+package scala.reflect.makro
+package runtime
+
+import language.existentials
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.ToolBoxError
+
+trait Parsers {
+ self: Context =>
+
+ def parse(code: String): Tree =
+ // todo. provide decent implementation
+ try {
+ import scala.reflect.runtime.{universe => ru}
+ val parsed = ru.rootMirror.mkToolBox().parseExpr(code)
+ val importer = universe.mkImporter(ru)
+ importer.importTree(parsed)
+ } catch {
+ case ToolBoxError(msg, cause) =>
+ throw new ParseError(universe.NoPosition, msg)
+ }
+
+ case class ParseError(val pos: Position, val msg: String) extends Throwable(msg)
+ object ParseError extends ParseErrorExtractor
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
index 1c5af4b752..10b5ae5f42 100644
--- a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
@@ -9,26 +9,71 @@ package runtime
trait Reifiers {
self: Context =>
- import mirror._
+ val global: universe.type = universe
+ import universe._
import definitions._
- lazy val reflectMirrorPrefix: Tree = ReflectMirrorPrefix
+ lazy val basisUniverse: Tree = gen.mkBasisUniverseRef
- def reifyTree(prefix: Tree, tree: Tree): Tree = {
- val result = scala.reflect.reify.`package`.reifyTree(mirror)(callsiteTyper, prefix, tree)
+ lazy val runtimeUniverse: Tree = gen.mkRuntimeUniverseRef
+
+ def reifyTree(universe: Tree, mirror: Tree, tree: Tree): Tree = {
+ val result = scala.reflect.reify.`package`.reifyTree(self.universe)(callsiteTyper, universe, mirror, tree)
logFreeVars(enclosingPosition, result)
result
}
- def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Tree = {
- val result = scala.reflect.reify.`package`.reifyType(mirror)(callsiteTyper, prefix, tpe, dontSpliceAtTopLevel, concrete)
+ def reifyType(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean = false): Tree = {
+ val result = scala.reflect.reify.`package`.reifyType(self.universe)(callsiteTyper, universe, mirror, tpe, concrete)
logFreeVars(enclosingPosition, result)
result
}
- def reifyErasure(tpe: Type, concrete: Boolean = true): Tree =
- scala.reflect.reify.`package`.reifyErasure(mirror)(callsiteTyper, tpe, concrete)
+ def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree =
+ scala.reflect.reify.`package`.reifyRuntimeClass(universe)(callsiteTyper, tpe, concrete = concrete)
+
+ def reifyEnclosingRuntimeClass: Tree =
+ scala.reflect.reify.`package`.reifyEnclosingRuntimeClass(universe)(callsiteTyper)
+
+ def unreifyTree(tree: Tree): Tree = {
+ assert(ExprSplice != NoSymbol)
+ Select(tree, ExprSplice)
+ }
+
+ // fixme: if I put utils here, then "global" from utils' early initialization syntax
+ // and "global" that comes from here conflict with each other when incrementally compiling
+ // the problem is that both are pickled with the same owner - trait Reifiers
+ // and this upsets the compiler, so that oftentimes it throws assertion failures
+ // Martin knows the details
+ //
+ // object utils extends {
+ // val global: self.global.type = self.global
+ // val typer: global.analyzer.Typer = self.callsiteTyper
+ // } with scala.reflect.reify.utils.Utils
+ // import utils._
+
+ private def logFreeVars(position: Position, reification: Tree): Unit = {
+ object utils extends {
+ val global: self.global.type = self.global
+ val typer: global.analyzer.Typer = self.callsiteTyper
+ } with scala.reflect.reify.utils.Utils
+ import utils._
- def unreifyTree(tree: Tree): Tree =
- Select(tree, definitions.ExprEval)
+ def logFreeVars(symtab: SymbolTable): Unit =
+ // logging free vars only when they are untyped prevents avalanches of duplicate messages
+ symtab.syms map (sym => symtab.symDef(sym)) foreach {
+ case FreeTermDef(_, _, binding, _, origin) if universe.settings.logFreeTerms.value && binding.tpe == null =>
+ reporter.echo(position, "free term: %s %s".format(showRaw(binding), origin))
+ case FreeTypeDef(_, _, binding, _, origin) if universe.settings.logFreeTypes.value && binding.tpe == null =>
+ reporter.echo(position, "free type: %s %s".format(showRaw(binding), origin))
+ case _ =>
+ // do nothing
+ }
+
+ if (universe.settings.logFreeTerms.value || universe.settings.logFreeTypes.value)
+ reification match {
+ case ReifiedTree(_, _, symtab, _, _, _, _) => logFreeVars(symtab)
+ case ReifiedType(_, _, symtab, _, _, _) => logFreeVars(symtab)
+ }
+ }
}
diff --git a/src/compiler/scala/reflect/makro/runtime/Settings.scala b/src/compiler/scala/reflect/makro/runtime/Settings.scala
index 32f7115db8..8288180b8d 100644
--- a/src/compiler/scala/reflect/makro/runtime/Settings.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Settings.scala
@@ -5,12 +5,12 @@ trait Settings {
self: Context =>
def settings: List[String] = {
- val optionName = mirror.settings.XmacroSettings.name
+ val optionName = universe.settings.XmacroSettings.name
val settings = compilerSettings.find(opt => opt.startsWith(optionName)).map(opt => opt.substring(optionName.length + 1)).getOrElse("")
settings.split(",").toList
}
- def compilerSettings: List[String] = mirror.settings.recreateArgs
+ def compilerSettings: List[String] = universe.settings.recreateArgs
def setCompilerSettings(options: String): this.type =
// todo. is not going to work with quoted arguments with embedded whitespaces
@@ -19,7 +19,7 @@ trait Settings {
def setCompilerSettings(options: List[String]): this.type = {
val settings = new tools.nsc.Settings(_ => ())
// [Eugene] what settings should we exclude?
- settings.copyInto(mirror.settings)
+ settings.copyInto(universe.settings)
this
}
diff --git a/src/compiler/scala/reflect/makro/runtime/Symbols.scala b/src/compiler/scala/reflect/makro/runtime/Symbols.scala
deleted file mode 100644
index 6341523486..0000000000
--- a/src/compiler/scala/reflect/makro/runtime/Symbols.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-package scala.reflect.makro
-package runtime
-
-trait Symbols {
- self: Context =>
-
- def isLocatable(sym: Symbol) = sym.isLocatable
-
- def isStatic(sym: Symbol) = sym.isStatic
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/makro/runtime/Traces.scala b/src/compiler/scala/reflect/makro/runtime/Traces.scala
index 6b61842316..225ee1f62b 100644
--- a/src/compiler/scala/reflect/makro/runtime/Traces.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Traces.scala
@@ -4,5 +4,5 @@ package runtime
trait Traces extends util.Traces {
self: Context =>
- def globalSettings = mirror.settings
+ def globalSettings = universe.settings
}
diff --git a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala b/src/compiler/scala/reflect/makro/runtime/TypeTags.scala
new file mode 100644
index 0000000000..4f9b287674
--- /dev/null
+++ b/src/compiler/scala/reflect/makro/runtime/TypeTags.scala
@@ -0,0 +1,9 @@
+package scala.reflect.makro
+package runtime
+
+trait TypeTags {
+ self: Context =>
+
+ def AbsTypeTag[T](tpe: Type): AbsTypeTag[T] = universe.AbsTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe))
+ def TypeTag[T](tpe: Type): TypeTag[T] = universe.TypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe))
+}
diff --git a/src/compiler/scala/reflect/makro/runtime/Typers.scala b/src/compiler/scala/reflect/makro/runtime/Typers.scala
index 704d3d7ac2..18c1714d15 100644
--- a/src/compiler/scala/reflect/makro/runtime/Typers.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Typers.scala
@@ -4,11 +4,11 @@ package runtime
trait Typers {
self: Context =>
- def openMacros: List[Context] = this :: mirror.analyzer.openMacros
+ def openMacros: List[Context] = this :: universe.analyzer.openMacros
def openImplicits: List[(Type, Tree)] = callsiteTyper.context.openImplicits
- def typeCheck(tree: Tree, pt: Type = mirror.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
+ def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
macroLogVerbose("typechecking %s with expected type %s, implicit views = %s, macros = %s".format(tree, pt, !withImplicitViewsDisabled, !withMacrosDisabled))
val wrapper1 = if (!withImplicitViewsDisabled) (callsiteTyper.context.withImplicitsEnabled[Tree] _) else (callsiteTyper.context.withImplicitsDisabled[Tree] _)
val wrapper2 = if (!withMacrosDisabled) (callsiteTyper.context.withMacrosEnabled[Tree] _) else (callsiteTyper.context.withMacrosDisabled[Tree] _)
@@ -18,28 +18,28 @@ trait Typers {
// typechecking uses silent anyways (e.g. in typedSelect), so you'll only waste your time
// I'd advise fixing the root cause: finding why the context is not set to report errors
// (also see reflect.runtime.ToolBoxes.typeCheckExpr for a workaround that might work for you)
- wrapper(callsiteTyper.silent(_.typed(tree, mirror.analyzer.EXPRmode, pt)) match {
- case mirror.analyzer.SilentResultValue(result) =>
+ wrapper(callsiteTyper.silent(_.typed(tree, universe.analyzer.EXPRmode, pt)) match {
+ case universe.analyzer.SilentResultValue(result) =>
macroLogVerbose(result)
result
- case error @ mirror.analyzer.SilentTypeError(_) =>
+ case error @ universe.analyzer.SilentTypeError(_) =>
macroLogVerbose(error.err.errMsg)
- if (!silent) throw new mirror.TypeError(error.err.errPos, error.err.errMsg)
- mirror.EmptyTree
+ if (!silent) throw new universe.TypeError(error.err.errPos, error.err.errMsg)
+ universe.EmptyTree
})
}
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
macroLogVerbose("inferring implicit value of type %s, macros = %s".format(pt, !withMacrosDisabled))
- import mirror.analyzer.SearchResult
+ import universe.analyzer.SearchResult
val context = callsiteTyper.context
val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
def wrapper (inference: => SearchResult) = wrapper1(inference)
- wrapper(mirror.analyzer.inferImplicit(mirror.EmptyTree, pt, true, false, context, !silent, pos)) match {
+ wrapper(universe.analyzer.inferImplicit(universe.EmptyTree, pt, true, false, context, !silent, pos)) match {
case failure if failure.tree.isEmpty =>
macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (context.hasErrors) throw new mirror.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
- mirror.EmptyTree
+ if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
+ universe.EmptyTree
case success =>
success.tree
}
@@ -47,29 +47,29 @@ trait Typers {
def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true, pos: Position = enclosingPosition): Tree = {
macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s, reportAmbiguous = %s".format(from, to, tree, !withMacrosDisabled, reportAmbiguous))
- import mirror.analyzer.SearchResult
+ import universe.analyzer.SearchResult
val context = callsiteTyper.context
val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
def wrapper (inference: => SearchResult) = wrapper1(inference)
- val fun1 = mirror.definitions.FunctionClass(1)
- val viewTpe = mirror.TypeRef(fun1.typeConstructor.prefix, fun1, List(from, to))
- wrapper(mirror.analyzer.inferImplicit(tree, viewTpe, reportAmbiguous, true, context, !silent, pos)) match {
+ val fun1 = universe.definitions.FunctionClass(1)
+ val viewTpe = universe.TypeRef(fun1.typeConstructor.prefix, fun1, List(from, to))
+ wrapper(universe.analyzer.inferImplicit(tree, viewTpe, reportAmbiguous, true, context, !silent, pos)) match {
case failure if failure.tree.isEmpty =>
macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (context.hasErrors) throw new mirror.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
- mirror.EmptyTree
+ if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
+ universe.EmptyTree
case success =>
success.tree
}
}
- type TypeError = mirror.TypeError
+ type TypeError = universe.TypeError
object TypeError extends TypeErrorExtractor {
def unapply(error: TypeError): Option[(Position, String)] = Some((error.pos, error.msg))
}
- def resetAllAttrs(tree: Tree): Tree = mirror.resetAllAttrs(tree)
+ def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(tree)
- def resetLocalAttrs(tree: Tree): Tree = mirror.resetLocalAttrs(tree)
+ def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(tree)
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala
index 4466f281b8..714795503b 100644
--- a/src/compiler/scala/reflect/reify/Errors.scala
+++ b/src/compiler/scala/reflect/reify/Errors.scala
@@ -1,5 +1,4 @@
-package scala.reflect
-package reify
+package scala.reflect.reify
import scala.reflect.makro.ReificationError
import scala.reflect.makro.UnexpectedReificationError
@@ -7,10 +6,13 @@ import scala.reflect.makro.UnexpectedReificationError
trait Errors {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- def defaultErrorPosition = analyzer.enclosingMacroPosition
+ def defaultErrorPosition = {
+ val stack = currents collect { case t: Tree if t.pos != NoPosition => t.pos }
+ stack.headOption getOrElse analyzer.enclosingMacroPosition
+ }
// expected errors: these can happen if the user casually writes whatever.reify(...)
// hence we don't crash here, but nicely report a typechecking error and bail out asap
@@ -30,11 +32,28 @@ trait Errors {
throw new ReificationError(defaultErrorPosition, msg)
}
- def CannotReifyConcreteTypeTagHavingUnresolvedTypeParameters(tpe: Type) = {
- val msg = "cannot reify ConcreteTypeTag having unresolved type parameter %s".format(tpe)
+ def CannotReifyTypeTagHavingUnresolvedTypeParameters(tpe: Type) = {
+ val msg = "cannot reify TypeTag having unresolved type parameter %s".format(tpe)
+ throw new ReificationError(defaultErrorPosition, msg)
+ }
+
+ def CannotConvertManifestToTagWithoutScalaReflect(tpe: Type, manifestInScope: Tree) = {
+ val msg = s"""
+ |to create a type tag here, it is necessary to interoperate with the manifest `$manifestInScope` in scope.
+ |however manifest -> typetag conversion requires Scala reflection, which is not present on the classpath.
+ |to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin
throw new ReificationError(defaultErrorPosition, msg)
}
+ def CannotReifyRuntimeSplice(tree: Tree) = {
+ val msg = """
+ |the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+ |cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+ |if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+ |import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.""".trim.stripMargin
+ throw new ReificationError(tree.pos, msg)
+ }
+
// unexpected errors: these can never happen under normal conditions unless there's a bug in the compiler (or in a compiler plugin or in a macro)
// hence, we fail fast and loudly and don't care about being nice - in this situation noone will appreciate our quiet nicety
diff --git a/src/compiler/scala/reflect/reify/NodePrinters.scala b/src/compiler/scala/reflect/reify/NodePrinters.scala
deleted file mode 100644
index eaca9a4968..0000000000
--- a/src/compiler/scala/reflect/reify/NodePrinters.scala
+++ /dev/null
@@ -1,111 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Martin Odersky
- */
-
-package scala.reflect
-package reify
-
-import scala.Array.canBuildFrom
-import scala.compat.Platform.EOL
-import scala.tools.nsc.symtab.Flags
-import scala.tools.nsc.Global
-
-trait NodePrinters { self: scala.tools.nsc.ast.NodePrinters =>
-
- val global: Global
- import global._
-
- object reifiedNodeToString extends Function2[Tree, Tree, String] {
- def apply(prefix: Tree, tree: Tree): String = {
- import scala.reflect.api.Modifier
- var modifierIsUsed = false
- var flagsAreUsed = false
-
- // @PP: I fervently hope this is a test case or something, not anything being
- // depended upon. Of more fragile code I cannot conceive.
- // @Eugene: This stuff is only needed to debug-print out reifications in human-readable format
- // Rolling a full-fledged, robust TreePrinter would be several times more code.
- val (List(mirror), reified) = (for (line <- (tree.toString.split(EOL).toList drop 1 dropRight 1)) yield {
- var s = line.trim
- s = s.replace("$mr.", "")
- s = s.replace(".apply", "")
- s = s.replace("scala.collection.immutable.", "")
- s = "List\\[List\\[.*?\\].*?\\]".r.replaceAllIn(s, "List")
- s = "List\\[.*?\\]".r.replaceAllIn(s, "List")
- s = s.replace("immutable.this.Nil", "List()")
- s = s.replace("modifiersFromInternalFlags", "Modifiers")
- s = s.replace("Modifiers(0L, newTypeName(\"\"), List())", "Modifiers()")
- s = """Modifiers\((\d+)[lL], newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => {
- val buf = new collection.mutable.ListBuffer[String]
-
- val annotations = m.group(3)
- if (buf.nonEmpty || annotations.nonEmpty)
- buf.append("List(" + annotations + ")")
-
- val privateWithin = "" + m.group(2)
- if (buf.nonEmpty || privateWithin != "")
- buf.append("newTypeName(\"" + privateWithin + "\")")
-
- val flags = m.group(1).toLong
- val s_flags = Flags.modifiersOfFlags(flags) map (_.sourceString) mkString ", "
- if (buf.nonEmpty || s_flags != "") {
- modifierIsUsed = true
- buf.append("Set(" + s_flags + ")")
- }
-
- "Modifiers(" + buf.reverse.mkString(", ") + ")"
- })
- s = """setInternalFlags\((\d+)L\)""".r.replaceAllIn(s, m => {
- flagsAreUsed = true
- val flags = m.group(1).toLong
- val mods = Flags.modifiersOfFlags(flags) map (_.sourceString)
- "setInternalFlags(flagsOfModifiers(List(" + mods.mkString(", ") + ")))"
- })
-
- s
- }) splitAt 1
-
- val printout = collection.mutable.ListBuffer(mirror);
- printout += "import " + nme.MIRROR_SHORT + "._"
- if (modifierIsUsed) printout += "import scala.reflect.api.Modifier._"
- if (flagsAreUsed) printout += "import scala.reflect.internal.Flags._"
- val body = reified dropWhile (_.startsWith("val"))
- if (body.length > 0 && body(0).startsWith("Expr[")) {
- if (reified(0) startsWith "val") {
- printout += "val code = {"
- printout ++= (reified map (" " + _))
- printout += "}"
- printout += "mkToolBox().runExpr(code)"
- } else {
- printout += "val code = " + reified(0)
- printout ++= reified drop 1
- printout += "mkToolBox().runExpr(code)"
- }
- try {
- val prefix = Select(Select(Ident(definitions.ScalaPackage), newTermName("reflect")), newTermName("mirror"))
- val tree1 = new global.Transformer {
- override def transform(tree: Tree) = super.transform(tree match {
- case Block(ValDef(_, mr, _, _) :: Nil, expr) if mr == nme.MIRROR_SHORT => transform(expr)
- case Block(ValDef(_, mr, _, _) :: symbolTable, expr) if mr == nme.MIRROR_SHORT => transform(Block(symbolTable, expr))
- case Select(Ident(mr), name) if mr == nme.MIRROR_SHORT => Select(prefix, name)
- case tree => tree
- })
- }.transform(tree)
- val stringified = mkToolBox().runExpr(tree1).toString
- if (settings.Yreifydebug.value) printout += "*****************************"
- printout += stringified
- } catch {
- case ex: Throwable =>
-// val realex = ReflectionUtils.unwrapThrowable(ex)
-// val message = new java.io.StringWriter()
-// realex.printStackTrace(new java.io.PrintWriter(message))
-// println(message)
- }
- } else {
- printout ++= reified
- }
- printout mkString EOL
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/Phases.scala b/src/compiler/scala/reflect/reify/Phases.scala
index 49d5a45e8e..1710cae2a5 100644
--- a/src/compiler/scala/reflect/reify/Phases.scala
+++ b/src/compiler/scala/reflect/reify/Phases.scala
@@ -1,16 +1,15 @@
-package scala.reflect
-package reify
+package scala.reflect.reify
-import scala.reflect.reify.phases._
+import phases._
-trait Phases extends Calculate
- with Reshape
+trait Phases extends Reshape
+ with Calculate
with Metalevels
with Reify {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
private var alreadyRun = false
@@ -26,16 +25,19 @@ trait Phases extends Calculate
if (reifyDebug) println("[reshape phase]")
tree = reshape.transform(tree)
+ if (reifyDebug) println("[interlude]")
+ if (reifyDebug) println("reifee = " + (if (opt.showTrees) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString))
+
+ if (reifyDebug) println("[calculate phase]")
+ calculate.traverse(tree)
if (reifyDebug) println("[metalevels phase]")
tree = metalevels.transform(tree)
-
if (reifyDebug) println("[interlude]")
- if (reifyDebug) println("symbol table = " + (if (symbolTable.length == 0) "<empty>" else ""))
- if (reifyDebug) symbolTable foreach (println(_))
- if (reifyDebug) println("reifee = " + (if (opt.showTrees) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString))
+ if (reifyDebug) println(symtab.debugString)
+
if (reifyDebug) println("[reify phase]")
- var result = reify(tree)
+ val result = reify(tree)
result
}
diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala
index fea825358e..00f25f0d8b 100644
--- a/src/compiler/scala/reflect/reify/Reifier.scala
+++ b/src/compiler/scala/reflect/reify/Reifier.scala
@@ -1,9 +1,9 @@
-package scala.reflect
-package reify
+package scala.reflect.reify
import scala.tools.nsc.Global
import scala.reflect.makro.ReificationError
import scala.reflect.makro.UnexpectedReificationError
+import scala.reflect.reify.utils.Utils
/** Given a tree or a type, generate a tree that when executed at runtime produces the original tree or type.
* See more info in the comments to ``reify'' in scala.reflect.api.Universe.
@@ -11,51 +11,59 @@ import scala.reflect.makro.UnexpectedReificationError
* @author Martin Odersky
* @version 2.10
*/
-abstract class Reifier extends Phases
- with Errors {
+abstract class Reifier extends States
+ with Phases
+ with Errors
+ with Utils {
- val mirror: Global
- import mirror._
+ val global: Global
+ import global._
import definitions._
- import treeInfo._
- val typer: mirror.analyzer.Typer
- val prefix: Tree
+ val typer: global.analyzer.Typer
+ val universe: Tree
+ val mirror: Tree
val reifee: Any
- val dontSpliceAtTopLevel: Boolean
val concrete: Boolean
+ // needed to seamlessly integrate with standalone utils
+ override def getReifier: Reifier { val global: Reifier.this.global.type } =
+ this.asInstanceOf[Reifier { val global: Reifier.this.global.type }]
+ override def hasReifier = true
+
/**
* For ``reifee'' and other reification parameters, generate a tree of the form
*
* {
- * val $mr = <[ prefix ]>
- * $mr.Expr[T](rtree) // if data is a Tree
- * $mr.TypeTag[T](rtree) // if data is a Type
+ * val $u: universe.type = <[ universe ]>
+ * val $m: $u.Mirror = <[ mirror ]>
+ * $u.Expr[T](rtree) // if data is a Tree
+ * $u.TypeTag[T](rtree) // if data is a Type
* }
*
* where
*
- * - `prefix` is the tree that represents the universe
- * the result will be bound to
+ * - `universe` is the tree that represents the universe the result will be bound to
+ * - `mirror` is the tree that represents the mirror the result will be initially bound to
* - `rtree` is code that generates `reifee` at runtime.
* - `T` is the type that corresponds to `data`.
*
* This is not a method, but a value to indicate the fact that Reifier instances are a one-off.
*/
- lazy val reified: Tree = {
+ lazy val reification: Tree = {
try {
// [Eugene] conventional way of doing this?
- if (prefix exists (_.isErroneous)) CannotReifyErroneousPrefix(prefix)
- if (prefix.tpe == null) CannotReifyUntypedPrefix(prefix)
+ if (universe exists (_.isErroneous)) CannotReifyErroneousPrefix(universe)
+ if (universe.tpe == null) CannotReifyUntypedPrefix(universe)
- val rtree = reifee match {
+ val result = reifee match {
case tree: Tree =>
reifyTrace("reifying = ")(if (opt.showTrees) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString)
reifyTrace("reifee is located at: ")(tree.pos)
- reifyTrace("prefix = ")(prefix)
+ reifyTrace("universe = ")(universe)
+ reifyTrace("mirror = ")(mirror)
// [Eugene] conventional way of doing this?
- if (tree exists (_.isErroneous)) CannotReifyErroneousReifee(prefix)
+ if (tree exists (_.isErroneous)) CannotReifyErroneousReifee(tree)
if (tree.tpe == null) CannotReifyUntypedReifee(tree)
val pipeline = mkReificationPipeline
val rtree = pipeline(tree)
@@ -74,31 +82,23 @@ abstract class Reifier extends Phases
if (tree.tpe exists (sub => sub.typeSymbol.isLocalToReifee))
CannotReifyReifeeThatHasTypeLocalToReifee(tree)
- val taggedType = typer.packedType(tree, NoSymbol)
- val tagModule = if (reificationIsConcrete) ConcreteTypeTagModule else TypeTagModule
- val tagCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(taggedType)))
- val exprCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), ExprModule.name), List(TypeTree(taggedType)))
- val tagArgs = List(reify(taggedType), reifyErasure(mirror)(typer, taggedType, concrete = false))
- Apply(Apply(exprCtor, List(rtree)), List(Apply(tagCtor, tagArgs)))
+ val tpe = typer.packedType(tree, NoSymbol)
+ val ReifiedType(_, _, tpeSymtab, _, rtpe, tpeReificationIsConcrete) = `package`.reifyType(global)(typer, universe, mirror, tpe, concrete = false)
+ state.reificationIsConcrete &= tpeReificationIsConcrete
+ state.symtab ++= tpeSymtab
+ ReifiedTree(universe, mirror, symtab, rtree, tpe, rtpe, reificationIsConcrete)
case tpe: Type =>
reifyTrace("reifying = ")(tpe.toString)
- reifyTrace("prefix = ")(prefix)
+ reifyTrace("universe = ")(universe)
+ reifyTrace("mirror = ")(mirror)
val rtree = reify(tpe)
-
- val taggedType = tpe
- val tagModule = if (reificationIsConcrete) ConcreteTypeTagModule else TypeTagModule
- val ctor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(taggedType)))
- val args = List(rtree, reifyErasure(mirror)(typer, taggedType, concrete = false))
- Apply(ctor, args)
+ ReifiedType(universe, mirror, symtab, tpe, rtree, reificationIsConcrete)
case _ =>
throw new Error("reifee %s of type %s is not supported".format(reifee, if (reifee == null) "null" else reifee.getClass.toString))
}
- val mirrorAlias = ValDef(NoMods, nme.MIRROR_SHORT, SingletonTypeTree(prefix), prefix)
- val wrapped = Block(mirrorAlias :: symbolTable, rtree)
-
// todo. why do we resetAllAttrs?
//
// typically we do some preprocessing before reification and
@@ -107,14 +107,14 @@ abstract class Reifier extends Phases
//
// ===example 1===
// we move a freevar from a nested symbol table to a top-level symbol table,
- // and then the reference to mr$ becomes screwed up, because nested symbol tables are already typechecked,
- // so we have an mr$ symbol that points to the nested mr$ rather than to the top-level one.
+ // and then the reference to $u becomes screwed up, because nested symbol tables are already typechecked,
+ // so we have an $u symbol that points to the nested $u rather than to the top-level one.
//
// ===example 2===
- // we inline a freevar by replacing a reference to it, e.g. $mr.Apply($mr.Select($mr.Ident($mr.newTermName("$mr")), $mr.newTermName("Ident")), List($mr.Ident($mr.newTermName("free$x"))))
- // with its original binding (e.g. $mr.Ident("x"))
- // we'd love to typecheck the result, but we cannot do this easily, because $mr is external to this tree
- // what's even worse, sometimes $mr can point to the top-level symbol table's $mr, which doesn't have any symbol/type yet -
+ // we inline a freevar by replacing a reference to it, e.g. $u.Apply($u.Select($u.Ident($u.newTermName("$u")), $u.newTermName("Ident")), List($u.Ident($u.newTermName("free$x"))))
+ // with its original binding (e.g. $u.Ident("x"))
+ // we'd love to typecheck the result, but we cannot do this easily, because $u is external to this tree
+ // what's even worse, sometimes $u can point to the top-level symbol table's $u, which doesn't have any symbol/type yet -
// it's just a ValDef that will be emitted only after the reification is completed
//
// hence, the simplest solution is to erase all attrs so that invalid (as well as non-existent) bindings get rebound correctly
@@ -124,31 +124,30 @@ abstract class Reifier extends Phases
// needs to be solved some day
//
// list of non-hygienic transformations:
- // 1) local freetype inlining in Nested
- // 2) external freevar moving in Nested
- // 3) local freeterm inlining in Metalevels
- // 4) trivial tree splice inlining in Reify (Trees.scala)
- // 5) trivial type splice inlining in Reify (Types.scala)
- val freevarBindings = symbolTable collect { case entry @ FreeDef(_, _, binding, _, _) => binding.symbol } toSet
- // [Eugene] yeah, ugly and extremely brittle, but we do need to do resetAttrs. will be fixed later
- var importantSymbols = Set[Symbol](PredefModule, ScalaRunTimeModule)
+ // todo. to be updated
+ // [Eugene++] yeah, ugly and extremely brittle, but we do need to do resetAttrs. will be fixed later
+ // todo. maybe try `resetLocalAttrs` once the dust settles
+ var importantSymbols = Set[Symbol](
+ NothingClass, AnyClass, SingletonClass, PredefModule, ScalaRunTimeModule, TypeCreatorClass, TreeCreatorClass, MirrorOfClass,
+ BaseUniverseClass, ApiUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror)
importantSymbols ++= importantSymbols map (_.companionSymbol)
importantSymbols ++= importantSymbols map (_.moduleClass)
importantSymbols ++= importantSymbols map (_.linkedClassOfClass)
- def importantSymbol(sym: Symbol): Boolean = sym != null && sym != NoSymbol && importantSymbols(sym)
- val untyped = resetAllAttrs(wrapped, leaveAlone = {
- case ValDef(_, mr, _, _) if mr == nme.MIRROR_SHORT => true
- case tree if freevarBindings contains tree.symbol => true
- case tree if importantSymbol(tree.symbol) => true
+ def isImportantSymbol(sym: Symbol): Boolean = sym != null && sym != NoSymbol && importantSymbols(sym)
+ val untyped = resetAllAttrs(result, leaveAlone = {
+ case ValDef(_, u, _, _) if u == nme.UNIVERSE_SHORT => true
+ case ValDef(_, m, _, _) if m == nme.MIRROR_SHORT => true
+ case tree if symtab.syms contains tree.symbol => true
+ case tree if isImportantSymbol(tree.symbol) => true
case _ => false
})
if (reifyCopypaste) {
if (reifyDebug) println("=============================")
- println(reifiedNodeToString(prefix, untyped))
+ println(reifiedNodeToString(untyped))
if (reifyDebug) println("=============================")
} else {
- reifyTrace("reified = ")(untyped)
+ reifyTrace("reification = ")(untyped)
}
untyped
diff --git a/src/compiler/scala/reflect/reify/States.scala b/src/compiler/scala/reflect/reify/States.scala
new file mode 100644
index 0000000000..a01cfe5d74
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/States.scala
@@ -0,0 +1,65 @@
+package scala.reflect.reify
+
+trait States {
+ self: Reifier =>
+
+ import global._
+ import definitions._
+
+ /** Encapsulates reifier state
+ *
+ * When untangling reifier symbol tables from the reifier itself,
+ * I discovered that encoding of a symbol table (e.g. producing corresponding reificode)
+ * might cause subsequent reification (e.g. when filling in signatures and annotations for syms).
+ *
+ * This is a mess in the face of nested reifications, splices and inlining of thereof,
+ * so I made `SymbolTable` immutable, which brought a significant amount of sanity.
+ *
+ * However that wasn't enough. Sure, symbol table became immutable, but the reifier still needed
+ * to mutate its `symtab` field during reification. This caused nasty desyncs between the table being encoded
+ * and the table of the underlying reifier, so I decided to encapsulate the entire state here,
+ * so that encoding can backup the state before it starts and restore it after it completes.
+ */
+ val state = new State
+
+ // todo. rewrite the reifier so that we don't need mutable state anymore
+ // to aid you with that I've already removed all the setters from the reifier
+ // so all the places that involve mutations are forced to do that by explicitly mentioning `state`
+ class State {
+ var symtab = SymbolTable()
+ var reifyTreeSymbols = false
+ var reifyTreeTypes = false
+ private var _reificationIsConcrete = true
+ def reificationIsConcrete: Boolean = _reificationIsConcrete
+ def reificationIsConcrete_=(value: Boolean): Unit = {
+ _reificationIsConcrete = value
+ if (!value && concrete) {
+ assert(current.isInstanceOf[Type], current)
+ val offender = current.asInstanceOf[Type]
+ CannotReifyTypeTagHavingUnresolvedTypeParameters(offender)
+ }
+ }
+ var reifyStack = reifee :: Nil
+ var localSymbols = Map[Symbol, Int]()
+
+ def backup: State = {
+ val backup = new State
+ backup.symtab = this.symtab
+ backup.reifyTreeSymbols = this.reifyTreeSymbols
+ backup.reifyTreeTypes = this.reifyTreeTypes
+ backup._reificationIsConcrete = this._reificationIsConcrete
+ backup.reifyStack = this.reifyStack
+ backup.localSymbols = this.localSymbols
+ backup
+ }
+
+ def restore(backup: State): Unit = {
+ this.symtab = backup.symtab
+ this.reifyTreeSymbols = backup.reifyTreeSymbols
+ this.reifyTreeTypes = backup.reifyTreeTypes
+ this._reificationIsConcrete = backup._reificationIsConcrete
+ this.reifyStack = backup.reifyStack
+ this.localSymbols = backup.localSymbols
+ }
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala
new file mode 100644
index 0000000000..b70c3f44a3
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/Taggers.scala
@@ -0,0 +1,103 @@
+package scala.reflect.reify
+
+import scala.reflect.makro.{ReificationError, UnexpectedReificationError}
+import scala.reflect.makro.runtime.Context
+
+abstract class Taggers {
+ val c: Context
+
+ import c.universe._
+ import definitions._
+ import treeBuild._
+
+ val coreTags = Map(
+ ByteClass.asType -> nme.Byte,
+ ShortClass.asType -> nme.Short,
+ CharClass.asType -> nme.Char,
+ IntClass.asType -> nme.Int,
+ LongClass.asType -> nme.Long,
+ FloatClass.asType -> nme.Float,
+ DoubleClass.asType -> nme.Double,
+ BooleanClass.asType -> nme.Boolean,
+ UnitClass.asType -> nme.Unit,
+ AnyClass.asType -> nme.Any,
+ ObjectClass.asType -> nme.Object,
+ NothingClass.asType -> nme.Nothing,
+ NullClass.asType -> nme.Null,
+ StringClass.asType -> nme.String)
+
+ def materializeClassTag(prefix: Tree, tpe: Type): Tree = {
+ val tagModule = ClassTagModule
+ materializeTag(prefix, tpe, tagModule, {
+ val erasure = c.reifyRuntimeClass(tpe, concrete = true)
+ val factory = TypeApply(Select(Ident(tagModule), nme.apply), List(TypeTree(tpe)))
+ Apply(factory, List(erasure))
+ })
+ }
+
+ def materializeTypeTag(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean): Tree = {
+ if (universe.symbol == MacroContextUniverse && mirror == EmptyTree) {
+ import scala.reflect.makro.runtime.ContextReifiers
+ import language.implicitConversions
+ implicit def context2contextreifiers(c0: Context) : ContextReifiers { val c: c0.type } = new { val c: c0.type = c0 } with ContextReifiers
+ val Select(prefix, _) = universe
+ c.materializeTypeTagForMacroContext(prefix, tpe, concrete)
+ } else {
+ val tagType = if (concrete) TypeTagClass else AbsTypeTagClass
+ val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.asTypeConstructor, tagType, List(tpe))
+ val unaffiliatedTag = c.inferImplicitValue(unaffiliatedTagTpe, silent = true, withMacrosDisabled = true)
+ unaffiliatedTag match {
+ case success if !success.isEmpty =>
+ Apply(Select(success, nme.in), List(mirror orElse mkDefaultMirrorRef(c.universe)(universe, c.callsiteTyper)))
+ case _ =>
+ val tagModule = if (concrete) TypeTagModule else AbsTypeTagModule
+ materializeTag(universe, tpe, tagModule, c.reifyType(universe, mirror, tpe, concrete = concrete))
+ }
+ }
+ }
+
+ private def materializeTag(prefix: Tree, tpe: Type, tagModule: Symbol, materializer: => Tree): Tree = {
+ val result =
+ tpe match {
+ case coreTpe if coreTags contains coreTpe =>
+ val ref = if (tagModule.owner.isPackageClass) Ident(tagModule) else Select(prefix, tagModule.name)
+ Select(ref, coreTags(coreTpe))
+ case _ =>
+ translatingReificationErrors(materializer)
+ }
+ try c.typeCheck(result)
+ catch { case terr @ c.TypeError(pos, msg) => failTag(result, terr) }
+ }
+
+ def materializeExpr(universe: Tree, mirror: Tree, expr: Tree): Tree = {
+ val result = translatingReificationErrors(c.reifyTree(universe, mirror, expr))
+ try c.typeCheck(result)
+ catch { case terr @ c.TypeError(pos, msg) => failExpr(result, terr) }
+ }
+
+ private def translatingReificationErrors(materializer: => Tree): Tree = {
+ try materializer
+ catch {
+ case ReificationError(pos, msg) =>
+ c.error(pos.asInstanceOf[c.Position], msg) // this cast is a very small price for the sanity of exception handling
+ EmptyTree
+ case UnexpectedReificationError(pos, err, cause) if cause != null =>
+ throw cause
+ }
+ }
+
+ private def failTag(result: Tree, reason: Any): Nothing = {
+ val Apply(TypeApply(fun, List(tpeTree)), _) = c.macroApplication
+ val tpe = tpeTree.tpe
+ val PolyType(_, MethodType(_, tagTpe)) = fun.tpe
+ val tagModule = tagTpe.typeSymbol.companionSymbol
+ if (c.compilerSettings.contains("-Xlog-implicits"))
+ c.echo(c.enclosingPosition, s"cannot materialize ${tagModule.name}[$tpe] as $result because:\n$reason")
+ c.abort(c.enclosingPosition, "No %s available for %s".format(tagModule.name, tpe))
+ }
+
+ private def failExpr(result: Tree, reason: Any): Nothing = {
+ val Apply(_, expr :: Nil) = c.macroApplication
+ c.abort(c.enclosingPosition, s"Cannot materialize $expr as $result because:\n$reason")
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/codegen/AnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala
index 1d218317dc..5f4296f54f 100644
--- a/src/compiler/scala/reflect/reify/codegen/AnnotationInfos.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala
@@ -1,12 +1,11 @@
package scala.reflect.reify
package codegen
-trait AnnotationInfos {
+trait GenAnnotationInfos {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
// usually annotations are reified as their originals from Modifiers
// however, when reifying free and tough types, we're forced to reify annotation infos as is
@@ -26,8 +25,8 @@ trait AnnotationInfos {
// reflective typechecker will fill in missing symbols and types, right?
// A: actually, no. annotation ASTs live inside AnnotatedTypes,
// and insides of the types is the place where typechecker doesn't look.
- reifyTreeSymbols = true
- reifyTreeTypes = true
+ state.reifyTreeSymbols = true
+ state.reifyTreeTypes = true
// todo. every AnnotationInfo is an island, entire of itself
// no regular Traverser or Transformer can reach it
@@ -35,8 +34,8 @@ trait AnnotationInfos {
// e.g. to apply reshaping or to check metalevels
reify(arg)
} finally {
- reifyTreeSymbols = saved1
- reifyTreeTypes = saved2
+ state.reifyTreeSymbols = saved1
+ state.reifyTreeTypes = saved2
}
}
diff --git a/src/compiler/scala/reflect/reify/codegen/Names.scala b/src/compiler/scala/reflect/reify/codegen/GenNames.scala
index 589f6355d0..4abf88f475 100644
--- a/src/compiler/scala/reflect/reify/codegen/Names.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenNames.scala
@@ -1,12 +1,11 @@
package scala.reflect.reify
package codegen
-trait Names {
+trait GenNames {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
def reifyName(name: Name) = {
val factory = if (name.isTypeName) nme.nmeNewTypeName else nme.nmeNewTermName
diff --git a/src/compiler/scala/reflect/reify/codegen/Positions.scala b/src/compiler/scala/reflect/reify/codegen/GenPositions.scala
index ac9195ef31..8c5db04454 100644
--- a/src/compiler/scala/reflect/reify/codegen/Positions.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenPositions.scala
@@ -1,12 +1,11 @@
package scala.reflect.reify
package codegen
-trait Positions {
+trait GenPositions {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
// we do not reify positions because this inflates resulting trees, but doesn't buy as anything
// where would one use positions? right, in error messages
diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
new file mode 100644
index 0000000000..3a98d308a7
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
@@ -0,0 +1,109 @@
+package scala.reflect.reify
+package codegen
+
+trait GenSymbols {
+ self: Reifier =>
+
+ import global._
+ import definitions._
+
+ /** Symbol table of the reifee.
+ *
+ * Keeps track of auxiliary symbols that are necessary for this reification session.
+ * These include:
+ * 1) Free vars (terms, types and existentials),
+ * 2) Non-locatable symbols (sometimes, e.g. for RefinedTypes, we need to reify these; to do that we create their local copies in the reificode)
+ * 3) Non-locatable symbols that are referred by #1, #2 and #3
+ *
+ * Exposes three main methods:
+ * 1) `syms` that lists symbols belonging to the table,
+ * 2) `symXXX` family of methods that provide information about the symbols in the table,
+ * 3) `encode` that renders the table into a list of trees (recursively populating #3 and setting up initialization code for #1, #2 and #3)
+ */
+ def symtab: SymbolTable = state.symtab
+
+ /** Reify a reference to a symbol */
+ def reifySymRef(sym0: Symbol): Tree = {
+ assert(sym0 != null, "sym is null")
+ val sym = sym0.dealias
+
+ if (sym == NoSymbol)
+ mirrorSelect(nme.NoSymbol)
+ else if (sym.isRootPackage)
+ mirrorMirrorSelect(nme.RootPackage)
+ else if (sym.isRoot)
+ mirrorMirrorSelect(nme.RootClass)
+ else if (sym.isEmptyPackage)
+ mirrorMirrorSelect(nme.EmptyPackage)
+ else if (sym.isEmptyPackageClass)
+ mirrorMirrorSelect(nme.EmptyPackageClass)
+ else if (sym.isModuleClass)
+ Select(Select(reify(sym.sourceModule), nme.asModuleSymbol), nme.moduleClass)
+ else if (sym.isLocatable) {
+ // [Eugene] am I doing this right?
+// if (sym.isStaticOwner) { // no good for us, because it returns false for packages
+ if (sym.isStatic && (sym.isClass || sym.isModule)) {
+ val resolver = if (sym.isType) nme.staticClass else nme.staticModule
+ mirrorMirrorCall(resolver, reify(sym.fullName))
+ } else {
+ if (reifyDebug) println("Locatable: %s (%s) owned by %s (%s) at %s".format(sym, sym.accurateKindString, sym.owner, sym.owner.accurateKindString, sym.owner.fullNameString))
+ val rowner = reify(sym.owner)
+ val rname = reify(sym.name.toString)
+ if (sym.isType)
+ mirrorBuildCall(nme.selectType, rowner, rname)
+ else if (sym.isMethod && sym.owner.isClass && sym.owner.info.decl(sym.name).isOverloaded) {
+ val index = sym.owner.info.decl(sym.name).alternatives indexOf sym
+ assert(index >= 0, sym)
+ mirrorBuildCall(nme.selectOverloadedMethod, rowner, rname, reify(index))
+ } else
+ mirrorBuildCall(nme.selectTerm, rowner, rname)
+ }
+ } else {
+ // todo. make sure that free methods and free local defs work correctly
+ if (sym.isTerm) reifyFreeTerm(sym, Ident(sym))
+ else reifyFreeType(sym, Ident(sym))
+ }
+ }
+
+ def reifyFreeTerm(sym: Symbol, value: Tree): Tree =
+ reifyIntoSymtab(sym) {
+ if (reifyDebug) println("Free term" + (if (sym.isCapturedVariable) " (captured)" else "") + ": " + sym + "(" + sym.accurateKindString + ")")
+ var name = newTermName(nme.REIFY_FREE_PREFIX + sym.name)
+ if (sym.isType) name = name.append(nme.REIFY_FREE_THIS_SUFFIX)
+ if (sym.isCapturedVariable) {
+ assert(value.isInstanceOf[Ident], showRaw(value))
+ val capturedTpe = capturedVariableType(sym)
+ val capturedValue = referenceCapturedVariable(sym)
+ (name, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), reify(capturedTpe), capturedValue, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym))))
+ } else {
+ (name, mirrorBuildCall(nme.newFreeTerm, reify(sym.name.toString), reify(sym.tpe), value, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym))))
+ }
+ }
+
+ def reifyFreeType(sym: Symbol, value: Tree): Tree =
+ reifyIntoSymtab(sym) {
+ if (reifyDebug) println("Free type: %s (%s)".format(sym, sym.accurateKindString))
+ var name = newTermName(nme.REIFY_FREE_PREFIX + sym.name)
+ val phantomTypeTag = Apply(TypeApply(Select(Ident(nme.UNIVERSE_SHORT), nme.TypeTag), List(value)), List(Literal(Constant(null)), Literal(Constant(null))))
+ val flavor = if (sym.isExistential) nme.newFreeExistential else nme.newFreeType
+ (name, mirrorBuildCall(flavor, reify(sym.name.toString), reify(sym.info), phantomTypeTag, mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(origin(sym))))
+ }
+
+ def reifySymDef(sym: Symbol): Tree =
+ reifyIntoSymtab(sym) {
+ if (reifyDebug) println("Sym def: %s (%s)".format(sym, sym.accurateKindString))
+ assert(!sym.isLocatable, sym) // if this assertion fires, then tough type reification needs to be rethought
+ sym.owner.ownersIterator find (!_.isLocatable) foreach reifySymDef
+ var name = newTermName(nme.REIFY_SYMDEF_PREFIX + sym.name)
+ (name, mirrorBuildCall(nme.newNestedSymbol, reify(sym.owner), reify(sym.name), reify(sym.pos), mirrorBuildCall(nme.flagsFromBits, reify(sym.flags)), reify(sym.isClass)))
+ }
+
+ private def reifyIntoSymtab(sym: Symbol)(reificode: => (TermName, Tree)): Tree ={
+ def fromSymtab = symtab symRef sym
+ if (fromSymtab == EmptyTree) {
+ val reification = reificode
+ state.symtab += (sym, reification._1, reification._2)
+ }
+ fromSymtab
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/codegen/Trees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala
index c9f5fc5b8d..b97bf6b0cd 100644
--- a/src/compiler/scala/reflect/reify/codegen/Trees.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala
@@ -1,18 +1,17 @@
package scala.reflect.reify
package codegen
-trait Trees {
+trait GenTrees {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
- import scala.reflect.api.Modifier
// unfortunately, these are necessary to reify AnnotatedTypes
- // I'd gladly got rid of them, but I don't fancy making a metaprogramming API that doesn't work with annotated types
- var reifyTreeSymbols = false
- var reifyTreeTypes = false
+ // I'd gladly get rid of them, but I don't fancy making a metaprogramming API that doesn't work with annotated types
+ // luckily for our sanity, these vars are mutated only within a very restricted code execution path
+ def reifyTreeSymbols: Boolean = state.reifyTreeSymbols
+ def reifyTreeTypes: Boolean = state.reifyTreeTypes
/**
* Reify a tree.
@@ -43,10 +42,10 @@ trait Trees {
// the second prototype reified external types, but avoided reifying local ones => this created an ugly irregularity
// current approach is uniform and compact
var rtree = tree match {
- case mirror.EmptyTree =>
+ case global.EmptyTree =>
reifyMirrorObject(EmptyTree)
- case mirror.emptyValDef =>
- mirrorSelect(nme.emptyValDef)
+ case global.emptyValDef =>
+ mirrorBuildSelect(nme.emptyValDef)
case FreeDef(_, _, _, _, _) =>
reifyNestedFreeDef(tree)
case FreeRef(_, _) =>
@@ -55,31 +54,7 @@ trait Trees {
reifyBoundTerm(tree)
case BoundType(tree) =>
reifyBoundType(tree)
- case NestedExpr(_, _, _) =>
- reifyNestedExpr(tree)
case Literal(const @ Constant(_)) =>
- // [Eugene] was necessary when we reified erasures as normalized tycons
- // now, when we do existentialAbstraction on normalizations, everything works great
- // todo. find an explanation
-// if (const.tag == ClazzTag) {
-//// def preprocess(tpe: Type): Type = tpe.typeSymbol match {
-//// case ArrayClass => appliedType(ArrayClass, preprocess(tpe.typeArgs.head))
-//// case _ => tpe.typeConstructor
-//// }
-//// val tpe = preprocess(const.typeValue)
-// val tpe = const.typeValue
-// var reified = reify(tpe)
-// reified = mirrorCall(nme.Literal, mirrorCall(nme.Constant, reified))
-//// val skolems = ClassClass.typeParams map (_ => newTypeName(typer.context.unit.fresh.newName("_$")))
-//// var existential = mirrorCall(nme.AppliedTypeTree, mirrorCall(nme.TypeTree, reify(ClassClass.typeConstructor)), mkList(skolems map (skolem => mirrorCall(nme.Ident, reify(skolem)))))
-//// existential = mirrorCall(nme.ExistentialTypeTree, existential, reify(skolems map (skolem => TypeDef(Modifiers(Set(Modifier.deferred: Modifier)), skolem, Nil, TypeBoundsTree(Ident(NothingClass) setType NothingClass.tpe, Ident(AnyClass) setType AnyClass.tpe)))))
-//// reified = mirrorCall(nme.TypeApply, mirrorCall(nme.Select, reified, reify(nme.asInstanceOf_)), mkList(List(existential)))
-// // why is this required??
-//// reified = mirrorCall(nme.TypeApply, mirrorCall(nme.Select, reified, reify(nme.asInstanceOf_)), mkList(List(mirrorCall(nme.TypeTree, reify(appliedType(ClassClass.tpe, List(AnyClass.tpe)))))))
-// reified
-// } else {
-// mirrorCall(nme.Literal, reifyProduct(const))
-// }
mirrorCall(nme.Literal, reifyProduct(const))
case Import(expr, selectors) =>
mirrorCall(nme.Import, reify(expr), mkList(selectors map reifyProduct))
@@ -91,61 +66,57 @@ trait Trees {
// however, reification of AnnotatedTypes is special. see ``reifyType'' to find out why.
if (reifyTreeSymbols && tree.hasSymbol) {
if (reifyDebug) println("reifying symbol %s for tree %s".format(tree.symbol, tree))
- rtree = Apply(Select(rtree, nme.setSymbol), List(reify(tree.symbol)))
+ rtree = mirrorBuildCall(nme.setSymbol, rtree, reify(tree.symbol))
}
if (reifyTreeTypes && tree.tpe != null) {
if (reifyDebug) println("reifying type %s for tree %s".format(tree.tpe, tree))
- rtree = Apply(Select(rtree, nme.setType), List(reify(tree.tpe)))
+ rtree = mirrorBuildCall(nme.setType, rtree, reify(tree.tpe))
}
rtree
}
- def reifyModifiers(m: mirror.Modifiers) =
- mirrorCall("modifiersFromInternalFlags", reify(m.flags), reify(m.privateWithin), reify(m.annotations))
+ def reifyModifiers(m: global.Modifiers) =
+ mirrorFactoryCall(nme.Modifiers, mirrorBuildCall(nme.flagsFromBits, reify(m.flags)), reify(m.privateWithin), reify(m.annotations))
private def spliceTree(tree: Tree): Tree = {
tree match {
- case EvalSplice(splicee) =>
- if (reifyDebug) println("splicing eval " + tree)
+ case TreeSplice(splicee) =>
+ if (reifyDebug) println("splicing " + tree)
// see ``Metalevels'' for more info about metalevel breaches
// and about how we deal with splices that contain them
- if (splicee exists (sub => sub.hasSymbol && sub.symbol != NoSymbol && sub.symbol.metalevel > 0)) {
- if (reifyDebug) println("splicing has failed: cannot splice when facing a metalevel breach")
- EmptyTree
+ val isMetalevelBreach = splicee exists (sub => sub.hasSymbol && sub.symbol != NoSymbol && sub.symbol.metalevel > 0)
+ val isRuntimeEval = splicee exists (sub => sub.hasSymbol && sub.symbol == ExprSplice)
+ if (isMetalevelBreach || isRuntimeEval) {
+ // we used to convert dynamic splices into runtime evals transparently, but we no longer do that
+ // why? see comments in ``Metalevels''
+ // if (reifyDebug) println("splicing has failed: cannot splice when facing a metalevel breach")
+ // EmptyTree
+ CannotReifyRuntimeSplice(tree)
} else {
if (reifyDebug) println("splicing has succeeded")
- var splice = Select(splicee, nme.tree)
- splice match {
- case InlinedTreeSplice(_, inlinedSymbolTable, tree, _) =>
+ splicee match {
+ // we intentionally don't care about the prefix (the first underscore in the `RefiedTree` pattern match)
+ case ReifiedTree(_, _, inlinedSymtab, rtree, _, _, _) =>
if (reifyDebug) println("inlining the splicee")
// all free vars local to the enclosing reifee should've already been inlined by ``Metalevels''
- inlinedSymbolTable collect { case freedef @ FreeDef(_, _, binding, _, _) if binding.symbol.isLocalToReifee => assert(false, freedef) }
- symbolTable ++= inlinedSymbolTable
- tree
+ inlinedSymtab.syms foreach (sym => if (sym.isLocalToReifee) assert(false, inlinedSymtab.symDef(sym)))
+ state.symtab ++= inlinedSymtab
+ rtree
case tree =>
- // we need to preserve types of exprs, because oftentimes they cannot be inferred later
- // this circumvents regular reification scheme, therefore we go the extra mile here
- new Transformer {
- override def transform(tree: Tree) = super.transform(tree match {
- case NestedExpr(factory, tree, typetag) =>
- val typedFactory = TypeApply(factory, List(TypeTree(typetag.tpe.typeArgs(0))))
- Apply(Apply(typedFactory, List(tree)), List(typetag))
- case _ =>
- tree
- })
- }.transform(tree)
+ val migrated = Apply(Select(splicee, nme.in), List(Ident(nme.MIRROR_SHORT)))
+ Select(migrated, nme.tree)
}
}
- case ValueSplice(splicee) =>
- // todo. implement this
- ???
case _ =>
EmptyTree
}
}
+ // unlike in `reifyBoundType` we can skip checking for `tpe` being local or not local w.r.t the reifee
+ // a single check for a symbol of the bound term should be enough
+ // that's because only Idents and Thises can be bound terms, and they cannot host complex types
private def reifyBoundTerm(tree: Tree): Tree = tree match {
case tree @ This(_) if tree.symbol == NoSymbol =>
throw new Error("unexpected: bound term that doesn't have a symbol: " + showRaw(tree))
@@ -153,10 +124,10 @@ trait Trees {
val sym = tree.symbol
if (reifyDebug) println("This for %s, reified as freeVar".format(sym))
if (reifyDebug) println("Free: " + sym)
- mirrorCall(nme.Ident, reifyFreeTerm(sym, This(sym)))
+ mirrorBuildCall(nme.Ident, reifyFreeTerm(sym, This(sym)))
case tree @ This(_) if !tree.symbol.isLocalToReifee =>
if (reifyDebug) println("This for %s, reified as This".format(tree.symbol))
- mirrorCall(nme.This, reify(tree.symbol))
+ mirrorBuildCall(nme.This, reify(tree.symbol))
case tree @ This(_) if tree.symbol.isLocalToReifee =>
mirrorCall(nme.This, reify(tree.qual))
case tree @ Ident(_) if tree.symbol == NoSymbol =>
@@ -167,9 +138,9 @@ trait Trees {
case tree @ Ident(_) if !tree.symbol.isLocalToReifee =>
if (tree.symbol.isVariable && tree.symbol.owner.isTerm) {
captureVariable(tree.symbol) // Note order dependency: captureVariable needs to come before reification here.
- mirrorCall(nme.Select, mirrorCall(nme.Ident, reify(tree.symbol)), reify(nme.elem))
+ mirrorCall(nme.Select, mirrorBuildCall(nme.Ident, reify(tree.symbol)), reify(nme.elem))
} else {
- mirrorCall(nme.Ident, reify(tree.symbol))
+ mirrorBuildCall(nme.Ident, reify(tree.symbol))
}
case tree @ Ident(_) if tree.symbol.isLocalToReifee =>
mirrorCall(nme.Ident, reify(tree.name))
@@ -182,7 +153,12 @@ trait Trees {
if (tree.tpe == null)
throw new Error("unexpected: bound type that doesn't have a tpe: " + showRaw(tree))
- if (tree.symbol.isLocalToReifee)
+ // if a symbol or a type of the scrutinee are local to reifee
+ // (e.g. point to a locally declared class or to a path-dependent thingie that depends on a local variable)
+ // then we can reify the scrutinee as a symless AST and that will definitely be hygienic
+ // why? because then typechecking of a scrutinee doesn't depend on the environment external to the quasiquote
+ // otherwise we need to reify the corresponding type
+ if (tree.symbol.isLocalToReifee || tree.tpe.isLocalToReifee)
reifyProduct(tree)
else {
val sym0 = tree.symbol
@@ -195,7 +171,7 @@ trait Trees {
val spliced = spliceType(tpe)
if (spliced == EmptyTree) {
if (reifyDebug) println("splicing failed: reify as is")
- mirrorCall(nme.TypeTree, reify(tpe))
+ mirrorBuildCall(nme.TypeTree, reify(tpe))
} else {
spliced match {
case TypeRefToFreeType(freeType) =>
@@ -203,16 +179,16 @@ trait Trees {
Ident(freeType)
case _ =>
if (reifyDebug) println("splicing succeeded: " + spliced)
- mirrorCall(nme.TypeTree, spliced)
+ mirrorBuildCall(nme.TypeTree, spliced)
}
}
} else {
if (sym.isLocatable) {
if (reifyDebug) println("tpe is locatable: reify as Ident(%s)".format(sym))
- mirrorCall(nme.Ident, reify(sym))
+ mirrorBuildCall(nme.Ident, reify(sym))
} else {
if (reifyDebug) println("tpe is an alias, but not a locatable: reify as TypeTree(%s)".format(tpe))
- mirrorCall(nme.TypeTree, reify(tpe))
+ mirrorBuildCall(nme.TypeTree, reify(tpe))
}
}
}
@@ -235,25 +211,8 @@ trait Trees {
reifyProduct(tree)
}
- private def reifyNestedFreeRef(tree: Tree): Tree = tree match {
- case Apply(Select(mrRef @ Ident(_), ident), List(Ident(name: TermName))) if ident == nme.Ident && name.startsWith(nme.MIRROR_FREE_PREFIX) =>
- if (reifyDebug) println("nested free ref: %s".format(showRaw(tree)))
- reifyProduct(tree)
- case _ =>
- throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass))
- }
-
- private def reifyNestedExpr(tree: Tree): Tree = tree match {
- case NestedExpr(factory, tree, typetag) =>
- // we need to preserve types of exprs, because oftentimes they cannot be inferred later
- // this circumvents regular reification scheme, therefore we go through this crazy dance
- if (reifyDebug) println("nested expr: %s".format(showRaw(tree)))
- val rtype = mirrorCall(nme.TypeTree, reify(typetag.tpe.typeArgs(0)))
- val rfactory = mirrorCall(nme.TypeApply, reify(factory), mkList(List(rtype)))
- val rexpr = mirrorCall(nme.Apply, rfactory, reify(List(tree)))
- val rwrapped = mirrorCall(nme.Apply, rexpr, reify(List(typetag)))
- rwrapped
- case _ =>
- throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass))
+ private def reifyNestedFreeRef(tree: Tree): Tree = {
+ if (reifyDebug) println("nested free ref: %s".format(showRaw(tree)))
+ reifyProduct(tree)
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
new file mode 100644
index 0000000000..f4e2200edc
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
@@ -0,0 +1,203 @@
+package scala.reflect.reify
+package codegen
+
+trait GenTypes {
+ self: Reifier =>
+
+ import global._
+ import definitions._
+
+ /**
+ * Reify a type.
+ * For internal use only, use ``reified'' instead.
+ */
+ def reifyType(tpe0: Type): Tree = {
+ assert(tpe0 != null, "tpe is null")
+ val tpe = tpe0.dealias
+
+ if (tpe.isErroneous)
+ CannotReifyErroneousReifee(tpe)
+ if (tpe.isLocalToReifee)
+ CannotReifyType(tpe)
+
+ // this is a very special case. see the comments below for more info.
+ if (isSemiConcreteTypeMember(tpe))
+ return reifySemiConcreteTypeMember(tpe)
+
+ // [Eugene] how do I check that the substitution is legal w.r.t tpe.info?
+ val spliced = spliceType(tpe)
+ if (spliced != EmptyTree)
+ return spliced
+
+ val tsym = tpe.typeSymbol
+ if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic)
+ Select(Select(reify(tpe.typeSymbol), nme.asTypeSymbol), nme.asTypeConstructor)
+ else tpe match {
+ case tpe @ NoType =>
+ reifyMirrorObject(tpe)
+ case tpe @ NoPrefix =>
+ reifyMirrorObject(tpe)
+ case tpe @ ThisType(root) if root.isRoot =>
+ mirrorBuildCall(nme.thisPrefix, mirrorMirrorSelect(nme.RootClass))
+ case tpe @ ThisType(empty) if empty.isEmptyPackageClass =>
+ mirrorBuildCall(nme.thisPrefix, mirrorMirrorSelect(nme.EmptyPackageClass))
+ case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic =>
+ // [Eugene++ to Martin] makes sense?
+ val module = mirrorMirrorCall(nme.staticModule, reify(clazz.fullName))
+ val moduleClass = Select(Select(module, nme.asModuleSymbol), nme.moduleClass)
+ mirrorFactoryCall(nme.ThisType, moduleClass)
+ case tpe @ ThisType(_) =>
+ reifyProduct(tpe)
+ case tpe @ SuperType(thistpe, supertpe) =>
+ reifyProduct(tpe)
+ case tpe @ SingleType(pre, sym) =>
+ reifyProduct(tpe)
+ case tpe @ ConstantType(value) =>
+ mirrorFactoryCall(nme.ConstantType, reifyProduct(value))
+ case tpe @ TypeRef(pre, sym, args) =>
+ reifyProduct(tpe)
+ case tpe @ TypeBounds(lo, hi) =>
+ reifyProduct(tpe)
+ case tpe @ NullaryMethodType(restpe) =>
+ reifyProduct(tpe)
+ case tpe @ AnnotatedType(anns, underlying, selfsym) =>
+ reifyAnnotatedType(tpe)
+ case _ =>
+ reifyToughType(tpe)
+ }
+ }
+
+ /** Keeps track of whether this reification contains abstract type parameters */
+ def reificationIsConcrete: Boolean = state.reificationIsConcrete
+
+ def spliceType(tpe: Type): Tree = {
+ // [Eugene] it seems that depending on the context the very same symbol can be either a spliceable tparam or a quantified existential. very weird!
+ val quantified = currentQuantified
+ if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) {
+ if (reifyDebug) println("splicing " + tpe)
+
+ val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.AbsTypeTag.toString
+ val key = (tagFlavor, tpe.typeSymbol)
+ // if this fails, it might produce the dreaded "erroneous or inaccessible type" error
+ // to find out the whereabouts of the error run scalac with -Ydebug
+ if (reifyDebug) println("launching implicit search for %s.%s[%s]".format(universe, tagFlavor, tpe))
+ val result =
+ typer.resolveTypeTag(defaultErrorPosition, universe.tpe, tpe, concrete = concrete, allowMaterialization = false) match {
+ case failure if failure.isEmpty =>
+ if (reifyDebug) println("implicit search was fruitless")
+ if (reifyDebug) println("trying to splice as manifest")
+ val splicedAsManifest = spliceAsManifest(tpe)
+ if (splicedAsManifest.isEmpty) {
+ if (reifyDebug) println("no manifest in scope")
+ EmptyTree
+ } else {
+ if (reifyDebug) println("successfully spliced as manifest: " + splicedAsManifest)
+ splicedAsManifest
+ }
+ case success =>
+ if (reifyDebug) println("implicit search has produced a result: " + success)
+ state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.asTypeConstructor
+ Select(Apply(Select(success, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe)
+ }
+ if (result != EmptyTree) return result
+ state.reificationIsConcrete = false
+ }
+
+ EmptyTree
+ }
+
+ private def spliceAsManifest(tpe: Type): Tree = {
+ val ManifestClass = rootMirror.staticClass("scala.reflect.Manifest")
+ val ManifestModule = rootMirror.staticModule("scala.reflect.Manifest")
+ def isSynthetic(manifest: Tree) = manifest exists (sub => sub.symbol != null && (sub.symbol == ManifestModule || sub.symbol.owner == ManifestModule))
+ def searchForManifest(typer: analyzer.Typer): Tree =
+ analyzer.inferImplicit(
+ EmptyTree,
+ appliedType(ManifestClass.asTypeConstructor, List(tpe)),
+ reportAmbiguous = false,
+ isView = false,
+ context = typer.context,
+ saveAmbiguousDivergent = false,
+ pos = defaultErrorPosition) match {
+ case success if !success.tree.isEmpty && !isSynthetic(success.tree) =>
+ val manifestInScope = success.tree
+ // todo. write a test for this
+ if (ReflectRuntimeUniverse == NoSymbol) CannotConvertManifestToTagWithoutScalaReflect(tpe, manifestInScope)
+ val cm = typer.typed(Ident(ReflectRuntimeCurrentMirror))
+ val tagTree = gen.mkMethodCall(ReflectRuntimeUniverse, nme.manifestToTypeTag, List(tpe), List(cm, manifestInScope))
+ Select(Apply(Select(tagTree, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe)
+ case _ =>
+ EmptyTree
+ }
+ val result = typer.silent(silentTyper => silentTyper.context.withMacrosDisabled(searchForManifest(silentTyper)))
+ result match {
+ case analyzer.SilentResultValue(result) => result
+ case analyzer.SilentTypeError(_) => EmptyTree
+ }
+ }
+
+ /** Reify a semi-concrete type member.
+ *
+ * This is a VERY special case to deal with stuff like `typeOf[ru.Type]`.
+ * In that case `Type`, which is an abstract type member of scala.reflect.api.Universe, is not a free type.
+ * Why? Because we know its prefix, and it unambiguously determines the type.
+ *
+ * Here is a different view on this question that supports this suggestion.
+ * Say, you reify a tree. Iff it doesn't contain free types, it can be successfully compiled and run.
+ * For example, if you reify `tpe.asInstanceOf[T]` taken from `def foo[T]`, then you won't be able to compile the result.
+ * Fair enough, you don't know the `T`, so the compiler will choke.
+ * This fact is captured by reification result having a free type T (this can be inspected by calling `tree.freeTypes`).
+ * Now imagine you reify the following tree: `tpe.asInstanceOf[ru.Type]`.
+ * To the contrast with the previous example, that's totally not a problem.
+ *
+ * Okay, so we figured out that `ru.Type` is not a free type.
+ * However, in our reification framework, this type would be treated a free type.
+ * Why? Because `tpe.isSpliceable` will return true.
+ * Hence we intervene and handle this situation in a special way.
+ *
+ * By the way, we cannot change the definition of `isSpliceable`, because class tags also depend on it.
+ * And, you know, class tags don't care whether we select a type member from a concrete instance or get it from scope (as with type parameters).
+ * The type itself still remains not concrete, in the sense that we don't know its erasure.
+ * I.e. we can compile the code that involves `ru.Type`, but we cannot serialize an instance of `ru.Type`.
+ */
+ private def reifySemiConcreteTypeMember(tpe: Type): Tree = tpe match {
+ case tpe @ TypeRef(pre @ SingleType(prepre, presym), sym, args) if sym.isAbstractType && !sym.isExistential =>
+ return mirrorFactoryCall(nme.TypeRef, reify(pre), mirrorBuildCall(nme.selectType, reify(sym.owner), reify(sym.name.toString)), reify(args))
+ }
+
+ /** Reify an annotated type, i.e. the one that makes us deal with AnnotationInfos */
+ private def reifyAnnotatedType(tpe: AnnotatedType): Tree = {
+ val AnnotatedType(anns, underlying, selfsym) = tpe
+ mirrorFactoryCall(nme.AnnotatedType, mkList(anns map reifyAnnotationInfo), reify(underlying), reify(selfsym))
+ }
+
+ /** Reify a tough type, i.e. the one that leads to creation of auxiliary symbols */
+ private def reifyToughType(tpe: Type): Tree = {
+ if (reifyDebug) println("tough type: %s (%s)".format(tpe, tpe.kind))
+
+ def reifyScope(scope: Scope): Tree = {
+ scope foreach reifySymDef
+ mirrorCall(nme.newScopeWith, scope.toList map reify: _*)
+ }
+
+ tpe match {
+ case tpe @ RefinedType(parents, decls) =>
+ reifySymDef(tpe.typeSymbol)
+ mirrorFactoryCall(tpe, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
+ case tpe @ ExistentialType(tparams, underlying) =>
+ tparams foreach reifySymDef
+ mirrorFactoryCall(tpe, reify(tparams), reify(underlying))
+ case tpe @ ClassInfoType(parents, decls, clazz) =>
+ reifySymDef(clazz)
+ mirrorFactoryCall(tpe, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
+ case tpe @ MethodType(params, restpe) =>
+ params foreach reifySymDef
+ mirrorFactoryCall(tpe, reify(params), reify(restpe))
+ case tpe @ PolyType(tparams, underlying) =>
+ tparams foreach reifySymDef
+ mirrorFactoryCall(tpe, reify(tparams), reify(underlying))
+ case _ =>
+ throw new Error("internal error: %s (%s) is not supported".format(tpe, tpe.kind))
+ }
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/codegen/Util.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
index bb369a1adb..2b7733fb6c 100644
--- a/src/compiler/scala/reflect/reify/codegen/Util.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
@@ -1,18 +1,11 @@
package scala.reflect.reify
package codegen
-trait Util {
+trait GenUtils {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
-
- val reifyDebug = settings.Yreifydebug.value
- val reifyCopypaste = settings.Yreifycopypaste.value
- val reifyTrace = scala.tools.nsc.util.trace when reifyDebug
- object reifiedNodePrinters extends { val global: mirror.type = mirror } with tools.nsc.ast.NodePrinters with NodePrinters
- val reifiedNodeToString = reifiedNodePrinters.reifiedNodeToString
def reifyList(xs: List[Any]): Tree =
mkList(xs map reify)
@@ -39,12 +32,30 @@ trait Util {
Apply(termPath(fname), args.toList)
def mirrorSelect(name: String): Tree =
+ termPath(nme.UNIVERSE_PREFIX + name)
+
+ def mirrorBuildSelect(name: String): Tree =
+ termPath(nme.UNIVERSE_BUILD_PREFIX + name)
+
+ def mirrorMirrorSelect(name: String): Tree =
termPath(nme.MIRROR_PREFIX + name)
def mirrorCall(name: TermName, args: Tree*): Tree =
- call("" + (nme.MIRROR_PREFIX append name), args: _*)
+ call("" + (nme.UNIVERSE_PREFIX append name), args: _*)
def mirrorCall(name: String, args: Tree*): Tree =
+ call(nme.UNIVERSE_PREFIX + name, args: _*)
+
+ def mirrorBuildCall(name: TermName, args: Tree*): Tree =
+ call("" + (nme.UNIVERSE_BUILD_PREFIX append name), args: _*)
+
+ def mirrorBuildCall(name: String, args: Tree*): Tree =
+ call(nme.UNIVERSE_BUILD_PREFIX + name, args: _*)
+
+ def mirrorMirrorCall(name: TermName, args: Tree*): Tree =
+ call("" + (nme.MIRROR_PREFIX append name), args: _*)
+
+ def mirrorMirrorCall(name: String, args: Tree*): Tree =
call(nme.MIRROR_PREFIX + name, args: _*)
def mirrorFactoryCall(value: Product, args: Tree*): Tree =
@@ -93,6 +104,17 @@ trait Util {
tpe != null && (tpe exists isTough)
}
+ object TypedOrAnnotated {
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case ty @ Typed(_, _) =>
+ Some(ty)
+ case at @ Annotated(_, _) =>
+ Some(at)
+ case _ =>
+ None
+ }
+ }
+
def isAnnotated(tpe: Type) = {
def isAnnotated(tpe: Type) = tpe match {
case _: AnnotatedType => true
@@ -102,6 +124,17 @@ trait Util {
tpe != null && (tpe exists isAnnotated)
}
+ def isSemiConcreteTypeMember(tpe: Type) = tpe match {
+ case TypeRef(SingleType(_, _), sym, _) if sym.isAbstractType && !sym.isExistential => true
+ case _ => false
+ }
+
+ def isCrossStageTypeBearer(tree: Tree): Boolean = tree match {
+ case TypeApply(hk, _) => isCrossStageTypeBearer(hk)
+ case Select(sym @ Select(_, ctor), nme.apply) if ctor == nme.AbsTypeTag || ctor == nme.TypeTag || ctor == nme.Expr => true
+ case _ => false
+ }
+
def origin(sym: Symbol) = {
var origin = ""
if (sym.owner != NoSymbol) origin += "defined by %s".format(sym.owner.name)
diff --git a/src/compiler/scala/reflect/reify/codegen/Symbols.scala b/src/compiler/scala/reflect/reify/codegen/Symbols.scala
deleted file mode 100644
index 21a08b7efb..0000000000
--- a/src/compiler/scala/reflect/reify/codegen/Symbols.scala
+++ /dev/null
@@ -1,184 +0,0 @@
-package scala.reflect.reify
-package codegen
-
-trait Symbols {
- self: Reifier =>
-
- import mirror._
- import definitions._
- import treeInfo._
-
- /** Reify a reference to a symbol */
- def reifySymRef(sym0: Symbol): Tree = {
- assert(sym0 != null, "sym is null")
- val sym = sym0.dealias
-
- if (sym == NoSymbol)
- mirrorSelect(nme.NoSymbol)
- else if (sym == RootPackage)
- Select(mirrorSelect(nme.definitions), nme.RootPackage)
- else if (sym == RootClass)
- Select(mirrorSelect(nme.definitions), nme.RootClass)
- else if (sym == EmptyPackage)
- Select(mirrorSelect(nme.definitions), nme.EmptyPackage)
- else if (sym == EmptyPackageClass)
- Select(mirrorSelect(nme.definitions), nme.EmptyPackageClass)
- else if (sym.isModuleClass)
- Select(reify(sym.sourceModule), nme.moduleClass)
- else if (sym.isLocatable) {
- // [Eugene] am I doing this right?
-// if (sym.isStaticOwner) { // no good for us, because it returns false for packages
- if (sym.isStatic && (sym.isClass || sym.isModule)) {
- val resolver = if (sym.isType) nme.staticClass else nme.staticModule
- mirrorCall(resolver, reify(sym.fullName))
- } else {
- if (reifyDebug) println("Locatable: %s (%s) owned by %s (%s) at %s".format(sym, sym.accurateKindString, sym.owner, sym.owner.accurateKindString, sym.owner.fullNameString))
- val rowner = reify(sym.owner)
- val rname = reify(sym.name.toString)
- if (sym.isType)
- mirrorCall(nme.selectType, rowner, rname)
- else if (sym.isMethod && sym.owner.isClass && sym.owner.info.decl(sym.name).isOverloaded) {
- val index = sym.owner.info.decl(sym.name).alternatives indexOf sym
- assert(index >= 0, sym)
- mirrorCall(nme.selectOverloadedMethod, rowner, rname, reify(index))
- } else
- mirrorCall(nme.selectTerm, rowner, rname)
- }
- } else {
- // todo. make sure that free methods and free local defs work correctly
- if (sym.isTerm) reifyFreeTerm(sym, Ident(sym))
- else reifyFreeType(sym, Ident(sym))
- }
- }
-
- def reifyFreeTerm(sym: Symbol, value: Tree): Tree =
- locallyReified get sym match {
- case Some(reified) =>
- reified
- case None =>
- if (reifyDebug) println("Free term" + (if (sym.isCapturedVariable) " (captured)" else "") + ": " + sym + "(" + sym.accurateKindString + ")")
- var name = newTermName(nme.MIRROR_FREE_PREFIX + sym.name)
- if (sym.isType) name = name.append(nme.MIRROR_FREE_THIS_SUFFIX)
- if (sym.isCapturedVariable) {
- assert(value.isInstanceOf[Ident], showRaw(value))
- val capturedTpe = capturedVariableType(sym)
- val capturedValue = referenceCapturedVariable(sym)
- locallyReify(sym, name, mirrorCall(nme.newFreeTerm, reify(sym.name.toString), reify(capturedTpe), capturedValue, reify(sym.flags), reify(origin(sym))))
- } else {
- locallyReify(sym, name, mirrorCall(nme.newFreeTerm, reify(sym.name.toString), reify(sym.tpe), value, reify(sym.flags), reify(origin(sym))))
- }
- }
-
- def reifyFreeType(sym: Symbol, value: Tree): Tree =
- locallyReified get sym match {
- case Some(reified) =>
- reified
- case None =>
- if (reifyDebug) println("Free type: %s (%s)".format(sym, sym.accurateKindString))
- var name = newTermName(nme.MIRROR_FREE_PREFIX + sym.name)
- val phantomTypeTag = Apply(TypeApply(Select(Ident(nme.MIRROR_SHORT), nme.TypeTag), List(value)), List(Literal(Constant(null)), Literal(Constant(null))))
- val flavor = if (sym.isExistential) nme.newFreeExistential else nme.newFreeType
- locallyReify(sym, name, mirrorCall(flavor, reify(sym.name.toString), reify(sym.info), phantomTypeTag, reify(sym.flags), reify(origin(sym))))
- }
-
- def reifySymDef(sym: Symbol): Tree =
- locallyReified get sym match {
- case Some(reified) =>
- reified
- case None =>
- if (reifyDebug) println("Sym def: %s (%s)".format(sym, sym.accurateKindString))
- assert(!sym.isLocatable, sym) // if this assertion fires, then tough type reification needs to be rethought
- sym.owner.ownersIterator find (!_.isLocatable) foreach reifySymDef
- var name = newTermName(nme.MIRROR_SYMDEF_PREFIX + sym.name)
- locallyReify(sym, name, Apply(Select(reify(sym.owner), nme.newNestedSymbol), List(reify(sym.name), reify(sym.pos), reify(sym.flags), reify(sym.isClass))))
- }
-
- // todo. very brittle abstraction, needs encapsulation
- import scala.collection.mutable._
- private val localReifications = ArrayBuffer[Tree]()
- private val locallyReified = Map[Symbol, Tree]()
- private var filledIn = false
- def symbolTable: List[Tree] = { fillInSymbolTable(); localReifications.toList }
- def symbolTable_=(newSymbolTable: List[Tree]): Unit = {
- localReifications.clear()
- locallyReified.clear()
- filledIn = false
- newSymbolTable foreach {
- case entry =>
- val att = entry.attachmentOpt[ReifyAttachment]
- att match {
- case Some(ReifyAttachment(sym)) =>
- // don't duplicate reified symbols when merging inlined reifee
- if (!(locallyReified contains sym)) {
- val ValDef(_, name, _, _) = entry
- localReifications += entry
- locallyReified(sym) = Ident(name)
- }
- case other =>
- // do nothing => symbol table fill-ins will be repopulated later
- }
- }
- }
-
- private def localName(name0: TermName): TermName = {
- var name = name0.toString
- name = name.replace(".type", "$type")
- name = name.replace(" ", "$")
- val fresh = typer.context.unit.fresh
- newTermName(fresh.newName(name))
- }
-
- private def locallyReify(sym: Symbol, name0: TermName, reificode: => Tree): Tree = {
- val reified = reificode
- val name = localName(name0)
- // todo. tried to declare a private class here to carry an attachment, but it's path-dependent
- // so got troubles with exchanging free variables between nested and enclosing quasiquotes
- // attaching just Symbol isn't good either, so we need to think of a principled solution
- val local = ValDef(NoMods, name, TypeTree(), reified) withAttachment ReifyAttachment(sym)
- localReifications += local
- filledIn = false
- locallyReified(sym) = Ident(name)
- locallyReified(sym)
- }
-
- /** Sets type signatures and annotations for locally reified symbols */
- private def fillInSymbolTable() = {
- if (!filledIn) {
- val fillIns = new ArrayBuffer[Tree]
- var i = 0
- while (i < localReifications.length) {
- // fillInSymbol might create new locallyReified symbols, that's why this is done iteratively
- val reified = localReifications(i)
- val att = reified.attachmentOpt[ReifyAttachment]
- att match {
- case Some(ReifyAttachment(sym)) => fillIns += fillInSymbol(sym)
- case other => // do nothing
- }
- i += 1
- }
-
- filledIn = true
- localReifications ++= fillIns.toList
- }
- }
-
- /** Generate code to add type and annotation info to a reified symbol */
- private def fillInSymbol(sym: Symbol): Tree = {
- if (reifyDebug) println("Filling in: %s (%s)".format(sym, sym.accurateKindString))
- val isFree = locallyReified(sym) match { case Ident(name) => name startsWith nme.MIRROR_FREE_PREFIX }
- if (isFree) {
- if (sym.annotations.isEmpty) EmptyTree
- else Apply(Select(locallyReified(sym), nme.setAnnotations), List(reify(sym.annotations)))
- } else {
- import scala.reflect.internal.Flags._
- if (sym hasFlag LOCKED) {
- // [Eugene] better to have a symbol without a type signature, than to crash with a CyclicReference
- EmptyTree
- } else {
- val rset = Apply(Select(locallyReified(sym), nme.setTypeSignature), List(reify(sym.info)))
- if (sym.annotations.isEmpty) rset
- else Apply(Select(rset, nme.setAnnotations), List(reify(sym.annotations)))
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/codegen/Types.scala b/src/compiler/scala/reflect/reify/codegen/Types.scala
deleted file mode 100644
index a2b074c6b2..0000000000
--- a/src/compiler/scala/reflect/reify/codegen/Types.scala
+++ /dev/null
@@ -1,168 +0,0 @@
-package scala.reflect.reify
-package codegen
-
-trait Types {
- self: Reifier =>
-
- import mirror._
- import definitions._
- import treeInfo._
-
- /**
- * Reify a type.
- * For internal use only, use ``reified'' instead.
- */
- def reifyType(tpe0: Type): Tree = {
- assert(tpe0 != null, "tpe is null")
- val tpe = tpe0.dealias
-
- if (tpe.isErroneous)
- CannotReifyErroneousReifee(tpe)
- if (tpe.isLocalToReifee)
- CannotReifyType(tpe)
-
- // [Eugene] how do I check that the substitution is legal w.r.t tpe.info?
- val spliced = spliceType(tpe)
- if (spliced != EmptyTree)
- return spliced
-
- val tsym = tpe.typeSymbol
- if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic)
- Select(reify(tpe.typeSymbol), nme.asTypeConstructor)
- else tpe match {
- case tpe @ NoType =>
- reifyMirrorObject(tpe)
- case tpe @ NoPrefix =>
- reifyMirrorObject(tpe)
- case tpe @ ThisType(root) if root == RootClass =>
- mirrorSelect("definitions.RootClass.thisPrefix")
- case tpe @ ThisType(empty) if empty == EmptyPackageClass =>
- mirrorSelect("definitions.EmptyPackageClass.thisPrefix")
- case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic =>
- mirrorCall(nme.thisModuleType, reify(clazz.fullName))
- case tpe @ ThisType(_) =>
- reifyProduct(tpe)
- case tpe @ SuperType(thistpe, supertpe) =>
- reifyProduct(tpe)
- case tpe @ SingleType(pre, sym) =>
- reifyProduct(tpe)
- case tpe @ ConstantType(value) =>
- mirrorFactoryCall(nme.ConstantType, reifyProduct(value))
- case tpe @ TypeRef(pre, sym, args) =>
- reifyProduct(tpe)
- case tpe @ TypeBounds(lo, hi) =>
- reifyProduct(tpe)
- case tpe @ NullaryMethodType(restpe) =>
- reifyProduct(tpe)
- case tpe @ AnnotatedType(anns, underlying, selfsym) =>
- reifyAnnotatedType(tpe)
- case _ =>
- reifyToughType(tpe)
- }
- }
-
- /** An obscure flag necessary for implicit TypeTag generation */
- private var spliceTypesEnabled = !dontSpliceAtTopLevel
-
- /** Keeps track of whether this reification contains abstract type parameters */
- private var _reificationIsConcrete = true
- def reificationIsConcrete = _reificationIsConcrete
- def reificationIsConcrete_=(value: Boolean) {
- _reificationIsConcrete = value
- if (!value && concrete) {
- assert(current.isInstanceOf[Type], current)
- val offender = current.asInstanceOf[Type]
- CannotReifyConcreteTypeTagHavingUnresolvedTypeParameters(offender)
- }
- }
-
- private type SpliceCacheKey = (Symbol, Symbol)
- private lazy val spliceCache: collection.mutable.Map[SpliceCacheKey, Tree] = {
- val cache = analyzer.perRunMacroCache.getOrElseUpdate(MacroContextReify, collection.mutable.Map[Any, Any]())
- cache.getOrElseUpdate("spliceCache", collection.mutable.Map[SpliceCacheKey, Tree]()).asInstanceOf[collection.mutable.Map[SpliceCacheKey, Tree]]
- }
-
- def spliceType(tpe: Type): Tree = {
- // [Eugene] it seems that depending on the context the very same symbol can be either a spliceable tparam or a quantified existential. very weird!
- val quantified = currentQuantified
- if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) {
- if (reifyDebug) println("splicing " + tpe)
-
- if (spliceTypesEnabled) {
- var tagClass = if (concrete) ConcreteTypeTagClass else TypeTagClass
- val tagTpe = singleType(prefix.tpe, prefix.tpe member tagClass.name)
-
- // [Eugene] this should be enough for an abstract type, right?
- val key = (tagClass, tpe.typeSymbol)
- if (reifyDebug && spliceCache.contains(key)) println("cache hit: " + spliceCache(key))
- val result = spliceCache.getOrElseUpdate(key, {
- // if this fails, it might produce the dreaded "erroneous or inaccessible type" error
- // to find out the whereabouts of the error run scalac with -Ydebug
- if (reifyDebug) println("launching implicit search for %s.%s[%s]".format(prefix, tagClass.name, tpe))
- typer.resolveTypeTag(prefix.tpe, tpe, defaultErrorPosition, concrete) match {
- case failure if failure.isEmpty =>
- if (reifyDebug) println("implicit search was fruitless")
- EmptyTree
- case success =>
- if (reifyDebug) println("implicit search has produced a result: " + success)
- reificationIsConcrete &= concrete
- var splice = Select(success, nme.tpe)
- splice match {
- case InlinedTypeSplice(_, inlinedSymbolTable, tpe) =>
- // all free vars local to the enclosing reifee should've already been inlined by ``Metalevels''
- inlinedSymbolTable collect { case freedef @ FreeDef(_, _, binding, _, _) if binding.symbol.isLocalToReifee => assert(false, freedef) }
- symbolTable ++= inlinedSymbolTable
- reifyTrace("inlined the splicee: ")(tpe)
- case tpe =>
- tpe
- }
- }
- })
- if (result != EmptyTree) return result.duplicate
- } else {
- if (reifyDebug) println("splicing has been cancelled: spliceTypesEnabled = false")
- }
-
- reificationIsConcrete = false
- }
-
- spliceTypesEnabled = true
- EmptyTree
- }
-
- /** Reify an annotated type, i.e. the one that makes us deal with AnnotationInfos */
- private def reifyAnnotatedType(tpe: AnnotatedType): Tree = {
- val AnnotatedType(anns, underlying, selfsym) = tpe
- mirrorFactoryCall(nme.AnnotatedType, mkList(anns map reifyAnnotationInfo), reify(underlying), reify(selfsym))
- }
-
- /** Reify a tough type, i.e. the one that leads to creation of auxiliary symbols */
- private def reifyToughType(tpe: Type): Tree = {
- if (reifyDebug) println("tough type: %s (%s)".format(tpe, tpe.kind))
-
- def reifyScope(scope: Scope): Tree = {
- scope foreach reifySymDef
- mirrorCall(nme.newScopeWith, scope.toList map reify: _*)
- }
-
- tpe match {
- case tpe @ RefinedType(parents, decls) =>
- reifySymDef(tpe.typeSymbol)
- mirrorFactoryCall(tpe, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
- case tpe @ ExistentialType(tparams, underlying) =>
- tparams foreach reifySymDef
- mirrorFactoryCall(tpe, reify(tparams), reify(underlying))
- case tpe @ ClassInfoType(parents, decls, clazz) =>
- reifySymDef(clazz)
- mirrorFactoryCall(tpe, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
- case tpe @ MethodType(params, restpe) =>
- params foreach reifySymDef
- mirrorFactoryCall(tpe, reify(params), reify(restpe))
- case tpe @ PolyType(tparams, underlying) =>
- tparams foreach reifySymDef
- mirrorFactoryCall(tpe, reify(tparams), reify(underlying))
- case _ =>
- throw new Error("internal error: %s (%s) is not supported".format(tpe, tpe.kind))
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala
index a096e2e93b..80011368a8 100644
--- a/src/compiler/scala/reflect/reify/package.scala
+++ b/src/compiler/scala/reflect/reify/package.scala
@@ -1,59 +1,76 @@
package scala.reflect
+import language.implicitConversions
+import language.experimental.macros
+import scala.reflect.base.{Universe => BaseUniverse}
+import scala.reflect.makro.{Context, ReificationError, UnexpectedReificationError}
import scala.tools.nsc.Global
-import scala.reflect.makro.ReificationError
-import scala.reflect.makro.UnexpectedReificationError
package object reify {
- private def mkReifier(global: Global)(typer: global.analyzer.Typer, prefix: global.Tree, reifee: Any, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Reifier { val mirror: global.type } = {
+ private def mkReifier(global1: Global)(typer: global1.analyzer.Typer, universe: global1.Tree, mirror: global1.Tree, reifee: Any, concrete: Boolean = false): Reifier { val global: global1.type } = {
val typer1: typer.type = typer
- val prefix1: prefix.type = prefix
+ val universe1: universe.type = universe
+ val mirror1: mirror.type = mirror
val reifee1 = reifee
- val dontSpliceAtTopLevel1 = dontSpliceAtTopLevel
val concrete1 = concrete
new {
- val mirror: global.type = global
+ val global: global1.type = global1
val typer = typer1
- val prefix = prefix1
+ val universe = universe1
+ val mirror = mirror1
val reifee = reifee1
- val dontSpliceAtTopLevel = dontSpliceAtTopLevel1
val concrete = concrete1
} with Reifier
}
- def reifyTree(global: Global)(typer: global.analyzer.Typer, prefix: global.Tree, tree: global.Tree): global.Tree =
- mkReifier(global)(typer, prefix, tree, false, false).reified.asInstanceOf[global.Tree]
+ private[reify] def mkDefaultMirrorRef(global: Global)(universe: global.Tree, typer0: global.analyzer.Typer): global.Tree = {
+ import global._
+ import definitions._
+ val enclosingErasure = reifyEnclosingRuntimeClass(global)(typer0)
+ // JavaUniverse is defined in scala-reflect.jar, so we must be very careful in case someone reifies stuff having only scala-library.jar on the classpath
+ val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.asTypeConstructor
+ if (isJavaUniverse && !enclosingErasure.isEmpty) Apply(Select(universe, nme.runtimeMirror), List(Select(enclosingErasure, sn.GetClassLoader)))
+ else Select(universe, nme.rootMirror)
+ }
- def reifyType(global: Global)(typer: global.analyzer.Typer, prefix: global.Tree, tpe: global.Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): global.Tree =
- mkReifier(global)(typer, prefix, tpe, dontSpliceAtTopLevel, concrete).reified.asInstanceOf[global.Tree]
+ def reifyTree(global: Global)(typer: global.analyzer.Typer, universe: global.Tree, mirror: global.Tree, tree: global.Tree): global.Tree =
+ mkReifier(global)(typer, universe, mirror, tree, concrete = false).reification.asInstanceOf[global.Tree]
- def reifyErasure(global: Global)(typer0: global.analyzer.Typer, tpe: global.Type, concrete: Boolean = true): global.Tree = {
+ def reifyType(global: Global)(typer: global.analyzer.Typer,universe: global.Tree, mirror: global.Tree, tpe: global.Type, concrete: Boolean = false): global.Tree =
+ mkReifier(global)(typer, universe, mirror, tpe, concrete = concrete).reification.asInstanceOf[global.Tree]
+
+ def reifyRuntimeClass(global: Global)(typer0: global.analyzer.Typer, tpe: global.Type, concrete: Boolean = true): global.Tree = {
import global._
import definitions._
import analyzer.enclosingMacroPosition
- def erasureTagInScope = typer0.context.withMacrosDisabled(typer0.resolveErasureTag(tpe, enclosingMacroPosition, concrete = concrete))
- def arrayTagInScope = typer0.context.withMacrosDisabled(typer0.resolveArrayTag(tpe, enclosingMacroPosition))
- val inScope = (erasureTagInScope, arrayTagInScope)
+ if (tpe.isSpliceable) {
+ val classTagInScope = typer0.resolveClassTag(enclosingMacroPosition, tpe, allowMaterialization = false)
+ if (!classTagInScope.isEmpty) return Select(classTagInScope, nme.runtimeClass)
+ if (concrete) throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
+ }
- inScope match {
- case (success, _) if !success.isEmpty =>
- Select(success, nme.erasure)
- case (_, success) if !success.isEmpty =>
- gen.mkMethodCall(arrayElementClassMethod, List(success))
+ tpe.normalize match {
+ case TypeRef(_, ArrayClass, componentTpe :: Nil) =>
+ val componentErasure = reifyRuntimeClass(global)(typer0, componentTpe, concrete)
+ gen.mkMethodCall(arrayClassMethod, List(componentErasure))
case _ =>
- tpe.normalize match {
- case TypeRef(_, ArrayClass, componentTpe :: Nil) =>
- val componentErasure = reifyErasure(global)(typer0, componentTpe, concrete)
- gen.mkMethodCall(arrayClassMethod, List(componentErasure))
- case _ =>
- if (tpe.isSpliceable && concrete)
- throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
- var erasure = tpe.erasure
- if (tpe.typeSymbol.isDerivedValueClass && global.phase.id < global.currentRun.erasurePhase.id) erasure = tpe
- gen.mkNullaryCall(Predef_classOf, List(erasure))
- }
+ var erasure = tpe.erasure
+ if (tpe.typeSymbol.isDerivedValueClass && global.phase.id < global.currentRun.erasurePhase.id) erasure = tpe
+ gen.mkNullaryCall(Predef_classOf, List(erasure))
}
}
+
+ def reifyEnclosingRuntimeClass(global: Global)(typer0: global.analyzer.Typer): global.Tree = {
+ import global._
+ import definitions._
+ def isThisInScope = typer0.context.enclosingContextChain exists (_.tree.isInstanceOf[Template])
+ if (isThisInScope) {
+ val enclosingClasses = typer0.context.enclosingContextChain map (_.tree) collect { case classDef: ClassDef => classDef }
+ val classInScope = enclosingClasses.headOption getOrElse EmptyTree
+ if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.asTypeConstructor, concrete = true)
+ else Select(This(tpnme.EMPTY), sn.GetClass)
+ } else EmptyTree
+ }
}
diff --git a/src/compiler/scala/reflect/reify/phases/Calculate.scala b/src/compiler/scala/reflect/reify/phases/Calculate.scala
index 93ef46472e..41cf6c066a 100644
--- a/src/compiler/scala/reflect/reify/phases/Calculate.scala
+++ b/src/compiler/scala/reflect/reify/phases/Calculate.scala
@@ -4,25 +4,26 @@ package phases
trait Calculate {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
- implicit class RichSymbol(sym: Symbol) {
- def metalevel: Int = { assert(sym != NoSymbol); localSymbols.getOrElse(sym, 0) }
+ implicit class RichCalculateSymbol(sym: Symbol) {
+ def metalevel: Int = { assert(sym != null && sym != NoSymbol); localSymbols.getOrElse(sym, 0) }
def isLocalToReifee = (localSymbols contains sym) // [Eugene] how do I account for local skolems?
}
- implicit class RichType(tpe: Type) {
+ implicit class RichCalculateType(tpe: Type) {
def isLocalToReifee = tpe != null && (tpe exists (tp => (localSymbols contains tp.typeSymbol) || (localSymbols contains tp.termSymbol)))
}
- private var localSymbols = collection.mutable.Map[Symbol, Int]() // set of all symbols that are local to the tree to be reified
+ private def localSymbols: Map[Symbol, Int] = state.localSymbols // set of all symbols that are local to the tree to be reified
+ private def localSymbols_=(value: Map[Symbol, Int]): Unit = state.localSymbols = value
private def registerLocalSymbol(sym: Symbol, metalevel: Int): Unit =
if (sym != null && sym != NoSymbol) {
if (localSymbols contains sym)
assert(localSymbols(sym) == metalevel, "metalevel mismatch: expected %s, actual %s".format(localSymbols(sym), metalevel))
- localSymbols(sym) = metalevel
+ else
+ localSymbols += (sym -> metalevel)
}
/**
@@ -38,7 +39,7 @@ trait Calculate {
try super.traverse(tree)
finally currMetalevel += 1
case tree if tree.isDef =>
- if (reifyDebug) println("boundSym: %s of type %s".format(tree.symbol, (tree.productIterator.toList collect { case tt: TypeTree => tt } headOption).getOrElse(TypeTree(tree.tpe))))
+ if (reifyDebug) println("boundSym: %s of type %s".format(tree.symbol, (tree.productIterator.toList collect { case tt: TypeTree => tt }).headOption.getOrElse(TypeTree(tree.tpe))))
registerLocalSymbol(tree.symbol, currMetalevel)
bindRelatedSymbol(tree.symbol.sourceModule, "sourceModule")
diff --git a/src/compiler/scala/reflect/reify/phases/Metalevels.scala b/src/compiler/scala/reflect/reify/phases/Metalevels.scala
index 206f3b1118..1624bbe951 100644
--- a/src/compiler/scala/reflect/reify/phases/Metalevels.scala
+++ b/src/compiler/scala/reflect/reify/phases/Metalevels.scala
@@ -4,9 +4,8 @@ package phases
trait Metalevels {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
/**
* Makes sense of cross-stage bindings.
@@ -23,7 +22,7 @@ trait Metalevels {
* val x = 2 // metalevel of symbol x is 1, because it's declared inside reify
* val y = reify{x} // metalevel of symbol y is 1, because it's declared inside reify
* // metalevel of Ident(x) is 2, because it's inside two reifies
- * y.eval // metalevel of Ident(y) is 0, because it's inside a designator of a splice
+ * y.splice // metalevel of Ident(y) is 0, because it's inside a designator of a splice
* }
*
* Cross-stage bindings are introduced when symbol.metalevel != curr_metalevel.
@@ -37,21 +36,26 @@ trait Metalevels {
*
* 2) symbol.metalevel > curr_metalevel. This leads to a metalevel breach that violates intuitive perception of splicing.
* As defined in macro spec, splicing takes a tree and inserts it into another tree - as simple as that.
- * However, how exactly do we do that in the case of y.eval? In this very scenario we can use dataflow analysis and inline it,
+ * However, how exactly do we do that in the case of y.splice? In this very scenario we can use dataflow analysis and inline it,
* but what if y were a var, and what if it were calculated randomly at runtime?
*
* This question has a genuinely simple answer. Sure, we cannot resolve such splices statically (i.e. during macro expansion of ``reify''),
* but now we have runtime toolboxes, so noone stops us from picking up that reified tree and evaluating it at runtime
- * (in fact, this is something that ``Expr.eval'' and ``Expr.value'' do transparently).
+ * (in fact, this is something that ``Expr.splice'' does transparently).
*
* This is akin to early vs late binding dilemma.
* The prior is faster, plus, the latter (implemented with reflection) might not work because of visibility issues or might be not available on all platforms.
* But the latter still has its uses, so I'm allowing metalevel breaches, but introducing the -Xlog-runtime-evals to log them.
*
+ * upd. We no longer do that. In case of a runaway ``splice'' inside a `reify`, one will get a static error.
+ * Why? Unfortunately, the cute idea of transparently converting between static and dynamic splices has failed.
+ * 1) Runtime eval that services dynamic splices requires scala-compiler.jar, which might not be on library classpath
+ * 2) Runtime eval incurs a severe performance penalty, so it'd better to be explicit about it
+ *
* ================
*
- * As we can see, the only problem is the fact that lhs'es of eval can be code blocks that can capture variables from the outside.
- * Code inside the lhs of an eval is not reified, while the code from the enclosing reify is.
+ * As we can see, the only problem is the fact that lhs'es of `splice` can be code blocks that can capture variables from the outside.
+ * Code inside the lhs of an `splice` is not reified, while the code from the enclosing reify is.
*
* Hence some bindings become cross-stage, which is not bad per se (in fact, some cross-stage bindings have sane semantics, as in the example above).
* However this affects freevars, since they are delicate inter-dimensional beings that refer to both current and next planes of existence.
@@ -61,10 +65,10 @@ trait Metalevels {
*
* reify {
* val x = 2
- * reify{x}.eval
+ * reify{x}.splice
* }
*
- * Since the result of the inner reify is wrapped in an eval, it won't be reified
+ * Since the result of the inner reify is wrapped in a splice, it won't be reified
* together with the other parts of the outer reify, but will be inserted into that result verbatim.
*
* The inner reify produces an Expr[Int] that wraps Ident(freeVar("x", IntClass.tpe, x)).
@@ -76,10 +80,10 @@ trait Metalevels {
* reify {
* val x = 2
* val y = reify{x}
- * y.eval
+ * y.splice
* }
*
- * In this case the inner reify doesn't appear next to eval, so it will be reified together with x.
+ * In this case the inner reify doesn't appear next to splice, so it will be reified together with x.
* This means that no special processing is needed here.
*
* Example 4. Consider the following fragment:
@@ -89,16 +93,16 @@ trait Metalevels {
* {
* val y = 2
* val z = reify{reify{x + y}}
- * z.eval
- * }.eval
+ * z.splice
+ * }.splice
* }
*
* The reasoning from Example 2 still holds here - we do need to inline the freevar that refers to x.
- * However, we must not touch anything inside the eval'd block, because it's not getting reified.
+ * However, we must not touch anything inside the splice'd block, because it's not getting reified.
*/
- var metalevels = new Transformer {
+ val metalevels = new Transformer {
var insideSplice = false
- var freedefsToInline = collection.mutable.Map[String, ValDef]()
+ var inlineableBindings = collection.mutable.Map[TermName, Tree]()
def withinSplice[T](op: => T) = {
val old = insideSplice
@@ -107,40 +111,36 @@ trait Metalevels {
finally insideSplice = old
}
- // Q: here we deal with all sorts of reified trees. what about ReifiedType(_, _, _, _)?
+ // Q: here we deal with all sorts of reified trees. what about ReifiedType(_, _, _, _, _, _)?
// A: nothing. reified trees give us problems because they sometimes create dimensional rifts as described above
// to the contrast, reified types (i.e. synthetic typetags materialized by Implicits.scala) always stay on the same metalevel as their enclosing code
override def transform(tree: Tree): Tree = tree match {
- case InlineableTreeSplice(splicee, inlinedSymbolTable, _, _, flavor) =>
- if (reifyDebug) println("entering inlineable splice: " + splicee)
- val Block(mrDef :: symbolTable, expr) = splicee
- // [Eugene] how to express the fact that a scrutinee is both of some type and matches an extractor?
- val freedefsToInline = symbolTable collect { case freedef @ FreeTermDef(_, _, binding, _, _) if binding.symbol.isLocalToReifee => freedef.asInstanceOf[ValDef] }
- freedefsToInline foreach (vdef => this.freedefsToInline(vdef.name) = vdef)
- val symbolTable1 = symbolTable diff freedefsToInline
- val tree1 = Select(Block(mrDef :: symbolTable1, expr), flavor)
- if (reifyDebug) println("trimmed %s inlineable free defs from its symbol table: %s".format(freedefsToInline.length, freedefsToInline map (_.name) mkString(", ")))
- withinSplice { super.transform(tree1) }
+ case TreeSplice(ReifiedTree(universe, mirror, symtab, rtree, tpe, rtpe, concrete)) =>
+ if (reifyDebug) println("entering inlineable splice: " + tree)
+ val inlinees = symtab.syms filter (_.isLocalToReifee)
+ inlinees foreach (inlinee => symtab.symAliases(inlinee) foreach (alias => inlineableBindings(alias) = symtab.symBinding(inlinee)))
+ val symtab1 = symtab -- inlinees
+ if (reifyDebug) println("trimmed %s inlineable free defs from its symbol table: %s".format(inlinees.length, inlinees map (inlinee => symtab.symName(inlinee)) mkString(", ")))
+ withinSplice { super.transform(TreeSplice(ReifiedTree(universe, mirror, symtab1, rtree, tpe, rtpe, concrete))) }
case TreeSplice(splicee) =>
if (reifyDebug) println("entering splice: " + splicee)
- val hasBreaches = splicee exists (_.symbol.metalevel > 0)
- if (!insideSplice && hasBreaches) {
- if (settings.logRuntimeSplices.value) reporter.echo(tree.pos, "this splice cannot be resolved statically")
- if (reifyDebug) println("metalevel breach in %s: %s".format(tree, (splicee filter (_.symbol.metalevel > 0) map (_.symbol) distinct) mkString ", "))
+ val breaches = splicee filter (sub => sub.hasSymbol && sub.symbol != NoSymbol && sub.symbol.metalevel > 0)
+ if (!insideSplice && breaches.nonEmpty) {
+ // we used to convert dynamic splices into runtime evals transparently, but we no longer do that
+ // why? see comments above
+ // if (settings.logRuntimeSplices.value) reporter.echo(tree.pos, "this splice cannot be resolved statically")
+ // withinSplice { super.transform(tree) }
+ if (reifyDebug) println("metalevel breach in %s: %s".format(tree, (breaches map (_.symbol)).distinct mkString ", "))
+ CannotReifyRuntimeSplice(tree)
+ } else {
+ withinSplice { super.transform(tree) }
}
- withinSplice { super.transform(tree) }
- // todo. also inline usages of ``freedefsToInline'' in the symbolTable itself
+ // todo. also inline usages of ``inlineableBindings'' in the symtab itself
// e.g. a free$Foo can well use free$x, if Foo is path-dependent w.r.t x
// FreeRef(_, _) check won't work, because metalevels of symbol table and body are different, hence, freerefs in symbol table look different from freerefs in body
- // todo. also perform garbage collection on local symbols
- // so that local symbols used only in type signatures of free vars get removed
- // todo. same goes for auxiliary symbol defs reified to support tough types
- // some of them need to be rebuilt, some of them need to be removed, because they're no longer necessary
- case FreeRef(mr, name) if freedefsToInline contains name =>
+ case FreeRef(_, name) if inlineableBindings contains name =>
if (reifyDebug) println("inlineable free ref: %s in %s".format(name, showRaw(tree)))
- val freedef @ FreeDef(_, _, binding, _, _) = freedefsToInline(name)
- if (reifyDebug) println("related definition: %s".format(showRaw(freedef)))
- val inlined = reify(binding)
+ val inlined = reify(inlineableBindings(name))
if (reifyDebug) println("verdict: inlined as %s".format(showRaw(inlined)))
inlined
case _ =>
diff --git a/src/compiler/scala/reflect/reify/phases/Reify.scala b/src/compiler/scala/reflect/reify/phases/Reify.scala
index e03ff5832c..dc0028be38 100644
--- a/src/compiler/scala/reflect/reify/phases/Reify.scala
+++ b/src/compiler/scala/reflect/reify/phases/Reify.scala
@@ -5,29 +5,22 @@ import scala.runtime.ScalaRunTime.isAnyVal
import scala.runtime.ScalaRunTime.isTuple
import scala.reflect.reify.codegen._
-trait Reify extends Symbols
- with Types
- with Names
- with Trees
- with AnnotationInfos
- with Positions
- with Util {
+trait Reify extends GenSymbols
+ with GenTypes
+ with GenNames
+ with GenTrees
+ with GenAnnotationInfos
+ with GenPositions
+ with GenUtils {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
- // `reify` looked so nice, I wanted to push the last bit of orthogonal
- // logic out of it so you can see the improvement. There is no cost to
- // wrapper methods of this form because the inliner will eliminate them,
- // but they are very good at separating concerns like pushing/popping
- // a stack, and they are great for composition and reuse.
- //
- // Also, please avoid public vars whenever possible.
private object reifyStack {
- var currents: List[Any] = reifee :: Nil
+ def currents: List[Any] = state.reifyStack
+ def currents_=(value: List[Any]): Unit = state.reifyStack = value
@inline final def push[T](reifee: Any)(body: => T): T = {
currents ::= reifee
@@ -37,6 +30,7 @@ trait Reify extends Symbols
}
def currentQuantified = flatCollect(reifyStack.currents)({ case ExistentialType(quantified, _) => quantified })
def current = reifyStack.currents.head
+ def currents = reifyStack.currents
/**
* Reifies any supported value.
@@ -52,9 +46,9 @@ trait Reify extends Symbols
case tree: Tree => reifyTree(tree)
// disabled because this is a very special case that I plan to remove later
// why do I dislike annotations? see comments to `reifyAnnotationInfo`
-// case ann: AnnotationInfo => reifyAnnotationInfo(ann)
+ // case ann: AnnotationInfo => reifyAnnotationInfo(ann)
case pos: Position => reifyPosition(pos)
- case mods: mirror.Modifiers => reifyModifiers(mods)
+ case mods: global.Modifiers => reifyModifiers(mods)
case xs: List[_] => reifyList(xs)
case s: String => Literal(Constant(s))
case v if isAnyVal(v) => Literal(Constant(v))
diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala
index 4ab306a13f..e26dd7e227 100644
--- a/src/compiler/scala/reflect/reify/phases/Reshape.scala
+++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala
@@ -6,15 +6,16 @@ import scala.tools.nsc.symtab.Flags._
trait Reshape {
self: Reifier =>
- import mirror._
+ import global._
import definitions._
- import treeInfo._
/**
* Rolls back certain changes that were introduced during typechecking of the reifee.
*
* These include:
+ * * Undoing macro expansions
* * Replacing type trees with TypeTree(tpe)
+ * * Reassembling CompoundTypeTrees into reifiable form
* * Transforming Modifiers.annotations into Symbol.annotations
* * Transforming Annotated annotations into AnnotatedType annotations
* * Transforming Annotated(annot, expr) into Typed(expr, TypeTree(Annotated(annot, _))
@@ -23,7 +24,8 @@ trait Reshape {
val reshape = new Transformer {
var currentSymbol: Symbol = NoSymbol
- override def transform(tree: Tree) = {
+ override def transform(tree0: Tree) = {
+ val tree = undoMacroExpansion(tree0)
currentSymbol = tree.symbol
val preTyper = tree match {
@@ -31,8 +33,13 @@ trait Reshape {
tree
case tt @ TypeTree() =>
toPreTyperTypeTree(tt)
+ case ctt @ CompoundTypeTree(_) =>
+ toPreTyperCompoundTypeTree(ctt)
case toa @ TypedOrAnnotated(_) =>
toPreTyperTypedOrAnnotated(toa)
+ case ta @ TypeApply(_, _) if isCrossStageTypeBearer(ta) =>
+ if (reifyDebug) println("cross-stage type bearer, retaining: " + tree)
+ ta
case ta @ TypeApply(hk, ts) =>
val discard = ts collect { case tt: TypeTree => tt } exists isDiscarded
if (reifyDebug && discard) println("discarding TypeApply: " + tree)
@@ -85,6 +92,27 @@ trait Reshape {
super.transform(preTyper)
}
+ private def undoMacroExpansion(tree: Tree): Tree =
+ tree.attachments.get[MacroExpansionAttachment] match {
+ case Some(MacroExpansionAttachment(original)) =>
+ original match {
+ // this hack is necessary until I fix implicit macros
+ // so far tag materialization is implemented by sneaky macros hidden in scala-compiler.jar
+ // hence we cannot reify references to them, because noone will be able to see them later
+ // when implicit macros are fixed, these sneaky macros will move to corresponding companion objects
+ // of, say, ClassTag or TypeTag
+ case Apply(TypeApply(_, List(tt)), _) if original.symbol == MacroInternal_materializeClassTag =>
+ gen.mkNullaryCall(Predef_implicitly, List(appliedType(ClassTagClass, tt.tpe)))
+ case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeAbsTypeTag =>
+ gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, AbsTypeTagClass, List(tt.tpe))))
+ case Apply(TypeApply(_, List(tt)), List(pre)) if original.symbol == MacroInternal_materializeTypeTag =>
+ gen.mkNullaryCall(Predef_implicitly, List(typeRef(pre.tpe, TypeTagClass, List(tt.tpe))))
+ case _ =>
+ original
+ }
+ case _ => tree
+ }
+
override def transformModifiers(mods: Modifiers) = {
val mods1 = toPreTyperModifiers(mods, currentSymbol)
super.transformModifiers(mods1)
@@ -130,6 +158,7 @@ trait Reshape {
* Suddenly I found out that in certain contexts original trees do not contain symbols, but are just parser trees.
* To the moment I know only one such situation: typedAnnotations does not typecheck the annotation in-place, but rather creates new trees and typechecks them, so the original remains symless.
* Thus we apply a workaround for that in typedAnnotated. I hope this will be the only workaround in this department.
+ * upd. There are also problems with CompoundTypeTrees. I had to use attachments to retain necessary information.
*
* upd. Recently I went ahead and started using original for all TypeTrees, regardless of whether they refer to local symbols or not.
* As a result, ``reifyType'' is never called directly by tree reification (and, wow, it seems to work great!).
@@ -137,7 +166,7 @@ trait Reshape {
*/
private def isDiscarded(tt: TypeTree) = tt.original == null
private def toPreTyperTypeTree(tt: TypeTree): Tree = {
- if (tt.original != null) {
+ if (!isDiscarded(tt)) {
// here we rely on the fact that the originals that reach this point
// have all necessary symbols attached to them (i.e. that they can be recompiled in any lexical context)
// if this assumption fails, please, don't be quick to add postprocessing here (like I did before)
@@ -154,6 +183,14 @@ trait Reshape {
}
}
+ private def toPreTyperCompoundTypeTree(ctt: CompoundTypeTree): Tree = {
+ val CompoundTypeTree(tmpl @ Template(parents, self, stats)) = ctt
+ assert(self eq emptyValDef, self)
+ val att = tmpl.attachments.get[CompoundTypeTreeOriginalAttachment]
+ val CompoundTypeTreeOriginalAttachment(parents1, stats1) = att.getOrElse(CompoundTypeTreeOriginalAttachment(parents, stats))
+ CompoundTypeTree(Template(parents1, self, stats1))
+ }
+
private def toPreTyperTypedOrAnnotated(tree: Tree): Tree = tree match {
case ty @ Typed(expr1, tt @ TypeTree()) =>
if (reifyDebug) println("reify typed: " + tree)
@@ -213,7 +250,7 @@ trait Reshape {
// [Eugene] is this implemented correctly?
private def trimAccessors(deff: Tree, stats: List[Tree]): List[Tree] = {
- val symdefs = stats collect { case vodef: ValOrDefDef => vodef } map (vodeff => vodeff.symbol -> vodeff) toMap
+ val symdefs = (stats collect { case vodef: ValOrDefDef => vodef } map (vodeff => vodeff.symbol -> vodeff)).toMap
val accessors = collection.mutable.Map[ValDef, List[DefDef]]()
stats collect { case ddef: DefDef => ddef } foreach (defdef => {
val valdef = symdefs get defdef.symbol.accessedOrSelf collect { case vdef: ValDef => vdef } getOrElse null
@@ -223,8 +260,8 @@ trait Reshape {
if (defdef.name.startsWith(prefix)) {
var name = defdef.name.toString.substring(prefix.length)
def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) }
- def findValDef(name: String) = symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef } headOption;
- val valdef = findValDef(name) orElse findValDef(uncapitalize(name)) orNull;
+ def findValDef(name: String) = (symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef }).headOption
+ val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull
if (valdef != null) accessors(valdef) = accessors.getOrElse(valdef, Nil) :+ defdef
}
}
diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala
new file mode 100644
index 0000000000..52e4ff08c1
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala
@@ -0,0 +1,302 @@
+package scala.reflect.reify
+package utils
+
+trait Extractors {
+ self: Utils =>
+
+ import global._
+ import definitions._
+ import Flag._
+
+ // Example of a reified tree for `reify(List(1, 2))`:
+ // (also contains an example of a reified type as a third argument to the constructor of Expr)
+ // {
+ // val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
+ // val $m: $u.Mirror = $u.runtimeMirror(Test.this.getClass().getClassLoader());
+ // $u.Expr[List[Int]]($m, {
+ // final class $treecreator1 extends scala.reflect.base.TreeCreator {
+ // def <init>(): $treecreator1 = {
+ // $treecreator1.super.<init>();
+ // ()
+ // };
+ // def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ // val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
+ // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ // applyImpl($m).asInstanceOf[U#Tree];
+ // }
+ // def applyImpl[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ // val $u: U = $m$untyped.universe;
+ // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ // $u.Apply($u.Select($u.Select($u.build.This($m.staticModule("scala.collection.immutable").moduleClass), $u.newTermName("List")), $u.newTermName("apply")), List($u.Literal($u.Constant(1)), $u.Literal($u.Constant(2))))
+ // }
+ // };
+ // new $treecreator1()
+ // })($u.TypeTag[List[Int]]($m, {
+ // final class $typecreator1 extends scala.reflect.base.TypeCreator {
+ // def <init>(): $typecreator1 = {
+ // $typecreator1.super.<init>();
+ // ()
+ // };
+ // def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ // val $u: U = $m$untyped.universe;
+ // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ // $u.TypeRef($u.ThisType($m.staticModule("scala.collection.immutable").moduleClass), $m.staticClass("scala.collection.immutable.List"), List($m.staticClass("scala.Int").asTypeConstructor))
+ // }
+ // };
+ // new $typecreator1()
+ // }))
+ // }
+
+ private def mkCreator(flavor: TypeName, symtab: SymbolTable, rtree: Tree): Tree = {
+ val tparamu = newTypeName("U")
+ val (reifierBase, reifierName, reifierTpt, reifierUniverse) = flavor match {
+ case tpnme.REIFY_TYPECREATOR_PREFIX => (TypeCreatorClass, nme.apply, SelectFromTypeTree(Ident(tparamu), tpnme.Type), BaseUniverseClass)
+ case tpnme.REIFY_TREECREATOR_PREFIX => (TreeCreatorClass, nme.applyImpl, SelectFromTypeTree(Ident(BaseUniverseClass), tpnme.Tree), ApiUniverseClass)
+ case _ => throw new Error(s"unexpected flavor $flavor")
+ }
+ val reifierPreamble = flavor match {
+ case tpnme.REIFY_TYPECREATOR_PREFIX => Nil
+ case tpnme.REIFY_TREECREATOR_PREFIX => List[Tree](
+ DefDef(NoMods,
+ nme.apply,
+ List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(BaseUniverseClass), Ident(SingletonClass)), emptyValDef, List()))))),
+ List(List(ValDef(Modifiers(PARAM), nme.MIRROR_UNTYPED, AppliedTypeTree(Ident(MirrorOfClass), List(Ident(tparamu))), EmptyTree))),
+ SelectFromTypeTree(Ident(tparamu), tpnme.Tree),
+ Block(
+ ValDef(NoMods, nme.UNIVERSE_SHORT, Ident(ApiUniverseClass), TypeApply(Select(Select(Ident(nme.MIRROR_UNTYPED), nme.universe), nme.asInstanceOf_), List(Ident(ApiUniverseClass)))),
+ ValDef(NoMods, nme.MIRROR_SHORT, Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror), TypeApply(Select(Ident(nme.MIRROR_UNTYPED), nme.asInstanceOf_), List(Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror)))),
+ TypeApply(Select(Apply(TypeApply(Ident(reifierName), List(SingletonTypeTree(Ident(nme.UNIVERSE_SHORT)))), List(Ident(nme.MIRROR_SHORT))), nme.asInstanceOf_), List(SelectFromTypeTree(Ident(tparamu), tpnme.Tree)))
+ ))
+ )
+ case _ => throw new Error(s"unexpected flavor $flavor")
+ }
+ val reifierBody = {
+ def gc(symtab: SymbolTable): SymbolTable = {
+ def loop(symtab: SymbolTable): SymbolTable = {
+ def extractNames(tree: Tree) = tree.collect{ case ref: RefTree => ref.name }.toSet
+ val usedNames = extractNames(rtree) ++ symtab.syms.flatMap(sym => extractNames(symtab.symDef(sym)))
+ symtab filterAliases { case (_, name) => usedNames(name) }
+ }
+ var prev = symtab
+ var next = loop(symtab)
+ while (next.syms.length < prev.syms.length) {
+ prev = next
+ next = loop(prev)
+ }
+ next
+ }
+
+ val universeAlias = ValDef(NoMods, nme.UNIVERSE_SHORT, Ident(tparamu), Select(Ident(nme.MIRROR_UNTYPED), nme.universe))
+ val mirrorAlias = ValDef(NoMods, nme.MIRROR_SHORT, Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror), TypeApply(Select(Ident(nme.MIRROR_UNTYPED), nme.asInstanceOf_), List(Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror))))
+ val trimmedSymtab = if (hasReifier) gc(symtab) else symtab
+ Block(universeAlias :: mirrorAlias :: trimmedSymtab.encode, rtree)
+ }
+ val tpec = ClassDef(
+ Modifiers(FINAL),
+ newTypeName(global.currentUnit.fresh.newName(flavor.toString)),
+ List(),
+ Template(List(Ident(reifierBase)),
+ emptyValDef,
+ List(
+ DefDef(NoMods, nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(()))))
+ ) ++ reifierPreamble ++ List(
+ DefDef(NoMods,
+ reifierName,
+ List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(reifierUniverse), Ident(SingletonClass)), emptyValDef, List()))))),
+ List(List(ValDef(Modifiers(PARAM), nme.MIRROR_UNTYPED, AppliedTypeTree(Ident(MirrorOfClass), List(Ident(tparamu))), EmptyTree))),
+ reifierTpt, reifierBody))))
+ Block(tpec, ApplyConstructor(Ident(tpec.name), List()))
+ }
+
+ private def mkWrapper(universe: Tree, mirror: Tree, wrappee: Tree): Tree = {
+ val universeAlias = ValDef(NoMods, nme.UNIVERSE_SHORT, SingletonTypeTree(universe), universe)
+ val mirrorAlias = ValDef(NoMods, nme.MIRROR_SHORT, Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror), mirror orElse mkDefaultMirrorRef(global)(universe, typer))
+ Block(List(universeAlias, mirrorAlias), wrappee)
+ }
+
+ object ReifiedTree {
+ def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, rtree: Tree, tpe: Type, rtpe: Tree, concrete: Boolean): Tree = {
+ val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag
+ val tagCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe)))
+ val exprCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), nme.Expr), nme.apply), List(TypeTree(tpe)))
+ val tagArgs = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe))
+ val unwrapped = Apply(Apply(exprCtor, List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TREECREATOR_PREFIX, symtab, rtree))), List(Apply(tagCtor, tagArgs)))
+ mkWrapper(universe, mirror, unwrapped)
+ }
+
+ def unapply(tree: Tree): Option[(Tree, Tree, SymbolTable, Tree, Type, Tree, Boolean)] = tree match {
+ case Block(
+ List(udef @ ValDef(_, _, _, universe), mdef @ ValDef(_, _, _, mirror)),
+ Apply(
+ Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, _, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))),
+ // todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization
+ List(Apply(TypeApply(tagFactory @ Select(_, _), _), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable2, rtpe)))))), _))))))
+ if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT =>
+ val tagFlavor = tagFactory match {
+ case Select(Select(_, tagFlavor), _) => tagFlavor
+ case Select(_, tagFlavor) => tagFlavor
+ }
+ Some(universe, mirror, SymbolTable(symbolTable1 ++ symbolTable2), rtree, ttpe.tpe, rtpe, tagFlavor == nme.TypeTag)
+ case _ =>
+ None
+ }
+ }
+
+ object ReifiedType {
+ def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, tpe: Type, rtpe: Tree, concrete: Boolean) = {
+ val tagFactory = if (concrete) nme.TypeTag else nme.AbsTypeTag
+ val ctor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe)))
+ val args = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe))
+ val unwrapped = Apply(ctor, args)
+ mkWrapper(universe, mirror, unwrapped)
+ }
+
+ def unapply(tree: Tree): Option[(Tree, Tree, SymbolTable, Type, Tree, Boolean)] = tree match {
+ case Block(
+ List(udef @ ValDef(_, _, _, universe), mdef @ ValDef(_, _, _, mirror)),
+ // todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization
+ Apply(TypeApply(tagFactory @ Select(_, _), List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symtab, rtpe)))))), _))))
+ if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT =>
+ val tagFlavor = tagFactory match {
+ case Select(Select(_, tagFlavor), _) => tagFlavor
+ case Select(_, tagFlavor) => tagFlavor
+ }
+ Some(universe, mirror, SymbolTable(symtab), ttpe.tpe, rtpe, tagFlavor == nme.TypeTag)
+ case _ =>
+ None
+ }
+ }
+
+ object TreeSplice {
+ def apply(splicee: Tree): Tree =
+ Select(splicee, ExprSplice)
+
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Select(splicee, _) if tree.symbol != NoSymbol && tree.symbol == ExprSplice =>
+ Some(splicee)
+ case _ =>
+ None
+ }
+ }
+
+ object FreeDef {
+ def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
+ case FreeTermDef(uref, name, binding, flags, origin) =>
+ Some(uref, name, binding, flags, origin)
+ case FreeTypeDef(uref, name, binding, flags, origin) =>
+ Some(uref, name, binding, flags, origin)
+ case _ =>
+ None
+ }
+ }
+
+ object FreeTermDef {
+ def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
+ case
+ ValDef(_, name, _, Apply(
+ Select(Select(uref1 @ Ident(_), build1), newFreeTerm),
+ List(
+ _,
+ _,
+ binding,
+ Apply(Select(Select(uref2 @ Ident(_), build2), flagsFromBits), List(Literal(Constant(flags: Long)))),
+ Literal(Constant(origin: String)))))
+ if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeTerm == nme.newFreeTerm &&
+ uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
+ Some(uref1, name, binding, flags, origin)
+ case _ =>
+ None
+ }
+ }
+
+ object FreeTypeDef {
+ def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
+ case
+ ValDef(_, name, _, Apply(
+ Select(Select(uref1 @ Ident(_), build1), newFreeType),
+ List(
+ _,
+ _,
+ value,
+ Apply(Select(Select(uref2 @ Ident(_), build2), flagsFromBits), List(Literal(Constant(flags: Long)))),
+ Literal(Constant(origin: String)))))
+ if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && (newFreeType == nme.newFreeType || newFreeType == nme.newFreeExistential) &&
+ uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
+ value match {
+ case Apply(TypeApply(Select(Select(uref3 @ Ident(_), typeTag), apply), List(binding)), List(Literal(Constant(null)), _))
+ if uref3.name == nme.UNIVERSE_SHORT && typeTag == nme.TypeTag && apply == nme.apply =>
+ Some(uref1, name, binding, flags, origin)
+ case Apply(TypeApply(Select(uref3 @ Ident(_), typeTag), List(binding)), List(Literal(Constant(null)), _))
+ if uref3.name == nme.UNIVERSE_SHORT && typeTag == nme.TypeTag =>
+ Some(uref1, name, binding, flags, origin)
+ case _ =>
+ throw new Error("unsupported free type def: %s%n%s".format(value, showRaw(value)))
+ }
+ case _ =>
+ None
+ }
+ }
+
+ object FreeRef {
+ def unapply(tree: Tree): Option[(Tree, TermName)] = tree match {
+ case Apply(Select(Select(uref @ Ident(_), build), ident), List(Ident(name: TermName)))
+ if build == nme.build && ident == nme.Ident && name.startsWith(nme.REIFY_FREE_PREFIX) =>
+ Some(uref, name)
+ case _ =>
+ None
+ }
+ }
+
+ object SymDef {
+ def unapply(tree: Tree): Option[(Tree, TermName, Long, Boolean)] = tree match {
+ case
+ ValDef(_, name, _, Apply(
+ Select(Select(uref1 @ Ident(_), build1), newNestedSymbol),
+ List(
+ _,
+ _,
+ _,
+ Apply(Select(Select(uref2 @ Ident(_), build2), flagsFromBits), List(Literal(Constant(flags: Long)))),
+ Literal(Constant(isClass: Boolean)))))
+ if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newNestedSymbol == nme.newNestedSymbol &&
+ uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
+ Some(uref1, name, flags, isClass)
+ case _ =>
+ None
+ }
+ }
+
+ object TypeRefToFreeType {
+ def unapply(tree: Tree): Option[TermName] = tree match {
+ case Apply(Select(Select(uref @ Ident(_), typeRef), apply), List(Select(_, noSymbol), Ident(freeType: TermName), nil))
+ if (uref.name == nme.UNIVERSE_SHORT && typeRef == nme.TypeRef && noSymbol == nme.NoSymbol && freeType.startsWith(nme.REIFY_FREE_PREFIX)) =>
+ Some(freeType)
+ case _ =>
+ None
+ }
+ }
+
+ object BoundTerm {
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Ident(name) if name.isTermName =>
+ Some(tree)
+ case This(_) =>
+ Some(tree)
+ case _ =>
+ None
+ }
+ }
+
+ object BoundType {
+ def unapply(tree: Tree): Option[Tree] = tree match {
+ case Select(_, name) if name.isTypeName =>
+ Some(tree)
+ case SelectFromTypeTree(_, name) if name.isTypeName =>
+ Some(tree)
+ case Ident(name) if name.isTypeName =>
+ Some(tree)
+ case _ =>
+ None
+ }
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala
new file mode 100644
index 0000000000..ce0ab2196a
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala
@@ -0,0 +1,144 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.reflect.reify
+package utils
+
+import scala.compat.Platform.EOL
+
+trait NodePrinters {
+ self: Utils =>
+
+ import global._
+ import definitions._
+ import Flag._
+
+ object reifiedNodeToString extends (Tree => String) {
+ // [Eugene++ to Martin] can we do better?
+ // didn't want to invent anything myself in order not to interfere with your line of thought
+ def bitsToFlags(bits: String): String = {
+ val flags = bits.toLong
+ if (flags == NoFlags) nme.NoFlags.toString
+ else {
+ val s_flags = new collection.mutable.ListBuffer[String]
+ if (flags containsAll TRAIT) s_flags += "TRAIT"
+ if (flags containsAll MODULE) s_flags += "MODULE"
+ if (flags containsAll MUTABLE) s_flags += "MUTABLE"
+ if (flags containsAll PACKAGE) s_flags += "PACKAGE"
+ if (flags containsAll METHOD) s_flags += "METHOD"
+ if (flags containsAll DEFERRED) s_flags += "DEFERRED"
+ if (flags containsAll ABSTRACT) s_flags += "ABSTRACT"
+ if (flags containsAll FINAL) s_flags += "FINAL"
+ if (flags containsAll SEALED) s_flags += "SEALED"
+ if (flags containsAll IMPLICIT) s_flags += "IMPLICIT"
+ if (flags containsAll LAZY) s_flags += "LAZY"
+ if (flags containsAll OVERRIDE) s_flags += "OVERRIDE"
+ if (flags containsAll PRIVATE) s_flags += "PRIVATE"
+ if (flags containsAll PROTECTED) s_flags += "PROTECTED"
+ if (flags containsAll CASE) s_flags += "CASE"
+ if (flags containsAll ABSOVERRIDE) s_flags += "ABSOVERRIDE"
+ if (flags containsAll BYNAMEPARAM) s_flags += "BYNAMEPARAM"
+ if (flags containsAll PARAM) s_flags += "PARAM"
+ if (flags containsAll PARAMACCESSOR) s_flags += "PARAMACCESSOR"
+ if (flags containsAll CASEACCESSOR) s_flags += "CASEACCESSOR"
+ if (flags containsAll COVARIANT) s_flags += "COVARIANT"
+ if (flags containsAll CONTRAVARIANT) s_flags += "CONTRAVARIANT"
+ if (flags containsAll DEFAULTPARAM) s_flags += "DEFAULTPARAM"
+ if (flags containsAll INTERFACE) s_flags += "INTERFACE"
+ s_flags mkString " | "
+ }
+ }
+
+ def apply(tree: Tree): String = {
+ var mirrorIsUsed = false
+ var flagsAreUsed = false
+
+ // @PP: I fervently hope this is a test case or something, not anything being
+ // depended upon. Of more fragile code I cannot conceive.
+ // @Eugene: This stuff is only needed to debug-print out reifications in human-readable format
+ // Rolling a full-fledged, robust TreePrinter would be several times more code.
+ val lines = (tree.toString.split(EOL) drop 1 dropRight 1).toList splitAt 2
+ var (List(universe, mirror), reification) = lines
+ reification = (for (line <- reification) yield {
+ var s = line substring 2
+ s = s.replace(nme.UNIVERSE_PREFIX.toString, "")
+ s = s.replace(".apply", "")
+ s = "([^\"])scala\\.collection\\.immutable\\.".r.replaceAllIn(s, "$1")
+ s = "List\\[List\\[.*?\\].*?\\]".r.replaceAllIn(s, "List")
+ s = "List\\[.*?\\]".r.replaceAllIn(s, "List")
+ s = s.replace("immutable.this.Nil", "List()")
+ s = """build\.flagsFromBits\((\d+)[lL]\)""".r.replaceAllIn(s, m => {
+ flagsAreUsed = true
+ bitsToFlags(m.group(1))
+ })
+ s = s.replace("Modifiers(0L, newTypeName(\"\"), List())", "Modifiers()")
+ s = """Modifiers\((\d+)[lL], newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => {
+ val buf = new collection.mutable.ListBuffer[String]
+
+ val annotations = m.group(3)
+ if (buf.nonEmpty || annotations.nonEmpty)
+ buf.append("List(" + annotations + ")")
+
+ val privateWithin = "" + m.group(2)
+ if (buf.nonEmpty || privateWithin != "")
+ buf.append("newTypeName(\"" + privateWithin + "\")")
+
+ val bits = m.group(1)
+ if (buf.nonEmpty || bits != "0L") {
+ flagsAreUsed = true
+ buf.append(bitsToFlags(bits))
+ }
+
+ val replacement = "Modifiers(" + buf.reverse.mkString(", ") + ")"
+ java.util.regex.Matcher.quoteReplacement(replacement)
+ })
+ s
+ })
+
+ val isExpr = reification.length > 0 && reification(0).trim.startsWith("Expr[")
+ var rtree = reification dropWhile (!_.trim.startsWith(s"val ${nme.UNIVERSE_SHORT}: U = ${nme.MIRROR_UNTYPED}.universe;"))
+ rtree = rtree drop 2
+ rtree = rtree takeWhile (_ != " }")
+ rtree = rtree map (s0 => {
+ var s = s0
+ mirrorIsUsed |= s contains nme.MIRROR_PREFIX.toString
+ s = s.replace(nme.MIRROR_PREFIX.toString, "")
+ s.trim
+ })
+
+ val printout = collection.mutable.ListBuffer[String]();
+ printout += universe.trim
+ if (mirrorIsUsed) printout += mirror.replace("MirrorOf[", "scala.reflect.base.MirrorOf[").trim
+ val imports = collection.mutable.ListBuffer[String]();
+ imports += nme.UNIVERSE_SHORT
+ // if (buildIsUsed) imports += nme.build
+ if (mirrorIsUsed) imports += nme.MIRROR_SHORT
+ if (flagsAreUsed) imports += nme.Flag
+ printout += s"""import ${imports map (_ + "._") mkString ", "}"""
+
+ val name = if (isExpr) "tree" else "tpe"
+ if (rtree(0) startsWith "val") {
+ printout += s"val $name = {"
+ printout ++= (rtree map (" " + _))
+ printout += "}"
+ } else {
+ printout += s"val $name = " + rtree(0)
+ }
+ if (isExpr) {
+ if (mirror contains ".getClassLoader") {
+ printout += "import scala.tools.reflect.ToolBox"
+ printout += s"println(${nme.MIRROR_SHORT}.mkToolBox().runExpr(tree))"
+ } else {
+ printout += "println(tree)"
+ }
+ } else {
+ printout += "println(tpe)"
+ }
+
+ // printout mkString EOL
+ val prefix = "// produced from " + reifier.defaultErrorPosition
+ (prefix +: "object Test extends App {" +: (printout map (" " + _)) :+ "}") mkString EOL
+ }
+ }
+}
diff --git a/src/compiler/scala/reflect/reify/utils/StdAttachments.scala b/src/compiler/scala/reflect/reify/utils/StdAttachments.scala
new file mode 100644
index 0000000000..abbed814e0
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/utils/StdAttachments.scala
@@ -0,0 +1,12 @@
+package scala.reflect.reify
+package utils
+
+trait StdAttachments {
+ self: Utils =>
+
+ import global._
+
+ case class ReifyBindingAttachment(binding: Symbol)
+
+ case class ReifyAliasAttachment(binding: Symbol, alias: TermName)
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala
new file mode 100644
index 0000000000..a7ac299317
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala
@@ -0,0 +1,223 @@
+package scala.reflect.reify
+package utils
+
+import scala.collection._
+import scala.compat.Platform.EOL
+
+trait SymbolTables {
+ self: Utils =>
+
+ import global._
+ import definitions._
+ import Flag._
+
+ class SymbolTable private[SymbolTable] (
+ private[SymbolTable] val symtab: immutable.ListMap[Symbol, Tree] = immutable.ListMap[Symbol, Tree](),
+ private[SymbolTable] val aliases: List[(Symbol, TermName)] = List[(Symbol, TermName)](),
+ private[SymbolTable] val original: Option[List[Tree]] = None) {
+
+ def syms: List[Symbol] = symtab.keys.toList
+
+// def aliases: Map[Symbol, List[TermName]] = aliases.distinct groupBy (_._1) mapValues (_ map (_._2))
+
+ def symDef(sym: Symbol): Tree =
+ symtab.getOrElse(sym, EmptyTree)
+
+ def symName(sym: Symbol): TermName =
+ symtab.get(sym) match {
+ case Some(FreeDef(_, name, _, _, _)) => name
+ case Some(SymDef(_, name, _, _)) => name
+ case None => EmptyTermName
+ }
+
+ def symAliases(sym: Symbol): List[TermName] =
+ symName(sym) match {
+ case name if name.isEmpty => Nil
+ case _ => (aliases.distinct groupBy (_._1) mapValues (_ map (_._2)))(sym)
+ }
+
+ def symBinding(sym: Symbol): Tree =
+ symtab.get(sym) match {
+ case Some(FreeDef(_, _, binding, _, _)) => binding
+ case Some(SymDef(_, _, _, _)) => throw new UnsupportedOperationException(s"${symtab(sym)} is a symdef, hence it doesn't have a binding")
+ case None => EmptyTree
+ }
+
+ def symRef(sym: Symbol): Tree =
+ symtab.get(sym) match {
+ case Some(FreeDef(_, name, _, _, _)) => Ident(name) addAttachment ReifyBindingAttachment(sym)
+ case Some(SymDef(_, name, _, _)) => Ident(name) addAttachment ReifyBindingAttachment(sym)
+ case None => EmptyTree
+ }
+
+ def +(sym: Symbol, name: TermName, reification: Tree): SymbolTable = add(sym, name, reification)
+ def +(sym: Symbol, name: TermName): SymbolTable = add(sym, name)
+ def +(symDef: Tree): SymbolTable = add(symDef)
+ def ++(symDefs: TraversableOnce[Tree]): SymbolTable = (this /: symDefs)((symtab, symDef) => symtab.add(symDef))
+ def ++(symtab: SymbolTable): SymbolTable = { val updated = this ++ symtab.symtab.values; new SymbolTable(updated.symtab, updated.aliases ++ symtab.aliases) }
+ def -(sym: Symbol): SymbolTable = remove(sym)
+ def -(name: TermName): SymbolTable = remove(name)
+ def -(symDef: Tree): SymbolTable = remove(binding(symDef))
+ def --(syms: GenTraversableOnce[Symbol]): SymbolTable = (this /: syms)((symtab, sym) => symtab.remove(sym))
+ def --(names: Iterable[TermName]): SymbolTable = (this /: names)((symtab, name) => symtab.remove(name))
+ def --(symDefs: TraversableOnce[Tree]): SymbolTable = this -- (symDefs map (binding(_)))
+ def --(symtab: SymbolTable): SymbolTable = { val updated = this -- symtab.symtab.values; new SymbolTable(updated.symtab, updated.aliases diff symtab.aliases) }
+ def filterSyms(p: Symbol => Boolean): SymbolTable = this -- (syms filterNot p)
+ def filterAliases(p: (Symbol, TermName) => Boolean): SymbolTable = this -- (aliases filterNot (tuple => p(tuple._1, tuple._2)) map (_._2))
+
+ private def add(symDef: Tree): SymbolTable = {
+ val sym = binding(symDef)
+ assert(sym != NoSymbol, showRaw(symDef))
+ val name = symDef match {
+ case FreeDef(_, name, _, _, _) => name
+ case SymDef(_, name, _, _) => name
+ }
+ val newSymtab = if (!(symtab contains sym)) symtab + (sym -> symDef) else symtab
+ val newAliases = aliases :+ (sym -> name)
+ new SymbolTable(newSymtab, newAliases)
+ }
+
+ private def add(sym: Symbol, name0: TermName, reification: Tree): SymbolTable = {
+ def freshName(name0: TermName): TermName = {
+ var name = name0.toString
+ name = name.replace(".type", "$type")
+ name = name.replace(" ", "$")
+ val fresh = typer.context.unit.fresh
+ newTermName(fresh.newName(name))
+ }
+ add(ValDef(NoMods, freshName(name0), TypeTree(), reification) addAttachment ReifyBindingAttachment(sym))
+ }
+
+ private def add(sym: Symbol, name: TermName): SymbolTable = {
+ if (!(syms contains sym)) error("cannot add an alias to a symbol not in the symbol table")
+ add(sym, name, EmptyTree)
+ }
+
+ private def remove(sym: Symbol): SymbolTable = {
+ val newSymtab = symtab - sym
+ val newAliases = aliases filter (_._1 != sym)
+ new SymbolTable(newSymtab, newAliases)
+ }
+
+ private def remove(name: TermName): SymbolTable = {
+ var newSymtab = symtab
+ val newAliases = aliases filter (_._2 != name)
+ newSymtab = newSymtab filter { case ((sym, _)) => newAliases exists (_._1 == sym) }
+ newSymtab = newSymtab map { case ((sym, tree)) =>
+ val ValDef(mods, primaryName, tpt, rhs) = tree
+ val tree1 =
+ if (!(newAliases contains (sym, primaryName))) {
+ val primaryName1 = newAliases.find(_._1 == sym).get._2
+ ValDef(mods, primaryName1, tpt, rhs).copyAttrs(tree)
+ } else tree
+ (sym, tree1)
+ }
+ new SymbolTable(newSymtab, newAliases)
+ }
+
+ private def binding(tree: Tree): Symbol =
+ tree.attachments.get[ReifyBindingAttachment] match {
+ case Some(ReifyBindingAttachment(binding)) => binding
+ case other => NoSymbol
+ }
+
+ private val cache = mutable.Map[SymbolTable, List[Tree]]()
+ def encode: List[Tree] = cache.getOrElseUpdate(this, SymbolTable.encode(this)) map (_.duplicate)
+
+ override def toString = {
+ val symtabString = symtab.keys.map(symName(_)).mkString(", ")
+ val trueAliases = aliases.distinct.filter(entry => symName(entry._1) != entry._2)
+ val aliasesString = trueAliases.map(entry => s"${symName(entry._1)} -> ${entry._2}").mkString(", ")
+ s"""symtab = [$symtabString], aliases = [$aliasesString]${if (original.isDefined) ", has original" else ""}"""
+ }
+
+ def debugString: String = {
+ val buf = new StringBuilder
+ buf.append("symbol table = " + (if (syms.length == 0) "<empty>" else "")).append(EOL)
+ syms foreach (sym => buf.append(symDef(sym)).append(EOL))
+ buf.delete(buf.length - EOL.length, buf.length)
+ buf.toString
+ }
+ }
+
+ object SymbolTable {
+ def apply(): SymbolTable =
+ new SymbolTable()
+
+ def apply(encoded: List[Tree]): SymbolTable = {
+ var result = new SymbolTable(original = Some(encoded))
+ encoded foreach (entry => (entry.attachments.get[ReifyBindingAttachment], entry.attachments.get[ReifyAliasAttachment]) match {
+ case (Some(ReifyBindingAttachment(sym)), _) => result += entry
+ case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ (sym, alias))
+ case _ => // do nothing, this is boilerplate that can easily be recreated by subsequent `result.encode`
+ })
+ result
+ }
+
+ private[SymbolTable] def encode(symtab0: SymbolTable): List[Tree] = {
+ if (symtab0.original.isDefined) return symtab0.original.get.map(_.duplicate)
+ else assert(hasReifier, "encoding a symbol table requires a reifier")
+ // during `encode` we might need to do some reifications
+ // these reifications might lead to changes in `reifier.symtab`
+ // reifier is mutable, symtab is immutable. this is a tough friendship
+ val backup = reifier.state.backup
+ reifier.state.symtab = symtab0.asInstanceOf[reifier.SymbolTable]
+ def currtab = reifier.symtab.asInstanceOf[SymbolTable]
+ try {
+ val cumulativeSymtab = mutable.ArrayBuffer[Tree](symtab0.symtab.values.toList: _*)
+ val cumulativeAliases = mutable.ArrayBuffer[(Symbol, TermName)](symtab0.aliases: _*)
+
+ def fillInSymbol(sym: Symbol): Tree = {
+ if (reifyDebug) println("Filling in: %s (%s)".format(sym, sym.accurateKindString))
+ val isFree = currtab.symName(sym) startsWith nme.REIFY_FREE_PREFIX
+ if (isFree) {
+ if (sym.annotations.isEmpty) EmptyTree
+ else Apply(Select(currtab.symRef(sym), nme.setAnnotations), List(reifier.reify(sym.annotations)))
+ } else {
+ import scala.reflect.internal.Flags._
+ if (sym hasFlag LOCKED) {
+ // [Eugene] better to have a symbol without a type signature, than to crash with a CyclicReference
+ EmptyTree
+ } else {
+ val rset = reifier.mirrorBuildCall(nme.setTypeSignature, currtab.symRef(sym), reifier.reify(sym.info))
+ if (sym.annotations.isEmpty) rset
+ else reifier.mirrorBuildCall(nme.setAnnotations, rset, reifier.mkList(sym.annotations map reifier.reifyAnnotationInfo))
+ }
+ }
+ }
+
+ // `fillInSymbol` might add symbols to `symtab`, that's why this is done iteratively
+ var progress = 0
+ while (progress < cumulativeSymtab.length) {
+ val sym = currtab.binding(cumulativeSymtab(progress))
+ if (sym != NoSymbol) {
+ val symtabProgress = currtab.symtab.size
+ val aliasesProgress = currtab.aliases.length
+ val fillIn = fillInSymbol(sym)
+ cumulativeSymtab ++= currtab.symtab.values drop symtabProgress
+ cumulativeAliases ++= currtab.aliases drop aliasesProgress
+ cumulativeSymtab += fillIn
+ }
+ progress += 1
+ }
+
+ val withAliases = cumulativeSymtab flatMap (entry => {
+ val result = mutable.ListBuffer[Tree]()
+ result += entry
+ val sym = currtab.binding(entry)
+ if (sym != NoSymbol)
+ result ++= cumulativeAliases.distinct filter (alias => alias._1 == sym && alias._2 != currtab.symName(sym)) map (alias => {
+ val canonicalName = currtab.symName(sym)
+ val aliasName = alias._2
+ ValDef(NoMods, aliasName, TypeTree(), Ident(canonicalName)) addAttachment ReifyAliasAttachment(sym, aliasName)
+ })
+ result.toList
+ })
+
+ withAliases.toList
+ } finally {
+ reifier.state.restore(backup)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/utils/Utils.scala b/src/compiler/scala/reflect/reify/utils/Utils.scala
new file mode 100644
index 0000000000..e1213f932c
--- /dev/null
+++ b/src/compiler/scala/reflect/reify/utils/Utils.scala
@@ -0,0 +1,21 @@
+package scala.reflect.reify
+package utils
+
+import scala.tools.nsc.Global
+
+trait Utils extends NodePrinters
+ with Extractors
+ with SymbolTables
+ with StdAttachments {
+
+ val global: Global
+ val typer: global.analyzer.Typer
+
+ lazy val reifier: Reifier { val global: Utils.this.global.type } = getReifier
+ def getReifier: Reifier { val global: Utils.this.global.type } = ???
+ def hasReifier = false
+
+ val reifyDebug = global.settings.Yreifydebug.value
+ val reifyCopypaste = global.settings.Yreifycopypaste.value
+ val reifyTrace = scala.tools.nsc.util.trace when reifyDebug
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/runtime/ClassLoaders.scala b/src/compiler/scala/reflect/runtime/ClassLoaders.scala
deleted file mode 100644
index b73d57c04d..0000000000
--- a/src/compiler/scala/reflect/runtime/ClassLoaders.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package scala.reflect
-package runtime
-
-trait ClassLoaders extends internal.SymbolTable { self: SymbolTable =>
-
- def staticClass(fullname: String) =
- definitions.getRequiredClass(fullname)
-
- def staticModule(fullname: String) =
- definitions.getRequiredModule(fullname)
-
- /** If `owner` is a package class (but not the empty package) and `name` is a term name, make a new package
- * <owner>.<name>, otherwise return NoSymbol.
- * Exception: If owner is root and a java class with given name exists, create symbol in empty package instead.
- */
- override def missingHook(owner: Symbol, name: Name): Symbol =
- if (owner.isRoot && isJavaClass(name.toString))
- definitions.EmptyPackageClass.info decl name
- else if (name.isTermName && owner.hasPackageFlag && !owner.isEmptyPackageClass)
- makeScalaPackage(if (owner.isRoot) name.toString else owner.fullName+"."+name).sourceModule
- else {
- info("*** missing: "+name+"/"+name.isTermName+"/"+owner+"/"+owner.hasPackageFlag+"/"+owner.info.decls.getClass)
- super.missingHook(owner, name)
- }
-}
diff --git a/src/compiler/scala/reflect/runtime/ConversionUtil.scala b/src/compiler/scala/reflect/runtime/ConversionUtil.scala
deleted file mode 100644
index e45fc243c6..0000000000
--- a/src/compiler/scala/reflect/runtime/ConversionUtil.scala
+++ /dev/null
@@ -1,92 +0,0 @@
-package scala.reflect
-package runtime
-
-import java.lang.{Class => jClass, Package => jPackage}
-import java.lang.reflect.{
- Method => jMethod, Constructor => jConstructor, Modifier => jModifier, Field => jField,
- Member => jMember, Type => jType, TypeVariable => jTypeVariable, GenericDeclaration}
-import collection.mutable.HashMap
-
-trait ConversionUtil { self: SymbolTable =>
-
- /** A cache that maintains a bijection between Java reflection type `J`
- * and Scala reflection type `S`.
- */
- // todo. should be weak
- protected class TwoWayCache[J, S] {
-
- private val toScalaMap = new HashMap[J, S]
- private val toJavaMap = new HashMap[S, J]
-
- def enter(j: J, s: S) = synchronized {
- debugInfo("cached: "+j+"/"+s)
- toScalaMap(j) = s
- toJavaMap(s) = j
- }
-
- def toScala(key: J)(body: => S): S = synchronized {
- toScalaMap get key match {
- case Some(v) =>
- v
- case none =>
- val result = body
- enter(key, result)
- result
- }
- }
-
- def toJava(key: S)(body: => J): J = synchronized {
- toJavaMap get key match {
- case Some(v) =>
- v
- case none =>
- val result = body
- enter(result, key)
- result
- }
- }
-
- def toJavaOption(key: S)(body: => Option[J]): Option[J] = synchronized {
- toJavaMap get key match {
- case None =>
- val result = body
- for (value <- result) enter(value, key)
- result
- case some => some
- }
- }
- }
-
- protected val classCache = new TwoWayCache[jClass[_], Symbol]
- protected val packageCache = new TwoWayCache[Package, Symbol]
- protected val methodCache = new TwoWayCache[jMethod, Symbol]
- protected val constructorCache = new TwoWayCache[jConstructor[_], Symbol]
- protected val fieldCache = new TwoWayCache[jField, Symbol]
- protected val tparamCache = new TwoWayCache[jTypeVariable[_], Symbol]
-
- /** the type of this symbol after Scala -> Java transformsi in refChecks, uncurry, erasure
- */
- def transformedType(sym: Symbol): Type
-
- /** The Java class thaty given type compiles to */
- def typeToJavaClass(tpe: Type): jClass[_]
-
- /** Does method `meth` erase to Java method `jmeth`?
- * This is true if the Java method type is the same as the Scala method type after performing
- * all Scala-specific transformations in InfoTransformers. (to be done)
- */
- protected def erasesTo(meth: Symbol, jmeth: jMethod): Boolean = {
- val mtpe = transformedType(meth)
- (mtpe.paramTypes map typeToJavaClass) == jmeth.getParameterTypes.toList &&
- typeToJavaClass(mtpe.resultType) == jmeth.getReturnType
- }
-
- /** Does constructor `meth` erase to Java method `jconstr`?
- * This is true if the Java constructor type is the same as the Scala constructor type after performing
- * all Scala-specific transformations in InfoTransformers. (to be done)
- */
- protected def erasesTo(meth: Symbol, jconstr: jConstructor[_]): Boolean = {
- val mtpe = transformedType(meth)
- (mtpe.paramTypes map typeToJavaClass) == jconstr.getParameterTypes.toList
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala
deleted file mode 100644
index e11f6140c9..0000000000
--- a/src/compiler/scala/reflect/runtime/JavaToScala.scala
+++ /dev/null
@@ -1,697 +0,0 @@
-package scala.reflect
-package runtime
-
-import java.lang.{ Class => jClass, Package => jPackage, ClassLoader => JClassLoader }
-import java.io.IOException
-import java.lang.reflect.{
- Method => jMethod,
- Constructor => jConstructor,
- Modifier => jModifier,
- Field => jField,
- Member => jMember,
- Type => jType,
- TypeVariable => jTypeVariable,
- GenericDeclaration,
- GenericArrayType,
- ParameterizedType,
- WildcardType,
- AnnotatedElement
-}
-import internal.MissingRequirementError
-import internal.pickling.ByteCodecs
-import internal.ClassfileConstants._
-import internal.pickling.UnPickler
-import collection.mutable.{ HashMap, ListBuffer }
-import internal.Flags._
-import scala.tools.nsc.util.ScalaClassLoader
-import scala.tools.nsc.util.ScalaClassLoader._
-
-trait JavaToScala extends ConversionUtil { self: SymbolTable =>
-
- import definitions._
-
- private object unpickler extends UnPickler {
- val global: JavaToScala.this.type = self
- }
-
- /** Defines the classloader that will be used for all class resolution activities in this mirror.
- * Is mutable, since sometimes we need to change it in flight (e.g. to make the default mirror work with REPL).
- *
- * If you want to have a mirror with non-standard class resolution, override this var
- * (or, even simpler, use the `mkMirror` function from `scala.reflect` package)
- *
- * Be careful, though, since fancy stuff might happen.
- * Here's one example:
- *
- * partest uses a URLClassLoader(urls, null) with custom classpath to run workers (in separate threads)
- * however it doesn't set the context classloader for them, so they inherit the system classloader
- * http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html
- *
- * Once upon a time, scala.reflect.mirror was loaded using getClass.getClassLoader,
- * which also means that classOf[...] constructs such as:
- *
- * classOf[scala.reflect.ScalaSignature]
- *
- * in unpickleClass were also loaded by the URLClassLoader
- *
- * But mirror's classLoader used Thread.currentThread.getContextClassLoader,
- * which introduced a subtle bug that made the following snippet incorrectly:
- *
- * jclazz.getAnnotation(classOf[scala.reflect.ScalaSignature])
- *
- * Indeed, jclazz was loaded by context classloader, which defaulted to system classloader,
- * while ScalaSignature class was loaded by getClass.getClassLoader, which was incompatible with system classloader.
- * As a result, unpickler couldn't see the signature and that blew up the mirror.
- */
- var classLoader: ClassLoader
-
- /** Paul: It seems the default class loader does not pick up root classes, whereas the system classloader does.
- * Can you check with your newly acquired classloader fu whether this implementation makes sense?
- */
- def javaClass(path: String): jClass[_] =
- javaClass(path, classLoader)
- def javaClass(path: String, classLoader: JClassLoader): jClass[_] =
- Class.forName(path, true, classLoader)
-
- /** Does `path` correspond to a Java class with that fully qualified name? */
- def isJavaClass(path: String): Boolean =
- try {
- javaClass(path)
- true
- } catch {
- case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
- false
- }
-
- /**
- * Generate types for top-level Scala root class and root companion object
- * from the pickled information stored in a corresponding Java class
- * @param clazz The top-level Scala class for which info is unpickled
- * @param module The top-level Scala companion object for which info is unpickled
- * @param jclazz The Java class which contains the unpickled information in a
- * ScalaSignature or ScalaLongSignature annotation.
- */
- def unpickleClass(clazz: Symbol, module: Symbol, jclazz: jClass[_]): Unit = {
- def markAbsent(tpe: Type) = setAllInfos(clazz, module, tpe)
- def handleError(ex: Exception) = {
- markAbsent(ErrorType)
- if (settings.debug.value) ex.printStackTrace()
- val msg = ex.getMessage()
- MissingRequirementError.signal(
- (if (msg eq null) "reflection error while loading " + clazz.name
- else "error while loading " + clazz.name) + ", " + msg)
- }
- // don't use classOf[scala.reflect.ScalaSignature] here, because it will use getClass.getClassLoader, not mirror's classLoader
- // don't use asInstanceOf either because of the same reason (lol, I cannot believe I fell for it)
- // don't use structural types to simplify reflective invocations because of the same reason
- // todo. test for this
- def loadAnnotation(name: String): java.lang.annotation.Annotation = {
- def inferClasspath(cl: ClassLoader) = cl match {
- case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]"
- case _ => "<unknown>"
- }
- def show(cl: ClassLoader) = cl match {
- case cl if cl != null =>
- "%s of type %s with classpath %s".format(cl, cl.getClass, inferClasspath(cl))
- case null =>
- import scala.tools.util.PathResolver.Environment._
- "primordial classloader with boot classpath [%s]".format(javaBootClassPath)
- }
-
- try {
- val cls_ann = Class.forName(name, true, classLoader)
- val anns = jclazz.getAnnotations
- val ann = anns find (_.annotationType == cls_ann) orNull;
- if (ann == null && anns.find(_.annotationType.getName == name).isDefined) {
- val msg = "Mirror classloader mismatch: %s (loaded by %s)%nis unrelated to the mirror's classloader (%s)"
- throw new Error(msg.format(jclazz, show(jclazz.getClassLoader), show(classLoader)))
- }
- ann
- } catch {
- case ex: ClassNotFoundException =>
- val msg = "Dysfunctional mirror classloader, cannot load %s: %s."
- throw new Error(msg.format(name, show(classLoader)), ex)
- }
- }
- def loadScalaSignature: Option[String] = {
- val ssig = loadAnnotation("scala.reflect.ScalaSignature")
- if (ssig != null) {
- val bytesMethod = ssig.annotationType.getMethod("bytes")
- val result = bytesMethod.invoke(ssig)
- Some(result.asInstanceOf[String])
- } else {
- None
- }
- }
- def loadScalaLongSignature: Option[Array[String]] = {
- val slsig = loadAnnotation("scala.reflect.ScalaLongSignature")
- if (slsig != null) {
- val bytesMethod = slsig.annotationType.getMethod("bytes")
- val result = bytesMethod.invoke(slsig)
- Some(result.asInstanceOf[Array[String]])
- } else {
- None
- }
- }
- try {
- markAbsent(NoType)
- val sigs = (loadScalaSignature, loadScalaLongSignature)
- sigs match {
- case (Some(ssig), _) =>
- info("unpickling Scala "+clazz + " and " + module+ ", owner = " + clazz.owner)
- val bytes = ssig.getBytes
- val len = ByteCodecs.decode(bytes)
- unpickler.unpickle(bytes take len, 0, clazz, module, jclazz.getName)
- case (_, Some(slsig)) =>
- info("unpickling Scala "+clazz + " and " + module + " with long Scala signature")
- val byteSegments = slsig map (_.getBytes)
- val lens = byteSegments map ByteCodecs.decode
- val bytes = Array.ofDim[Byte](lens.sum)
- var len = 0
- for ((bs, l) <- byteSegments zip lens) {
- bs.copyToArray(bytes, len, l)
- len += l
- }
- unpickler.unpickle(bytes, 0, clazz, module, jclazz.getName)
- case (None, None) =>
- // class does not have a Scala signature; it's a Java class
- info("translating reflection info for Java " + jclazz) //debug
- initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz))
- }
- } catch {
- case ex: MissingRequirementError =>
- handleError(ex)
- case ex: IOException =>
- handleError(ex)
- }
- }
-
- /**
- * A fresh Scala type parameter that corresponds to a Java type variable.
- * The association between Scala type parameter and Java type variable is entered in the cache.
- * @param jtvar The Java type variable
- */
- private def createTypeParameter(jtvar: jTypeVariable[_ <: GenericDeclaration]): Symbol = {
- val tparam = sOwner(jtvar).newTypeParameter(newTypeName(jtvar.getName))
- .setInfo(new TypeParamCompleter(jtvar))
- tparamCache enter (jtvar, tparam)
- tparam
- }
-
- /**
- * A completer that fills in the type of a Scala type parameter from the bounds of a Java type variable.
- * @param jtvar The Java type variable
- */
- private class TypeParamCompleter(jtvar: jTypeVariable[_ <: GenericDeclaration]) extends LazyType {
- override def load(sym: Symbol) = complete(sym)
- override def complete(sym: Symbol) = {
- sym setInfo TypeBounds.upper(glb(jtvar.getBounds.toList map typeToScala map objToAny))
- }
- }
-
- /**
- * Copy all annotations of Java annotated element `jann` over to Scala symbol `sym`.
- * Pre: `sym` is already initialized with a concrete type.
- * Note: If `sym` is a method or constructor, its parameter annotations are copied as well.
- */
- private def copyAnnotations(sym: Symbol, jann: AnnotatedElement) {
- // to do: implement
- }
-
- /**
- * A completer that fills in the types of a Scala class and its companion object
- * by copying corresponding type info from a Java class. This completer is used
- * to reflect classes in Scala that do not have a Scala pickle info, be it
- * because they are local classes or have been compiled from Java sources.
- * @param clazz The Scala class for which info is copied
- * @param module The Scala companion object for which info is copied
- * @param jclazz The Java class
- */
- private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType {
- override def load(sym: Symbol) = {
- debugInfo("completing from Java " + sym + "/" + clazz.fullName)//debug
- assert(sym == clazz || (module != NoSymbol && (sym == module || sym == module.moduleClass)), sym)
- val flags = toScalaClassFlags(jclazz.getModifiers)
- clazz setFlag (flags | JAVA)
- if (module != NoSymbol) {
- module setFlag (flags & PRIVATE | JAVA)
- module.moduleClass setFlag (flags & PRIVATE | JAVA)
- }
-
- copyAnnotations(clazz, jclazz)
- // to do: annotations to set also for module?
-
- clazz setInfo new LazyPolyType(jclazz.getTypeParameters.toList map createTypeParameter)
- if (module != NoSymbol) {
- module setInfo module.moduleClass.tpe
- module.moduleClass setInfo new LazyPolyType(List())
- }
- }
-
- override def complete(sym: Symbol): Unit = {
- load(sym)
- completeRest()
- }
- def completeRest(): Unit = self.synchronized {
- val tparams = clazz.rawInfo.typeParams
-
- val parents = try {
- parentsLevel += 1
- val jsuperclazz = jclazz.getGenericSuperclass
- val superclazz = if (jsuperclazz == null) AnyClass.tpe else typeToScala(jsuperclazz)
- superclazz :: (jclazz.getGenericInterfaces.toList map typeToScala)
- } finally {
- parentsLevel -= 1
- }
- clazz setInfo GenPolyType(tparams, new ClassInfoType(parents, newScope, clazz))
- if (module != NoSymbol) {
- module.moduleClass setInfo new ClassInfoType(List(), newScope, module.moduleClass)
- }
-
- def enter(sym: Symbol, mods: Int) =
- (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym
-
- for (jinner <- jclazz.getDeclaredClasses) {
- enter(jclassAsScala(jinner, clazz), jinner.getModifiers)
- }
-
- pendingLoadActions = { () =>
-
- for (jfield <- jclazz.getDeclaredFields)
- enter(jfieldAsScala(jfield), jfield.getModifiers)
-
- for (jmeth <- jclazz.getDeclaredMethods)
- enter(jmethodAsScala(jmeth), jmeth.getModifiers)
-
- for (jconstr <- jclazz.getConstructors)
- enter(jconstrAsScala(jconstr), jconstr.getModifiers)
-
- } :: pendingLoadActions
-
- if (parentsLevel == 0) {
- while (!pendingLoadActions.isEmpty) {
- val item = pendingLoadActions.head
- pendingLoadActions = pendingLoadActions.tail
- item()
- }
- }
- }
- class LazyPolyType(override val typeParams: List[Symbol]) extends LazyType {
- override def complete(sym: Symbol) {
- completeRest()
- }
- }
- }
-
- /** used to avoid cyclies */
- var parentsLevel = 0
- var pendingLoadActions: List[() => Unit] = Nil
-
- /**
- * If Java modifiers `mods` contain STATIC, return the module class
- * of the companion module of `clazz`, otherwise the class `clazz` itself.
- */
- private def followStatic(clazz: Symbol, mods: Int) =
- if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz
-
- /** Methods which need to be wrapped because they either are getSimpleName
- * or call getSimpleName:
- *
- * public String getSimpleName()
- * public boolean isAnonymousClass()
- * public boolean isLocalClass()
- * public boolean isMemberClass()
- * public String getCanonicalName()
- *
- * TODO - find all such calls and wrap them.
- * TODO - create mechanism to avoid the recurrence of unwrapped calls.
- */
- private def wrapClassCheck[T](alt: T)(body: => T): T =
- try body catch { case x: InternalError if x.getMessage == "Malformed class name" => alt }
-
- private def wrapIsLocalClass(clazz: jClass[_]): Boolean =
- wrapClassCheck(false)(clazz.isLocalClass)
-
- private def wrapGetSimpleName(clazz: jClass[_]): String =
- wrapClassCheck("")(clazz.getSimpleName)
-
- /**
- * The Scala owner of the Scala class corresponding to the Java class `jclazz`
- */
- private def sOwner(jclazz: jClass[_]): Symbol = {
- if (jclazz.isMemberClass) {
- val jEnclosingClass = jclazz.getEnclosingClass
- val sEnclosingClass = classToScala(jEnclosingClass)
- followStatic(sEnclosingClass, jclazz.getModifiers)
- } else if (wrapIsLocalClass(jclazz)) {
- val jEnclosingMethod = jclazz.getEnclosingMethod
- if (jEnclosingMethod != null) {
- methodToScala(jEnclosingMethod)
- } else {
- val jEnclosingConstructor = jclazz.getEnclosingConstructor
- constrToScala(jEnclosingConstructor)
- }
- } else if (jclazz.isPrimitive || jclazz.isArray) {
- ScalaPackageClass
- } else if (jclazz.getPackage != null) {
- val jPackage = jclazz.getPackage
- packageToScala(jPackage)
- } else {
- // @eb: a weird classloader might return a null package for something with a non-empty package name
- // for example, http://groups.google.com/group/scala-internals/browse_thread/thread/7be09ff8f67a1e5c
- // in that case we could invoke packageNameToScala(jPackageName) and, probably, be okay
- // however, I think, it's better to blow up, since weirdness of the class loader might bite us elsewhere
- val jPackageName = jclazz.getName.substring(0, Math.max(jclazz.getName.lastIndexOf("."), 0))
- assert(jPackageName == "")
- EmptyPackageClass
- }
- }
-
- /**
- * The Scala owner of the Scala symbol corresponding to the Java member `jmember`
- */
- private def sOwner(jmember: jMember): Symbol = {
- followStatic(classToScala(jmember.getDeclaringClass), jmember.getModifiers)
- }
-
- /**
- * The Scala owner of the Scala type parameter corresponding to the Java type variable `jtvar`
- */
- private def sOwner(jtvar: jTypeVariable[_ <: GenericDeclaration]): Symbol =
- genericDeclarationToScala(jtvar.getGenericDeclaration)
-
- /**
- * Returns `true` if Scala name `name` equals Java name `jstr`, possibly after
- * make-not-private expansion.
- */
- private def approximateMatch(sym: Symbol, jstr: String): Boolean =
- (sym.name.toString == jstr) ||
- sym.isPrivate && nme.expandedName(sym.name.toTermName, sym.owner).toString == jstr
-
- /**
- * Find declarations or definition in class `clazz` that maps to a Java
- * entity with name `jname`. Because of name-mangling, this is more difficult
- * than a simple name-based lookup via `decl`. If `decl` fails, members
- * that start with the given name are searched instead.
- */
- private def lookup(clazz: Symbol, jname: String): Symbol =
- clazz.info.decl(newTermName(jname)) orElse {
- (clazz.info.decls.iterator filter (approximateMatch(_, jname))).toList match {
- case List() => NoSymbol
- case List(sym) => sym
- case alts => clazz.newOverloaded(alts.head.tpe.prefix, alts)
- }
- }
-
- /**
- * The Scala method corresponding to given Java method.
- * @param jmeth The Java method
- * @return A Scala method object that corresponds to `jmeth`.
- */
- def methodToScala(jmeth: jMethod): Symbol = methodCache.toScala(jmeth) {
- val jOwner = jmeth.getDeclaringClass
- var sOwner = classToScala(jOwner)
- sOwner = followStatic(sOwner, jmeth.getModifiers)
- lookup(sOwner, jmeth.getName) suchThat (erasesTo(_, jmeth)) orElse jmethodAsScala(jmeth)
- }
-
- /**
- * The Scala constructor corresponding to given Java constructor.
- * @param jconstr The Java constructor
- * @return A Scala method object that corresponds to `jconstr`.
- */
- def constrToScala(jconstr: jConstructor[_]): Symbol = constructorCache.toScala(jconstr) {
- val owner = followStatic(classToScala(jconstr.getDeclaringClass), jconstr.getModifiers)
- lookup(owner, "<init>") suchThat (erasesTo(_, jconstr)) orElse jconstrAsScala(jconstr)
- }
-
- /**
- * The Scala package corresponding to given Java package
- */
- def packageToScala(jpkg: jPackage): Symbol = packageCache.toScala(jpkg) {
- makeScalaPackage(jpkg.getName)
- }
-
- /**
- * The Scala package with given fully qualified name.
- */
- def packageNameToScala(fullname: String): Symbol = {
- val jpkg = jPackage.getPackage(fullname)
- if (jpkg != null) packageToScala(jpkg) else makeScalaPackage(fullname)
- }
-
- /**
- * The Scala package with given fully qualified name. Unlike `packageNameToScala`,
- * this one bypasses the cache.
- */
- def makeScalaPackage(fullname: String): Symbol = {
- val split = fullname lastIndexOf '.'
- val owner = if (split > 0) packageNameToScala(fullname take split) else RootClass
- assert(owner.isModuleClass, owner+" when making "+fullname)
- val name = newTermName(fullname drop (split + 1))
- var pkg = owner.info decl name
- if (pkg == NoSymbol) {
- pkg = owner.newPackage(name)
- pkg.moduleClass setInfo new LazyPackageType
- pkg setInfoAndEnter pkg.moduleClass.tpe
- info("made Scala "+pkg)
- } else if (!pkg.isPackage)
- throw new ReflectError(pkg+" is not a package")
- pkg.moduleClass
- }
-
- private def scalaSimpleName(jclazz: jClass[_]): TypeName = {
- val owner = sOwner(jclazz)
- val enclosingClass = jclazz.getEnclosingClass
- var prefix = if (enclosingClass != null) enclosingClass.getName else ""
- val isObject = owner.isModuleClass && !owner.isPackageClass
- if (isObject && !prefix.endsWith(nme.MODULE_SUFFIX_STRING)) prefix += nme.MODULE_SUFFIX_STRING
- assert(jclazz.getName.startsWith(prefix))
- var name = jclazz.getName.substring(prefix.length)
- name = name.substring(name.lastIndexOf(".") + 1)
- newTypeName(name)
- }
-
- /**
- * The Scala class that corresponds to a given Java class.
- * @param jclazz The Java class
- * @return A Scala class symbol that reflects all elements of the Java class,
- * in the form they appear in the Scala pickling info, or, if that is
- * not available, wrapped from the Java reflection info.
- */
- def classToScala(jclazz: jClass[_]): Symbol = classCache.toScala(jclazz) {
- val jname = javaTypeName(jclazz)
-
- val sym =
- if (jname == fulltpnme.RuntimeNothing)
- NothingClass
- else if (jname == fulltpnme.RuntimeNull)
- NullClass
- else
- {
- val owner = sOwner(jclazz)
- val simpleName = scalaSimpleName(jclazz)
-
- def lookup = {
- def coreLookup(name: Name): Symbol = {
- val sym = owner.info.decl(name)
- sym orElse {
- if (name.startsWith(nme.NAME_JOIN_STRING))
- coreLookup(name.subName(1, name.length))
- else
- NoSymbol
- }
- }
-
- if (nme.isModuleName(simpleName)) {
- val moduleName = nme.stripModuleSuffix(simpleName).toTermName
- val sym = coreLookup(moduleName)
- if (sym == NoSymbol) sym else sym.moduleClass
- } else {
- coreLookup(simpleName)
- }
- }
-
- val sym = {
- if (jclazz.isMemberClass && !nme.isImplClassName(jname)) {
- lookup
- } else if (wrapIsLocalClass(jclazz) || invalidClassName(jname)) {
- // local classes and implementation classes not preserved by unpickling - treat as Java
- jclassAsScala(jclazz)
- } else if (jclazz.isArray) {
- ArrayClass
- } else javaTypeToValueClass(jclazz) orElse {
- // jclazz is top-level - get signature
- lookup
- // val (clazz, module) = createClassModule(
- // sOwner(jclazz), newTypeName(jclazz.getSimpleName), new TopClassCompleter(_, _))
- // classCache enter (jclazz, clazz)
- // clazz
- }
- }
-
- if (!sym.isType) {
- val classloader = jclazz.getClassLoader
- println("classloader is: %s of type %s".format(classloader, classloader.getClass))
- def inferClasspath(cl: ClassLoader) = cl match {
- case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]"
- case _ => "<unknown>"
- }
- println("classpath is: %s".format(inferClasspath(classloader)))
- def msgNoSym = "no symbol could be loaded from %s (scala equivalent is %s) by name %s".format(owner, jclazz, simpleName)
- def msgIsNotType = "not a type: symbol %s loaded from %s (scala equivalent is %s) by name %s".format(sym, owner, jclazz, simpleName)
- assert(false, if (sym == NoSymbol) msgNoSym else msgIsNotType)
- }
-
- sym
- }
-
- sym.asInstanceOf[ClassSymbol]
- }
-
- /**
- * The Scala type parameter that corresponds to a given Java type parameter.
- * @param jparam The Java type parameter
- * @return A Scala type parameter symbol that has the same owner and name as the Java type parameter
- */
- def tparamToScala(jparam: jTypeVariable[_ <: GenericDeclaration]): Symbol = tparamCache.toScala(jparam) {
- val owner = genericDeclarationToScala(jparam.getGenericDeclaration)
- owner.info match {
- case PolyType(tparams, _) => tparams.find(_.name.toString == jparam.getName).get
- }
- }
-
- /**
- * The Scala symbol that corresponds to a given Java generic declaration (class, method, or constructor)
- */
- def genericDeclarationToScala(jdecl: GenericDeclaration) = jdecl match {
- case jclazz: jClass[_] => classToScala(jclazz)
- case jmeth: jMethod => methodToScala(jmeth)
- case jconstr: jConstructor[_] => constrToScala(jconstr)
- }
-
- /**
- * Given some Java type arguments, a corresponding list of Scala types, plus potentially
- * some existentially bound type variables that represent wildcard arguments.
- */
- private def targsToScala(owner: Symbol, args: List[jType]): (List[Type], List[Symbol]) = {
- val tparams = new ListBuffer[Symbol]
- def targToScala(arg: jType): Type = arg match {
- case jwild: WildcardType =>
- val tparam = owner.newExistential(newTypeName("T$" + tparams.length))
- .setInfo(TypeBounds(
- lub(jwild.getLowerBounds.toList map typeToScala),
- glb(jwild.getUpperBounds.toList map typeToScala map objToAny)))
- tparams += tparam
- typeRef(NoPrefix, tparam, List())
- case _ =>
- typeToScala(arg)
- }
- (args map targToScala, tparams.toList)
- }
-
- /**
- * The Scala type that corresponds to given Java type
- */
- def typeToScala(jtpe: jType): Type = jtpe match {
- case jclazz: jClass[_] =>
- if (jclazz.isArray)
- arrayType(typeToScala(jclazz.getComponentType))
- else {
- val clazz = classToScala(jclazz)
- rawToExistential(typeRef(clazz.owner.thisType, clazz, List()))
- }
- case japplied: ParameterizedType =>
- val (pre, sym) = typeToScala(japplied.getRawType) match {
- case ExistentialType(tparams, TypeRef(pre, sym, _)) => (pre, sym)
- case TypeRef(pre, sym, _) => (pre, sym)
- }
- val args0 = japplied.getActualTypeArguments
- val (args, bounds) = targsToScala(pre.typeSymbol, args0.toList)
- ExistentialType(bounds, typeRef(pre, sym, args))
- case jarr: GenericArrayType =>
- arrayType(typeToScala(jarr.getGenericComponentType))
- case jtvar: jTypeVariable[_] =>
- val tparam = tparamToScala(jtvar)
- typeRef(NoPrefix, tparam, List())
- }
-
- /**
- * The Scala class that corresponds to given Java class without taking
- * Scala pickling info into account.
- * @param jclazz The Java class
- * @return A Scala class symbol that wraps all reflection info of `jclazz`
- */
- private def jclassAsScala(jclazz: jClass[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz))
-
- private def jclassAsScala(jclazz: jClass[_], owner: Symbol): Symbol = {
- val name = scalaSimpleName(jclazz)
- val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz)
- val (clazz, module) = createClassModule(owner, name, completer)
- classCache enter (jclazz, clazz)
- clazz
- }
-
- /**
- * The Scala field that corresponds to given Java field without taking
- * Scala pickling info into account.
- * @param jfield The Java field
- * @return A Scala value symbol that wraps all reflection info of `jfield`
- */
- private def jfieldAsScala(jfield: jField): Symbol = fieldCache.toScala(jfield) {
- val field = (
- sOwner(jfield)
- newValue(newTermName(jfield.getName), NoPosition, toScalaFieldFlags(jfield.getModifiers))
- setInfo typeToScala(jfield.getGenericType)
- )
- fieldCache enter (jfield, field)
- copyAnnotations(field, jfield)
- field
- }
-
- private def setMethType(meth: Symbol, tparams: List[Symbol], paramtpes: List[Type], restpe: Type) = {
- meth setInfo GenPolyType(tparams, MethodType(meth.owner.newSyntheticValueParams(paramtpes map objToAny), restpe))
- }
-
- /**
- * The Scala method that corresponds to given Java method without taking
- * Scala pickling info into account.
- * @param jmeth The Java method
- * @return A Scala method symbol that wraps all reflection info of `jmethod`
- */
- private def jmethodAsScala(jmeth: jMethod): Symbol = methodCache.toScala(jmeth) {
- val clazz = sOwner(jmeth)
- val meth = clazz.newMethod(newTermName(jmeth.getName), NoPosition, toScalaMethodFlags(jmeth.getModifiers))
- methodCache enter (jmeth, meth)
- val tparams = jmeth.getTypeParameters.toList map createTypeParameter
- val paramtpes = jmeth.getGenericParameterTypes.toList map typeToScala
- val resulttpe = typeToScala(jmeth.getGenericReturnType)
- setMethType(meth, tparams, paramtpes, resulttpe)
- copyAnnotations(meth, jmeth)
- if ((jmeth.getModifiers & JAVA_ACC_VARARGS) != 0) {
- meth.setInfo(arrayToRepeated(meth.info))
- }
- meth
- }
-
- /**
- * The Scala constructor that corresponds to given Java constructor without taking
- * Scala pickling info into account.
- * @param jconstr The Java constructor
- * @return A Scala constructor symbol that wraps all reflection info of `jconstr`
- */
- private def jconstrAsScala(jconstr: jConstructor[_]): Symbol = {
- // [Martin] Note: I know there's a lot of duplication wrt jmethodAsScala, but don't think it's worth it to factor this out.
- val clazz = sOwner(jconstr)
- val constr = clazz.newConstructor(NoPosition, toScalaMethodFlags(jconstr.getModifiers))
- constructorCache enter (jconstr, constr)
- val tparams = jconstr.getTypeParameters.toList map createTypeParameter
- val paramtpes = jconstr.getGenericParameterTypes.toList map typeToScala
- setMethType(constr, tparams, paramtpes, clazz.tpe)
- constr setInfo GenPolyType(tparams, MethodType(clazz.newSyntheticValueParams(paramtpes), clazz.tpe))
- copyAnnotations(constr, jconstr)
- constr
- }
-}
-
-class ReflectError(msg: String) extends java.lang.Error(msg)
diff --git a/src/compiler/scala/reflect/runtime/Mirror.scala b/src/compiler/scala/reflect/runtime/Mirror.scala
deleted file mode 100644
index bf4bc83bea..0000000000
--- a/src/compiler/scala/reflect/runtime/Mirror.scala
+++ /dev/null
@@ -1,85 +0,0 @@
-package scala.reflect
-package runtime
-
-import java.lang.reflect.Array
-import ReflectionUtils._
-import scala.tools.nsc.util.ScalaClassLoader._
-
-/** The mirror for standard runtime reflection from Java.
- */
-class Mirror(var classLoader: ClassLoader) extends Universe with api.Mirror {
-
- definitions.init()
- import definitions._
-
- def symbolForName(name: String): Symbol = {
- val clazz = javaClass(name, classLoader)
- classToScala(clazz)
- }
-
- def companionInstance(clazz: Symbol): AnyRef = {
- val singleton = singletonInstance(classLoader, clazz.fullName)
- singleton
- }
-
- def symbolOfInstance(obj: Any): Symbol = classToScala(obj.getClass)
- def typeOfInstance(obj: Any): Type = typeToScala(obj.getClass)
- // to do add getClass/getType for instances of primitive types, probably like this:
- // def getClass[T <: AnyVal : ClassTag](x: T): Symbol = classTag[T].sym
-
- def getValueOfField(receiver: AnyRef, field: Symbol): Any = {
- fieldToJava(field).get(receiver)
- }
- def setValueOfField(receiver: AnyRef, field: Symbol, value: Any): Unit = {
- fieldToJava(field).set(receiver, value)
- }
- def invoke(receiver: AnyRef, meth: Symbol)(args: Any*): Any = {
- if (meth.owner == ArrayClass) {
- meth.name match {
- case nme.length => return Array.getLength(receiver)
- case nme.apply => return Array.get(receiver, args(0).asInstanceOf[Int])
- case nme.update => return Array.set(receiver, args(0).asInstanceOf[Int], args(1))
- }
- }
-
- val jmeth = methodToJava(meth)
- jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*)
- }
-
- private def validateIncomingClassLoader(wannabeCl: ClassLoader) = {
- val ourCls = loaderChain(classLoader)
- if (wannabeCl != null && !(ourCls contains wannabeCl))
- throw new Error("class doesn't belong to the classloader chain of the mirror")
- }
-
- def classToType(jclazz: java.lang.Class[_]): Type = {
- validateIncomingClassLoader(jclazz.getClassLoader)
- typeToScala(jclazz)
- }
-
- def classToSymbol(jclazz: java.lang.Class[_]): Symbol = {
- validateIncomingClassLoader(jclazz.getClassLoader)
- classToScala(jclazz)
- }
-
- def typeToClass(tpe: Type): java.lang.Class[_] =
- typeToJavaClass(tpe)
-
- def symbolToClass(sym: Symbol): java.lang.Class[_] =
- classToJava(sym)
-
- override def inReflexiveMirror = true
-}
-
-/** test code; should go to tests once things settle down a bit
- *
-
-object Test extends Mirror with App {
- val sym = classToScala(classOf[scala.collection.Iterable[_]])
- println(sym)
- println("parents = "+sym.info.parents)
- println("decls = "+(sym.info.decls.toList map (_.defString)))
- val ms = sym.info.members.toList map (_.initialize)
- println("members = "+(ms map (_.defString) mkString ("\n ")))
-}
-*/ \ No newline at end of file
diff --git a/src/compiler/scala/reflect/runtime/ScalaToJava.scala b/src/compiler/scala/reflect/runtime/ScalaToJava.scala
deleted file mode 100644
index 87cdd11652..0000000000
--- a/src/compiler/scala/reflect/runtime/ScalaToJava.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-package scala.reflect
-package runtime
-
-import java.lang.{Class => jClass, Package => jPackage}
-import java.lang.reflect.{
- Method => jMethod, Constructor => jConstructor, Modifier => jModifier, Field => jField,
- Member => jMember, Type => jType, Array => jArray, GenericDeclaration}
-
-trait ScalaToJava extends ConversionUtil { self: SymbolTable =>
-
- import definitions._
-
- /** Optionally, the Java package corresponding to a given Scala package, or None if no such Java package exists.
- * @param pkg The Scala package
- */
- def packageToJava(pkg: Symbol): Option[jPackage] = packageCache.toJavaOption(pkg) {
- Option(jPackage.getPackage(pkg.fullName.toString))
- }
-
- /** The Java class corresponding to given Scala class.
- * Note: This only works for
- * - top-level classes
- * - Scala classes that were generated via jclassToScala
- * - classes that have a class owner that has a corresponding Java class
- * @throws A `ClassNotFoundException` for all Scala classes not in one of these categories.
- */
- @throws(classOf[ClassNotFoundException])
- def classToJava(clazz: Symbol): jClass[_] = classCache.toJava(clazz) {
- def noClass = throw new ClassNotFoundException("no Java class corresponding to "+clazz+" found")
- //println("classToJava "+clazz+" "+clazz.owner+" "+clazz.owner.isPackageClass)//debug
- if (clazz.isPrimitiveValueClass)
- valueClassToJavaType(clazz)
- else if (clazz == ArrayClass)
- noClass
- else if (clazz.owner.isPackageClass)
- javaClass(clazz.javaClassName)
- else if (clazz.owner.isClass)
- classToJava(clazz.owner)
- .getDeclaredClasses
- .find(_.getSimpleName == clazz.name.toString)
- .getOrElse(noClass)
- else
- noClass
- }
-
- private def expandedName(sym: Symbol): String =
- if (sym.isPrivate) nme.expandedName(sym.name.toTermName, sym.owner).toString
- else sym.name.toString
-
- def fieldToJava(fld: Symbol): jField = fieldCache.toJava(fld) {
- val jclazz = classToJava(fld.owner)
- try jclazz getDeclaredField fld.name.toString
- catch {
- case ex: NoSuchFieldException => jclazz getDeclaredField expandedName(fld)
- }
- }
-
- def methodToJava(meth: Symbol): jMethod = methodCache.toJava(meth) {
- val jclazz = classToJava(meth.owner)
- val paramClasses = transformedType(meth).paramTypes map typeToJavaClass
- try jclazz getDeclaredMethod (meth.name.toString, paramClasses: _*)
- catch {
- case ex: NoSuchMethodException =>
- jclazz getDeclaredMethod (expandedName(meth), paramClasses: _*)
- }
- }
-
- def constrToJava(constr: Symbol): jConstructor[_] = constructorCache.toJava(constr) {
- val jclazz = classToJava(constr.owner)
- val paramClasses = transformedType(constr).paramTypes map typeToJavaClass
- jclazz getConstructor (paramClasses: _*)
- }
-
- private def jArrayClass(elemClazz: jClass[_]): jClass[_] = {
- jArray.newInstance(elemClazz, 0).getClass
- }
-
- /** The Java class that corresponds to given Scala type.
- * Pre: Scala type is already transformed to Java level.
- */
- def typeToJavaClass(tpe: Type): jClass[_] = tpe match {
- case ExistentialType(_, rtpe) => typeToJavaClass(rtpe)
- case TypeRef(_, ArrayClass, List(elemtpe)) => jArrayClass(typeToJavaClass(elemtpe))
- case TypeRef(_, sym, _) => classToJava(sym)
- case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found")
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/runtime/Universe.scala b/src/compiler/scala/reflect/runtime/Universe.scala
deleted file mode 100644
index fd53308d0a..0000000000
--- a/src/compiler/scala/reflect/runtime/Universe.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package scala.reflect
-package runtime
-
-import internal.{SomePhase, NoPhase, Phase, TreeGen}
-
-/** The universe for standard runtime reflection from Java.
- * This type implements all abstract term members in internal.SymbolTable.
- * It also provides methods to go from Java members to Scala members,
- * using the code in JavaConversions.
- */
-abstract class Universe extends SymbolTable with ToolBoxes {
-
- type AbstractFileType = AbstractFile
-
- def picklerPhase = SomePhase
-
- type TreeGen = internal.TreeGen
-
- val gen = new TreeGen { val global: Universe.this.type = Universe.this }
-
- lazy val settings = new Settings
- def forInteractive = false
- def forScaladoc = false
-
- val phaseWithId: Array[Phase] = Array(NoPhase, SomePhase)
- val currentRunId = 1 // fake a run id so that it is different from NoRunId
- phase = SomePhase // set to a phase different from NoPhase
-
- def log(msg: => AnyRef): Unit = println(" [] "+msg)
-
- type TreeCopier = TreeCopierOps
- def newStrictTreeCopier: TreeCopier = new StrictTreeCopier
- def newLazyTreeCopier: TreeCopier = new LazyTreeCopier
-
- definitions.AnyValClass // force it.
-
- // establish root association to avoid cyclic dependency errors later
- // don't use classOf[...] here, because it gets serviced by getClass.getClassLoader!
- classToScala(Class.forName("java.lang.Object", true, classLoader)).initialize
-
-// println("initializing definitions")
- definitions.init()
-}
diff --git a/src/compiler/scala/reflect/runtime/package.scala b/src/compiler/scala/reflect/runtime/package.scala
deleted file mode 100644
index 52ab2c5deb..0000000000
--- a/src/compiler/scala/reflect/runtime/package.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package scala.reflect
-
-package object runtime {
- def mkMirror(classLoader: ClassLoader): api.Mirror = new Mirror(classLoader)
-} \ No newline at end of file
diff --git a/src/compiler/scala/tools/ant/FastScalac.scala b/src/compiler/scala/tools/ant/FastScalac.scala
index 19a1526e67..c0d7441ad5 100644
--- a/src/compiler/scala/tools/ant/FastScalac.scala
+++ b/src/compiler/scala/tools/ant/FastScalac.scala
@@ -157,7 +157,7 @@ class FastScalac extends Scalac {
val scalaHome: String = try {
val url = ScalaClassLoader.originOfClass(classOf[FastScalac]).get
- File(url.getFile).jfile.getParentFile.getParentFile getAbsolutePath
+ File(url.getFile).jfile.getParentFile.getParentFile.getAbsolutePath
} catch {
case _ =>
buildError("Compilation failed because of an internal compiler error;"+
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 3c79fcd3fb..a34692f5e0 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -632,7 +632,7 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
case "none" =>
case x =>
val depFilePath = SPath(x)
- command.settings.dependenciesFile.value = SPath(getProject.getBaseDir).normalize resolve depFilePath path
+ command.settings.dependenciesFile.value = SPath(getProject.getBaseDir).normalize.resolve(depFilePath).path
}
(command.settings, sourceFiles, javaOnly)
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 85bb5f2056..256b5088e9 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -9,19 +9,14 @@
##############################################################################
findScalaHome () {
- # see SI-2092
- local SOURCE="${BASH_SOURCE[0]}"
- while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
- local bindir="$( dirname "$SOURCE" )"
- if [[ -d "$bindir"/.. ]]; then
- ( cd -P "$bindir"/.. && pwd )
- else
- # See SI-5792
- local dir=$(dirname "${BASH_SOURCE[0]}")
- local link=$(dirname "$(readlink "${BASH_SOURCE[0]}")")
- local path="$dir/$link/.."
- ( cd "$path" && pwd )
- fi
+ # see SI-2092 and SI-5792
+ local source="${BASH_SOURCE[0]}"
+ while [ -h "$source" ] ; do
+ local linked="$(readlink "$source")"
+ local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )"
+ source="$dir/$(basename "$linked")"
+ done
+ ( cd -P "$(dirname "$source")/.." && pwd )
}
execCommand () {
[[ -n $SCALA_RUNNER_DEBUG ]] && echo "" && for arg in "$@@"; do echo "$arg"; done && echo "";
diff --git a/src/compiler/scala/tools/cmd/CommandLine.scala b/src/compiler/scala/tools/cmd/CommandLine.scala
index ced3a97380..d9a74a698c 100644
--- a/src/compiler/scala/tools/cmd/CommandLine.scala
+++ b/src/compiler/scala/tools/cmd/CommandLine.scala
@@ -7,6 +7,7 @@ package scala.tools
package cmd
import scala.collection.mutable.ListBuffer
+import language.postfixOps
trait CommandLineConfig {
def enforceArity: Boolean = true
diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala
index 91356b3c19..29f1baaa0c 100644
--- a/src/compiler/scala/tools/cmd/FromString.scala
+++ b/src/compiler/scala/tools/cmd/FromString.scala
@@ -7,14 +7,15 @@ package scala.tools
package cmd
import nsc.io.{ Path, File, Directory }
-import scala.reflect.TypeTag
+import scala.reflect.runtime.{universe => ru}
+import scala.tools.reflect.StdTags._
/** A general mechanism for defining how a command line argument
* (always a String) is transformed into an arbitrary type. A few
* example instances are in the companion object, but in general
* either IntFromString will suffice or you'll want custom transformers.
*/
-abstract class FromString[+T](implicit t: TypeTag[T]) extends PartialFunction[String, T] {
+abstract class FromString[+T](implicit t: ru.TypeTag[T]) extends PartialFunction[String, T] {
def apply(s: String): T
def isDefinedAt(s: String): Boolean = true
def zero: T = apply("")
@@ -29,19 +30,19 @@ object FromString {
/** Path related stringifiers.
*/
- val ExistingFile: FromString[File] = new FromString[File] {
+ val ExistingFile: FromString[File] = new FromString[File]()(tagOfFile) {
override def isDefinedAt(s: String) = toFile(s).isFile
def apply(s: String): File =
if (isDefinedAt(s)) toFile(s)
else cmd.runAndExit(println("'%s' is not an existing file." format s))
}
- val ExistingDir: FromString[Directory] = new FromString[Directory] {
+ val ExistingDir: FromString[Directory] = new FromString[Directory]()(tagOfDirectory) {
override def isDefinedAt(s: String) = toDir(s).isDirectory
def apply(s: String): Directory =
if (isDefinedAt(s)) toDir(s)
else cmd.runAndExit(println("'%s' is not an existing directory." format s))
}
- def ExistingDirRelativeTo(root: Directory) = new FromString[Directory] {
+ def ExistingDirRelativeTo(root: Directory) = new FromString[Directory]()(tagOfDirectory) {
private def resolve(s: String) = toDir(s) toAbsoluteWithRoot root toDirectory
override def isDefinedAt(s: String) = resolve(s).isDirectory
def apply(s: String): Directory =
@@ -52,19 +53,19 @@ object FromString {
/** Argument expander, i.e. turns single argument "foo bar baz" into argument
* list "foo", "bar", "baz".
*/
- val ArgumentsFromString: FromString[List[String]] = new FromString[List[String]] {
+ val ArgumentsFromString: FromString[List[String]] = new FromString[List[String]]()(tagOfListOfString) {
def apply(s: String) = toArgs(s)
}
/** Identity.
*/
- implicit val StringFromString: FromString[String] = new FromString[String] {
+ implicit val StringFromString: FromString[String] = new FromString[String]()(tagOfString) {
def apply(s: String): String = s
}
/** Implicit as the most likely to be useful as-is.
*/
- implicit val IntFromString: FromString[Int] = new FromString[Int] {
+ implicit val IntFromString: FromString[Int] = new FromString[Int]()(tagOfInt) {
override def isDefinedAt(s: String) = safeToInt(s).isDefined
def apply(s: String) = safeToInt(s).get
def safeToInt(s: String): Option[Int] = try Some(java.lang.Integer.parseInt(s)) catch { case _: NumberFormatException => None }
diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
index 83cd9c2578..9d0795b2f6 100644
--- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala
+++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
@@ -177,7 +177,7 @@ trait AnyValReps {
case (res, lines) =>
val xs = lines map {
case "" => ""
- case s => interpolate(s) + " = " + stub
+ case s => interpolate(s)
}
res ++ xs
}
@@ -205,7 +205,7 @@ trait AnyValReps {
def classLines: List[String]
def objectLines: List[String]
def commonClassLines = List(
- "override def getClass(): Class[@name@]"
+ "override def getClass(): Class[@name@] = null"
)
def lcname = name.toLowerCase
@@ -248,7 +248,7 @@ trait AnyValReps {
def objectDoc = ""
def mkImports = ""
- def mkClass = assemble("final class " + name + " private extends AnyVal", classLines)
+ def mkClass = assemble("final abstract class " + name + " private extends AnyVal", classLines)
def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines)
def make() = List[String](
headerTemplate,
@@ -281,6 +281,8 @@ trait AnyValTemplates {
%s
package scala
+import language.implicitConversions
+
""".trim.format(timestampString) + "\n\n")
def classDocTemplate = ("""
@@ -294,7 +296,6 @@ package scala
""".trim + "\n")
def timestampString = "// DO NOT EDIT, CHANGES WILL BE LOST.\n"
- def stub = """sys.error("stub")"""
def allCompanions = """
/** Transform a value type into a boxed reference type.
@@ -373,7 +374,7 @@ class AnyVals extends AnyValReps with AnyValTemplates {
*
* @return the negated expression
*/
-def unary_! : Boolean = sys.error("stub")
+def unary_! : Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to the same value.
@@ -382,7 +383,7 @@ def unary_! : Boolean = sys.error("stub")
* - `a` and `b` are `true` or
* - `a` and `b` are `false`.
*/
-def ==(x: Boolean): Boolean = sys.error("stub")
+def ==(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to a different value.
@@ -391,7 +392,7 @@ def ==(x: Boolean): Boolean = sys.error("stub")
* - `a` is `true` and `b` is `false` or
* - `a` is `false` and `b` is `true`.
*/
-def !=(x: Boolean): Boolean = sys.error("stub")
+def !=(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
@@ -405,7 +406,7 @@ def !=(x: Boolean): Boolean = sys.error("stub")
* behaves as if it was declared as `def ||(x: => Boolean): Boolean`.
* If `a` evaluates to `true`, `true` is returned without evaluating `b`.
*/
-def ||(x: Boolean): Boolean = sys.error("stub")
+def ||(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
@@ -417,11 +418,11 @@ def ||(x: Boolean): Boolean = sys.error("stub")
* behaves as if it was declared as `def &&(x: => Boolean): Boolean`.
* If `a` evaluates to `false`, `false` is returned without evaluating `b`.
*/
-def &&(x: Boolean): Boolean = sys.error("stub")
+def &&(x: Boolean): Boolean
// Compiler won't build with these seemingly more accurate signatures
-// def ||(x: => Boolean): Boolean = sys.error("stub")
-// def &&(x: => Boolean): Boolean = sys.error("stub")
+// def ||(x: => Boolean): Boolean
+// def &&(x: => Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
@@ -433,7 +434,7 @@ def &&(x: Boolean): Boolean = sys.error("stub")
*
* @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`.
*/
-def |(x: Boolean): Boolean = sys.error("stub")
+def |(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
@@ -443,7 +444,7 @@ def |(x: Boolean): Boolean = sys.error("stub")
*
* @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`.
*/
-def &(x: Boolean): Boolean = sys.error("stub")
+def &(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to a different value.
@@ -452,9 +453,9 @@ def &(x: Boolean): Boolean = sys.error("stub")
* - `a` is `true` and `b` is `false` or
* - `a` is `false` and `b` is `true`.
*/
-def ^(x: Boolean): Boolean = sys.error("stub")
+def ^(x: Boolean): Boolean
-override def getClass(): Class[Boolean] = sys.error("stub")
+override def getClass(): Class[Boolean] = null
""".trim.lines.toList
def objectLines = interpolate(allCompanions + "\n" + nonUnitCompanions).lines.toList
@@ -468,7 +469,7 @@ override def getClass(): Class[Boolean] = sys.error("stub")
*/
"""
def classLines = List(
- """override def getClass(): Class[Unit] = sys.error("stub")"""
+ """override def getClass(): Class[Unit] = null"""
)
def objectLines = interpolate(allCompanions).lines.toList
diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala
index 1bb820455a..59b58563d1 100644
--- a/src/compiler/scala/tools/cmd/gen/Codegen.scala
+++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala
@@ -6,6 +6,8 @@
package scala.tools.cmd
package gen
+import language.postfixOps
+
class Codegen(args: List[String]) extends {
val parsed = CodegenSpec(args: _*)
} with CodegenSpec with Instance { }
diff --git a/src/compiler/scala/tools/nsc/ClassLoaders.scala b/src/compiler/scala/tools/nsc/ClassLoaders.scala
deleted file mode 100644
index 4058ee9324..0000000000
--- a/src/compiler/scala/tools/nsc/ClassLoaders.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-package scala.tools.nsc
-
-import util.ScalaClassLoader
-
-trait ClassLoaders { self: Global =>
-
- def staticClass(fullname: String) = {
- if (self.forMSIL)
- throw new UnsupportedOperationException("Scala reflection not available on this platform")
-
- getClass(newTypeName(fullname))
- }
-
- def staticModule(fullname: String) = {
- if (self.forMSIL)
- throw new UnsupportedOperationException("Scala reflection not available on this platform")
-
- getModule(newTermName(fullname))
- }
-
- private def getClass(fullname: Name): Symbol = {
- var result = getModuleOrClass(fullname.toTypeName)
- while (result.isAliasType) result = result.info.typeSymbol
- result
- }
-
- private def getModule(fullname: Name): Symbol =
- getModuleOrClass(fullname.toTermName)
-
- private def getModuleOrClass(path: Name): Symbol =
- getModuleOrClass(path, path.length)
-
- private def getModuleOrClass(path: Name, len: Int): Symbol = {
- val point = path lastPos('.', len - 1)
- val owner =
- if (point > 0) getModuleOrClass(path.toTermName, point)
- else definitions.RootClass
- val name = path subName (point + 1, len)
- val sym = owner.info member name
- val result = if (path.isTermName) sym.suchThat(_ hasFlag symtab.Flags.MODULE) else sym
- if (result != NoSymbol) result
- else {
- if (settings.debug.value) { log(sym.info); log(sym.info.members) }//debug
- if (owner.isRoot && isJavaClass(name.toString))
- definitions.EmptyPackageClass.info decl name
- else {
- def info(msg: => String) = if (settings.verbose.value) println(msg)
- info("*** missing: "+name+"/"+name.isTermName+"/"+owner+"/"+owner.hasPackageFlag+"/"+owner.info.decls.getClass)
- MissingRequirementError.notFound((if (path.isTermName) "object " else "class ")+path)
- }
- }
- }
-
- private def isJavaClass(path: String): Boolean =
- try {
- val classpath = platform.classPath.asURLs
- var classLoader = ScalaClassLoader.fromURLs(classpath)
- Class.forName(path, true, classLoader)
- true
- } catch {
- case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
- false
- }
-}
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index 2f1e15168a..54b114bf82 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -5,7 +5,8 @@
package scala.tools.nsc
-import util.{ FreshNameCreator, Position, NoPosition, BatchSourceFile, SourceFile, NoSourceFile }
+import util.FreshNameCreator
+import scala.reflect.internal.util.{ Position, NoPosition, BatchSourceFile, SourceFile, NoSourceFile }
import scala.collection.mutable
import scala.collection.mutable.{ LinkedHashSet, ListBuffer }
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 6393ade146..fd59319c14 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
import java.io.{ BufferedOutputStream, FileOutputStream, PrintStream }
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
-import scala.tools.nsc.util.FakePos //Position
+import scala.reflect.internal.util.FakePos //Position
import scala.tools.util.SocketServer
import settings.FscSettings
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index a4a8e1fd11..7d2abd42fd 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -13,7 +13,7 @@ import java.security.SecureRandom
import io.{ File, Path, Directory, Socket }
import scala.util.control.Exception.catching
import scala.tools.util.CompileOutputCommon
-import scala.tools.util.StringOps.splitWhere
+import scala.reflect.internal.util.StringOps.splitWhere
import scala.sys.process._
trait HasCompileSocket {
diff --git a/src/compiler/scala/tools/nsc/Driver.scala b/src/compiler/scala/tools/nsc/Driver.scala
index 0c52954a0b..0051c3bdec 100644
--- a/src/compiler/scala/tools/nsc/Driver.scala
+++ b/src/compiler/scala/tools/nsc/Driver.scala
@@ -2,7 +2,7 @@ package scala.tools.nsc
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import Properties.{ versionString, copyrightString }
-import scala.tools.nsc.util.{ BatchSourceFile, FakePos }
+import scala.reflect.internal.util.{ BatchSourceFile, FakePos }
abstract class Driver {
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index c917ec9984..787c9c7f57 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -12,7 +12,8 @@ import scala.tools.util.PathResolver
import scala.collection.{ mutable, immutable }
import io.{ SourceReader, AbstractFile, Path }
import reporters.{ Reporter, ConsoleReporter }
-import util.{ NoPosition, Exceptional, ClassPath, SourceFile, NoSourceFile, Statistics, StatisticsInfo, BatchSourceFile, ScriptSourceFile, ScalaClassLoader, returning }
+import util.{ Exceptional, ClassPath, MergedClassPath, Statistics, StatisticsInfo, ScalaClassLoader, returning }
+import scala.reflect.internal.util.{ NoPosition, SourceFile, NoSourceFile, BatchSourceFile, ScriptSourceFile }
import scala.reflect.internal.pickling.{ PickleBuffer, PickleFormat }
import settings.{ AestheticSettings }
import symtab.{ Flags, SymbolTable, SymbolLoaders, SymbolTrackers }
@@ -30,22 +31,44 @@ import backend.opt.{ Inliners, InlineExceptionHandlers, ClosureElimination, Dead
import backend.icode.analysis._
import language.postfixOps
import reflect.internal.StdAttachments
+import scala.reflect.ClassTag
-class Global(var currentSettings: Settings, var reporter: Reporter) extends SymbolTable
- with ClassLoaders
- with ToolBoxes
- with CompilationUnits
- with Plugins
- with PhaseAssembly
- with Trees
- with FreeVars
- with TreePrinters
- with DocComments
- with Positions {
+class Global(var currentSettings: Settings, var reporter: Reporter)
+ extends SymbolTable
+ with CompilationUnits
+ with Plugins
+ with PhaseAssembly
+ with Trees
+ with TreePrinters
+ with DocComments
+ with Positions { self =>
+
+ // [Eugene++] would love to find better homes for the new things dumped into Global
+
+ // the mirror --------------------------------------------------
+
+ override def isCompilerUniverse = true
+
+ class GlobalMirror extends Roots(NoSymbol) {
+ val universe: self.type = self
+ def rootLoader: LazyType = platform.rootLoader
+ override def toString = "compiler mirror"
+ }
+
+ lazy val rootMirror: Mirror = {
+ val rm = new GlobalMirror
+ rm.init()
+ rm.asInstanceOf[Mirror]
+ }
+ def RootClass: ClassSymbol = rootMirror.RootClass
+ def EmptyPackageClass: ClassSymbol = rootMirror.EmptyPackageClass
+ // [Eugene++] this little inconvenience gives us precise types for Expr.mirror and TypeTag.mirror
+ // by the way, is it possible to define variant type members?
override def settings = currentSettings
- import definitions.{ findNamedMember, findMemberFromRoot }
+ import definitions.findNamedMember
+ def findMemberFromRoot(fullName: Name): Symbol = rootMirror.findMemberFromRoot(fullName)
// alternate constructors ------------------------------------------
@@ -72,15 +95,17 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
if (forMSIL) new { val global: Global.this.type = Global.this } with MSILPlatform
else new { val global: Global.this.type = Global.this } with JavaPlatform
- def classPath: ClassPath[platform.BinaryRepr] = platform.classPath
- def rootLoader: LazyType = platform.rootLoader
+ type PlatformClassPath = ClassPath[platform.BinaryRepr]
+ type OptClassPath = Option[PlatformClassPath]
+
+ def classPath: PlatformClassPath = platform.classPath
// sub-components --------------------------------------------------
/** Generate ASTs */
type TreeGen = scala.tools.nsc.ast.TreeGen
- object gen extends {
+ override object gen extends {
val global: Global.this.type = Global.this
} with TreeGen {
def mkAttributedCast(tree: Tree, pt: Type): Tree =
@@ -339,8 +364,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
def checkPhase = wasActive(settings.check)
def logPhase = isActive(settings.log)
- // Write *.icode files the setting was given.
- def writeICode = settings.writeICode.isSetByUser && isActive(settings.writeICode)
+ // Write *.icode files right after GenICode when -Xprint-icode was given.
+ def writeICodeAtICode = settings.writeICode.isSetByUser && isActive(settings.writeICode)
// showing/printing things
def browsePhase = isActive(settings.browse)
@@ -382,6 +407,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
val global: Global.this.type = Global.this
}
+ /** Returns the mirror that loaded given symbol */
+ def mirrorThatLoaded(sym: Symbol): Mirror = rootMirror
+
// ------------ Phases -------------------------------------------}
var globalPhase: Phase = NoPhase
@@ -682,7 +710,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
object icodeChecker extends icodeCheckers.ICodeChecker()
object typer extends analyzer.Typer(
- analyzer.NoContext.make(EmptyTree, Global.this.definitions.RootClass, newScope)
+ analyzer.NoContext.make(EmptyTree, RootClass, newScope)
)
/** Add the internal compiler phases to the phases set.
@@ -840,6 +868,170 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
def printAfterEachPhase[T](op: => T): Unit =
describeAfterEachPhase(op) foreach (m => println(" " + m))
+ // ------------ Invalidations ---------------------------------
+
+ /** Is given package class a system package class that cannot be invalidated?
+ */
+ private def isSystemPackageClass(pkg: Symbol) =
+ // [Eugene++ to Martin] please, verify
+// was: pkg == definitions.RootClass ||
+ pkg == RootClass ||
+ pkg == definitions.ScalaPackageClass || {
+ val pkgname = pkg.fullName
+ (pkgname startsWith "scala.") && !(pkgname startsWith "scala.tools")
+ }
+
+ /** Invalidates packages that contain classes defined in a classpath entry, and
+ * rescans that entry.
+ * @param path A fully qualified name that refers to a directory or jar file that's
+ * an entry on the classpath.
+ * First, causes the classpath entry referred to by `path` to be rescanned, so that
+ * any new files or deleted files or changes in subpackages are picked up.
+ * Second, invalidates any packages for which one of the following considitions is met:
+
+ * - the classpath entry contained during the last compilation run classfiles
+ * that represent a member in the package
+ * - the classpath entry now contains classfiles
+ * that represent a member in the package
+ * - the set of subpackages has changed.
+ *
+ * The invalidated packages are reset in their entirety; all member classes and member packages
+ * are re-accessed using the new classpath.
+ * Not invalidated are system packages that the compiler needs to access as parts
+ * of standard definitions. The criterion what is a system package is currently:
+ * any package rooted in "scala", with the exception of packages rooted in "scala.tools".
+ * This can be refined later.
+ * @return A pair consisting of
+ * - a list of invalidated packages
+ * - a list of of packages that should have been invalidated but were not because
+ * they are system packages.
+ */
+ def invalidateClassPathEntries(paths: String*): (List[ClassSymbol], List[ClassSymbol]) = {
+ val invalidated, failed = new mutable.ListBuffer[ClassSymbol]
+ classPath match {
+ case cp: MergedClassPath[_] =>
+ def assoc(path: String): List[(PlatformClassPath, PlatformClassPath)] = {
+ val dir = AbstractFile getDirectory path
+ val canonical = dir.canonicalPath
+ def matchesCanonical(e: ClassPath[_]) = e.origin match {
+ case Some(opath) =>
+ (AbstractFile getDirectory opath).canonicalPath == canonical
+ case None =>
+ false
+ }
+ cp.entries find matchesCanonical match {
+ case Some(oldEntry) =>
+ List(oldEntry -> cp.context.newClassPath(dir))
+ case None =>
+ println(s"canonical = $canonical, origins = ${cp.entries map (_.origin)}")
+ error(s"cannot invalidate: no entry named $path in classpath $classPath")
+ List()
+ }
+ }
+ val subst = Map(paths flatMap assoc: _*)
+ if (subst.nonEmpty) {
+ platform updateClassPath subst
+ informProgress(s"classpath updated on entries [${subst.keys mkString ","}]")
+ def mkClassPath(elems: Iterable[PlatformClassPath]): PlatformClassPath =
+ if (elems.size == 1) elems.head
+ else new MergedClassPath(elems, classPath.context)
+ val oldEntries = mkClassPath(subst.keys)
+ val newEntries = mkClassPath(subst.values)
+ // [Eugene++ to Martin] please, verify
+// was: reSync(definitions.RootClass, Some(classPath), Some(oldEntries), Some(newEntries), invalidated, failed)
+ reSync(RootClass, Some(classPath), Some(oldEntries), Some(newEntries), invalidated, failed)
+ }
+ }
+ def show(msg: String, syms: collection.Traversable[Symbol]) =
+ if (syms.nonEmpty)
+ informProgress(s"$msg: ${syms map (_.fullName) mkString ","}")
+ show("invalidated packages", invalidated)
+ show("could not invalidate system packages", failed)
+ (invalidated.toList, failed.toList)
+ }
+
+ /** Re-syncs symbol table with classpath
+ * @param root The root symbol to be resynced (a package class)
+ * @param allEntries Optionally, the corresponding package in the complete current classPath
+ * @param oldEntries Optionally, the corresponding package in the old classPath entries
+ * @param newEntries Optionally, the corresponding package in the new classPath entries
+ * @param invalidated A listbuffer collecting the invalidated package classes
+ * @param failed A listbuffer collecting system package classes which could not be invalidated
+ * The resyncing strategy is determined by the absence or presence of classes and packages.
+ * If either oldEntries or newEntries contains classes, root is invalidated, provided a corresponding package
+ * exists in allEntries, or otherwise is removed.
+ * Otherwise, the action is determined by the following matrix, with columns:
+ *
+ * old new all sym action
+ * + + + + recurse into all child packages of old ++ new
+ * + - + + invalidate root
+ * + - - + remove root from its scope
+ * - + + + invalidate root
+ * - + + - create and enter root
+ * - - * * no action
+ *
+ * Here, old, new, all mean classpaths and sym means symboltable. + is presence of an
+ * entry in its column, - is absence, * is don't care.
+ *
+ * Note that new <= all and old <= sym, so the matrix above covers all possibilities.
+ */
+ private def reSync(root: ClassSymbol,
+ allEntries: OptClassPath, oldEntries: OptClassPath, newEntries: OptClassPath,
+ invalidated: mutable.ListBuffer[ClassSymbol], failed: mutable.ListBuffer[ClassSymbol]) {
+ ifDebug(informProgress(s"syncing $root, $oldEntries -> $newEntries"))
+
+ val getName: ClassPath[platform.BinaryRepr] => String = (_.name)
+ def hasClasses(cp: OptClassPath) = cp.isDefined && cp.get.classes.nonEmpty
+ def invalidateOrRemove(root: ClassSymbol) = {
+ allEntries match {
+ case Some(cp) => root setInfo new loaders.PackageLoader(cp)
+ case None => root.owner.info.decls unlink root.sourceModule
+ }
+ invalidated += root
+ }
+ def packageNames(cp: PlatformClassPath): Set[String] = cp.packages.toSet map getName
+ def subPackage(cp: PlatformClassPath, name: String): OptClassPath =
+ cp.packages find (cp1 => getName(cp1) == name)
+
+ val classesFound = hasClasses(oldEntries) || hasClasses(newEntries)
+ if (classesFound && !isSystemPackageClass(root)) {
+ invalidateOrRemove(root)
+ } else {
+ if (classesFound) {
+ // [Eugene++ to Martin] please, verify
+// was: if (root.isRoot) invalidateOrRemove(definitions.EmptyPackageClass)
+ if (root.isRoot) invalidateOrRemove(EmptyPackageClass)
+ else failed += root
+ }
+ (oldEntries, newEntries) match {
+ case (Some(oldcp) , Some(newcp)) =>
+ for (pstr <- packageNames(oldcp) ++ packageNames(newcp)) {
+ val pname = newTermName(pstr)
+ val pkg = (root.info decl pname) orElse {
+ // package was created by external agent, create symbol to track it
+ assert(!subPackage(oldcp, pstr).isDefined)
+ loaders.enterPackage(root, pstr, new loaders.PackageLoader(allEntries.get))
+ }
+ reSync(
+ pkg.moduleClass.asInstanceOf[ClassSymbol],
+ subPackage(allEntries.get, pstr), subPackage(oldcp, pstr), subPackage(newcp, pstr),
+ invalidated, failed)
+ }
+ case (Some(oldcp), None) =>
+ invalidateOrRemove(root)
+ case (None, Some(newcp)) =>
+ invalidateOrRemove(root)
+ case (None, None) =>
+ }
+ }
+ }
+
+ /** Invalidate contents of setting -Yinvalidate */
+ def doInvalidation() = settings.Yinvalidate.value match {
+ case "" =>
+ case entry => invalidateClassPathEntries(entry)
+ }
+
// ----------- Runs ---------------------------------------
private var curRun: Run = null
@@ -859,6 +1051,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
*
* @param sym A class symbol, object symbol, package, or package class.
*/
+ @deprecated("use invalidateClassPathEntries instead")
def clearOnNextRun(sym: Symbol) = false
/* To try out clearOnNext run on the scala.tools.nsc project itself
* replace `false` above with the following code
@@ -870,7 +1063,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
}
}}
- * Then, fsc -Xexperimental clears the nsc porject between successive runs of `fsc`.
+ * Then, fsc -Xexperimental clears the nsc project between successive runs of `fsc`.
*/
/** Remove the current run when not needed anymore. Used by the build
@@ -1115,6 +1308,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
/** Reset all classes contained in current project, as determined by
* the clearOnNextRun hook
*/
+ @deprecated("use invalidateClassPathEntries instead")
def resetProjectClasses(root: Symbol): Unit = try {
def unlink(sym: Symbol) =
if (sym != NoSymbol) root.info.decls.unlink(sym)
@@ -1220,14 +1414,22 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
val mixinPhase = phaseNamed("mixin")
val cleanupPhase = phaseNamed("cleanup")
val icodePhase = phaseNamed("icode")
- // val inlinerPhase = phaseNamed("inliner")
- // val inlineExceptionHandlersPhase = phaseNamed("inlineExceptionHandlers")
- // val closelimPhase = phaseNamed("closelim")
- // val dcePhase = phaseNamed("dce")
+ val inlinerPhase = phaseNamed("inliner")
+ val inlineExceptionHandlersPhase = phaseNamed("inlineExceptionHandlers")
+ val closelimPhase = phaseNamed("closelim")
+ val dcePhase = phaseNamed("dce")
val jvmPhase = phaseNamed("jvm")
+ // val msilPhase = phaseNamed("msil")
def runIsAt(ph: Phase) = globalPhase.id == ph.id
def runIsPast(ph: Phase) = globalPhase.id > ph.id
+ // def runIsAtBytecodeGen = (runIsAt(jvmPhase) || runIsAt(msilPhase))
+ def runIsAtOptimiz = {
+ runIsAt(inlinerPhase) || // listing phases in full for robustness when -Ystop-after has been given.
+ runIsAt(inlineExceptionHandlersPhase) ||
+ runIsAt(closelimPhase) ||
+ runIsAt(dcePhase)
+ }
isDefined = true
@@ -1342,17 +1544,23 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
compileUnits(sources map (new CompilationUnit(_)), firstPhase)
}
- /** Compile list of units, starting with phase `fromPhase`
- */
def compileUnits(units: List[CompilationUnit], fromPhase: Phase) {
try compileUnitsInternal(units, fromPhase)
catch { case ex =>
- globalError(supplementErrorMessage("uncaught exception during compilation: " + ex.getClass.getName))
+ val shown = if (settings.verbose.value) {
+ val pw = new java.io.PrintWriter(new java.io.StringWriter)
+ ex.printStackTrace(pw)
+ pw.toString
+ } else ex.getClass.getName
+ // ex.printStackTrace(Console.out) // DEBUG for fsc, note that error stacktraces do not print in fsc
+ globalError(supplementErrorMessage("uncaught exception during compilation: " + shown))
throw ex
}
}
private def compileUnitsInternal(units: List[CompilationUnit], fromPhase: Phase) {
+ doInvalidation()
+
units foreach addUnit
val startTime = currentTime
@@ -1369,15 +1577,15 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
informTime(globalPhase.description, startTime)
phaseTimings(globalPhase) = currentTime - startTime
- // write icode to *.icode files
- if (opt.writeICode)
+ if (opt.writeICodeAtICode || (opt.printPhase && runIsAtOptimiz)) {
+ // Write *.icode files when -Xprint-icode or -Xprint:<some-optimiz-phase> was given.
writeICode()
-
- // print trees
- if (opt.printPhase || opt.printLate && runIsAt(cleanupPhase)) {
+ } else if (opt.printPhase || opt.printLate && runIsAt(cleanupPhase)) {
+ // print trees
if (opt.showTrees) nodePrinters.printAll()
else printAllUnits()
}
+
// print the symbols presently attached to AST nodes
if (opt.showSymbols)
trackerFactory.snapshot()
@@ -1425,7 +1633,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
// Reset project
if (!stopPhase("namer")) {
atPhase(namerPhase) {
- resetProjectClasses(definitions.RootClass)
+ resetProjectClasses(RootClass)
}
}
}
@@ -1468,20 +1676,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
refreshProgress
}
- /**
- * Attempt to locate a source file providing the given name as a top-level
- * definition in the given context, and add it to the run via compileLate
- * if found.
- */
- def compileSourceFor(context : analyzer.Context, name : Name) = false
-
- /**
- * Attempt to locate a source file providing the given name as a top-level
- * definition with the given prefix, and add it to the run via compileLate
- * if found.
- */
- def compileSourceFor(qual : Tree, name : Name) = false
-
/** Reset package class to state at typer (not sure what this
* is needed for?)
*/
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 4763fab45c..19c872b6d3 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -11,7 +11,7 @@ import File.pathSeparator
import scala.tools.nsc.interactive.{ RefinedBuildManager, SimpleBuildManager }
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
-import scala.tools.nsc.util.{ BatchSourceFile, FakePos } //{Position}
+import scala.reflect.internal.util.{ BatchSourceFile, FakePos } //{Position}
import Properties.{ versionString, copyrightString, residentPromptString, msilLibPath }
/** The main class for NSC, a compiler for the programming
diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala
index aa0ea1bdd8..896fcb3ca1 100644
--- a/src/compiler/scala/tools/nsc/Phases.scala
+++ b/src/compiler/scala/tools/nsc/Phases.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
import symtab.Flags
-import util.TableDef
+import reflect.internal.util.TableDef
import language.postfixOps
object Phases {
diff --git a/src/compiler/scala/tools/nsc/ReflectGlobal.scala b/src/compiler/scala/tools/nsc/ReflectGlobal.scala
index 68a6a4d336..4f4db83339 100644
--- a/src/compiler/scala/tools/nsc/ReflectGlobal.scala
+++ b/src/compiler/scala/tools/nsc/ReflectGlobal.scala
@@ -5,17 +5,33 @@ import reporters.Reporter
/** A version of Global that uses reflection to get class
* infos, instead of reading class or source files.
*/
-class ReflectGlobal(currentSettings: Settings, reporter: Reporter, var classLoader: ClassLoader)
- extends Global(currentSettings, reporter) with reflect.runtime.SymbolTable {
+class ReflectGlobal(currentSettings: Settings, reporter: Reporter, override val rootClassLoader: ClassLoader)
+ extends Global(currentSettings, reporter) with scala.tools.nsc.ReflectSetup with scala.reflect.runtime.SymbolTable {
override def transformedType(sym: Symbol) =
erasure.transformInfo(sym,
uncurry.transformInfo(sym,
refChecks.transformInfo(sym, sym.info)))
- override def staticClass(fullname: String) =
- super[SymbolTable].staticClass(fullname)
+ override def isCompilerUniverse = true
- override def staticModule(fullname: String) =
- super[SymbolTable].staticModule(fullname)
+ // Typically `runtimeMirror` creates a new mirror for every new classloader
+ // and shares symbols between the created mirrors.
+ //
+ // However we can't do that for the compiler.
+ // The problem is that symbol sharing violates owner chain assumptions that the compiler has.
+ //
+ // For example, we can easily end up with a situation when:
+ //
+ // Predef defined in package scala loaded by the classloader that has scala-library.jar
+ //
+ // cannot be accessed in:
+ //
+ // package scala for the rootMirror of ReflectGlobal that might correspond to a different classloader
+ //
+ // This happens because, despite the fact that `Predef` is shared between multiple `scala` packages (i.e. multiple scopes)
+ // (each mirror has its own set package symbols, because of the peculiarities of symbol loading in scala),
+ // that `Predef` symbol only has a single owner, and this messes up visibility, which is calculated based on owners, not scopes.
+ override def runtimeMirror(cl: ClassLoader): Mirror = rootMirror
}
+
diff --git a/src/compiler/scala/tools/nsc/ReflectMain.scala b/src/compiler/scala/tools/nsc/ReflectMain.scala
index f9a18abc25..161391fc2c 100644
--- a/src/compiler/scala/tools/nsc/ReflectMain.scala
+++ b/src/compiler/scala/tools/nsc/ReflectMain.scala
@@ -1,16 +1,15 @@
package scala.tools.nsc
-import util.ScalaClassLoader
import tools.util.PathResolver
import util.ClassPath.DefaultJavaContext
+import util.ScalaClassLoader
object ReflectMain extends Driver {
- private def reflectionClassloaderFromSettings(settings: Settings) = {
+ private def classloaderFromSettings(settings: Settings) = {
val classpath = new PathResolver(settings).result
ScalaClassLoader.fromURLs(classpath.asURLs, getClass.getClassLoader)
}
- override def newCompiler(): Global = new ReflectGlobal(settings, reporter, reflectionClassloaderFromSettings(settings))
-
+ override def newCompiler(): Global = new ReflectGlobal(settings, reporter, classloaderFromSettings(settings))
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ReflectSetup.scala b/src/compiler/scala/tools/nsc/ReflectSetup.scala
new file mode 100644
index 0000000000..26c720a10f
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/ReflectSetup.scala
@@ -0,0 +1,7 @@
+package scala.tools.nsc
+
+/** A helper trait to initialize things that need to be set before JavaMirrors and other
+ * reflect specific traits are initialized */
+private[nsc] trait ReflectSetup { this: Global =>
+ phase = new Run().typerPhase
+} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ScalaDoc.scala b/src/compiler/scala/tools/nsc/ScalaDoc.scala
index 4fa2cc71e5..5a4b4172c6 100644
--- a/src/compiler/scala/tools/nsc/ScalaDoc.scala
+++ b/src/compiler/scala/tools/nsc/ScalaDoc.scala
@@ -9,7 +9,7 @@ package scala.tools.nsc
import java.io.File.pathSeparator
import scala.tools.nsc.doc.DocFactory
import scala.tools.nsc.reporters.ConsoleReporter
-import scala.tools.nsc.util.FakePos
+import scala.reflect.internal.util.FakePos
import Properties.msilLibPath
/** The main class for scaladoc, a front-end for the Scala compiler
diff --git a/src/compiler/scala/tools/nsc/ToolBoxes.scala b/src/compiler/scala/tools/nsc/ToolBoxes.scala
deleted file mode 100644
index f5eefa4e62..0000000000
--- a/src/compiler/scala/tools/nsc/ToolBoxes.scala
+++ /dev/null
@@ -1,84 +0,0 @@
-package scala.tools.nsc
-
-import util.ScalaClassLoader
-
-trait ToolBoxes { self: Global =>
-
- def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = "") = new ToolBox(frontEnd, options)
-
- class ToolBox(val frontEnd: FrontEnd, val options: String) extends AbsToolBox {
- def typeCheck(tree0: Tree, pt: Type = WildcardType, freeTypes: Map[FreeType, Type] = Map[FreeType, Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
- val tree = substituteFreeTypes(tree0, freeTypes)
- val currentTyper = typer
- val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _)
- val wrapper2 = if (!withMacrosDisabled) (currentTyper.context.withMacrosEnabled[Tree] _) else (currentTyper.context.withMacrosDisabled[Tree] _)
- def wrapper (tree: => Tree) = wrapper1(wrapper2(tree))
- wrapper(currentTyper.silent(_.typed(tree, analyzer.EXPRmode, pt)) match {
- case analyzer.SilentResultValue(result) =>
- result
- case error @ analyzer.SilentTypeError(_) =>
- if (!silent) throw new ToolBoxError(this, "reflective typecheck has failed: %s".format(error.err.errMsg))
- EmptyTree
- })
- }
-
- def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): Tree =
- // todo. implement this
- ???
-
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): Tree =
- // todo. implement this
- ???
-
- def resetAllAttrs(tree: Tree): Tree =
- self.resetAllAttrs(tree)
-
- def resetLocalAttrs(tree: Tree): Tree =
- self.resetLocalAttrs(tree)
-
- def runExpr(tree0: Tree, freeTypes: Map[FreeType, Type] = Map[FreeType, Type]()): Any = {
- var tree = substituteFreeTypes(tree0, freeTypes)
- // need to reset the tree, otherwise toolbox will refuse to work with it
- // upd. this has to be done by the user himself, otherwise we run into troubles. see SI-5713
-// tree = resetAllAttrs(tree0.duplicate)
- val imported = importer.importTree(tree)
- val toolBox = libraryClasspathMirror.mkToolBox(frontEnd.asInstanceOf[libraryClasspathMirror.FrontEnd], options)
- try toolBox.runExpr(imported)
- catch {
- case ex: toolBox.ToolBoxError =>
- throw new ToolBoxError(this, ex.message, ex.cause)
- }
- }
-
- // [Eugene] how do I make this work without casts?
- // private lazy val importer = libraryClasspathMirror.mkImporter(self)
- private lazy val importer = libraryClasspathMirror.mkImporter(self).asInstanceOf[libraryClasspathMirror.Importer { val from: self.type }]
-
- private lazy val libraryClasspathMirror = {
- if (self.forMSIL)
- throw new UnsupportedOperationException("Scala reflection not available on this platform")
-
- val libraryClassLoader = {
- val classpath = self.classPath.asURLs
- var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
-
- // [Eugene] a heuristic to detect REPL
- if (self.settings.exposeEmptyPackage.value) {
- import scala.tools.nsc.interpreter._
- val virtualDirectory = self.settings.outputDirs.getSingleOutput.get
- loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
- }
-
- loader
- }
-
- new scala.reflect.runtime.Mirror(libraryClassLoader)
- }
-
- class ToolBoxError(val toolBox: ToolBox, val message: String, val cause: Throwable = null) extends Throwable(message, cause)
-
- object ToolBoxError extends ToolBoxErrorExtractor {
- def unapply(error: ToolBoxError): Option[(ToolBox, String)] = Some((error.toolBox, error.message))
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index 028c5741c9..316faba6e2 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -8,7 +8,7 @@ package ast
import symtab._
import reporters._
-import util.{Position, NoPosition}
+import scala.reflect.internal.util.{Position, NoPosition}
import util.DocStrings._
import scala.reflect.internal.Chars._
import scala.collection.mutable
@@ -458,7 +458,7 @@ trait DocComments { self: Global =>
case site :: sites1 => select(site.thisType, name, findIn(sites1))
}
val (classes, pkgs) = site.ownerChain.span(!_.isPackageClass)
- findIn(classes ::: List(pkgs.head, definitions.RootClass))
+ findIn(classes ::: List(pkgs.head, rootMirror.RootClass))
}
def getType(_str: String, variable: String): Type = {
@@ -508,7 +508,7 @@ trait DocComments { self: Global =>
val tpe = getType(repl.trim, alias.name.toString)
if (tpe != NoType) tpe
else {
- val alias1 = alias.cloneSymbol(definitions.RootClass, alias.rawflags, newTypeName(repl))
+ val alias1 = alias.cloneSymbol(rootMirror.RootClass, alias.rawflags, newTypeName(repl))
typeRef(NoPrefix, alias1, Nil)
}
case None =>
diff --git a/src/compiler/scala/tools/nsc/ast/FreeVars.scala b/src/compiler/scala/tools/nsc/ast/FreeVars.scala
deleted file mode 100644
index a1983d1834..0000000000
--- a/src/compiler/scala/tools/nsc/ast/FreeVars.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-package scala.tools.nsc
-package ast
-
-trait FreeVars extends reflect.internal.FreeVars { self: Global =>
-
- import self._
- import definitions._
- import treeInfo._
-
- def logFreeVars(position: Position, reified: Tree): Unit = {
- if (settings.logFreeTerms.value || settings.logFreeTypes.value) {
- reified match {
- case Reified(_, symbolTable, _) =>
- // logging free vars only when they are untyped prevents avalanches of duplicate messages
- symbolTable foreach {
- case FreeTermDef(_, _, binding, _, origin) if settings.logFreeTerms.value && binding.tpe == null =>
- reporter.echo(position, "free term: %s %s".format(showRaw(binding), origin))
- case FreeTypeDef(_, _, binding, _, origin) if settings.logFreeTypes.value && binding.tpe == null =>
- reporter.echo(position, "free type: %s %s".format(showRaw(binding), origin))
- case _ =>
- // do nothing
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
index ce3106ab29..ba1f3b2e3c 100644
--- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
@@ -145,6 +145,8 @@ abstract class NodePrinters {
str.toString
}
def printModifiers(tree: MemberDef) {
+ // [Eugene++] there's most likely a bug here (?)
+ // see `TreePrinters.printAnnotations` for more information
val annots0 = tree.symbol.annotations match {
case Nil => tree.mods.annotations
case xs => xs map annotationInfoToString
@@ -167,7 +169,7 @@ abstract class NodePrinters {
}
}
- def treePrefix(tree: Tree) = showPosition(tree) + tree.printingPrefix
+ def treePrefix(tree: Tree) = showPosition(tree) + tree.productPrefix
def printMultiline(tree: Tree)(body: => Unit) {
printMultiline(treePrefix(tree), showAttributes(tree))(body)
}
diff --git a/src/compiler/scala/tools/nsc/ast/Positions.scala b/src/compiler/scala/tools/nsc/ast/Positions.scala
index 83a67cfbe3..74d1f8ab4b 100644
--- a/src/compiler/scala/tools/nsc/ast/Positions.scala
+++ b/src/compiler/scala/tools/nsc/ast/Positions.scala
@@ -1,7 +1,7 @@
package scala.tools.nsc
package ast
-import scala.tools.nsc.util.{ SourceFile, Position, OffsetPosition, NoPosition }
+import scala.reflect.internal.util.{ SourceFile, Position, OffsetPosition, NoPosition }
trait Positions extends scala.reflect.internal.Positions {
self: Global =>
@@ -14,7 +14,7 @@ trait Positions extends scala.reflect.internal.Positions {
// [Eugene] disabling this for now. imo it doesn't justify pollution of the public API
// override def _checkSetAnnotation(tree: Tree, annot: TreeAnnotation): Unit = {
// if (tree.pos != NoPosition && tree.pos != annot.pos) debugwarn("Overwriting annotation "+ tree.annotation +" of tree "+ tree +" with annotation "+ annot)
- // // if ((tree.annotation.isInstanceOf[scala.tools.nsc.util.Position] || !annot.isInstanceOf[scala.tools.nsc.util.Position]) && tree.isInstanceOf[Block])
+ // // if ((tree.annotation.isInstanceOf[scala.reflect.internal.util.Position] || !annot.isInstanceOf[scala.reflect.internal.util.Position]) && tree.isInstanceOf[Block])
// // println("Updating block from "+ tree.annotation +" to "+ annot)
// }
diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
index b4beb231ab..f88e41375d 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
@@ -354,7 +354,7 @@ abstract class TreeBrowsers {
*/
object TreeInfo {
/** Return the case class name and the Name, if the node defines one */
- def treeName(t: Tree): (String, Name) = ((t.printingPrefix, t match {
+ def treeName(t: Tree): (String, Name) = ((t.productPrefix, t match {
case UnitTree(unit) => newTermName("" + unit)
case Super(_, mix) => newTermName("mix: " + mix)
case This(qual) => qual
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 6f1a8f488f..1d29e33c50 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -116,7 +116,10 @@ trait Trees extends reflect.internal.Trees { self: Global =>
if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit)
vparamss1 = List() :: vparamss1;
val superRef: Tree = atPos(superPos)(gen.mkSuperSelect)
- val superCall = (superRef /: argss) (Apply)
+ def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
+ val superCall = (superRef /: argss) (mkApply)
+ // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
+ // val superCall = (superRef /: argss) (Apply)
List(
atPos(wrappingPos(superPos, lvdefs ::: argss.flatten)) (
DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant())))))
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
index f702f44338..12b39d9e9c 100755
--- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
@@ -9,7 +9,8 @@ package ast.parser
import scala.collection.mutable
import mutable.{ Buffer, ArrayBuffer, ListBuffer }
import scala.util.control.ControlThrowable
-import scala.tools.nsc.util.{SourceFile,CharArrayReader}
+import scala.tools.nsc.util.CharArrayReader
+import scala.reflect.internal.util.SourceFile
import scala.xml.{ Text, TextBuffer }
import scala.xml.parsing.MarkupParserCommon
import scala.xml.Utility.{ isNameStart, isNameChar, isSpace }
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index a0524d6932..fd154fe796 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -10,10 +10,11 @@ package scala.tools.nsc
package ast.parser
import scala.collection.mutable.{ListBuffer, StringBuilder}
-import util.{ SourceFile, OffsetPosition, FreshNameCreator }
import scala.reflect.internal.{ ModifierFlags => Flags }
-import Tokens._
import scala.reflect.internal.Chars.{ isScalaLetter }
+import scala.reflect.internal.util.{ SourceFile, OffsetPosition }
+import Tokens._
+import util.FreshNameCreator
/** Historical note: JavaParsers started life as a direct copy of Parsers
* but at a time when that Parsers had been replaced by a different one.
@@ -162,9 +163,9 @@ self =>
def incompleteInputError(msg: String): Unit = throw new MalformedInput(source.content.length - 1, msg)
/** the markup parser */
- lazy val xmlp = new MarkupParser(this, true)
+ lazy val xmlp = new MarkupParser(this, preserveWS = true)
- object symbXMLBuilder extends SymbolicXMLBuilder(this, true) { // DEBUG choices
+ object symbXMLBuilder extends SymbolicXMLBuilder(this, preserveWS = true) { // DEBUG choices
val global: self.global.type = self.global
def freshName(prefix: String): Name = SourceFileParser.this.freshName(prefix)
}
@@ -735,9 +736,9 @@ self =>
}
ts.toList
}
- @inline final def commaSeparated[T](part: => T): List[T] = tokenSeparated(COMMA, false, part)
- @inline final def caseSeparated[T](part: => T): List[T] = tokenSeparated(CASE, true, part)
- @inline final def readAnnots[T](part: => T): List[T] = tokenSeparated(AT, true, part)
+ @inline final def commaSeparated[T](part: => T): List[T] = tokenSeparated(COMMA, sepFirst = false, part)
+ @inline final def caseSeparated[T](part: => T): List[T] = tokenSeparated(CASE, sepFirst = true, part)
+ @inline final def readAnnots[T](part: => T): List[T] = tokenSeparated(AT, sepFirst = true, part)
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
@@ -776,8 +777,7 @@ self =>
syntaxError(
offset, "left- and right-associative operators with same precedence may not be mixed", false)
- def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree,
- prec: Int, leftAssoc: Boolean): Tree = {
+ def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree, prec: Int, leftAssoc: Boolean): Tree = {
var top = top0
if (opstack != base && precedence(opstack.head.operator) == prec)
checkAssoc(opstack.head.offset, opstack.head.operator, leftAssoc)
@@ -825,7 +825,7 @@ self =>
atPos(start, in.skipToken()) { makeFunctionTypeTree(ts, typ()) }
else {
ts foreach checkNotByNameOrVarargs
- val tuple = atPos(start) { makeTupleType(ts, true) }
+ val tuple = atPos(start) { makeTupleType(ts, flattenUnary = true) }
infixTypeRest(
compoundTypeRest(
annotTypeRest(
@@ -887,10 +887,10 @@ self =>
def simpleType(): Tree = {
val start = in.offset
simpleTypeRest(in.token match {
- case LPAREN => atPos(start)(makeTupleType(inParens(types()), true))
+ case LPAREN => atPos(start)(makeTupleType(inParens(types()), flattenUnary = true))
case USCORE => wildcardType(in.skipToken())
case _ =>
- path(false, true) match {
+ path(thisOK = false, typeOK = true) match {
case r @ SingletonTypeTree(_) => r
case r => convertToTypeId(r)
}
@@ -900,7 +900,7 @@ self =>
private def typeProjection(t: Tree): Tree = {
val hashOffset = in.skipToken()
val nameOffset = in.offset
- val name = identForType(false)
+ val name = identForType(skipIt = false)
val point = if (name == tpnme.ERROR) hashOffset else nameOffset
atPos(t.pos.startOrPoint, point)(SelectFromTypeTree(t, name))
}
@@ -949,7 +949,7 @@ self =>
if (isIdent && in.name != nme.STAR) {
val opOffset = in.offset
val leftAssoc = treeInfo.isLeftAssoc(in.name)
- if (mode != InfixMode.FirstOp) checkAssoc(opOffset, in.name, mode == InfixMode.LeftOp)
+ if (mode != InfixMode.FirstOp) checkAssoc(opOffset, in.name, leftAssoc = mode == InfixMode.LeftOp)
val op = identForType()
val tycon = atPos(opOffset) { Ident(op) }
newLineOptWhenFollowing(isTypeIntroToken)
@@ -986,7 +986,7 @@ self =>
syntaxErrorOrIncomplete(expectedMsg(IDENTIFIER), skipIt)
nme.ERROR
}
- def ident(): Name = ident(true)
+ def ident(): Name = ident(skipIt = true)
def rawIdent(): Name = try in.name finally in.nextToken()
/** For when it's known already to be a type name. */
@@ -997,7 +997,7 @@ self =>
val point = in.offset
//assert(t.pos.isDefined, t)
if (t != EmptyTree)
- Select(t, ident(false)) setPos r2p(t.pos.startOrPoint, point, in.lastOffset)
+ Select(t, ident(skipIt = false)) setPos r2p(t.pos.startOrPoint, point, in.lastOffset)
else
errorTermTree // has already been reported
}
@@ -1027,7 +1027,7 @@ self =>
val tok = in.token
val name = ident()
t = atPos(start) {
- if (tok == BACKQUOTED_IDENT) Ident(name) withAttachment BackquotedIdentifier
+ if (tok == BACKQUOTED_IDENT) Ident(name) addAttachment BackquotedIdentifierAttachment
else Ident(name)
}
if (in.token == DOT) {
@@ -1055,7 +1055,8 @@ self =>
if (typeOK && in.token == TYPE) {
in.nextToken()
atPos(t.pos.startOrPoint, dotOffset) { SingletonTypeTree(t) }
- } else {
+ }
+ else {
val t1 = selector(t)
if (in.token == DOT) { selectors(t1, typeOK, in.skipToken()) }
else t1
@@ -1076,7 +1077,7 @@ self =>
* }}}
*/
def stableId(): Tree =
- path(false, false)
+ path(thisOK = false, typeOK = false)
/** {{{
* QualId ::= Id {`.' Id}
@@ -1085,7 +1086,7 @@ self =>
def qualId(): Tree = {
val start = in.offset
val id = atPos(start) { Ident(ident()) }
- if (in.token == DOT) { selectors(id, false, in.skipToken()) }
+ if (in.token == DOT) { selectors(id, typeOK = false, in.skipToken()) }
else id
}
/** Calls `qualId()` and manages some package state. */
@@ -1118,7 +1119,7 @@ self =>
if (in.token == SYMBOLLIT)
Apply(scalaDot(nme.Symbol), List(finish(in.strVal)))
else if (in.token == INTERPOLATIONID)
- interpolatedString(inPattern)
+ interpolatedString(inPattern = inPattern)
else finish(in.token match {
case CHARLIT => in.charVal
case INTLIT => in.intVal(isNegated).toInt
@@ -1206,7 +1207,7 @@ self =>
else startInfixType()
def annotTypeRest(t: Tree): Tree =
- (t /: annotations(false)) (makeAnnotated)
+ (t /: annotations(skipNewLines = false)) (makeAnnotated)
/** {{{
* WildcardType ::= `_' TypeBounds
@@ -1385,7 +1386,7 @@ self =>
syntaxErrorOrIncomplete("`*' expected", true)
}
} else if (in.token == AT) {
- t = (t /: annotations(false)) (makeAnnotated)
+ t = (t /: annotations(skipNewLines = false)) (makeAnnotated)
} else {
t = atPos(t.pos.startOrPoint, colonPos) {
val tpt = typeOrInfixType(location)
@@ -1451,7 +1452,7 @@ self =>
var top = prefixExpr()
while (isIdent) {
- top = reduceStack(true, base, top, precedence(in.name), treeInfo.isLeftAssoc(in.name))
+ top = reduceStack(isExpr = true, base, top, precedence(in.name), leftAssoc = treeInfo.isLeftAssoc(in.name))
val op = in.name
opstack = OpInfo(top, op, in.offset) :: opstack
ident()
@@ -1459,19 +1460,19 @@ self =>
if (isExprIntro) {
val next = prefixExpr()
if (next == EmptyTree)
- return reduceStack(true, base, top, 0, true)
+ return reduceStack(isExpr = true, base, top, 0, leftAssoc = true)
top = next
} else {
// postfix expression
val topinfo = opstack.head
opstack = opstack.tail
- val od = stripParens(reduceStack(true, base, topinfo.operand, 0, true))
+ val od = stripParens(reduceStack(isExpr = true, base, topinfo.operand, 0, leftAssoc = true))
return atPos(od.pos.startOrPoint, topinfo.offset) {
new PostfixSelect(od, topinfo.operator.encode)
}
}
}
- reduceStack(true, base, top, 0, true)
+ reduceStack(isExpr = true, base, top, 0, leftAssoc = true)
}
/** {{{
@@ -1482,9 +1483,10 @@ self =>
if (isUnaryOp) {
atPos(in.offset) {
val name = nme.toUnaryName(rawIdent())
- // val name = nme.toUnaryName(ident()) // val name: Name = "unary_" + ident()
- if (name == nme.UNARY_- && isNumericLit) simpleExprRest(atPos(in.offset)(literal(isNegated = true)), true)
- else Select(stripParens(simpleExpr()), name)
+ if (name == nme.UNARY_- && isNumericLit)
+ simpleExprRest(atPos(in.offset)(literal(isNegated = true)), canApply = true)
+ else
+ Select(stripParens(simpleExpr()), name)
}
}
else simpleExpr()
@@ -1512,7 +1514,7 @@ self =>
case XMLSTART =>
xmlLiteral()
case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER =>
- path(true, false)
+ path(thisOK = true, typeOK = false)
case USCORE =>
val start = in.offset
val pname = freshName("x$")
@@ -1531,14 +1533,14 @@ self =>
val nstart = in.skipToken()
val npos = r2p(nstart, nstart, in.lastOffset)
val tstart = in.offset
- val (parents, argss, self, stats) = template(false)
+ val (parents, argss, self, stats) = template(isTrait = false)
val cpos = r2p(tstart, tstart, in.lastOffset max tstart)
makeNew(parents, self, stats, argss, npos, cpos)
case _ =>
syntaxErrorOrIncomplete("illegal start of simple expression", true)
errorTermTree
}
- simpleExprRest(t, canApply)
+ simpleExprRest(t, canApply = canApply)
}
def simpleExprRest(t: Tree, canApply: Boolean): Tree = {
@@ -1546,7 +1548,7 @@ self =>
in.token match {
case DOT =>
in.nextToken()
- simpleExprRest(selector(stripParens(t)), true)
+ simpleExprRest(selector(stripParens(t)), canApply = true)
case LBRACKET =>
val t1 = stripParens(t)
t1 match {
@@ -1555,7 +1557,7 @@ self =>
while (in.token == LBRACKET)
app = atPos(app.pos.startOrPoint, in.offset)(TypeApply(app, exprTypeArgs()))
- simpleExprRest(app, true)
+ simpleExprRest(app, canApply = true)
case _ =>
t1
}
@@ -1571,7 +1573,7 @@ self =>
}
Apply(sel, argumentExprs())
}
- simpleExprRest(app, true)
+ simpleExprRest(app, canApply = true)
case USCORE =>
atPos(t.pos.startOrPoint, in.skipToken()) {
Typed(stripParens(t), Function(Nil, EmptyTree))
@@ -1659,11 +1661,11 @@ self =>
*/
def enumerators(): List[Enumerator] = {
val enums = new ListBuffer[Enumerator]
- generator(enums, false)
+ generator(enums, eqOK = false)
while (isStatSep) {
in.nextToken()
if (in.token == IF) enums += makeFilter(in.offset, guard())
- else generator(enums, true)
+ else generator(enums, eqOK = true)
}
enums.toList
}
@@ -1827,13 +1829,13 @@ self =>
}
val base = opstack
while (isIdent && in.name != raw.BAR) {
- top = reduceStack(false, base, top, precedence(in.name), treeInfo.isLeftAssoc(in.name))
+ top = reduceStack(isExpr = false, base, top, precedence(in.name), leftAssoc = treeInfo.isLeftAssoc(in.name))
val op = in.name
opstack = OpInfo(top, op, in.offset) :: opstack
ident()
top = simplePattern(badPattern3)
}
- stripParens(reduceStack(false, base, top, 0, true))
+ stripParens(reduceStack(isExpr = false, base, top, 0, leftAssoc = true))
}
def badPattern3(): Tree = {
def isComma = in.token == COMMA
@@ -2096,7 +2098,7 @@ self =>
var caseParam = ofCaseClass
def param(): ValDef = {
val start = in.offset
- val annots = annotations(false)
+ val annots = annotations(skipNewLines = false)
var mods = Modifiers(Flags.PARAM)
if (owner.isTypeName) {
mods = modifiers() | Flags.PARAMACCESSOR
@@ -2244,7 +2246,7 @@ self =>
param
}
newLineOptWhenFollowedBy(LBRACKET)
- if (in.token == LBRACKET) inBrackets(commaSeparated(typeParam(NoMods withAnnotations annotations(true))))
+ if (in.token == LBRACKET) inBrackets(commaSeparated(typeParam(NoMods withAnnotations annotations(skipNewLines = true))))
else Nil
}
@@ -2401,7 +2403,7 @@ self =>
private def caseAwareTokenOffset = if (in.token == CASECLASS || in.token == CASEOBJECT) in.prev.offset else in.offset
def nonLocalDefOrDcl : List[Tree] = {
- val annots = annotations(true)
+ val annots = annotations(skipNewLines = true)
defOrDcl(caseAwareTokenOffset, modifiers() withAnnotations annots)
}
@@ -2495,7 +2497,7 @@ self =>
in.nextToken
if (in.token == THIS) {
atPos(start, in.skipToken()) {
- val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), false)
+ val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
val rhs = in.token match {
case LBRACE => atPos(in.offset) { constrBlock(vparamss) }
@@ -2519,7 +2521,7 @@ self =>
// i.e. (B[T] or T => B)
val contextBoundBuf = new ListBuffer[Tree]
val tparams = typeParamClauseOpt(name, contextBoundBuf)
- val vparamss = paramClauses(name, contextBoundBuf.toList, false)
+ val vparamss = paramClauses(name, contextBoundBuf.toList, ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
var restype = fromWithinReturnType(typedOpt())
val rhs =
@@ -2533,8 +2535,7 @@ self =>
} else {
if (in.token == EQUALS) {
in.nextTokenAllow(nme.MACROkw)
- if (settings.Xmacros.value && in.token == MACRO || // [Martin] Xmacros can be retired now
- in.token == IDENTIFIER && in.name == nme.MACROkw) {
+ if (in.token == IDENTIFIER && in.name == nme.MACROkw) {
in.nextToken()
newmods |= Flags.MACRO
}
@@ -2618,7 +2619,7 @@ self =>
/** Hook for IDE, for top-level classes/objects. */
def topLevelTmplDef: Tree = {
- val annots = annotations(true)
+ val annots = annotations(skipNewLines = true)
val pos = caseAwareTokenOffset
val mods = modifiers() withAnnotations annots
tmplDef(pos, mods)
@@ -2672,7 +2673,7 @@ self =>
val constrAnnots = constructorAnnotations()
val (constrMods, vparamss) =
if (mods.isTrait) (Modifiers(Flags.TRAIT), List())
- else (accessModifierOpt(), paramClauses(name, classContextBounds, mods.isCase))
+ else (accessModifierOpt(), paramClauses(name, classContextBounds, ofCaseClass = mods.isCase))
var mods1 = mods
if (mods.isTrait) {
if (settings.YvirtClasses && in.token == SUBTYPE) mods1 |= Flags.DEFERRED
@@ -2739,7 +2740,7 @@ self =>
newLineOptWhenFollowedBy(LBRACE)
if (in.token == LBRACE) {
// @S: pre template body cannot stub like post body can!
- val (self, body) = templateBody(true)
+ val (self, body) = templateBody(isPre = true)
if (in.token == WITH && self.isEmpty) {
val earlyDefs: List[Tree] = body flatMap {
case vdef @ ValDef(mods, _, _, _) if !mods.isDeferred =>
@@ -2752,15 +2753,15 @@ self =>
case _ => List()
}
in.nextToken()
- val (parents, argss) = templateParents(isTrait)
- val (self1, body1) = templateBodyOpt(isTrait)
+ val (parents, argss) = templateParents(isTrait = isTrait)
+ val (self1, body1) = templateBodyOpt(traitParentSeen = isTrait)
(parents, argss, self1, earlyDefs ::: body1)
} else {
(List(), List(List()), self, body)
}
} else {
- val (parents, argss) = templateParents(isTrait)
- val (self, body) = templateBodyOpt(isTrait)
+ val (parents, argss) = templateParents(isTrait = isTrait)
+ val (self, body) = templateBodyOpt(traitParentSeen = isTrait)
(parents, argss, self, body)
}
}
@@ -2778,11 +2779,11 @@ self =>
val (parents0, argss, self, body) = (
if (in.token == EXTENDS || in.token == SUBTYPE && mods.isTrait) {
in.nextToken()
- template(mods.isTrait)
+ template(isTrait = mods.isTrait)
}
else {
newLineOptWhenFollowedBy(LBRACE)
- val (self, body) = templateBodyOpt(false)
+ val (self, body) = templateBodyOpt(traitParentSeen = false)
(List(), List(List()), self, body)
}
)
@@ -2816,14 +2817,14 @@ self =>
* }}}
* @param isPre specifies whether in early initializer (true) or not (false)
*/
- def templateBody(isPre: Boolean) = inBraces(templateStatSeq(isPre)) match {
+ def templateBody(isPre: Boolean) = inBraces(templateStatSeq(isPre = isPre)) match {
case (self, Nil) => (self, List(EmptyTree))
case result => result
}
def templateBodyOpt(traitParentSeen: Boolean): (ValDef, List[Tree]) = {
newLineOptWhenFollowedBy(LBRACE)
if (in.token == LBRACE) {
- templateBody(false)
+ templateBody(isPre = false)
} else {
if (in.token == LPAREN)
syntaxError((if (traitParentSeen) "parents of traits" else "traits or objects")+
@@ -2920,7 +2921,7 @@ self =>
/** Informal - for the repl and other direct parser accessors.
*/
- def templateStats(): List[Tree] = templateStatSeq(false)._2 match {
+ def templateStats(): List[Tree] = templateStatSeq(isPre = false)._2 match {
case Nil => List(EmptyTree)
case stats => stats
}
@@ -3004,7 +3005,7 @@ self =>
def localDef : List[Tree] = {
atEndPos {
atStartPos(in.offset) {
- val annots = annotations(true)
+ val annots = annotations(skipNewLines = true)
val mods = localModifiers() withAnnotations annots
if (!(mods hasFlag ~(Flags.IMPLICIT | Flags.LAZY))) defOrDcl(mods)
else List(tmplDef(mods))
@@ -3014,7 +3015,7 @@ self =>
*/
def localDef(implicitMod: Int): List[Tree] = {
- val annots = annotations(true)
+ val annots = annotations(skipNewLines = true)
val pos = in.offset
val mods = (localModifiers() | implicitMod) withAnnotations annots
val defs =
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 87072f3172..6ba273b8ea 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -5,7 +5,8 @@
package scala.tools.nsc
package ast.parser
-import scala.tools.nsc.util._
+import scala.tools.nsc.util.CharArrayReader
+import scala.reflect.internal.util._
import scala.reflect.internal.Chars._
import Tokens._
import scala.annotation.switch
@@ -185,7 +186,7 @@ trait Scanners extends ScannersCommon {
sepRegions.nonEmpty && sepRegions.head == STRINGLIT
/** Are we directly in a multiline string interpolation expression?
- * @pre: inStringInterpolation
+ * @pre inStringInterpolation
*/
@inline private def inMultiLineInterpolation =
inStringInterpolation && sepRegions.tail.nonEmpty && sepRegions.tail.head == STRINGPART
diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
index b0204c5971..a4b45482de 100755
--- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
@@ -10,7 +10,7 @@ import scala.collection.{ mutable, immutable }
import xml.{ EntityRef, Text }
import xml.XML.{ xmlns }
import symtab.Flags.MUTABLE
-import scala.tools.util.StringOps.splitWhere
+import scala.reflect.internal.util.StringOps.splitWhere
import language.implicitConversions
/** This class builds instance of `Tree` that represent XML.
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index de7e6f9c7a..90f9d538c1 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -546,7 +546,10 @@ abstract class TreeBuilder {
rhs1,
List(
atPos(pat1.pos) {
- CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident, true))
+ def mkIdent(name: Name) = Ident(name)
+ CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map mkIdent, true))
+ // [Eugene++] no longer compiles after I moved the `Ident` case class into scala.reflect.internal
+ // CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident, true))
}
))
}
diff --git a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala
index 7da7611ce2..62885cc73d 100644
--- a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala
+++ b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package backend
import io.AbstractFile
-import util.{ClassPath,JavaClassPath}
+import util.{ClassPath,JavaClassPath,MergedClassPath,DeltaClassPath}
import util.ClassPath.{ JavaContext, DefaultJavaContext }
import scala.tools.util.PathResolver
@@ -17,7 +17,17 @@ trait JavaPlatform extends Platform {
type BinaryRepr = AbstractFile
- lazy val classPath = new PathResolver(settings).result
+ private var currentClassPath: Option[MergedClassPath[BinaryRepr]] = None
+
+ def classPath: ClassPath[BinaryRepr] = {
+ if (currentClassPath.isEmpty) currentClassPath = Some(new PathResolver(settings).result)
+ currentClassPath.get
+ }
+
+ /** Update classpath with a substituted subentry */
+ def updateClassPath(subst: Map[ClassPath[BinaryRepr], ClassPath[BinaryRepr]]) =
+ currentClassPath = Some(new DeltaClassPath(currentClassPath.get, subst))
+
def rootLoader = new loaders.PackageLoader(classPath.asInstanceOf[ClassPath[platform.BinaryRepr]])
// [Martin] Why do we need a cast here?
// The problem is that we cannot specify at this point that global.platform should be of type JavaPlatform.
diff --git a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala
index 65b1fbc229..f4176c46b8 100644
--- a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala
+++ b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala
@@ -31,6 +31,10 @@ trait MSILPlatform extends Platform {
def rootLoader = new loaders.PackageLoader(classPath.asInstanceOf[ClassPath[platform.BinaryRepr]])
// See discussion in JavaPlatForm for why we need a cast here.
+ /** Update classpath with a substituted subentry */
+ def updateClassPath(subst: Map[ClassPath[BinaryRepr], ClassPath[BinaryRepr]]) =
+ throw new UnsupportedOperationException("classpath invalidations not supported on MSIL")
+
def platformPhases = List(
genMSIL // generate .msil files
)
diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala
index 23592eeb61..f770713093 100644
--- a/src/compiler/scala/tools/nsc/backend/Platform.scala
+++ b/src/compiler/scala/tools/nsc/backend/Platform.scala
@@ -24,6 +24,9 @@ trait Platform {
/** The root symbol loader. */
def rootLoader: LazyType
+ /** Update classpath with a substitution that maps entries to entries */
+ def updateClassPath(subst: Map[ClassPath[BinaryRepr], ClassPath[BinaryRepr]])
+
/** Any platform-specific phases. */
def platformPhases: List[SubComponent]
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index b8ecaf1b43..86533c713e 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -9,7 +9,7 @@ package icode
import scala.collection.{ mutable, immutable }
import mutable.{ ListBuffer, ArrayBuffer }
-import util.{ Position, NoPosition }
+import scala.reflect.internal.util.{ Position, NoPosition }
import backend.icode.analysis.ProgramPoint
import language.postfixOps
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
index 019e887c4e..00f4a9d262 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
@@ -9,7 +9,7 @@ package icode
import java.io.PrintWriter
import scala.collection.{ mutable, immutable }
-import util.{ SourceFile, NoSourceFile }
+import scala.reflect.internal.util.{ SourceFile, NoSourceFile }
import symtab.Flags.{ DEFERRED }
trait ReferenceEquality {
@@ -156,7 +156,7 @@ trait Members {
def newBlock() = code.newBlock
def startBlock = code.startBlock
- def lastBlock = blocks.last
+ def lastBlock = { assert(blocks.nonEmpty, symbol); blocks.last }
def blocks = code.blocksList
def linearizedBlocks(lin: Linearizer = self.linearizer): List[BasicBlock] = lin linearize this
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
index 3179fc5c56..5f495c8456 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
@@ -10,7 +10,7 @@ package backend
package icode
import scala.tools.nsc.ast._
-import scala.tools.nsc.util.{Position,NoPosition}
+import scala.reflect.internal.util.{Position,NoPosition}
/*
A pattern match
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala
index 4ea253d29d..d34d93f147 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala
@@ -9,7 +9,7 @@ package icode
import java.io.PrintWriter
import scala.tools.nsc.symtab.Flags
-import scala.tools.nsc.util.Position
+import scala.reflect.internal.util.Position
trait Printers { self: ICodes =>
import global._
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index 81fe907a0c..0c527fbaf4 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -53,7 +53,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
override def erasedTypes = true
def apply(cls: IClass) = sys.error("no implementation")
- val BeanInfoAttr = definitions.getRequiredClass("scala.beans.BeanInfo")
+ val BeanInfoAttr = rootMirror.getRequiredClass("scala.beans.BeanInfo")
def isJavaEntryPoint(icls: IClass) = {
val sym = icls.symbol
@@ -223,8 +223,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
// unlike javaNameCache, reverseJavaName contains entries only for class symbols and their internal names.
val reverseJavaName = mutable.Map.empty[String, Symbol] ++= List(
- binarynme.RuntimeNothing.toString() -> NothingClass, // neither RuntimeNothingClass nor RuntimeNullClass belong to the co-domain of this map.
- binarynme.RuntimeNull.toString() -> NullClass
+ binarynme.RuntimeNothing.toString() -> RuntimeNothingClass, // RuntimeNothingClass is the bytecode-level return type of Scala methods with Nothing return-type.
+ binarynme.RuntimeNull.toString() -> RuntimeNullClass
)
private def mkFlags(args: Int*) = args.foldLeft(0)(_ | _)
@@ -283,12 +283,16 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
&& !sym.isMutable // lazy vals and vars both
)
+ // Primitives are "abstract final" to prohibit instantiation
+ // without having to provide any implementations, but that is an
+ // illegal combination of modifiers at the bytecode level so
+ // suppress final if abstract if present.
import asm.Opcodes._
mkFlags(
if (privateFlag) ACC_PRIVATE else ACC_PUBLIC,
if (sym.isDeferred || sym.hasAbstractFlag) ACC_ABSTRACT else 0,
if (sym.isInterface) ACC_INTERFACE else 0,
- if (finalFlag) ACC_FINAL else 0,
+ if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0,
if (sym.isStaticMember) ACC_STATIC else 0,
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
@@ -341,8 +345,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
def inameToSymbol(iname: String): Symbol = {
val name = global.newTypeName(iname)
val res0 =
- if (nme.isModuleName(name)) definitions.getModule(nme.stripModuleSuffix(name))
- else definitions.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested).
+ if (nme.isModuleName(name)) rootMirror.getModule(nme.stripModuleSuffix(name))
+ else rootMirror.getClassByName(name.replace('/', '.')) // TODO fails for inner classes (but this hasn't been tested).
assert(res0 != NoSymbol)
val res = jsymbol(res0)
res
@@ -433,10 +437,11 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
}
private val majorVersion: Int = (classfileVersion & 0xFF)
+ private val emitStackMapFrame = (majorVersion >= 50)
private val extraProc: Int = mkFlags(
asm.ClassWriter.COMPUTE_MAXS,
- if(majorVersion >= 50) asm.ClassWriter.COMPUTE_FRAMES else 0
+ if(emitStackMapFrame) asm.ClassWriter.COMPUTE_FRAMES else 0
)
val JAVA_LANG_OBJECT = asm.Type.getObjectType("java/lang/Object")
@@ -580,14 +585,14 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
else { sym.javaSimpleName }
})
- if(hasInternalName) {
+ if(emitStackMapFrame && hasInternalName) {
val internalName = cachedJN.toString()
val trackedSym = jsymbol(sym)
reverseJavaName.get(internalName) match {
case None =>
reverseJavaName.put(internalName, trackedSym)
case Some(oldsym) =>
- assert(List(NothingClass, NullClass).contains(oldsym) || oldsym == trackedSym,
+ assert((oldsym == trackedSym) || (oldsym == RuntimeNothingClass) || (oldsym == RuntimeNullClass), // In contrast, neither NothingClass nor NullClass show up bytecode-level.
"how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name.")
}
}
@@ -1175,8 +1180,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
*/
private val androidFieldName = newTermName("CREATOR")
- private lazy val AndroidParcelableInterface = definitions.getClassIfDefined("android.os.Parcelable")
- private lazy val AndroidCreatorClass = definitions.getClassIfDefined("android.os.Parcelable$Creator")
+ private lazy val AndroidParcelableInterface = rootMirror.getClassIfDefined("android.os.Parcelable")
+ private lazy val AndroidCreatorClass = rootMirror.getClassIfDefined("android.os.Parcelable$Creator")
def isAndroidParcelableClass(sym: Symbol) =
(AndroidParcelableInterface != NoSymbol) &&
@@ -1395,7 +1400,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
// typestate: entering mode with valid call sequences:
// ( visitInnerClass | visitField | visitMethod )* visitEnd
- if (isStaticModule(c.symbol) || serialVUID != None || isParcelableClass) {
+ if (isStaticModule(c.symbol) || isParcelableClass) {
if (isStaticModule(c.symbol)) { addModuleInstanceField() }
addStaticInit(c.lookupStaticCtor)
@@ -1423,6 +1428,18 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
}
+ // add static serialVersionUID field if `clasz` annotated with `@SerialVersionUID(uid: Long)`
+ serialVUID foreach { value =>
+ val fieldName = "serialVersionUID"
+ jclass.visitField(
+ PublicStaticFinal,
+ fieldName,
+ tdesc_long,
+ null, // no java-generic-signature
+ value
+ ).visitEnd()
+ }
+
clasz.fields foreach genField
clasz.methods foreach { im => genMethod(im, c.symbol.isInterface) }
@@ -1645,15 +1662,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
lastBlock emit CALL_METHOD(m.symbol.enclClass.primaryConstructor, Static(true))
}
- // add serialVUID code
- serialVUID foreach { value =>
- val fieldName = "serialVersionUID"
- val fieldSymbol = clasz.symbol.newValue(newTermName(fieldName), NoPosition, Flags.STATIC | Flags.FINAL) setInfo LongClass.tpe
- clasz addField new IField(fieldSymbol)
- lastBlock emit CONSTANT(Constant(value))
- lastBlock emit STORE_FIELD(fieldSymbol, true)
- }
-
if (isParcelableClass) { addCreatorCode(lastBlock) }
lastBlock emit RETURN(UNIT)
@@ -1684,17 +1692,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
thisName, INSTANCE_CONSTRUCTOR_NAME, mdesc_arglessvoid)
}
- serialVUID foreach { value =>
- val fieldName = "serialVersionUID"
- jclass.visitField(
- PublicStaticFinal,
- fieldName,
- tdesc_long,
- null, // no java-generic-signature
- value // TODO confirm whether initial value here is behaviorally equiv to fjbg's emitPUSH emitPUTSTATIC
- ).visitEnd()
- }
-
if (isParcelableClass) { legacyAddCreatorCode(clinit) }
clinit.visitInsn(asm.Opcodes.RETURN)
@@ -2542,7 +2539,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
} else if(kind.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_)
val Success = success
val Failure = failure
- (cond, nextBlock) match {
+ // @unchecked because references aren't compared with GT, GE, LT, LE.
+ ((cond, nextBlock) : @unchecked) match {
case (EQ, Success) => jcode emitIFNONNULL labels(failure)
case (NE, Failure) => jcode emitIFNONNULL labels(success)
case (EQ, Failure) => jcode emitIFNULL labels(success)
@@ -2727,7 +2725,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
// TODO Logical's 2nd elem should be declared ValueTypeKind, to better approximate its allowed values (isIntSized, its comments appears to convey)
// TODO GenICode uses `toTypeKind` to define that elem, `toValueTypeKind` would be needed instead.
// TODO How about adding some asserts to Logical and similar ones to capture the remaining constraint (UNIT not allowed).
- case Logical(op, kind) => (op, kind) match {
+ case Logical(op, kind) => ((op, kind): @unchecked) match {
case (AND, LONG) => emit(Opcodes.LAND)
case (AND, INT) => emit(Opcodes.IAND)
case (AND, _) =>
@@ -2747,7 +2745,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
if (kind != BOOL) { emitT2T(INT, kind) }
}
- case Shift(op, kind) => (op, kind) match {
+ case Shift(op, kind) => ((op, kind): @unchecked) match {
case (LSL, LONG) => emit(Opcodes.LSHL)
case (LSL, INT) => emit(Opcodes.ISHL)
case (LSL, _) =>
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala
index 1ba5b155fc..e3da5c486b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala
@@ -25,8 +25,8 @@ trait GenAndroid {
*/
private val fieldName = newTermName("CREATOR")
- private lazy val AndroidParcelableInterface = definitions.getClassIfDefined("android.os.Parcelable")
- private lazy val AndroidCreatorClass = definitions.getClassIfDefined("android.os.Parcelable$Creator")
+ private lazy val AndroidParcelableInterface = rootMirror.getClassIfDefined("android.os.Parcelable")
+ private lazy val AndroidCreatorClass = rootMirror.getClassIfDefined("android.os.Parcelable$Creator")
def isAndroidParcelableClass(sym: Symbol) =
(AndroidParcelableInterface != NoSymbol) &&
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 17c244ee82..21260d399c 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -11,7 +11,7 @@ import java.nio.ByteBuffer
import scala.collection.{ mutable, immutable }
import scala.reflect.internal.pickling.{ PickleFormat, PickleBuffer }
import scala.tools.nsc.symtab._
-import scala.tools.nsc.util.{ SourceFile, NoSourceFile }
+import scala.reflect.internal.util.{ SourceFile, NoSourceFile }
import scala.reflect.internal.ClassfileConstants._
import ch.epfl.lamp.fjbg._
import JAccessFlags._
@@ -203,10 +203,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
val MethodHandleType = new JObjectType("java.dyn.MethodHandle")
// Scala attributes
- val BeanInfoAttr = definitions.getRequiredClass("scala.beans.BeanInfo")
- val BeanInfoSkipAttr = definitions.getRequiredClass("scala.beans.BeanInfoSkip")
- val BeanDisplayNameAttr = definitions.getRequiredClass("scala.beans.BeanDisplayName")
- val BeanDescriptionAttr = definitions.getRequiredClass("scala.beans.BeanDescription")
+ val BeanInfoAttr = rootMirror.getRequiredClass("scala.beans.BeanInfo")
+ val BeanInfoSkipAttr = rootMirror.getRequiredClass("scala.beans.BeanInfoSkip")
+ val BeanDisplayNameAttr = rootMirror.getRequiredClass("scala.beans.BeanDisplayName")
+ val BeanDescriptionAttr = rootMirror.getRequiredClass("scala.beans.BeanDescription")
final val ExcludedForwarderFlags = {
import Flags._
@@ -1532,6 +1532,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
case (NE, _) =>
jcode emitIFNONNULL labels(success)
jcode.emitGOTO_maybe_W(labels(failure), false)
+ case _ =>
}
} else {
(kind: @unchecked) match {
@@ -1710,7 +1711,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
abort("Unknown arithmetic primitive " + primitive)
}
- case Logical(op, kind) => (op, kind) match {
+ case Logical(op, kind) => ((op, kind): @unchecked) match {
case (AND, LONG) => jcode.emitLAND()
case (AND, INT) => jcode.emitIAND()
case (AND, _) =>
@@ -1733,7 +1734,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
jcode.emitT2T(javaType(INT), javaType(kind));
}
- case Shift(op, kind) => (op, kind) match {
+ case Shift(op, kind) => ((op, kind): @unchecked) match {
case (LSL, LONG) => jcode.emitLSHL()
case (LSL, INT) => jcode.emitISHL()
case (LSL, _) =>
@@ -1960,11 +1961,15 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
&& !sym.isMutable // lazy vals and vars both
)
+ // Primitives are "abstract final" to prohibit instantiation
+ // without having to provide any implementations, but that is an
+ // illegal combination of modifiers at the bytecode level so
+ // suppress final if abstract if present.
mkFlags(
if (privateFlag) ACC_PRIVATE else ACC_PUBLIC,
if (sym.isDeferred || sym.hasAbstractFlag) ACC_ABSTRACT else 0,
if (sym.isInterface) ACC_INTERFACE else 0,
- if (finalFlag) ACC_FINAL else 0,
+ if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0,
if (sym.isStaticMember) ACC_STATIC else 0,
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
index 66e7becb12..d23571b517 100644
--- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
+++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
@@ -1553,7 +1553,7 @@ abstract class GenMSIL extends SubComponent {
}
def emitBrBool(cond: TestOp, dest: Label) {
- cond match {
+ (cond: @unchecked) match {
// EQ -> Brfalse, NE -> Brtrue; this is because we come from
// a CZJUMP. If the value on the stack is 0 (e.g. a boolean
// method returned false), and we are in the case EQ, then
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 08e059419a..f332e8cfdd 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -9,7 +9,7 @@ package backend.opt
import scala.collection.mutable
import scala.tools.nsc.symtab._
-import scala.tools.nsc.util.NoSourceFile
+import scala.reflect.internal.util.NoSourceFile
/**
* @author Iulian Dragos
@@ -100,7 +100,7 @@ abstract class Inliners extends SubComponent {
}
def isBottomType(sym: Symbol) = sym == NullClass || sym == NothingClass
- def posToStr(pos: util.Position) = if (pos.isDefined) pos.point.toString else "<nopos>"
+ def posToStr(pos: scala.reflect.internal.util.Position) = if (pos.isDefined) pos.point.toString else "<nopos>"
/** Is the given class a closure? */
def isClosureClass(cls: Symbol): Boolean =
diff --git a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala
index 02be916f59..317cc28298 100644
--- a/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/dependencies/DependencyAnalysis.scala
@@ -1,11 +1,11 @@
package scala.tools.nsc
package dependencies
-import util.SourceFile
import io.Path
import collection._
import symtab.Flags
import scala.tools.nsc.io.AbstractFile
+import scala.reflect.internal.util.SourceFile
trait DependencyAnalysis extends SubComponent with Files {
import global._
diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
index 76a8b87ba7..e2e1ddf065 100644
--- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
@@ -8,7 +8,7 @@ package doc
import scala.util.control.ControlThrowable
import reporters.Reporter
-import util.{ NoPosition, BatchSourceFile}
+import scala.reflect.internal.util.{ NoPosition, BatchSourceFile}
import io.{ File, Directory }
import DocParser.Parsed
diff --git a/src/compiler/scala/tools/nsc/doc/DocParser.scala b/src/compiler/scala/tools/nsc/doc/DocParser.scala
index 2bd80f31da..119a2c06e9 100644
--- a/src/compiler/scala/tools/nsc/doc/DocParser.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocParser.scala
@@ -8,7 +8,7 @@ package nsc
package doc
import reporters._
-import util._
+import scala.reflect.internal.util._
import interactive.RangePositions
import DocParser.Parsed
diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala
index d3a1d47de8..4458889d55 100644
--- a/src/compiler/scala/tools/nsc/doc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/doc/Settings.scala
@@ -150,15 +150,15 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
* the function result should be a humanly-understandable description of the type class
*/
val knownTypeClasses: Map[String, String => String] = Map() +
- ("<root>.scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) +
- ("<root>.scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) +
- ("<root>.scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) +
- ("<root>.scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) +
- ("<root>.scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) +
- ("<root>.scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) +
- ("<root>.scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) +
- ("<root>.scala.reflect.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure")) +
- ("<root>.scala.reflect.ConcreteTypeTag" -> ((tparam: String) => tparam + " is accompanied by an ConcreteTypeTag, which is a runtime representation of a concrete type that survives erasure"))
+ ("<root>.scala.package.Numeric" -> ((tparam: String) => tparam + " is a numeric class, such as Int, Long, Float or Double")) +
+ ("<root>.scala.package.Integral" -> ((tparam: String) => tparam + " is an integral numeric class, such as Int or Long")) +
+ ("<root>.scala.package.Fractional" -> ((tparam: String) => tparam + " is a fractional numeric class, such as Float or Double")) +
+ ("<root>.scala.reflect.Manifest" -> ((tparam: String) => tparam + " is accompanied by a Manifest, which is a runtime representation of its type that survives erasure")) +
+ ("<root>.scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) +
+ ("<root>.scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) +
+ ("<root>.scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) +
+ ("<root>.scala.reflect.AbsTypeTag" -> ((tparam: String) => tparam + " is accompanied by an AbsTypeTag, which is a runtime representation of its type that survives erasure")) +
+ ("<root>.scala.reflect.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure"))
/**
* Set of classes to exclude from index and diagrams
diff --git a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
index 8f426a443d..fef753b12c 100644
--- a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
+++ b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala
@@ -16,7 +16,8 @@ trait Uncompilable {
val settings: Settings
import global.{ reporter, inform, warning, newTypeName, newTermName, Symbol, Name, DocComment, NoSymbol }
- import global.definitions.{ RootClass, AnyRefClass }
+ import global.definitions.AnyRefClass
+ import global.rootMirror.RootClass
private implicit def translateName(name: Global#Name) =
if (name.isTypeName) newTypeName("" + name) else newTermName("" + name)
diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
index 3ff973ec66..629ac84b34 100644
--- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
@@ -40,8 +40,8 @@ private[html] object SyntaxHigh {
/** Standard library classes/objects, sorted alphabetically */
val standards = Array (
- "Any", "AnyRef", "AnyVal", "App", "Application", "Array",
- "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "ConcreteTypeTag",
+ "AbsTypeTag", "Any", "AnyRef", "AnyVal", "App", "Application", "Array",
+ "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest",
"Console", "Double", "Enumeration", "Float", "Function", "Int",
"List", "Long", "Manifest", "Map",
"NoManifest", "None", "Nothing", "Null", "Object", "Option", "OptManifest",
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index 49cd17c176..66189a6854 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -316,7 +316,6 @@ class Template(universe: doc.Universe, tpl: DocTemplateEntity) extends HtmlPage
def mbrCmt = mbr.comment.get
def paramCommentToHtml(prs: List[ParameterEntity]): NodeSeq = prs match {
- case Nil => NodeSeq.Empty
case (tp: TypeParam) :: rest =>
val paramEntry: NodeSeq = {
@@ -329,6 +328,9 @@ class Template(universe: doc.Universe, tpl: DocTemplateEntity) extends HtmlPage
<dt class="param">{ vp.name }</dt><dd class="cmt">{ bodyToHtml(mbrCmt.valueParams(vp.name)) }</dd>
}
paramEntry ++ paramCommentToHtml(rest)
+
+ case _ =>
+ NodeSeq.Empty
}
if (mbr.comment.isEmpty) NodeSeq.Empty
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 9062203dcd..3dd77d47da 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -20,7 +20,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
thisFactory: ModelFactory with ModelFactoryImplicitSupport with CommentFactory with TreeFactory =>
import global._
- import definitions.{ ObjectClass, RootPackage, EmptyPackage, NothingClass, AnyClass, AnyValClass, AnyRefClass }
+ import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass }
+ import rootMirror.{ RootPackage, EmptyPackage }
private var droppedPackages = 0
def templatesCount = templatesCache.size - droppedPackages
@@ -339,7 +340,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
/** */
def normalizeTemplate(aSym: Symbol): Symbol = aSym match {
- case null | EmptyPackage | NoSymbol =>
+ case null | rootMirror.EmptyPackage | NoSymbol =>
normalizeTemplate(RootPackage)
case ObjectClass =>
normalizeTemplate(AnyRefClass)
diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala
index f948d53c8b..fe586c4996 100755
--- a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala
@@ -3,7 +3,7 @@ package doc
package model
import scala.collection._
-import util.{RangePosition, OffsetPosition, SourceFile}
+import scala.reflect.internal.util.{RangePosition, OffsetPosition, SourceFile}
/** The goal of this trait is , using makeTree,
* to browse a tree to
diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
index e6bc76f676..996223b9f9 100644
--- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
@@ -12,7 +12,7 @@ import reporters.Reporter
import scala.collection._
import scala.util.matching.Regex
import scala.annotation.switch
-import util.{NoPosition, Position}
+import scala.reflect.internal.util.{NoPosition, Position}
import language.postfixOps
/** The comment parser transforms raw comment strings into `Comment` objects.
diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
index 0f89236861..7d36d17a18 100644
--- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
+++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
@@ -9,7 +9,7 @@ package interactive
import scala.collection._
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
-import util.FakePos
+import scala.reflect.internal.util.FakePos
import dependencies._
import io.AbstractFile
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index 1b91b06942..801b4ad22b 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -7,11 +7,12 @@ package interactive
import scala.util.control.ControlThrowable
import scala.tools.nsc.io.AbstractFile
-import scala.tools.nsc.util.{SourceFile, Position, WorkScheduler}
import scala.tools.nsc.symtab._
import scala.tools.nsc.ast._
import scala.tools.nsc.util.FailedInterrupt
import scala.tools.nsc.util.EmptyAction
+import scala.tools.nsc.util.WorkScheduler
+import scala.reflect.internal.util.{SourceFile, Position}
/** Interface of interactive compiler to a client such as an IDE
* The model the presentation compiler consists of the following parts:
diff --git a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala
index fc48d4819c..80d2796801 100644
--- a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala
+++ b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala
@@ -6,7 +6,7 @@ package scala.tools.nsc
package interactive
import collection.mutable.ArrayBuffer
-import util.Position
+import scala.reflect.internal.util.Position
trait ContextTrees { self: Global =>
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index edf0108e58..82ce59d075 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -11,7 +11,8 @@ import mutable.{LinkedHashMap, SynchronizedMap, HashSet, SynchronizedSet}
import scala.concurrent.SyncVar
import scala.util.control.ControlThrowable
import scala.tools.nsc.io.{ AbstractFile, LogReplay, Logger, NullLogger, Replayer }
-import scala.tools.nsc.util.{ SourceFile, BatchSourceFile, Position, RangePosition, NoPosition, WorkScheduler, MultiHashMap }
+import scala.tools.nsc.util.{ WorkScheduler, MultiHashMap }
+import scala.reflect.internal.util.{ SourceFile, BatchSourceFile, Position, RangePosition, NoPosition }
import scala.tools.nsc.reporters._
import scala.tools.nsc.symtab._
import scala.tools.nsc.ast._
diff --git a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala
index 397e83a362..df8fc3b21e 100644
--- a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala
+++ b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala
@@ -6,7 +6,7 @@ package scala.tools.nsc
package interactive
import collection.mutable.ArrayBuffer
-import util.Position
+import scala.reflect.internal.util.Position
import reporters.Reporter
case class Problem(pos: Position, msg: String, severityLevel: Int)
diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala
index b7a9c7329c..bf920191c8 100644
--- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala
@@ -5,10 +5,12 @@
package scala.tools.nsc
package interactive
-import util.{SourceFile, BatchSourceFile, InterruptReq}
+import util.InterruptReq
+import scala.reflect.internal.util.{SourceFile, BatchSourceFile}
import io.{AbstractFile, PlainFile}
-import util.{Position, RangePosition, NoPosition, OffsetPosition, TransparentPosition, EmptyAction}
+import util.EmptyAction
+import scala.reflect.internal.util.{Position, RangePosition, NoPosition, OffsetPosition, TransparentPosition}
import io.{Pickler, CondPickler}
import io.Pickler._
import collection.mutable
@@ -115,7 +117,7 @@ trait Picklers { self: Global =>
if (sym.isOverloaded) makeSymbol(sym.alternatives(rest.head.toString.toInt), rest.tail)
else makeSymbol(sym, rest)
}
- pkl[List[Name]] .wrapped { makeSymbol(definitions.RootClass, _) } { ownerNames(_, new ListBuffer).toList }
+ pkl[List[Name]] .wrapped { makeSymbol(rootMirror.RootClass, _) } { ownerNames(_, new ListBuffer).toList }
}
implicit def workEvent: Pickler[WorkEvent] = {
diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala
index 1d78cc6e1c..1dcc979255 100644
--- a/src/compiler/scala/tools/nsc/interactive/REPL.scala
+++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala
@@ -6,7 +6,7 @@ package scala.tools.nsc
package interactive
import scala.concurrent.SyncVar
-import scala.tools.nsc.util._
+import scala.reflect.internal.util._
import scala.tools.nsc.symtab._
import scala.tools.nsc.ast._
import scala.tools.nsc.reporters._
@@ -141,7 +141,7 @@ object REPL {
*/
def compileInstrumented(iSourceName: String, arguments: List[String]): Option[AbstractFile] = {
println("compiling "+iSourceName)
- val command = new CompilerCommand(iSourceName :: arguments, reporter.error(scala.tools.nsc.util.NoPosition, _))
+ val command = new CompilerCommand(iSourceName :: arguments, reporter.error(scala.reflect.internal.util.NoPosition, _))
val virtualDirectoryOpt =
if (arguments contains "-d")
None
diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
index 49ba9d0aeb..06828f3a3a 100644
--- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
@@ -7,7 +7,8 @@ package interactive
import ast.Trees
import ast.Positions
-import scala.tools.nsc.util.{SourceFile, Position, RangePosition, NoPosition, WorkScheduler}
+import scala.reflect.internal.util.{SourceFile, Position, RangePosition, NoPosition}
+import scala.tools.nsc.util.WorkScheduler
import scala.collection.mutable.ListBuffer
/** Handling range positions
@@ -189,7 +190,7 @@ self: scala.tools.nsc.Global =>
override def validatePositions(tree: Tree) {
def reportTree(prefix : String, tree : Tree) {
val source = if (tree.pos.isDefined) tree.pos.source else ""
- inform("== "+prefix+" tree ["+tree.id+"] of type "+tree.printingPrefix+" at "+tree.pos.show+source)
+ inform("== "+prefix+" tree ["+tree.id+"] of type "+tree.productPrefix+" at "+tree.pos.show+source)
inform("")
inform(treeStatus(tree))
inform("")
diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
index bad181eb76..57f0835edd 100644
--- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala
@@ -12,7 +12,8 @@ import scala.util.control.Breaks._
import scala.tools.nsc.symtab.Flags
import dependencies._
-import util.{FakePos, ClassPath}
+import scala.reflect.internal.util.FakePos
+import util.ClassPath
import io.AbstractFile
import scala.tools.util.PathResolver
diff --git a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
index 9ef7d33549..9b2fee5f1f 100644
--- a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala
@@ -5,7 +5,7 @@
package scala.tools.nsc
package interactive
-import scala.tools.nsc.util.{SourceFile, Position, NoPosition}
+import scala.reflect.internal.util.{SourceFile, Position, NoPosition}
import collection.mutable.ArrayBuffer
trait RichCompilationUnits { self: Global =>
diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
index e2dcc48709..a3f6726b44 100644
--- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
+++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
@@ -1,7 +1,7 @@
package scala.tools.nsc
package interactive
-import util.{SourceFile, BatchSourceFile, RangePosition}
+import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition}
import collection.mutable.ArrayBuffer
import reflect.internal.Chars.isLineBreakChar
diff --git a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala
index dd06e7dafa..6c9c7249e8 100644
--- a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala
+++ b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala
@@ -10,7 +10,7 @@ import scala.collection._
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import dependencies._
-import util.FakePos
+import scala.reflect.internal.util.FakePos
import io.AbstractFile
/** A simple build manager, using the default scalac dependency tracker.
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
index 9dc2a8de10..f622f11ffd 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala
@@ -12,8 +12,8 @@ import java.io.File.pathSeparatorChar
import java.io.File.separatorChar
import scala.annotation.migration
-import scala.tools.nsc.util.Position
-import scala.tools.nsc.util.SourceFile
+import scala.reflect.internal.util.Position
+import scala.reflect.internal.util.SourceFile
import collection.mutable.ListBuffer
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
index 034db218ae..55198e3617 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
@@ -6,7 +6,7 @@ package scala.tools.nsc
package interactive
package tests
-import util._
+import scala.reflect.internal.util._
import reporters._
import io.AbstractFile
import collection.mutable.ArrayBuffer
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
index 657ef23eed..0cf32a8d8a 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
@@ -7,8 +7,8 @@ package interactive
package tests.core
import scala.tools.nsc.interactive.Response
-import scala.tools.nsc.util.Position
-import scala.tools.nsc.util.SourceFile
+import scala.reflect.internal.util.Position
+import scala.reflect.internal.util.SourceFile
/**
* A trait for defining commands that can be queried to the
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
index d6102734ab..c8e6b6ccce 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
@@ -2,7 +2,7 @@ package scala.tools.nsc
package interactive
package tests.core
-import scala.tools.nsc.util.Position
+import scala.reflect.internal.util.Position
import scala.tools.nsc.interactive.tests.core._
/** Set of core test definitions that are executed for each test run. */
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala
index d2baaf32c6..18a8eb5fc3 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerRequestsWorkingMode.scala
@@ -2,8 +2,8 @@ package scala.tools.nsc
package interactive
package tests.core
-import scala.tools.nsc.util.Position
-import scala.tools.nsc.util.SourceFile
+import scala.reflect.internal.util.Position
+import scala.reflect.internal.util.SourceFile
trait PresentationCompilerRequestsWorkingMode extends TestResources {
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala
index 8b8be697cc..9cf2aa4fe4 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala
@@ -1,7 +1,7 @@
package scala.tools.nsc.interactive.tests.core
import scala.tools.nsc.interactive.Global
-import scala.tools.nsc.util.Position
+import scala.reflect.internal.util.Position
trait PresentationCompilerTestDef {
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala
index 21e90fe57f..e80b741a8d 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala
@@ -1,6 +1,6 @@
package scala.tools.nsc.interactive.tests.core
-import scala.tools.nsc.util.{SourceFile,BatchSourceFile}
+import scala.reflect.internal.util.{SourceFile,BatchSourceFile}
import scala.tools.nsc.io.{AbstractFile,Path}
private[tests] object SourcesCollector {
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/TestResources.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/TestResources.scala
index 106d1dacb3..887c3cf29b 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/TestResources.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/TestResources.scala
@@ -1,7 +1,7 @@
package scala.tools.nsc.interactive.tests.core
import scala.tools.nsc.io.Path
-import scala.tools.nsc.util.SourceFile
+import scala.reflect.internal.util.SourceFile
/** Resources used by the test. */
private[tests] trait TestResources extends TestSettings {
diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
index 605ecee6c7..7289a947f4 100644
--- a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
@@ -15,7 +15,7 @@ import scala.collection.{ mutable, immutable }
*
* @author Lex Spoon
*/
-class AbstractFileClassLoader(root: AbstractFile, parent: ClassLoader)
+class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader)
extends ClassLoader(parent)
with ScalaClassLoader
{
diff --git a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala
index 79b429e26a..f2438dcc20 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
package interpreter
-import util.BatchSourceFile
+import scala.reflect.internal.util.BatchSourceFile
import scala.tools.nsc.ast.parser.Tokens.EOF
trait ExprTyper {
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index de778e7469..e5e7d7081d 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -24,6 +24,8 @@ import util.ScalaClassLoader
import ScalaClassLoader._
import scala.tools.util._
import language.{implicitConversions, existentials}
+import scala.reflect.{ClassTag, classTag}
+import scala.tools.reflect.StdTags._
/** The Scala interactive shell. It provides a read-eval-print loop
* around the Interpreter class.
@@ -105,7 +107,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
}
def isAsync = !settings.Yreplsync.value
- lazy val power = new Power(intp, new StdReplVals(this))
+ lazy val power = new Power(intp, new StdReplVals(this))(tagOfStdReplVals, classTag[StdReplVals])
def history = in.history
/** The context class loader at the time this object was created */
@@ -554,7 +556,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
// return false if repl should exit
def processLine(line: String): Boolean = {
if (isAsync) {
- awaitInitialized()
+ if (!awaitInitialized()) return false
runThunks()
}
if (line eq null) false // assume null means EOF
@@ -830,7 +832,14 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
}
// Bind intp somewhere out of the regular namespace where
// we can get at it in generated code.
- addThunk(intp.quietBind("$intp" -> intp))
+ addThunk(intp.quietBind(NamedParam[IMain]("$intp", intp)(tagOfIMain, classTag[IMain])))
+ addThunk({
+ import scala.tools.nsc.io._
+ import Properties.userHome
+ import compat.Platform.EOL
+ val autorun = replProps.replAutorunCode.option flatMap (f => io.File(f).safeSlurp())
+ if (autorun.isDefined) intp.quietRun(autorun.get)
+ })
loadFiles(settings)
// it is broken on startup; go ahead and exit
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
index 9072eaae46..37e4dfaea4 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
package interpreter
-import util.Position
+import scala.reflect.internal.util.Position
import scala.util.control.Exception.ignoring
/**
@@ -44,6 +44,7 @@ trait ILoopInit {
}
// a condition used to ensure serial access to the compiler.
@volatile private var initIsComplete = false
+ @volatile private var initError: String = null
private def elapsed() = "%.3f".format((System.nanoTime - initStart).toDouble / 1000000000L)
// the method to be called when the interpreter is initialized.
@@ -63,9 +64,17 @@ trait ILoopInit {
}
// called from main repl loop
- protected def awaitInitialized() {
+ protected def awaitInitialized(): Boolean = {
if (!initIsComplete)
withLock { while (!initIsComplete) initLoopCondition.await() }
+ if (initError != null) {
+ println("""
+ |Failed to initialize the REPL due to an unexpected error.
+ |This is a bug, please, report it along with the error diagnostics printed below.
+ |%s.""".stripMargin.format(initError)
+ )
+ false
+ } else true
}
// private def warningsThunks = List(
// () => intp.bind("lastWarnings", "" + typeTag[List[(Position, String)]], intp.lastWarnings _),
@@ -80,13 +89,22 @@ trait ILoopInit {
// )
// called once after init condition is signalled
protected def postInitialization() {
- postInitThunks foreach (f => addThunk(f()))
- runThunks()
- initIsComplete = true
+ try {
+ postInitThunks foreach (f => addThunk(f()))
+ runThunks()
+ } catch {
+ case ex =>
+ val message = new java.io.StringWriter()
+ ex.printStackTrace(new java.io.PrintWriter(message))
+ initError = message.toString
+ throw ex
+ } finally {
+ initIsComplete = true
- if (isAsync) {
- asyncMessage("[info] total init time: " + elapsed() + " s.")
- withLock(initLoopCondition.signal())
+ if (isAsync) {
+ asyncMessage("[info] total init time: " + elapsed() + " s.")
+ withLock(initLoopCondition.signal())
+ }
}
}
// code to be executed only after the interpreter is initialized
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index 956e282b26..2a7adbe781 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -7,7 +7,8 @@ package scala.tools.nsc
package interpreter
import Predef.{ println => _, _ }
-import util.{ Set => _, _ }
+import util.stringFromWriter
+import scala.reflect.internal.util._
import java.net.URL
import scala.sys.BooleanProp
import io.VirtualDirectory
@@ -25,6 +26,9 @@ import IMain._
import java.util.concurrent.Future
import typechecker.Analyzer
import language.implicitConversions
+import scala.reflect.runtime.{ universe => ru }
+import scala.reflect.{ ClassTag, classTag }
+import scala.tools.reflect.StdTags._
/** directory to save .class files to */
private class ReplVirtualDirectory(out: JPrintWriter) extends VirtualDirectory("(memory)", None) {
@@ -149,6 +153,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
private def _initSources = List(new BatchSourceFile("<init>", "class $repl_$init { }"))
private def _initialize() = {
try {
+ // [Eugene] todo. if this crashes, REPL will hang
new _compiler.Run() compileSources _initSources
_initializeComplete = true
true
@@ -194,17 +199,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
lazy val compiler: global.type = global
import global._
- import definitions.{
- ScalaPackage, JavaLangPackage, RootClass,
- getClassIfDefined, getModuleIfDefined, getRequiredModule, getRequiredClass,
- termMember, typeMember
- }
-
- private implicit def privateTreeOps(t: Tree): List[Tree] = {
- (new Traversable[Tree] {
- def foreach[U](f: Tree => U): Unit = t foreach { x => f(x) ; () }
- }).toList
- }
+ import definitions.{ScalaPackage, JavaLangPackage, termMember, typeMember}
+ import rootMirror.{RootClass, getClassIfDefined, getModuleIfDefined, getRequiredModule, getRequiredClass}
implicit class ReplTypeOps(tp: Type) {
def orElse(other: => Type): Type = if (tp ne NoType) tp else other
@@ -331,14 +327,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
def getInterpreterClassLoader() = classLoader
// Set the current Java "context" class loader to this interpreter's class loader
- def setContextClassLoader() = {
- classLoader.setAsContext()
-
- // this is risky, but it's our only possibility to make default reflexive mirror to work with REPL
- // so far we have only used the default mirror to create a few tags for the compiler
- // so it shouldn't be in conflict with our classloader, especially since it respects its parent
- scala.reflect.mirror.classLoader = classLoader
- }
+ def setContextClassLoader() = classLoader.setAsContext()
/** Given a simple repl-defined name, returns the real name of
* the class representing it, e.g. for "Bippy" it may return
@@ -499,11 +488,17 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
case Some(trees) => trees
}
repltrace(
- trees map (t =>
- t map (t0 =>
+ trees map (t => {
+ // [Eugene to Paul] previously it just said `t map ...`
+ // because there was an implicit conversion from Tree to a list of Trees
+ // however Martin and I have removed the conversion
+ // (it was conflicting with the new reflection API),
+ // so I had to rewrite this a bit
+ val subs = t collect { case sub => sub }
+ subs map (t0 =>
" " + safePos(t0, -1) + ": " + t0.shortClass + "\n"
) mkString ""
- ) mkString "\n"
+ }) mkString "\n"
)
// If the last tree is a bare expression, pinpoint where it begins using the
// AST node position and snap the line off there. Rewrite the code embodied
@@ -651,8 +646,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
directlyBoundNames += newTermName(name)
result
}
- def directBind(p: NamedParam): IR.Result = directBind(p.name, p.tpe, p.value)
- def directBind[T: ClassTag](name: String, value: T): IR.Result = directBind((name, value))
+ def directBind(p: NamedParam): IR.Result = directBind(p.name, p.tpe, p.value)
+ def directBind[T: ru.TypeTag : ClassTag](name: String, value: T): IR.Result = directBind((name, value))
def rebind(p: NamedParam): IR.Result = {
val name = p.name
@@ -668,12 +663,12 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
if (ids.isEmpty) IR.Success
else interpret("import " + ids.mkString(", "))
- def quietBind(p: NamedParam): IR.Result = beQuietDuring(bind(p))
- def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value)
- def bind[T: TypeTag](name: String, value: T): IR.Result = bind((name, value))
- def bindSyntheticValue(x: Any): IR.Result = bindValue(freshInternalVarName(), x)
- def bindValue(x: Any): IR.Result = bindValue(freshUserVarName(), x)
- def bindValue(name: String, x: Any): IR.Result = bind(name, TypeStrings.fromValue(x), x)
+ def quietBind(p: NamedParam): IR.Result = beQuietDuring(bind(p))
+ def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value)
+ def bind[T: ru.TypeTag : ClassTag](name: String, value: T): IR.Result = bind((name, value))
+ def bindSyntheticValue(x: Any): IR.Result = bindValue(freshInternalVarName(), x)
+ def bindValue(x: Any): IR.Result = bindValue(freshUserVarName(), x)
+ def bindValue(name: String, x: Any): IR.Result = bind(name, TypeStrings.fromValue(x), x)
/** Reset this interpreter, forgetting all user-specified requests. */
def reset() {
@@ -716,7 +711,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
val unwrapped = unwrap(t)
withLastExceptionLock[String]({
- directBind[Throwable]("lastException", unwrapped)
+ directBind[Throwable]("lastException", unwrapped)(tagOfThrowable, classTag[Throwable])
util.stackTraceString(unwrapped)
}, util.stackTraceString(unwrapped))
}
@@ -1050,7 +1045,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
valueOfTerm(id) map (_.getClass)
def typeOfTerm(id: String): Type = newTermName(id) match {
- case nme.ROOTPKG => definitions.RootClass.tpe
+ case nme.ROOTPKG => RootClass.tpe
case name => requestForName(name).fold(NoType: Type)(_ compilerTypeOf name)
}
@@ -1127,9 +1122,9 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
findName(termname) orElse getModuleIfDefined(termname)
}
// [Eugene to Paul] possibly you could make use of TypeTags here
- def types[T: ClassTag] : Symbol = types(classTag[T].erasure.getName)
- def terms[T: ClassTag] : Symbol = terms(classTag[T].erasure.getName)
- def apply[T: ClassTag] : Symbol = apply(classTag[T].erasure.getName)
+ def types[T: ClassTag] : Symbol = types(classTag[T].runtimeClass.getName)
+ def terms[T: ClassTag] : Symbol = terms(classTag[T].runtimeClass.getName)
+ def apply[T: ClassTag] : Symbol = apply(classTag[T].runtimeClass.getName)
def classSymbols = allDefSymbols collect { case x: ClassSymbol => x }
def methodSymbols = allDefSymbols collect { case x: MethodSymbol => x }
@@ -1227,7 +1222,7 @@ object IMain {
def maxStringLength: Int
def isTruncating: Boolean
def truncate(str: String): String = {
- if (isTruncating && str.length > maxStringLength)
+ if (isTruncating && (maxStringLength != 0 && str.length > maxStringLength))
(str take maxStringLength - 3) + "..."
else str
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala
index 59c933632b..d68a2becfb 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala
@@ -24,7 +24,7 @@ class ISettings(intp: IMain) {
* more than this number of characters, then the printout is
* truncated.
*/
- var maxPrintString = 800
+ var maxPrintString = replProps.maxPrintString.option.getOrElse(800)
/** The maximum number of completion candidates to print for tab
* completion without requiring confirmation.
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
index b1e6a9d7d9..c429e3b196 100644
--- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -16,7 +16,8 @@ import collection.mutable.ListBuffer
class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput {
val global: intp.global.type = intp.global
import global._
- import definitions.{ PredefModule, RootClass, AnyClass, AnyRefClass, ScalaPackage, JavaLangPackage, getModuleIfDefined }
+ import definitions.{ PredefModule, AnyClass, AnyRefClass, ScalaPackage, JavaLangPackage }
+ import rootMirror.{ RootClass, getModuleIfDefined }
type ExecResult = Any
import intp.{ debugging }
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
index a29eb3ac6d..236f3f23c5 100644
--- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -115,7 +115,11 @@ trait MemberHandlers {
if (mods.isLazy) codegenln(false, "<lazy>")
else any2stringOf(req fullPath name, maxStringElements)
- """ + "%s: %s = " + %s""".format(prettyName, string2code(req typeOf name), resultString)
+ val vidString =
+ if (replProps.vids) """" + " @ " + "%%8x".format(System.identityHashCode(%s)) + " """.trim.format(req fullPath name)
+ else ""
+
+ """ + "%s%s: %s = " + %s""".format(prettyName, vidString, string2code(req typeOf name), resultString)
}
}
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
index a3cbfffc3b..3a69ea86b5 100644
--- a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
@@ -8,23 +8,25 @@ package interpreter
import NamedParam._
import language.implicitConversions
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.{ClassTag, classTag}
trait NamedParamCreator {
protected def freshName: () => String
def apply(name: String, tpe: String, value: Any): NamedParam = NamedParamClass(name, tpe, value)
- def apply[T: TypeTag](name: String, x: T): NamedParam = new Typed[T](name, x)
- def apply[T: TypeTag](x: T): NamedParam = apply(freshName(), x)
+ def apply[T: ru.TypeTag : ClassTag](name: String, x: T): NamedParam = new Typed[T](name, x)
+ def apply[T: ru.TypeTag : ClassTag](x: T): NamedParam = apply(freshName(), x)
def clazz(name: String, x: Any): NamedParam = new Untyped(name, x)
def clazz(x: Any): NamedParam = clazz(freshName(), x)
- implicit def namedValue[T: TypeTag](name: String, x: T): NamedParam = apply(name, x)
- implicit def tuple[T: TypeTag](pair: (String, T)): NamedParam = apply(pair._1, pair._2)
+ implicit def namedValue[T: ru.TypeTag : ClassTag](name: String, x: T): NamedParam = apply(name, x)
+ implicit def tuple[T: ru.TypeTag : ClassTag](pair: (String, T)): NamedParam = apply(pair._1, pair._2)
}
object NamedParam extends NamedParamCreator {
- class Typed[T: TypeTag](val name: String, val value: T) extends NamedParam {
+ class Typed[T: ru.TypeTag : ClassTag](val name: String, val value: T) extends NamedParam {
val tpe = TypeStrings.fromTag[T]
}
class Untyped(val name: String, val value: Any) extends NamedParam {
diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala
index 9c4c05f1ee..57d7cef726 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Power.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala
@@ -8,12 +8,14 @@ package interpreter
import scala.collection.{ mutable, immutable }
import scala.util.matching.Regex
-import scala.tools.nsc.util.{ BatchSourceFile }
+import scala.reflect.internal.util.{ BatchSourceFile }
import session.{ History }
import scala.io.Codec
import java.net.{ URL, MalformedURLException }
import io.{ Path }
import language.implicitConversions
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.{ClassTag, classTag}
/** Collecting some power mode examples.
@@ -42,10 +44,11 @@ Lost after 18/flatten {
/** A class for methods to be injected into the intp in power mode.
*/
-class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplValsImpl) {
+class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, replVals: ReplValsImpl) {
import intp.{ beQuietDuring, typeOfExpression, interpret, parse }
import intp.global._
- import definitions.{ compilerTypeFromTag, compilerSymbolFromTag, getClassIfDefined, getModuleIfDefined }
+ import definitions.{ compilerTypeFromTag, compilerSymbolFromTag}
+ import rootMirror.{ getClassIfDefined, getModuleIfDefined }
abstract class SymSlurper {
def isKeep(sym: Symbol): Boolean
@@ -162,7 +165,7 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
}
trait LowPriorityInternalInfo {
- implicit def apply[T: TypeTag] : InternalInfo[T] = new InternalInfo[T](None)
+ implicit def apply[T: ru.TypeTag : ClassTag] : InternalInfo[T] = new InternalInfo[T](None)
}
object InternalInfo extends LowPriorityInternalInfo { }
@@ -173,12 +176,12 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
* of the conveniences exist on that wrapper.
*/
trait LowPriorityInternalInfoWrapper {
- implicit def apply[T: TypeTag] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None)
+ implicit def apply[T: ru.TypeTag : ClassTag] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None)
}
object InternalInfoWrapper extends LowPriorityInternalInfoWrapper {
}
- class InternalInfoWrapper[T: TypeTag](value: Option[T] = None) {
+ class InternalInfoWrapper[T: ru.TypeTag : ClassTag](value: Option[T] = None) {
def ? : InternalInfo[T] = new InternalInfo[T](value)
}
@@ -186,8 +189,8 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
* translate tag type arguments into applied types
* customizable symbol filter (had to hardcode no-spec to reduce noise)
*/
- class InternalInfo[T: TypeTag](value: Option[T] = None) {
- private def newInfo[U: TypeTag](value: U): InternalInfo[U] = new InternalInfo[U](Some(value))
+ class InternalInfo[T](value: Option[T] = None)(implicit typeEvidence: ru.TypeTag[T], runtimeClassEvidence: ClassTag[T]) {
+ private def newInfo[U: ru.TypeTag : ClassTag](value: U): InternalInfo[U] = new InternalInfo[U](Some(value))
private def isSpecialized(s: Symbol) = s.name.toString contains "$mc"
private def isImplClass(s: Symbol) = s.name.toString endsWith "$class"
@@ -226,9 +229,9 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
def pkgClasses = pkgMembers filter (s => s.isClass && s.isDefinedInPackage)
def pkgSymbols = new PackageSlurper(pkgClass).slurp() filterNot excludeMember
- def tag = typeTag[T]
- def erasure = tag.erasure
- def shortClass = erasure.getName split "[$.]" last
+ def tag = typeEvidence
+ def runtimeClass = runtimeClassEvidence.runtimeClass
+ def shortClass = runtimeClass.getName split "[$.]" last
def baseClasses = tpe.baseClasses
def baseClassDecls = mapFrom(baseClasses)(_.info.decls.toList.sortBy(_.name))
@@ -236,13 +239,13 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
def ancestorDeclares(name: String) = ancestors filter (_.info member newTermName(name) ne NoSymbol)
def baseTypes = tpe.baseTypeSeq.toList
- def <:<[U: TypeTag](other: U) = tpe <:< newInfo(other).tpe
- def lub[U: TypeTag](other: U) = intp.global.lub(List(tpe, newInfo(other).tpe))
- def glb[U: TypeTag](other: U) = intp.global.glb(List(tpe, newInfo(other).tpe))
+ def <:<[U: ru.TypeTag : ClassTag](other: U) = tpe <:< newInfo(other).tpe
+ def lub[U: ru.TypeTag : ClassTag](other: U) = intp.global.lub(List(tpe, newInfo(other).tpe))
+ def glb[U: ru.TypeTag : ClassTag](other: U) = intp.global.glb(List(tpe, newInfo(other).tpe))
override def toString = value match {
case Some(x) => "%s (%s)".format(x, shortClass)
- case _ => erasure.getName
+ case _ => runtimeClass.getName
}
}
@@ -362,7 +365,7 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
implicit lazy val powerSymbolOrdering: Ordering[Symbol] = Ordering[Name] on (_.name)
implicit lazy val powerTypeOrdering: Ordering[Type] = Ordering[Symbol] on (_.typeSymbol)
- implicit def replInternalInfo[T: TypeTag](x: T): InternalInfoWrapper[T] = new InternalInfoWrapper[T](Some(x))
+ implicit def replInternalInfo[T: ru.TypeTag : ClassTag](x: T): InternalInfoWrapper[T] = new InternalInfoWrapper[T](Some(x))
implicit def replEnhancedStrings(s: String): RichReplString = new RichReplString(s)
implicit def replMultiPrinting[T: Prettifier](xs: TraversableOnce[T]): MultiPrettifierClass[T] =
new MultiPrettifierClass[T](xs.toSeq)
@@ -378,12 +381,12 @@ class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplV
trait ReplUtilities {
// [Eugene to Paul] needs review!
- // def module[T: TypeTag] = getModuleIfDefined(typeTag[T].erasure.getName stripSuffix nme.MODULE_SUFFIX_STRING)
- // def clazz[T: TypeTag] = getClassIfDefined(typeTag[T].erasure.getName)
- def module[T: TypeTag] = typeTag[T].sym.suchThat(_.isPackage)
- def clazz[T: TypeTag] = typeTag[T].sym.suchThat(_.isClass)
- def info[T: TypeTag] = InternalInfo[T]
- def ?[T: TypeTag] = InternalInfo[T]
+ // def module[T: Manifest] = getModuleIfDefined(manifest[T].erasure.getName stripSuffix nme.MODULE_SUFFIX_STRING)
+ // def clazz[T: Manifest] = getClassIfDefined(manifest[T].erasure.getName)
+ def module[T: ru.TypeTag] = ru.typeOf[T].typeSymbol.suchThat(_.isPackage)
+ def clazz[T: ru.TypeTag] = ru.typeOf[T].typeSymbol.suchThat(_.isClass)
+ def info[T: ru.TypeTag : ClassTag] = InternalInfo[T]
+ def ?[T: ru.TypeTag : ClassTag] = InternalInfo[T]
def url(s: String) = {
try new URL(s)
catch { case _: MalformedURLException =>
diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala
index 5eb1e0ae18..218e02193a 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala
@@ -7,9 +7,11 @@ package scala.tools.nsc
package interpreter
import scala.sys._
+import Prop._
class ReplProps {
private def bool(name: String) = BooleanProp.keyExists(name)
+ private def int(name: String) = IntProp(name)
val jlineDebug = bool("scala.tools.jline.internal.Log.debug")
val jlineTrace = bool("scala.tools.jline.internal.Log.trace")
@@ -19,7 +21,11 @@ class ReplProps {
val trace = bool("scala.repl.trace")
val power = bool("scala.repl.power")
- val replInitCode = Prop[JFile]("scala.repl.initcode")
- val powerInitCode = Prop[JFile]("scala.repl.power.initcode")
- val powerBanner = Prop[JFile]("scala.repl.power.banner")
+ val replInitCode = Prop[JFile]("scala.repl.initcode")
+ val replAutorunCode = Prop[JFile]("scala.repl.autoruncode")
+ val powerInitCode = Prop[JFile]("scala.repl.power.initcode")
+ val powerBanner = Prop[JFile]("scala.repl.power.banner")
+
+ val vids = bool("scala.repl.vids")
+ val maxPrintString = int("scala.repl.maxprintstring")
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
index 280247f20c..588d0647d2 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
@@ -6,8 +6,9 @@
package scala.tools.nsc
package interpreter
-import scala.reflect.{mirror => rm}
import language.implicitConversions
+import scala.reflect.base.{Universe => BaseUniverse}
+import scala.reflect.runtime.{universe => ru}
/** A class which the repl utilizes to expose predefined objects.
* The base implementation is empty; the standard repl implementation
@@ -64,15 +65,15 @@ object ReplVals {
* I have this forwarder which widens the type and then cast the result back
* to the dependent type.
*/
- def compilerTypeFromTag(t: rm.TypeTag[_]): Global#Type =
+ def compilerTypeFromTag(t: BaseUniverse # AbsTypeTag[_]): Global#Type =
definitions.compilerTypeFromTag(t)
class AppliedTypeFromTags(sym: Symbol) {
- def apply[M](implicit m1: rm.TypeTag[M]): Type =
+ def apply[M](implicit m1: ru.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
else appliedType(sym, compilerTypeFromTag(m1).asInstanceOf[Type])
- def apply[M1, M2](implicit m1: rm.TypeTag[M1], m2: rm.TypeTag[M2]): Type =
+ def apply[M1, M2](implicit m1: ru.TypeTag[M1], m2: ru.TypeTag[M2]): Type =
if (sym eq NoSymbol) NoType
else appliedType(sym, compilerTypeFromTag(m1).asInstanceOf[Type], compilerTypeFromTag(m2).asInstanceOf[Type])
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
index 2e735e3b9b..32eb1e95c1 100644
--- a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc
package interpreter
+import scala.reflect.{ ClassTag, classTag }
+
class RichClass[T](val clazz: Class[T]) {
def toTag: ClassTag[T] = ClassTag[T](clazz)
def toTypeString: String = TypeStrings.fromClazz(clazz)
diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
index 5d5123811e..56b9c7011c 100644
--- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
@@ -10,9 +10,11 @@ import java.lang.{ reflect => r }
import r.TypeVariable
import scala.reflect.NameTransformer
import NameTransformer._
-import scala.reflect.{mirror => rm}
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.{ClassTag, classTag}
import typechecker.DestructureTypes
-import scala.tools.util.StringOps.ojoin
+import scala.reflect.internal.util.StringOps.ojoin
+import language.implicitConversions
/** A more principled system for turning types into strings.
*/
@@ -192,7 +194,7 @@ trait TypeStrings {
else enclClass.getName + "." + (name stripPrefix enclPre)
)
}
- def scalaName(m: ClassTag[_]): String = scalaName(m.erasure)
+ def scalaName(ct: ClassTag[_]): String = scalaName(ct.runtimeClass)
def anyClass(x: Any): JClass = if (x == null) null else x.getClass
private def brackets(tps: String*): String =
@@ -209,10 +211,12 @@ trait TypeStrings {
brackets(clazz.getTypeParameters map tvarString: _*)
}
- private def tparamString[T: TypeTag] : String = {
- // [Eugene to Paul] needs review!!
- def typeArguments: List[rm.Type] = typeTag[T].tpe.typeArguments
- def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => rm.typeToClass(targ))
+ private def tparamString[T: ru.TypeTag] : String = {
+ // [Eugene++ to Paul] needs review!!
+ def typeArguments: List[ru.Type] = ru.typeOf[T].typeArguments
+ // [Eugene++] todo. need to use not the `rootMirror`, but a mirror with the REPL's classloader
+ // how do I get to it? acquiring context classloader seems unreliable because of multithreading
+ def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => ru.rootMirror.runtimeClass(targ))
brackets(typeArguments map (jc => tvarString(List(jc))): _*)
}
@@ -224,10 +228,10 @@ trait TypeStrings {
* practice to rely on toString for correctness) generated the VALID string
* representation of the type.
*/
- def fromTypedValue[T: TypeTag](x: T): String = fromTag[T]
- def fromValue(value: Any): String = if (value == null) "Null" else fromClazz(anyClass(value))
- def fromClazz(clazz: JClass): String = scalaName(clazz) + tparamString(clazz)
- def fromTag[T: TypeTag] : String = scalaName(typeTag[T].erasure) + tparamString[T]
+ def fromTypedValue[T: ru.TypeTag : ClassTag](x: T): String = fromTag[T]
+ def fromValue(value: Any): String = if (value == null) "Null" else fromClazz(anyClass(value))
+ def fromClazz(clazz: JClass): String = scalaName(clazz) + tparamString(clazz)
+ def fromTag[T: ru.TypeTag : ClassTag] : String = scalaName(classTag[T].runtimeClass) + tparamString[T]
/** Reducing fully qualified noise for some common packages.
*/
diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala
index 416b84eec6..48361cd157 100644
--- a/src/compiler/scala/tools/nsc/io/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/io/Pickler.scala
@@ -4,6 +4,7 @@ import annotation.unchecked
import Lexer._
import java.io.Writer
import language.implicitConversions
+import reflect.ClassTag
/** An abstract class for writing and reading Scala objects to and
* from a legible representation. The presesentation follows the following grammar:
diff --git a/src/compiler/scala/tools/nsc/io/SourceReader.scala b/src/compiler/scala/tools/nsc/io/SourceReader.scala
index 324c5e4111..2e146becdf 100644
--- a/src/compiler/scala/tools/nsc/io/SourceReader.scala
+++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala
@@ -28,7 +28,7 @@ class SourceReader(decoder: CharsetDecoder, reporter: Reporter) {
private var chars: CharBuffer = CharBuffer.allocate(0x4000)
private def reportEncodingError(filename:String) = {
- reporter.error(util.NoPosition,
+ reporter.error(scala.reflect.internal.util.NoPosition,
"IO error while decoding "+filename+" with "+decoder.charset()+"\n"+
"Please try specifying another one using the -encoding option")
}
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index f71e067366..e2203e07b3 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -8,7 +8,7 @@
package scala.tools.nsc
package javac
-import scala.tools.nsc.util.OffsetPosition
+import scala.reflect.internal.util.OffsetPosition
import scala.collection.mutable.ListBuffer
import symtab.Flags
import JavaTokens._
diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
index d47756e757..73b5a752b4 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
@@ -6,7 +6,8 @@
package scala.tools.nsc
package javac
-import scala.tools.nsc.util._
+import scala.tools.nsc.util.JavaCharArrayReader
+import scala.reflect.internal.util._
import scala.reflect.internal.Chars._
import JavaTokens._
import scala.annotation.switch
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
index 7346d9c59f..0d1356a6b0 100644
--- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
+++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
@@ -9,7 +9,7 @@ package matching
import PartialFunction._
import scala.collection.{ mutable }
-import util.Position
+import scala.reflect.internal.util.Position
import transform.ExplicitOuter
import symtab.Flags
import mutable.ListBuffer
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 48c4a9b5b3..7f9df2235a 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
package plugins
-import io.{ File, Path }
+import io.{ File, Path, Jar }
import java.net.URLClassLoader
import java.util.jar.JarFile
import java.util.zip.ZipException
@@ -132,7 +132,8 @@ object Plugin {
val alljars = (jars ::: (for {
dir <- dirs if dir.isDirectory
entry <- dir.toDirectory.files.toList sortBy (_.name)
- if Path.isJarOrZip(entry)
+// was: if Path.isJarOrZip(entry)
+ if Jar.isJarOrZip(entry)
pdesc <- loadDescription(entry)
if !(ignoring contains pdesc.name)
} yield entry)).distinct
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index ab8fe23909..cb85e49d55 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -8,7 +8,7 @@ package reporters
import scala.collection.mutable
import scala.tools.nsc.Settings
-import scala.tools.nsc.util.Position
+import scala.reflect.internal.util.Position
/**
* This reporter implements filtering.
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 956c43c35a..dff900383e 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -7,8 +7,7 @@ package scala.tools.nsc
package reporters
import java.io.{ BufferedReader, IOException, PrintWriter }
-import util._
-import scala.tools.util.StringOps
+import scala.reflect.internal.util._
/**
* This class implements a Reporter that displays messages on a text
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 309fc5733f..303a477491 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -6,9 +6,8 @@
package scala.tools.nsc
package reporters
-import scala.tools.nsc.util._
-import scala.tools.util.StringOps
-import StringOps._
+import scala.reflect.internal.util._
+import scala.reflect.internal.util.StringOps._
/**
* This interface provides methods to issue information, warning and
@@ -78,8 +77,8 @@ abstract class Reporter {
}
// sbt compat
- @deprecated("Moved to scala.tools.util.StringOps", "2.10.0")
+ @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.tools.util.StringOps", "2.10.0")
+ @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/reporters/StoreReporter.scala b/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala
index 12edd9bf31..5c3f7b8965 100644
--- a/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package reporters
import scala.collection.mutable
-import scala.tools.nsc.util.Position
+import scala.reflect.internal.util.Position
/**
* This class implements a Reporter that displays messages on a text
diff --git a/src/compiler/scala/tools/nsc/scratchpad/Executor.scala b/src/compiler/scala/tools/nsc/scratchpad/Executor.scala
index 8a918a829c..89523df71e 100644
--- a/src/compiler/scala/tools/nsc/scratchpad/Executor.scala
+++ b/src/compiler/scala/tools/nsc/scratchpad/Executor.scala
@@ -4,7 +4,7 @@ import java.io.{PrintStream, OutputStreamWriter, Writer}
import scala.runtime.ScalaRunTime.stringOf
import java.lang.reflect.InvocationTargetException
-import scala.reflect.ReflectionUtils._
+import scala.reflect.runtime.ReflectionUtils._
object Executor {
diff --git a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
index 311aa6e324..42a35dc642 100644
--- a/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
+++ b/src/compiler/scala/tools/nsc/scratchpad/SourceInserter.scala
@@ -2,7 +2,7 @@ package scala.tools.nsc
package scratchpad
import java.io.Writer
-import util.SourceFile
+import scala.reflect.internal.util.SourceFile
import reflect.internal.Chars._
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index c4dd9a2a36..fc833e2c26 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -8,10 +8,11 @@ package scala.tools
package nsc
package settings
-import io.{ AbstractFile, Path, PlainFile, VirtualDirectory }
-import scala.tools.util.StringOps
+import io.{ AbstractFile, Jar, Path, PlainFile, VirtualDirectory }
+import scala.reflect.internal.util.StringOps
import scala.collection.mutable.ListBuffer
import scala.io.Source
+import scala.reflect.{ ClassTag, classTag }
/** A mutable Settings object.
*/
@@ -184,7 +185,7 @@ class MutableSettings(val errorFn: String => Unit)
* and `boot.class.path`. These resources should contain the application
* and boot classpaths in the same form as would be passed on the command line.*/
def embeddedDefaults[T: ClassTag]: Unit =
- embeddedDefaults(classTag[T].erasure.getClassLoader)
+ embeddedDefaults(classTag[T].runtimeClass.getClassLoader)
/** Initializes these settings for embedded use by a class from the given class loader.
* The class loader for `T` should provide resources `app.class.path`
@@ -254,7 +255,8 @@ class MutableSettings(val errorFn: String => Unit)
private def checkDir(dir: AbstractFile, name: String, allowJar: Boolean = false): AbstractFile = (
if (dir != null && dir.isDirectory)
dir
- else if (allowJar && dir == null && Path.isJarOrZip(name, false))
+// was: else if (allowJar && dir == null && Path.isJarOrZip(name, false))
+ else if (allowJar && dir == null && Jar.isJarOrZip(name, false))
new PlainFile(Path(name))
else
throw new FatalError(name + " does not exist or is not a directory")
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 4aa30038f6..04acba06e8 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -82,7 +82,6 @@ trait ScalaSettings extends AbsScalaSettings
val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more detail on why some implicits are not applicable.")
val logImplicitConv = BooleanSetting ("-Xlog-implicit-conversions", "Print a message whenever an implicit conversion is inserted.")
val logReflectiveCalls = BooleanSetting("-Xlog-reflective-calls", "Print a message when a reflective method call is generated")
- val logRuntimeSplices = BooleanSetting("-Xlog-runtime-splices", "Print a message when Expr.eval or Expr.value cannot be resolved statically.")
val logFreeTerms = BooleanSetting ("-Xlog-free-terms", "Print a message when reification creates a free term.")
val logFreeTypes = BooleanSetting ("-Xlog-free-types", "Print a message when reification resorts to generating a free type.")
val maxClassfileName = IntSetting ("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, Some((72, 255)), _ => None)
@@ -109,6 +108,8 @@ trait ScalaSettings extends AbsScalaSettings
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
val XoldPatmat = BooleanSetting ("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.")
+ val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")
+ val XfullLubs = BooleanSetting ("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.")
/** Compatibility stubs for options whose value name did
* not previously match the option name.
@@ -171,6 +172,7 @@ trait ScalaSettings extends AbsScalaSettings
val Ynotnull = BooleanSetting ("-Ynotnull", "Enable (experimental and incomplete) scala.NotNull.")
val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overriden methods.")
val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.")
+ val Yinvalidate = StringSetting ("-Yinvalidate", "classpath-entry", "Invalidate classpath entry before run", "")
val noSelfCheck = BooleanSetting ("-Yno-self-type-checks", "Suppress check for self-type conformance among inherited members.")
val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes")
@@ -201,7 +203,6 @@ trait ScalaSettings extends AbsScalaSettings
val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enabling experimentalSettings
// Feature extensions
- val Xmacros = BooleanSetting("-Xmacros", "Enable macros.") // [Martin] Can be retired now.
val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.")
val XmacroPrimaryClasspath = PathSetting("-Xmacro-primary-classpath", "Classpath to load macros implementations from, defaults to compilation classpath (aka \"library classpath\".", "")
val XmacroFallbackClasspath = PathSetting("-Xmacro-fallback-classpath", "Classpath to load macros implementations from if they cannot be loaded from library classpath.", "")
diff --git a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
index 5f7deb87bd..25d835790e 100644
--- a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
package symtab
-import scala.tools.nsc.util.BatchSourceFile
+import scala.reflect.internal.util.BatchSourceFile
import scala.tools.nsc.io.AbstractFile
/** A subclass of SymbolLoaders that implements browsing behavior.
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index 390b1a5ec6..15edac16d5 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -51,6 +51,46 @@ abstract class SymbolLoaders {
enterIfNew(owner, module, completer)
}
+ /** Enter package with given `name` into scope of `root`
+ * and give them `completer` as type.
+ */
+ def enterPackage(root: Symbol, name: String, completer: SymbolLoader): Symbol = {
+ val pname = newTermName(name)
+ val preExisting = root.info.decls lookup pname
+ if (preExisting != NoSymbol) {
+ // Some jars (often, obfuscated ones) include a package and
+ // object with the same name. Rather than render them unusable,
+ // offer a setting to resolve the conflict one way or the other.
+ // This was motivated by the desire to use YourKit probes, which
+ // require yjp.jar at runtime. See SI-2089.
+ if (settings.termConflict.isDefault)
+ throw new TypeError(
+ root+" contains object and package with same name: "+
+ name+"\none of them needs to be removed from classpath"
+ )
+ else if (settings.termConflict.value == "package") {
+ global.warning(
+ "Resolving package/object name conflict in favor of package " +
+ preExisting.fullName + ". The object will be inaccessible."
+ )
+ root.info.decls.unlink(preExisting)
+ }
+ else {
+ global.warning(
+ "Resolving package/object name conflict in favor of object " +
+ preExisting.fullName + ". The package will be inaccessible."
+ )
+ return NoSymbol
+ }
+ }
+ // todo: find out initialization sequence for pkg/pkg.moduleClass is different from enterModule
+ val pkg = root.newPackage(pname)
+ pkg.moduleClass setInfo completer
+ pkg setInfo pkg.moduleClass.tpe
+ root.info.decls enter pkg
+ pkg
+ }
+
/** Enter class and module with given `name` into scope of `root`
* and give them `completer` as type.
*/
@@ -171,40 +211,6 @@ abstract class SymbolLoaders {
class PackageLoader(classpath: ClassPath[platform.BinaryRepr]) extends SymbolLoader {
protected def description = "package loader "+ classpath.name
- def enterPackage(root: Symbol, name: String, completer: SymbolLoader) {
- val preExisting = root.info.decls.lookup(newTermName(name))
- if (preExisting != NoSymbol) {
- // Some jars (often, obfuscated ones) include a package and
- // object with the same name. Rather than render them unusable,
- // offer a setting to resolve the conflict one way or the other.
- // This was motivated by the desire to use YourKit probes, which
- // require yjp.jar at runtime. See SI-2089.
- if (settings.termConflict.isDefault)
- throw new TypeError(
- root+" contains object and package with same name: "+
- name+"\none of them needs to be removed from classpath"
- )
- else if (settings.termConflict.value == "package") {
- global.warning(
- "Resolving package/object name conflict in favor of package " +
- preExisting.fullName + ". The object will be inaccessible."
- )
- root.info.decls.unlink(preExisting)
- }
- else {
- global.warning(
- "Resolving package/object name conflict in favor of object " +
- preExisting.fullName + ". The package will be inaccessible."
- )
- return
- }
- }
- val pkg = root.newPackage(newTermName(name))
- pkg.moduleClass.setInfo(completer)
- pkg.setInfo(pkg.moduleClass.tpe)
- root.info.decls.enter(pkg)
- }
-
protected def doComplete(root: Symbol) {
assert(root.isPackageClass, root)
root.setInfo(new PackageClassInfoType(newScope, root))
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 7373a610d7..d8bf23f4fe 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -183,7 +183,7 @@ abstract class ClassfileParser {
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
if (nme.isModuleName(name))
- c = definitions.getModule(nme.stripModuleSuffix(name))
+ c = rootMirror.getModule(nme.stripModuleSuffix(name))
else
c = classNameToSymbol(name)
@@ -234,7 +234,7 @@ abstract class ClassfileParser {
//assert(name.endsWith("$"), "Not a module class: " + name)
f = forceMangledName(name dropRight 1, true)
if (f == NoSymbol)
- f = definitions.getModule(name dropRight 1)
+ f = rootMirror.getModule(name dropRight 1)
} else {
val origName = nme.originalName(name)
val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol
@@ -417,7 +417,7 @@ abstract class ClassfileParser {
*/
def forceMangledName(name: Name, module: Boolean): Symbol = {
val parts = name.decode.toString.split(Array('.', '$'))
- var sym: Symbol = definitions.RootClass
+ var sym: Symbol = rootMirror.RootClass
// was "at flatten.prev"
beforeFlatten {
@@ -445,7 +445,7 @@ abstract class ClassfileParser {
return NoSymbol.newClass(name.toTypeName)
}
val completer = new global.loaders.ClassfileLoader(file)
- var owner: Symbol = definitions.RootClass
+ var owner: Symbol = rootMirror.RootClass
var sym: Symbol = NoSymbol
var ss: Name = null
var start = 0
@@ -473,9 +473,9 @@ abstract class ClassfileParser {
def lookupClass(name: Name) = try {
if (name.pos('.') == name.length)
- definitions.getMember(definitions.EmptyPackageClass, name.toTypeName)
+ definitions.getMember(rootMirror.EmptyPackageClass, name.toTypeName)
else
- definitions.getClass(name) // see tickets #2464, #3756
+ rootMirror.getClass(name) // see tickets #2464, #3756
} catch {
case _: FatalError => loadClassSymbol(name)
}
@@ -919,7 +919,7 @@ abstract class ClassfileParser {
val srcfileLeaf = pool.getName(in.nextChar).toString.trim
val srcpath = sym.enclosingPackage match {
case NoSymbol => srcfileLeaf
- case definitions.EmptyPackage => srcfileLeaf
+ case rootMirror.EmptyPackage => srcfileLeaf
case pkg => pkg.fullName(File.separatorChar)+File.separator+srcfileLeaf
}
srcfile0 = settings.outputDirs.srcFilesFor(in.file, srcpath).find(_.exists)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 862a3ffdc7..bb9f9bde98 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -165,21 +165,21 @@ abstract class ICodeReader extends ClassfileParser {
else if (name == fulltpnme.RuntimeNull)
definitions.NullClass
else if (nme.isImplClassName(name)) {
- val iface = definitions.getClass(tpnme.interfaceName(name))
+ val iface = rootMirror.getClassByName(tpnme.interfaceName(name))
log("forcing " + iface.owner + " at phase: " + phase + " impl: " + iface.implClass)
iface.owner.info // force the mixin type-transformer
- definitions.getClass(name)
+ rootMirror.getClassByName(name)
}
else if (nme.isModuleName(name)) {
val strippedName = nme.stripModuleSuffix(name)
val sym = forceMangledName(newTermName(strippedName.decode), true)
- if (sym == NoSymbol) definitions.getModule(strippedName)
+ if (sym == NoSymbol) rootMirror.getModule(strippedName)
else sym
}
else {
forceMangledName(name, false)
- afterFlatten(definitions.getClass(name.toTypeName))
+ afterFlatten(rootMirror.getClassByName(name.toTypeName))
}
if (sym.isModule)
sym.moduleClass
diff --git a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala
index 7be0fcb146..d3b6c9238d 100644
--- a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala
+++ b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala
@@ -12,7 +12,7 @@ import java.util.{Comparator, StringTokenizer}
import scala.util.Sorting
import ch.epfl.lamp.compiler.msil._
import scala.collection.{ mutable, immutable }
-import scala.tools.nsc.util.{Position, NoPosition}
+import scala.reflect.internal.util.{Position, NoPosition}
/**
* Collects all types from all reference assemblies.
diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
index 028d6f2484..e54ecdd590 100644
--- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
@@ -653,7 +653,7 @@ abstract class TypeParser {
private def getClassType(typ: MSILType): Type = {
assert(typ != null);
- val res = definitions.getClass(typ.FullName.replace('+', '.')).tpe;
+ val res = rootMirror.getClassByName(typ.FullName.replace('+', '.')).tpe;
//if (res.isError())
// global.reporter.error("unknown class reference " + type.FullName);
res
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index bf01e142c9..bbdf10a021 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -678,7 +678,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
// need to create a new block with inits and the old term
treeCopy.Block(term, newStaticInits.toList, term)
}
- case None =>
+ case _ =>
// create new static ctor
val staticCtorSym = currentClass.newStaticConstructor(template.pos)
val rhs = Block(newStaticInits.toList, Literal(Constant(())))
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index ea66dbedd6..ce16facf77 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -638,7 +638,6 @@ abstract class Erasure extends AddInterfaces
*/
private def adaptMember(tree: Tree): Tree = {
//Console.println("adaptMember: " + tree);
- val x = 2 + 2
tree match {
case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List())
if tree.symbol == Any_asInstanceOf =>
@@ -967,7 +966,7 @@ abstract class Erasure extends AddInterfaces
}
// Rewrite 5.getClass to ScalaRunTime.anyValClass(5)
else if (isPrimitiveValueClass(qual.tpe.typeSymbol))
- global.typer.typed(gen.mkRuntimeCall(nme.anyValClass, List(qual, typer.resolveErasureTag(qual.tpe.widen, tree.pos, true))))
+ global.typer.typed(gen.mkRuntimeCall(nme.anyValClass, List(qual, typer.resolveClassTag(tree.pos, qual.tpe.widen))))
else
tree
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index 9cffb6a1e1..1b8513373d 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -385,7 +385,7 @@ abstract class ExplicitOuter extends InfoTransform
method setInfo new MethodType(params, BooleanClass.tpe)
localTyper typed {
- DEF(method) === guard.changeOwner(currentOwner -> method).substTreeSyms(vs zip params: _*)
+ DEF(method) === guard.changeOwner(currentOwner -> method).substituteSymbols(vs, params)
}
}
@@ -410,18 +410,15 @@ abstract class ExplicitOuter extends InfoTransform
(CASE(transform(strippedPat)) IF gdcall) ==> transform(body)
}
- def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation UncheckedClass
- def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation SwitchClass
-
val (checkExhaustive, requireSwitch) = nselector match {
case Typed(nselector1, tpt) =>
- val unchecked = isUncheckedAnnotation(tpt.tpe)
+ val unchecked = treeInfo.isUncheckedAnnotation(tpt.tpe)
if (unchecked)
nselector = nselector1
// Don't require a tableswitch if there are 1-2 casedefs
// since the matcher intentionally emits an if-then-else.
- (!unchecked, isSwitchAnnotation(tpt.tpe) && ncases.size > 2)
+ (!unchecked, treeInfo.isSwitchAnnotation(tpt.tpe) && ncases.size > 2)
case _ =>
(true, false)
}
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
index 007457ef7b..1c97eaad8b 100644
--- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -44,8 +44,18 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
* in `extensionMethod` if the first name has the wrong type. We thereby gain a level of insensitivity
* of how overloaded types are ordered between phases and picklings.
*/
- private def extensionNames(imeth: Symbol): Stream[Name] =
- imeth.owner.info.decl(imeth.name).tpe match {
+ private def extensionNames(imeth: Symbol): Stream[Name] = {
+ val decl = imeth.owner.info.decl(imeth.name)
+
+ // Bridge generation is done at phase `erasure`, but new scopes are only generated
+ // for the phase after that. So bridges are visible in earlier phases.
+ //
+ // `info.member(imeth.name)` filters these out, but we need to use `decl`
+ // to restrict ourselves to members defined in the current class, so we
+ // must do the filtering here.
+ val declTypeNoBridge = decl.filter(sym => !sym.isBridge).tpe
+
+ declTypeNoBridge match {
case OverloadedType(_, alts) =>
val index = alts indexOf imeth
assert(index >= 0, alts+" does not contain "+imeth)
@@ -55,6 +65,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls)
Stream(newTermName("extension$"+imeth.name))
}
+ }
/** Return the extension method that corresponds to given instance method `meth`.
*/
@@ -66,11 +77,26 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
matching.head
}
+ /** This method removes the `$this` argument from the parameter list a method.
+ *
+ * A method may be a `PolyType`, in which case we tear out the `$this` and the class
+ * type params from its nested `MethodType`.
+ * It may be a `MethodType`, either with a curried parameter list in which the first argument
+ * is a `$this` - we just return the rest of the list.
+ * This means that the corresponding symbol was generated during `extmethods`.
+ *
+ * It may also be a `MethodType` in which the `$this` does not appear in a curried parameter list.
+ * The curried lists disappear during `uncurry`, and the methods may be duplicated afterwards,
+ * for instance, during `specialize`.
+ * In this case, the first argument is `$this` and we just get rid of it.
+ */
private def normalize(stpe: Type, clazz: Symbol): Type = stpe match {
case PolyType(tparams, restpe) =>
GenPolyType(tparams dropRight clazz.typeParams.length, normalize(restpe.substSym(tparams takeRight clazz.typeParams.length, clazz.typeParams), clazz))
- case MethodType(tparams, restpe) =>
+ case MethodType(List(thiz), restpe) if thiz.name == nme.SELF =>
restpe
+ case MethodType(tparams, restpe) =>
+ MethodType(tparams.drop(1), restpe)
case _ =>
stpe
}
@@ -127,9 +153,9 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
val GenPolyType(extensionTpeParams, extensionMono) = extensionMeth.info
val origTpeParams = (tparams map (_.symbol)) ::: currentOwner.typeParams
val extensionBody = rhs
- .substTreeSyms(origTpeParams, extensionTpeParams)
- .substTreeSyms(vparamss.flatten map (_.symbol), allParams(extensionMono).tail)
- .substTreeThis(currentOwner, thisParamRef)
+ .substituteSymbols(origTpeParams, extensionTpeParams)
+ .substituteSymbols(vparamss.flatten map (_.symbol), allParams(extensionMono).tail)
+ .substituteThis(currentOwner, thisParamRef)
.changeOwner((origMeth, extensionMeth))
extensionDefs(companion) += atPos(tree.pos) { DefDef(extensionMeth, extensionBody) }
val extensionCallPrefix = Apply(
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 79b9317f20..fe5bef5009 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -477,7 +477,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
/** The rootContext used for typing */
private val rootContext =
- erasure.NoContext.make(EmptyTree, RootClass, newScope)
+ erasure.NoContext.make(EmptyTree, rootMirror.RootClass, newScope)
/** The typer */
private var localTyper: erasure.Typer = _
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index f2e109a5ad..4b488a6437 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -9,6 +9,7 @@ package transform
import scala.tools.nsc.symtab.Flags
import scala.collection.{ mutable, immutable }
import language.postfixOps
+import language.existentials
/** Specialize code on types.
*
@@ -66,11 +67,12 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
private implicit val typeOrdering: Ordering[Type] = Ordering[String] on ("" + _.typeSymbol.name)
import definitions.{
- RootClass, BooleanClass, UnitClass, ArrayClass,
+ BooleanClass, UnitClass, ArrayClass,
ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType,
SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule,
GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass
}
+ import rootMirror.RootClass
/** TODO - this is a lot of maps.
*/
@@ -434,7 +436,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val sClassMap = anyrefSpecCache.getOrElseUpdate(sClass, mutable.Map[Symbol, Symbol]())
sClassMap.getOrElseUpdate(tparam,
- tparam.cloneSymbol(sClass, tparam.flags, tparam.name append tpnme.SPECIALIZED_SUFFIX)
+ tparam.cloneSymbol(sClass, tparam.flags, (tparam.name append tpnme.SPECIALIZED_SUFFIX).asInstanceOf[Name]) // [Eugene++] why do we need this cast?
modifyInfo (info => TypeBounds(info.bounds.lo, AnyRefClass.tpe))
).tpe
}
@@ -821,6 +823,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
debuglog("%s expands to %s in %s".format(sym, specMember.name.decode, pp(env)))
info(specMember) = NormalizedMember(sym)
overloads(sym) ::= Overload(specMember, env)
+ owner.info.decls.enter(specMember)
specMember
}
}
@@ -1693,9 +1696,12 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
}
- private def forwardCall(pos: util.Position, receiver: Tree, paramss: List[List[ValDef]]): Tree = {
+ private def forwardCall(pos: scala.reflect.internal.util.Position, receiver: Tree, paramss: List[List[ValDef]]): Tree = {
val argss = mmap(paramss)(x => Ident(x.symbol))
- atPos(pos) { (receiver /: argss) (Apply) }
+ def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
+ atPos(pos) { (receiver /: argss) (mkApply) }
+ // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
+ // atPos(pos) { (receiver /: argss) (Apply) }
}
/** Forward to the generic class constructor. If the current class initializes
@@ -1717,7 +1723,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
* }
* }}
*/
- private def forwardCtorCall(pos: util.Position, receiver: Tree, paramss: List[List[ValDef]], clazz: Symbol): Tree = {
+ private def forwardCtorCall(pos: scala.reflect.internal.util.Position, receiver: Tree, paramss: List[List[ValDef]], clazz: Symbol): Tree = {
/** A constructor parameter `f` initializes a specialized field
* iff:
@@ -1737,7 +1743,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
else
Ident(x.symbol)
)
- atPos(pos) { (receiver /: argss) (Apply) }
+ def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
+ atPos(pos) { (receiver /: argss) (mkApply) }
+ // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
+ // atPos(pos) { (receiver /: argss) (Apply) }
}
/** Add method m to the set of symbols for which we need an implementation tree
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 8af12f3f10..663b3dd2e9 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -418,23 +418,23 @@ abstract class UnCurry extends InfoTransform
def sequenceToArray(tree: Tree) = {
val toArraySym = tree.tpe member nme.toArray
assert(toArraySym != NoSymbol)
- def getArrayTag(tp: Type): Tree = {
- val tag = localTyper.resolveArrayTag(tp, tree.pos)
+ def getClassTag(tp: Type): Tree = {
+ val tag = localTyper.resolveClassTag(tree.pos, tp)
// Don't want bottom types getting any further than this (SI-4024)
- if (tp.typeSymbol.isBottomClass) getArrayTag(AnyClass.tpe)
+ if (tp.typeSymbol.isBottomClass) getClassTag(AnyClass.tpe)
else if (!tag.isEmpty) tag
- else if (tp.bounds.hi ne tp) getArrayTag(tp.bounds.hi)
- else localTyper.TyperErrorGen.MissingArrayTagError(tree, tp)
+ else if (tp.bounds.hi ne tp) getClassTag(tp.bounds.hi)
+ else localTyper.TyperErrorGen.MissingClassTagError(tree, tp)
}
- def traversableArrayTag(tpe: Type): Tree = {
+ def traversableClassTag(tpe: Type): Tree = {
(tpe baseType TraversableClass).typeArgs match {
- case targ :: _ => getArrayTag(targ)
+ case targ :: _ => getClassTag(targ)
case _ => EmptyTree
}
}
afterUncurry {
localTyper.typedPos(pos) {
- gen.mkMethodCall(tree, toArraySym, Nil, List(traversableArrayTag(tree.tpe)))
+ gen.mkMethodCall(tree, toArraySym, Nil, List(traversableClassTag(tree.tpe)))
}
}
}
@@ -688,7 +688,7 @@ abstract class UnCurry extends InfoTransform
tree match {
/* Some uncurry post transformations add members to templates.
- *
+ *
* Members registered by `addMembers` for the current template are added
* once the template transformation has finished.
*
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index affa9cd63b..a2f0e053a8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package typechecker
import scala.collection.{ mutable, immutable }
-import scala.tools.util.StringOps.{ countElementsAsString, countAsString }
+import scala.reflect.internal.util.StringOps.{ countElementsAsString, countAsString }
import symtab.Flags.{ PRIVATE, PROTECTED }
trait ContextErrors {
@@ -562,9 +562,9 @@ trait ContextErrors {
def AbstractExistentiallyOverParamerizedTpeError(tree: Tree, tp: Type) =
issueNormalTypeError(tree, "can't existentially abstract over parameterized type " + tp)
- // resolveArrayTag
- def MissingArrayTagError(tree: Tree, tp: Type) = {
- issueNormalTypeError(tree, "cannot find array tag for element type "+tp)
+ // resolveClassTag
+ def MissingClassTagError(tree: Tree, tp: Type) = {
+ issueNormalTypeError(tree, "cannot find class tag for element type "+tp)
setError(tree)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index f4f081252f..ac3c94c47a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -30,9 +30,9 @@ trait Contexts { self: Analyzer =>
private val startContext = {
NoContext.make(
- global.Template(List(), emptyValDef, List()) setSymbol global.NoSymbol setType global.NoType,
- global.definitions.RootClass,
- global.definitions.RootClass.info.decls)
+ Template(List(), emptyValDef, List()) setSymbol global.NoSymbol setType global.NoType,
+ rootMirror.RootClass,
+ rootMirror.RootClass.info.decls)
}
var lastAccessCheckDetails: String = ""
@@ -543,7 +543,7 @@ trait Contexts { self: Analyzer =>
(pre == NoPrefix) || {
val ab = sym.accessBoundary(sym.owner)
- ( (ab.isTerm || ab == definitions.RootClass)
+ ( (ab.isTerm || ab == rootMirror.RootClass)
|| (accessWithin(ab) || accessWithinLinked(ab)) &&
( !sym.hasLocalFlag
|| sym.owner.isImplClass // allow private local accesses to impl classes
diff --git a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
index 0b414801d6..5802d36878 100644
--- a/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc
package typechecker
+import language.implicitConversions
+
/** A generic means of breaking down types into their subcomponents.
* Types are decomposed top down, and recognizable substructure is
* dispatched via self-apparently named methods. Those methods can
@@ -64,7 +66,7 @@ trait DestructureTypes {
case x: NameTree => atom(x.name.toString, x)
case _ => wrapAtom(tree)
},
- tree.printingPrefix
+ tree.productPrefix
)
def wrapSymbol(label: String, sym: Symbol): Node = {
if (sym eq NoSymbol) wrapEmpty
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index a671b8d6b5..aa63f3ec31 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -17,6 +17,7 @@ import mutable.{ LinkedHashMap, ListBuffer }
import scala.util.matching.Regex
import symtab.Flags._
import util.Statistics._
+import language.implicitConversions
/** This trait provides methods to find various kinds of implicits.
*
@@ -335,7 +336,7 @@ trait Implicits {
* The _complexity_ of a stripped core type corresponds roughly to the number of
* nodes in its ast, except that singleton types are widened before taking the complexity.
* Two types overlap if they have the same type symbol, or
- * if one or both are intersection types with a pair of overlapiing parent types.
+ * if one or both are intersection types with a pair of overlapping parent types.
*/
private def dominates(dtor: Type, dted: Type): Boolean = {
def core(tp: Type): Type = tp.normalize match {
@@ -346,7 +347,11 @@ trait Implicits {
case _ => tp
}
def stripped(tp: Type): Type = {
- deriveTypeWithWildcards(freeTypeParametersNoSkolems.collect(tp))(tp)
+ // `t.typeSymbol` returns the symbol of the normalized type. If that normalized type
+ // is a `PolyType`, the symbol of the result type is collected. This is precisely
+ // what we require for SI-5318.
+ 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.normalize match {
@@ -1128,11 +1133,9 @@ trait Implicits {
private def TagSymbols = TagMaterializers.keySet
private val TagMaterializers = Map[Symbol, Symbol](
- ArrayTagClass -> MacroInternal_materializeArrayTag,
- ErasureTagClass -> MacroInternal_materializeErasureTag,
- ClassTagClass -> MacroInternal_materializeClassTag,
- TypeTagClass -> MacroInternal_materializeTypeTag,
- ConcreteTypeTagClass -> MacroInternal_materializeConcreteTypeTag
+ ClassTagClass -> MacroInternal_materializeClassTag,
+ AbsTypeTagClass -> MacroInternal_materializeAbsTypeTag,
+ TypeTagClass -> MacroInternal_materializeTypeTag
)
/** Creates a tree will produce a tag of the requested flavor.
@@ -1162,9 +1165,8 @@ trait Implicits {
}
val prefix = (
- // ClassTags only exist for scala.reflect.mirror, so their materializer
- // doesn't care about prefixes
- if ((tagClass eq ArrayTagClass) || (tagClass eq ErasureTagClass) || (tagClass eq ClassTagClass)) ReflectMirrorPrefix
+ // ClassTags are not path-dependent, so their materializer doesn't care about prefixes
+ if (tagClass eq ClassTagClass) gen.mkBasisUniverseRef
else pre match {
// [Eugene to Martin] this is the crux of the interaction between
// implicits and reifiers here we need to turn a (supposedly
@@ -1179,16 +1181,24 @@ trait Implicits {
// if ``pre'' is not a PDT, e.g. if someone wrote
// implicitly[scala.reflect.makro.Context#TypeTag[Int]]
// then we need to fail, because we don't know the prefix to use during type reification
- return failure(tp, "tag error: unsupported prefix type %s (%s)".format(pre, pre.kind))
+ // 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
+ // so that if we find one, we could convert it to whatever universe we need by the means of the `in` method
+ // if no tag is found in scope, we end up here, where we ask someone to materialize the tag for us
+ // however, since the original search was about a tag with no particular prefix, we cannot proceed
+ // this situation happens very often, so emitting an error message here (even if only for -Xlog-implicits) would be too much
+ //return failure(tp, "tag error: unsupported prefix type %s (%s)".format(pre, pre.kind))
+ return SearchFailure
}
)
// todo. migrate hardcoded materialization in Implicits to corresponding implicit macros
- var materializer = atPos(pos.focus)(
- gen.mkMethodCall(TagMaterializers(tagClass), List(tp), List(prefix))
- )
+ var materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), List(prefix)))
if (settings.XlogImplicits.value) println("materializing requested %s.%s[%s] using %s".format(pre, tagClass.name, tp, materializer))
if (context.macrosEnabled) success(materializer)
- else failure(materializer, "macros are disabled")
+ // don't call `failure` here. if macros are disabled, we just fail silently
+ // otherwise -Xlog-implicits will spam the long with zillions of "macros are disabled"
+ // this is ugly but temporary, since all this code will be removed once I fix implicit macros
+ else SearchFailure
}
private val ManifestSymbols = Set[Symbol](PartialManifestClass, FullManifestClass, OptManifestClass)
@@ -1283,13 +1293,33 @@ trait Implicits {
}
val tagInScope =
- if (full) context.withMacrosDisabled(resolveTypeTag(ReflectMirrorPrefix.tpe, tp, pos, true))
- else context.withMacrosDisabled(resolveArrayTag(tp, pos))
+ if (full) resolveTypeTag(pos, NoType, tp, concrete = true, allowMaterialization = false)
+ else resolveClassTag(pos, tp, allowMaterialization = false)
if (tagInScope.isEmpty) mot(tp, Nil, Nil)
else {
+ if (full) {
+ if (ReflectRuntimeUniverse == NoSymbol) {
+ // todo. write a test for this
+ context.error(pos, s"""
+ |to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
+ |however typetag -> manifest conversion requires Scala reflection, which is not present on the classpath.
+ |to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin)
+ return SearchFailure
+ }
+ if (resolveClassTag(pos, tp, allowMaterialization = true) == EmptyTree) {
+ context.error(pos, s"""
+ |to create a manifest here, it is necessary to interoperate with the type tag `$tagInScope` in scope.
+ |however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
+ |to proceed add a class tag to the type `$tp` (e.g. by introducing a context bound) and recompile.""".trim.stripMargin)
+ return SearchFailure
+ }
+ }
+
val interop =
- if (full) gen.mkMethodCall(ReflectPackage, nme.concreteTypeTagToManifest, List(tp), List(tagInScope))
- else gen.mkMethodCall(ReflectPackage, nme.arrayTagToClassManifest, List(tp), List(tagInScope))
+ if (full) {
+ val cm = typed(Ident(ReflectRuntimeCurrentMirror))
+ gen.mkMethodCall(ReflectRuntimeUniverse, nme.typeTagToManifest, List(tp), List(cm, tagInScope))
+ } else gen.mkMethodCall(ReflectRuntimeUniverse, nme.classTagToClassManifest, List(tp), List(tagInScope))
wrapResult(interop)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index abe77ead9a..9e371dd2dd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -187,7 +187,7 @@ trait Infer {
tp1 // @MAT aliases already handled by subtyping
}
- private val stdErrorClass = RootClass.newErrorClass(tpnme.ERROR)
+ private val stdErrorClass = rootMirror.RootClass.newErrorClass(tpnme.ERROR)
private val stdErrorValue = stdErrorClass.newErrorValue(nme.ERROR)
/** The context-dependent inferencer part */
@@ -1088,7 +1088,7 @@ trait Infer {
*/
def inferConstructorInstance(tree: Tree, undetparams: List[Symbol], pt0: Type) {
val pt = widen(pt0)
- val ptparams = freeTypeParamsOfTerms.collect(pt)
+ val ptparams = freeTypeParamsOfTerms(pt)
val ctorTp = tree.tpe
val resTp = ctorTp.finalResultType
@@ -1247,7 +1247,10 @@ trait Infer {
check(tp, Nil)
}
- def checkCheckable(tree: Tree, tp: Type, kind: String) {
+ // if top-level abstract types can be checked using a classtag extractor, don't warn about them
+ def checkCheckable(tree: Tree, tp: Type, inPattern: Boolean, canRemedy: Boolean = false) = {
+ val kind = if (inPattern) "pattern " else ""
+
def patternWarning(tp0: Type, prefix: String) = {
context.unit.uncheckedWarning(tree.pos, prefix+tp0+" in type "+kind+tp+" is unchecked since it is eliminated by erasure")
}
@@ -1264,7 +1267,8 @@ trait Infer {
check(pre, bound)
case TypeRef(pre, sym, args) =>
if (sym.isAbstractType) {
- if (!isLocalBinding(sym)) patternWarning(tp, "abstract type ")
+ // we only use the extractor for top-level type tests, type arguments (see below) remain unchecked
+ if (!isLocalBinding(sym) && !canRemedy) patternWarning(tp, "abstract type ")
} else if (sym.isAliasType) {
check(tp.normalize, bound)
} else if (sym == NothingClass || sym == NullClass || sym == AnyValClass) {
@@ -1320,10 +1324,10 @@ trait Infer {
}
}
- def inferTypedPattern(tree0: Tree, pattp: Type, pt0: Type): Type = {
+ def inferTypedPattern(tree0: Tree, pattp: Type, pt0: Type, canRemedy: Boolean): Type = {
val pt = widen(pt0)
- val ptparams = freeTypeParamsOfTerms.collect(pt)
- val tpparams = freeTypeParamsOfTerms.collect(pattp)
+ val ptparams = freeTypeParamsOfTerms(pt)
+ val tpparams = freeTypeParamsOfTerms(pattp)
def ptMatchesPattp = pt matchesPattern pattp.widen
def pattpMatchesPt = pattp matchesPattern pt
@@ -1337,7 +1341,7 @@ trait Infer {
return ErrorType
}
- checkCheckable(tree0, pattp, "pattern ")
+ checkCheckable(tree0, pattp, inPattern = true, canRemedy)
if (pattp <:< pt) ()
else {
debuglog("free type params (1) = " + tpparams)
@@ -1376,7 +1380,7 @@ trait Infer {
def inferModulePattern(pat: Tree, pt: Type) =
if (!(pat.tpe <:< pt)) {
- val ptparams = freeTypeParamsOfTerms.collect(pt)
+ val ptparams = freeTypeParamsOfTerms(pt)
debuglog("free type params (2) = " + ptparams)
val ptvars = ptparams map freshVar
val pt1 = pt.instantiateTypeParams(ptparams, ptvars)
@@ -1393,19 +1397,6 @@ trait Infer {
}
}
- abstract class SymCollector extends TypeCollector(List[Symbol]()) {
- protected def includeCondition(sym: Symbol): Boolean
-
- def traverse(tp: Type) {
- tp.normalize match {
- case TypeRef(_, sym, _) =>
- if (includeCondition(sym) && !result.contains(sym)) result = sym :: result
- case _ =>
- }
- mapOver(tp)
- }
- }
-
object approximateAbstracts extends TypeMap {
def apply(tp: Type): Type = tp.normalize match {
case TypeRef(pre, sym, _) if sym.isAbstractType => WildcardType
@@ -1413,31 +1404,30 @@ trait Infer {
}
}
- /** A traverser to collect type parameters referred to in a type
+ /** Collects type parameters referred to in a type.
*/
- object freeTypeParamsOfTerms extends SymCollector {
+ def freeTypeParamsOfTerms(tp: Type): List[Symbol] = {
// An inferred type which corresponds to an unknown type
// constructor creates a file/declaration order-dependent crasher
// situation, the behavior of which depends on the state at the
// time the typevar is created. Until we can deal with these
// properly, we can avoid it by ignoring type parameters which
// have type constructors amongst their bounds. See SI-4070.
- protected def includeCondition(sym: Symbol) = (
- sym.isAbstractType
- && sym.owner.isTerm
- && !sym.info.bounds.exists(_.typeParams.nonEmpty)
- )
- }
-
- /** A traverser to collect type parameters referred to in a type
- */
- object freeTypeParametersNoSkolems extends SymCollector {
- protected def includeCondition(sym: Symbol): Boolean =
- sym.isTypeParameter && sym.owner.isTerm
- }
+ def isFreeTypeParamOfTerm(sym: Symbol) = (
+ sym.isAbstractType
+ && sym.owner.isTerm
+ && !sym.info.bounds.exists(_.typeParams.nonEmpty)
+ )
- object typeRefs extends SymCollector {
- protected def includeCondition(sym: Symbol): Boolean = true
+ // Intentionally *not* using `Type#typeSymbol` here, which would normalize `tp`
+ // and collect symbols from the result type of any resulting `PolyType`s, which
+ // are not free type parameters of `tp`.
+ //
+ // Contrast with `isFreeTypeParamNoSkolem`.
+ val syms = tp collect {
+ case TypeRef(_, sym, _) if isFreeTypeParamOfTerm(sym) => sym
+ }
+ syms.distinct
}
/* -- Overload Resolution ---------------------------------------------- */
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index c10901cdce..ec14476d1a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -4,13 +4,13 @@ package typechecker
import symtab.Flags._
import scala.tools.nsc.util._
import scala.tools.nsc.util.ClassPath._
-import scala.reflect.ReflectionUtils
+import scala.reflect.runtime.ReflectionUtils
import scala.collection.mutable.ListBuffer
import scala.compat.Platform.EOL
-import scala.reflect.makro.runtime.{Context => MacroContext}
-import scala.reflect.runtime.Mirror
import util.Statistics._
import scala.reflect.makro.util._
+import java.lang.{Class => jClass}
+import java.lang.reflect.{Array => jArray, Method => jMethod}
/**
* Code to deal with macros, namely with:
@@ -26,7 +26,7 @@ import scala.reflect.makro.util._
* def fooBar[T: c.TypeTag]
* (c: scala.reflect.makro.Context)
* (xs: c.Expr[List[T]])
- * : c.mirror.Tree = {
+ * : c.Tree = {
* ...
* }
*
@@ -37,7 +37,7 @@ import scala.reflect.makro.util._
* (Expr(elems))
* (TypeTag(Int))
*/
-trait Macros extends Traces {
+trait Macros extends scala.tools.reflect.FastTrack with Traces {
self: Analyzer =>
import global._
@@ -104,7 +104,7 @@ trait Macros extends Traces {
RepeatedParamClass.typeConstructor,
List(implType(isType, sigma(origTpe.typeArgs.head))))
else {
- val tsym = getMember(MacroContextClass, if (isType) tpnme.TypeTag else tpnme.Expr)
+ val tsym = getMember(MacroContextClass, if (isType) tpnme.AbsTypeTag else tpnme.Expr)
typeRef(singleType(NoPrefix, ctxParam), tsym, List(sigma(origTpe)))
}
val paramCache = collection.mutable.Map[Symbol, Symbol]()
@@ -155,7 +155,7 @@ trait Macros extends Traces {
case TypeRef(SingleType(NoPrefix, contextParam), sym, List(tparam)) =>
var wannabe = sym
while (wannabe.isAliasType) wannabe = wannabe.info.typeSymbol
- if (wannabe != definitions.TypeTagClass && wannabe != definitions.ConcreteTypeTagClass)
+ if (wannabe != definitions.AbsTypeTagClass && wannabe != definitions.TypeTagClass)
List(param)
else
transform(param, tparam.typeSymbol) map (_ :: Nil) getOrElse Nil
@@ -185,7 +185,14 @@ trait Macros extends Traces {
import typer.context
macroLogVerbose("typechecking macro def %s at %s".format(ddef.symbol, ddef.pos))
+ if (fastTrack contains ddef.symbol) {
+ macroLogVerbose("typecheck terminated unexpectedly: macro is hardwired")
+ assert(!ddef.tpt.isEmpty, "hardwired macros must provide result type")
+ return EmptyTree
+ }
+
if (!typer.checkFeature(ddef.pos, MacrosFeature, immediate = true)) {
+ macroLogVerbose("typecheck terminated unexpectedly: language.experimental.macros feature is not enabled")
ddef.symbol setFlag IS_ERROR
return EmptyTree
}
@@ -193,8 +200,9 @@ trait Macros extends Traces {
implicit class AugmentedString(s: String) {
def abbreviateCoreAliases: String = { // hack!
var result = s
- result = result.replace("c.mirror.TypeTag", "c.TypeTag")
- result = result.replace("c.mirror.Expr", "c.Expr")
+ result = result.replace("c.universe.AbsTypeTag", "c.AbsTypeTag")
+ result = result.replace("c.universe.TypeTag", "c.TypeTag")
+ result = result.replace("c.universe.Expr", "c.Expr")
result
}
}
@@ -582,126 +590,81 @@ trait Macros extends Traces {
runtimeType
}
- /** Primary mirror that is used to resolve and run macro implementations.
+ /** Primary classloader that is used to resolve and run macro implementations.
* Loads classes from -Xmacro-primary-classpath, or from -cp if the option is not specified.
+ * Is also capable of detecting REPL and reusing its classloader.
*/
- private lazy val primaryMirror: Mirror = {
+ private lazy val primaryClassloader: ClassLoader = {
if (global.forMSIL)
throw new UnsupportedOperationException("Scala reflection not available on this platform")
- val libraryClassLoader = {
- if (settings.XmacroPrimaryClasspath.value != "") {
- macroLogVerbose("primary macro mirror: initializing from -Xmacro-primary-classpath: %s".format(settings.XmacroPrimaryClasspath.value))
- val classpath = toURLs(settings.XmacroFallbackClasspath.value)
- ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
- } else {
- macroLogVerbose("primary macro mirror: initializing from -cp: %s".format(global.classPath.asURLs))
- val classpath = global.classPath.asURLs
- var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
-
- // [Eugene] a heuristic to detect REPL
- if (global.settings.exposeEmptyPackage.value) {
- import scala.tools.nsc.interpreter._
- val virtualDirectory = global.settings.outputDirs.getSingleOutput.get
- loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
- }
-
- loader
+ if (settings.XmacroPrimaryClasspath.value != "") {
+ macroLogVerbose("primary macro classloader: initializing from -Xmacro-primary-classpath: %s".format(settings.XmacroPrimaryClasspath.value))
+ val classpath = toURLs(settings.XmacroFallbackClasspath.value)
+ ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
+ } else {
+ macroLogVerbose("primary macro classloader: initializing from -cp: %s".format(global.classPath.asURLs))
+ val classpath = global.classPath.asURLs
+ var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
+
+ // [Eugene] a heuristic to detect the REPL
+ if (global.settings.exposeEmptyPackage.value) {
+ macroLogVerbose("primary macro classloader: initializing from a REPL classloader".format(global.classPath.asURLs))
+ import scala.tools.nsc.interpreter._
+ val virtualDirectory = global.settings.outputDirs.getSingleOutput.get
+ loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
}
- }
- new Mirror(libraryClassLoader) { override def toString = "<primary macro mirror>" }
+ loader
+ }
}
- /** Fallback mirror that is used to resolve and run macro implementations.
- * Loads classes from -Xmacro-fallback-classpath aka "macro fallback classpath".
+ /** Fallback classloader that is used to resolve and run macro implementations when `primaryClassloader` fails.
+ * Loads classes from -Xmacro-fallback-classpath.
*/
- private lazy val fallbackMirror: Mirror = {
+ private lazy val fallbackClassloader: ClassLoader = {
if (global.forMSIL)
throw new UnsupportedOperationException("Scala reflection not available on this platform")
- val fallbackClassLoader = {
- macroLogVerbose("fallback macro mirror: initializing from -Xmacro-fallback-classpath: %s".format(settings.XmacroFallbackClasspath.value))
- val classpath = toURLs(settings.XmacroFallbackClasspath.value)
- ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
- }
-
- new Mirror(fallbackClassLoader) { override def toString = "<fallback macro mirror>" }
+ macroLogVerbose("fallback macro classloader: initializing from -Xmacro-fallback-classpath: %s".format(settings.XmacroFallbackClasspath.value))
+ val classpath = toURLs(settings.XmacroFallbackClasspath.value)
+ ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
}
/** Produces a function that can be used to invoke macro implementation for a given macro definition:
* 1) Looks up macro implementation symbol in this universe.
- * 2) Loads its enclosing class from the primary mirror.
- * 3) Loads the companion of that enclosing class from the primary mirror.
+ * 2) Loads its enclosing class from the primary classloader.
+ * 3) Loads the companion of that enclosing class from the primary classloader.
* 4) Resolves macro implementation within the loaded companion.
- * 5) If 2-4 fails, repeats them for the fallback mirror.
+ * 5) If 2-4 fails, repeats them for the fallback classloader.
*
* @return Some(runtime) if macro implementation can be loaded successfully from either of the mirrors,
* None otherwise.
*/
- private type MacroRuntime = List[Any] => Any
+ type MacroRuntime = List[Any] => Any
private val macroRuntimesCache = perRunCaches.newWeakMap[Symbol, Option[MacroRuntime]]
- private lazy val fastTrack: Map[Symbol, MacroRuntime] = {
- import scala.reflect.api.Universe
- import scala.reflect.makro.internal._
- Map( // challenge: how can we factor out the common code? Does not seem to be easy.
- MacroInternal_materializeArrayTag -> (args => {
- assert(args.length == 3, args)
- val c = args(0).asInstanceOf[MacroContext]
- materializeArrayTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]])
- }),
- MacroInternal_materializeErasureTag -> (args => {
- assert(args.length == 3, args)
- val c = args(0).asInstanceOf[MacroContext]
- materializeErasureTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]])
- }),
- MacroInternal_materializeClassTag -> (args => {
- assert(args.length == 3, args)
- val c = args(0).asInstanceOf[MacroContext]
- materializeClassTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]])
- }),
- MacroInternal_materializeTypeTag -> (args => {
- assert(args.length == 3, args)
- val c = args(0).asInstanceOf[MacroContext]
- materializeTypeTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]])
- }),
- MacroInternal_materializeConcreteTypeTag -> (args => {
- assert(args.length == 3, args)
- val c = args(0).asInstanceOf[MacroContext]
- materializeConcreteTypeTag_impl(c)(args(1).asInstanceOf[c.Expr[Universe]])(args(2).asInstanceOf[c.TypeTag[_]])
- })
- )
- }
private def macroRuntime(macroDef: Symbol): Option[MacroRuntime] = {
macroTraceVerbose("looking for macro implementation: ")(macroDef)
if (fastTrack contains macroDef) {
- macroLogVerbose("macro expansion serviced by a fast track")
+ macroLogVerbose("macro expansion is serviced by a fast track")
Some(fastTrack(macroDef))
} else {
macroRuntimesCache.getOrElseUpdate(macroDef, {
val runtime = {
- macroTraceVerbose("looking for macro implementation: ")(macroDef)
macroTraceVerbose("macroDef is annotated with: ")(macroDef.annotations)
val ann = macroDef.getAnnotation(MacroImplAnnotation)
- if (ann == None) {
- macroTraceVerbose("@macroImpl annotation is missing (this means that macro definition failed to typecheck)")(macroDef)
- return None
- }
+ if (ann == None) { macroTraceVerbose("@macroImpl annotation is missing (this means that macro definition failed to typecheck)")(macroDef); return None }
val macroImpl = ann.get.args(0).symbol
- if (macroImpl == NoSymbol) {
- macroTraceVerbose("@macroImpl annotation is malformed (this means that macro definition failed to typecheck)")(macroDef)
- return None
- }
-
+ if (macroImpl == NoSymbol) { macroTraceVerbose("@macroImpl annotation is malformed (this means that macro definition failed to typecheck)")(macroDef); return None }
macroLogVerbose("resolved implementation %s at %s".format(macroImpl, macroImpl.pos))
- if (macroImpl.isErroneous) {
- macroTraceVerbose("macro implementation is erroneous (this means that either macro body or macro implementation signature failed to typecheck)")(macroDef)
- return None
- }
+ if (macroImpl.isErroneous) { macroTraceVerbose("macro implementation is erroneous (this means that either macro body or macro implementation signature failed to typecheck)")(macroDef); return None }
- def loadMacroImpl(macroMirror: Mirror): Option[(Object, macroMirror.Symbol)] = {
+ // [Eugene++] I don't use Scala reflection here, because it seems to interfere with JIT magic
+ // whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20%
+ // I'm not sure what's the reason - for me it's pure voodoo
+ def loadMacroImpl(cl: ClassLoader): Option[(Object, jMethod)] = {
try {
// this logic relies on the assumptions that were valid for the old macro prototype
// namely that macro implementations can only be defined in top-level classes and modules
@@ -711,17 +674,11 @@ trait Macros extends Traces {
// however, the code below doesn't account for these guys, because it'd take a look of time to get it right
// for now I leave it as a todo and move along to more the important stuff
- macroTraceVerbose("loading implementation class from %s: ".format(macroMirror))(macroImpl.owner.fullName)
- macroTraceVerbose("classloader is: ")("%s of type %s".format(macroMirror.classLoader, if (macroMirror.classLoader != null) macroMirror.classLoader.getClass.toString else "primordial classloader"))
- def inferClasspath(cl: ClassLoader) = cl match {
- case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]"
- case null => "[" + scala.tools.util.PathResolver.Environment.javaBootClassPath + "]"
- case _ => "<unknown>"
- }
- macroTraceVerbose("classpath is: ")(inferClasspath(macroMirror.classLoader))
+ macroTraceVerbose("loading implementation class: ")(macroImpl.owner.fullName)
+ macroTraceVerbose("classloader is: ")(ReflectionUtils.show(cl))
// [Eugene] relies on the fact that macro implementations can only be defined in static classes
- // [Martin to Eugene] There's similar logic buried in Symbol#flatname. Maybe we can refactor?
+ // [Martin to Eugene++] There's similar logic buried in Symbol#flatname. Maybe we can refactor?
def classfile(sym: Symbol): String = {
def recur(sym: Symbol): String = sym match {
case sym if sym.owner.isPackageClass =>
@@ -736,71 +693,66 @@ trait Macros extends Traces {
else recur(sym.enclClass)
}
- // [Eugene] this doesn't work for inner classes
+ // [Eugene++] this doesn't work for inner classes
// neither does macroImpl.owner.javaClassName, so I had to roll my own implementation
//val receiverName = macroImpl.owner.fullName
val implClassName = classfile(macroImpl.owner)
- val implClassSymbol: macroMirror.Symbol = macroMirror.symbolForName(implClassName)
-
- if (macroDebugVerbose) {
- println("implClassSymbol is: " + implClassSymbol.fullNameString)
-
- if (implClassSymbol != macroMirror.NoSymbol) {
- val implClass = macroMirror.classToJava(implClassSymbol)
- val implSource = implClass.getProtectionDomain.getCodeSource
- println("implClass is %s from %s".format(implClass, implSource))
- println("implClassLoader is %s with classpath %s".format(implClass.getClassLoader, inferClasspath(implClass.getClassLoader)))
- }
+ val implObj = try {
+ val implObjClass = jClass.forName(implClassName, true, cl)
+ implObjClass getField "MODULE$" get null
+ } catch {
+ case ex: NoSuchFieldException => macroTraceVerbose("exception when loading implObj: ")(ex); null
+ case ex: NoClassDefFoundError => macroTraceVerbose("exception when loading implObj: ")(ex); null
+ case ex: ClassNotFoundException => macroTraceVerbose("exception when loading implObj: ")(ex); null
}
- val implObjSymbol = implClassSymbol.companionModule
- macroTraceVerbose("implObjSymbol is: ")(implObjSymbol.fullNameString)
-
- if (implObjSymbol == macroMirror.NoSymbol) None
+ if (implObj == null) None
else {
- // yet another reflection method that doesn't work for inner classes
- //val receiver = macroMirror.companionInstance(receiverClass)
- val implObj = try {
- val implObjClass = java.lang.Class.forName(implClassName, true, macroMirror.classLoader)
- implObjClass getField "MODULE$" get null
- } catch {
- case ex: NoSuchFieldException => macroTraceVerbose("exception when loading implObj: ")(ex); null
- case ex: NoClassDefFoundError => macroTraceVerbose("exception when loading implObj: ")(ex); null
- case ex: ClassNotFoundException => macroTraceVerbose("exception when loading implObj: ")(ex); null
- }
-
- if (implObj == null) None
- else {
- val implMethSymbol = implObjSymbol.info.member(macroMirror.newTermName(macroImpl.name.toString))
- macroLogVerbose("implMethSymbol is: " + implMethSymbol.fullNameString)
- macroLogVerbose("jimplMethSymbol is: " + macroMirror.methodToJava(implMethSymbol))
+ // [Eugene++] doh, it seems that I need to copy/paste Scala reflection logic
+ // see `JavaMirrors.methodToJava` or whatever it's called now
+ val implMeth = {
+ def typeToJavaClass(tpe: Type): jClass[_] = tpe match {
+ case ExistentialType(_, rtpe) => typeToJavaClass(rtpe)
+ case TypeRef(_, ArrayClass, List(elemtpe)) => jArray.newInstance(typeToJavaClass(elemtpe), 0).getClass
+ case TypeRef(_, sym: ClassSymbol, _) => jClass.forName(classfile(sym), true, cl)
+ case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found")
+ }
- if (implMethSymbol == macroMirror.NoSymbol) None
- else {
- macroLogVerbose("successfully loaded macro impl as (%s, %s)".format(implObj, implMethSymbol))
- Some((implObj, implMethSymbol))
+ val paramClasses = transformedType(macroImpl).paramTypes map typeToJavaClass
+ try implObj.getClass getDeclaredMethod (macroImpl.name.toString, paramClasses: _*)
+ catch {
+ case ex: NoSuchMethodException =>
+ val expandedName =
+ if (macroImpl.isPrivate) nme.expandedName(macroImpl.name.toTermName, macroImpl.owner).toString
+ else macroImpl.name.toString
+ implObj.getClass getDeclaredMethod (expandedName, paramClasses: _*)
}
}
+ macroLogVerbose("successfully loaded macro impl as (%s, %s)".format(implObj, implMeth))
+ Some((implObj, implMeth))
}
} catch {
case ex: ClassNotFoundException =>
macroTraceVerbose("implementation class failed to load: ")(ex.toString)
None
+ case ex: NoSuchMethodException =>
+ macroTraceVerbose("implementation method failed to load: ")(ex.toString)
+ None
}
}
- val primary = loadMacroImpl(primaryMirror)
+ val primary = loadMacroImpl(primaryClassloader)
primary match {
- case Some((implObj, implMethSymbol)) =>
- def runtime(args: List[Any]) = primaryMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any]
+ case Some((implObj, implMeth)) =>
+ def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any]
Some(runtime _)
case None =>
if (settings.XmacroFallbackClasspath.value != "") {
macroLogVerbose("trying to load macro implementation from the fallback mirror: %s".format(settings.XmacroFallbackClasspath.value))
- val fallback = loadMacroImpl(fallbackMirror)
+ val fallback = loadMacroImpl(fallbackClassloader)
fallback match {
- case Some((implObj, implMethSymbol)) =>
- def runtime(args: List[Any]) = fallbackMirror.invoke(implObj, implMethSymbol)(args: _*).asInstanceOf[Any]
+ case Some((implObj, implMeth)) =>
+ def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any]
Some(runtime _)
case None =>
None
@@ -817,15 +769,14 @@ trait Macros extends Traces {
}
}
- /** Should become private again once we're done with migrating typetag generation from implicits */
- def macroContext(typer: Typer, prefixTree: Tree, expandeeTree: Tree): MacroContext { val mirror: global.type } =
+ private def macroContext(typer: Typer, prefixTree: Tree, expandeeTree: Tree): MacroContext =
new {
- val mirror: global.type = global
- val callsiteTyper: mirror.analyzer.Typer = typer.asInstanceOf[global.analyzer.Typer]
- // todo. infer precise typetag for this Expr, namely the PrefixType member of the Context refinement
- val prefix = Expr(prefixTree)(TypeTag.Nothing)
+ val universe: self.global.type = self.global
+ val callsiteTyper: universe.analyzer.Typer = typer.asInstanceOf[global.analyzer.Typer]
val expandee = expandeeTree
- } with MacroContext {
+ } with UnaffiliatedMacroContext {
+ // todo. infer precise typetag for this Expr, namely the PrefixType member of the Context refinement
+ val prefix = Expr[Nothing](prefixTree)(TypeTag.Nothing)
override def toString = "MacroContext(%s@%s +%d)".format(expandee.symbol.name, expandee.pos, enclosingMacros.length - 1 /* exclude myself */)
}
@@ -837,118 +788,124 @@ trait Macros extends Traces {
* @return list of runtime objects to pass to the implementation obtained by ``macroRuntime''
*/
private def macroArgs(typer: Typer, expandee: Tree): Option[List[Any]] = {
- val macroDef = expandee.symbol
- val runtime = macroRuntime(macroDef) orElse { return None }
- var prefixTree: Tree = EmptyTree
- var typeArgs = List[Tree]()
- val exprArgs = ListBuffer[List[Expr[_]]]()
-
+ val macroDef = expandee.symbol
+ val runtime = macroRuntime(macroDef) orElse { return None }
+ val prefixTree = expandee.collect{ case Select(qual, name) => qual }.headOption.getOrElse(EmptyTree)
+ val context = expandee.attachments.get[MacroRuntimeAttachment].flatMap(_.macroContext).getOrElse(macroContext(typer, prefixTree, expandee))
+ var typeArgs = List[Tree]()
+ val exprArgs = ListBuffer[List[Expr[_]]]()
def collectMacroArgs(tree: Tree): Unit = tree match {
case Apply(fn, args) =>
// todo. infer precise typetag for this Expr, namely the declared type of the corresponding macro impl argument
- exprArgs.prepend(args map (Expr(_)(TypeTag.Nothing)))
+ exprArgs.prepend(args map (arg => context.Expr[Nothing](arg)(TypeTag.Nothing)))
collectMacroArgs(fn)
case TypeApply(fn, args) =>
typeArgs = args
collectMacroArgs(fn)
- case Select(qual, name) =>
- prefixTree = qual
case _ =>
}
collectMacroArgs(expandee)
- val context = expandee.attachmentOpt[MacroAttachment].flatMap(_.macroContext).getOrElse(macroContext(typer, prefixTree, expandee))
var argss: List[List[Any]] = List(context) :: exprArgs.toList
macroTraceVerbose("argss: ")(argss)
+ val rawArgss =
+ if (fastTrack contains macroDef) {
+ if (fastTrack(macroDef) validate argss) argss
+ else {
+ // if you're getting here, it's not necessarily partial application that is at fault
+ // for example, if a signature of a hardwired macro has been changed without updated FastTrack
+ // then the corresponding partial function in FastTrack will refuse to process the expandee
+ // validation will return false, and control flow will end up here
+ // however, for simplicity sake, I didn't introduce the notion of error handling to FastTrack
+ // so all kinds of validation errors produce `MacroPartialApplicationError`
+ typer.TyperErrorGen.MacroPartialApplicationError(expandee)
+ return None
+ }
+ } else {
+ val ann = macroDef.getAnnotation(MacroImplAnnotation).getOrElse(throw new Error("assertion failed. %s: %s".format(macroDef, macroDef.annotations)))
+ val macroImpl = ann.args(0).symbol
+ var paramss = macroImpl.paramss
+ val tparams = macroImpl.typeParams
+ macroTraceVerbose("paramss: ")(paramss)
+
+ // we need to take care of all possible combos of nullary/empty-paramlist macro defs vs nullary/empty-arglist invocations
+ // nullary def + nullary invocation => paramss and argss match, everything is okay
+ // nullary def + empty-arglist invocation => illegal Scala code, impossible, everything is okay
+ // empty-paramlist def + nullary invocation => uh-oh, we need to append a List() to argss
+ // empty-paramlist def + empty-arglist invocation => paramss and argss match, everything is okay
+ // that's almost it, but we need to account for the fact that paramss might have context bounds that mask the empty last paramlist
+ val paramss_without_evidences = transformTypeTagEvidenceParams(paramss, (param, tparam) => None)
+ val isEmptyParamlistDef = paramss_without_evidences.nonEmpty && paramss_without_evidences.last.isEmpty
+ val isEmptyArglistInvocation = argss.nonEmpty && argss.last.isEmpty
+ if (isEmptyParamlistDef && !isEmptyArglistInvocation) {
+ macroLogVerbose("isEmptyParamlistDef && !isEmptyArglistInvocation: appending a List() to argss")
+ argss = argss :+ Nil
+ }
- val ann = macroDef.getAnnotation(MacroImplAnnotation).getOrElse(throw new Error("assertion failed. %s: %s".format(macroDef, macroDef.annotations)))
- val macroImpl = ann.args(0).symbol
- var paramss = macroImpl.paramss
- val tparams = macroImpl.typeParams
- macroTraceVerbose("paramss: ")(paramss)
-
- // we need to take care of all possible combos of nullary/empty-paramlist macro defs vs nullary/empty-arglist invocations
- // nullary def + nullary invocation => paramss and argss match, everything is okay
- // nullary def + empty-arglist invocation => illegal Scala code, impossible, everything is okay
- // empty-paramlist def + nullary invocation => uh-oh, we need to append a List() to argss
- // empty-paramlist def + empty-arglist invocation => paramss and argss match, everything is okay
- // that's almost it, but we need to account for the fact that paramss might have context bounds that mask the empty last paramlist
- val paramss_without_evidences = transformTypeTagEvidenceParams(paramss, (param, tparam) => None)
- val isEmptyParamlistDef = paramss_without_evidences.nonEmpty && paramss_without_evidences.last.isEmpty
- val isEmptyArglistInvocation = argss.nonEmpty && argss.last.isEmpty
- if (isEmptyParamlistDef && !isEmptyArglistInvocation) {
- macroLogVerbose("isEmptyParamlistDef && !isEmptyArglistInvocation: appending a List() to argss")
- argss = argss :+ Nil
- }
-
- // nb! check partial application against paramss without evidences
- val numParamLists = paramss_without_evidences.length
- val numArgLists = argss.length
- if (numParamLists != numArgLists) {
- typer.TyperErrorGen.MacroPartialApplicationError(expandee)
- return None
- }
+ // nb! check partial application against paramss without evidences
+ val numParamLists = paramss_without_evidences.length
+ val numArgLists = argss.length
+ if (numParamLists != numArgLists) {
+ typer.TyperErrorGen.MacroPartialApplicationError(expandee)
+ return None
+ }
- // if paramss have typetag context bounds, add an arglist to argss if necessary and instantiate the corresponding evidences
- // consider the following example:
- //
- // class D[T] {
- // class C[U] {
- // def foo[V] = macro Impls.foo[T, U, V]
- // }
- // }
- //
- // val outer1 = new D[Int]
- // val outer2 = new outer1.C[String]
- // outer2.foo[Boolean]
- //
- // then T and U need to be inferred from the lexical scope of the call using ``asSeenFrom''
- // whereas V won't be resolved by asSeenFrom and need to be loaded directly from ``expandee'' which needs to contain a TypeApply node
- // also, macro implementation reference may contain a regular type as a type argument, then we pass it verbatim
- val resolved = collection.mutable.Map[Symbol, Type]()
- paramss = transformTypeTagEvidenceParams(paramss, (param, tparam) => {
- val TypeApply(_, implRefTargs) = ann.args(0)
- var implRefTarg = implRefTargs(tparam.paramPos).tpe.typeSymbol
- val tpe = if (implRefTarg.isTypeParameterOrSkolem) {
- if (implRefTarg.owner == macroDef) {
- // [Eugene] doesn't work when macro def is compiled separately from its usages
- // then implRefTarg is not a skolem and isn't equal to any of macroDef.typeParams
-// val paramPos = implRefTarg.deSkolemize.paramPos
- val paramPos = macroDef.typeParams.indexWhere(_.name == implRefTarg.name)
- typeArgs(paramPos).tpe
- } else
- implRefTarg.tpe.asSeenFrom(
- if (prefixTree == EmptyTree) macroDef.owner.tpe else prefixTree.tpe,
- macroDef.owner)
- } else
- implRefTarg.tpe
- macroLogVerbose("resolved tparam %s as %s".format(tparam, tpe))
- resolved(tparam) = tpe
- param.tpe.typeSymbol match {
- case definitions.TypeTagClass =>
- // do nothing
- case definitions.ConcreteTypeTagClass =>
- if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create ConcreteTypeTag from a type %s having unresolved type parameters".format(tpe))
- // otherwise do nothing
- case _ =>
- throw new Error("unsupported tpe: " + tpe)
+ // if paramss have typetag context bounds, add an arglist to argss if necessary and instantiate the corresponding evidences
+ // consider the following example:
+ //
+ // class D[T] {
+ // class C[U] {
+ // def foo[V] = macro Impls.foo[T, U, V]
+ // }
+ // }
+ //
+ // val outer1 = new D[Int]
+ // val outer2 = new outer1.C[String]
+ // outer2.foo[Boolean]
+ //
+ // then T and U need to be inferred from the lexical scope of the call using ``asSeenFrom''
+ // whereas V won't be resolved by asSeenFrom and need to be loaded directly from ``expandee'' which needs to contain a TypeApply node
+ // also, macro implementation reference may contain a regular type as a type argument, then we pass it verbatim
+ val resolved = collection.mutable.Map[Symbol, Type]()
+ paramss = transformTypeTagEvidenceParams(paramss, (param, tparam) => {
+ val TypeApply(_, implRefTargs) = ann.args(0)
+ var implRefTarg = implRefTargs(tparam.paramPos).tpe.typeSymbol
+ val tpe = if (implRefTarg.isTypeParameterOrSkolem) {
+ if (implRefTarg.owner == macroDef) {
+ // [Eugene] doesn't work when macro def is compiled separately from its usages
+ // then implRefTarg is not a skolem and isn't equal to any of macroDef.typeParams
+ // val paramPos = implRefTarg.deSkolemize.paramPos
+ val paramPos = macroDef.typeParams.indexWhere(_.name == implRefTarg.name)
+ typeArgs(paramPos).tpe
+ } else
+ implRefTarg.tpe.asSeenFrom(
+ if (prefixTree == EmptyTree) macroDef.owner.tpe else prefixTree.tpe,
+ macroDef.owner)
+ } else
+ implRefTarg.tpe
+ macroLogVerbose("resolved tparam %s as %s".format(tparam, tpe))
+ resolved(tparam) = tpe
+ param.tpe.typeSymbol match {
+ case definitions.AbsTypeTagClass =>
+ // do nothing
+ case definitions.TypeTagClass =>
+ if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create TypeTag from a type %s having unresolved type parameters".format(tpe))
+ // otherwise do nothing
+ case _ =>
+ throw new Error("unsupported tpe: " + tpe)
+ }
+ Some(tparam)
+ })
+ val tags = paramss.last takeWhile (_.isType) map (resolved(_)) map (tpe => if (tpe.isConcrete) context.TypeTag(tpe) else context.AbsTypeTag(tpe))
+ if (paramss.lastOption map (params => !params.isEmpty && params.forall(_.isType)) getOrElse false) argss = argss :+ Nil
+ argss = argss.dropRight(1) :+ (tags ++ argss.last) // todo. add support for context bounds in argss
+
+ assert(argss.length == paramss.length, "argss: %s, paramss: %s".format(argss, paramss))
+ val rawArgss = for ((as, ps) <- argss zip paramss) yield {
+ if (isVarArgsList(ps)) as.take(ps.length - 1) :+ as.drop(ps.length - 1)
+ else as
+ }
+ rawArgss
}
- Some(tparam)
- })
- val tags = paramss.last takeWhile (_.isType) map (resolved(_)) map (tpe => {
- // generally speaking, it's impossible to calculate erasure from a tpe here
- // the tpe might be compiled by this run, so its jClass might not exist yet
- // hence I just pass `null` instead and leave this puzzle to macro programmers
- val ttag = TypeTag(tpe, null)
- if (ttag.isConcrete) ttag.toConcrete else ttag
- })
- if (paramss.lastOption map (params => !params.isEmpty && params.forall(_.isType)) getOrElse false) argss = argss :+ Nil
- argss = argss.dropRight(1) :+ (tags ++ argss.last) // todo. add support for context bounds in argss
-
- assert(argss.length == paramss.length, "argss: %s, paramss: %s".format(argss, paramss))
- val rawArgss = for ((as, ps) <- argss zip paramss) yield {
- if (isVarArgsList(ps)) as.take(ps.length - 1) :+ as.drop(ps.length - 1)
- else as
- }
val rawArgs = rawArgss.flatten
macroTraceVerbose("rawArgs: ")(rawArgs)
Some(rawArgs)
@@ -985,15 +942,17 @@ trait Macros extends Traces {
def macroExpand(typer: Typer, expandee: Tree, mode: Int = EXPRmode, pt: Type = WildcardType): Tree = {
def fail(what: String, tree: Tree): Tree = {
val err = typer.context.errBuffer.head
- this.fail(typer, tree, "failed to %s: %s at %s".format(what, err.errMsg, err.errPos))
+ this.fail(typer, tree, err.errPos, "failed to %s: %s".format(what, err.errMsg))
return expandee
}
val start = startTimer(macroExpandNanos)
incCounter(macroExpandCount)
try {
macroExpand1(typer, expandee) match {
- case Success(expanded) =>
+ case Success(expanded0) =>
try {
+ val expanded = expanded0 // virtpatmat swallows the local for expandee from the match
+ // so I added this dummy local for the ease of debugging
var expectedTpe = expandee.tpe
// [Eugene] weird situation. what's the conventional way to deal with it?
@@ -1024,7 +983,7 @@ trait Macros extends Traces {
if (typer.context.hasErrors) fail("typecheck against expected type", expanded)
macroLogVerbose("typechecked2:%n%s%n%s".format(typechecked, showRaw(typechecked)))
- typechecked
+ typechecked addAttachment MacroExpansionAttachment(expandee)
} finally {
openMacros = openMacros.tail
}
@@ -1046,11 +1005,11 @@ trait Macros extends Traces {
private def Skip(expanded: Tree) = Other(expanded)
private def Cancel(expandee: Tree) = Other(expandee)
private def Failure(expandee: Tree) = Other(expandee)
- private def fail(typer: Typer, expandee: Tree, msg: String = null) = {
+ private def fail(typer: Typer, expandee: Tree, pos: Position = NoPosition, msg: String = null) = {
def msgForLog = if (msg != null && (msg contains "exception during macro expansion")) msg.split(EOL).drop(1).headOption.getOrElse("?") else msg
macroLogLite("macro expansion has failed: %s".format(msgForLog))
- val pos = if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition
- if (msg != null) typer.context.error(pos, msg)
+ val errorPos = if (pos != NoPosition) pos else (if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition)
+ if (msg != null) typer.context.error(errorPos, msg)
typer.infer.setError(expandee)
Failure(expandee)
}
@@ -1069,7 +1028,7 @@ trait Macros extends Traces {
// if a macro implementation is incompatible or any of the arguments are erroneous
// there is no sense to expand the macro itself => it will only make matters worse
if (expandee.symbol.isErroneous || (expandee exists (_.isErroneous))) {
- val reason = if (expandee.symbol.isErroneous) "incompatible macro implementation" else "erroneous arguments"
+ val reason = if (expandee.symbol.isErroneous) "not found or incompatible macro implementation" else "erroneous arguments"
macroTraceVerbose("cancelled macro expansion because of %s: ".format(reason))(expandee)
return Cancel(typer.infer.setError(expandee))
}
@@ -1092,7 +1051,7 @@ trait Macros extends Traces {
+ "If you have troubles tracking free @kind@ variables, consider using -Xlog-free-@kind@s"
)
val forgotten = (
- if (sym.isTerm) "eval when splicing this variable into a reifee"
+ if (sym.isTerm) "splice when splicing this variable into a reifee"
else "c.TypeTag annotation for this type parameter"
)
typer.context.error(expandee.pos,
@@ -1105,7 +1064,7 @@ trait Macros extends Traces {
val undetparams = calculateUndetparams(expandee)
val nowDelayed = !typer.context.macrosEnabled || undetparams.nonEmpty
- def failExpansion(msg: String = null) = fail(typer, expandee, msg)
+ def failExpansion(msg: String = null) = fail(typer, expandee, msg = msg)
def performExpansion(args: List[Any]): MacroExpansionResult = {
val numErrors = reporter.ERROR.count
def hasNewErrors = reporter.ERROR.count > numErrors
@@ -1119,8 +1078,8 @@ trait Macros extends Traces {
macroLogVerbose("original:")
macroLogLite("" + expanded.tree + "\n" + showRaw(expanded.tree))
- freeTerms(expanded.tree) foreach issueFreeError
- freeTypes(expanded.tree) foreach issueFreeError
+ expanded.tree.freeTerms foreach issueFreeError
+ expanded.tree.freeTypes foreach issueFreeError
if (hasNewErrors) failExpansion()
// inherit the position from the first position-ful expandee in macro callstack
@@ -1145,31 +1104,36 @@ trait Macros extends Traces {
else {
macroLogLite("typechecking macro expansion %s at %s".format(expandee, expandee.pos))
macroArgs(typer, expandee).fold(failExpansion(): MacroExpansionResult) {
- case args @ ((context: MacroContext) :: _) =>
- if (nowDelayed) {
- macroLogLite("macro expansion is delayed: %s".format(expandee))
- delayed += expandee -> undetparams
- // need to save typer context for `macroExpandAll`
- // need to save macro context to preserve enclosures
- expandee attach MacroAttachment(delayed = true, typerContext = typer.context, macroContext = Some(context))
- Delay(expandee)
- }
- else {
- // adding stuff to openMacros is easy, but removing it is a nightmare
- // it needs to be sprinkled over several different code locations
- // why? https://github.com/scala/scala/commit/bd3eacbae21f39b1ac7fe8ade4ed71fa98e1a28d#L2R1137
- // todo. will be improved
- openMacros ::= context
- var isSuccess = false
- try performExpansion(args) match {
- case x: Success => isSuccess = true ; x
- case x => x
+ args => (args: @unchecked) match {
+ // [Eugene++] crashes virtpatmat:
+ // case args @ ((context: MacroContext) :: _) =>
+ case args @ (context0 :: _) =>
+ val context = context0.asInstanceOf[MacroContext]
+ if (nowDelayed) {
+ macroLogLite("macro expansion is delayed: %s".format(expandee))
+ delayed += expandee -> undetparams
+ // need to save typer context for `macroExpandAll`
+ // need to save macro context to preserve enclosures
+ expandee addAttachment MacroRuntimeAttachment(delayed = true, typerContext = typer.context, macroContext = Some(context.asInstanceOf[MacroContext]))
+ Delay(expandee)
}
- finally {
- expandee.detach(classOf[MacroAttachment])
- if (!isSuccess) openMacros = openMacros.tail
+ else {
+ // adding stuff to openMacros is easy, but removing it is a nightmare
+ // it needs to be sprinkled over several different code locations
+ // why? https://github.com/scala/scala/commit/bd3eacbae21f39b1ac7fe8ade4ed71fa98e1a28d#L2R1137
+ // todo. will be improved
+ openMacros ::= context
+ var isSuccess = false
+ try performExpansion(args) match {
+ case x: Success => isSuccess = true ; x
+ case x => x
+ }
+ finally {
+ expandee.removeAttachment[MacroRuntimeAttachment]
+ if (!isSuccess) openMacros = openMacros.tail
+ }
}
- }
+ }
}
}
}
@@ -1257,7 +1221,7 @@ trait Macros extends Traces {
None
}
} getOrElse realex.getMessage
- fail(typer, expandee, "exception during macro expansion: " + message)
+ fail(typer, expandee, msg = "exception during macro expansion: " + message)
}
}
@@ -1317,7 +1281,7 @@ trait Macros extends Traces {
override def transform(tree: Tree) = super.transform(tree match {
// todo. expansion should work from the inside out
case wannabe if (delayed contains wannabe) && calculateUndetparams(wannabe).isEmpty =>
- val context = wannabe.attachment[MacroAttachment].typerContext
+ val context = wannabe.attachments.get[MacroRuntimeAttachment].get.typerContext
delayed -= wannabe
context.implicitsEnabled = typer.context.implicitsEnabled
context.enrichmentEnabled = typer.context.enrichmentEnabled
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index cf94f7d4d6..95d0369707 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -7,8 +7,9 @@ package typechecker
import symtab.Flags._
import scala.collection.{ mutable, immutable }
-import scala.tools.util.StringOps.{ ojoin }
-import scala.reflect.{ mirror => rm }
+import scala.reflect.internal.util.StringOps.{ ojoin }
+import scala.reflect.ClassTag
+import scala.reflect.runtime.{ universe => ru }
import language.higherKinds
/** Logic related to method synthesis which involves cooperation between
@@ -22,15 +23,15 @@ trait MethodSynthesis {
import CODE._
object synthesisUtil {
- type CTT[T] = rm.ConcreteTypeTag[T]
+ type TT[T] = ru.TypeTag[T]
type CT[T] = ClassTag[T]
def ValOrDefDef(sym: Symbol, body: Tree) =
if (sym.isLazy) ValDef(sym, body)
else DefDef(sym, body)
- def applyTypeInternal(tags: List[CTT[_]]): Type = {
- // [Eugene to Paul] needs review!!
+ def applyTypeInternal(tags: List[TT[_]]): Type = {
+ // [Eugene++ to Paul] needs review!!
val symbols = tags map compilerSymbolFromTag
val container :: args = symbols
val tparams = container.typeConstructor.typeParams
@@ -44,26 +45,33 @@ trait MethodSynthesis {
appliedType(container, args map (_.tpe): _*)
}
- def companionType[T](implicit m: CTT[T]) =
- getRequiredModule(m.erasure.getName).tpe
+ def companionType[T](implicit ct: CT[T]) =
+ rootMirror.getRequiredModule(ct.runtimeClass.getName).tpe
// Use these like `applyType[List, Int]` or `applyType[Map, Int, String]`
- def applyType[CC](implicit m1: CTT[CC]): Type =
- applyTypeInternal(List(m1))
-
- def applyType[CC[X1], X1](implicit m1: CTT[CC[_]], m2: CTT[X1]): Type =
- applyTypeInternal(List(m1, m2))
-
- def applyType[CC[X1, X2], X1, X2](implicit m1: CTT[CC[_,_]], m2: CTT[X1], m3: CTT[X2]): Type =
- applyTypeInternal(List(m1, m2, m3))
-
- def applyType[CC[X1, X2, X3], X1, X2, X3](implicit m1: CTT[CC[_,_,_]], m2: CTT[X1], m3: CTT[X2], m4: CTT[X3]): Type =
- applyTypeInternal(List(m1, m2, m3, m4))
-
- def newMethodType[F](owner: Symbol)(implicit t: CTT[F]): Type = {
+ def applyType[CC](implicit t1: TT[CC]): Type =
+ applyTypeInternal(List(t1))
+
+ def applyType[CC[X1], X1](implicit t1: TT[CC[_]], t2: TT[X1]): Type =
+ applyTypeInternal(List[TT[_]](t1, t2))
+
+ def applyType[CC[X1, X2], X1, X2](implicit t1: TT[CC[_,_]], t2: TT[X1], t3: TT[X2]): Type =
+ // [Eugene++] without an explicit type annotation for List, we get this:
+ // [scalacfork] C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\MethodSynthesis.scala:59: error: no type parameters for method apply: (xs: A*)List[A] in object List exist so that it can be applied to arguments (scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[CC[_, _]], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X1], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X2])
+ // [scalacfork] --- because ---
+ // [scalacfork] undetermined type
+ // [scalacfork] applyTypeInternal(List(t1, t2, t3))
+ applyTypeInternal(List[TT[_]](t1, t2, t3))
+
+ def applyType[CC[X1, X2, X3], X1, X2, X3](implicit t1: TT[CC[_,_,_]], t2: TT[X1], t3: TT[X2], t4: TT[X3]): Type =
+ applyTypeInternal(List[TT[_]](t1, t2, t3, t4))
+
+ // [Martin->Eugene] !!! reinstantiate when typeables are in.
+ // [Eugene++->Martin] now this compiles, will soon check it out
+ def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = {
val fnSymbol = compilerSymbolFromTag(t)
assert(fnSymbol isSubClass FunctionClass(t.tpe.typeArguments.size - 1), (owner, t))
- // [Eugene to Paul] needs review!!
+ // [Eugene++ to Paul] needs review!!
// val symbols = m.typeArguments map (m => manifestToSymbol(m))
// val formals = symbols.init map (_.typeConstructor)
val formals = compilerTypeFromTag(t).typeArguments
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index b4f42a5033..decd18b599 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -313,7 +313,7 @@ trait Namers extends MethodSynthesis {
/** All PackageClassInfoTypes come from here. */
private def createPackageSymbol(pos: Position, pid: RefTree): Symbol = {
val pkgOwner = pid match {
- case Ident(_) => if (owner == EmptyPackageClass) RootClass else owner
+ case Ident(_) => if (owner.isEmptyPackageClass) rootMirror.RootClass else owner
case Select(qual: RefTree, _) => createPackageSymbol(pos, qual).moduleClass
}
val existing = pkgOwner.info.decls.lookup(pid.name)
@@ -473,12 +473,8 @@ trait Namers extends MethodSynthesis {
if (from != nme.WILDCARD && base != ErrorType) {
if (isValid(from)) {
- if (currentRun.compileSourceFor(expr, from)) {
- // side effecting, apparently
- typeSig(tree)
- }
// for Java code importing Scala objects
- else if (!nme.isModuleName(from) || isValid(nme.stripModuleSuffix(from))) {
+ if (!nme.isModuleName(from) || isValid(nme.stripModuleSuffix(from))) {
typer.TyperErrorGen.NotAMemberError(tree, expr, from)
typer.infer.setError(tree)
}
@@ -1306,14 +1302,18 @@ trait Namers extends MethodSynthesis {
if (expr1.symbol != null && expr1.symbol.isRootPackage)
RootImportError(tree)
- val newImport = treeCopy.Import(tree, expr1, selectors).asInstanceOf[Import]
- checkSelectors(newImport)
- transformed(tree) = newImport
- // copy symbol and type attributes back into old expression
- // so that the structure builder will find it.
- expr.symbol = expr1.symbol
- expr.tpe = expr1.tpe
- ImportType(expr1)
+ if (expr1.isErrorTyped)
+ ErrorType
+ else {
+ val newImport = treeCopy.Import(tree, expr1, selectors).asInstanceOf[Import]
+ checkSelectors(newImport)
+ transformed(tree) = newImport
+ // copy symbol and type attributes back into old expression
+ // so that the structure builder will find it.
+ expr.symbol = expr1.symbol
+ expr.tpe = expr1.tpe
+ ImportType(expr1)
+ }
}
val result =
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 932e4548ef..61443faba0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -9,6 +9,7 @@ package typechecker
import symtab.Flags._
import scala.collection.mutable
import scala.ref.WeakReference
+import scala.reflect.ClassTag
/**
* @author Lukas Rytz
@@ -39,14 +40,14 @@ trait NamesDefaults { self: Analyzer =>
def isNamed(arg: Tree) = nameOf(arg).isDefined
/** @param pos maps indices from old to new */
- def reorderArgs[T: ArrayTag](args: List[T], pos: Int => Int): List[T] = {
+ def reorderArgs[T: ClassTag](args: List[T], pos: Int => Int): List[T] = {
val res = new Array[T](args.length)
foreachWithIndex(args)((arg, index) => res(pos(index)) = arg)
res.toList
}
/** @param pos maps indices from new to old (!) */
- def reorderArgsInv[T: ArrayTag](args: List[T], pos: Int => Int): List[T] = {
+ def reorderArgsInv[T: ClassTag](args: List[T], pos: Int => Int): List[T] = {
val argsArray = args.toArray
(argsArray.indices map (i => argsArray(pos(i)))).toList
}
@@ -376,7 +377,7 @@ trait NamesDefaults { self: Analyzer =>
*/
def addDefaults(givenArgs: List[Tree], qual: Option[Tree], targs: List[Tree],
previousArgss: List[List[Tree]], params: List[Symbol],
- pos: util.Position, context: Context): (List[Tree], List[Symbol]) = {
+ pos: scala.reflect.internal.util.Position, context: Context): (List[Tree], List[Symbol]) = {
if (givenArgs.length < params.length) {
val (missing, positional) = missingParams(givenArgs, params)
if (missing forall (_.hasDefault)) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
index 80d40011ad..68522c727f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
@@ -14,6 +14,7 @@ import scala.tools.nsc.transform.TypingTransformers
import scala.tools.nsc.transform.Transform
import scala.collection.mutable.HashSet
import scala.collection.mutable.HashMap
+import scala.tools.nsc.util.Statistics
/** Translate pattern matching.
*
@@ -26,11 +27,9 @@ import scala.collection.mutable.HashMap
* Cases are combined into a pattern match using the `orElse` combinator (the implicit failure case is expressed using the monad's `zero`).
*
* TODO:
- * - exhaustivity
- * - DCE (unreachability/refutability/optimization)
* - use TypeTags for type testing
- * - Array patterns
- * - implement spec more closely (see TODO's)
+ * - DCE (on irrefutable patterns)
+ * - update spec and double check it's implemented correctly (see TODO's)
*
* (longer-term) TODO:
* - user-defined unapplyProd
@@ -38,6 +37,8 @@ import scala.collection.mutable.HashMap
* - recover exhaustivity and unreachability checking using a variation on the type-safe builder pattern
*/
trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL { // self: Analyzer =>
+ import Statistics._
+
val global: Global // need to repeat here because otherwise last mixin defines global as
// SymbolTable. If we had DOT this would not be an issue
import global._ // the global environment
@@ -45,16 +46,18 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
val phaseName: String = "patmat"
+ def patmatDebug(msg: String) = println(msg)
+
def newTransformer(unit: CompilationUnit): Transformer =
if (opt.virtPatmat) new MatchTransformer(unit)
else noopTransformer
// duplicated from CPSUtils (avoid dependency from compiler -> cps plugin...)
- private lazy val MarkerCPSAdaptPlus = definitions.getClassIfDefined("scala.util.continuations.cpsPlus")
- private lazy val MarkerCPSAdaptMinus = definitions.getClassIfDefined("scala.util.continuations.cpsMinus")
- private lazy val MarkerCPSSynth = definitions.getClassIfDefined("scala.util.continuations.cpsSynth")
+ private lazy val MarkerCPSAdaptPlus = rootMirror.getClassIfDefined("scala.util.continuations.cpsPlus")
+ private lazy val MarkerCPSAdaptMinus = rootMirror.getClassIfDefined("scala.util.continuations.cpsMinus")
+ private lazy val MarkerCPSSynth = rootMirror.getClassIfDefined("scala.util.continuations.cpsSynth")
private lazy val stripTriggerCPSAnns = List(MarkerCPSSynth, MarkerCPSAdaptMinus, MarkerCPSAdaptPlus)
- private lazy val MarkerCPSTypes = definitions.getClassIfDefined("scala.util.continuations.cpsParam")
+ private lazy val MarkerCPSTypes = rootMirror.getClassIfDefined("scala.util.continuations.cpsParam")
private lazy val strippedCPSAnns = MarkerCPSTypes :: stripTriggerCPSAnns
private def removeCPSAdaptAnnotations(tp: Type) = tp filterAnnotations (ann => !(strippedCPSAnns exists (ann matches _)))
@@ -173,13 +176,15 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// (that would require more sophistication when generating trees,
// and the only place that emits Matches after typers is for exception handling anyway)
if(phase.id >= currentRun.uncurryPhase.id) debugwarn("running translateMatch at "+ phase +" on "+ selector +" match "+ cases)
- // println("translating "+ cases.mkString("{", "\n", "}"))
+ // patmatDebug("translating "+ cases.mkString("{", "\n", "}"))
def repeatedToSeq(tp: Type): Type = (tp baseType RepeatedParamClass) match {
case TypeRef(_, RepeatedParamClass, arg :: Nil) => seqType(arg)
case _ => tp
}
+ val start = startTimer(patmatNanos)
+
val selectorTp = repeatedToSeq(elimAnonymousClass(selector.tpe.widen.withoutAnnotations))
val origPt = match_.tpe
@@ -199,11 +204,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// the alternative to attaching the default case override would be to simply
// append the default to the list of cases and suppress the unreachable case error that may arise (once we detect that...)
- val matchFailGenOverride = match_ firstAttachment {case DefaultOverrideMatchAttachment(default) => ((scrut: Tree) => default)}
+ val matchFailGenOverride = match_.attachments.get[DefaultOverrideMatchAttachment].map{case DefaultOverrideMatchAttachment(default) => ((scrut: Tree) => default)}
val selectorSym = freshSym(selector.pos, pureType(selectorTp)) setFlag SYNTH_CASE
// pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental
- combineCases(selector, selectorSym, cases map translateCase(selectorSym, pt), pt, matchOwner, matchFailGenOverride)
+ val combined = combineCases(selector, selectorSym, cases map translateCase(selectorSym, pt), pt, matchOwner, matchFailGenOverride)
+
+ stopTimer(patmatNanos, start)
+ combined
}
// return list of typed CaseDefs that are supported by the backend (typed/bind/wildcard)
@@ -297,9 +305,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// as b.info may be based on a Typed type ascription, which has not been taken into account yet by the translation
// (it will later result in a type test when `tp` is not a subtype of `b.info`)
// TODO: can we simplify this, together with the Bound case?
- (extractor.subPatBinders, extractor.subPatTypes).zipped foreach { case (b, tp) => b setInfo tp } // println("changing "+ b +" : "+ b.info +" -> "+ tp);
+ (extractor.subPatBinders, extractor.subPatTypes).zipped foreach { case (b, tp) => b setInfo tp } // patmatDebug("changing "+ b +" : "+ b.info +" -> "+ tp);
- // println("translateExtractorPattern checking parameter type: "+ (patBinder, patBinder.info.widen, extractor.paramType, patBinder.info.widen <:< extractor.paramType))
+ // patmatDebug("translateExtractorPattern checking parameter type: "+ (patBinder, patBinder.info.widen, extractor.paramType, patBinder.info.widen <:< extractor.paramType))
// example check: List[Int] <:< ::[Int]
// TODO: extractor.paramType may contain unbound type params (run/t2800, run/t3530)
val (typeTestTreeMaker, patBinderOrCasted) =
@@ -337,7 +345,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case WildcardPattern() => noFurtherSubPats()
case UnApply(unfun, args) =>
// TODO: check unargs == args
- // println("unfun: "+ (unfun.tpe, unfun.symbol.ownerChain, unfun.symbol.info, patBinder.info))
+ // patmatDebug("unfun: "+ (unfun.tpe, unfun.symbol.ownerChain, unfun.symbol.info, patBinder.info))
translateExtractorPattern(ExtractorCall(unfun, args))
/** A constructor pattern is of the form c(p1, ..., pn) where n ≥ 0.
@@ -403,7 +411,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
*/
case Bind(n, p) => // this happens in certain ill-formed programs, there'll be an error later
- // println("WARNING: Bind tree with unbound symbol "+ patTree)
+ // patmatDebug("WARNING: Bind tree with unbound symbol "+ patTree)
noFurtherSubPats() // there's no symbol -- something's wrong... don't fail here though (or should we?)
// case Star(_) | ArrayValue | This => error("stone age pattern relics encountered!")
@@ -476,13 +484,13 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// this fails to resolve overloading properly...
// Apply(typedOperator(Select(orig, extractor)), List(Ident(nme.SELECTOR_DUMMY))) // no need to set the type of the dummy arg, it will be replaced anyway
- // println("funtpe after = "+ fun.tpe.finalResultType)
- // println("orig: "+(orig, orig.tpe))
+ // patmatDebug("funtpe after = "+ fun.tpe.finalResultType)
+ // patmatDebug("orig: "+(orig, orig.tpe))
val tgt = typed(orig, EXPRmode | QUALmode | POLYmode, HasMember(extractor.name)) // can't specify fun.tpe.finalResultType as the type for the extractor's arg,
// as it may have been inferred incorrectly (see t602, where it's com.mosol.sl.Span[Any], instead of com.mosol.sl.Span[?K])
- // println("tgt = "+ (tgt, tgt.tpe))
+ // patmatDebug("tgt = "+ (tgt, tgt.tpe))
val oper = typed(Select(tgt, extractor.name), EXPRmode | FUNmode | POLYmode | TAPPmode, WildcardType)
- // println("oper: "+ (oper, oper.tpe))
+ // patmatDebug("oper: "+ (oper, oper.tpe))
Apply(oper, List(Ident(nme.SELECTOR_DUMMY))) // no need to set the type of the dummy arg, it will be replaced anyway
}
} finally context.undetparams = savedUndets
@@ -598,8 +606,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// private val orig = fun match {case tpt: TypeTree => tpt.original case _ => fun}
// private val origExtractorTp = unapplyMember(orig.symbol.filter(sym => reallyExists(unapplyMember(sym.tpe))).tpe).tpe
// private val extractorTp = if (wellKinded(fun.tpe)) fun.tpe else existentialAbstraction(origExtractorTp.typeParams, origExtractorTp.resultType)
- // println("ExtractorCallProd: "+ (fun.tpe, existentialAbstraction(origExtractorTp.typeParams, origExtractorTp.resultType)))
- // println("ExtractorCallProd: "+ (fun.tpe, args map (_.tpe)))
+ // patmatDebug("ExtractorCallProd: "+ (fun.tpe, existentialAbstraction(origExtractorTp.typeParams, origExtractorTp.resultType)))
+ // patmatDebug("ExtractorCallProd: "+ (fun.tpe, args map (_.tpe)))
private def constructorTp = fun.tpe
def isTyped = fun.isTyped
@@ -627,14 +635,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def indexInCPA(acc: Symbol) =
constrParamAccessors indexWhere { orig =>
- // println("compare: "+ (orig, acc, orig.name, acc.name, (acc.name == orig.name), (acc.name startsWith (orig.name append "$"))))
+ // patmatDebug("compare: "+ (orig, acc, orig.name, acc.name, (acc.name == orig.name), (acc.name startsWith (orig.name append "$"))))
val origName = orig.name.toString.trim
val accName = acc.name.toString.trim
(accName == origName) || (accName startsWith (origName + "$"))
}
- // println("caseFieldAccessors: "+ (accessors, binder.caseFieldAccessors map indexInCPA))
- // println("constrParamAccessors: "+ constrParamAccessors)
+ // patmatDebug("caseFieldAccessors: "+ (accessors, binder.caseFieldAccessors map indexInCPA))
+ // patmatDebug("constrParamAccessors: "+ constrParamAccessors)
val accessorsSorted = accessors sortBy indexInCPA
if (accessorsSorted isDefinedAt (i-1)) REF(binder) DOT accessorsSorted(i-1)
@@ -793,6 +801,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
None
abstract class TreeMaker {
+ def pos: Position
+
/** captures the scope and the value of the bindings in patterns
* important *when* the substitution happens (can't accumulate and do at once after the full matcher has been constructed)
*/
@@ -804,7 +814,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
private[TreeMakers] def incorporateOuterSubstitution(outerSubst: Substitution): Unit = {
if (currSub ne null) {
- println("BUG: incorporateOuterSubstitution called more than once for "+ (this, currSub, outerSubst))
+ // patmatDebug("BUG: incorporateOuterSubstitution called more than once for "+ (this, currSub, outerSubst))
Thread.dumpStack()
}
else currSub = outerSubst >> substitution
@@ -820,16 +830,22 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
case class TrivialTreeMaker(tree: Tree) extends TreeMaker with NoNewBinders {
+ def pos = tree.pos
+
def chainBefore(next: Tree)(casegen: Casegen): Tree = tree
}
case class BodyTreeMaker(body: Tree, matchPt: Type) extends TreeMaker with NoNewBinders {
+ def pos = body.pos
+
def chainBefore(next: Tree)(casegen: Casegen): Tree = // assert(next eq EmptyTree)
atPos(body.pos)(casegen.one(substitution(body))) // since SubstOnly treemakers are dropped, need to do it here
override def toString = "B"+(body, matchPt)
}
case class SubstOnlyTreeMaker(prevBinder: Symbol, nextBinder: Symbol) extends TreeMaker {
+ val pos = NoPosition
+
val localSubstitution = Substitution(prevBinder, CODE.REF(nextBinder))
def chainBefore(next: Tree)(casegen: Casegen): Tree = substitution(next)
override def toString = "S"+ localSubstitution
@@ -837,10 +853,10 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
abstract class FunTreeMaker extends TreeMaker {
val nextBinder: Symbol
+ def pos = nextBinder.pos
}
abstract class CondTreeMaker extends FunTreeMaker {
- val pos: Position
val prevBinder: Symbol
val nextBinderTp: Type
val cond: Tree
@@ -962,11 +978,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
- A parameterized type pattern scala.Array[T1], where T1 is a type pattern. // TODO
This type pattern matches any non-null instance of type scala.Array[U1], where U1 is a type matched by T1.
**/
- case class TypeTestTreeMaker(prevBinder: Symbol, testedBinder: Symbol, expectedTp: Type, nextBinderTp: Type)(_pos: Position, extractorArgTypeTest: Boolean = false) extends CondTreeMaker {
- val pos = _pos
-
+ case class TypeTestTreeMaker(prevBinder: Symbol, testedBinder: Symbol, expectedTp: Type, nextBinderTp: Type)(override val pos: Position, extractorArgTypeTest: Boolean = false) extends CondTreeMaker {
import TypeTestTreeMaker._
- // println("TTTM"+(prevBinder, extractorArgTypeTest, testedBinder, expectedTp, nextBinderTp))
+ // patmatDebug("TTTM"+(prevBinder, extractorArgTypeTest, testedBinder, expectedTp, nextBinderTp))
lazy val outerTestNeeded = (
!((expectedTp.prefix eq NoPrefix) || expectedTp.prefix.typeSymbol.isPackageClass)
@@ -985,6 +999,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
if (outerTestNeeded) and(typeTest(testedBinder, expectedTp), outerTest(testedBinder, expectedTp))
else typeTest(testedBinder, expectedTp)
+ // propagate expected type
+ @inline def expTp(t: Tree): t.type = t setType expectedTp
+
// true when called to type-test the argument to an extractor
// don't do any fancy equality checking, just test the type
if (extractorArgTypeTest) default
@@ -994,11 +1011,10 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case SingleType(_, sym) => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen))
// must use == to support e.g. List() == Nil
case ThisType(sym) if sym.isModule => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen))
- case ConstantType(const) => equalsTest(Literal(const), testedBinder)
-
- case ThisType(sym) => eqTest(This(sym), testedBinder)
case ConstantType(Constant(null)) if testedBinder.info.widen <:< AnyRefClass.tpe
- => eqTest(CODE.NULL, testedBinder)
+ => eqTest(expTp(CODE.NULL), testedBinder)
+ case ConstantType(const) => equalsTest(expTp(Literal(const)), testedBinder)
+ case ThisType(sym) => eqTest(expTp(This(sym)), testedBinder)
// TODO: verify that we don't need to special-case Array
// I think it's okay:
@@ -1023,7 +1039,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
// need to substitute to deal with existential types -- TODO: deal with existentials better, don't substitute (see RichClass during quick.comp)
- case class EqualityTestTreeMaker(prevBinder: Symbol, patTree: Tree, pos: Position) extends CondTreeMaker {
+ case class EqualityTestTreeMaker(prevBinder: Symbol, patTree: Tree, override val pos: Position) extends CondTreeMaker {
val nextBinderTp = prevBinder.info.widen
// NOTE: generate `patTree == patBinder`, since the extractor must be in control of the equals method (also, patBinder may be null)
@@ -1056,6 +1072,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
case class GuardTreeMaker(guardTree: Tree) extends TreeMaker with NoNewBinders {
+ val pos = guardTree.pos
+
def chainBefore(next: Tree)(casegen: Casegen): Tree = casegen.flatMapGuard(substitution(guardTree), next)
override def toString = "G("+ guardTree +")"
}
@@ -1090,22 +1108,21 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
fixerUpper(owner, scrut.pos){
val ptDefined = if (isFullyDefined(pt)) pt else NoType
def matchFailGen = (matchFailGenOverride orElse Some(CODE.MATCHERROR(_: Tree)))
- // println("combining cases: "+ (casesNoSubstOnly.map(_.mkString(" >> ")).mkString("{", "\n", "}")))
-
- def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation SwitchClass
- def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation UncheckedClass
-
- val (unchecked, requireSwitch) = scrut match {
- case Typed(_, tpt) =>
- (isUncheckedAnnotation(tpt.tpe),
- // matches with two or fewer cases need not apply for switchiness (if-then-else will do)
- isSwitchAnnotation(tpt.tpe) && casesNoSubstOnly.lengthCompare(2) > 0)
- case _ =>
- (false, false)
- }
+ // patmatDebug("combining cases: "+ (casesNoSubstOnly.map(_.mkString(" >> ")).mkString("{", "\n", "}")))
+
+ val (unchecked, requireSwitch) =
+ if (settings.XnoPatmatAnalysis.value) (true, false)
+ else scrut match {
+ case Typed(_, tpt) =>
+ (treeInfo.isUncheckedAnnotation(tpt.tpe),
+ // matches with two or fewer cases need not apply for switchiness (if-then-else will do)
+ treeInfo.isSwitchAnnotation(tpt.tpe) && casesNoSubstOnly.lengthCompare(2) > 0)
+ case _ =>
+ (false, false)
+ }
emitSwitch(scrut, scrutSym, casesNoSubstOnly, pt, matchFailGenOverride).getOrElse{
- if (requireSwitch) typer.context.unit.error(scrut.pos, "could not emit switch for @switch annotated match")
+ if (requireSwitch) typer.context.unit.warning(scrut.pos, "could not emit switch for @switch annotated match")
if (casesNoSubstOnly nonEmpty) {
// before optimizing, check casesNoSubstOnly for presence of a default case,
@@ -1145,12 +1162,12 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
t match {
case Function(_, _) if t.symbol == NoSymbol =>
t.symbol = currentOwner.newAnonymousFunctionValue(t.pos)
- // println("new symbol for "+ (t, t.symbol.ownerChain))
+ // patmatDebug("new symbol for "+ (t, t.symbol.ownerChain))
case Function(_, _) if (t.symbol.owner == NoSymbol) || (t.symbol.owner == origOwner) =>
- // println("fundef: "+ (t, t.symbol.ownerChain, currentOwner.ownerChain))
+ // patmatDebug("fundef: "+ (t, t.symbol.ownerChain, currentOwner.ownerChain))
t.symbol.owner = currentOwner
case d : DefTree if (d.symbol != NoSymbol) && ((d.symbol.owner == NoSymbol) || (d.symbol.owner == origOwner)) => // don't indiscriminately change existing owners! (see e.g., pos/t3440, pos/t3534, pos/unapplyContexts2)
- // println("def: "+ (d, d.symbol.ownerChain, currentOwner.ownerChain))
+ // patmatDebug("def: "+ (d, d.symbol.ownerChain, currentOwner.ownerChain))
if(d.symbol.isLazy) { // for lazy val's accessor -- is there no tree??
assert(d.symbol.lazyAccessor != NoSymbol && d.symbol.lazyAccessor.owner == d.symbol.owner, d.symbol.lazyAccessor)
d.symbol.lazyAccessor.owner = currentOwner
@@ -1160,16 +1177,16 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
d.symbol.owner = currentOwner
// case _ if (t.symbol != NoSymbol) && (t.symbol ne null) =>
- // println("untouched "+ (t, t.getClass, t.symbol.ownerChain, currentOwner.ownerChain))
+ // patmatDebug("untouched "+ (t, t.getClass, t.symbol.ownerChain, currentOwner.ownerChain))
case _ =>
}
super.traverse(t)
}
// override def apply
- // println("before fixerupper: "+ xTree)
+ // patmatDebug("before fixerupper: "+ xTree)
// currentRun.trackerFactory.snapshot()
- // println("after fixerupper")
+ // patmatDebug("after fixerupper")
// currentRun.trackerFactory.snapshot()
}
}
@@ -1234,7 +1251,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def _asInstanceOf(t: Tree, tp: Type, force: Boolean = false): Tree = if (!force && (t.tpe ne NoType) && t.isTyped && typesConform(t.tpe, tp)) t else mkCast(t, tp)
def _asInstanceOf(b: Symbol, tp: Type): Tree = if (typesConform(b.info, tp)) REF(b) else mkCast(REF(b), tp)
def _isInstanceOf(b: Symbol, tp: Type): Tree = gen.mkIsInstanceOf(REF(b), tp.withoutAnnotations, true, false)
- // if (typesConform(b.info, tpX)) { println("warning: emitted spurious isInstanceOf: "+(b, tp)); TRUE }
+ // if (typesConform(b.info, tpX)) { patmatDebug("warning: emitted spurious isInstanceOf: "+(b, tp)); TRUE }
// duplicated out of frustration with cast generation
def mkZero(tp: Type): Tree = {
@@ -1315,11 +1332,11 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// def andThen_: (prev: List[Test]): List[Test] =
// prev.filterNot(this <:< _) :+ this
- private val reusedBy = new collection.mutable.HashSet[Test]
+ // private val reusedBy = new collection.mutable.HashSet[Test]
var reuses: Option[Test] = None
def registerReuseBy(later: Test): Unit = {
assert(later.reuses.isEmpty, later.reuses)
- reusedBy += later
+ // reusedBy += later
later.reuses = Some(this)
}
@@ -1414,19 +1431,51 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// returns (tree, tests), where `tree` will be used to refer to `root` in `tests`
- abstract class TreeMakersToConds(val root: Symbol, val cases: List[List[TreeMaker]]) {
+ abstract class TreeMakersToConds(val root: Symbol) {
+ def discard() = {
+ pointsToBound.clear()
+ trees.clear()
+ normalize = EmptySubstitution
+ accumSubst = EmptySubstitution
+ }
// a variable in this set should never be replaced by a tree that "does not consist of a selection on a variable in this set" (intuitively)
- private val pointsToBound = collection.mutable.HashSet(root)
+ private val pointsToBound = collection.mutable.HashSet(root)
+ private val trees = collection.mutable.HashSet.empty[Tree]
// the substitution that renames variables to variables in pointsToBound
private var normalize: Substitution = EmptySubstitution
// replaces a variable (in pointsToBound) by a selection on another variable in pointsToBound
+ // in the end, instead of having x1, x1.hd, x2, x2.hd, ... flying around,
+ // we want something like x1, x1.hd, x1.hd.tl, x1.hd.tl.hd, so that we can easily recognize when
+ // we're testing the same variable
// TODO check:
// pointsToBound -- accumSubst.from == Set(root) && (accumSubst.from.toSet -- pointsToBound) isEmpty
private var accumSubst: Substitution = EmptySubstitution
- private val trees = new collection.mutable.HashSet[Tree]
+ private def updateSubstitution(subst: Substitution) = {
+ // find part of substitution that replaces bound symbols by new symbols, and reverse that part
+ // so that we don't introduce new aliases for existing symbols, thus keeping the set of bound symbols minimal
+ val (boundSubst, unboundSubst) = (subst.from zip subst.to) partition {
+ case (f, t) =>
+ t.isInstanceOf[Ident] && (t.symbol ne NoSymbol) && pointsToBound(f)
+ }
+ val (boundFrom, boundTo) = boundSubst.unzip
+ val (unboundFrom, unboundTo) = unboundSubst.unzip
+
+ // reverse substitution that would otherwise replace a variable we already encountered by a new variable
+ // NOTE: this forgets the more precise type we have for these later variables, but that's probably okay
+ normalize >>= Substitution(boundTo map (_.symbol), boundFrom map (CODE.REF(_)))
+ // patmatDebug("normalize: "+ normalize)
+
+ val okSubst = Substitution(unboundFrom, unboundTo map (normalize(_))) // it's important substitution does not duplicate trees here -- it helps to keep hash consing simple, anyway
+ pointsToBound ++= ((okSubst.from, okSubst.to).zipped filter { (f, t) => pointsToBound exists (sym => t.exists(_.symbol == sym)) })._1
+ // patmatDebug("pointsToBound: "+ pointsToBound)
+
+ accumSubst >>= okSubst
+ // patmatDebug("accumSubst: "+ accumSubst)
+ }
+
// TODO: improve, e.g., for constants
def sameValue(a: Tree, b: Tree): Boolean = (a eq b) || ((a, b) match {
@@ -1436,8 +1485,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// hashconsing trees (modulo value-equality)
def unique(t: Tree, tpOverride: Type = NoType): Tree =
- trees find (a => a.equalsStructure0(t)(sameValue)) match {
- case Some(orig) => orig // println("unique: "+ (t eq orig, orig));
+ trees find (a => a.correspondsStructure(t)(sameValue)) match {
+ case Some(orig) => orig // patmatDebug("unique: "+ (t eq orig, orig));
case _ =>
trees += t
if (tpOverride != NoType) t setType tpOverride
@@ -1454,28 +1503,40 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// produce the unique tree used to refer to this binder
// the type of the binder passed to the first invocation
// determines the type of the tree that'll be returned for that binder as of then
- def binderToUniqueTree(b: Symbol) =
+ final def binderToUniqueTree(b: Symbol) =
unique(accumSubst(normalize(CODE.REF(b))), b.tpe)
+ @inline def /\(conds: Iterable[Cond]) = if (conds.isEmpty) Top else conds.reduceLeft(AndCond(_, _))
+ @inline def \/(conds: Iterable[Cond]) = if (conds.isEmpty) Havoc else conds.reduceLeft(OrCond(_, _))
+
// note that the sequencing of operations is important: must visit in same order as match execution
// binderToUniqueTree uses the type of the first symbol that was encountered as the type for all future binders
- def treeMakerToCond(tm: TreeMaker): Cond = {
+ final protected def treeMakerToCond(tm: TreeMaker, condMaker: CondMaker): Cond = {
updateSubstitution(tm.substitution)
+ condMaker(tm)(treeMakerToCond(_, condMaker))
+ }
+ final protected def treeMakerToCondNoSubst(tm: TreeMaker, condMaker: CondMaker): Cond =
+ condMaker(tm)(treeMakerToCondNoSubst(_, condMaker))
+
+ type CondMaker = TreeMaker => (TreeMaker => Cond) => Cond
+ final def makeCond(tm: TreeMaker)(recurse: TreeMaker => Cond): Cond = {
tm match {
case ttm@TypeTestTreeMaker(prevBinder, testedBinder, pt, _) =>
object condStrategy extends TypeTestTreeMaker.TypeTestCondStrategy {
type Result = Cond
def and(a: Result, b: Result) = AndCond(a, b)
def outerTest(testedBinder: Symbol, expectedTp: Type) = Top // TODO OuterEqCond(testedBinder, expectedType)
- def typeTest(b: Symbol, pt: Type) = TypeCond(binderToUniqueTree(b), uniqueTp(pt))
+ def typeTest(b: Symbol, pt: Type) = { // a type test implies the tested path is non-null (null.isInstanceOf[T] is false for all T)
+ val p = binderToUniqueTree(b); AndCond(NonNullCond(p), TypeCond(p, uniqueTp(pt)))
+ }
def nonNullTest(testedBinder: Symbol) = NonNullCond(binderToUniqueTree(testedBinder))
def equalsTest(pat: Tree, testedBinder: Symbol) = EqualityCond(binderToUniqueTree(testedBinder), unique(pat))
def eqTest(pat: Tree, testedBinder: Symbol) = EqualityCond(binderToUniqueTree(testedBinder), unique(pat)) // TODO: eq, not ==
}
ttm.renderCondition(condStrategy)
case EqualityTestTreeMaker(prevBinder, patTree, _) => EqualityCond(binderToUniqueTree(prevBinder), unique(patTree))
- case AlternativesTreeMaker(_, altss, _) => altss map (_ map treeMakerToCond reduceLeft AndCond) reduceLeft OrCond
+ case AlternativesTreeMaker(_, altss, _) => \/(altss map (alts => /\(alts map recurse)))
case ProductExtractorTreeMaker(testedBinder, None, subst) => NonNullCond(binderToUniqueTree(testedBinder))
case ExtractorTreeMaker(_, _, _, _)
| GuardTreeMaker(_)
@@ -1485,47 +1546,24 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
}
- private def updateSubstitution(subst: Substitution) = {
- // find part of substitution that replaces bound symbols by new symbols, and reverse that part
- // so that we don't introduce new aliases for existing symbols, thus keeping the set of bound symbols minimal
- val (boundSubst, unboundSubst) = (subst.from zip subst.to) partition {case (f, t) =>
- t.isInstanceOf[Ident] && (t.symbol ne NoSymbol) && pointsToBound(f)
- }
- val (boundFrom, boundTo) = boundSubst.unzip
- val (unboundFrom, unboundTo) = unboundSubst.unzip
-
- // reverse substitution that would otherwise replace a variable we already encountered by a new variable
- // NOTE: this forgets the more precise we have for these later variables, but that's probably okay
- normalize >>= Substitution(boundTo map (_.symbol), boundFrom map (CODE.REF(_)))
- // println("normalize: "+ normalize)
-
- val okSubst = Substitution(unboundFrom, unboundTo map (normalize(_))) // it's important substitution does not duplicate trees here -- it helps to keep hash consing simple, anyway
- pointsToBound ++= ((okSubst.from, okSubst.to).zipped filter { (f, t) => pointsToBound exists (sym => t.exists(_.symbol == sym)) })._1
- // println("pointsToBound: "+ pointsToBound)
-
- accumSubst >>= okSubst
- // println("accumSubst: "+ accumSubst)
- }
-
- def approximateTreeMaker(tm: TreeMaker): Test =
- Test(treeMakerToCond(tm), tm)
+ final def approximateMatch(cases: List[List[TreeMaker]], condMaker: CondMaker = makeCond): List[List[Test]] = cases.map { _ map (tm => Test(treeMakerToCond(tm, condMaker), tm)) }
- def approximateMatch: List[List[Test]] = cases.map { _ map approximateTreeMaker }
+ final def approximateMatchAgain(cases: List[List[TreeMaker]], condMaker: CondMaker = makeCond): List[List[Test]] = cases.map { _ map (tm => Test(treeMakerToCondNoSubst(tm, condMaker), tm)) }
}
def approximateMatch(root: Symbol, cases: List[List[TreeMaker]]): List[List[Test]] = {
- object approximator extends TreeMakersToConds(root, cases)
- approximator.approximateMatch
+ object approximator extends TreeMakersToConds(root)
+ approximator.approximateMatch(cases)
}
def showTreeMakers(cases: List[List[TreeMaker]]) = {
- println("treeMakers:")
- println(alignAcrossRows(cases, ">>"))
+ patmatDebug("treeMakers:")
+ patmatDebug(alignAcrossRows(cases, ">>"))
}
def showTests(testss: List[List[Test]]) = {
- println("tests: ")
- println(alignAcrossRows(testss, "&"))
+ patmatDebug("tests: ")
+ patmatDebug(alignAcrossRows(testss, "&"))
}
}
@@ -1560,18 +1598,33 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
class Prop
case class Eq(p: Var, q: Const) extends Prop
- type Const
+ type Const <: AbsConst
+
+ trait AbsConst {
+ def implies(other: Const): Boolean
+ def excludes(other: Const): Boolean
+ }
+
type Var <: AbsVar
trait AbsVar {
- // if the domain is enumerable, at least one assignment must be true
- def domainEnumerable: Boolean
- def domain: Option[Set[Const]]
+ // indicate we may later require a prop for V = C
+ def registerEquality(c: Const): Unit
+
+ // indicates null is part of the domain
+ def considerNull: Unit
+
+ // compute the domain and return it (call considerNull first!)
+ def domainSyms: Option[Set[Sym]]
// for this var, call it V, turn V = C into the equivalent proposition in boolean logic
+ // registerEquality(c) must have been called prior to this call
+ // in fact, all equalities relevant to this variable must have been registered
def propForEqualsTo(c: Const): Prop
- def equalitySyms: Set[Sym]
+ // populated by registerEquality
+ // once equalitySyms has been called, must not call registerEquality anymore
+ def equalitySyms: List[Sym]
}
// would be nice to statically check whether a prop is equational or pure,
@@ -1583,12 +1636,17 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case object True extends Prop
case object False extends Prop
- private def nextSymId = {_symId += 1; _symId}; private var _symId = 0
-
// symbols are propositions
case class Sym(val variable: Var, val const: Const) extends Prop {
- override val toString = variable +"="+ const +"#"+ nextSymId
+ private[this] val id = nextSymId
+ override def toString = variable +"="+ const +"#"+ id
}
+ private def nextSymId = {_symId += 1; _symId}; private var _symId = 0
+
+
+ @inline def /\(props: Iterable[Prop]) = if (props.isEmpty) True else props.reduceLeft(And(_, _))
+ @inline def \/(props: Iterable[Prop]) = if (props.isEmpty) False else props.reduceLeft(Or(_, _))
+
trait PropTraverser {
def apply(x: Prop): Unit = x match {
@@ -1602,6 +1660,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def applyConst(x: Const): Unit = {}
}
+ def gatherVariables(p: Prop): Set[Var] = {
+ val vars = new HashSet[Var]()
+ (new PropTraverser {
+ override def applyVar(v: Var) = vars += v
+ })(p)
+ vars.toSet
+ }
+
trait PropMap {
def apply(x: Prop): Prop = x match { // TODO: mapConserve
case And(a, b) => And(apply(a), apply(b))
@@ -1611,287 +1677,670 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
}
- // plan: (aka TODO)
+ // convert finite domain propositional logic with subtyping to pure boolean propositional logic
+ // a type test or a value equality test are modelled as a variable being equal to some constant
+ // a variable V may be assigned multiple constants, as long as they do not contradict each other
+ // according to subtyping, e.g., V = ConstantType(1) and V = Int are valid assignments
+ // we rewrite V = C to a fresh boolean symbol, and model what we know about the variable's domain
+ // in a prelude (the equality axioms)
+ // 1. a variable with a closed domain (of a sealed type) must be assigned one of the instantiatable types in its domain
+ // 2. for each variable V in props, and each constant C it is compared to,
+ // compute which assignments imply each other (as in the example above: V = 1 implies V = Int)
+ // and which assignments are mutually exclusive (V = String implies -(V = Int))
+ //
+ // note that this is a conservative approximation: V = Constant(A) and V = Constant(B)
+ // are considered mutually exclusive (and thus both cases are considered reachable in {case A => case B =>}),
+ // even though A may be equal to B (and thus the second case is not "dynamically reachable")
+ //
+ // TODO: for V1 representing x1 and V2 standing for x1.head, encode that
+ // V1 = Nil implies -(V2 = Ci) for all Ci in V2's domain (i.e., it is unassignable)
+ def removeVarEq(props: List[Prop], considerNull: Boolean = false): (Prop, List[Prop]) = {
+ val start = startTimer(patmatAnaVarEq)
- // convert finite domain propositional logic to boolean propositional logic
- // for all c in C, there is a corresponding (meta-indexed) proposition Qv(c) that represents V = c,
- // the only property of equality that is encoded is that a variable can at most be equal to one of the c in C:
- // thus, for each distinct c, c', c'',... in C, a clause `not (Qv(c) /\ (Qv(c') \/ ... \/ Qv(c'')))` is added
- def removeVarEq(prop: Prop): Prop = {
val vars = new collection.mutable.HashSet[Var]
- object dropEquational extends PropMap {
+ object gatherEqualities extends PropTraverser {
override def apply(p: Prop) = p match {
- case Eq(v, c) => vars += v; v.propForEqualsTo(c)
+ case Eq(v, c) =>
+ vars += v
+ v.registerEquality(c)
case _ => super.apply(p)
}
}
- // dropEquational populates vars, and for each var in vars. var.equalitySyms
- val pure = dropEquational(prop)
+ object rewriteEqualsToProp extends PropMap {
+ override def apply(p: Prop) = p match {
+ case Eq(v, c) => v.propForEqualsTo(c)
+ case _ => super.apply(p)
+ }
+ }
- // X = C is translated to P_X=C
- // X = C' is translated to P_X=C'
- // need to enforce X cannot simultaneously equal C and C'
- // thus, all equality syms are mutually exclusive
- // X = A, B, C, D --> Not(And(A, B)) /\ Not(And(A, C)) /\ Not(And(A, D))
- // /\ Not(And(B, C)) /\ Not(And(B, D))
- // /\ Not(And(C, D))
- // equivalently Or(Not(A), Not(B)) /\ Or(...)
+ props foreach gatherEqualities.apply
+ if (considerNull) vars foreach (_.considerNull)
+
+ val pure = props map rewriteEqualsToProp.apply
var eqAxioms: Prop = True
- def mutex(a: Sym)(b: Sym) =
- eqAxioms = And(eqAxioms, Or(Not(a), Not(b)))
+ @inline def addAxiom(p: Prop) = eqAxioms = And(eqAxioms, p)
- // at least one assignment from the domain must be true
- def assigned(dom: Set[Sym]) =
- eqAxioms = And(eqAxioms, dom.reduceLeft(Or))
+ case class ExcludedPair(a: Const, b: Const) {
+ override def equals(o: Any) = o match {
+ case ExcludedPair(aa, bb) => (a == aa && b == bb) || (a == bb && b == aa)
+ case _ => false
+ }
+ // make ExcludedPair(a, b).hashCode == ExcludedPair(b, a).hashCode
+ override def hashCode = a.hashCode ^ b.hashCode
+ }
- // println("vars: "+ vars)
+ // patmatDebug("vars: "+ vars)
vars.foreach { v =>
- // is the domain enumerable? then create equality syms for all elements in the domain and
- // assert at least one of them must be selected
- // if v.domain.isEmpty, we must consider the domain to be infinite
- v.domain foreach { dom =>
- // get the Syms for the constants in the domain (making fresh ones for those not encountered in the formula)
- val domProps = dom map {c => v.propForEqualsTo(c)}
- val domSyms = new collection.mutable.HashSet[Sym]()
- object collectSyms extends PropTraverser {
- override def apply(p: Prop) = p match {
- case domSym: Sym => domSyms += domSym
- case _ => super.apply(p)
- }
+ val excludedPair = new collection.mutable.HashSet[ExcludedPair]
+
+ // if v.domainSyms.isEmpty, we must consider the domain to be infinite
+ // otherwise, since the domain fully partitions the type of the value,
+ // exactly one of the types (and whatever it implies, imposed separately) must be chosen
+ // consider X ::= A | B | C, and A => B
+ // coverage is formulated as: A \/ B \/ C and the implications are
+ v.domainSyms foreach { dsyms => addAxiom(\/(dsyms)) }
+
+ val syms = v.equalitySyms
+ // patmatDebug("eqSyms "+(v, syms))
+ syms foreach { sym =>
+ // if we've already excluded the pair at some point (-A \/ -B), then don't exclude the symmetric one (-B \/ -A)
+ // (nor the positive implications -B \/ A, or -A \/ B, which would entail the equality axioms falsifying the whole formula)
+ val todo = syms filterNot (b => (b.const == sym.const) || excludedPair(ExcludedPair(b.const, sym.const)))
+ val (excluded, notExcluded) = todo partition (b => sym.const.excludes(b.const))
+ val implied = notExcluded filter (b => sym.const.implies(b.const))
+ // patmatDebug("implications: "+ (sym.const, excluded, implied, syms))
+
+ // when this symbol is true, what must hold...
+ implied foreach (impliedSym => addAxiom(Or(Not(sym), impliedSym)))
+
+ // ... and what must not?
+ excluded foreach {excludedSym =>
+ excludedPair += ExcludedPair(sym.const, excludedSym.const)
+ addAxiom(Or(Not(sym), Not(excludedSym)))
}
- domProps foreach collectSyms.apply
-
- // TODO: an empty domain means involved type tests can never be true --> always non-exhaustive?
- if (domSyms.nonEmpty) assigned(domSyms.toSet)
- }
-
- // recover mutual-exclusivity (a variable can never be assigned two different constants)
- var syms = v.equalitySyms.toList
- while (syms.nonEmpty) {
- syms.tail.foreach(mutex(syms.head))
- syms = syms.tail
}
}
- // println("eqAxioms:\n"+ cnfString(conjunctiveNormalForm(negationNormalForm(eqAxioms))))
- // println("pure:\n"+ cnfString(conjunctiveNormalForm(negationNormalForm(pure))))
+ // patmatDebug("eqAxioms:\n"+ cnfString(eqFreePropToSolvable(eqAxioms)))
+ // patmatDebug("pure:\n"+ cnfString(eqFreePropToSolvable(pure)))
+
+ stopTimer(patmatAnaVarEq, start)
- And(eqAxioms, pure)
+ (eqAxioms, pure)
}
- // convert propositional logic formula to CNF
- // http://www.dcs.warwick.ac.uk/people/academic/Ranko.Lazic/fsv/fsv6.pdf
- def negationNormalForm(p: Prop): Prop = p match {
- case And(a, b) => And(negationNormalForm(a), negationNormalForm(b))
- case Or(a, b) => Or(negationNormalForm(a), negationNormalForm(b))
- case Not(And(a, b)) => negationNormalForm(Or(Not(a), Not(b)))
- case Not(Or(a, b)) => negationNormalForm(And(Not(a), Not(b)))
- case Not(Not(p)) => negationNormalForm(p)
- case Not(True) => False
- case Not(False) => True
- case True
- | False
- | (_ : Sym)
- | Not(_ : Sym) => p
+
+ type Formula
+ def andFormula(a: Formula, b: Formula): Formula
+
+ class CNFBudgetExceeded extends RuntimeException("CNF budget exceeded")
+
+ // may throw an CNFBudgetExceeded
+ def propToSolvable(p: Prop) = {
+ val (eqAxioms, pure :: Nil) = removeVarEq(List(p), considerNull = false)
+ eqFreePropToSolvable(And(eqAxioms, pure))
}
+ def eqFreePropToSolvable(p: Prop): Formula
+ def cnfString(f: Formula): String
+
+ type Model = Map[Sym, Boolean]
+ val EmptyModel: Model
+ val NoModel: Model
+
+ def findModelFor(f: Formula): Model
+ def findAllModelsFor(f: Formula): List[Model]
+ }
+
+ trait CNF extends Logic {
// CNF: a formula is a conjunction of clauses
- type Formula = List[Clause] ; def formula(c: Clause*): Formula = c.toList
+ type Formula = Array[Clause]
+ def formula(c: Clause*): Formula = c.toArray
+ def andFormula(a: Formula, b: Formula): Formula = a ++ b
// a clause is a disjunction of distinct literals
- type Clause = Set[Lit] ; def clause(l: Lit*): Clause = l.toSet
+ type Clause = Set[Lit]
+ def clause(l: Lit*): Clause = l.toSet
+ @inline private def merge(a: Clause, b: Clause) = a ++ b
+
+ type Lit
+ def Lit(sym: Sym, pos: Boolean = true): Lit
+
+ // throws an CNFBudgetExceeded when the prop results in a CNF that's too big
+ def eqFreePropToSolvable(p: Prop): Formula = {
+ // TODO: for now, reusing the normalization from DPLL
+ def negationNormalForm(p: Prop): Prop = p match {
+ case And(a, b) => And(negationNormalForm(a), negationNormalForm(b))
+ case Or(a, b) => Or(negationNormalForm(a), negationNormalForm(b))
+ case Not(And(a, b)) => negationNormalForm(Or(Not(a), Not(b)))
+ case Not(Or(a, b)) => negationNormalForm(And(Not(a), Not(b)))
+ case Not(Not(p)) => negationNormalForm(p)
+ case Not(True) => False
+ case Not(False) => True
+ case True
+ | False
+ | (_ : Sym)
+ | Not(_ : Sym) => p
+ }
+
+ val TrueF = formula()
+ val FalseF = formula(clause())
+ def lit(s: Sym) = formula(clause(Lit(s)))
+ def negLit(s: Sym) = formula(clause(Lit(s, false)))
+
+ def conjunctiveNormalForm(p: Prop, budget: Int = 256): Formula = {
+ def distribute(a: Formula, b: Formula, budget: Int): Formula =
+ if (budget <= 0) throw new CNFBudgetExceeded
+ else
+ (a, b) match {
+ // true \/ _ = true
+ // _ \/ true = true
+ case (trueA, trueB) if trueA.size == 0 || trueB.size == 0 => TrueF
+ // lit \/ lit
+ case (a, b) if a.size == 1 && b.size == 1 => formula(merge(a(0), b(0)))
+ // (c1 /\ ... /\ cn) \/ d = ((c1 \/ d) /\ ... /\ (cn \/ d))
+ // d \/ (c1 /\ ... /\ cn) = ((d \/ c1) /\ ... /\ (d \/ cn))
+ case (cs, ds) =>
+ val (big, small) = if (cs.size > ds.size) (cs, ds) else (ds, cs)
+ big flatMap (c => distribute(formula(c), small, budget - (big.size*small.size)))
+ }
- // a literal is a (possibly negated) variable
- case class Lit(sym: Sym, pos: Boolean = true) {
- override def toString = if (!pos) "-"+ sym.toString else sym.toString
- def unary_- = Lit(sym, !pos)
+ if (budget <= 0) throw new CNFBudgetExceeded
+
+ p match {
+ case True => TrueF
+ case False => FalseF
+ case s: Sym => lit(s)
+ case Not(s: Sym) => negLit(s)
+ case And(a, b) =>
+ val cnfA = conjunctiveNormalForm(a, budget - 1)
+ val cnfB = conjunctiveNormalForm(b, budget - cnfA.size)
+ cnfA ++ cnfB
+ case Or(a, b) =>
+ val cnfA = conjunctiveNormalForm(a)
+ val cnfB = conjunctiveNormalForm(b)
+ distribute(cnfA, cnfB, budget - (cnfA.size + cnfB.size))
+ }
+ }
+
+ val start = startTimer(patmatCNF)
+ val res = conjunctiveNormalForm(negationNormalForm(p))
+ stopTimer(patmatCNF, start)
+ patmatCNFSizes(res.size) += 1
+
+// patmatDebug("cnf for\n"+ p +"\nis:\n"+cnfString(res))
+ res
}
- val TrueF = formula()
- val FalseF = formula(clause())
- def lit(s: Sym) = formula(clause(Lit(s)))
- def negLit(s: Sym) = formula(clause(Lit(s, false)))
+ }
- def conjunctiveNormalForm(p: Prop): Formula = {
- def distribute(a: Formula, b: Formula): Formula = (a, b) match {
- // true \/ _ = true
- case (TrueF, _) => TrueF
- // _ \/ true = true
- case (_, TrueF) => TrueF
- // lit \/ lit
- case (List(a), List(b)) => formula(a ++ b)
- // (c1 /\ ... /\ cn) \/ d = ((c1 \/ d) /\ ... /\ (cn \/ d))
- case (cs, d) if cs.tail nonEmpty => cs flatMap (c => distribute(formula(c), d))
- // d \/ (c1 /\ ... /\ cn) = ((d \/ c1) /\ ... /\ (d \/ cn))
- case (d, cs) if cs.tail nonEmpty => cs flatMap (c => distribute(d, formula(c)))
+ trait DPLLSolver extends CNF {
+ // a literal is a (possibly negated) variable
+ def Lit(sym: Sym, pos: Boolean = true) = new Lit(sym, pos)
+ class Lit(val sym: Sym, val pos: Boolean) {
+ override def toString = if (!pos) "-"+ sym.toString else sym.toString
+ override def equals(o: Any) = o match {
+ case o: Lit => (o.sym == sym) && (o.pos == pos)
+ case _ => false
}
+ override def hashCode = sym.hashCode + pos.hashCode
- p match {
- case True => TrueF
- case False => FalseF
- case s: Sym => lit(s)
- case Not(s: Sym) => negLit(s)
- case And(a, b) => conjunctiveNormalForm(a) ++ conjunctiveNormalForm(b)
- case Or(a, b) => distribute(conjunctiveNormalForm(a), conjunctiveNormalForm(b))
- }
+ def unary_- = Lit(sym, !pos)
}
- def normalize(p: Prop) = conjunctiveNormalForm(negationNormalForm(removeVarEq(p)))
def cnfString(f: Formula) = alignAcrossRows(f map (_.toList) toList, "\\/", " /\\\n")
// adapted from http://lara.epfl.ch/w/sav10:simple_sat_solver (original by Hossein Hojjat)
- type Model = Map[Sym, Boolean]
val EmptyModel = Map.empty[Sym, Boolean]
+ val NoModel: Model = null
// returns all solutions, if any (TODO: better infinite recursion backstop -- detect fixpoint??)
- def fullDPLL(f: Formula): List[Model] = {
+ def findAllModelsFor(f: Formula): List[Model] = {
+ val vars: Set[Sym] = f.flatMap(_ collect {case l: Lit => l.sym}).toSet
+ // patmatDebug("vars "+ vars)
// the negation of a model -(S1=True/False /\ ... /\ SN=True/False) = clause(S1=False/True, ...., SN=False/True)
def negateModel(m: Model) = clause(m.toSeq.map{ case (sym, pos) => Lit(sym, !pos) } : _*)
- def findAllModels(f: Formula, models: List[Model], recursionDepthAllowed: Int = 20): List[Model]=
+ def findAllModels(f: Formula, models: List[Model], recursionDepthAllowed: Int = 10): List[Model]=
if (recursionDepthAllowed == 0) models
else {
- val (ok, model) = DPLL(f)
+ // patmatDebug("solving\n"+ cnfString(f))
+ val model = findModelFor(f)
// if we found a solution, conjunct the formula with the model's negation and recurse
- if (ok) findAllModels(f :+ negateModel(model), model :: models, recursionDepthAllowed - 1)
+ if (model ne NoModel) {
+ val unassigned = (vars -- model.keySet).toList
+ // patmatDebug("unassigned "+ unassigned +" in "+ model)
+ def force(lit: Lit) = {
+ val model = withLit(findModelFor(dropUnit(f, lit)), lit)
+ if (model ne NoModel) List(model)
+ else Nil
+ }
+ val forced = unassigned flatMap { s =>
+ force(Lit(s, true)) ++ force(Lit(s, false))
+ }
+ // patmatDebug("forced "+ forced)
+ val negated = negateModel(model)
+ findAllModels(f :+ negated, model :: (forced ++ models), recursionDepthAllowed - 1)
+ }
else models
}
findAllModels(f, Nil)
}
- def DPLL(f: Formula): (Boolean, Model) = {
- @inline def withLit(res: (Boolean, Model), l: Lit) = (res._1, res._2 + (l.sym -> l.pos))
- @inline def orElse(a: (Boolean, Model), b: => (Boolean, Model)) = if (a._1) a else b
-
-// println("dpll\n"+ cnfString(f))
-
- if (f isEmpty) (true, EmptyModel)
- else if(f exists (_.isEmpty)) (false, EmptyModel)
- else f.find(_.size == 1) map { unitClause =>
- val unitLit = unitClause.head
-// println("unit: "+ unitLit)
- val negated = -unitLit
- // drop entire clauses that are trivially true
- // (i.e., disjunctions that contain the literal we're making true in the returned model),
- // and simplify clauses by dropping the negation of the literal we're making true
- // (since False \/ X == X)
- val simplified = f.filterNot(_.contains(unitLit)).map(_ - negated)
- withLit(DPLL(simplified), unitLit)
- } getOrElse {
- // partition symbols according to whether they appear in positive and/or negative literals
- val pos = new HashSet[Sym]()
- val neg = new HashSet[Sym]()
- f.foreach{_.foreach{ lit =>
- if (lit.pos) pos += lit.sym else neg += lit.sym
- }}
- // appearing in both positive and negative
- val impures = pos intersect neg
- // appearing only in either positive/negative positions
- val pures = (pos ++ neg) -- impures
-
- if (pures nonEmpty) {
- val pureSym = pures.head
- // turn it back into a literal
- // (since equality on literals is in terms of equality
- // of the underlying symbol and its positivity, simply construct a new Lit)
- val pureLit = Lit(pureSym, pos(pureSym))
-// println("pure: "+ pureLit +" pures: "+ pures +" impures: "+ impures)
- val simplified = f.filterNot(_.contains(pureLit))
- withLit(DPLL(simplified), pureLit)
- } else {
- val split = f.head.head
-// println("split: "+ split)
- orElse(DPLL(f :+ clause(split)), DPLL(f :+ clause(-split)))
+ @inline private def withLit(res: Model, l: Lit): Model = if (res eq NoModel) NoModel else res + (l.sym -> l.pos)
+ @inline private def dropUnit(f: Formula, unitLit: Lit) = {
+ val negated = -unitLit
+ // drop entire clauses that are trivially true
+ // (i.e., disjunctions that contain the literal we're making true in the returned model),
+ // and simplify clauses by dropping the negation of the literal we're making true
+ // (since False \/ X == X)
+ f.filterNot(_.contains(unitLit)).map(_ - negated)
+ }
+
+ def findModelFor(f: Formula): Model = {
+ @inline def orElse(a: Model, b: => Model) = if (a ne NoModel) a else b
+
+ // patmatDebug("dpll\n"+ cnfString(f))
+
+ val start = startTimer(patmatAnaDPLL)
+
+ val satisfiableWithModel: Model =
+ if (f isEmpty) EmptyModel
+ else if(f exists (_.isEmpty)) NoModel
+ else f.find(_.size == 1) match {
+ case Some(unitClause) =>
+ val unitLit = unitClause.head
+ // patmatDebug("unit: "+ unitLit)
+ withLit(findModelFor(dropUnit(f, unitLit)), unitLit)
+ case _ =>
+ // partition symbols according to whether they appear in positive and/or negative literals
+ val pos = new HashSet[Sym]()
+ val neg = new HashSet[Sym]()
+ f.foreach{_.foreach{ lit =>
+ if (lit.pos) pos += lit.sym else neg += lit.sym
+ }}
+ // appearing in both positive and negative
+ val impures = pos intersect neg
+ // appearing only in either positive/negative positions
+ val pures = (pos ++ neg) -- impures
+
+ if (pures nonEmpty) {
+ val pureSym = pures.head
+ // turn it back into a literal
+ // (since equality on literals is in terms of equality
+ // of the underlying symbol and its positivity, simply construct a new Lit)
+ val pureLit = Lit(pureSym, pos(pureSym))
+ // patmatDebug("pure: "+ pureLit +" pures: "+ pures +" impures: "+ impures)
+ val simplified = f.filterNot(_.contains(pureLit))
+ withLit(findModelFor(simplified), pureLit)
+ } else {
+ val split = f.head.head
+ // patmatDebug("split: "+ split)
+ orElse(findModelFor(f :+ clause(split)), findModelFor(f :+ clause(-split)))
+ }
}
- }
+
+ stopTimer(patmatAnaDPLL, start)
+
+ satisfiableWithModel
}
}
+
/**
* Represent a match as a formula in propositional logic that encodes whether the match matches (abstractly: we only consider types)
*
*/
trait SymbolicMatchAnalysis extends TreeMakerApproximation with Logic { self: CodegenCore =>
+ def prepareNewAnalysis() = { Var.resetUniques(); Const.resetUniques() }
+
object Var {
private var _nextId = 0
def nextId = {_nextId += 1; _nextId}
+ def resetUniques() = {_nextId = 0; uniques.clear()}
private val uniques = new collection.mutable.HashMap[Tree, Var]
def apply(x: Tree): Var = uniques getOrElseUpdate(x, new Var(x, x.tpe))
}
class Var(val path: Tree, fullTp: Type, checked: Boolean = true) extends AbsVar {
+ private[this] val id: Int = Var.nextId
+
+ // private[this] var canModify: Option[Array[StackTraceElement]] = None
+ @inline private[this] def ensureCanModify = {} //if (canModify.nonEmpty) patmatDebug("BUG!"+ this +" modified after having been observed: "+ canModify.get.mkString("\n"))
+
+ @inline private[this] def observed = {} //canModify = Some(Thread.currentThread.getStackTrace)
+
+ // don't access until all potential equalities have been registered using registerEquality
+ private[this] val symForEqualsTo = new collection.mutable.HashMap[Const, Sym]
+
// when looking at the domain, we only care about types we can check at run time
val domainTp: Type = checkableType(fullTp)
+ private[this] var _considerNull = false
+ def considerNull: Unit = { ensureCanModify; if (NullTp <:< domainTp) _considerNull = true }
+
// case None => domain is unknown,
// case Some(List(tps: _*)) => domain is exactly tps
// we enumerate the subtypes of the full type, as that allows us to filter out more types statically,
// once we go to run-time checks (on Const's), convert them to checkable types
// TODO: there seems to be bug for singleton domains (variable does not show up in model)
- val domain = if (checked) enumerateSubtypes(fullTp).map(_.map(Const).toSet) else None
-
- def describe = toString + ": "+ fullTp + domain.map(_.map(_.tp).mkString(" ::= ", " | ", "")).getOrElse(" ::= ??") +" // = "+ path
- def domainEnumerable = domain.nonEmpty
+ lazy val domain: Option[Set[Const]] =
+ if (!checked) None
+ else {
+ val subConsts = enumerateSubtypes(fullTp).map{ tps =>
+ tps.toSet[Type].map{ tp =>
+ val domainC = TypeConst(tp)
+ registerEquality(domainC)
+ domainC
+ }
+ }
- private val domMap = new collection.mutable.HashMap[Const, Sym]
- private def symForEqualsTo(c: Const) = {
- domMap getOrElseUpdate(c, {
- // println("creating symbol for equality "+ this +" = "+ c)
- Sym(this, c)
- })
- }
+ val allConsts =
+ if (! _considerNull) subConsts
+ else {
+ registerEquality(NullConst)
+ subConsts map (_ + NullConst)
+ }
- // for this var, call it V, turn V = C into the equivalent proposition in boolean logic
- // over all executions of this method on the same Var object,
- def propForEqualsTo(c: Const): Prop = {
- domain match {
- case None => symForEqualsTo(c)
- case Some(domainConsts) =>
- val domainTps = domainConsts map (_.tp)
- val checkedTp = c.tp
- // find all the domain types that could make the type test true
- // if the checked type is a supertype of the lub of the domain,
- // we'll end up \/'ing the whole domain together,
- // but must not simplify to True, as the type test may also fail...
- val matches = domainTps.filter(_ <:< checkedTp).map{ tp => symForEqualsTo(Const(tp)) }
- // println("type-equals-prop for "+ this +" = "+ c +": "+ (checkedTp, domainTp, domainTps) +" matches: "+ matches)
-
- if (matches isEmpty) False else matches.reduceLeft(Or)
+ observed; allConsts
}
- }
- def equalitySyms: Set[Sym] = domMap.values.toSet
+ // accessing after calling considerNull will result in inconsistencies
+ lazy val domainSyms: Option[Set[Sym]] = domain map { _ map symForEqualsTo }
- private[this] val id: Int = Var.nextId
+
+ // populate equalitySyms
+ // don't care about the result, but want only one fresh symbol per distinct constant c
+ def registerEquality(c: Const): Unit = {ensureCanModify; symForEqualsTo getOrElseUpdate(c, Sym(this, c))}
+
+ // don't access until all potential equalities have been registered using registerEquality
+ lazy val equalitySyms = {observed; symForEqualsTo.values.toList}
+
+ // return the symbol that represents this variable being equal to the constant `c`, if it exists, otherwise False (for robustness)
+ // (registerEquality(c) must have been called prior, either when constructing the domain or from outside)
+ def propForEqualsTo(c: Const): Prop = {observed; symForEqualsTo.getOrElse(c, False)}
+
+
+ // don't call until all equalities have been registered and considerNull has been called (if needed)
+ def describe = toString + ": " + fullTp + domain.map(_.mkString(" ::= ", " | ", "// "+ symForEqualsTo.keys)).getOrElse(symForEqualsTo.keys.mkString(" ::= ", " | ", " | ...")) + " // = " + path
override def toString = "V"+ id
}
+
// all our variables range over types
// a literal constant becomes ConstantType(Constant(v)) when the type allows it (roughly, anyval + string + null)
// equality between variables: SingleType(x) (note that pattern variables cannot relate to each other -- it's always patternVar == nonPatternVar)
- case class Const(tp: Type) {
- override def toString = tp.toString
+ object Const {
+ def resetUniques() = {_nextTypeId = 0; _nextValueId = 0; uniques.clear()} // patmatDebug("RESET")
+
+ private var _nextTypeId = 0
+ def nextTypeId = {_nextTypeId += 1; _nextTypeId}
+
+ private var _nextValueId = 0
+ def nextValueId = {_nextValueId += 1; _nextValueId}
+
+ private val uniques = new collection.mutable.HashMap[Type, Const]
+ private[SymbolicMatchAnalysis] def unique(tp: Type, mkFresh: => Const): Const =
+ uniques.get(tp).getOrElse(
+ uniques.find {case (oldTp, oldC) => oldTp =:= tp} match {
+ case Some((_, c)) => c
+ case _ =>
+ val fresh = mkFresh
+ uniques(tp) = fresh
+ fresh
+ })
+ }
+
+ sealed abstract class Const extends AbsConst {
+ protected def tp: Type
+ protected def wideTp: Type
+
+ def isAny = wideTp.typeSymbol == AnyClass
+
+ final def implies(other: Const): Boolean = {
+ val r = (this, other) match {
+ case (_: ValueConst, _: ValueConst) => this == other // hashconsed
+ case (_: ValueConst, _: TypeConst) => tp <:< other.tp
+ case (_: TypeConst, _) => tp <:< other.tp
+ case _ => false
+ }
+ // if(r) patmatDebug("implies : "+(this, other))
+ // else patmatDebug("NOT implies: "+(this, other))
+ r
+ }
+
+ // does V = C preclude V having value `other`? V = null is an exclusive assignment,
+ // but V = 1 does not preclude V = Int, or V = Any
+ final def excludes(other: Const): Boolean = {
+ val r = (this, other) match {
+ case (_, NullConst) => true
+ case (NullConst, _) => true
+ // this causes false negative for unreachability, but that's ok:
+ // example: val X = 1; val Y = 1; (2: Int) match { case X => case Y => /* considered reachable */ }
+ case (_: ValueConst, _: ValueConst) => this != other
+ case (_: ValueConst, _: TypeConst) => !((tp <:< other.tp) || (other.tp <:< wideTp))
+ case (_: TypeConst, _: ValueConst) => !((other.tp <:< tp) || (tp <:< other.wideTp))
+ case (_: TypeConst, _: TypeConst) => !((tp <:< other.tp) || (other.tp <:< tp))
+ case _ => false
+ }
+ // if(r) patmatDebug("excludes : "+(this, other))
+ // else patmatDebug("NOT excludes: "+(this, other))
+ r
+ }
+
+ // note: use reference equality on Const since they're hash-consed (doing type equality all the time is too expensive)
+ // the equals inherited from AnyRef does just this
+ }
+
+
+ object TypeConst {
+ def apply(tp: Type) = {
+ if (tp =:= NullTp) NullConst
+ else if (tp.isInstanceOf[SingletonType]) ValueConst.fromType(tp)
+ else Const.unique(tp, new TypeConst(tp))
+ }
+ def unapply(c: TypeConst): Some[Type] = Some(c.tp)
+ }
+
+ // corresponds to a type test that does not imply any value-equality (well, except for outer checks, which we don't model yet)
+ sealed class TypeConst(val tp: Type) extends Const {
+ assert(!(tp =:= NullTp))
+ private[this] val id: Int = Const.nextTypeId
+
+ val wideTp = tp.widen
+
+ override def toString = tp.toString //+"#"+ id
+ }
+
+ // p is a unique type or a constant value
+ object ValueConst {
+ def fromType(tp: Type) = {
+ assert(tp.isInstanceOf[SingletonType])
+ val toString = tp match {
+ case ConstantType(c) => c.escapedStringValue
+ case _ => tp.toString
+ }
+ Const.unique(tp, new ValueConst(tp, tp.widen, toString))
+ }
+ def apply(p: Tree) = {
+ val tp = p.tpe.normalize
+ if (tp =:= NullTp) NullConst
+ else {
+ val wideTp = {
+ if (p.hasSymbol && p.symbol.isStable) tp.asSeenFrom(tp.prefix, p.symbol.owner).widen
+ else tp.widen
+ }
+
+ val narrowTp =
+ if (tp.isInstanceOf[SingletonType]) tp
+ else p match {
+ case Literal(c) =>
+ if (c.tpe.typeSymbol == UnitClass) c.tpe
+ else ConstantType(c)
+ case p if p.symbol.isStable =>
+ singleType(tp.prefix, p.symbol)
+ case x =>
+ // TODO: better type
+ x.tpe.narrow
+ }
- def toValueString = tp match {
- case ConstantType(c) => c.escapedStringValue
- case _ => tp.toString
+ val toString =
+ if (p.hasSymbol && p.symbol.isStable) p.symbol.name.toString // tp.toString
+ else p.toString //+"#"+ id
+
+ Const.unique(narrowTp, new ValueConst(narrowTp, checkableType(wideTp), toString)) // must make wide type checkable so that it is comparable to types from TypeConst
+ }
+ }
+ }
+ sealed class ValueConst(val tp: Type, val wideTp: Type, override val toString: String) extends Const {
+ // patmatDebug("VC"+(tp, wideTp, toString))
+ assert(!(tp =:= NullTp))
+ private[this] val id: Int = Const.nextValueId
+ }
+
+ lazy val NullTp = ConstantType(Constant(null))
+ case object NullConst extends Const {
+ protected def tp = NullTp
+ protected def wideTp = NullTp
+
+ def isValue = true
+ override def toString = "null"
+ }
+
+
+ // turns a case (represented as a list of abstract tests)
+ // into a proposition that is satisfiable if the case may match
+ def symbolicCase(tests: List[Test], modelNull: Boolean = false): Prop = {
+ def symbolic(t: Cond): Prop = t match {
+ case AndCond(a, b) => And(symbolic(a), symbolic(b))
+ case OrCond(a, b) => Or(symbolic(a), symbolic(b))
+ case Top => True
+ case Havoc => False
+ case TypeCond(p, pt) => Eq(Var(p), TypeConst(checkableType(pt)))
+ case EqualityCond(p, q) => Eq(Var(p), ValueConst(q))
+ case NonNullCond(p) => if (!modelNull) True else Not(Eq(Var(p), NullConst))
}
+
+ val testsBeforeBody = tests.takeWhile(t => !t.treeMaker.isInstanceOf[BodyTreeMaker])
+ /\(testsBeforeBody.map(t => symbolic(t.cond)))
}
+ // TODO: model dependencies between variables: if V1 corresponds to (x: List[_]) and V2 is (x.hd), V2 cannot be assigned when V1 = null or V1 = Nil
+ // right now hackily implement this by pruning counter-examples
+ // unreachability would also benefit from a more faithful representation
+
+ // reachability (dead code)
+
+ // computes the first 0-based case index that is unreachable (if any)
+ // a case is unreachable if it implies its preceding cases
+ // call C the formula that is satisfiable if the considered case matches
+ // call P the formula that is satisfiable if the cases preceding it match
+ // the case is reachable if there is a model for -P /\ C,
+ // thus, the case is unreachable if there is no model for -(-P /\ C),
+ // or, equivalently, P \/ -C, or C => P
+ def unreachableCase(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): Option[Int] = {
+ // customize TreeMakersToConds (which turns a tree of tree makers into a more abstract DAG of tests)
+ // when approximating the current case (which we hope is reachable), be optimistic about the unknowns
+ object reachabilityApproximation extends TreeMakersToConds(prevBinder) {
+ def makeCondOptimistic(tm: TreeMaker)(recurse: TreeMaker => Cond): Cond = tm match {
+ // for unreachability, let's assume a guard always matches (unless we statically determined otherwise)
+ // otherwise, a guarded case would be considered unreachable
+ case GuardTreeMaker(guard) =>
+ guard.tpe match {
+ case ConstantType(Constant(false)) => Havoc // not the best name; however, symbolically, 'Havoc' becomes 'False'
+ case _ => Top
+ }
+ // similar to a guard, user-defined extractors should not cause us to freak out
+ // if we're not 100% sure it does not match (i.e., its result type is None or Constant(false) -- TODO),
+ // let's stay optimistic and assume it does
+ case ExtractorTreeMaker(_, _, _, _)
+ | ProductExtractorTreeMaker(_, Some(_), _) => Top
+ // TODO: consider length-checks
+ case _ =>
+ makeCond(tm)(recurse)
+ }
+
+ // be pessimistic when approximating the prefix of the current case
+ // we hope the prefix fails so that we might get to the current case, which we hope is not dead
+ def makeCondPessimistic(tm: TreeMaker)(recurse: TreeMaker => Cond): Cond = makeCond(tm)(recurse)
+ }
+
+ val start = startTimer(patmatAnaReach)
+
+ // use the same approximator so we share variables,
+ // but need different conditions depending on whether we're conservatively looking for failure or success
+ val testCasesOk = reachabilityApproximation.approximateMatch(cases, reachabilityApproximation.makeCondOptimistic)
+ val testCasesFail = reachabilityApproximation.approximateMatchAgain(cases, reachabilityApproximation.makeCondPessimistic)
+
+ reachabilityApproximation.discard()
+ prepareNewAnalysis()
+
+ val propsCasesOk = testCasesOk map (t => symbolicCase(t, modelNull = true))
+ val propsCasesFail = testCasesFail map (t => Not(symbolicCase(t, modelNull = true)))
+ val (eqAxiomsFail, symbolicCasesFail) = removeVarEq(propsCasesFail, considerNull = true)
+ val (eqAxiomsOk, symbolicCasesOk) = removeVarEq(propsCasesOk, considerNull = true)
+
+ try {
+ // most of the time eqAxiomsFail == eqAxiomsOk, but the different approximations might cause different variables to disapper in general
+ val eqAxiomsCNF =
+ if (eqAxiomsFail == eqAxiomsOk) eqFreePropToSolvable(eqAxiomsFail)
+ else eqFreePropToSolvable(And(eqAxiomsFail, eqAxiomsOk))
+
+ var prefix = eqAxiomsCNF
+ var prefixRest = symbolicCasesFail
+ var current = symbolicCasesOk
+ var reachable = true
+ var caseIndex = 0
+
+ // patmatDebug("reachability, vars:\n"+ ((propsCasesFail flatMap gatherVariables) map (_.describe) mkString ("\n")))
+ // patmatDebug("equality axioms:\n"+ cnfString(eqAxiomsCNF))
+
+ // invariant (prefixRest.length == current.length) && (prefix.reverse ++ prefixRest == symbolicCasesFail)
+ // termination: prefixRest.length decreases by 1
+ while (prefixRest.nonEmpty && reachable) {
+ val prefHead = prefixRest.head
+ caseIndex += 1
+ prefixRest = prefixRest.tail
+ if (prefixRest.isEmpty) reachable = true
+ else {
+ prefix = andFormula(eqFreePropToSolvable(prefHead), prefix)
+ current = current.tail
+ val model = findModelFor(andFormula(eqFreePropToSolvable(current.head), prefix))
+
+ // patmatDebug("trying to reach:\n"+ cnfString(current.head) +"\nunder prefix:\n"+ cnfString(prefix))
+ // if (ok) patmatDebug("reached: "+ modelString(model))
+
+ reachable = model ne NoModel
+ }
+ }
+
+ stopTimer(patmatAnaReach, start)
+
+ if (reachable) None else Some(caseIndex)
+ } catch {
+ case e : CNFBudgetExceeded =>
+// debugWarn(util.Position.formatMessage(prevBinder.pos, "Cannot check match for reachability", false))
+// e.printStackTrace()
+ None // CNF budget exceeded
+ }
+ }
+
+ // exhaustivity
+
// make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte
// TODO: domain of feasibly enumerable built-in types (enums, char?)
def enumerateSubtypes(tp: Type): Option[List[Type]] =
tp.typeSymbol match {
case BooleanClass =>
- // println("enum bool "+ tp)
+ // patmatDebug("enum bool "+ tp)
Some(List(ConstantType(Constant(true)), ConstantType(Constant(false))))
// TODO case _ if tp.isTupleType => // recurse into component types
case sym if !sym.isSealed || isPrimitiveValueClass(sym) =>
- // println("enum unsealed "+ (tp, sym, sym.isSealed, isPrimitiveValueClass(sym)))
+ // patmatDebug("enum unsealed "+ (tp, sym, sym.isSealed, isPrimitiveValueClass(sym)))
None
case sym =>
val subclasses = (
@@ -1899,7 +2348,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// symbols which are both sealed and abstract need not be covered themselves, because
// all of their children must be and they cannot otherwise be created.
filterNot (x => x.isSealed && x.isAbstractClass && !isPrimitiveValueClass(x)))
- // println("subclasses "+ (sym, subclasses))
+ // patmatDebug("subclasses "+ (sym, subclasses))
val tpApprox = typer.infer.approximateAbstracts(tp)
val pre = tpApprox.prefix
@@ -1911,20 +2360,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// however, must approximate abstract types in
val subTp = appliedType(pre.memberType(sym), sym.typeParams.map(_ => WildcardType))
val subTpApprox = typer.infer.approximateAbstracts(subTp) // TODO: needed?
- // println("subtp"+(subTpApprox <:< tpApprox, subTpApprox, tpApprox))
+ // patmatDebug("subtp"+(subTpApprox <:< tpApprox, subTpApprox, tpApprox))
if (subTpApprox <:< tpApprox) Some(checkableType(subTp))
else None
})
- // println("enum sealed "+ (tp, tpApprox) + " as "+ validSubTypes)
+ // patmatDebug("enum sealed "+ (tp, tpApprox) + " as "+ validSubTypes)
Some(validSubTypes)
}
- def narrowTypeOf(p: Tree) = p match {
- case Literal(c) => ConstantType(c)
- case Ident(_) if p.symbol.isStable => singleType(p.tpe.prefix, p.symbol)
- case x => x.tpe.narrow
- }
-
// approximate a type to the static type that is fully checkable at run time,
// hiding statically known but dynamically uncheckable information using existential quantification
// TODO: this is subject to the availability of TypeTags (since an abstract type with a type tag is checkable at run time)
@@ -1941,7 +2384,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
}
val res = toCheckable(tp)
- // println("checkable "+(tp, res))
+ // patmatDebug("checkable "+(tp, res))
res
}
@@ -1952,7 +2395,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
val checkable = (
(isTupleType(tp) && tupleComponents(tp).exists(tp => !uncheckableType(tp)))
|| enumerateSubtypes(tp).nonEmpty)
- // if (!checkable) println("deemed uncheckable: "+ tp)
+ // if (!checkable) patmatDebug("deemed uncheckable: "+ tp)
!checkable
}
@@ -1963,57 +2406,48 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// - back off (to avoid crying exhaustive too often) when:
// - there are guards -->
// - there are extractor calls (that we can't secretly/soundly) rewrite
+ val start = startTimer(patmatAnaExhaust)
var backoff = false
- object exhaustivityApproximation extends TreeMakersToConds(prevBinder, cases) {
- override def treeMakerToCond(tm: TreeMaker): Cond = tm match {
- case p@ExtractorTreeMaker(extractor, Some(lenCheck), testedBinder, _) =>
+ object exhaustivityApproximation extends TreeMakersToConds(prevBinder) {
+ def makeCondExhaustivity(tm: TreeMaker)(recurse: TreeMaker => Cond): Cond = tm match {
+ case p @ ExtractorTreeMaker(extractor, Some(lenCheck), testedBinder, _) =>
p.checkedLength match {
// pattern: `List()` (interpret as `Nil`)
// TODO: make it more general List(1, 2) => 1 :: 2 :: Nil
case Some(0) if testedBinder.tpe.typeSymbol == ListClass => // extractor.symbol.owner == SeqFactory
EqualityCond(binderToUniqueTree(p.prevBinder), unique(Ident(NilModule) setType NilModule.tpe))
case _ =>
- super.treeMakerToCond(tm)
+ backoff = true
+ makeCond(tm)(recurse)
}
case ExtractorTreeMaker(_, _, _, _) =>
-// println("backing off due to "+ tm)
+// patmatDebug("backing off due to "+ tm)
backoff = true
- super.treeMakerToCond(tm)
+ makeCond(tm)(recurse)
case GuardTreeMaker(guard) =>
guard.tpe match {
case ConstantType(Constant(true)) => Top
case ConstantType(Constant(false)) => Havoc
case _ =>
-// println("can't statically interpret guard: "+(guard, guard.tpe))
+// patmatDebug("can't statically interpret guard: "+(guard, guard.tpe))
backoff = true
Havoc
}
case _ =>
- super.treeMakerToCond(tm)
+ makeCond(tm)(recurse)
}
}
- def symbolic(t: Cond): Prop = t match {
- case AndCond(a, b) => And(symbolic(a), symbolic(b))
- case OrCond(a, b) => Or(symbolic(a), symbolic(b))
- case Top => True
- case Havoc => False
- case TypeCond(p, pt) => Eq(Var(p), Const(checkableType(pt)))
- case EqualityCond(p, q) => Eq(Var(p), Const(narrowTypeOf(q)))
- case NonNullCond(p) => True // ignoring nullness because it generates too much noise Not(Eq(Var(p), Const(NullClass.tpe)))
- }
+ val tests = exhaustivityApproximation.approximateMatch(cases, exhaustivityApproximation.makeCondExhaustivity)
- def symbolicCase(tests: List[Test]) = {
- val testsBeforeBody = tests.takeWhile(t => !t.treeMaker.isInstanceOf[BodyTreeMaker])
- testsBeforeBody.map(t => symbolic(t.cond)).foldLeft(True: Prop)(And)
- }
+ if (backoff) Nil else {
+ val prevBinderTree = exhaustivityApproximation.binderToUniqueTree(prevBinder)
- val tests = exhaustivityApproximation.approximateMatch
+ exhaustivityApproximation.discard()
+ prepareNewAnalysis()
- if (backoff) Nil else {
- val symbolicCases = tests map symbolicCase
+ val symbolicCases = tests map (symbolicCase(_, modelNull = false))
- val prevBinderTree = exhaustivityApproximation.binderToUniqueTree(prevBinder)
// TODO: null tests generate too much noise, so disabled them -- is there any way to bring them back?
// assuming we're matching on a non-null scrutinee (prevBinder), when does the match fail?
@@ -2026,33 +2460,35 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// val matchFails = And(symbolic(nonNullScrutineeCond), Not(symbolicCases reduceLeft (Or(_, _))))
// when does the match fail?
- val matchFails = Not(symbolicCases reduceLeft (Or(_, _)))
-
+ val matchFails = Not(\/(symbolicCases))
// debug output:
- // println("analysing:")
+ // patmatDebug("analysing:")
// showTreeMakers(cases)
// showTests(tests)
//
- // def gatherVariables(p: Prop): Set[Var] = {
- // val vars = new HashSet[Var]()
- // (new PropTraverser {
- // override def applyVar(v: Var) = vars += v
- // })(p)
- // vars.toSet
- // }
// val vars = gatherVariables(matchFails)
- // println("\nvars:\n"+ (vars map (_.describe) mkString ("\n")))
+ // patmatDebug("\nvars:\n"+ (vars map (_.describe) mkString ("\n")))
//
- // println("\nmatchFails as CNF:\n"+ cnfString(normalize(matchFails)))
+ // patmatDebug("\nmatchFails as CNF:\n"+ cnfString(propToSolvable(matchFails)))
+
+ try {
+ // find the models (under which the match fails)
+ val matchFailModels = findAllModelsFor(propToSolvable(matchFails))
- // find the models (under which the match fails)
- val matchFailModels = fullDPLL(normalize(matchFails))
+ val scrutVar = Var(prevBinderTree)
+ val counterExamples = matchFailModels.map(modelToCounterExample(scrutVar))
- val scrutVar = Var(prevBinderTree)
- val counterExamples = matchFailModels.map(modelToCounterExample(scrutVar))
+ val pruned = CounterExample.prune(counterExamples).map(_.toString).sorted
- CounterExample.prune(counterExamples).map(_.toString).sorted
+ stopTimer(patmatAnaExhaust, start)
+ pruned
+ } catch {
+ case e : CNFBudgetExceeded =>
+ // patmatDebug(util.Position.formatMessage(prevBinder.pos, "Cannot check match for exhaustivity", false))
+ // e.printStackTrace()
+ Nil // CNF budget exceeded
+ }
}
}
@@ -2068,13 +2504,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
protected[SymbolicMatchAnalysis] def flattenConsArgs: List[CounterExample] = Nil
def coveredBy(other: CounterExample): Boolean = this == other || other == WildcardExample
}
- case class ValueExample(c: Const) extends CounterExample { override def toString = c.toValueString }
+ case class ValueExample(c: ValueConst) extends CounterExample { override def toString = c.toString }
case class TypeExample(c: Const) extends CounterExample { override def toString = "(_ : "+ c +")" }
case class NegativeExample(nonTrivialNonEqualTo: List[Const]) extends CounterExample {
+ // require(nonTrivialNonEqualTo.nonEmpty, nonTrivialNonEqualTo)
override def toString = {
val negation =
- if (nonTrivialNonEqualTo.tail.isEmpty) nonTrivialNonEqualTo.head.toValueString
- else nonTrivialNonEqualTo.map(_.toValueString).sorted.mkString("in (", ", ", ")")
+ if (nonTrivialNonEqualTo.tail.isEmpty) nonTrivialNonEqualTo.head.toString
+ else nonTrivialNonEqualTo.map(_.toString).sorted.mkString("in (", ", ", ")")
"<not "+ negation +">"
}
}
@@ -2111,6 +2548,21 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case object WildcardExample extends CounterExample { override def toString = "_" }
case object NoExample extends CounterExample { override def toString = "??" }
+ @inline def modelToVarAssignment(model: Model): Map[Var, (Seq[Const], Seq[Const])] =
+ model.toSeq.groupBy{f => f match {case (sym, value) => sym.variable} }.mapValues{ xs =>
+ val (trues, falses) = xs.partition(_._2)
+ (trues map (_._1.const), falses map (_._1.const))
+ // should never be more than one value in trues...
+ }
+
+ def varAssignmentString(varAssignment: Map[Var, (Seq[Const], Seq[Const])]) =
+ varAssignment.toSeq.sortBy(_._1.toString).map { case (v, (trues, falses)) =>
+ val assignment = "== "+ (trues mkString("(", ", ", ")")) +" != ("+ (falses mkString(", ")) +")"
+ v +"(="+ v.path +": "+ v.domainTp +") "+ assignment
+ }.mkString("\n")
+
+ def modelString(model: Model) = varAssignmentString(modelToVarAssignment(model))
+
// return constructor call when the model is a true counter example
// (the variables don't take into account type information derived from other variables,
// so, naively, you might try to construct a counter example like _ :: Nil(_ :: _, _ :: _),
@@ -2121,24 +2573,16 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// x1.tl = ...
// x1.hd.hd = ...
// ...
- val varAssignment = model.toSeq.groupBy{f => f match {case (sym, value) => sym.variable} }.mapValues{ xs =>
- val (trues, falses) = xs.partition(_._2)
- (trues map (_._1.const), falses map (_._1.const))
- // should never be more than one value in trues...
- }
-
- // println("var assignment:\n"+
- // varAssignment.toSeq.sortBy(_._1.toString).map { case (v, (trues, falses)) =>
- // val assignment = "== "+ (trues mkString("(", ", ", ")")) +" != ("+ (falses mkString(", ")) +")"
- // v +"(="+ v.path +": "+ v.domainTp +") "+ assignment
- // }.mkString("\n"))
+ val varAssignment = modelToVarAssignment(model)
+ // patmatDebug("var assignment for model "+ model +":\n"+ varAssignmentString(varAssignment))
// chop a path into a list of symbols
def chop(path: Tree): List[Symbol] = path match {
case Ident(_) => List(path.symbol)
case Select(pre, name) => chop(pre) :+ path.symbol
- case _ => println("don't know how to chop "+ path); Nil
+ case _ => // patmatDebug("don't know how to chop "+ path)
+ Nil
}
// turn the variable assignments into a tree
@@ -2177,7 +2621,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// node in the tree that describes how to construct a counter-example
case class VariableAssignment(variable: Var, equalTo: List[Const], notEqualTo: List[Const], fields: collection.mutable.Map[Symbol, VariableAssignment]) {
- private lazy val ctor = (equalTo match { case List(Const(tp)) => tp case _ => variable.domainTp }).typeSymbol.primaryConstructor
+ // need to prune since the model now incorporates all super types of a constant (needed for reachability)
+ private lazy val prunedEqualTo = equalTo filterNot (subsumed => equalTo.exists(better => (better ne subsumed) && (better implies subsumed)))
+ private lazy val ctor = (prunedEqualTo match { case List(TypeConst(tp)) => tp case _ => variable.domainTp }).typeSymbol.primaryConstructor
private lazy val ctorParams = if (ctor == NoSymbol || ctor.paramss.isEmpty) Nil else ctor.paramss.head
private lazy val cls = if (ctor == NoSymbol) NoSymbol else ctor.owner
private lazy val caseFieldAccs = if (cls == NoSymbol) Nil else cls.caseFieldAccessors
@@ -2186,7 +2632,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def allFieldAssignmentsLegal: Boolean =
(fields.keySet subsetOf caseFieldAccs.toSet) && fields.values.forall(_.allFieldAssignmentsLegal)
- private lazy val nonTrivialNonEqualTo = notEqualTo.filterNot{c => val sym = c.tp.typeSymbol; sym == AnyClass } // sym == NullClass ||
+ private lazy val nonTrivialNonEqualTo = notEqualTo.filterNot{c => c.isAny }
// NoExample if the constructor call is ill-typed
// (thus statically impossible -- can we incorporate this into the formula?)
@@ -2194,17 +2640,17 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def toCounterExample(beBrief: Boolean = false): CounterExample =
if (!allFieldAssignmentsLegal) NoExample
else {
-// println("describing "+ (variable, equalTo, notEqualTo, fields, cls, allFieldAssignmentsLegal))
- val res = equalTo match {
+ // patmatDebug("describing "+ (variable, equalTo, notEqualTo, fields, cls, allFieldAssignmentsLegal))
+ val res = prunedEqualTo match {
// a definite assignment to a value
- case List(eq@Const(_: ConstantType)) if fields.isEmpty => ValueExample(eq)
+ case List(eq: ValueConst) if fields.isEmpty => ValueExample(eq)
// constructor call
// or we did not gather any information about equality but we have information about the fields
// --> typical example is when the scrutinee is a tuple and all the cases first unwrap that tuple and only then test something interesting
case _ if cls != NoSymbol &&
- ( equalTo.nonEmpty
- || (fields.nonEmpty && !isPrimitiveValueClass(cls) && equalTo.isEmpty && notEqualTo.isEmpty)) =>
+ ( prunedEqualTo.nonEmpty
+ || (fields.nonEmpty && !isPrimitiveValueClass(cls) && prunedEqualTo.isEmpty && notEqualTo.isEmpty)) =>
@inline def args(brevity: Boolean = beBrief) = {
// figure out the constructor arguments from the field assignment
@@ -2231,7 +2677,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// TODO: improve reasoning -- in the mean time, a false negative is better than an annoying false positive
case _ => NoExample
}
-// println("described as: "+ res)
+ // patmatDebug("described as: "+ res)
res
}
@@ -2251,11 +2697,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
/** a flow-sensitive, generalised, common sub-expression elimination
* reuse knowledge from performed tests
* the only sub-expressions we consider are the conditions and results of the three tests (type, type&equality, equality)
- * when a sub-expression is share, it is stored in a mutable variable
+ * when a sub-expression is shared, it is stored in a mutable variable
* the variable is floated up so that its scope includes all of the program that shares it
* we generalize sharing to implication, where b reuses a if a => b and priors(a) => priors(b) (the priors of a sub expression form the path through the decision tree)
- *
- * intended to be generalised to exhaustivity/reachability checking
*/
def doCSE(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): List[List[TreeMaker]] = {
val testss = approximateMatch(prevBinder, cases)
@@ -2304,7 +2748,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
tested.clear()
tests dropWhile storeDependencies
}
- // println("dependencies: "+ dependencies)
+ // patmatDebug("dependencies: "+ dependencies)
// find longest prefix of tests that reuse a prior test, and whose dependent conditions monotonically increase
// then, collapse these contiguous sequences of reusing tests
@@ -2338,7 +2782,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case _ =>
}
- // println("sharedPrefix: "+ sharedPrefix)
+ // patmatDebug("sharedPrefix: "+ sharedPrefix)
// if the shared prefix contains interesting conditions (!= Top)
// and the last of such interesting shared conditions reuses another treemaker's test
// replace the whole sharedPrefix by a ReusingCondTreeMaker
@@ -2354,7 +2798,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
// replace original treemakers that are reused (as determined when computing collapsed),
// by ReusedCondTreeMakers
val reusedMakers = collapsed mapConserve (_ mapConserve reusedOrOrig)
-// println("after CSE:")
+// patmatDebug("after CSE:")
// showTreeMakers(reusedMakers)
reusedMakers
}
@@ -2362,7 +2806,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
object ReusedCondTreeMaker {
def apply(orig: CondTreeMaker) = new ReusedCondTreeMaker(orig.prevBinder, orig.nextBinder, orig.cond, orig.res, orig.pos)
}
- class ReusedCondTreeMaker(prevBinder: Symbol, val nextBinder: Symbol, cond: Tree, res: Tree, pos: Position) extends TreeMaker { import CODE._
+ class ReusedCondTreeMaker(prevBinder: Symbol, val nextBinder: Symbol, cond: Tree, res: Tree, val pos: Position) extends TreeMaker { import CODE._
lazy val localSubstitution = Substitution(List(prevBinder), List(CODE.REF(nextBinder)))
lazy val storedCond = freshSym(pos, BooleanClass.tpe, "rc") setFlag MUTABLE
lazy val treesToHoist: List[Tree] = {
@@ -2378,6 +2822,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
}
case class ReusingCondTreeMaker(sharedPrefix: List[Test], toReused: TreeMaker => TreeMaker) extends TreeMaker { import CODE._
+ val pos = sharedPrefix.last.treeMaker.pos
+
lazy val localSubstitution = {
// replace binder of each dropped treemaker by corresponding binder bound by the most recent reused treemaker
var mostRecentReusedMaker: ReusedCondTreeMaker = null
@@ -2467,7 +2913,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
val substedBody = btm.substitution(body)
CaseDef(Alternative(patterns), EmptyTree, substedBody)
}
- case _ => //println("can't emit switch for "+ makers)
+ case _ => // patmatDebug("can't emit switch for "+ makers)
None //failure (can't translate pattern to a switch)
}
}
@@ -2692,8 +3138,14 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
with DeadCodeElimination
with SwitchEmission
with OptimizedCodegen
- with SymbolicMatchAnalysis { self: TreeMakers =>
+ with SymbolicMatchAnalysis
+ with DPLLSolver { self: TreeMakers =>
override def optimizeCases(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type, unchecked: Boolean): (List[List[TreeMaker]], List[Tree]) = {
+ if (!unchecked) {
+ unreachableCase(prevBinder, cases, pt) foreach { caseIndex =>
+ typer.context.unit.warning(cases(caseIndex).last.pos, "unreachable code")
+ }
+ }
val counterExamples = if (unchecked) Nil else exhaustive(prevBinder, cases, pt)
if (counterExamples.nonEmpty) {
val ceString =
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 3373878beb..26cf246ed7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -285,7 +285,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
def memberTp = self.memberType(member)
def otherTp = self.memberType(other)
def noErrorType = other.tpe != ErrorType && member.tpe != ErrorType
- def isRootOrNone(sym: Symbol) = sym == RootClass || sym == NoSymbol
+ def isRootOrNone(sym: Symbol) = sym != null && sym.isRoot || sym == NoSymbol
def isNeitherInClass = (member.owner != clazz) && (other.owner != clazz)
def objectOverrideErrorMsg = (
"overriding " + other.fullLocationString + " with " + member.fullLocationString + ":\n" +
@@ -807,9 +807,9 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
for (i <- 0 until seenTypes.length) {
val baseClass = clazz.info.baseTypeSeq(i).typeSymbol
seenTypes(i) match {
- case List() =>
+ case Nil =>
println("??? base "+baseClass+" not found in basetypes of "+clazz)
- case List(_) =>
+ case _ :: Nil =>
;// OK
case tp1 :: tp2 :: _ =>
unit.error(clazz.pos, "illegal inheritance;\n " + clazz +
@@ -1309,9 +1309,9 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
}
List(tree1)
}
- case Import(_, _) => Nil
- case DefDef(mods, _, _, _, _, _) if (mods hasFlag MACRO) => Nil
- case _ => List(transform(tree))
+ case Import(_, _) => Nil
+ case DefDef(mods, _, _, _, _, _) if (mods hasFlag MACRO) || (tree.symbol hasFlag MACRO) => Nil
+ case _ => List(transform(tree))
}
/* Check whether argument types conform to bounds of type parameters */
@@ -1496,7 +1496,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
private def transformCaseApply(tree: Tree, ifNot: => Unit) = {
val sym = tree.symbol
-
+
def isClassTypeAccessible(tree: Tree): Boolean = tree match {
case TypeApply(fun, targs) =>
isClassTypeAccessible(fun)
@@ -1505,7 +1505,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
// the companion class is actually not a ClassSymbol, but a reference to an abstract type.
module.symbol.companionClass.isClass
}
-
+
val doTransform =
sym.isSourceMethod &&
sym.isCase &&
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
index 329a247106..190b18711c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
@@ -1,10 +1,10 @@
package scala.tools.nsc
package typechecker
-import scala.reflect.makro.runtime.{Context => MacroContext}
-
trait StdAttachments {
self: Analyzer =>
- case class MacroAttachment(delayed: Boolean, typerContext: Context, macroContext: Option[MacroContext])
+ type UnaffiliatedMacroContext = scala.reflect.makro.runtime.Context
+ type MacroContext = UnaffiliatedMacroContext { val universe: self.global.type }
+ case class MacroRuntimeAttachment(delayed: Boolean, typerContext: Context, macroContext: Option[MacroContext])
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index d327d9c397..daae69590f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -246,7 +246,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
&& sym.isProtected
&& sym.enclClass != currentClass
&& !sym.owner.isTrait
- && (sym.owner.enclosingPackageClass != currentPackage)
+ && (sym.owner.enclosingPackageClass != currentClass.enclosingPackageClass)
&& (qual.symbol.info.member(sym.name) ne NoSymbol)
)
if (shouldEnsureAccessor) {
@@ -451,7 +451,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
&& sym.isJavaDefined
&& !sym.isDefinedInPackage
&& !accessibleThroughSubclassing
- && (sym.enclosingPackageClass != currentPackage)
+ && (sym.enclosingPackageClass != currentClass.enclosingPackageClass)
&& (sym.enclosingPackageClass == sym.accessBoundary(sym.enclosingPackageClass))
)
val host = hostForAccessorOf(sym, clazz)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 6faa9a3cb7..f01e095856 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -63,7 +63,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// in the original order.
def accessors = clazz.caseFieldAccessors sortBy { acc =>
originalAccessors indexWhere { orig =>
- (acc.name == orig.name) || (acc.name startsWith (orig.name append "$"))
+ (acc.name == orig.name) || (acc.name startsWith (orig.name append "$").asInstanceOf[Name]) // [Eugene++] why do we need this cast?
}
}
val arity = accessors.size
@@ -87,7 +87,7 @@ trait SyntheticMethods extends ast.TreeDSL {
)
def forwardToRuntime(method: Symbol): Tree =
- forwardMethod(method, getMember(ScalaRunTimeModule, method.name prepend "_"))(mkThis :: _)
+ forwardMethod(method, getMember(ScalaRunTimeModule, (method.name prepend "_").asInstanceOf[Name]))(mkThis :: _) // [Eugene++] why do we need this cast?
def callStaticsMethod(name: String)(args: Tree*): Tree = {
val method = termMember(RuntimeStaticsModule, name)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Taggings.scala b/src/compiler/scala/tools/nsc/typechecker/Taggings.scala
deleted file mode 100644
index fb0d6fb3c5..0000000000
--- a/src/compiler/scala/tools/nsc/typechecker/Taggings.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-package scala.tools.nsc
-package typechecker
-
-trait Taggings {
- self: Analyzer =>
-
- import global._
- import definitions._
-
- trait Tagging {
- self: Typer =>
-
- private def resolveTag(taggedTp: Type, pos: Position) = beforeTyper {
- inferImplicit(
- EmptyTree,
- taggedTp,
- /*reportAmbiguous =*/ true,
- /*isView =*/ false,
- /*context =*/ context,
- /*saveAmbiguousDivergent =*/ true,
- /*pos =*/ pos
- ).tree
- }
-
- /** Finds in scope or materializes an ArrayTag.
- * Should be used instead of ClassTag or ClassManifest every time compiler needs to create an array.
- *
- * @param tp Type we're looking an ArrayTag for, e.g. resolveArrayTag(IntClass.tpe, pos) will look for ArrayTag[Int].
- * @param pos Position for error reporting. Please, provide meaningful value.
- *
- * @returns Tree that represents an `scala.reflect.ArrayTag` for `tp` if everything is okay.
- * EmptyTree if the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
- */
- def resolveArrayTag(tp: Type, pos: Position): Tree = {
- val taggedTp = appliedType(ArrayTagClass.typeConstructor, List(tp))
- resolveTag(taggedTp, pos)
- }
-
- /** Finds in scope or materializes an ErasureTag (if `concrete` is false) or a ClassTag (if `concrete` is true).
- * Should be used instead of ClassTag or ClassManifest every time compiler needs to persist an erasure.
- *
- * @param tp Type we're looking an ErasureTag for, e.g. resolveErasureTag(IntClass.tpe, pos, true) will look for ClassTag[Int].
- * @param pos Position for error reporting. Please, provide meaningful value.
- * @param concrete If true then the result must not contain unresolved (i.e. not spliced) type parameters and abstract type members.
- * If false then the function will always succeed (abstract types will be erased to their upper bounds).
- *
- * @returns Tree that represents an `scala.reflect.ErasureTag` for `tp` if everything is okay.
- * EmptyTree if `concrete` is true and the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
- */
- def resolveErasureTag(tp: Type, pos: Position, concrete: Boolean): Tree = {
- val taggedTp = appliedType(if (concrete) ClassTagClass.typeConstructor else ErasureTagClass.typeConstructor, List(tp))
- resolveTag(taggedTp, pos)
- }
-
- /** Finds in scope or materializes a TypeTag (if `concrete` is false) or a ConcreteTypeTag (if `concrete` is true).
- *
- * @param pre Prefix that represents a universe this type tag will be bound to.
- * @param tp Type we're looking a TypeTag for, e.g. resolveTypeTag(reflectMirrorPrefix, IntClass.tpe, pos, false) will look for scala.reflect.mirror.TypeTag[Int].
- * @param pos Position for error reporting. Please, provide meaningful value.
- * @param concrete If true then the result must not contain unresolved (i.e. not spliced) type parameters and abstract type members.
- * If false then the function will always succeed (abstract types will be reified as free types).
- *
- * @returns Tree that represents a `scala.reflect.TypeTag` for `tp` if everything is okay.
- * EmptyTree if `concrete` is true and the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
- */
- def resolveTypeTag(pre: Type, tp: Type, pos: Position, concrete: Boolean): Tree = {
- val taggedTp = appliedType(singleType(pre, pre member (if (concrete) ConcreteTypeTagClass else TypeTagClass).name), List(tp))
- resolveTag(taggedTp, pos)
- }
- }
-} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala
new file mode 100644
index 0000000000..052484e8e1
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala
@@ -0,0 +1,69 @@
+package scala.tools.nsc
+package typechecker
+
+trait Tags {
+ self: Analyzer =>
+
+ import global._
+ import definitions._
+
+ trait Tag {
+ self: Typer =>
+
+ private def resolveTag(pos: Position, taggedTp: Type, allowMaterialization: Boolean) = beforeTyper {
+ def wrapper (tree: => Tree): Tree = if (allowMaterialization) (context.withMacrosEnabled[Tree](tree)) else (context.withMacrosDisabled[Tree](tree))
+ wrapper(inferImplicit(
+ EmptyTree,
+ taggedTp,
+ /*reportAmbiguous =*/ true,
+ /*isView =*/ false,
+ /*context =*/ context,
+ /*saveAmbiguousDivergent =*/ true,
+ /*pos =*/ pos
+ ).tree)
+ }
+
+ /** Finds in scope or materializes a ClassTag.
+ * Should be used instead of ClassManifest every time compiler needs to persist an erasure.
+ *
+ * Once upon a time, we had an `ErasureTag` which was to `ClassTag` the same that `AbsTypeTag` is for `TypeTag`.
+ * However we found out that we don't really need this concept, so it got removed.
+ *
+ * @param pos Position for error reporting. Please, provide meaningful value.
+ * @param tp Type we're looking a ClassTag for, e.g. resolveClassTag(pos, IntClass.tpe) will look for ClassTag[Int].
+ * @param allowMaterialization If true (default) then the resolver is allowed to launch materialization macros when there's no class tag in scope.
+ * If false then materialization macros are prohibited from running.
+ *
+ * @returns Tree that represents an `scala.reflect.ClassTag` for `tp` if everything is okay.
+ * EmptyTree if the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
+ * EmptyTree if `allowMaterialization` is false, and there is no class tag in scope.
+ */
+ def resolveClassTag(pos: Position, tp: Type, allowMaterialization: Boolean = true): Tree = {
+ val taggedTp = appliedType(ClassTagClass.typeConstructor, List(tp))
+ resolveTag(pos, taggedTp, allowMaterialization)
+ }
+
+ /** Finds in scope or materializes an AbsTypeTag (if `concrete` is false) or a TypeTag (if `concrete` is true).
+ *
+ * @param pos Position for error reporting. Please, provide meaningful value.
+ * @param pre Prefix that represents a universe this type tag will be bound to.
+ * If `pre` is set to `NoType`, then any type tag in scope will do, regardless of its affiliation.
+ * If `pre` is set to `NoType`, and tag resolution involves materialization, then `mkBasisPrefix` will be used.
+ * @param tp Type we're looking a TypeTag for, e.g. resolveTypeTag(pos, reflectBasisPrefix, IntClass.tpe, false) will look for scala.reflect.basis.TypeTag[Int].
+ * @param concrete If true then the result must not contain unresolved (i.e. not spliced) type parameters and abstract type members.
+ * If false then the function will always succeed (abstract types will be reified as free types).
+ * @param allowMaterialization If true (default) then the resolver is allowed to launch materialization macros when there's no type tag in scope.
+ * If false then materialization macros are prohibited from running.
+ *
+ * @returns Tree that represents a `scala.reflect.TypeTag` for `tp` if everything is okay.
+ * EmptyTree if `concrete` is true and the result contains unresolved (i.e. not spliced) type parameters and abstract type members.
+ * EmptyTree if `allowMaterialization` is false, and there is no array tag in scope.
+ */
+ def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = {
+ val tagSym = if (concrete) TypeTagClass else AbsTypeTagClass
+ val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.asTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name)
+ val taggedTp = appliedType(tagTp, List(tp))
+ resolveTag(pos, taggedTp, allowMaterialization)
+ }
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
index fde760c752..b0956446a7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
@@ -272,7 +272,7 @@ abstract class TreeCheckers extends Analyzer {
tree match {
case x: PackageDef =>
- if ((sym.ownerChain contains currentOwner) || currentOwner == definitions.EmptyPackageClass) ()
+ if ((sym.ownerChain contains currentOwner) || currentOwner.isEmptyPackageClass) ()
else fail(sym + " owner chain does not contain currentOwner " + currentOwner + sym.ownerChain)
case _ =>
def cond(s: Symbol) = !s.isTerm || s.isMethod || s == sym.owner
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 349bd1912b..2a1af2755f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -13,7 +13,7 @@ package scala.tools.nsc
package typechecker
import scala.collection.mutable
-import scala.tools.nsc.util.BatchSourceFile
+import scala.reflect.internal.util.BatchSourceFile
import mutable.ListBuffer
import symtab.Flags._
import util.Statistics
@@ -26,7 +26,7 @@ import util.Statistics._
* @author Martin Odersky
* @version 1.0
*/
-trait Typers extends Modes with Adaptations with Taggings {
+trait Typers extends Modes with Adaptations with Tags {
self: Analyzer =>
import global._
@@ -96,7 +96,7 @@ trait Typers extends Modes with Adaptations with Taggings {
// this is disabled by: -Xoldpatmat, scaladoc or interactive compilation
@inline private def newPatternMatching = opt.virtPatmat && !forScaladoc && !forInteractive // && (phase.id < currentRun.uncurryPhase.id)
- abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tagging with TyperContextErrors {
+ abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tag with TyperContextErrors {
import context0.unit
import typeDebug.{ ptTree, ptBlock, ptLine }
import TyperErrorGen._
@@ -237,7 +237,9 @@ trait Typers extends Modes with Adaptations with Taggings {
* @return ...
*/
def checkStable(tree: Tree): Tree =
- if (treeInfo.isExprSafeToInline(tree)) tree else UnstableTreeError(tree)
+ if (treeInfo.isExprSafeToInline(tree)) tree
+ else if (tree.isErrorTyped) tree
+ else UnstableTreeError(tree)
/** Would tree be a stable (i.e. a pure expression) if the type
* of its symbol was not volatile?
@@ -903,6 +905,10 @@ trait Typers extends Modes with Adaptations with Taggings {
def adaptType(): Tree = {
if (inFunMode(mode)) {
+ // [Eugene++] the commented line below makes sense for typechecking, say, TypeApply(Ident(`some abstract type symbol`), List(...))
+ // because otherwise Ident will have its tpe set to a TypeRef, not to a PolyType, and `typedTypeApply` will fail
+ // but this needs additional investigation, because it crashes t5228, gadts1 and maybe something else
+ // tree setType tree.tpe.normalize
tree
} else if (tree.hasSymbol && !tree.symbol.typeParams.isEmpty && !inHKMode(mode) &&
!(tree.symbol.isJavaDefined && context.unit.isJava)) { // (7)
@@ -960,12 +966,21 @@ trait Typers extends Modes with Adaptations with Taggings {
* see test/files/../t5189*.scala
*/
def adaptConstrPattern(): Tree = { // (5)
- def isExtractor(sym: Symbol) = reallyExists(unapplyMember(sym.tpe))
- val extractor = tree.symbol filter isExtractor
+ def hasUnapplyMember(tp: Type) = reallyExists(unapplyMember(tp))
+ val overloadedExtractorOfObject = tree.symbol filter (sym => hasUnapplyMember(sym.tpe))
+ // if the tree's symbol's type does not define an extractor, maybe the tree's type does
+ // this is the case when we encounter an arbitrary tree as the target of an unapply call (rather than something that looks like a constructor call)
+ // (for now, this only happens due to wrapClassTagUnapply, but when we support parameterized extractors, it will become more common place)
+ val extractor = overloadedExtractorOfObject orElse unapplyMember(tree.tpe)
if (extractor != NoSymbol) {
- tree setSymbol extractor
+ // if we did some ad-hoc overloading resolution, update the tree's symbol
+ // do not update the symbol if the tree's symbol's type does not define an unapply member
+ // (e.g. since it's some method that returns an object with an unapply member)
+ if (overloadedExtractorOfObject != NoSymbol)
+ tree setSymbol overloadedExtractorOfObject
+
tree.tpe match {
- case OverloadedType(pre, alts) => tree.tpe = overloadedType(pre, alts filter isExtractor)
+ case OverloadedType(pre, alts) => tree.tpe = overloadedType(pre, alts filter (alt => hasUnapplyMember(alt.tpe)))
case _ =>
}
val unapply = unapplyMember(extractor.tpe)
@@ -1350,20 +1365,21 @@ trait Typers extends Modes with Adaptations with Taggings {
if (!clazz.isStatic)
unit.error(clazz.pos, "value class may not be a "+
(if (clazz.owner.isTerm) "local class" else "member of another class"))
- val constr = clazz.primaryConstructor
- clazz.info.decls.toList.filter(acc => acc.isMethod && (acc hasFlag PARAMACCESSOR)) match {
- case List(acc) =>
- def isUnderlyingAcc(sym: Symbol) =
- sym == acc || acc.hasAccessorFlag && sym == acc.accessed
- if (acc.accessBoundary(clazz) != RootClass)
- unit.error(acc.pos, "value class needs to have a publicly accessible val parameter")
- for (stat <- body)
- if (!treeInfo.isAllowedInUniversalTrait(stat) && !isUnderlyingAcc(stat.symbol))
- unit.error(stat.pos,
- if (stat.symbol hasFlag PARAMACCESSOR) "illegal parameter for value class"
- else "this statement is not allowed in value class: "+stat)
- case x =>
- unit.error(clazz.pos, "value class needs to have exactly one public val parameter")
+ if (!clazz.isPrimitiveValueClass) {
+ clazz.info.decls.toList.filter(acc => acc.isMethod && (acc hasFlag PARAMACCESSOR)) match {
+ case List(acc) =>
+ def isUnderlyingAcc(sym: Symbol) =
+ sym == acc || acc.hasAccessorFlag && sym == acc.accessed
+ if (acc.accessBoundary(clazz) != rootMirror.RootClass)
+ unit.error(acc.pos, "value class needs to have a publicly accessible val parameter")
+ for (stat <- body)
+ if (!treeInfo.isAllowedInUniversalTrait(stat) && !isUnderlyingAcc(stat.symbol))
+ unit.error(stat.pos,
+ if (stat.symbol hasFlag PARAMACCESSOR) "illegal parameter for value class"
+ else "this statement is not allowed in value class: " + stat)
+ case x =>
+ unit.error(clazz.pos, "value class needs to have exactly one public val parameter")
+ }
}
for (tparam <- clazz.typeParams)
if (tparam hasAnnotation definitions.SpecializedClass)
@@ -1729,7 +1745,7 @@ trait Typers extends Modes with Adaptations with Taggings {
val body1 = typedStats(body, templ.symbol)
- if (clazz.isDerivedValueClass)
+ if (clazz.info.firstParent.typeSymbol == AnyValClass)
validateDerivedValueClass(clazz, body1)
treeCopy.Template(templ, parents1, self1, body1) setType clazz.tpe
@@ -2237,7 +2253,7 @@ trait Typers extends Modes with Adaptations with Taggings {
// takes untyped sub-trees of a match and type checks them
def typedMatch(selector: Tree, cases: List[CaseDef], mode: Int, pt: Type, tree: Tree = EmptyTree): Match = {
val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType))
- val selectorTp = packCaptured(selector1.tpe.widen)
+ val selectorTp = packCaptured(selector1.tpe.widen).skolemizeExistential(context.owner, selector)
val casesTyped = typedCases(cases, selectorTp, pt)
val (resTp, needAdapt) =
@@ -2309,7 +2325,7 @@ trait Typers extends Modes with Adaptations with Taggings {
import CODE._
// need to duplicate the cases before typing them to generate the apply method, or the symbols will be all messed up
- val casesTrue = if (isPartial) cases map (c => deriveCaseDef(c)(x => atPos(x.pos.focus)(TRUE_typed)).duplicate) else Nil
+ val casesTrue = if (isPartial) cases map (c => deriveCaseDef(c)(x => atPos(x.pos.focus)(TRUE_typed)).duplicate.asInstanceOf[CaseDef]) else Nil
// println("casesTrue "+ casesTrue)
def parentsPartial(targs: List[Type]) = addSerializable(appliedType(AbstractPartialFunctionClass.typeConstructor, targs))
@@ -2377,7 +2393,7 @@ trait Typers extends Modes with Adaptations with Taggings {
match_ setType B1.tpe
// the default uses applyOrElse's first parameter since the scrut's type has been widened
- val body = methodBodyTyper.virtualizedMatch(match_ withAttachment DefaultOverrideMatchAttachment(REF(default) APPLY (REF(x))), mode, B1.tpe)
+ val body = methodBodyTyper.virtualizedMatch(match_ addAttachment DefaultOverrideMatchAttachment(REF(default) APPLY (REF(x))), mode, B1.tpe)
DefDef(methodSym, body)
}
@@ -2395,7 +2411,7 @@ trait Typers extends Modes with Adaptations with Taggings {
methodSym setInfoAndEnter MethodType(paramSyms, BooleanClass.tpe)
val match_ = methodBodyTyper.typedMatch(gen.mkUnchecked(selector), casesTrue, mode, BooleanClass.tpe)
- val body = methodBodyTyper.virtualizedMatch(match_ withAttachment DefaultOverrideMatchAttachment(FALSE_typed), mode, BooleanClass.tpe)
+ val body = methodBodyTyper.virtualizedMatch(match_ addAttachment DefaultOverrideMatchAttachment(FALSE_typed), mode, BooleanClass.tpe)
DefDef(methodSym, body)
}
@@ -2506,11 +2522,18 @@ trait Typers extends Modes with Adaptations with Taggings {
}
}
- def typedRefinement(stats: List[Tree]) {
+ def typedRefinement(templ: Template) {
+ val stats = templ.body
namer.enterSyms(stats)
// need to delay rest of typedRefinement to avoid cyclic reference errors
unit.toCheck += { () =>
val stats1 = typedStats(stats, NoSymbol)
+ // this code kicks in only after typer, so `stats` will never be filled in time
+ // as a result, most of compound type trees with non-empty stats will fail to reify
+ // [Eugene++] todo. investigate whether something can be done about this
+ val att = templ.attachments.get[CompoundTypeTreeOriginalAttachment].getOrElse(CompoundTypeTreeOriginalAttachment(Nil, Nil))
+ templ.removeAttachment[CompoundTypeTreeOriginalAttachment]
+ templ addAttachment att.copy(stats = stats1)
for (stat <- stats1 if stat.isDef) {
val member = stat.symbol
if (!(context.owner.ancestors forall
@@ -2523,7 +2546,7 @@ trait Typers extends Modes with Adaptations with Taggings {
def typedImport(imp : Import) : Import = (transformed remove imp) match {
case Some(imp1: Import) => imp1
- case None => log("unhandled import: "+imp+" in "+unit); imp
+ case _ => log("unhandled import: "+imp+" in "+unit); imp
}
private def isWarnablePureExpression(tree: Tree) = tree match {
case EmptyTree | Literal(Constant(())) => false
@@ -2549,9 +2572,11 @@ trait Typers extends Modes with Adaptations with Taggings {
else
stat match {
case imp @ Import(_, _) =>
- context = context.makeNewImport(imp)
imp.symbol.initialize
- typedImport(imp)
+ if (!imp.symbol.isError) {
+ context = context.makeNewImport(imp)
+ typedImport(imp)
+ } else EmptyTree
case _ =>
if (localTarget && !includesTargetPos(stat)) {
// skip typechecking of statements in a sequence where some other statement includes
@@ -3026,9 +3051,21 @@ trait Typers extends Modes with Adaptations with Taggings {
case ErrorType =>
if (!tree.isErrorTyped) setError(tree) else tree
// @H change to setError(treeCopy.Apply(tree, fun, args))
- /* --- begin unapply --- */
case otpe if inPatternMode(mode) && unapplyMember(otpe).exists =>
+ doTypedUnapply(tree, fun0, fun, args, mode, pt)
+
+ case _ =>
+ duplErrorTree(ApplyWithoutArgsError(tree, fun))
+ }
+ }
+
+ def doTypedUnapply(tree: Tree, fun0: Tree, fun: Tree, args: List[Tree], mode: Int, pt: Type): Tree = {
+ def duplErrTree = setError(treeCopy.Apply(tree, fun0, args))
+ def duplErrorTree(err: AbsTypeError) = { issue(err); duplErrTree }
+
+ val otpe = fun.tpe
+
if (args.length > MaxTupleArity)
return duplErrorTree(TooManyArgsPatternError(fun))
@@ -3052,6 +3089,11 @@ trait Typers extends Modes with Adaptations with Taggings {
val argDummy = context.owner.newValue(nme.SELECTOR_DUMMY, fun.pos, SYNTHETIC) setInfo pt
val arg = Ident(argDummy) setType pt
+ val uncheckedTypeExtractor =
+ if (unappType.paramTypes.nonEmpty)
+ extractorForUncheckedType(tree.pos, unappType.paramTypes.head)
+ else None
+
if (!isApplicableSafe(Nil, unappType, List(pt), WildcardType)) {
//Console.println("UNAPP: need to typetest, arg.tpe = "+arg.tpe+", unappType = "+unappType)
val (freeVars, unappFormal) = freshArgType(unappType.skolemizeExistential(context.owner, tree))
@@ -3059,7 +3101,7 @@ trait Typers extends Modes with Adaptations with Taggings {
freeVars foreach unapplyContext.scope.enter
val typer1 = newTyper(unapplyContext)
- val pattp = typer1.infer.inferTypedPattern(tree, unappFormal, arg.tpe)
+ val pattp = typer1.infer.inferTypedPattern(tree, unappFormal, arg.tpe, canRemedy = uncheckedTypeExtractor.nonEmpty)
// turn any unresolved type variables in freevars into existential skolems
val skolems = freeVars map (fv => unapplyContext.owner.newExistentialSkolem(fv, fv))
@@ -3084,15 +3126,58 @@ trait Typers extends Modes with Adaptations with Taggings {
val itype = glb(List(pt1, arg.tpe))
arg.tpe = pt1 // restore type (arg is a dummy tree, just needs to pass typechecking)
- UnApply(fun1, args1) setPos tree.pos setType itype
+ val unapply = UnApply(fun1, args1) setPos tree.pos setType itype
+
+ // if the type that the unapply method expects for its argument is uncheckable, wrap in classtag extractor
+ // skip if the unapply's type is not a method type with (at least, but really it should be exactly) one argument
+ // also skip if we already wrapped a classtag extractor (so we don't keep doing that forever)
+ if (uncheckedTypeExtractor.isEmpty || fun1.symbol.owner.isNonBottomSubClass(ClassTagClass)) unapply
+ else wrapClassTagUnapply(unapply, uncheckedTypeExtractor.get, unappType.paramTypes.head)
} else
duplErrorTree(WrongNumberArgsPatternError(tree, fun))
}
+ }
-/* --- end unapply --- */
- case _ =>
- duplErrorTree(ApplyWithoutArgsError(tree, fun))
+ def wrapClassTagUnapply(uncheckedPattern: Tree, classTagExtractor: Tree, pt: Type): Tree = {
+ // TODO: disable when in unchecked match
+ // we don't create a new Context for a Match, so find the CaseDef, then go out one level and navigate back to the match that has this case
+ // val thisCase = context.nextEnclosing(_.tree.isInstanceOf[CaseDef])
+ // val unchecked = thisCase.outer.tree.collect{case Match(selector, cases) if cases contains thisCase => selector} match {
+ // case List(Typed(_, tpt)) if treeInfo.isUncheckedAnnotation(tpt.tpe) => true
+ // case t => println("outer tree: "+ (t, thisCase, thisCase.outer.tree)); false
+ // }
+ // println("wrapClassTagUnapply"+ (!isPastTyper && infer.containsUnchecked(pt), pt, uncheckedPattern))
+ // println("wrapClassTagUnapply: "+ extractor)
+ // println(util.Position.formatMessage(uncheckedPattern.pos, "made unchecked type test into a checked one", true))
+
+ val args = List(uncheckedPattern)
+ // must call doTypedUnapply directly, as otherwise we get undesirable rewrites
+ // and re-typechecks of the target of the unapply call in PATTERNmode,
+ // this breaks down when the classTagExtractor (which defineds the unapply member) is not a simple reference to an object,
+ // but an arbitrary tree as is the case here
+ doTypedUnapply(Apply(classTagExtractor, args), classTagExtractor, classTagExtractor, args, PATTERNmode, pt)
}
+
+ // if there's a ClassTag that allows us to turn the unchecked type test for `pt` into a checked type test
+ // return the corresponding extractor (an instance of ClassTag[`pt`])
+ def extractorForUncheckedType(pos: Position, pt: Type): Option[Tree] = if (!opt.virtPatmat || isPastTyper) None else {
+ // only look at top-level type, can't (reliably) do anything about unchecked type args (in general)
+ pt.normalize.typeConstructor match {
+ // if at least one of the types in an intersection is checkable, use the checkable ones
+ // this avoids problems as in run/matchonseq.scala, where the expected type is `Coll with scala.collection.SeqLike`
+ // Coll is an abstract type, but SeqLike of course is not
+ case RefinedType(parents, _) if (parents.length >= 2) && (parents.exists(tp => !infer.containsUnchecked(tp))) =>
+ None
+
+ case ptCheckable if infer.containsUnchecked(ptCheckable) =>
+ val classTagExtractor = resolveClassTag(pos, ptCheckable)
+
+ if (classTagExtractor != EmptyTree && unapplyMember(classTagExtractor.tpe) != NoSymbol)
+ Some(classTagExtractor)
+ else None
+
+ case _ => None
+ }
}
/**
@@ -3143,7 +3228,7 @@ trait Typers extends Modes with Adaptations with Taggings {
if (annInfo.atp.isErroneous) { hasError = true; None }
else Some(NestedAnnotArg(annInfo))
- // use of Array.apply[T: ArrayTag](xs: T*): Array[T]
+ // use of Array.apply[T: ClassTag](xs: T*): Array[T]
// and Array.apply(x: Int, xs: Int*): Array[Int] (and similar)
case Apply(fun, args) =>
val typedFun = typed(fun, forFunMode(mode), WildcardType)
@@ -3535,7 +3620,7 @@ trait Typers extends Modes with Adaptations with Taggings {
typedClassOf(tree, args.head, true)
else {
if (!isPastTyper && fun.symbol == Any_isInstanceOf && !targs.isEmpty)
- checkCheckable(tree, targs.head, "")
+ checkCheckable(tree, targs.head, inPattern = false)
val resultpe = restpe.instantiateTypeParams(tparams, targs)
//@M substitution in instantiateParams needs to be careful!
//@M example: class Foo[a] { def foo[m[x]]: m[a] = error("") } (new Foo[Int]).foo[List] : List[Int]
@@ -3629,7 +3714,7 @@ trait Typers extends Modes with Adaptations with Taggings {
case t => (t, Nil)
}
- @inline def hasNamedArg(as: List[Tree]) = as collectFirst {case AssignOrNamedArg(lhs, rhs) =>} nonEmpty
+ @inline def hasNamedArg(as: List[Tree]) = as.collectFirst{case AssignOrNamedArg(lhs, rhs) =>}.nonEmpty
// note: context.tree includes at most one Apply node
// thus, we can't use it to detect we're going to receive named args in expressions such as:
@@ -3649,7 +3734,7 @@ trait Typers extends Modes with Adaptations with Taggings {
}
val dynSel = Select(qual, oper)
- val tappSel = if (explicitTargs nonEmpty) TypeApply(dynSel, explicitTargs) else dynSel
+ val tappSel = if (explicitTargs.nonEmpty) TypeApply(dynSel, explicitTargs) else dynSel
atPos(qual.pos)(Apply(tappSel, List(Literal(Constant(name.decode)))))
}
@@ -3686,11 +3771,10 @@ trait Typers extends Modes with Adaptations with Taggings {
// hence we go the extra mile to hand-craft tis guy
val original =
if (arg1.isType)
- (tree, arg1) match {
- case (Annotated(annot, arg), tt @ TypeTree()) => Annotated(annot, tt.original)
+ arg1 match {
+ case tt @ TypeTree() => Annotated(ann, tt.original)
// this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)"
- case (Annotated(annot, arg), _) => Annotated(annot, arg1)
- case _ => throw new Error("unexpected trees in typedAnnotated: tree = %s, arg1 = %s".format(showRaw(tree), showRaw(arg1)))
+ case _ => Annotated(ann, arg1)
}
else
tree
@@ -4177,7 +4261,8 @@ trait Typers extends Modes with Adaptations with Taggings {
nme.update,
Apply(Select(mkCall(nme.apply), prefix) setPos fun.pos, args) setPos tree.pos
)
- }
+ case _ => EmptyTree
+ }
}
val tree1 = qual match {
@@ -4394,7 +4479,7 @@ trait Typers extends Modes with Adaptations with Taggings {
// last ditch effort before failing. This method sets defSym and returns
// true if a member of the given name exists.
def checkEmptyPackage(): Boolean = {
- defSym = EmptyPackageClass.tpe.nonPrivateMember(name)
+ defSym = rootMirror.EmptyPackageClass.tpe.nonPrivateMember(name)
defSym != NoSymbol
}
def startingIdentContext = (
@@ -4419,10 +4504,6 @@ trait Typers extends Modes with Adaptations with Taggings {
var cx = startingIdentContext
while (defSym == NoSymbol && cx != NoContext && (cx.scope ne null)) { // cx.scope eq null arises during FixInvalidSyms in Duplicators
- // !!! Shouldn't the argument to compileSourceFor be cx, not context?
- // I can't tell because those methods do nothing in the standard compiler,
- // presumably they are overridden in the IDE.
- currentRun.compileSourceFor(context.asInstanceOf[analyzer.Context], name)
pre = cx.enclClass.prefix
defEntry = cx.scope.lookupEntry(name)
if ((defEntry ne null) && qualifies(defEntry.sym)) {
@@ -4526,7 +4607,7 @@ trait Typers extends Modes with Adaptations with Taggings {
log("Allowing empty package member " + name + " due to settings.")
else {
if ((mode & QUALmode) != 0) {
- val lastTry = missingHook(RootClass, name)
+ val lastTry = missingHook(rootMirror.RootClass, name)
if (lastTry != NoSymbol) return typed1(tree setSymbol lastTry, mode, pt)
}
if (settings.debug.value) {
@@ -4580,7 +4661,8 @@ trait Typers extends Modes with Adaptations with Taggings {
val decls = newScope
//Console.println("Owner: " + context.enclClass.owner + " " + context.enclClass.owner.id)
val self = refinedType(parents1 map (_.tpe), context.enclClass.owner, decls, templ.pos)
- newTyper(context.make(templ, self.typeSymbol, decls)).typedRefinement(templ.body)
+ newTyper(context.make(templ, self.typeSymbol, decls)).typedRefinement(templ)
+ templ addAttachment CompoundTypeTreeOriginalAttachment(parents1, Nil) // stats are set elsewhere
tree setType self
}
}
@@ -4795,10 +4877,21 @@ trait Typers extends Modes with Adaptations with Taggings {
}
case Typed(expr, tpt) =>
- val tpt1 = typedType(tpt, mode)
- val expr1 = typed(expr, onlyStickyModes(mode), tpt1.tpe.deconst)
- val ownType = if (isPatternMode) inferTypedPattern(tpt1, tpt1.tpe, pt) else tpt1.tpe
- treeCopy.Typed(tree, expr1, tpt1) setType ownType
+ val tptTyped = typedType(tpt, mode)
+ val exprTyped = typed(expr, onlyStickyModes(mode), tptTyped.tpe.deconst)
+ val treeTyped = treeCopy.Typed(tree, exprTyped, tptTyped)
+
+ if (isPatternMode) {
+ val uncheckedTypeExtractor = extractorForUncheckedType(tpt.pos, tptTyped.tpe)
+ val ownType = inferTypedPattern(tptTyped, tptTyped.tpe, pt, canRemedy = uncheckedTypeExtractor.nonEmpty)
+ treeTyped setType ownType
+
+ uncheckedTypeExtractor match {
+ case None => treeTyped
+ case Some(extractor) => wrapClassTagUnapply(treeTyped, extractor, tptTyped.tpe)
+ }
+ } else
+ treeTyped setType tptTyped.tpe
case TypeApply(fun, args) =>
// @M: kind-arity checking is done here and in adapt, full kind-checking is in checkKindBounds (in Infer)
@@ -4852,8 +4945,8 @@ trait Typers extends Modes with Adaptations with Taggings {
val Some((level, componentType)) = erasure.GenericArray.unapply(tpt.tpe)
val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.asType, List(tpe))).last
val newArrayApp = atPos(tree.pos) {
- val tag = resolveArrayTag(tagType, tree.pos)
- if (tag.isEmpty) MissingArrayTagError(tree, tagType)
+ val tag = resolveClassTag(tree.pos, tagType)
+ if (tag.isEmpty) MissingClassTagError(tree, tagType)
else new ApplyToImplicitArgs(Select(tag, nme.newArray), args)
}
typed(newArrayApp, mode, pt)
@@ -4862,6 +4955,7 @@ trait Typers extends Modes with Adaptations with Taggings {
}
case ApplyDynamic(qual, args) =>
+ assert(phase.erasedTypes)
val reflectiveCalls = !(settings.refinementMethodDispatch.value == "invoke-dynamic")
val qual1 = typed(qual, AnyRefClass.tpe)
val args1 = args mapConserve (arg => if (reflectiveCalls) typed(arg, AnyRefClass.tpe) else typed(arg))
@@ -4908,7 +5002,7 @@ trait Typers extends Modes with Adaptations with Taggings {
if (tree1.symbol != null && tree1.symbol.isOnlyRefinementMember)
checkFeature(tree1.pos, ReflectiveCallsFeature, tree1.symbol.toString)
- if (qual1.symbol == RootPackage) treeCopy.Ident(tree1, name)
+ if (qual1.hasSymbolWhich(_.isRootPackage)) treeCopy.Ident(tree1, name)
else tree1
case Ident(name) =>
@@ -5209,7 +5303,8 @@ trait Typers extends Modes with Adaptations with Taggings {
}
val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous))
- if (isMacroBodyOkay) computeMacroDefTypeFromMacroImpl(ddef, tree.symbol, tree1.symbol) else AnyClass.tpe
+ val shouldInheritMacroImplReturnType = ddef.tpt.isEmpty
+ if (isMacroBodyOkay && shouldInheritMacroImplReturnType) computeMacroDefTypeFromMacroImpl(ddef, tree.symbol, tree1.symbol) else AnyClass.tpe
}
def transformedOr(tree: Tree, op: => Tree): Tree = transformed.get(tree) match {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
index 3d9453d8cd..4c20d14406 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
@@ -221,10 +221,13 @@ trait Unapplies extends ast.TreeDSL
val bodyTpe = funParamss.foldRight(classTpe)((params, restp) => gen.scalaFunctionConstr(params.map(_.tpt), restp))
val argss = copyParamss match {
- case Nil => Nil
- case ps :: Nil => mmap(ps :: funParamss)(toIdent)
- }
- val body = funParamss.foldRight(New(classTpe, argss): Tree)(Function)
+ case Nil => Nil
+ case ps :: _ => mmap(ps :: funParamss)(toIdent)
+ }
+ def mkFunction(vparams: List[ValDef], body: Tree) = Function(vparams, body)
+ val body = funParamss.foldRight(New(classTpe, argss): Tree)(mkFunction)
+ // [Eugene++] no longer compiles after I moved the `Function` case class into scala.reflect.internal
+ // val body = funParamss.foldRight(New(classTpe, argss): Tree)(Function)
Some(atPos(cdef.pos.focus)(
DefDef(Modifiers(SYNTHETIC), nme.copy, tparams, copyParamss, bodyTpe,
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 404490bd49..9755fb6c60 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -10,7 +10,8 @@ package util
import java.net.URL
import scala.collection.{ mutable, immutable }
import io.{ File, Directory, Path, Jar, AbstractFile }
-import scala.tools.util.StringOps.splitWhere
+import scala.reflect.internal.util.StringOps.splitWhere
+import scala.reflect.ClassTag
import Jar.isJarOrZip
import File.pathSeparator
import java.net.MalformedURLException
@@ -312,6 +313,13 @@ class DirectoryClassPath(val dir: AbstractFile, val context: ClassPathContext[Ab
override def toString() = "directory classpath: "+ origin.getOrElse("?")
}
+class DeltaClassPath[T](original: MergedClassPath[T], subst: Map[ClassPath[T], ClassPath[T]])
+extends MergedClassPath[T](original.entries map (e => subst getOrElse (e, e)), original.context) {
+ // not sure we should require that here. Commented out for now.
+ // require(subst.keySet subsetOf original.entries.toSet)
+ // We might add specialized operations for computing classes packages here. Not sure it's worth it.
+}
+
/**
* A classpath unifying multiple class- and sourcepath entries.
*/
diff --git a/src/compiler/scala/tools/nsc/util/Exceptional.scala b/src/compiler/scala/tools/nsc/util/Exceptional.scala
index 7c093b7866..90d032518a 100644
--- a/src/compiler/scala/tools/nsc/util/Exceptional.scala
+++ b/src/compiler/scala/tools/nsc/util/Exceptional.scala
@@ -3,7 +3,7 @@ package util
import java.util.concurrent.ExecutionException
import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableException }
-import scala.tools.util.StringOps._
+import scala.reflect.internal.util.StringOps._
import language.implicitConversions
object Exceptional {
diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
index 88fc6718a2..16bf748414 100644
--- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
+++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
@@ -16,9 +16,9 @@ trait FreshNameCreator {
def newName(prefix: String): String
@deprecated("use newName(prefix)", "2.9.0")
- def newName(pos: util.Position, prefix: String): String = newName(prefix)
+ def newName(pos: scala.reflect.internal.util.Position, prefix: String): String = newName(prefix)
@deprecated("use newName()", "2.9.0")
- def newName(pos: util.Position): String = newName()
+ def newName(pos: scala.reflect.internal.util.Position): String = newName()
}
object FreshNameCreator {
diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
index 4c7920d6b3..5b30d9aacd 100644
--- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
+++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
@@ -11,10 +11,11 @@ import java.lang.reflect.{ Constructor, Modifier, Method }
import java.io.{ File => JFile }
import java.net.{ URLClassLoader => JURLClassLoader }
import java.net.URL
-import scala.reflect.ReflectionUtils.unwrapHandler
+import scala.reflect.runtime.ReflectionUtils.unwrapHandler
import ScalaClassLoader._
import scala.util.control.Exception.{ catching }
import language.implicitConversions
+import scala.reflect.{ ClassTag, classTag }
trait HasClassPath {
def classPathURLs: Seq[URL]
@@ -46,7 +47,7 @@ trait ScalaClassLoader extends JClassLoader {
tryToInitializeClass[AnyRef](path) map (_.newInstance()) orNull
def constructorsOf[T <: AnyRef : ClassTag]: List[Constructor[T]] =
- classTag[T].erasure.getConstructors.toList map (_.asInstanceOf[Constructor[T]])
+ classTag[T].runtimeClass.getConstructors.toList map (_.asInstanceOf[Constructor[T]])
/** The actual bytes for a class file, or an empty array if it can't be found. */
def classBytes(className: String): Array[Byte] = classAsStream(className) match {
@@ -102,7 +103,7 @@ object ScalaClassLoader {
def bootLoader = apply(null)
def contextChain = loaderChain(contextLoader)
- def pathToErasure[T: ClassTag] = pathToClass(classTag[T].erasure)
+ def pathToErasure[T: ClassTag] = pathToClass(classTag[T].runtimeClass)
def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class"
def locate[T: ClassTag] = contextLoader getResource pathToErasure[T]
diff --git a/src/compiler/scala/tools/nsc/util/Statistics.scala b/src/compiler/scala/tools/nsc/util/Statistics.scala
index 61c7695911..087111a7ba 100644
--- a/src/compiler/scala/tools/nsc/util/Statistics.scala
+++ b/src/compiler/scala/tools/nsc/util/Statistics.scala
@@ -60,6 +60,14 @@ class Statistics extends scala.reflect.internal.util.Statistics {
val macroExpandCount = new Counter
val macroExpandNanos = new Timer
+
+ val patmatNanos = new Timer
+ val patmatAnaDPLL = new Timer
+ val patmatAnaVarEq = new Timer
+ val patmatCNF = new Timer
+ val patmatAnaExhaust = new Timer
+ val patmatAnaReach = new Timer
+ val patmatCNFSizes = new collection.mutable.HashMap[Int, Int] withDefaultValue 0
}
object Statistics extends Statistics
@@ -71,7 +79,7 @@ abstract class StatisticsInfo {
val global: Global
import global._
- var phasesShown = List("parser", "typer", "erasure", "cleanup")
+ var phasesShown = List("parser", "typer", "patmat", "erasure", "cleanup")
def countNodes(tree: Tree, counts: ClassCounts) {
for (t <- tree) counts(t.getClass) += 1
@@ -83,10 +91,15 @@ abstract class StatisticsInfo {
def showRelTyper(timer: Timer) =
timer+showPercent(timer.nanos, typerNanos.nanos)
- def showCounts(counts: ClassCounts) =
+ def showRelPatmat(timer: Timer) =
+ timer+showPercent(timer.nanos, patmatNanos.nanos)
+
+ def showCounts[T](counts: scala.collection.mutable.Map[T, Int]) =
counts.toSeq.sortWith(_._2 > _._2).map {
- case (cls, cnt) =>
+ case (cls: Class[_], cnt) =>
cls.toString.substring(cls.toString.lastIndexOf("$") + 1)+": "+cnt
+ case (o, cnt) =>
+ o.toString +": "+cnt
}
def print(phase: Phase) = if (phasesShown contains phase.name) {
@@ -125,6 +138,8 @@ abstract class StatisticsInfo {
inform(" of which in app impl : " + subtypeAppInfos)
inform(" of which in improv : " + subtypeImprovCount)
inform("#sametype : " + sametypeCount)
+ inform("#toplevel lub : " + lubCount)
+ inform("#all lub : " + nestedLubCount)
inform("ms type-flow-analysis: " + analysis.timer.millis)
if (phase.name == "typer") {
@@ -142,6 +157,7 @@ abstract class StatisticsInfo {
inform(" failed apply : " + showRelTyper(failedApplyNanos))
inform(" failed op= : " + showRelTyper(failedOpEqNanos))
inform("time spent ref scanning : " + showRelTyper(isReferencedNanos))
+ inform("time spent in lubs : " + showRelTyper(lubNanos))
inform("micros by tree node : " + showCounts(microsByType))
inform("#visits by tree node : " + showCounts(visitsByType))
val average = new ClassCounts
@@ -169,6 +185,16 @@ abstract class StatisticsInfo {
if (timer1 != null) inform("#timer1 : " + timer1)
if (timer2 != null) inform("#timer2 : " + timer2)
//for (t <- uniques.iterator) println("unique: "+t)
+
+ if (phase.name == "patmat") {
+ inform("time spent in patmat : " + patmatNanos )
+ inform(" of which DPLL : " + showRelPatmat(patmatAnaDPLL ))
+ inform("of which in CNF conversion : " + showRelPatmat(patmatCNF ))
+ inform(" CNF size counts : " + showCounts(patmatCNFSizes ))
+ inform("of which variable equality : " + showRelPatmat(patmatAnaVarEq ))
+ inform(" of which in exhaustivity : " + showRelPatmat(patmatAnaExhaust))
+ inform("of which in unreachability : " + showRelPatmat(patmatAnaReach ))
+ }
}
}
}
diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala
index 1336cca3c5..2229b8d997 100644
--- a/src/compiler/scala/tools/nsc/util/package.scala
+++ b/src/compiler/scala/tools/nsc/util/package.scala
@@ -86,4 +86,57 @@ package object util {
lazy val trace = new SimpleTracer(System.out)
lazy val errtrace = new SimpleTracer(System.err)
+ @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("Moved to scala.reflect.internal.util.TableDef", "2.10.0")
+ val TableDef = scala.reflect.internal.util.TableDef
+
+ @deprecated("Moved to scala.reflect.internal.util.TableDef", "2.10.0")
+ type TableDef[T] = scala.reflect.internal.util.TableDef[T]
+
+ @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
+
+ @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
+
+ @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/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala
new file mode 100644
index 0000000000..59160f87d0
--- /dev/null
+++ b/src/compiler/scala/tools/reflect/FastTrack.scala
@@ -0,0 +1,47 @@
+package scala.tools
+package reflect
+
+import scala.reflect.makro.runtime.ContextReifiers
+import scala.reflect.reify.Taggers
+import scala.tools.nsc.typechecker.{Analyzer, Macros}
+
+/** Optimizes system macro expansions by hardwiring them directly to their implementations
+ * bypassing standard reflective load and invoke to avoid the overhead of Java/Scala reflection.
+ */
+trait FastTrack {
+ self: Macros with Analyzer =>
+
+ import global._
+ import definitions._
+
+ import language.implicitConversions
+ private implicit def context2taggers(c0: MacroContext) : Taggers { val c: c0.type } = new { val c: c0.type = c0 } with Taggers
+ private implicit def context2contextreifiers(c0: MacroContext) : ContextReifiers { val c: c0.type } = new { val c: c0.type = c0 } with ContextReifiers
+
+ implicit def fastTrackEntry2MacroRuntime(entry: FastTrackEntry): MacroRuntime = args => entry.run(args)
+ type FastTrackExpander = PartialFunction[(MacroContext, Tree), Tree]
+ case class FastTrackEntry(sym: Symbol, expander: FastTrackExpander) {
+ def validate(argss: List[List[Any]]): Boolean = {
+ val c = argss.flatten.apply(0).asInstanceOf[MacroContext]
+ val isValid = expander isDefinedAt (c, c.expandee)
+ isValid
+ }
+ def run(args: List[Any]): Any = {
+ val c = args(0).asInstanceOf[MacroContext]
+ val result = expander((c, c.expandee))
+ c.Expr[Nothing](result)(c.TypeTag.Nothing)
+ }
+ }
+
+ lazy val fastTrack: Map[Symbol, FastTrackEntry] = {
+ var registry = Map[Symbol, FastTrackEntry]()
+ implicit class BindTo(sym: Symbol) { def bindTo(expander: FastTrackExpander): Unit = if (sym != NoSymbol) registry += sym -> FastTrackEntry(sym, expander) }
+ MacroInternal_materializeClassTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeClassTag(u, tt.tpe) }
+ MacroInternal_materializeAbsTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) }
+ MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) }
+ ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) }
+ MacroContextReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExprForMacroContext(c.prefix.tree, expr) }
+ ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree }
+ registry
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/FrontEnds.scala b/src/compiler/scala/tools/reflect/FrontEnds.scala
index 74501c7686..d8f07fb2e5 100644
--- a/src/compiler/scala/reflect/internal/FrontEnds.scala
+++ b/src/compiler/scala/tools/reflect/FrontEnds.scala
@@ -1,10 +1,13 @@
-package scala.reflect
-package internal
+package scala.tools
+package reflect
-trait FrontEnds { self: SymbolTable =>
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import scala.reflect.ClassTag
- import scala.tools.nsc.reporters._
- import scala.tools.nsc.Settings
+trait FrontEnds extends scala.reflect.api.FrontEnds {
+
+ type Position = scala.reflect.internal.util.Position
def mkConsoleFrontEnd(minSeverity: Int = 1): FrontEnd = {
val settings = new Settings()
diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala
new file mode 100644
index 0000000000..c782181f21
--- /dev/null
+++ b/src/compiler/scala/tools/reflect/StdTags.scala
@@ -0,0 +1,42 @@
+package scala.tools
+package reflect
+
+import java.lang.{Class => jClass}
+import scala.reflect.{ClassTag, classTag}
+import scala.reflect.base.{MirrorOf, TypeCreator, Universe => BaseUniverse}
+import scala.reflect.runtime.{universe => ru}
+
+// [Eugene++] Before 2.10 is released, I suggest we don't rely on automated type tag generation
+// sure, it's convenient, but then refactoring reflection / reification becomes a pain
+// `ClassTag` tags are fine, because they don't need a reifier to be generated
+
+object StdTags {
+ // root mirror is fine for these guys, since scala-library.jar is guaranteed to be reachable from the root mirror
+ lazy val tagOfString = ru.TypeTag.String
+ lazy val tagOfListOfString = ru.TypeTag[List[String]](
+ ru.rootMirror,
+ new TypeCreator {
+ def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = {
+ val u = m.universe
+ val pre = u.ThisType(m.staticModule("scala.collection.immutable").moduleClass.asInstanceOf[u.Symbol])
+ u.TypeRef(pre, u.definitions.ListClass, List(u.definitions.StringClass.asTypeConstructor))
+ }
+ })
+
+ // root mirror is NOT fine for these guys, hence we use the `currentMirror` trick
+ private val ourClassloader = getClass.getClassLoader
+ private def tagOfStaticClass[T: ClassTag] =
+ ru.TypeTag[T](
+ ru.runtimeMirror(ourClassloader),
+ new TypeCreator {
+ def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type =
+ m.staticClass(classTag[T].runtimeClass.getName).asTypeConstructor.asInstanceOf[U # Type]
+ })
+ lazy val tagOfInt = ru.TypeTag.Int
+ lazy val tagOfFile = tagOfStaticClass[scala.tools.nsc.io.File]
+ lazy val tagOfDirectory = tagOfStaticClass[scala.tools.nsc.io.Directory]
+ lazy val tagOfStdReplVals = tagOfStaticClass[scala.tools.nsc.interpreter.StdReplVals]
+ lazy val tagOfIMain = tagOfStaticClass[scala.tools.nsc.interpreter.IMain]
+ lazy val tagOfThrowable = tagOfStaticClass[java.lang.Throwable]
+ lazy val tagOfClassLoader = tagOfStaticClass[java.lang.ClassLoader]
+}
diff --git a/src/compiler/scala/tools/reflect/ToolBox.scala b/src/compiler/scala/tools/reflect/ToolBox.scala
new file mode 100644
index 0000000000..edd22c60f4
--- /dev/null
+++ b/src/compiler/scala/tools/reflect/ToolBox.scala
@@ -0,0 +1,93 @@
+package scala.tools
+package reflect
+
+import scala.reflect.api.Universe
+import scala.reflect.base.MirrorOf
+
+trait ToolBox[U <: Universe] {
+
+ /** Underlying universe of a ToolBox
+ */
+ val u: U
+
+ /** Underlying mirror of a ToolBox
+ */
+ val mirror: MirrorOf[u.type]
+
+ /** Front end of the toolbox.
+ *
+ * Accumulates and displays warnings and errors, can drop to interactive mode (if supported).
+ * The latter can be useful to study the typechecker or to debug complex macros.
+ */
+ def frontEnd: FrontEnd
+
+ /** Typechecks a tree using this ToolBox.
+ * This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.
+ *
+ * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
+ * then they might, might be partially or might not be specified in the ``freeTypes'' parameter.
+ *
+ * If ``silent'' is false, ``TypeError'' will be thrown in case of a typecheck error.
+ * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * Such errors don't vanish and can be inspected by turning on -Ydebug.
+ *
+ * Typechecking can be steered with the following optional parameters:
+ * ``withImplicitViewsDisabled'' recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
+ * ``withMacrosDisabled'' recursively prohibits macro expansions and macro-based implicits, default value is false
+ */
+ def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
+
+
+ /** Infers an implicit value of the expected type ``pt'' in the macro callsite context.
+ *
+ * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
+ * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
+ * Unlike in ``typeCheck'', ``silent'' is true by default.
+ */
+ def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): u.Tree
+
+ /** Infers an implicit view from the provided tree ``tree'' from the type ``from'' to the type ``to'' in the macro callsite context.
+ *
+ * Otional parameter, ``reportAmbiguous`` controls whether ambiguous implicit errors should be reported.
+ * If we search for a view simply to find out whether one type is coercible to another, it might be desirable to set this flag to ``false''.
+ *
+ * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
+ * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
+ * Unlike in ``typeCheck'', ``silent'' is true by default.
+ */
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): u.Tree
+
+ /** Recursively resets symbols and types in a given tree.
+ *
+ * Note that this does not revert the tree to its pre-typer shape.
+ * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
+ */
+ def resetAllAttrs(tree: u.Tree): u.Tree
+
+ /** Recursively resets locally defined symbols and types in a given tree.
+ *
+ * Note that this does not revert the tree to its pre-typer shape.
+ * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
+ */
+ def resetLocalAttrs(tree: u.Tree): u.Tree
+
+ /** .. */
+ def parseExpr(code: String): u.Tree
+
+ /** Compiles and runs a tree using this ToolBox.
+ *
+ * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
+ * then they all have to be specified in the ``freeTypes'' parameter or an error occurs.
+ *
+ * This spawns the compiler at the Namer phase, and pipelines the tree through that compiler.
+ * Currently ``runExpr'' does not accept trees that already typechecked, because typechecking isn't idempotent.
+ * For more info, take a look at https://issues.scala-lang.org/browse/SI-5464.
+ */
+ def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type]()): Any
+}
+
+/** Represents an error during toolboxing
+ */
+case class ToolBoxError(val message: String, val cause: Throwable = null) extends Throwable(message, cause)
diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index 895c645c83..7cf515425d 100644
--- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -1,5 +1,5 @@
-package scala.reflect
-package runtime
+package scala.tools
+package reflect
import scala.tools.nsc.reporters._
import scala.tools.nsc.ReflectGlobal
@@ -10,29 +10,43 @@ import scala.tools.nsc.io.VirtualDirectory
import scala.tools.nsc.interpreter.AbstractFileClassLoader
import scala.tools.nsc.util.FreshNameCreator
import scala.reflect.internal.Flags
-import scala.tools.nsc.util.{NoSourceFile, NoFile}
+import scala.reflect.internal.util.{BatchSourceFile, NoSourceFile, NoFile}
import java.lang.{Class => jClass}
import scala.compat.Platform.EOL
+import scala.reflect.NameTransformer
+import scala.reflect.api.JavaUniverse
+import scala.reflect.base.MirrorOf
-trait ToolBoxes extends { self: Universe =>
+// [Eugene++ to Martin] by the way, toolboxes are unable to compile anything that involves packages
+// is this intentional?
- def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = "") = new ToolBox(frontEnd, options)
+abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
- class ToolBox(val frontEnd: FrontEnd, val options: String) extends AbsToolBox {
+ val mirror: u.Mirror
+
+ def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = ""): ToolBox[U] =
+ new ToolBoxImpl(frontEnd, options)
+
+ private class ToolBoxImpl(val frontEnd: FrontEnd, val options: String) extends ToolBox[U] { toolBoxSelf =>
+
+ val u: factorySelf.u.type = factorySelf.u
+ val mirror: u.Mirror = factorySelf.mirror
class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter: Reporter)
- extends ReflectGlobal(settings, reporter, ToolBox.this.classLoader) {
+ extends ReflectGlobal(settings, reporter, toolBoxSelf.classLoader) {
import definitions._
private val trace = scala.tools.nsc.util.trace when settings.debug.value
- private final val wrapperMethodName = "wrapper"
-
private var wrapCount = 0
+ private final val wrapperMethodName = "wrapper"
+
private def nextWrapperModuleName() = {
wrapCount += 1
- newTermName("__wrapper$" + wrapCount)
+ // we need to use UUIDs here, because our toolbox might be spawned by another toolbox
+ // that already has, say, __wrapper$1 in its virtual directory, which will shadow our codegen
+ newTermName("__wrapper$" + wrapCount + "$" + java.util.UUID.randomUUID.toString.replace("-", ""))
}
def verifyExpr(expr: Tree): Unit = {
@@ -46,37 +60,34 @@ trait ToolBoxes extends { self: Universe =>
// That's why we cannot allow inputs of toolboxes to be typechecked,
// at least not until the aforementioned issue is closed.
val typed = expr filter (t => t.tpe != null && t.tpe != NoType && !t.isInstanceOf[TypeTree])
- if (!typed.isEmpty) throw new ToolBoxError(ToolBox.this, "reflective toolbox has failed: cannot operate on trees that are already typed")
+ if (!typed.isEmpty) throw ToolBoxError("reflective toolbox has failed: cannot operate on trees that are already typed")
- val freeTypes = this.freeTypes(expr)
+ val freeTypes = expr.freeTypes
if (freeTypes.length > 0) {
var msg = "reflective toolbox has failed:" + EOL
msg += "unresolved free type variables (namely: " + (freeTypes map (ft => "%s %s".format(ft.name, ft.origin)) mkString ", ") + "). "
msg += "have you forgot to use TypeTag annotations for type parameters external to a reifee? "
msg += "if you have troubles tracking free type variables, consider using -Xlog-free-types"
- throw new ToolBoxError(ToolBox.this, msg)
+ throw ToolBoxError(msg)
}
}
- def typeCheckExpr(expr0: Tree, pt: Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
- verifyExpr(expr0)
-
- // need to wrap the expr, because otherwise you won't be able to typecheck macros against something that contains free vars
- // [Eugene] get rid of the copy/paste w.r.t compileExpr
- val freeTerms = this.freeTerms(expr0)
- val freeTermNames = collection.mutable.Map[Symbol, TermName]()
+ def extractFreeTerms(expr0: Tree, wrapFreeTermRefs: Boolean): (Tree, collection.mutable.LinkedHashMap[FreeTermSymbol, TermName]) = {
+ val freeTerms = expr0.freeTerms
+ val freeTermNames = collection.mutable.LinkedHashMap[FreeTermSymbol, TermName]()
freeTerms foreach (ft => {
var name = ft.name.toString
val namesakes = freeTerms takeWhile (_ != ft) filter (ft2 => ft != ft2 && ft.name == ft2.name)
if (namesakes.length > 0) name += ("$" + (namesakes.length + 1))
- freeTermNames += (ft -> newTermName(name + nme.MIRROR_FREE_VALUE_SUFFIX))
+ freeTermNames += (ft -> newTermName(name + nme.REIFY_FREE_VALUE_SUFFIX))
})
var expr = new Transformer {
override def transform(tree: Tree): Tree =
if (tree.hasSymbol && tree.symbol.isFreeTerm) {
tree match {
case Ident(_) =>
- Ident(freeTermNames(tree.symbol))
+ val freeTermRef = Ident(freeTermNames(tree.symbol.asFreeTermSymbol))
+ if (wrapFreeTermRefs) Apply(freeTermRef, List()) else freeTermRef
case _ =>
throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass))
}
@@ -84,14 +95,23 @@ trait ToolBoxes extends { self: Universe =>
super.transform(tree)
}
}.transform(expr0)
- val dummies = freeTerms map (freeTerm => ValDef(NoMods, freeTermNames(freeTerm), TypeTree(freeTerm.info), Select(Ident(PredefModule), newTermName("$qmark$qmark$qmark"))))
+ (expr, freeTermNames)
+ }
+
+ def typeCheckExpr(expr0: Tree, pt: Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree = {
+ verifyExpr(expr0)
+
+ // need to wrap the expr, because otherwise you won't be able to typecheck macros against something that contains free vars
+ var (expr, freeTerms) = extractFreeTerms(expr0, wrapFreeTermRefs = false)
+ val dummies = freeTerms.map{ case (freeTerm, name) => ValDef(NoMods, name, TypeTree(freeTerm.info), Select(Ident(PredefModule), newTermName("$qmark$qmark$qmark"))) }.toList
expr = Block(dummies, expr)
// [Eugene] how can we implement that?
// !!! Why is this is in the empty package? If it's only to make
// it inaccessible then please put it somewhere designed for that
// rather than polluting the empty package with synthetics.
- val ownerClass = EmptyPackageClass.newClassWithInfo(newTypeName("<expression-owner>"), List(ObjectClass.tpe), newScope)
+ val ownerClass = rootMirror.EmptyPackageClass.newClassSymbol(newTypeName("<expression-owner>"))
+ build.setTypeSignature(ownerClass, ClassInfoType(List(ObjectClass.tpe), newScope, ownerClass))
val owner = ownerClass.newLocalDummy(expr.pos)
var currentTyper = typer.atOwner(expr, owner)
val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _)
@@ -107,22 +127,22 @@ trait ToolBoxes extends { self: Universe =>
case analyzer.SilentResultValue(result) =>
trace("success: ")(showAttributed(result, true, true, settings.Yshowsymkinds.value))
var Block(dummies, unwrapped) = result
- var reversedFreeTermNames = freeTermNames map (_.swap)
+ var invertedIndex = freeTerms map (_.swap)
// todo. also fixup singleton types
unwrapped = new Transformer {
override def transform(tree: Tree): Tree =
tree match {
- case Ident(name) if reversedFreeTermNames contains name =>
- Ident(reversedFreeTermNames(name)) setType tree.tpe
+ case Ident(name) if invertedIndex contains name =>
+ Ident(invertedIndex(name)) setType tree.tpe
case _ =>
super.transform(tree)
}
}.transform(unwrapped)
- new TreeTypeSubstituter(dummies map (_.symbol), dummies map (dummy => SingleType(NoPrefix, reversedFreeTermNames(dummy.symbol.name)))).traverse(unwrapped)
+ new TreeTypeSubstituter(dummies map (_.symbol), dummies map (dummy => SingleType(NoPrefix, invertedIndex(dummy.symbol.name)))).traverse(unwrapped)
unwrapped
case error @ analyzer.SilentTypeError(_) =>
trace("failed: ")(error.err.errMsg)
- if (!silent) throw new ToolBoxError(ToolBox.this, "reflective typecheck has failed: %s".format(error.err.errMsg))
+ if (!silent) throw ToolBoxError("reflective typecheck has failed: %s".format(error.err.errMsg))
EmptyTree
})
}
@@ -131,48 +151,32 @@ trait ToolBoxes extends { self: Universe =>
verifyExpr(expr)
def wrapExpr(expr0: Tree): Tree = {
- def defOwner(tree: Tree): Symbol = tree find (_.isDef) map (_.symbol) match {
- case Some(sym) if sym != null && sym != NoSymbol => sym.owner
- case _ => NoSymbol
- }
+ val (expr, freeTerms) = extractFreeTerms(expr0, wrapFreeTermRefs = true)
- val freeTerms = this.freeTerms(expr0)
- val freeTermNames = collection.mutable.Map[Symbol, TermName]()
- freeTerms foreach (ft => {
- var name = ft.name.toString
- val namesakes = freeTerms takeWhile (_ != ft) filter (ft2 => ft != ft2 && ft.name == ft2.name)
- if (namesakes.length > 0) name += ("$" + (namesakes.length + 1))
- freeTermNames += (ft -> newTermName(name + nme.MIRROR_FREE_VALUE_SUFFIX))
- })
- val expr = new Transformer {
- override def transform(tree: Tree): Tree =
- if (tree.hasSymbol && tree.symbol.isFreeTerm) {
- tree match {
- case Ident(_) =>
- Apply(Ident(freeTermNames(tree.symbol)), List())
- case _ =>
- throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass))
- }
- } else {
- super.transform(tree)
- }
- }.transform(expr0)
+ val (obj, mclazz) = rootMirror.EmptyPackageClass.newModuleAndClassSymbol(
+ nextWrapperModuleName())
- val obj = EmptyPackageClass.newModule(nextWrapperModuleName())
val minfo = ClassInfoType(List(ObjectClass.tpe), newScope, obj.moduleClass)
obj.moduleClass setInfo minfo
obj setInfo obj.moduleClass.tpe
+
val meth = obj.moduleClass.newMethod(newTermName(wrapperMethodName))
- def makeParam(fv: Symbol) = {
+ def makeParam(schema: (FreeTermSymbol, TermName)) = {
+ val (fv, name) = schema
// [Eugene] conventional way of doing this?
val underlying = fv.tpe.resultType
val tpe = appliedType(definitions.FunctionClass(0).tpe, List(underlying))
- meth.newValueParameter(freeTermNames(fv)) setInfo tpe
+ meth.newValueParameter(name) setInfo tpe
}
- meth setInfo MethodType(freeTerms map makeParam, AnyClass.tpe)
+ meth setInfo MethodType(freeTerms.map(makeParam).toList, AnyClass.tpe)
minfo.decls enter meth
+ def defOwner(tree: Tree): Symbol = tree find (_.isDef) map (_.symbol) match {
+ case Some(sym) if sym != null && sym != NoSymbol => sym.owner
+ case _ => NoSymbol
+ }
trace("wrapping ")(defOwner(expr) -> meth)
val methdef = DefDef(meth, expr changeOwner (defOwner(expr) -> meth))
+
val moduledef = ModuleDef(
obj,
Template(
@@ -184,6 +188,7 @@ trait ToolBoxes extends { self: Universe =>
List(methdef),
NoPosition))
trace("wrapped: ")(showAttributed(moduledef, true, true, settings.Yshowsymkinds.value))
+
var cleanedUp = resetLocalAttrs(moduledef)
trace("cleaned up: ")(showAttributed(cleanedUp, true, true, settings.Yshowsymkinds.value))
cleanedUp
@@ -210,7 +215,7 @@ trait ToolBoxes extends { self: Universe =>
}
def runExpr(expr: Tree, freeTypes: Map[TypeName, Type] = Map[TypeName, Type]()): Any = {
- val freeTerms = this.freeTerms(expr) // need to calculate them here, because later on they will be erased
+ val freeTerms = expr.freeTerms // need to calculate them here, because later on they will be erased
val thunks = freeTerms map (fte => () => fte.value) // need to be lazy in order not to distort evaluation order
// @odersky writes: Not sure we will be able to drop this. I forgot the reason why we dereference () functions,
@@ -218,14 +223,33 @@ trait ToolBoxes extends { self: Universe =>
// @Eugene writes: this dates back to the days when one could only reify functions
// hence, blocks were translated into nullary functions, so
// presumably, it was useful to immediately evaluate them to get the result of a block
-// val result = jmeth.invoke(singleton, freeTerms map (sym => sym.asInstanceOf[FreeTermVar].value.asInstanceOf[AnyRef]): _*)
-// if (etpe.typeSymbol != FunctionClass(0)) result
-// else {
-// val applyMeth = result.getClass.getMethod("apply")
-// applyMeth.invoke(result)
-// }
+ // @Eugene writes: anyways, I'll stash the old sources here in comments in case anyone wants to revive them
+ // val result = jmeth.invoke(singleton, freeTerms map (sym => sym.asInstanceOf[FreeTermVar].value.asInstanceOf[AnyRef]): _*)
+ // if (etpe.typeSymbol != FunctionClass(0)) result
+ // else {
+ // val applyMeth = result.getClass.getMethod("apply")
+ // applyMeth.invoke(result)
+ // }
val (singleton, jmeth) = compileExpr(expr)
- jmeth.invoke(singleton, thunks map (_.asInstanceOf[AnyRef]): _*)
+ val result = jmeth.invoke(singleton, thunks map (_.asInstanceOf[AnyRef]): _*)
+ result
+ }
+
+ def parseExpr(code: String): Tree = {
+ val run = new Run
+ reporter.reset()
+ val wrappedCode = "object wrapper {" + EOL + code + EOL + "}"
+ val file = new BatchSourceFile("<toolbox>", wrappedCode)
+ val unit = new CompilationUnit(file)
+ phase = run.parserPhase
+ val parser = new syntaxAnalyzer.UnitParser(unit)
+ val wrappedTree = parser.parse()
+ throwIfErrors()
+ val PackageDef(_, List(ModuleDef(_, _, Template(_, _, _ :: parsed)))) = wrappedTree
+ parsed match {
+ case expr :: Nil => expr
+ case stats :+ expr => Block(stats, expr)
+ }
}
def showAttributed(tree: Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String = {
@@ -249,7 +273,7 @@ trait ToolBoxes extends { self: Universe =>
if (frontEnd.hasErrors) {
var msg = "reflective compilation has failed: " + EOL + EOL
msg += frontEnd.infos map (_.msg) mkString EOL
- throw new ToolBoxError(ToolBox.this, msg)
+ throw ToolBoxError(msg)
}
}
}
@@ -258,94 +282,93 @@ trait ToolBoxes extends { self: Universe =>
lazy val arguments = options.split(" ")
lazy val virtualDirectory =
- (arguments zip arguments.tail) collect { case ("-d", dir) => dir } lastOption match {
+ (arguments zip arguments.tail).collect{ case ("-d", dir) => dir }.lastOption match {
case Some(outDir) => scala.tools.nsc.io.AbstractFile.getDirectory(outDir)
case None => new VirtualDirectory("(memory)", None)
}
lazy val compiler: ToolBoxGlobal = {
try {
- val errorFn: String => Unit = msg => frontEnd.log(NoPosition, msg, frontEnd.ERROR)
+ val errorFn: String => Unit = msg => frontEnd.log(scala.reflect.internal.util.NoPosition, msg, frontEnd.ERROR)
val command = new CompilerCommand(arguments.toList, errorFn)
command.settings.outputDirs setSingleOutput virtualDirectory
val instance = new ToolBoxGlobal(command.settings, new FrontEndToReporterProxy(frontEnd) { val settings = command.settings })
if (frontEnd.hasErrors) {
var msg = "reflective compilation has failed: cannot initialize the compiler: " + EOL + EOL
msg += frontEnd.infos map (_.msg) mkString EOL
- throw new ToolBoxError(this, msg)
+ throw ToolBoxError(msg)
}
- instance.phase = (new instance.Run).typerPhase // need to manually set a phase, because otherwise TypeHistory will crash
instance
} catch {
case ex: Throwable =>
var msg = "reflective compilation has failed: cannot initialize the compiler due to %s".format(ex.toString)
- throw new ToolBoxError(this, msg, ex)
+ throw ToolBoxError(msg, ex)
}
}
- // @Eugene: how do I make this work without casts?
- // lazy val importer = compiler.mkImporter(self)
- lazy val importer = compiler.mkImporter(self).asInstanceOf[compiler.Importer { val from: self.type }]
-
+ lazy val importer = compiler.mkImporter(u)
lazy val exporter = importer.reverse
+ lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, mirror.classLoader)
- lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, self.classLoader)
-
- def typeCheck(tree: Tree, expectedType: Type = WildcardType, freeTypes: Map[FreeType, Type] = Map[FreeType, Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
+ def typeCheck(tree: u.Tree, expectedType: u.Type, freeTypes: Map[u.FreeTypeSymbol, u.Type], silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): u.Tree = {
if (compiler.settings.verbose.value) println("typing "+tree+", expectedType = "+expectedType+", freeTypes = "+freeTypes)
var ctree: compiler.Tree = importer.importTree(tree)
var cexpectedType: compiler.Type = importer.importType(expectedType)
if (compiler.settings.verbose.value) println("substituting "+ctree+", expectedType = "+expectedType)
- val cfreeTypes: Map[compiler.FreeType, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeType], importer.importType(v)) }
- ctree = compiler.substituteFreeTypes(ctree, cfreeTypes)
- cexpectedType = compiler.substituteFreeTypes(cexpectedType, cfreeTypes)
+ val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
+ ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
+ cexpectedType = cexpectedType.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
if (compiler.settings.verbose.value) println("typing "+ctree+", expectedType = "+expectedType)
val ttree: compiler.Tree = compiler.typeCheckExpr(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)
- val rmttree = exporter.importTree(ttree)
- rmttree
+ val uttree = exporter.importTree(ttree)
+ uttree
}
- def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): Tree =
+ def inferImplicitValue(pt: u.Type, silent: Boolean, withMacrosDisabled: Boolean): u.Tree =
// todo. implement this
???
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): Tree =
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean, withMacrosDisabled: Boolean, reportAmbiguous: Boolean): u.Tree =
// todo. implement this
???
- def resetAllAttrs(tree: Tree): Tree = {
+ def resetAllAttrs(tree: u.Tree): u.Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
val ttree: compiler.Tree = compiler.resetAllAttrs(ctree)
- exporter.importTree(ttree)
+ val uttree = exporter.importTree(ttree)
+ uttree
}
- def resetLocalAttrs(tree: Tree): Tree = {
+ def resetLocalAttrs(tree: u.Tree): u.Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
val ttree: compiler.Tree = compiler.resetLocalAttrs(ctree)
- exporter.importTree(ttree)
+ val uttree = exporter.importTree(ttree)
+ uttree
}
- def showAttributed(tree: Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String =
+ def showAttributed(tree: u.Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String =
compiler.showAttributed(importer.importTree(tree), printTypes, printIds, printKinds)
- def runExpr(tree: Tree, freeTypes: Map[FreeType, Type] = Map[FreeType, Type]()): Any = {
+ def parseExpr(code: String): u.Tree = {
+ if (compiler.settings.verbose.value) println("parsing "+code)
+ val ctree: compiler.Tree = compiler.parseExpr(code)
+ val utree = exporter.importTree(ctree)
+ utree
+ }
+
+ def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type]): Any = {
if (compiler.settings.verbose.value) println("running "+tree+", freeTypes = "+freeTypes)
var ctree: compiler.Tree = importer.importTree(tree)
if (compiler.settings.verbose.value) println("substituting "+ctree)
- val cfreeTypes: Map[compiler.FreeType, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeType], importer.importType(v)) }
- ctree = compiler.substituteFreeTypes(ctree, cfreeTypes)
+ val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
+ ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
if (compiler.settings.verbose.value) println("running "+ctree)
compiler.runExpr(ctree)
}
-
- class ToolBoxError(val toolBox: ToolBox, val message: String, val cause: Throwable = null) extends Throwable(message, cause)
-
- object ToolBoxError extends ToolBoxErrorExtractor {
- def unapply(error: ToolBoxError): Option[(ToolBox, String)] = Some((error.toolBox, error.message))
- }
}
}
+
diff --git a/src/compiler/scala/tools/reflect/WrappedProperties.scala b/src/compiler/scala/tools/reflect/WrappedProperties.scala
index 2ca374cf01..45c1b57d71 100644
--- a/src/compiler/scala/tools/reflect/WrappedProperties.scala
+++ b/src/compiler/scala/tools/reflect/WrappedProperties.scala
@@ -21,8 +21,8 @@ trait WrappedProperties extends PropertiesTrait {
override def propIsSet(name: String) = wrap(super.propIsSet(name)) exists (x => x)
override def propOrElse(name: String, alt: String) = wrap(super.propOrElse(name, alt)) getOrElse alt
- override def setProp(name: String, value: String) = wrap(super.setProp(name, value)) orNull
- override def clearProp(name: String) = wrap(super.clearProp(name)) orNull
+ override def setProp(name: String, value: String) = wrap(super.setProp(name, value)).orNull
+ override def clearProp(name: String) = wrap(super.clearProp(name)).orNull
override def envOrElse(name: String, alt: String) = wrap(super.envOrElse(name, alt)) getOrElse alt
override def envOrNone(name: String) = wrap(super.envOrNone(name)).flatten
diff --git a/src/compiler/scala/tools/reflect/package.scala b/src/compiler/scala/tools/reflect/package.scala
new file mode 100644
index 0000000000..a3778a3b69
--- /dev/null
+++ b/src/compiler/scala/tools/reflect/package.scala
@@ -0,0 +1,33 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala.tools
+
+import scala.reflect.api.JavaUniverse
+import language.implicitConversions
+
+package object reflect extends FrontEnds {
+ // [todo: can we generalize this?
+ import scala.reflect.runtime.{universe => ru}
+ implicit def ToolBox(mirror0: ru.Mirror): ToolBoxFactory[ru.type] =
+ new ToolBoxFactory[ru.type](mirror0.universe) {
+ lazy val mirror = mirror0
+ }
+
+ // todo. replace this with an implicit class, once the pesky warning is gone
+ implicit def Eval[T](expr: JavaUniverse # Expr[T]): Eval[T] = new Eval[T](expr)
+
+ // we don't provide `Eval` for trees, because it's unclear where to get an evaluation mirror from
+}
+
+package reflect {
+ class Eval[T](expr: JavaUniverse # Expr[T]) {
+ def eval: T = {
+ val factory = new ToolBoxFactory[JavaUniverse](expr.mirror.universe) { val mirror = expr.mirror.asInstanceOf[this.u.Mirror] }
+ val toolBox = factory.mkToolBox()
+ toolBox.runExpr(expr.tree.asInstanceOf[toolBox.u.Tree]).asInstanceOf[T]
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/util/Javap.scala b/src/compiler/scala/tools/util/Javap.scala
index 42d8a910f0..f4f218350a 100644
--- a/src/compiler/scala/tools/util/Javap.scala
+++ b/src/compiler/scala/tools/util/Javap.scala
@@ -12,6 +12,7 @@ import scala.tools.nsc.util.ScalaClassLoader
import java.io.{ InputStream, PrintWriter, ByteArrayInputStream, FileNotFoundException }
import scala.tools.nsc.io.File
import Javap._
+import language.reflectiveCalls
trait Javap {
def loader: ScalaClassLoader
diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala
index 788891a062..5f4e6d58c3 100644
--- a/src/compiler/scala/tools/util/PathResolver.scala
+++ b/src/compiler/scala/tools/util/PathResolver.scala
@@ -13,6 +13,7 @@ import nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader }
import nsc.io.{ File, Directory, Path, AbstractFile }
import ClassPath.{ JavaContext, DefaultJavaContext, join, split }
import PartialFunction.condOpt
+import language.postfixOps
// Loosely based on the draft specification at:
// https://wiki.scala-lang.org/display/SW/Classpath
@@ -192,7 +193,15 @@ class PathResolver(settings: Settings, context: JavaContext) {
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
- def sourcePath = cmdLineOrElse("sourcepath", Defaults.scalaSourcePath)
+ /** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
+ * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/makro/Reifiers.scala:89: error: object api is not a member of package reflect
+ * [scaladoc] case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
+ * [scaladoc] ^
+ * because the bootstrapping will look at the sourcepath and create package "reflect" in "<root>"
+ * and then when typing relative names, instead of picking <root>.scala.relect, typedIdentifier will pick up the
+ * <root>.reflect package created by the bootstrapping. Thus, no bootstrapping for scaladoc!
+ * TODO: we should refactor this as a separate -bootstrap option to have a clean implementation, no? */
+ def sourcePath = if (!settings.isScaladoc) cmdLineOrElse("sourcepath", Defaults.scalaSourcePath) else ""
/** Against my better judgment, giving in to martin here and allowing
* CLASSPATH to be used automatically. So for the user-specified part
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
index 6f5284f75f..3a1dc87a6a 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
@@ -29,14 +29,14 @@ trait CPSUtils {
val shiftUnitR = newTermName("shiftUnitR")
}
- lazy val MarkerCPSSym = definitions.getRequiredClass("scala.util.continuations.cpsSym")
- lazy val MarkerCPSTypes = definitions.getRequiredClass("scala.util.continuations.cpsParam")
- lazy val MarkerCPSSynth = definitions.getRequiredClass("scala.util.continuations.cpsSynth")
- lazy val MarkerCPSAdaptPlus = definitions.getRequiredClass("scala.util.continuations.cpsPlus")
- lazy val MarkerCPSAdaptMinus = definitions.getRequiredClass("scala.util.continuations.cpsMinus")
-
- lazy val Context = definitions.getRequiredClass("scala.util.continuations.ControlContext")
- lazy val ModCPS = definitions.getRequiredModule("scala.util.continuations")
+ lazy val MarkerCPSSym = rootMirror.getRequiredClass("scala.util.continuations.cpsSym")
+ lazy val MarkerCPSTypes = rootMirror.getRequiredClass("scala.util.continuations.cpsParam")
+ lazy val MarkerCPSSynth = rootMirror.getRequiredClass("scala.util.continuations.cpsSynth")
+ lazy val MarkerCPSAdaptPlus = rootMirror.getRequiredClass("scala.util.continuations.cpsPlus")
+ lazy val MarkerCPSAdaptMinus = rootMirror.getRequiredClass("scala.util.continuations.cpsMinus")
+
+ lazy val Context = rootMirror.getRequiredClass("scala.util.continuations.ControlContext")
+ lazy val ModCPS = rootMirror.getRequiredModule("scala.util.continuations")
lazy val MethShiftUnit = definitions.getMember(ModCPS, cpsNames.shiftUnit)
lazy val MethShiftUnit0 = definitions.getMember(ModCPS, cpsNames.shiftUnit0)
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
index dcb7cd601f..54a0079f40 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
@@ -347,7 +347,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with
// val <lhs> = ctx.getTrivialValue; ... <--- TODO: try/catch ??? don't bother for the moment...
// else
// ctx.flatMap { <lhs> => ... }
- val ctxSym = currentOwner.newValue(vd.symbol.name append cpsNames.shiftSuffix).setInfo(rhs1.tpe)
+ val ctxSym = currentOwner.newValue(newTermName("" + vd.symbol.name + cpsNames.shiftSuffix)).setInfo(rhs1.tpe)
val ctxDef = localTyper.typed(ValDef(ctxSym, rhs1))
def ctxRef = localTyper.typed(Ident(ctxSym))
val argSym = currentOwner.newValue(vd.symbol.name).setInfo(tpe)
diff --git a/src/forkjoin/scala/concurrent/forkjoin/ForkJoinPool.java b/src/forkjoin/scala/concurrent/forkjoin/ForkJoinPool.java
index 4b5b3382f5..65654be69b 100644
--- a/src/forkjoin/scala/concurrent/forkjoin/ForkJoinPool.java
+++ b/src/forkjoin/scala/concurrent/forkjoin/ForkJoinPool.java
@@ -2864,24 +2864,7 @@ public class ForkJoinPool extends AbstractExecutorService {
* @return a sun.misc.Unsafe
*/
private static sun.misc.Unsafe getUnsafe() {
- try {
- return sun.misc.Unsafe.getUnsafe();
- } catch (SecurityException se) {
- try {
- return java.security.AccessController.doPrivileged
- (new java.security
- .PrivilegedExceptionAction<sun.misc.Unsafe>() {
- public sun.misc.Unsafe run() throws Exception {
- java.lang.reflect.Field f = sun.misc
- .Unsafe.class.getDeclaredField("theUnsafe");
- f.setAccessible(true);
- return (sun.misc.Unsafe) f.get(null);
- }});
- } catch (java.security.PrivilegedActionException e) {
- throw new RuntimeException("Could not initialize intrinsics",
- e.getCause());
- }
- }
+ return scala.concurrent.util.Unsafe.instance;
}
}
diff --git a/src/forkjoin/scala/concurrent/forkjoin/ForkJoinTask.java b/src/forkjoin/scala/concurrent/forkjoin/ForkJoinTask.java
index 2ba146c4da..15c60118b3 100644
--- a/src/forkjoin/scala/concurrent/forkjoin/ForkJoinTask.java
+++ b/src/forkjoin/scala/concurrent/forkjoin/ForkJoinTask.java
@@ -1537,23 +1537,6 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* @return a sun.misc.Unsafe
*/
private static sun.misc.Unsafe getUnsafe() {
- try {
- return sun.misc.Unsafe.getUnsafe();
- } catch (SecurityException se) {
- try {
- return java.security.AccessController.doPrivileged
- (new java.security
- .PrivilegedExceptionAction<sun.misc.Unsafe>() {
- public sun.misc.Unsafe run() throws Exception {
- java.lang.reflect.Field f = sun.misc
- .Unsafe.class.getDeclaredField("theUnsafe");
- f.setAccessible(true);
- return (sun.misc.Unsafe) f.get(null);
- }});
- } catch (java.security.PrivilegedActionException e) {
- throw new RuntimeException("Could not initialize intrinsics",
- e.getCause());
- }
- }
+ return scala.concurrent.util.Unsafe.instance;
}
}
diff --git a/src/forkjoin/scala/concurrent/forkjoin/LinkedTransferQueue.java b/src/forkjoin/scala/concurrent/forkjoin/LinkedTransferQueue.java
index ceeb9212d5..07e81b395d 100644
--- a/src/forkjoin/scala/concurrent/forkjoin/LinkedTransferQueue.java
+++ b/src/forkjoin/scala/concurrent/forkjoin/LinkedTransferQueue.java
@@ -1329,24 +1329,7 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
* @return a sun.misc.Unsafe
*/
static sun.misc.Unsafe getUnsafe() {
- try {
- return sun.misc.Unsafe.getUnsafe();
- } catch (SecurityException se) {
- try {
- return java.security.AccessController.doPrivileged
- (new java.security
- .PrivilegedExceptionAction<sun.misc.Unsafe>() {
- public sun.misc.Unsafe run() throws Exception {
- java.lang.reflect.Field f = sun.misc
- .Unsafe.class.getDeclaredField("theUnsafe");
- f.setAccessible(true);
- return (sun.misc.Unsafe) f.get(null);
- }});
- } catch (java.security.PrivilegedActionException e) {
- throw new RuntimeException("Could not initialize intrinsics",
- e.getCause());
- }
- }
+ return scala.concurrent.util.Unsafe.instance;
}
}
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index 393f0899f4..d637527b30 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -26,7 +26,5 @@ package scala
* The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
*/
abstract class AnyVal extends Any with NotNull {
- // disabled for now to make the standard build go through.
- // Once we have a new strap we can uncomment this and delete the AnyVal_getClass entry in Definitions.
- def getClass(): Class[_ <: AnyVal] = ???
+ def getClass(): Class[_ <: AnyVal] = null
}
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index e7cf399fa4..6784b630c7 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -12,7 +12,7 @@ import scala.collection.generic._
import scala.collection.{ mutable, immutable }
import mutable.{ ArrayBuilder, ArraySeq }
import compat.Platform.arraycopy
-import scala.reflect.ArrayTag
+import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime.{ array_apply, array_update }
/** Contains a fallback builder for arrays when the element type
@@ -48,7 +48,7 @@ class FallbackArrayBuilding {
* @version 1.0
*/
object Array extends FallbackArrayBuilding {
- implicit def canBuildFrom[T](implicit t: ArrayTag[T]): CanBuildFrom[Array[_], T, Array[T]] =
+ implicit def canBuildFrom[T](implicit t: ClassTag[T]): CanBuildFrom[Array[_], T, Array[T]] =
new CanBuildFrom[Array[_], T, Array[T]] {
def apply(from: Array[_]) = ArrayBuilder.make[T]()(t)
def apply() = ArrayBuilder.make[T]()(t)
@@ -57,7 +57,7 @@ object Array extends FallbackArrayBuilding {
/**
* Returns a new [[scala.collection.mutable.ArrayBuilder]].
*/
- def newBuilder[T](implicit t: ArrayTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T]()(t)
+ def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T]()(t)
private def slowcopy(src : AnyRef,
srcPos : Int,
@@ -98,14 +98,14 @@ object Array extends FallbackArrayBuilding {
}
/** Returns an array of length 0 */
- def empty[T: ArrayTag]: Array[T] = new Array[T](0)
+ def empty[T: ClassTag]: Array[T] = new Array[T](0)
/** Creates an array with given elements.
*
* @param xs the elements to put in the array
* @return an array containing all elements from xs.
*/
- def apply[T: ArrayTag](xs: T*): Array[T] = {
+ def apply[T: ClassTag](xs: T*): Array[T] = {
val array = new Array[T](xs.length)
var i = 0
for (x <- xs.iterator) { array(i) = x; i += 1 }
@@ -194,23 +194,23 @@ object Array extends FallbackArrayBuilding {
}
/** Creates array with given dimensions */
- def ofDim[T: ArrayTag](n1: Int): Array[T] =
+ def ofDim[T: ClassTag](n1: Int): Array[T] =
new Array[T](n1)
/** Creates a 2-dimensional array */
- def ofDim[T: ArrayTag](n1: Int, n2: Int): Array[Array[T]] = {
+ def ofDim[T: ClassTag](n1: Int, n2: Int): Array[Array[T]] = {
val arr: Array[Array[T]] = (new Array[Array[T]](n1): Array[Array[T]])
for (i <- 0 until n1) arr(i) = new Array[T](n2)
arr
// tabulate(n1)(_ => ofDim[T](n2))
}
/** Creates a 3-dimensional array */
- def ofDim[T: ArrayTag](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
+ def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
tabulate(n1)(_ => ofDim[T](n2, n3))
/** Creates a 4-dimensional array */
- def ofDim[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
+ def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
tabulate(n1)(_ => ofDim[T](n2, n3, n4))
/** Creates a 5-dimensional array */
- def ofDim[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
+ def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
tabulate(n1)(_ => ofDim[T](n2, n3, n4, n5))
/** Concatenates all arrays into a single array.
@@ -218,7 +218,7 @@ object Array extends FallbackArrayBuilding {
* @param xss the given arrays
* @return the array created from concatenating `xss`
*/
- def concat[T: ArrayTag](xss: Array[T]*): Array[T] = {
+ def concat[T: ClassTag](xss: Array[T]*): Array[T] = {
val b = newBuilder[T]
b.sizeHint(xss.map(_.size).sum)
for (xs <- xss) b ++= xs
@@ -239,7 +239,7 @@ object Array extends FallbackArrayBuilding {
* @return an Array of size n, where each element contains the result of computing
* `elem`.
*/
- def fill[T: ArrayTag](n: Int)(elem: => T): Array[T] = {
+ def fill[T: ClassTag](n: Int)(elem: => T): Array[T] = {
val b = newBuilder[T]
b.sizeHint(n)
var i = 0
@@ -257,7 +257,7 @@ object Array extends FallbackArrayBuilding {
* @param n2 the number of elements in the 2nd dimension
* @param elem the element computation
*/
- def fill[T: ArrayTag](n1: Int, n2: Int)(elem: => T): Array[Array[T]] =
+ def fill[T: ClassTag](n1: Int, n2: Int)(elem: => T): Array[Array[T]] =
tabulate(n1)(_ => fill(n2)(elem))
/** Returns a three-dimensional array that contains the results of some element
@@ -268,7 +268,7 @@ object Array extends FallbackArrayBuilding {
* @param n3 the number of elements in the 3nd dimension
* @param elem the element computation
*/
- def fill[T: ArrayTag](n1: Int, n2: Int, n3: Int)(elem: => T): Array[Array[Array[T]]] =
+ def fill[T: ClassTag](n1: Int, n2: Int, n3: Int)(elem: => T): Array[Array[Array[T]]] =
tabulate(n1)(_ => fill(n2, n3)(elem))
/** Returns a four-dimensional array that contains the results of some element
@@ -280,7 +280,7 @@ object Array extends FallbackArrayBuilding {
* @param n4 the number of elements in the 4th dimension
* @param elem the element computation
*/
- def fill[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => T): Array[Array[Array[Array[T]]]] =
+ def fill[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => T): Array[Array[Array[Array[T]]]] =
tabulate(n1)(_ => fill(n2, n3, n4)(elem))
/** Returns a five-dimensional array that contains the results of some element
@@ -293,7 +293,7 @@ object Array extends FallbackArrayBuilding {
* @param n5 the number of elements in the 5th dimension
* @param elem the element computation
*/
- def fill[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => T): Array[Array[Array[Array[Array[T]]]]] =
+ def fill[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => T): Array[Array[Array[Array[Array[T]]]]] =
tabulate(n1)(_ => fill(n2, n3, n4, n5)(elem))
/** Returns an array containing values of a given function over a range of integer
@@ -303,7 +303,7 @@ object Array extends FallbackArrayBuilding {
* @param f The function computing element values
* @return A traversable consisting of elements `f(0),f(1), ..., f(n - 1)`
*/
- def tabulate[T: ArrayTag](n: Int)(f: Int => T): Array[T] = {
+ def tabulate[T: ClassTag](n: Int)(f: Int => T): Array[T] = {
val b = newBuilder[T]
b.sizeHint(n)
var i = 0
@@ -321,7 +321,7 @@ object Array extends FallbackArrayBuilding {
* @param n2 the number of elements in the 2nd dimension
* @param f The function computing element values
*/
- def tabulate[T: ArrayTag](n1: Int, n2: Int)(f: (Int, Int) => T): Array[Array[T]] =
+ def tabulate[T: ClassTag](n1: Int, n2: Int)(f: (Int, Int) => T): Array[Array[T]] =
tabulate(n1)(i1 => tabulate(n2)(f(i1, _)))
/** Returns a three-dimensional array containing values of a given function
@@ -332,7 +332,7 @@ object Array extends FallbackArrayBuilding {
* @param n3 the number of elements in the 3rd dimension
* @param f The function computing element values
*/
- def tabulate[T: ArrayTag](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => T): Array[Array[Array[T]]] =
+ def tabulate[T: ClassTag](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => T): Array[Array[Array[T]]] =
tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _)))
/** Returns a four-dimensional array containing values of a given function
@@ -344,7 +344,7 @@ object Array extends FallbackArrayBuilding {
* @param n4 the number of elements in the 4th dimension
* @param f The function computing element values
*/
- def tabulate[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => T): Array[Array[Array[Array[T]]]] =
+ def tabulate[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => T): Array[Array[Array[Array[T]]]] =
tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _)))
/** Returns a five-dimensional array containing values of a given function
@@ -357,7 +357,7 @@ object Array extends FallbackArrayBuilding {
* @param n5 the number of elements in the 5th dimension
* @param f The function computing element values
*/
- def tabulate[T: ArrayTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => T): Array[Array[Array[Array[Array[T]]]]] =
+ def tabulate[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => T): Array[Array[Array[Array[Array[T]]]]] =
tabulate(n1)(i1 => tabulate(n2, n3, n4, n5)(f(i1, _, _, _, _)))
/** Returns an array containing a sequence of increasing integers in a range.
@@ -396,7 +396,7 @@ object Array extends FallbackArrayBuilding {
* @param f the function that is repeatedly applied
* @return the array returning `len` values in the sequence `start, f(start), f(f(start)), ...`
*/
- def iterate[T: ArrayTag](start: T, len: Int)(f: T => T): Array[T] = {
+ def iterate[T: ClassTag](start: T, len: Int)(f: T => T): Array[T] = {
val b = newBuilder[T]
if (len > 0) {
@@ -475,7 +475,7 @@ object Array extends FallbackArrayBuilding {
* @define collectExample
* @define undefinedorder
* @define thatinfo the class of the returned collection. In the standard library configuration,
- * `That` is either `Array[B]` if an ArrayTag is available for B or `ArraySeq[B]` otherwise.
+ * `That` is either `Array[B]` if an ClassTag is available for B or `ArraySeq[B]` otherwise.
* @define zipthatinfo $thatinfo
* @define bfinfo an implicit value of class `CanBuildFrom` which determines the result class `That` from the current
* representation type `Repr` and the new element type `B`.
diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala
index edb82b33fe..014928d986 100644
--- a/src/library/scala/Boolean.scala
+++ b/src/library/scala/Boolean.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Boolean` (equivalent to Java's `boolean` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Boolean` are not
* represented by an object in the underlying runtime system.
@@ -17,7 +19,7 @@ package scala
* There is an implicit conversion from [[scala.Boolean]] => [[scala.runtime.RichBoolean]]
* which provides useful non-primitive operations.
*/
-final class Boolean private extends AnyVal {
+final abstract class Boolean private extends AnyVal {
/**
* Negates a Boolean expression.
*
@@ -26,7 +28,7 @@ final class Boolean private extends AnyVal {
*
* @return the negated expression
*/
- def unary_! : Boolean = sys.error("stub")
+ def unary_! : Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to the same value.
@@ -35,7 +37,7 @@ final class Boolean private extends AnyVal {
* - `a` and `b` are `true` or
* - `a` and `b` are `false`.
*/
- def ==(x: Boolean): Boolean = sys.error("stub")
+ def ==(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to a different value.
@@ -44,7 +46,7 @@ final class Boolean private extends AnyVal {
* - `a` is `true` and `b` is `false` or
* - `a` is `false` and `b` is `true`.
*/
- def !=(x: Boolean): Boolean = sys.error("stub")
+ def !=(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
@@ -58,7 +60,7 @@ final class Boolean private extends AnyVal {
* behaves as if it was declared as `def ||(x: => Boolean): Boolean`.
* If `a` evaluates to `true`, `true` is returned without evaluating `b`.
*/
- def ||(x: Boolean): Boolean = sys.error("stub")
+ def ||(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
@@ -70,11 +72,11 @@ final class Boolean private extends AnyVal {
* behaves as if it was declared as `def &&(x: => Boolean): Boolean`.
* If `a` evaluates to `false`, `false` is returned without evaluating `b`.
*/
- def &&(x: Boolean): Boolean = sys.error("stub")
+ def &&(x: Boolean): Boolean
// Compiler won't build with these seemingly more accurate signatures
- // def ||(x: => Boolean): Boolean = sys.error("stub")
- // def &&(x: => Boolean): Boolean = sys.error("stub")
+ // def ||(x: => Boolean): Boolean
+ // def &&(x: => Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
@@ -86,7 +88,7 @@ final class Boolean private extends AnyVal {
*
* @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`.
*/
- def |(x: Boolean): Boolean = sys.error("stub")
+ def |(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
@@ -96,7 +98,7 @@ final class Boolean private extends AnyVal {
*
* @note This method evaluates both `a` and `b`, even if the result is already determined after evaluating `a`.
*/
- def &(x: Boolean): Boolean = sys.error("stub")
+ def &(x: Boolean): Boolean
/**
* Compares two Boolean expressions and returns `true` if they evaluate to a different value.
@@ -105,12 +107,12 @@ final class Boolean private extends AnyVal {
* - `a` is `true` and `b` is `false` or
* - `a` is `false` and `b` is `true`.
*/
- def ^(x: Boolean): Boolean = sys.error("stub")
+ def ^(x: Boolean): Boolean
- override def getClass(): Class[Boolean] = sys.error("stub")
+ override def getClass(): Class[Boolean] = null
}
-object Boolean extends AnyValCompanion {
+object Boolean extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
@@ -132,5 +134,6 @@ object Boolean extends AnyValCompanion {
/** The String representation of the scala.Boolean companion object.
*/
override def toString = "object scala.Boolean"
+
}
diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala
index b5b3d88e3f..6f54f6cedf 100644
--- a/src/library/scala/Byte.scala
+++ b/src/library/scala/Byte.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Byte`, a 8-bit signed integer (equivalent to Java's `byte` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Byte` are not
* represented by an object in the underlying runtime system.
@@ -17,14 +19,14 @@ package scala
* There is an implicit conversion from [[scala.Byte]] => [[scala.runtime.RichByte]]
* which provides useful non-primitive operations.
*/
-final class Byte private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Byte private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns the bitwise negation of this value.
@@ -34,30 +36,30 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def unary_~ : Int = sys.error("stub")
+ def unary_~ : Int
/**
* Returns this value, unmodified.
*/
- def unary_+ : Int = sys.error("stub")
+ def unary_+ : Int
/**
* Returns the negation of this value.
*/
- def unary_- : Int = sys.error("stub")
+ def unary_- : Int
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Int): Int = sys.error("stub")
+ def <<(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Long): Int = sys.error("stub")
+ def <<(x: Long): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -68,7 +70,7 @@ final class Byte private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Int): Int = sys.error("stub")
+ def >>>(x: Int): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -79,7 +81,7 @@ final class Byte private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Long): Int = sys.error("stub")
+ def >>>(x: Long): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -90,7 +92,7 @@ final class Byte private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Int): Int = sys.error("stub")
+ def >>(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -101,181 +103,181 @@ final class Byte private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Long): Int = sys.error("stub")
+ def >>(x: Long): Int
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the bitwise OR of this value and `x`.
@@ -287,7 +289,7 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Byte): Int = sys.error("stub")
+ def |(x: Byte): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -298,7 +300,7 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Short): Int = sys.error("stub")
+ def |(x: Short): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -309,7 +311,7 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Char): Int = sys.error("stub")
+ def |(x: Char): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -320,7 +322,7 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Int): Int = sys.error("stub")
+ def |(x: Int): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -331,7 +333,7 @@ final class Byte private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Long): Long = sys.error("stub")
+ def |(x: Long): Long
/**
* Returns the bitwise AND of this value and `x`.
@@ -343,7 +345,7 @@ final class Byte private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Byte): Int = sys.error("stub")
+ def &(x: Byte): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -354,7 +356,7 @@ final class Byte private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Short): Int = sys.error("stub")
+ def &(x: Short): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -365,7 +367,7 @@ final class Byte private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Char): Int = sys.error("stub")
+ def &(x: Char): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -376,7 +378,7 @@ final class Byte private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Int): Int = sys.error("stub")
+ def &(x: Int): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -387,7 +389,7 @@ final class Byte private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Long): Long = sys.error("stub")
+ def &(x: Long): Long
/**
* Returns the bitwise XOR of this value and `x`.
@@ -399,7 +401,7 @@ final class Byte private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Byte): Int = sys.error("stub")
+ def ^(x: Byte): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -410,7 +412,7 @@ final class Byte private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Short): Int = sys.error("stub")
+ def ^(x: Short): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -421,7 +423,7 @@ final class Byte private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Char): Int = sys.error("stub")
+ def ^(x: Char): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -432,7 +434,7 @@ final class Byte private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Int): Int = sys.error("stub")
+ def ^(x: Int): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -443,157 +445,157 @@ final class Byte private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Long): Long = sys.error("stub")
+ def ^(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Int = sys.error("stub")
+ def +(x: Byte): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Int = sys.error("stub")
+ def +(x: Short): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Int = sys.error("stub")
+ def +(x: Char): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Int = sys.error("stub")
+ def +(x: Int): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Long = sys.error("stub")
+ def +(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Int = sys.error("stub")
+ def -(x: Byte): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Int = sys.error("stub")
+ def -(x: Short): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Int = sys.error("stub")
+ def -(x: Char): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Int = sys.error("stub")
+ def -(x: Int): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Long = sys.error("stub")
+ def -(x: Long): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Int = sys.error("stub")
+ def *(x: Byte): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Int = sys.error("stub")
+ def *(x: Short): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Int = sys.error("stub")
+ def *(x: Char): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Int = sys.error("stub")
+ def *(x: Int): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Long = sys.error("stub")
+ def *(x: Long): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Int = sys.error("stub")
+ def /(x: Byte): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Int = sys.error("stub")
+ def /(x: Short): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Int = sys.error("stub")
+ def /(x: Char): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Int = sys.error("stub")
+ def /(x: Int): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Long = sys.error("stub")
+ def /(x: Long): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Int = sys.error("stub")
+ def %(x: Byte): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Int = sys.error("stub")
+ def %(x: Short): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Int = sys.error("stub")
+ def %(x: Char): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Int = sys.error("stub")
+ def %(x: Int): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Long = sys.error("stub")
+ def %(x: Long): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Byte] = sys.error("stub")
+ override def getClass(): Class[Byte] = null
}
-object Byte extends AnyValCompanion {
+object Byte extends AnyValCompanion {
/** The smallest value representable as a Byte.
*/
final val MinValue = java.lang.Byte.MIN_VALUE
@@ -622,6 +624,9 @@ object Byte extends AnyValCompanion {
/** The String representation of the scala.Byte companion object.
*/
override def toString = "object scala.Byte"
+
+ /** Language mandated coercions from Byte to "wider" types.
+ */
implicit def byte2short(x: Byte): Short = x.toShort
implicit def byte2int(x: Byte): Int = x.toInt
implicit def byte2long(x: Byte): Long = x.toLong
diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala
index e0ac9a2550..b681ae1693 100644
--- a/src/library/scala/Char.scala
+++ b/src/library/scala/Char.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Char`, a 16-bit unsigned integer (equivalent to Java's `char` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Char` are not
* represented by an object in the underlying runtime system.
@@ -17,14 +19,14 @@ package scala
* There is an implicit conversion from [[scala.Char]] => [[scala.runtime.RichChar]]
* which provides useful non-primitive operations.
*/
-final class Char private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Char private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns the bitwise negation of this value.
@@ -34,30 +36,30 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def unary_~ : Int = sys.error("stub")
+ def unary_~ : Int
/**
* Returns this value, unmodified.
*/
- def unary_+ : Int = sys.error("stub")
+ def unary_+ : Int
/**
* Returns the negation of this value.
*/
- def unary_- : Int = sys.error("stub")
+ def unary_- : Int
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Int): Int = sys.error("stub")
+ def <<(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Long): Int = sys.error("stub")
+ def <<(x: Long): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -68,7 +70,7 @@ final class Char private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Int): Int = sys.error("stub")
+ def >>>(x: Int): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -79,7 +81,7 @@ final class Char private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Long): Int = sys.error("stub")
+ def >>>(x: Long): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -90,7 +92,7 @@ final class Char private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Int): Int = sys.error("stub")
+ def >>(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -101,181 +103,181 @@ final class Char private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Long): Int = sys.error("stub")
+ def >>(x: Long): Int
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the bitwise OR of this value and `x`.
@@ -287,7 +289,7 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Byte): Int = sys.error("stub")
+ def |(x: Byte): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -298,7 +300,7 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Short): Int = sys.error("stub")
+ def |(x: Short): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -309,7 +311,7 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Char): Int = sys.error("stub")
+ def |(x: Char): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -320,7 +322,7 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Int): Int = sys.error("stub")
+ def |(x: Int): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -331,7 +333,7 @@ final class Char private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Long): Long = sys.error("stub")
+ def |(x: Long): Long
/**
* Returns the bitwise AND of this value and `x`.
@@ -343,7 +345,7 @@ final class Char private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Byte): Int = sys.error("stub")
+ def &(x: Byte): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -354,7 +356,7 @@ final class Char private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Short): Int = sys.error("stub")
+ def &(x: Short): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -365,7 +367,7 @@ final class Char private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Char): Int = sys.error("stub")
+ def &(x: Char): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -376,7 +378,7 @@ final class Char private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Int): Int = sys.error("stub")
+ def &(x: Int): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -387,7 +389,7 @@ final class Char private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Long): Long = sys.error("stub")
+ def &(x: Long): Long
/**
* Returns the bitwise XOR of this value and `x`.
@@ -399,7 +401,7 @@ final class Char private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Byte): Int = sys.error("stub")
+ def ^(x: Byte): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -410,7 +412,7 @@ final class Char private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Short): Int = sys.error("stub")
+ def ^(x: Short): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -421,7 +423,7 @@ final class Char private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Char): Int = sys.error("stub")
+ def ^(x: Char): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -432,7 +434,7 @@ final class Char private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Int): Int = sys.error("stub")
+ def ^(x: Int): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -443,157 +445,157 @@ final class Char private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Long): Long = sys.error("stub")
+ def ^(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Int = sys.error("stub")
+ def +(x: Byte): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Int = sys.error("stub")
+ def +(x: Short): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Int = sys.error("stub")
+ def +(x: Char): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Int = sys.error("stub")
+ def +(x: Int): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Long = sys.error("stub")
+ def +(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Int = sys.error("stub")
+ def -(x: Byte): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Int = sys.error("stub")
+ def -(x: Short): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Int = sys.error("stub")
+ def -(x: Char): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Int = sys.error("stub")
+ def -(x: Int): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Long = sys.error("stub")
+ def -(x: Long): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Int = sys.error("stub")
+ def *(x: Byte): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Int = sys.error("stub")
+ def *(x: Short): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Int = sys.error("stub")
+ def *(x: Char): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Int = sys.error("stub")
+ def *(x: Int): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Long = sys.error("stub")
+ def *(x: Long): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Int = sys.error("stub")
+ def /(x: Byte): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Int = sys.error("stub")
+ def /(x: Short): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Int = sys.error("stub")
+ def /(x: Char): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Int = sys.error("stub")
+ def /(x: Int): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Long = sys.error("stub")
+ def /(x: Long): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Int = sys.error("stub")
+ def %(x: Byte): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Int = sys.error("stub")
+ def %(x: Short): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Int = sys.error("stub")
+ def %(x: Char): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Int = sys.error("stub")
+ def %(x: Int): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Long = sys.error("stub")
+ def %(x: Long): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Char] = sys.error("stub")
+ override def getClass(): Class[Char] = null
}
-object Char extends AnyValCompanion {
+object Char extends AnyValCompanion {
/** The smallest value representable as a Char.
*/
final val MinValue = java.lang.Character.MIN_VALUE
@@ -622,6 +624,9 @@ object Char extends AnyValCompanion {
/** The String representation of the scala.Char companion object.
*/
override def toString = "object scala.Char"
+
+ /** Language mandated coercions from Char to "wider" types.
+ */
implicit def char2int(x: Char): Int = x.toInt
implicit def char2long(x: Char): Long = x.toLong
implicit def char2float(x: Char): Float = x.toFloat
diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala
index bb659b963a..2ff46c433d 100644
--- a/src/library/scala/Double.scala
+++ b/src/library/scala/Double.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Double` are not
* represented by an object in the underlying runtime system.
@@ -17,349 +19,349 @@ package scala
* There is an implicit conversion from [[scala.Double]] => [[scala.runtime.RichDouble]]
* which provides useful non-primitive operations.
*/
-final class Double private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Double private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns this value, unmodified.
*/
- def unary_+ : Double = sys.error("stub")
+ def unary_+ : Double
/**
* Returns the negation of this value.
*/
- def unary_- : Double = sys.error("stub")
+ def unary_- : Double
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Double = sys.error("stub")
+ def +(x: Byte): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Double = sys.error("stub")
+ def +(x: Short): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Double = sys.error("stub")
+ def +(x: Char): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Double = sys.error("stub")
+ def +(x: Int): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Double = sys.error("stub")
+ def +(x: Long): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Double = sys.error("stub")
+ def +(x: Float): Double
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Double = sys.error("stub")
+ def -(x: Byte): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Double = sys.error("stub")
+ def -(x: Short): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Double = sys.error("stub")
+ def -(x: Char): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Double = sys.error("stub")
+ def -(x: Int): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Double = sys.error("stub")
+ def -(x: Long): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Double = sys.error("stub")
+ def -(x: Float): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Double = sys.error("stub")
+ def *(x: Byte): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Double = sys.error("stub")
+ def *(x: Short): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Double = sys.error("stub")
+ def *(x: Char): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Double = sys.error("stub")
+ def *(x: Int): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Double = sys.error("stub")
+ def *(x: Long): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Double = sys.error("stub")
+ def *(x: Float): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Double = sys.error("stub")
+ def /(x: Byte): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Double = sys.error("stub")
+ def /(x: Short): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Double = sys.error("stub")
+ def /(x: Char): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Double = sys.error("stub")
+ def /(x: Int): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Double = sys.error("stub")
+ def /(x: Long): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Double = sys.error("stub")
+ def /(x: Float): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Double = sys.error("stub")
+ def %(x: Byte): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Double = sys.error("stub")
+ def %(x: Short): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Double = sys.error("stub")
+ def %(x: Char): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Double = sys.error("stub")
+ def %(x: Int): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Double = sys.error("stub")
+ def %(x: Long): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Double = sys.error("stub")
+ def %(x: Float): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Double] = sys.error("stub")
+ override def getClass(): Class[Double] = null
}
-object Double extends AnyValCompanion {
+object Double extends AnyValCompanion {
/** The smallest positive value greater than 0.0d which is
* representable as a Double.
*/
diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala
index bb03581062..bd7a07fece 100644
--- a/src/library/scala/Float.scala
+++ b/src/library/scala/Float.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Float`, a 32-bit IEEE-754 floating point number (equivalent to Java's `float` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Float` are not
* represented by an object in the underlying runtime system.
@@ -17,349 +19,349 @@ package scala
* There is an implicit conversion from [[scala.Float]] => [[scala.runtime.RichFloat]]
* which provides useful non-primitive operations.
*/
-final class Float private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Float private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns this value, unmodified.
*/
- def unary_+ : Float = sys.error("stub")
+ def unary_+ : Float
/**
* Returns the negation of this value.
*/
- def unary_- : Float = sys.error("stub")
+ def unary_- : Float
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Float = sys.error("stub")
+ def +(x: Byte): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Float = sys.error("stub")
+ def +(x: Short): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Float = sys.error("stub")
+ def +(x: Char): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Float = sys.error("stub")
+ def +(x: Int): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Float = sys.error("stub")
+ def +(x: Long): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Float = sys.error("stub")
+ def -(x: Byte): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Float = sys.error("stub")
+ def -(x: Short): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Float = sys.error("stub")
+ def -(x: Char): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Float = sys.error("stub")
+ def -(x: Int): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Float = sys.error("stub")
+ def -(x: Long): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Float = sys.error("stub")
+ def *(x: Byte): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Float = sys.error("stub")
+ def *(x: Short): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Float = sys.error("stub")
+ def *(x: Char): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Float = sys.error("stub")
+ def *(x: Int): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Float = sys.error("stub")
+ def *(x: Long): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Float = sys.error("stub")
+ def /(x: Byte): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Float = sys.error("stub")
+ def /(x: Short): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Float = sys.error("stub")
+ def /(x: Char): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Float = sys.error("stub")
+ def /(x: Int): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Float = sys.error("stub")
+ def /(x: Long): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Float = sys.error("stub")
+ def %(x: Byte): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Float = sys.error("stub")
+ def %(x: Short): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Float = sys.error("stub")
+ def %(x: Char): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Float = sys.error("stub")
+ def %(x: Int): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Float = sys.error("stub")
+ def %(x: Long): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Float] = sys.error("stub")
+ override def getClass(): Class[Float] = null
}
-object Float extends AnyValCompanion {
+object Float extends AnyValCompanion {
/** The smallest positive value greater than 0.0f which is
* representable as a Float.
*/
@@ -401,6 +403,9 @@ object Float extends AnyValCompanion {
/** The String representation of the scala.Float companion object.
*/
override def toString = "object scala.Float"
+
+ /** Language mandated coercions from Float to "wider" types.
+ */
implicit def float2double(x: Float): Double = x.toDouble
}
diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala
index d5d7ef011d..b2a4f93253 100644
--- a/src/library/scala/Int.scala
+++ b/src/library/scala/Int.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Int`, a 32-bit signed integer (equivalent to Java's `int` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Int` are not
* represented by an object in the underlying runtime system.
@@ -17,14 +19,14 @@ package scala
* There is an implicit conversion from [[scala.Int]] => [[scala.runtime.RichInt]]
* which provides useful non-primitive operations.
*/
-final class Int private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Int private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns the bitwise negation of this value.
@@ -34,30 +36,30 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def unary_~ : Int = sys.error("stub")
+ def unary_~ : Int
/**
* Returns this value, unmodified.
*/
- def unary_+ : Int = sys.error("stub")
+ def unary_+ : Int
/**
* Returns the negation of this value.
*/
- def unary_- : Int = sys.error("stub")
+ def unary_- : Int
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Int): Int = sys.error("stub")
+ def <<(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Long): Int = sys.error("stub")
+ def <<(x: Long): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -68,7 +70,7 @@ final class Int private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Int): Int = sys.error("stub")
+ def >>>(x: Int): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -79,7 +81,7 @@ final class Int private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Long): Int = sys.error("stub")
+ def >>>(x: Long): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -90,7 +92,7 @@ final class Int private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Int): Int = sys.error("stub")
+ def >>(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -101,181 +103,181 @@ final class Int private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Long): Int = sys.error("stub")
+ def >>(x: Long): Int
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the bitwise OR of this value and `x`.
@@ -287,7 +289,7 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Byte): Int = sys.error("stub")
+ def |(x: Byte): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -298,7 +300,7 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Short): Int = sys.error("stub")
+ def |(x: Short): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -309,7 +311,7 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Char): Int = sys.error("stub")
+ def |(x: Char): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -320,7 +322,7 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Int): Int = sys.error("stub")
+ def |(x: Int): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -331,7 +333,7 @@ final class Int private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Long): Long = sys.error("stub")
+ def |(x: Long): Long
/**
* Returns the bitwise AND of this value and `x`.
@@ -343,7 +345,7 @@ final class Int private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Byte): Int = sys.error("stub")
+ def &(x: Byte): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -354,7 +356,7 @@ final class Int private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Short): Int = sys.error("stub")
+ def &(x: Short): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -365,7 +367,7 @@ final class Int private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Char): Int = sys.error("stub")
+ def &(x: Char): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -376,7 +378,7 @@ final class Int private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Int): Int = sys.error("stub")
+ def &(x: Int): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -387,7 +389,7 @@ final class Int private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Long): Long = sys.error("stub")
+ def &(x: Long): Long
/**
* Returns the bitwise XOR of this value and `x`.
@@ -399,7 +401,7 @@ final class Int private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Byte): Int = sys.error("stub")
+ def ^(x: Byte): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -410,7 +412,7 @@ final class Int private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Short): Int = sys.error("stub")
+ def ^(x: Short): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -421,7 +423,7 @@ final class Int private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Char): Int = sys.error("stub")
+ def ^(x: Char): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -432,7 +434,7 @@ final class Int private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Int): Int = sys.error("stub")
+ def ^(x: Int): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -443,157 +445,157 @@ final class Int private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Long): Long = sys.error("stub")
+ def ^(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Int = sys.error("stub")
+ def +(x: Byte): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Int = sys.error("stub")
+ def +(x: Short): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Int = sys.error("stub")
+ def +(x: Char): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Int = sys.error("stub")
+ def +(x: Int): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Long = sys.error("stub")
+ def +(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Int = sys.error("stub")
+ def -(x: Byte): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Int = sys.error("stub")
+ def -(x: Short): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Int = sys.error("stub")
+ def -(x: Char): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Int = sys.error("stub")
+ def -(x: Int): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Long = sys.error("stub")
+ def -(x: Long): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Int = sys.error("stub")
+ def *(x: Byte): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Int = sys.error("stub")
+ def *(x: Short): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Int = sys.error("stub")
+ def *(x: Char): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Int = sys.error("stub")
+ def *(x: Int): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Long = sys.error("stub")
+ def *(x: Long): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Int = sys.error("stub")
+ def /(x: Byte): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Int = sys.error("stub")
+ def /(x: Short): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Int = sys.error("stub")
+ def /(x: Char): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Int = sys.error("stub")
+ def /(x: Int): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Long = sys.error("stub")
+ def /(x: Long): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Int = sys.error("stub")
+ def %(x: Byte): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Int = sys.error("stub")
+ def %(x: Short): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Int = sys.error("stub")
+ def %(x: Char): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Int = sys.error("stub")
+ def %(x: Int): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Long = sys.error("stub")
+ def %(x: Long): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Int] = sys.error("stub")
+ override def getClass(): Class[Int] = null
}
-object Int extends AnyValCompanion {
+object Int extends AnyValCompanion {
/** The smallest value representable as a Int.
*/
final val MinValue = java.lang.Integer.MIN_VALUE
@@ -622,6 +624,9 @@ object Int extends AnyValCompanion {
/** The String representation of the scala.Int companion object.
*/
override def toString = "object scala.Int"
+
+ /** Language mandated coercions from Int to "wider" types.
+ */
implicit def int2long(x: Int): Long = x.toLong
implicit def int2float(x: Int): Float = x.toFloat
implicit def int2double(x: Int): Double = x.toDouble
diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala
index 85131b4f54..40932a65a7 100644
--- a/src/library/scala/Long.scala
+++ b/src/library/scala/Long.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Long`, a 64-bit signed integer (equivalent to Java's `long` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Long` are not
* represented by an object in the underlying runtime system.
@@ -17,14 +19,14 @@ package scala
* There is an implicit conversion from [[scala.Long]] => [[scala.runtime.RichLong]]
* which provides useful non-primitive operations.
*/
-final class Long private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Long private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns the bitwise negation of this value.
@@ -34,30 +36,30 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def unary_~ : Long = sys.error("stub")
+ def unary_~ : Long
/**
* Returns this value, unmodified.
*/
- def unary_+ : Long = sys.error("stub")
+ def unary_+ : Long
/**
* Returns the negation of this value.
*/
- def unary_- : Long = sys.error("stub")
+ def unary_- : Long
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Int): Long = sys.error("stub")
+ def <<(x: Int): Long
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Long): Long = sys.error("stub")
+ def <<(x: Long): Long
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -68,7 +70,7 @@ final class Long private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Int): Long = sys.error("stub")
+ def >>>(x: Int): Long
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -79,7 +81,7 @@ final class Long private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Long): Long = sys.error("stub")
+ def >>>(x: Long): Long
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -90,7 +92,7 @@ final class Long private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Int): Long = sys.error("stub")
+ def >>(x: Int): Long
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -101,181 +103,181 @@ final class Long private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Long): Long = sys.error("stub")
+ def >>(x: Long): Long
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the bitwise OR of this value and `x`.
@@ -287,7 +289,7 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Byte): Long = sys.error("stub")
+ def |(x: Byte): Long
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -298,7 +300,7 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Short): Long = sys.error("stub")
+ def |(x: Short): Long
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -309,7 +311,7 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Char): Long = sys.error("stub")
+ def |(x: Char): Long
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -320,7 +322,7 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Int): Long = sys.error("stub")
+ def |(x: Int): Long
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -331,7 +333,7 @@ final class Long private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Long): Long = sys.error("stub")
+ def |(x: Long): Long
/**
* Returns the bitwise AND of this value and `x`.
@@ -343,7 +345,7 @@ final class Long private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Byte): Long = sys.error("stub")
+ def &(x: Byte): Long
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -354,7 +356,7 @@ final class Long private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Short): Long = sys.error("stub")
+ def &(x: Short): Long
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -365,7 +367,7 @@ final class Long private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Char): Long = sys.error("stub")
+ def &(x: Char): Long
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -376,7 +378,7 @@ final class Long private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Int): Long = sys.error("stub")
+ def &(x: Int): Long
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -387,7 +389,7 @@ final class Long private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Long): Long = sys.error("stub")
+ def &(x: Long): Long
/**
* Returns the bitwise XOR of this value and `x`.
@@ -399,7 +401,7 @@ final class Long private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Byte): Long = sys.error("stub")
+ def ^(x: Byte): Long
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -410,7 +412,7 @@ final class Long private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Short): Long = sys.error("stub")
+ def ^(x: Short): Long
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -421,7 +423,7 @@ final class Long private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Char): Long = sys.error("stub")
+ def ^(x: Char): Long
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -432,7 +434,7 @@ final class Long private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Int): Long = sys.error("stub")
+ def ^(x: Int): Long
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -443,157 +445,157 @@ final class Long private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Long): Long = sys.error("stub")
+ def ^(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Long = sys.error("stub")
+ def +(x: Byte): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Long = sys.error("stub")
+ def +(x: Short): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Long = sys.error("stub")
+ def +(x: Char): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Long = sys.error("stub")
+ def +(x: Int): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Long = sys.error("stub")
+ def +(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Long = sys.error("stub")
+ def -(x: Byte): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Long = sys.error("stub")
+ def -(x: Short): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Long = sys.error("stub")
+ def -(x: Char): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Long = sys.error("stub")
+ def -(x: Int): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Long = sys.error("stub")
+ def -(x: Long): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Long = sys.error("stub")
+ def *(x: Byte): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Long = sys.error("stub")
+ def *(x: Short): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Long = sys.error("stub")
+ def *(x: Char): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Long = sys.error("stub")
+ def *(x: Int): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Long = sys.error("stub")
+ def *(x: Long): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Long = sys.error("stub")
+ def /(x: Byte): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Long = sys.error("stub")
+ def /(x: Short): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Long = sys.error("stub")
+ def /(x: Char): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Long = sys.error("stub")
+ def /(x: Int): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Long = sys.error("stub")
+ def /(x: Long): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Long = sys.error("stub")
+ def %(x: Byte): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Long = sys.error("stub")
+ def %(x: Short): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Long = sys.error("stub")
+ def %(x: Char): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Long = sys.error("stub")
+ def %(x: Int): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Long = sys.error("stub")
+ def %(x: Long): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Long] = sys.error("stub")
+ override def getClass(): Class[Long] = null
}
-object Long extends AnyValCompanion {
+object Long extends AnyValCompanion {
/** The smallest value representable as a Long.
*/
final val MinValue = java.lang.Long.MIN_VALUE
@@ -622,6 +624,9 @@ object Long extends AnyValCompanion {
/** The String representation of the scala.Long companion object.
*/
override def toString = "object scala.Long"
+
+ /** Language mandated coercions from Long to "wider" types.
+ */
implicit def long2float(x: Long): Float = x.toFloat
implicit def long2double(x: Long): Double = x.toDouble
}
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index c08462ac1b..65e8549ae1 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -111,26 +111,6 @@ object Predef extends LowPriorityImplicits {
def classManifest[T](implicit m: ClassManifest[T]) = m
def optManifest[T](implicit m: OptManifest[T]) = m
- // Tag types and companions, and incantations for summoning
- type ArrayTag[T] = scala.reflect.ArrayTag[T]
- type ErasureTag[T] = scala.reflect.ErasureTag[T]
- type ClassTag[T] = scala.reflect.ClassTag[T]
- type TypeTag[T] = scala.reflect.TypeTag[T]
- type ConcreteTypeTag[T] = scala.reflect.ConcreteTypeTag[T]
- val ClassTag = scala.reflect.ClassTag // doesn't need to be lazy, because it's not a path-dependent type
- // [Paul to Eugene] No lazy vals in Predef. Too expensive. Have to work harder on breaking initialization dependencies.
- lazy val TypeTag = scala.reflect.TypeTag // needs to be lazy, because requires scala.reflect.mirror instance
- lazy val ConcreteTypeTag = scala.reflect.ConcreteTypeTag
-
- // [Eugene to Martin] it's really tedious to type "implicitly[...]" all the time, so I'm reintroducing these shortcuts
- def arrayTag[T](implicit atag: ArrayTag[T]) = atag
- def erasureTag[T](implicit etag: ErasureTag[T]) = etag
- def classTag[T](implicit ctag: ClassTag[T]) = ctag
- def tag[T](implicit ttag: TypeTag[T]) = ttag
- def typeTag[T](implicit ttag: TypeTag[T]) = ttag
- def concreteTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag
- def concreteTypeTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag
-
// Minor variations on identity functions
def identity[A](x: A): A = x // @see `conforms` for the implicit version
@inline def implicitly[T](implicit e: T) = e // for summoning implicit values from the nether world -- TODO: when dependent method types are on by default, give this result type `e.type`, so that inliner has better chance of knowing which method to inline in calls like `implicitly[MatchingStrategy[Option]].zero`
diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala
index 1060a9db16..687b198a11 100644
--- a/src/library/scala/Short.scala
+++ b/src/library/scala/Short.scala
@@ -10,6 +10,8 @@
package scala
+import language.implicitConversions
+
/** `Short`, a 16-bit signed integer (equivalent to Java's `short` primitive type) is a
* subtype of [[scala.AnyVal]]. Instances of `Short` are not
* represented by an object in the underlying runtime system.
@@ -17,14 +19,14 @@ package scala
* There is an implicit conversion from [[scala.Short]] => [[scala.runtime.RichShort]]
* which provides useful non-primitive operations.
*/
-final class Short private extends AnyVal {
- def toByte: Byte = sys.error("stub")
- def toShort: Short = sys.error("stub")
- def toChar: Char = sys.error("stub")
- def toInt: Int = sys.error("stub")
- def toLong: Long = sys.error("stub")
- def toFloat: Float = sys.error("stub")
- def toDouble: Double = sys.error("stub")
+final abstract class Short private extends AnyVal {
+ def toByte: Byte
+ def toShort: Short
+ def toChar: Char
+ def toInt: Int
+ def toLong: Long
+ def toFloat: Float
+ def toDouble: Double
/**
* Returns the bitwise negation of this value.
@@ -34,30 +36,30 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def unary_~ : Int = sys.error("stub")
+ def unary_~ : Int
/**
* Returns this value, unmodified.
*/
- def unary_+ : Int = sys.error("stub")
+ def unary_+ : Int
/**
* Returns the negation of this value.
*/
- def unary_- : Int = sys.error("stub")
+ def unary_- : Int
- def +(x: String): String = sys.error("stub")
+ def +(x: String): String
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Int): Int = sys.error("stub")
+ def <<(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the new right bits with zeroes.
* @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}
*/
- def <<(x: Long): Int = sys.error("stub")
+ def <<(x: Long): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -68,7 +70,7 @@ final class Short private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Int): Int = sys.error("stub")
+ def >>>(x: Int): Int
/**
* Returns this value bit-shifted right by the specified number of bits,
* filling the new left bits with zeroes.
@@ -79,7 +81,7 @@ final class Short private extends AnyVal {
* // 00011111 11111111 11111111 11111101
* }}}
*/
- def >>>(x: Long): Int = sys.error("stub")
+ def >>>(x: Long): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -90,7 +92,7 @@ final class Short private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Int): Int = sys.error("stub")
+ def >>(x: Int): Int
/**
* Returns this value bit-shifted left by the specified number of bits,
* filling in the right bits with the same value as the left-most bit of this.
@@ -101,181 +103,181 @@ final class Short private extends AnyVal {
* // 11111111 11111111 11111111 11111101
* }}}
*/
- def >>(x: Long): Int = sys.error("stub")
+ def >>(x: Long): Int
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Byte): Boolean = sys.error("stub")
+ def ==(x: Byte): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Short): Boolean = sys.error("stub")
+ def ==(x: Short): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Char): Boolean = sys.error("stub")
+ def ==(x: Char): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Int): Boolean = sys.error("stub")
+ def ==(x: Int): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Long): Boolean = sys.error("stub")
+ def ==(x: Long): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Float): Boolean = sys.error("stub")
+ def ==(x: Float): Boolean
/**
* Returns `true` if this value is equal to x, `false` otherwise.
*/
- def ==(x: Double): Boolean = sys.error("stub")
+ def ==(x: Double): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Byte): Boolean = sys.error("stub")
+ def !=(x: Byte): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Short): Boolean = sys.error("stub")
+ def !=(x: Short): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Char): Boolean = sys.error("stub")
+ def !=(x: Char): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Int): Boolean = sys.error("stub")
+ def !=(x: Int): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Long): Boolean = sys.error("stub")
+ def !=(x: Long): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Float): Boolean = sys.error("stub")
+ def !=(x: Float): Boolean
/**
* Returns `true` if this value is not equal to x, `false` otherwise.
*/
- def !=(x: Double): Boolean = sys.error("stub")
+ def !=(x: Double): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Byte): Boolean = sys.error("stub")
+ def <(x: Byte): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Short): Boolean = sys.error("stub")
+ def <(x: Short): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Char): Boolean = sys.error("stub")
+ def <(x: Char): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Int): Boolean = sys.error("stub")
+ def <(x: Int): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Long): Boolean = sys.error("stub")
+ def <(x: Long): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Float): Boolean = sys.error("stub")
+ def <(x: Float): Boolean
/**
* Returns `true` if this value is less than x, `false` otherwise.
*/
- def <(x: Double): Boolean = sys.error("stub")
+ def <(x: Double): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Byte): Boolean = sys.error("stub")
+ def <=(x: Byte): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Short): Boolean = sys.error("stub")
+ def <=(x: Short): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Char): Boolean = sys.error("stub")
+ def <=(x: Char): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Int): Boolean = sys.error("stub")
+ def <=(x: Int): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Long): Boolean = sys.error("stub")
+ def <=(x: Long): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Float): Boolean = sys.error("stub")
+ def <=(x: Float): Boolean
/**
* Returns `true` if this value is less than or equal to x, `false` otherwise.
*/
- def <=(x: Double): Boolean = sys.error("stub")
+ def <=(x: Double): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Byte): Boolean = sys.error("stub")
+ def >(x: Byte): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Short): Boolean = sys.error("stub")
+ def >(x: Short): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Char): Boolean = sys.error("stub")
+ def >(x: Char): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Int): Boolean = sys.error("stub")
+ def >(x: Int): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Long): Boolean = sys.error("stub")
+ def >(x: Long): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Float): Boolean = sys.error("stub")
+ def >(x: Float): Boolean
/**
* Returns `true` if this value is greater than x, `false` otherwise.
*/
- def >(x: Double): Boolean = sys.error("stub")
+ def >(x: Double): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Byte): Boolean = sys.error("stub")
+ def >=(x: Byte): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Short): Boolean = sys.error("stub")
+ def >=(x: Short): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Char): Boolean = sys.error("stub")
+ def >=(x: Char): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Int): Boolean = sys.error("stub")
+ def >=(x: Int): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Long): Boolean = sys.error("stub")
+ def >=(x: Long): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Float): Boolean = sys.error("stub")
+ def >=(x: Float): Boolean
/**
* Returns `true` if this value is greater than or equal to x, `false` otherwise.
*/
- def >=(x: Double): Boolean = sys.error("stub")
+ def >=(x: Double): Boolean
/**
* Returns the bitwise OR of this value and `x`.
@@ -287,7 +289,7 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Byte): Int = sys.error("stub")
+ def |(x: Byte): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -298,7 +300,7 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Short): Int = sys.error("stub")
+ def |(x: Short): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -309,7 +311,7 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Char): Int = sys.error("stub")
+ def |(x: Char): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -320,7 +322,7 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Int): Int = sys.error("stub")
+ def |(x: Int): Int
/**
* Returns the bitwise OR of this value and `x`.
* @example {{{
@@ -331,7 +333,7 @@ final class Short private extends AnyVal {
* // 11111010
* }}}
*/
- def |(x: Long): Long = sys.error("stub")
+ def |(x: Long): Long
/**
* Returns the bitwise AND of this value and `x`.
@@ -343,7 +345,7 @@ final class Short private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Byte): Int = sys.error("stub")
+ def &(x: Byte): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -354,7 +356,7 @@ final class Short private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Short): Int = sys.error("stub")
+ def &(x: Short): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -365,7 +367,7 @@ final class Short private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Char): Int = sys.error("stub")
+ def &(x: Char): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -376,7 +378,7 @@ final class Short private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Int): Int = sys.error("stub")
+ def &(x: Int): Int
/**
* Returns the bitwise AND of this value and `x`.
* @example {{{
@@ -387,7 +389,7 @@ final class Short private extends AnyVal {
* // 10100000
* }}}
*/
- def &(x: Long): Long = sys.error("stub")
+ def &(x: Long): Long
/**
* Returns the bitwise XOR of this value and `x`.
@@ -399,7 +401,7 @@ final class Short private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Byte): Int = sys.error("stub")
+ def ^(x: Byte): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -410,7 +412,7 @@ final class Short private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Short): Int = sys.error("stub")
+ def ^(x: Short): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -421,7 +423,7 @@ final class Short private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Char): Int = sys.error("stub")
+ def ^(x: Char): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -432,7 +434,7 @@ final class Short private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Int): Int = sys.error("stub")
+ def ^(x: Int): Int
/**
* Returns the bitwise XOR of this value and `x`.
* @example {{{
@@ -443,157 +445,157 @@ final class Short private extends AnyVal {
* // 01011010
* }}}
*/
- def ^(x: Long): Long = sys.error("stub")
+ def ^(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Byte): Int = sys.error("stub")
+ def +(x: Byte): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Short): Int = sys.error("stub")
+ def +(x: Short): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Char): Int = sys.error("stub")
+ def +(x: Char): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Int): Int = sys.error("stub")
+ def +(x: Int): Int
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Long): Long = sys.error("stub")
+ def +(x: Long): Long
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Float): Float = sys.error("stub")
+ def +(x: Float): Float
/**
* Returns the sum of this value and `x`.
*/
- def +(x: Double): Double = sys.error("stub")
+ def +(x: Double): Double
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Byte): Int = sys.error("stub")
+ def -(x: Byte): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Short): Int = sys.error("stub")
+ def -(x: Short): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Char): Int = sys.error("stub")
+ def -(x: Char): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Int): Int = sys.error("stub")
+ def -(x: Int): Int
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Long): Long = sys.error("stub")
+ def -(x: Long): Long
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Float): Float = sys.error("stub")
+ def -(x: Float): Float
/**
* Returns the difference of this value and `x`.
*/
- def -(x: Double): Double = sys.error("stub")
+ def -(x: Double): Double
/**
* Returns the product of this value and `x`.
*/
- def *(x: Byte): Int = sys.error("stub")
+ def *(x: Byte): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Short): Int = sys.error("stub")
+ def *(x: Short): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Char): Int = sys.error("stub")
+ def *(x: Char): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Int): Int = sys.error("stub")
+ def *(x: Int): Int
/**
* Returns the product of this value and `x`.
*/
- def *(x: Long): Long = sys.error("stub")
+ def *(x: Long): Long
/**
* Returns the product of this value and `x`.
*/
- def *(x: Float): Float = sys.error("stub")
+ def *(x: Float): Float
/**
* Returns the product of this value and `x`.
*/
- def *(x: Double): Double = sys.error("stub")
+ def *(x: Double): Double
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Byte): Int = sys.error("stub")
+ def /(x: Byte): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Short): Int = sys.error("stub")
+ def /(x: Short): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Char): Int = sys.error("stub")
+ def /(x: Char): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Int): Int = sys.error("stub")
+ def /(x: Int): Int
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Long): Long = sys.error("stub")
+ def /(x: Long): Long
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Float): Float = sys.error("stub")
+ def /(x: Float): Float
/**
* Returns the quotient of this value and `x`.
*/
- def /(x: Double): Double = sys.error("stub")
+ def /(x: Double): Double
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Byte): Int = sys.error("stub")
+ def %(x: Byte): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Short): Int = sys.error("stub")
+ def %(x: Short): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Char): Int = sys.error("stub")
+ def %(x: Char): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Int): Int = sys.error("stub")
+ def %(x: Int): Int
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Long): Long = sys.error("stub")
+ def %(x: Long): Long
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Float): Float = sys.error("stub")
+ def %(x: Float): Float
/**
* Returns the remainder of the division of this value by `x`.
*/
- def %(x: Double): Double = sys.error("stub")
+ def %(x: Double): Double
- override def getClass(): Class[Short] = sys.error("stub")
+ override def getClass(): Class[Short] = null
}
-object Short extends AnyValCompanion {
+object Short extends AnyValCompanion {
/** The smallest value representable as a Short.
*/
final val MinValue = java.lang.Short.MIN_VALUE
@@ -622,6 +624,9 @@ object Short extends AnyValCompanion {
/** The String representation of the scala.Short companion object.
*/
override def toString = "object scala.Short"
+
+ /** Language mandated coercions from Short to "wider" types.
+ */
implicit def short2int(x: Short): Int = x.toInt
implicit def short2long(x: Short): Long = x.toLong
implicit def short2float(x: Short): Float = x.toFloat
diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala
index 3da5c083d4..4156071f29 100644
--- a/src/library/scala/Unit.scala
+++ b/src/library/scala/Unit.scala
@@ -10,17 +10,19 @@
package scala
+import language.implicitConversions
+
/** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type
* `Unit`, `()`, and it is not represented by any object in the underlying
* runtime system. A method with return type `Unit` is analogous to a Java
* method which is declared `void`.
*/
-final class Unit private extends AnyVal {
- override def getClass(): Class[Unit] = sys.error("stub")
+final abstract class Unit private extends AnyVal {
+ override def getClass(): Class[Unit] = null
}
-object Unit extends AnyValCompanion {
+object Unit extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala
index 4dd2a4fe37..b6c90d4d2a 100644
--- a/src/library/scala/collection/GenMapLike.scala
+++ b/src/library/scala/collection/GenMapLike.scala
@@ -31,7 +31,7 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals
// This hash code must be symmetric in the contents but ought not
// collide trivially.
- override def hashCode() = util.MurmurHash3.mapHash(seq)
+ override def hashCode() = util.hashing.MurmurHash3.mapHash(seq)
/** Returns the value associated with a key, or a default value if the key is not contained in the map.
* @param key the key.
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index cfa0ca101e..a77cb05960 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -465,7 +465,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
/** Hashcodes for $Coll produce a value from the hashcodes of all the
* elements of the $coll.
*/
- override def hashCode() = util.MurmurHash3.seqHash(seq)
+ override def hashCode() = util.hashing.MurmurHash3.seqHash(seq)
/** The equals method for arbitrary sequences. Compares this sequence to
* some other object.
diff --git a/src/library/scala/collection/GenSetLike.scala b/src/library/scala/collection/GenSetLike.scala
index 219374abc6..18eb31da03 100644
--- a/src/library/scala/collection/GenSetLike.scala
+++ b/src/library/scala/collection/GenSetLike.scala
@@ -127,5 +127,5 @@ extends GenIterableLike[A, Repr]
// Calling map on a set drops duplicates: any hashcode collisions would
// then be dropped before they can be added.
// Hash should be symmetric in set entries, but without trivial collisions.
- override def hashCode() = util.MurmurHash3.setHash(seq)
+ override def hashCode() = util.hashing.MurmurHash3.setHash(seq)
}
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index eab6b84ea8..eadacd9209 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -8,6 +8,8 @@
package scala.collection
+import scala.reflect.ClassTag
+
/** A template trait for all traversable-once objects which may be
* traversed in parallel.
*
@@ -459,7 +461,7 @@ trait GenTraversableOnce[+A] extends Any {
/** Converts this $coll to an array.
*
- * @tparam A1 the type of the elements of the array. An `ArrayTag` for
+ * @tparam A1 the type of the elements of the array. An `ClassTag` for
* this type must be available.
* @return an array containing all elements of this $coll.
*
@@ -469,9 +471,9 @@ trait GenTraversableOnce[+A] extends Any {
* $willNotTerminateInf
*
* @return an array containing all elements of this $coll.
- * An `ArrayTag` must be available for the element type of this $coll.
+ * An `ClassTag` must be available for the element type of this $coll.
*/
- def toArray[A1 >: A: ArrayTag]: Array[A1]
+ def toArray[A1 >: A: ClassTag]: Array[A1]
/** Converts this $coll to a list.
* $willNotTerminateInf
diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala
index 11f481e425..f79a9d2c66 100644
--- a/src/library/scala/collection/IndexedSeqLike.scala
+++ b/src/library/scala/collection/IndexedSeqLike.scala
@@ -41,7 +41,7 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] {
self =>
def seq: IndexedSeq[A]
- override def hashCode() = util.MurmurHash3.seqHash(seq) // TODO - can we get faster via "indexedSeqHash" ?
+ override def hashCode() = util.hashing.MurmurHash3.seqHash(seq) // TODO - can we get faster via "indexedSeqHash" ?
override protected[this] def thisCollection: IndexedSeq[A] = this.asInstanceOf[IndexedSeq[A]]
override protected[this] def toCollection(repr: Repr): IndexedSeq[A] = repr.asInstanceOf[IndexedSeq[A]]
diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala
index ceb980ff80..bfe27ef94a 100644
--- a/src/library/scala/collection/LinearSeqLike.scala
+++ b/src/library/scala/collection/LinearSeqLike.scala
@@ -50,7 +50,7 @@ trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr
def seq: LinearSeq[A]
- override def hashCode() = util.MurmurHash3.seqHash(seq) // TODO - can we get faster via "linearSeqHash" ?
+ override def hashCode() = util.hashing.MurmurHash3.seqHash(seq) // TODO - can we get faster via "linearSeqHash" ?
override /*IterableLike*/
def iterator: Iterator[A] = new AbstractIterator[A] {
diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala
index cd85ea4d2d..56a73ae62f 100644
--- a/src/library/scala/collection/Traversable.scala
+++ b/src/library/scala/collection/Traversable.scala
@@ -68,7 +68,7 @@ trait Traversable[+A] extends TraversableLike[A, Traversable[A]]
override def copyToBuffer[B >: A](dest: Buffer[B])
override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int)
override def copyToArray[B >: A](xs: Array[B], start: Int)
- override def toArray[B >: A : ArrayTag]: Array[B]
+ override def toArray[B >: A : ClassTag]: Array[B]
override def toList: List[A]
override def toIterable: Iterable[A]
override def toSeq: Seq[A]
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index d42c037dee..386ce2d95a 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -11,6 +11,7 @@ package scala.collection
import mutable.{ Buffer, Builder, ListBuffer, ArrayBuffer }
import annotation.unchecked.{ uncheckedVariance => uV }
import language.{implicitConversions, higherKinds}
+import reflect.ClassTag
/** A template trait for collections which can be traversed either once only
* or one or more times.
@@ -227,7 +228,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
def copyToArray[B >: A](xs: Array[B]): Unit =
copyToArray(xs, 0, xs.length)
- def toArray[B >: A : ArrayTag]: Array[B] = {
+ def toArray[B >: A : ClassTag]: Array[B] = {
if (isTraversableAgain) {
val result = new Array[B](size)
copyToArray(result, 0)
diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala
index 20880e369d..74b30e0faf 100644
--- a/src/library/scala/collection/TraversableProxyLike.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -12,6 +12,7 @@ package scala.collection
import generic._
import mutable.{Buffer, StringBuilder}
+import reflect.ClassTag
// Methods could be printed by cat TraversableLike.scala | egrep '^ (override )?def'
@@ -73,7 +74,7 @@ trait TraversableProxyLike[+A, +Repr <: TraversableLike[A, Repr] with Traversabl
override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) = self.copyToArray(xs, start, len)
override def copyToArray[B >: A](xs: Array[B], start: Int) = self.copyToArray(xs, start)
override def copyToArray[B >: A](xs: Array[B]) = self.copyToArray(xs)
- override def toArray[B >: A: ArrayTag]: Array[B] = self.toArray
+ override def toArray[B >: A: ClassTag]: Array[B] = self.toArray
override def toList: List[A] = self.toList
override def toIterable: Iterable[A] = self.toIterable
override def toSeq: Seq[A] = self.toSeq
diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala
index 2a908aebb1..08e9125bd8 100644
--- a/src/library/scala/collection/concurrent/TrieMap.scala
+++ b/src/library/scala/collection/concurrent/TrieMap.scala
@@ -14,6 +14,7 @@ package concurrent
import java.util.concurrent.atomic._
import collection.immutable.{ ListMap => ImmutableListMap }
import collection.parallel.mutable.ParTrieMap
+import util.hashing.Hashing
import generic._
import annotation.tailrec
import annotation.switch
@@ -80,6 +81,9 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
} else false
}
+ @inline
+ private def equal(k1: K, k2: K, ct: TrieMap[K, V]) = ct.equality.equiv(k1, k2)
+
@inline private def inode(cn: MainNode[K, V]) = {
val nin = new INode[K, V](gen)
nin.WRITE(cn)
@@ -117,7 +121,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
else false
}
case sn: SNode[K, V] =>
- if (sn.hc == hc && sn.k == k) GCAS(cn, cn.updatedAt(pos, new SNode(k, v, hc), gen), ct)
+ if (sn.hc == hc && equal(sn.k, k, ct)) GCAS(cn, cn.updatedAt(pos, new SNode(k, v, hc), gen), ct)
else {
val rn = if (cn.gen eq gen) cn else cn.renewed(gen, ct)
val nn = rn.updatedAt(pos, inode(CNode.dual(sn, sn.hc, new SNode(k, v, hc), hc, lev + 5, gen)), gen)
@@ -164,7 +168,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
}
case sn: SNode[K, V] => cond match {
case null =>
- if (sn.hc == hc && sn.k == k) {
+ if (sn.hc == hc && equal(sn.k, k, ct)) {
if (GCAS(cn, cn.updatedAt(pos, new SNode(k, v, hc), gen), ct)) Some(sn.v) else null
} else {
val rn = if (cn.gen eq gen) cn else cn.renewed(gen, ct)
@@ -173,7 +177,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
else null
}
case INode.KEY_ABSENT =>
- if (sn.hc == hc && sn.k == k) Some(sn.v)
+ if (sn.hc == hc && equal(sn.k, k, ct)) Some(sn.v)
else {
val rn = if (cn.gen eq gen) cn else cn.renewed(gen, ct)
val nn = rn.updatedAt(pos, inode(CNode.dual(sn, sn.hc, new SNode(k, v, hc), hc, lev + 5, gen)), gen)
@@ -181,11 +185,11 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
else null
}
case INode.KEY_PRESENT =>
- if (sn.hc == hc && sn.k == k) {
+ if (sn.hc == hc && equal(sn.k, k, ct)) {
if (GCAS(cn, cn.updatedAt(pos, new SNode(k, v, hc), gen), ct)) Some(sn.v) else null
} else None
case otherv: V =>
- if (sn.hc == hc && sn.k == k && sn.v == otherv) {
+ if (sn.hc == hc && equal(sn.k, k, ct) && sn.v == otherv) {
if (GCAS(cn, cn.updatedAt(pos, new SNode(k, v, hc), gen), ct)) Some(sn.v) else null
} else None
}
@@ -253,7 +257,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
else return RESTART // used to be throw RestartException
}
case sn: SNode[K, V] => // 2) singleton node
- if (sn.hc == hc && sn.k == k) sn.v.asInstanceOf[AnyRef]
+ if (sn.hc == hc && equal(sn.k, k, ct)) sn.v.asInstanceOf[AnyRef]
else null
}
}
@@ -296,7 +300,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
else null
}
case sn: SNode[K, V] =>
- if (sn.hc == hc && sn.k == k && (v == null || sn.v == v)) {
+ if (sn.hc == hc && equal(sn.k, k, ct) && (v == null || sn.v == v)) {
val ncn = cn.removedAt(pos, flag, gen).toContracted(lev)
if (GCAS(cn, ncn, ct)) Some(sn.v) else null
} else None
@@ -341,11 +345,11 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
case ln: LNode[K, V] =>
if (v == null) {
val optv = ln.get(k)
- val nn = ln.removed(k)
+ val nn = ln.removed(k, ct)
if (GCAS(ln, nn, ct)) optv else null
} else ln.get(k) match {
case optv @ Some(v0) if v0 == v =>
- val nn = ln.removed(k)
+ val nn = ln.removed(k, ct)
if (GCAS(ln, nn, ct)) optv else null
case _ => None
}
@@ -433,12 +437,12 @@ extends MainNode[K, V] {
def this(k: K, v: V) = this(ImmutableListMap(k -> v))
def this(k1: K, v1: V, k2: K, v2: V) = this(ImmutableListMap(k1 -> v1, k2 -> v2))
def inserted(k: K, v: V) = new LNode(listmap + ((k, v)))
- def removed(k: K): MainNode[K, V] = {
+ def removed(k: K, ct: TrieMap[K, V]): MainNode[K, V] = {
val updmap = listmap - k
if (updmap.size > 1) new LNode(updmap)
else {
val (k, v) = updmap.iterator.next
- new TNode(k, v, TrieMap.computeHash(k)) // create it tombed so that it gets compressed on subsequent accesses
+ new TNode(k, v, ct.computeHash(k)) // create it tombed so that it gets compressed on subsequent accesses
}
}
def get(k: K) = listmap.get(k)
@@ -627,25 +631,34 @@ private[concurrent] case class RDCSS_Descriptor[K, V](old: INode[K, V], expected
* @since 2.10
*/
@SerialVersionUID(0L - 6402774413839597105L)
-final class TrieMap[K, V] private (r: AnyRef, rtupd: AtomicReferenceFieldUpdater[TrieMap[K, V], AnyRef])
+final class TrieMap[K, V] private (r: AnyRef, rtupd: AtomicReferenceFieldUpdater[TrieMap[K, V], AnyRef], hashf: Hashing[K], ef: Equiv[K])
extends scala.collection.concurrent.Map[K, V]
with scala.collection.mutable.MapLike[K, V, TrieMap[K, V]]
with CustomParallelizable[(K, V), ParTrieMap[K, V]]
with Serializable
{
- import TrieMap.computeHash
-
+ private var hashingobj = if (hashf.isInstanceOf[Hashing.Default[_]]) new TrieMap.MangledHashing[K] else hashf
+ private var equalityobj = ef
private var rootupdater = rtupd
+ def hashing = hashingobj
+ def equality = equalityobj
@volatile var root = r
-
- def this() = this(
+
+ def this(hashf: Hashing[K], ef: Equiv[K]) = this(
INode.newRootNode,
- AtomicReferenceFieldUpdater.newUpdater(classOf[TrieMap[K, V]], classOf[AnyRef], "root")
+ AtomicReferenceFieldUpdater.newUpdater(classOf[TrieMap[K, V]], classOf[AnyRef], "root"),
+ hashf,
+ ef
)
-
+
+ def this() = this(Hashing.default, Equiv.universal)
+
/* internal methods */
private def writeObject(out: java.io.ObjectOutputStream) {
+ out.writeObject(hashf)
+ out.writeObject(ef)
+
val it = iterator
while (it.hasNext) {
val (k, v) = it.next()
@@ -659,6 +672,9 @@ extends scala.collection.concurrent.Map[K, V]
root = INode.newRootNode
rootupdater = AtomicReferenceFieldUpdater.newUpdater(classOf[TrieMap[K, V]], classOf[AnyRef], "root")
+ hashingobj = in.readObject().asInstanceOf[Hashing[K]]
+ equalityobj = in.readObject().asInstanceOf[Equiv[K]]
+
var obj: AnyRef = null
do {
obj = in.readObject()
@@ -780,7 +796,7 @@ extends scala.collection.concurrent.Map[K, V]
@tailrec final def snapshot(): TrieMap[K, V] = {
val r = RDCSS_READ_ROOT()
val expmain = r.gcasRead(this)
- if (RDCSS_ROOT(r, expmain, r.copyToGen(new Gen, this))) new TrieMap(r.copyToGen(new Gen, this), rootupdater)
+ if (RDCSS_ROOT(r, expmain, r.copyToGen(new Gen, this))) new TrieMap(r.copyToGen(new Gen, this), rootupdater, hashing, equality)
else snapshot()
}
@@ -799,7 +815,7 @@ extends scala.collection.concurrent.Map[K, V]
@tailrec final def readOnlySnapshot(): collection.Map[K, V] = {
val r = RDCSS_READ_ROOT()
val expmain = r.gcasRead(this)
- if (RDCSS_ROOT(r, expmain, r.copyToGen(new Gen, this))) new TrieMap(r, null)
+ if (RDCSS_ROOT(r, expmain, r.copyToGen(new Gen, this))) new TrieMap(r, null, hashing, equality)
else readOnlySnapshot()
}
@@ -807,7 +823,10 @@ extends scala.collection.concurrent.Map[K, V]
val r = RDCSS_READ_ROOT()
if (!RDCSS_ROOT(r, r.gcasRead(this), INode.newRootNode[K, V])) clear()
}
-
+
+ @inline
+ def computeHash(k: K) = hashingobj.hash(k)
+
final def lookup(k: K): V = {
val hc = computeHash(k)
lookuphc(k, hc).asInstanceOf[V]
@@ -894,14 +913,11 @@ object TrieMap extends MutableMapFactory[TrieMap] {
implicit def canBuildFrom[K, V]: CanBuildFrom[Coll, (K, V), TrieMap[K, V]] = new MapCanBuildFrom[K, V]
def empty[K, V]: TrieMap[K, V] = new TrieMap[K, V]
-
- @inline final def computeHash[K](k: K): Int = {
- var hcode = k.hashCode
- hcode = hcode * 0x9e3775cd
- hcode = java.lang.Integer.reverseBytes(hcode)
- hcode * 0x9e3775cd
+
+ class MangledHashing[K] extends Hashing[K] {
+ def hash(k: K) = util.hashing.byteswap32(k.##)
}
-
+
}
diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala
index b1b48b760f..8c603dc91b 100644
--- a/src/library/scala/collection/convert/Wrappers.scala
+++ b/src/library/scala/collection/convert/Wrappers.scala
@@ -171,15 +171,16 @@ private[collection] trait Wrappers {
var prev : Option[A] = None
def hasNext = ui.hasNext
-
+
def next() = {
val (k, v) = ui.next
prev = Some(k)
new ju.Map.Entry[A, B] {
+ import util.hashing.byteswap32
def getKey = k
def getValue = v
def setValue(v1 : B) = self.put(k, v1)
- override def hashCode = k.hashCode + v.hashCode
+ override def hashCode = byteswap32(k.hashCode) + (byteswap32(v.hashCode) << 16)
override def equals(other: Any) = other match {
case e: ju.Map.Entry[_, _] => k == e.getKey && v == e.getValue
case _ => false
diff --git a/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala
index ddae0a4d64..95835d3e90 100644
--- a/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala
+++ b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala
@@ -10,6 +10,7 @@ package scala.collection
package generic
import language.higherKinds
+import reflect.ClassTag
/** A template for companion objects of `ClassTagTraversable` and
* subclasses thereof.
@@ -21,11 +22,11 @@ import language.higherKinds
* @author Aleksandar Prokopec
* @since 2.8
*/
-abstract class ArrayTagTraversableFactory[CC[X] <: Traversable[X] with GenericArrayTagTraversableTemplate[X, CC]]
- extends GenericArrayTagCompanion[CC] {
+abstract class ClassTagTraversableFactory[CC[X] <: Traversable[X] with GenericClassTagTraversableTemplate[X, CC]]
+ extends GenericClassTagCompanion[CC] {
- class GenericCanBuildFrom[A](implicit tag: ArrayTag[A]) extends CanBuildFrom[CC[_], A, CC[A]] {
- def apply(from: CC[_]) = from.genericArrayTagBuilder[A]
+ class GenericCanBuildFrom[A](implicit tag: ClassTag[A]) extends CanBuildFrom[CC[_], A, CC[A]] {
+ def apply(from: CC[_]) = from.genericClassTagBuilder[A]
def apply = newBuilder[A]
}
}
diff --git a/src/library/scala/collection/generic/GenericArrayTagCompanion.scala b/src/library/scala/collection/generic/GenericClassTagCompanion.scala
index 959adbce6d..8cce592627 100644
--- a/src/library/scala/collection/generic/GenericArrayTagCompanion.scala
+++ b/src/library/scala/collection/generic/GenericClassTagCompanion.scala
@@ -11,20 +11,21 @@ package generic
import mutable.Builder
import language.higherKinds
+import reflect.ClassTag
-/** This class represents companions of classes which require ArrayTags
+/** This class represents companions of classes which require ClassTags
* for their element types.
*
* @author Aleksandar Prokopec
*/
-abstract class GenericArrayTagCompanion[+CC[X] <: Traversable[X]] {
+abstract class GenericClassTagCompanion[+CC[X] <: Traversable[X]] {
type Coll = CC[_]
- def newBuilder[A](implicit ord: ArrayTag[A]): Builder[A, CC[A]]
+ def newBuilder[A](implicit ord: ClassTag[A]): Builder[A, CC[A]]
- def empty[A: ArrayTag]: CC[A] = newBuilder[A].result
+ def empty[A: ClassTag]: CC[A] = newBuilder[A].result
- def apply[A](elems: A*)(implicit ord: ArrayTag[A]): CC[A] = {
+ def apply[A](elems: A*)(implicit ord: ClassTag[A]): CC[A] = {
val b = newBuilder[A]
b ++= elems
b.result
diff --git a/src/library/scala/collection/generic/GenericArrayTagTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala
index ac84683c59..d368d0007b 100644
--- a/src/library/scala/collection/generic/GenericArrayTagTraversableTemplate.scala
+++ b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala
@@ -12,19 +12,20 @@ package generic
import mutable.Builder
import annotation.unchecked.uncheckedVariance
import language.higherKinds
+import reflect.ClassTag
-/** This trait represents collections classes which require array
+/** This trait represents collections classes which require class
* tags for their element types.
*
* @author Aleksandar Prokopec
* @since 2.8
*/
-trait GenericArrayTagTraversableTemplate[+A, +CC[X] <: Traversable[X]] extends HasNewBuilder[A, CC[A] @uncheckedVariance] {
- implicit protected[this] val tag: ArrayTag[A]
- def arrayTagCompanion: GenericArrayTagCompanion[CC]
- def genericArrayTagBuilder[B](implicit tag: ArrayTag[B]): Builder[B, CC[B]] = arrayTagCompanion.newBuilder[B]
- @deprecated("use arrayTagCompanion instead", "2.10.0")
- def classManifestCompanion: GenericClassManifestCompanion[CC] = arrayTagCompanion
- @deprecated("use genericArrayTagBuilder instead", "2.10.0")
- def genericClassManifestBuilder[B](implicit manifest: ClassManifest[B]): Builder[B, CC[B]] = genericArrayTagBuilder[B](manifest)
+trait GenericClassTagTraversableTemplate[+A, +CC[X] <: Traversable[X]] extends HasNewBuilder[A, CC[A] @uncheckedVariance] {
+ implicit protected[this] val tag: ClassTag[A]
+ def classTagCompanion: GenericClassTagCompanion[CC]
+ def genericClassTagBuilder[B](implicit tag: ClassTag[B]): Builder[B, CC[B]] = classTagCompanion.newBuilder[B]
+ @deprecated("use classTagCompanion instead", "2.10.0")
+ def classManifestCompanion: GenericClassManifestCompanion[CC] = classTagCompanion
+ @deprecated("use genericClassTagBuilder instead", "2.10.0")
+ def genericClassManifestBuilder[B](implicit manifest: ClassManifest[B]): Builder[B, CC[B]] = genericClassTagBuilder[B](manifest)
}
diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala
index 3d5bc2704f..5c55c27983 100644
--- a/src/library/scala/collection/generic/TraversableForwarder.scala
+++ b/src/library/scala/collection/generic/TraversableForwarder.scala
@@ -11,6 +11,7 @@ package scala.collection.generic
import scala.collection._
import mutable.{ Buffer, StringBuilder }
import immutable.{ List, Stream }
+import reflect.ClassTag
/** This trait implements a forwarder for traversable objects. It forwards
* all calls to a different traversable, except for:
@@ -57,7 +58,7 @@ trait TraversableForwarder[+A] extends Traversable[A] {
override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) = underlying.copyToArray(xs, start, len)
override def copyToArray[B >: A](xs: Array[B], start: Int) = underlying.copyToArray(xs, start)
override def copyToArray[B >: A](xs: Array[B]) = underlying.copyToArray(xs)
- override def toArray[B >: A: ArrayTag]: Array[B] = underlying.toArray
+ override def toArray[B >: A: ClassTag]: Array[B] = underlying.toArray
override def toList: List[A] = underlying.toList
override def toIterable: Iterable[A] = underlying.toIterable
override def toSeq: Seq[A] = underlying.toSeq
diff --git a/src/library/scala/collection/generic/package.scala b/src/library/scala/collection/generic/package.scala
index e0351ebae6..85b9995f2e 100644
--- a/src/library/scala/collection/generic/package.scala
+++ b/src/library/scala/collection/generic/package.scala
@@ -1,6 +1,8 @@
package scala.collection
import generic.CanBuildFrom
+import language.higherKinds
+
package object generic {
type CanBuild[-Elem, +To] = CanBuildFrom[Nothing, Elem, To]
@@ -10,12 +12,12 @@ package object generic {
*/
type HasElem[Repr, A] = Repr => GenTraversableLike[A, Repr]
- @deprecated("use ArrayTagTraversableFactory instead", "2.10.0")
- type ClassManifestTraversableFactory[CC[X] <: Traversable[X] with GenericClassManifestTraversableTemplate[X, CC]] = ArrayTagTraversableFactory[CC]
+ @deprecated("use ClassTagTraversableFactory instead", "2.10.0")
+ type ClassManifestTraversableFactory[CC[X] <: Traversable[X] with GenericClassManifestTraversableTemplate[X, CC]] = ClassTagTraversableFactory[CC]
- @deprecated("use GenericArrayTagCompanion instead", "2.10.0")
- type GenericClassManifestCompanion[+CC[X] <: Traversable[X]] = GenericArrayTagCompanion[CC]
+ @deprecated("use GenericClassTagCompanion instead", "2.10.0")
+ type GenericClassManifestCompanion[+CC[X] <: Traversable[X]] = GenericClassTagCompanion[CC]
- @deprecated("use GenericArrayTagTraversableTemplate instead", "2.10.0")
- type GenericClassManifestTraversableTemplate[+A, +CC[X] <: Traversable[X]] = GenericArrayTagTraversableTemplate[A, CC]
+ @deprecated("use GenericClassTagTraversableTemplate instead", "2.10.0")
+ type GenericClassManifestTraversableTemplate[+A, +CC[X] <: Traversable[X]] = GenericClassTagTraversableTemplate[A, CC]
} \ No newline at end of file
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 13a0febfee..05529761d3 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -74,11 +74,22 @@ class HashMap[A, +B] extends AbstractMap[A, B]
private[collection] def computeHash(key: A) = improve(elemHashCode(key))
- protected type Merger[B1] = ((A, B1), (A, B1)) => (A, B1)
+ protected type MergeFunction[A1, B1] = ((A1, B1), (A1, B1)) => (A1, B1);
+
+ import HashMap.Merger
+
+ protected def liftMerger[A1, B1](mergef: MergeFunction[A1, B1]): Merger[A1, B1] = if (mergef == null) null else new Merger[A1, B1] {
+ self =>
+ def apply(kv1: (A1, B1), kv2: (A1, B1)): (A1, B1) = mergef(kv1, kv2)
+ val invert: Merger[A1, B1] = new Merger[A1, B1] {
+ def apply(kv1: (A1, B1), kv2: (A1, B1)): (A1, B1) = mergef(kv2, kv1)
+ def invert: Merger[A1, B1] = self
+ }
+ }
private[collection] def get0(key: A, hash: Int, level: Int): Option[B] = None
- private[collection] def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[B1]): HashMap[A, B1] =
+ private[collection] def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
new HashMap.HashMap1(key, hash, value, kv)
protected def removed0(key: A, hash: Int, level: Int): HashMap[A, B] = this
@@ -87,9 +98,25 @@ class HashMap[A, +B] extends AbstractMap[A, B]
def split: Seq[HashMap[A, B]] = Seq(this)
- def merge[B1 >: B](that: HashMap[A, B1], merger: Merger[B1] = null): HashMap[A, B1] = merge0(that, 0, merger)
-
- protected def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[B1]): HashMap[A, B1] = that
+ @deprecated("Use the `merged` method instead.", "2.10.0")
+ def merge[B1 >: B](that: HashMap[A, B1], mergef: MergeFunction[A, B1] = null): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef))
+
+ /** Creates a new map which is the merge of this and the argument hash map.
+ *
+ * Uses the specified collision resolution function if two keys are the same.
+ * The collision resolution function will always take the first argument from
+ * `this` hash map and the second from `that`.
+ *
+ * The `merged` method is on average more performant than doing a traversal and reconstructing a
+ * new immutable hash map from scratch, or `++`.
+ *
+ * @tparam B1 the value type of the other hash map
+ * @param that the other hash map
+ * @param mergef the merge function or null if the first key-value pair is to be picked
+ */
+ def merged[B1 >: B](that: HashMap[A, B1])(mergef: MergeFunction[A, B1]): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef))
+
+ protected def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = that
override def par = ParHashMap.fromTrie(this)
@@ -103,6 +130,13 @@ class HashMap[A, +B] extends AbstractMap[A, B]
* @since 2.3
*/
object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
+
+ private[immutable] abstract class Merger[A, B] {
+ def apply(kv1: (A, B), kv2: (A, B)): (A, B)
+ def invert: Merger[A, B]
+ }
+
+
/** $mapCanBuildFromInfo */
implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), HashMap[A, B]] = new MapCanBuildFrom[A, B]
def empty[A, B]: HashMap[A, B] = EmptyHashMap.asInstanceOf[HashMap[A, B]]
@@ -136,12 +170,15 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
// }
// }
- override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[B1]): HashMap[A, B1] =
+ override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
if (hash == this.hash && key == this.key ) {
if (merger eq null) {
- if(this.value.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this
+ if (this.value.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this
else new HashMap1(key, hash, value, kv)
- } else new HashMap1(key, hash, value, merger(this.kv, kv))
+ } else {
+ val nkv = merger(this.kv, kv)
+ new HashMap1(nkv._1, hash, nkv._2, nkv)
+ }
} else {
var thatindex = (hash >>> level) & 0x1f
var thisindex = (this.hash >>> level) & 0x1f
@@ -180,8 +217,8 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
override def foreach[U](f: ((A, B)) => U): Unit = f(ensurePair)
// this method may be called multiple times in a multithreaded environment, but that's ok
private[HashMap] def ensurePair: (A,B) = if (kv ne null) kv else { kv = (key, value); kv }
- protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[B1]): HashMap[A, B1] = {
- that.updated0(key, hash, level, value, kv, merger)
+ protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = {
+ that.updated0(key, hash, level, value, kv, if (merger ne null) merger.invert else null)
}
}
@@ -193,7 +230,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
override def get0(key: A, hash: Int, level: Int): Option[B] =
if (hash == this.hash) kvs.get(key) else None
- override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[B1]): HashMap[A, B1] =
+ override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
if (hash == this.hash) {
if ((merger eq null) || !kvs.contains(key)) new HashMapCollision1(hash, kvs.updated(key, value))
else new HashMapCollision1(hash, kvs + merger((key, kvs(key)), kv))
@@ -221,7 +258,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
def newhm(lm: ListMap[A, B @uV]) = new HashMapCollision1(hash, lm)
List(newhm(x), newhm(y))
}
- protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[B1]): HashMap[A, B1] = {
+ protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = {
// this can be made more efficient by passing the entire ListMap at once
var m = that
for (p <- kvs) m = m.updated0(p._1, this.hash, level, p._2, p, merger)
@@ -268,7 +305,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
None
}
- override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[B1]): HashMap[A, B1] = {
+ override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] = {
val index = (hash >>> level) & 0x1f
val mask = (1 << index)
val offset = Integer.bitCount(bitmap & (mask-1))
@@ -380,7 +417,7 @@ time { mNew.iterator.foreach( p => ()) }
} else elems(0).split
}
- protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[B1]): HashMap[A, B1] = that match {
+ protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = that match {
case hm: HashMap1[_, _] =>
this.updated0(hm.key, hm.hash, level, hm.value.asInstanceOf[B1], hm.kv, merger)
case hm: HashTrieMap[_, _] =>
@@ -440,7 +477,7 @@ time { mNew.iterator.foreach( p => ()) }
}
new HashTrieMap[A, B1](this.bitmap | that.bitmap, merged, totalelems)
- case hm: HashMapCollision1[_, _] => that.merge0(this, level, merger)
+ case hm: HashMapCollision1[_, _] => that.merge0(this, level, if (merger ne null) merger.invert else null)
case hm: HashMap[_, _] => this
case _ => sys.error("section supposed to be unreachable.")
}
diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala
index 4c82d99c03..5662a11f93 100644
--- a/src/library/scala/collection/immutable/NumericRange.scala
+++ b/src/library/scala/collection/immutable/NumericRange.scala
@@ -124,7 +124,21 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
if (idx < 0 || idx >= length) throw new IndexOutOfBoundsException(idx.toString)
else locationAfterN(idx)
}
-
+
+ import NumericRange.defaultOrdering
+
+ override def min[T1 >: T](implicit ord: Ordering[T1]): T =
+ if (ord eq defaultOrdering(num)) {
+ if (num.signum(step) > 0) start
+ else last
+ } else super.min(ord)
+
+ override def max[T1 >: T](implicit ord: Ordering[T1]): T =
+ if (ord eq defaultOrdering(num)) {
+ if (num.signum(step) > 0) last
+ else start
+ } else super.max(ord)
+
// Motivated by the desire for Double ranges with BigDecimal precision,
// we need some way to map a Range and get another Range. This can't be
// done in any fully general way because Ranges are not arbitrary
@@ -199,6 +213,7 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
/** A companion object for numeric ranges.
*/
object NumericRange {
+
/** Calculates the number of elements in a range given start, end, step, and
* whether or not it is inclusive. Throws an exception if step == 0 or
* the number of elements exceeds the maximum Int.
@@ -257,5 +272,18 @@ object NumericRange {
new Exclusive(start, end, step)
def inclusive[T](start: T, end: T, step: T)(implicit num: Integral[T]): Inclusive[T] =
new Inclusive(start, end, step)
+
+ private[collection] val defaultOrdering = Map[Numeric[_], Ordering[_]](
+ Numeric.BigIntIsIntegral -> Ordering.BigInt,
+ Numeric.IntIsIntegral -> Ordering.Int,
+ Numeric.ShortIsIntegral -> Ordering.Short,
+ Numeric.ByteIsIntegral -> Ordering.Byte,
+ Numeric.CharIsIntegral -> Ordering.Char,
+ Numeric.LongIsIntegral -> Ordering.Long,
+ Numeric.FloatAsIfIntegral -> Ordering.Float,
+ Numeric.DoubleAsIfIntegral -> Ordering.Double,
+ Numeric.BigDecimalAsIfIntegral -> Ordering.BigDecimal
+ )
+
}
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index 94953ce38b..7d373b7b39 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -13,6 +13,7 @@ package immutable
import java.io._
import scala.util.matching.Regex
+import reflect.ClassTag
/** The `PagedSeq` object defines a lazy implementations of
* a random access sequence.
@@ -25,7 +26,7 @@ object PagedSeq {
final val UndeterminedEnd = Int.MaxValue
/** Constructs a paged sequence from an iterator */
- def fromIterator[T: ArrayTag](source: Iterator[T]): PagedSeq[T] =
+ def fromIterator[T: ClassTag](source: Iterator[T]): PagedSeq[T] =
new PagedSeq[T]((data: Array[T], start: Int, len: Int) => {
var i = 0
while (i < len && source.hasNext) {
@@ -36,7 +37,7 @@ object PagedSeq {
})
/** Constructs a paged sequence from an iterable */
- def fromIterable[T: ArrayTag](source: Iterable[T]): PagedSeq[T] =
+ def fromIterable[T: ClassTag](source: Iterable[T]): PagedSeq[T] =
fromIterator(source.iterator)
/** Constructs a paged character sequence from a string iterator */
@@ -115,7 +116,7 @@ import PagedSeq._
* It returns the number of elements produced, or -1 if end of logical input stream was reached
* before reading any element.
*
- * @tparam T the type of the elements contained in this paged sequence, with an `ArrayTag` context bound.
+ * @tparam T the type of the elements contained in this paged sequence, with an `ClassTag` context bound.
*
* @author Martin Odersky
* @since 2.7
@@ -124,7 +125,7 @@ import PagedSeq._
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
-class PagedSeq[T: ArrayTag] protected(
+class PagedSeq[T: ClassTag] protected(
more: (Array[T], Int, Int) => Int,
first1: Page[T],
start: Int,
@@ -205,7 +206,7 @@ extends scala.collection.AbstractSeq[T]
/** Page containing up to PageSize characters of the input sequence.
*/
-private class Page[T: ArrayTag](val num: Int) {
+private class Page[T: ClassTag](val num: Int) {
private final val PageSize = 4096
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 033331b58b..7607837491 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -78,7 +78,19 @@ extends collection.AbstractSeq[Int]
final val terminalElement = start + numRangeElements * step
override def last = if (isEmpty) Nil.last else lastElement
-
+
+ override def min[A1 >: Int](implicit ord: Ordering[A1]): Int =
+ if (ord eq Ordering.Int) {
+ if (step > 0) start
+ else last
+ } else super.min(ord)
+
+ override def max[A1 >: Int](implicit ord: Ordering[A1]): Int =
+ if (ord eq Ordering.Int) {
+ if (step > 0) last
+ else start
+ } else super.max(ord)
+
protected def copy(start: Int, end: Int, step: Int): Range = new Range(start, end, step)
/** Create a new range with the `start` and `end` values of this range and
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index e41b17a5e8..af7662d2e0 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -13,6 +13,7 @@ import generic._
import mutable.Builder
import scala.util.matching.Regex
import scala.math.ScalaNumber
+import reflect.ClassTag
/** A companion object for the `StringLike` containing some constants.
* @since 2.8
@@ -239,7 +240,7 @@ self =>
else
throw new IllegalArgumentException("For input string: \"null\"")
- override def toArray[B >: Char : ArrayTag]: Array[B] =
+ override def toArray[B >: Char : ClassTag]: Array[B] =
toString.toCharArray.asInstanceOf[Array[B]]
private def unwrapArg(arg: Any): AnyRef = arg match {
diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala
index 293e85a97e..0eb96de6d7 100644
--- a/src/library/scala/collection/mutable/ArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/ArrayBuilder.scala
@@ -12,7 +12,7 @@ package scala.collection
package mutable
import generic._
-import scala.reflect.ArrayTag
+import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime
/** A builder class for arrays.
@@ -31,13 +31,12 @@ object ArrayBuilder {
/** Creates a new arraybuilder of type `T`.
*
- * @tparam T type of the elements for the array builder, with a `ArrayTag` context bound.
+ * @tparam T type of the elements for the array builder, with a `ClassTag` context bound.
* @return a new empty array builder.
*/
- def make[T: ArrayTag](): ArrayBuilder[T] = {
- val tag = implicitly[ArrayTag[T]]
- val erasure = ScalaRunTime.arrayElementClass(tag)
- erasure match {
+ def make[T: ClassTag](): ArrayBuilder[T] = {
+ val tag = implicitly[ClassTag[T]]
+ tag.runtimeClass match {
case java.lang.Byte.TYPE => new ArrayBuilder.ofByte().asInstanceOf[ArrayBuilder[T]]
case java.lang.Short.TYPE => new ArrayBuilder.ofShort().asInstanceOf[ArrayBuilder[T]]
case java.lang.Character.TYPE => new ArrayBuilder.ofChar().asInstanceOf[ArrayBuilder[T]]
@@ -47,15 +46,15 @@ object ArrayBuilder {
case java.lang.Double.TYPE => new ArrayBuilder.ofDouble().asInstanceOf[ArrayBuilder[T]]
case java.lang.Boolean.TYPE => new ArrayBuilder.ofBoolean().asInstanceOf[ArrayBuilder[T]]
case java.lang.Void.TYPE => new ArrayBuilder.ofUnit().asInstanceOf[ArrayBuilder[T]]
- case _ => new ArrayBuilder.ofRef[T with AnyRef]()(tag.asInstanceOf[ArrayTag[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]]
+ case _ => new ArrayBuilder.ofRef[T with AnyRef]()(tag.asInstanceOf[ClassTag[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]]
}
}
/** A class for array builders for arrays of reference types.
*
- * @tparam T type of elements for the array builder, subtype of `AnyRef` with a `ArrayTag` context bound.
+ * @tparam T type of elements for the array builder, subtype of `AnyRef` with a `ClassTag` context bound.
*/
- class ofRef[T <: AnyRef : ArrayTag] extends ArrayBuilder[T] {
+ class ofRef[T <: AnyRef : ClassTag] extends ArrayBuilder[T] {
private var elems: Array[T] = _
private var capacity: Int = 0
diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala
index 0807721f7d..01636eb54e 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -12,7 +12,7 @@ package scala.collection
package mutable
import compat.Platform.arraycopy
-import scala.reflect.ArrayTag
+import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime._
import parallel.mutable.ParArray
@@ -47,8 +47,8 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
Array.copy(repr, 0, xs, start, l)
}
- override def toArray[U >: T : ArrayTag]: Array[U] = {
- val thatElementClass = arrayElementClass(implicitly[ArrayTag[U]])
+ override def toArray[U >: T : ClassTag]: Array[U] = {
+ val thatElementClass = arrayElementClass(implicitly[ClassTag[U]])
if (elementClass eq thatElementClass)
repr.asInstanceOf[Array[U]]
else
@@ -64,7 +64,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
* @param asTrav A function that converts elements of this array to rows - arrays of type `U`.
* @return An array obtained by concatenating rows of this array.
*/
- def flatten[U, To](implicit asTrav: T => collection.Traversable[U], m: ArrayTag[U]): Array[U] = {
+ def flatten[U, To](implicit asTrav: T => collection.Traversable[U], m: ClassTag[U]): Array[U] = {
val b = Array.newBuilder[U]
b.sizeHint(map{case is: collection.IndexedSeq[_] => is.size case _ => 0}.sum)
for (xs <- this)
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index ed5f39f21b..040a0e2aa7 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -10,6 +10,7 @@ package scala.collection
package mutable
import generic._
+import reflect.ClassTag
/** Factory object for the `ArrayStack` class.
*
@@ -21,7 +22,7 @@ object ArrayStack extends SeqFactory[ArrayStack] {
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, ArrayStack[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
def newBuilder[A]: Builder[A, ArrayStack[A]] = new ArrayStack[A]
def empty: ArrayStack[Nothing] = new ArrayStack()
- def apply[A: ArrayTag](elems: A*): ArrayStack[A] = {
+ def apply[A: ClassTag](elems: A*): ArrayStack[A] = {
val els: Array[AnyRef] = elems.reverseMap(_.asInstanceOf[AnyRef])(breakOut)
if (els.length == 0) new ArrayStack()
else new ArrayStack[A](els, els.length)
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index 4070174902..f6d4cc31b6 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -397,9 +397,7 @@ private[collection] object FlatHashTable {
//h = h + (h << 4)
//h ^ (h >>> 10)
- var i = hcode * 0x9e3775cd
- i = java.lang.Integer.reverseBytes(i)
- val improved = i * 0x9e3775cd
+ val improved = util.hashing.byteswap32(hcode)
// for the remainder, see SI-5293
// to ensure that different bits are used for different hash tables, we have to rotate based on the seed
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala
index c307e6dcab..97e794f06e 100644
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -401,12 +401,7 @@ private[collection] object HashTable {
*
* For performance reasons, we avoid this improvement.
* */
- var i = hcode * 0x9e3775cd
- i = java.lang.Integer.reverseBytes(i)
- i = i * 0x9e3775cd
- // a slower alternative for byte reversal:
- // i = (i << 16) | (i >> 16)
- // i = ((i >> 8) & 0x00ff00ff) | ((i << 8) & 0xff00ff00)
+ val i = util.hashing.byteswap32(hcode)
/* Jenkins hash
* for range 0-10000, output has the msb set to zero */
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index 12dee45bae..af55a01ed6 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -161,10 +161,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
*/
def clear(): Unit = { resarr.p_size0 = 1 }
- /** Returns an iterator which yields all the elements of the priority
- * queue in descending priority order.
+ /** Returns an iterator which yields all the elements.
*
- * @return an iterator over all elements sorted in descending order.
+ * Note: The order of elements returned is undefined.
+ * If you want to traverse the elements in priority queue
+ * order, use `clone().dequeueAll.iterator`.
+ *
+ * @return an iterator over all the elements.
*/
override def iterator: Iterator[A] = new AbstractIterator[A] {
private var i = 1
@@ -176,7 +179,6 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
}
}
-
/** Returns the reverse of this queue. The priority queue that gets
* returned will have an inversed ordering - if for some elements
* `x` and `y` the original queue's ordering
@@ -198,6 +200,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
revq
}
+ /** Returns an iterator which yields all the elements in the reverse order
+ * than that returned by the method `iterator`.
+ *
+ * Note: The order of elements returned is undefined.
+ *
+ * @return an iterator over all elements sorted in descending order.
+ */
def reverseIterator: Iterator[A] = new AbstractIterator[A] {
private var i = resarr.p_size0 - 1
def hasNext: Boolean = i >= 1
@@ -217,6 +226,8 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
throw new UnsupportedOperationException("unsuitable as hash key")
/** Returns a regular queue containing the same elements.
+ *
+ * Note: the order of elements is undefined.
*/
def toQueue: Queue[A] = new Queue[A] ++= this.iterator
@@ -225,6 +236,13 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
* @return the string representation of this queue.
*/
override def toString() = toList.mkString("PriorityQueue(", ", ", ")")
+
+ /** Converts this $coll to a list.
+ *
+ * Note: the order of elements is undefined.
+ *
+ * @return a list containing all elements of this $coll.
+ */
override def toList = this.iterator.toList
/** This method clones the priority queue.
diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala
index 8884f03bbd..9eadfe4045 100644
--- a/src/library/scala/collection/mutable/StackProxy.scala
+++ b/src/library/scala/collection/mutable/StackProxy.scala
@@ -54,6 +54,11 @@ trait StackProxy[A] extends Stack[A] with Proxy {
this
}
+ override def push(elem: A): this.type = {
+ self.push(elem)
+ this
+ }
+
/** Returns the top element of the stack. This method will not remove
* the element from the stack. An error is signaled if there is no
* element on the stack.
diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala
index cd76c7de4e..6785aba10d 100644
--- a/src/library/scala/collection/mutable/UnrolledBuffer.scala
+++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala
@@ -12,6 +12,7 @@ import collection.AbstractIterator
import collection.Iterator
import collection.generic._
import annotation.tailrec
+import reflect.ClassTag
/** A buffer that stores elements in an unrolled linked list.
*
@@ -41,11 +42,11 @@ import annotation.tailrec
*
*/
@SerialVersionUID(1L)
-class UnrolledBuffer[T](implicit val tag: ArrayTag[T])
+class UnrolledBuffer[T](implicit val tag: ClassTag[T])
extends collection.mutable.AbstractBuffer[T]
with collection.mutable.Buffer[T]
with collection.mutable.BufferLike[T, UnrolledBuffer[T]]
- with GenericArrayTagTraversableTemplate[T, UnrolledBuffer]
+ with GenericClassTagTraversableTemplate[T, UnrolledBuffer]
with collection.mutable.Builder[T, UnrolledBuffer[T]]
with Serializable
{
@@ -67,7 +68,7 @@ extends collection.mutable.AbstractBuffer[T]
private[collection] def calcNextLength(sz: Int) = sz
- def arrayTagCompanion = UnrolledBuffer
+ def classTagCompanion = UnrolledBuffer
/** Concatenates the targer unrolled buffer to this unrolled buffer.
*
@@ -179,15 +180,17 @@ extends collection.mutable.AbstractBuffer[T]
}
}
+ override def clone(): UnrolledBuffer[T] = new UnrolledBuffer[T] ++= this
+
override def stringPrefix = "UnrolledBuffer"
}
-object UnrolledBuffer extends ArrayTagTraversableFactory[UnrolledBuffer] {
+object UnrolledBuffer extends ClassTagTraversableFactory[UnrolledBuffer] {
/** $genericCanBuildFromInfo */
- implicit def canBuildFrom[T](implicit t: ArrayTag[T]): CanBuildFrom[Coll, T, UnrolledBuffer[T]] =
+ implicit def canBuildFrom[T](implicit t: ClassTag[T]): CanBuildFrom[Coll, T, UnrolledBuffer[T]] =
new GenericCanBuildFrom[T]
- def newBuilder[T](implicit t: ArrayTag[T]): Builder[T, UnrolledBuffer[T]] = new UnrolledBuffer[T]
+ def newBuilder[T](implicit t: ClassTag[T]): Builder[T, UnrolledBuffer[T]] = new UnrolledBuffer[T]
val waterline = 50
val waterlineDelim = 100
@@ -195,7 +198,7 @@ object UnrolledBuffer extends ArrayTagTraversableFactory[UnrolledBuffer] {
/** Unrolled buffer node.
*/
- class Unrolled[T: ArrayTag] private[collection] (var size: Int, var array: Array[T], var next: Unrolled[T], val buff: UnrolledBuffer[T] = null) {
+ class Unrolled[T: ClassTag] private[collection] (var size: Int, var array: Array[T], var next: Unrolled[T], val buff: UnrolledBuffer[T] = null) {
private[collection] def this() = this(0, new Array[T](unrolledlength), null, null)
private[collection] def this(b: UnrolledBuffer[T]) = this(0, new Array[T](unrolledlength), null, b)
diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala
index 86317819a1..fec0fbaa3c 100644
--- a/src/library/scala/collection/mutable/WrappedArray.scala
+++ b/src/library/scala/collection/mutable/WrappedArray.scala
@@ -11,7 +11,7 @@
package scala.collection
package mutable
-import scala.reflect.ArrayTag
+import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime._
import scala.collection.generic._
import scala.collection.parallel.mutable.ParArray
@@ -42,7 +42,7 @@ extends AbstractSeq[T]
override protected[this] def toCollection(repr: WrappedArray[T]): WrappedArray[T] = repr
/** The tag of the element type */
- def elemTag: ArrayTag[T]
+ def elemTag: ClassTag[T]
@deprecated("use elemTag instead", "2.10.0")
def elemManifest: ClassManifest[T] = ClassManifest.fromClass[T](arrayElementClass(elemTag).asInstanceOf[Class[T]])
@@ -64,8 +64,8 @@ extends AbstractSeq[T]
private def elementClass: Class[_] =
arrayElementClass(repr.getClass)
- override def toArray[U >: T : ArrayTag]: Array[U] = {
- val thatElementClass = arrayElementClass(implicitly[ArrayTag[U]])
+ override def toArray[U >: T : ClassTag]: Array[U] = {
+ val thatElementClass = arrayElementClass(implicitly[ClassTag[U]])
if (elementClass eq thatElementClass)
array.asInstanceOf[Array[U]]
else
@@ -110,7 +110,7 @@ object WrappedArray {
case x: Array[Unit] => new ofUnit(x)
}).asInstanceOf[WrappedArray[T]]
- implicit def canBuildFrom[T](implicit m: ArrayTag[T]): CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] =
+ implicit def canBuildFrom[T](implicit m: ClassTag[T]): CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] =
new CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] {
def apply(from: WrappedArray[_]): Builder[T, WrappedArray[T]] =
ArrayBuilder.make[T]()(m) mapResult WrappedArray.make[T]
diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
index 99a0b0ede3..b7db8d1245 100644
--- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
@@ -12,7 +12,7 @@ package scala.collection
package mutable
import generic._
-import scala.reflect.ArrayTag
+import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime._
/** A builder class for arrays.
@@ -22,18 +22,18 @@ import scala.runtime.ScalaRunTime._
*
* @since 2.8
*/
-class WrappedArrayBuilder[A](tag: ArrayTag[A]) extends Builder[A, WrappedArray[A]] {
+class WrappedArrayBuilder[A](tag: ClassTag[A]) extends Builder[A, WrappedArray[A]] {
@deprecated("use tag instead", "2.10.0")
- val manifest: ArrayTag[A] = tag
+ val manifest: ClassTag[A] = tag
private var elems: WrappedArray[A] = _
private var capacity: Int = 0
private var size: Int = 0
private def mkArray(size: Int): WrappedArray[A] = {
- val erasure = arrayElementClass(tag)
- val newelems = erasure match {
+ val runtimeClass = arrayElementClass(tag)
+ val newelems = runtimeClass match {
case java.lang.Byte.TYPE => new WrappedArray.ofByte(new Array[Byte](size)).asInstanceOf[WrappedArray[A]]
case java.lang.Short.TYPE => new WrappedArray.ofShort(new Array[Short](size)).asInstanceOf[WrappedArray[A]]
case java.lang.Character.TYPE => new WrappedArray.ofChar(new Array[Char](size)).asInstanceOf[WrappedArray[A]]
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 321f259f5d..a447f1b5e4 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -24,6 +24,7 @@ import scala.collection.GenIterable
import scala.collection.GenTraversableOnce
import scala.collection.GenTraversable
import immutable.HashMapCombiner
+import reflect.{ClassTag, classTag}
import java.util.concurrent.atomic.AtomicBoolean
@@ -183,25 +184,25 @@ self: ParIterableLike[T, Repr, Sequential] =>
def hasDefiniteSize = true
def isEmpty = size == 0
-
+
def nonEmpty = size != 0
-
+
def head = iterator.next
-
+
def headOption = if (nonEmpty) Some(head) else None
-
+
def tail = drop(1)
-
+
def last = {
var lst = head
for (x <- this.seq) lst = x
lst
}
-
+
def lastOption = if (nonEmpty) Some(last) else None
-
+
def init = take(size - 1)
-
+
/** Creates a new parallel iterator used to traverse the elements of this parallel collection.
* This iterator is more specific than the iterator of the returned by `iterator`, and augmented
* with additional accessor and transformer methods.
@@ -303,7 +304,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected implicit def builder2ops[Elem, To](cb: Builder[Elem, To]) = new BuilderOps[Elem, To] {
def ifIs[Cmb](isbody: Cmb => Unit) = new Otherwise[Cmb] {
def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]) {
- if (cb.getClass == t.erasure) isbody(cb.asInstanceOf[Cmb]) else notbody
+ if (cb.getClass == t.runtimeClass) isbody(cb.asInstanceOf[Cmb]) else notbody
}
}
def isCombiner = cb.isInstanceOf[Combiner[_, _]]
@@ -822,7 +823,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def size = splitter.remaining
}
- override def toArray[U >: T: ArrayTag]: Array[U] = {
+ override def toArray[U >: T: ClassTag]: Array[U] = {
val arr = new Array[U](size)
copyToArray(arr)
arr
diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala
index 29d84408db..6889d8b472 100644
--- a/src/library/scala/collection/parallel/mutable/ParArray.scala
+++ b/src/library/scala/collection/parallel/mutable/ParArray.scala
@@ -26,7 +26,7 @@ import scala.collection.parallel.CHECK_RATE
import scala.collection.mutable.ArraySeq
import scala.collection.mutable.Builder
import scala.collection.GenTraversableOnce
-
+import scala.reflect.ClassTag
@@ -706,7 +706,7 @@ object ParArray extends ParFactory[ParArray] {
case _ => new ParArray[T](new ExposedArraySeq[T](runtime.ScalaRunTime.toObjectArray(arr), sz))
}
- def createFromCopy[T <: AnyRef : ArrayTag](arr: Array[T]): ParArray[T] = {
+ def createFromCopy[T <: AnyRef : ClassTag](arr: Array[T]): ParArray[T] = {
val newarr = new Array[T](arr.length)
Array.copy(arr, 0, newarr, 0, arr.length)
handoff(newarr)
diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
index 43d40776bf..9648791502 100644
--- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
@@ -21,12 +21,12 @@ import scala.collection.parallel.TaskSupport
import scala.collection.parallel.unsupportedop
import scala.collection.parallel.Combiner
import scala.collection.parallel.Task
+import scala.reflect.ClassTag
-
-private[mutable] class DoublingUnrolledBuffer[T](implicit t: ArrayTag[T]) extends UnrolledBuffer[T]()(t) {
+private[mutable] class DoublingUnrolledBuffer[T](implicit t: ClassTag[T]) extends UnrolledBuffer[T]()(t) {
override def calcNextLength(sz: Int) = if (sz < 10000) sz * 2 else sz
protected override def newUnrolled = new Unrolled[T](0, new Array[T](4), null, this)
}
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 4df2bb63af..2a52d0ac0b 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -25,6 +25,7 @@ import scala.annotation.tailrec
import scala.collection.mutable.Stack
import scala.collection.mutable.Builder
import scala.collection.generic.CanBuildFrom
+import scala.reflect.ClassTag
import language.higherKinds
@@ -82,9 +83,29 @@ import language.higherKinds
* {{{
* f flatMap { (x: Int) => g map { (y: Int) => x + y } }
* }}}
+ *
+ * @define callbackInContext
+ * The provided callback always runs in the provided implicit
+ *`ExecutionContext`, though there is no guarantee that the
+ * `execute()` method on the `ExecutionContext` will be called once
+ * per callback or that `execute()` will be called in the current
+ * thread. That is, the implementation may run multiple callbacks
+ * in a batch within a single `execute()` and it may run
+ * `execute()` either immediately or asynchronously.
*/
trait Future[+T] extends Awaitable[T] {
+ // The executor within the lexical scope
+ // of the Future trait. Note that this will
+ // (modulo bugs) _never_ execute a callback
+ // other than those below in this same file.
+ // As a nice side benefit, having this implicit
+ // here forces an ambiguity in those methods
+ // that also have an executor parameter, which
+ // keeps us from accidentally forgetting to use
+ // the executor parameter.
+ private implicit def internalExecutor: ExecutionContext = Future.InternalCallbackExecutor
+
/* Callbacks */
/** When this future is completed successfully (i.e. with a value),
@@ -95,11 +116,12 @@ trait Future[+T] extends Awaitable[T] {
* this will either be applied immediately or be scheduled asynchronously.
*
* $multipleCallbacks
+ * $callbackInContext
*/
- def onSuccess[U](pf: PartialFunction[T, U]): Unit = onComplete {
+ def onSuccess[U](pf: PartialFunction[T, U])(implicit executor: ExecutionContext): Unit = onComplete {
case Right(v) if pf isDefinedAt v => pf(v)
case _ =>
- }
+ }(executor)
/** When this future is completed with a failure (i.e. with a throwable),
* apply the provided callback to the throwable.
@@ -112,11 +134,12 @@ trait Future[+T] extends Awaitable[T] {
* Will not be called in case that the future is completed with a value.
*
* $multipleCallbacks
+ * $callbackInContext
*/
- def onFailure[U](callback: PartialFunction[Throwable, U]): Unit = onComplete {
+ def onFailure[U](callback: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Unit = onComplete {
case Left(t) if (isFutureThrowable(t) && callback.isDefinedAt(t)) => callback(t)
case _ =>
- }
+ }(executor)
/** When this future is completed, either through an exception, or a value,
* apply the provided function.
@@ -125,8 +148,9 @@ trait Future[+T] extends Awaitable[T] {
* this will either be applied immediately or be scheduled asynchronously.
*
* $multipleCallbacks
+ * $callbackInContext
*/
- def onComplete[U](func: Either[Throwable, T] => U): Unit
+ def onComplete[U](func: Either[Throwable, T] => U)(implicit executor: ExecutionContext): Unit
/* Miscellaneous */
@@ -182,10 +206,10 @@ trait Future[+T] extends Awaitable[T] {
*
* Will not be called if the future fails.
*/
- def foreach[U](f: T => U): Unit = onComplete {
+ def foreach[U](f: T => U)(implicit executor: ExecutionContext): Unit = onComplete {
case Right(r) => f(r)
case _ => // do nothing
- }
+ }(executor)
/** Creates a new future by applying the 's' function to the successful result of
* this future, or the 'f' function to the failed result. If there is any non-fatal
@@ -198,7 +222,7 @@ trait Future[+T] extends Awaitable[T] {
* the returned future
* @return a future that will be completed with the transformed value
*/
- def transform[S](s: T => S, f: Throwable => Throwable): Future[S] = {
+ def transform[S](s: T => S, f: Throwable => Throwable)(implicit executor: ExecutionContext): Future[S] = {
val p = Promise[S]()
onComplete {
@@ -211,7 +235,7 @@ trait Future[+T] extends Awaitable[T] {
} catch {
case NonFatal(t) => p failure t
}
- }
+ }(executor)
p.future
}
@@ -222,7 +246,7 @@ trait Future[+T] extends Awaitable[T] {
*
* $forComprehensionExamples
*/
- def map[S](f: T => S): Future[S] = { // transform(f, identity)
+ def map[S](f: T => S)(implicit executor: ExecutionContext): Future[S] = { // transform(f, identity)
val p = Promise[S]()
onComplete {
@@ -235,7 +259,7 @@ trait Future[+T] extends Awaitable[T] {
} catch {
case NonFatal(t) => p failure t
}
- }
+ }(executor)
p.future
}
@@ -247,21 +271,21 @@ trait Future[+T] extends Awaitable[T] {
*
* $forComprehensionExamples
*/
- def flatMap[S](f: T => Future[S]): Future[S] = {
+ def flatMap[S](f: T => Future[S])(implicit executor: ExecutionContext): Future[S] = {
val p = Promise[S]()
onComplete {
case l: Left[_, _] => p complete l.asInstanceOf[Left[Throwable, S]]
case Right(v) =>
try {
- f(v) onComplete {
+ f(v).onComplete({
case l: Left[_, _] => p complete l.asInstanceOf[Left[Throwable, S]]
case Right(v) => p success v
- }
+ })(internalExecutor)
} catch {
case NonFatal(t) => p failure t
}
- }
+ }(executor)
p.future
}
@@ -282,7 +306,7 @@ trait Future[+T] extends Awaitable[T] {
* await(h, 0) // throw a NoSuchElementException
* }}}
*/
- def filter(pred: T => Boolean): Future[T] = {
+ def filter(pred: T => Boolean)(implicit executor: ExecutionContext): Future[T] = {
val p = Promise[T]()
onComplete {
@@ -294,14 +318,14 @@ trait Future[+T] extends Awaitable[T] {
} catch {
case NonFatal(t) => p failure t
}
- }
+ }(executor)
p.future
}
/** Used by for-comprehensions.
*/
- final def withFilter(p: T => Boolean): Future[T] = filter(p)
+ final def withFilter(p: T => Boolean)(implicit executor: ExecutionContext): Future[T] = filter(p)(executor)
// final def withFilter(p: T => Boolean) = new FutureWithFilter[T](this, p)
// final class FutureWithFilter[+S](self: Future[S], p: S => Boolean) {
@@ -331,7 +355,7 @@ trait Future[+T] extends Awaitable[T] {
* await(h, 0) // throw a NoSuchElementException
* }}}
*/
- def collect[S](pf: PartialFunction[T, S]): Future[S] = {
+ def collect[S](pf: PartialFunction[T, S])(implicit executor: ExecutionContext): Future[S] = {
val p = Promise[S]()
onComplete {
@@ -343,7 +367,7 @@ trait Future[+T] extends Awaitable[T] {
} catch {
case NonFatal(t) => p failure t
}
- }
+ }(executor)
p.future
}
@@ -360,7 +384,7 @@ trait Future[+T] extends Awaitable[T] {
* future (6 / 2) recover { case e: ArithmeticException ⇒ 0 } // result: 3
* }}}
*/
- def recover[U >: T](pf: PartialFunction[Throwable, U]): Future[U] = {
+ def recover[U >: T](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U] = {
val p = Promise[U]()
onComplete {
@@ -370,7 +394,7 @@ trait Future[+T] extends Awaitable[T] {
case NonFatal(t) => p failure t
}
case otherwise => p complete otherwise
- }
+ }(executor)
p.future
}
@@ -388,7 +412,7 @@ trait Future[+T] extends Awaitable[T] {
* future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue
* }}}
*/
- def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]]): Future[U] = {
+ def recoverWith[U >: T](pf: PartialFunction[Throwable, Future[U]])(implicit executor: ExecutionContext): Future[U] = {
val p = Promise[U]()
onComplete {
@@ -399,7 +423,7 @@ trait Future[+T] extends Awaitable[T] {
case NonFatal(t) => p failure t
}
case otherwise => p complete otherwise
- }
+ }(executor)
p.future
}
@@ -466,7 +490,7 @@ trait Future[+T] extends Awaitable[T] {
case l: Left[_, _] => p complete l.asInstanceOf[Left[Throwable, S]]
case Right(t) =>
p complete (try {
- Right(boxedType(tag.erasure).cast(t).asInstanceOf[S])
+ Right(boxedType(tag.runtimeClass).cast(t).asInstanceOf[S])
} catch {
case e: ClassCastException => Left(e)
})
@@ -498,12 +522,12 @@ trait Future[+T] extends Awaitable[T] {
* }
* }}}
*/
- def andThen[U](pf: PartialFunction[Either[Throwable, T], U]): Future[T] = {
+ def andThen[U](pf: PartialFunction[Either[Throwable, T], U])(implicit executor: ExecutionContext): Future[T] = {
val p = Promise[T]()
onComplete {
case r => try if (pf isDefinedAt r) pf(r) finally p complete r
- }
+ }(executor)
p.future
}
@@ -656,6 +680,33 @@ object Future {
for (r <- fr; b <- fb) yield (r += b)
}.map(_.result)
+ // This is used to run callbacks which are internal
+ // to scala.concurrent; our own callbacks are only
+ // ever used to eventually run another callback,
+ // and that other callback will have its own
+ // executor because all callbacks come with
+ // an executor. Our own callbacks never block
+ // and have no "expected" exceptions.
+ // As a result, this executor can do nothing;
+ // some other executor will always come after
+ // it (and sometimes one will be before it),
+ // and those will be performing the "real"
+ // dispatch to code outside scala.concurrent.
+ // Because this exists, ExecutionContext.defaultExecutionContext
+ // isn't instantiated by Future internals, so
+ // if some code for some reason wants to avoid
+ // ever starting up the default context, it can do so
+ // by just not ever using it itself. scala.concurrent
+ // doesn't need to create defaultExecutionContext as
+ // a side effect.
+ private[concurrent] object InternalCallbackExecutor extends ExecutionContext {
+ def execute(runnable: Runnable): Unit =
+ runnable.run()
+ def internalBlockingCall[T](awaitable: Awaitable[T], atMost: Duration): T =
+ throw new IllegalStateException("bug in scala.concurrent, called blocking() from internal callback")
+ def reportFailure(t: Throwable): Unit =
+ throw new IllegalStateException("problem in scala.concurrent internal callback", t)
+ }
}
diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala
index 2e9de4a0d0..578642966f 100644
--- a/src/library/scala/concurrent/Promise.scala
+++ b/src/library/scala/concurrent/Promise.scala
@@ -25,6 +25,11 @@ package scala.concurrent
*/
trait Promise[T] {
+ // used for internal callbacks defined in
+ // the lexical scope of this trait;
+ // _never_ for application callbacks.
+ private implicit def internalExecutor: ExecutionContext = Future.InternalCallbackExecutor
+
/** Future containing the value of this promise.
*/
def future: Future[T]
@@ -106,26 +111,23 @@ object Promise {
/** Creates a promise object which can be completed with a value.
*
* @tparam T the type of the value in the promise
- * @param executor the execution context on which the promise is created on
* @return the newly created `Promise` object
*/
- def apply[T]()(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.DefaultPromise[T]()
+ def apply[T](): Promise[T] = new impl.Promise.DefaultPromise[T]()
/** Creates an already completed Promise with the specified exception.
*
* @tparam T the type of the value in the promise
- * @param executor the execution context on which the promise is created on
* @return the newly created `Promise` object
*/
- def failed[T](exception: Throwable)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Left(exception))
+ def failed[T](exception: Throwable): Promise[T] = new impl.Promise.KeptPromise[T](Left(exception))
/** Creates an already completed Promise with the specified result.
*
* @tparam T the type of the value in the promise
- * @param executor the execution context on which the promise is created on
* @return the newly created `Promise` object
*/
- def successful[T](result: T)(implicit executor: ExecutionContext): Promise[T] = new impl.Promise.KeptPromise[T](Right(result))
+ def successful[T](result: T): Promise[T] = new impl.Promise.KeptPromise[T](Right(result))
}
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index 1083a93439..7549bf8314 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -43,17 +43,31 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
}
}
}
-
- def createExecutorService: ExecutorService = try { new ForkJoinPool(
- Runtime.getRuntime.availableProcessors(), //FIXME from config
- forkJoinPoolThreadFactory,
- null, //FIXME we should have an UncaughtExceptionHandler, see what Akka does
- true) //FIXME I really think this should be async...
+
+ def createExecutorService: ExecutorService = try {
+ def getInt(name: String, f: String => Int): Int =
+ try f(System.getProperty(name)) catch { case e: Exception => Runtime.getRuntime.availableProcessors }
+ def range(floor: Int, desired: Int, ceiling: Int): Int =
+ if (ceiling < floor) range(ceiling, desired, floor) else scala.math.min(scala.math.max(desired, floor), ceiling)
+
+ new ForkJoinPool(
+ range(
+ getInt("scala.concurrent.ec.minThreads", _.toInt),
+ getInt("scala.concurrent.ec.numThreads", {
+ case null | "" => Runtime.getRuntime.availableProcessors
+ case s if s.charAt(0) == 'x' => (Runtime.getRuntime.availableProcessors * s.substring(1).toDouble).ceil.toInt
+ case other => other.toInt
+ }),
+ getInt("scala.concurrent.ec.maxThreads", _.toInt)
+ ),
+ forkJoinPoolThreadFactory,
+ null, //FIXME we should have an UncaughtExceptionHandler, see what Akka does
+ true) //FIXME I really think this should be async...
} catch {
case NonFatal(t) =>
System.err.println("Failed to create ForkJoinPool for the default ExecutionContext, falling back to Executors.newCachedThreadPool")
t.printStackTrace(System.err)
- Executors.newCachedThreadPool(executorsThreadFactory)
+ Executors.newCachedThreadPool(executorsThreadFactory) //FIXME use the same desired parallelism here too?
}
def execute(runnable: Runnable): Unit = executor match {
diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala
index a54e81bd05..47534e398b 100644
--- a/src/library/scala/concurrent/impl/Future.scala
+++ b/src/library/scala/concurrent/impl/Future.scala
@@ -17,8 +17,6 @@ import scala.collection.mutable.Stack
private[concurrent] trait Future[+T] extends scala.concurrent.Future[T] with Awaitable[T] {
- implicit def executor: ExecutionContext
-
}
private[concurrent] object Future {
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 78053f5117..1d573ef818 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -42,7 +42,7 @@ object Promise {
/** Default promise implementation.
*/
- class DefaultPromise[T](implicit val executor: ExecutionContext) extends AbstractPromise with Promise[T] { self =>
+ class DefaultPromise[T] extends AbstractPromise with Promise[T] { self =>
updateState(null, Nil) // Start at "No callbacks" //FIXME switch to Unsafe instead of ARFU
protected final def tryAwait(atMost: Duration): Boolean = {
@@ -108,21 +108,26 @@ object Promise {
}) match {
case null => false
case cs if cs.isEmpty => true
- case cs => Future.dispatchFuture(executor, () => cs.foreach(f => notifyCompleted(f, resolved))); true
+ // this assumes that f(resolved) will go via dispatchFuture
+ // and notifyCompleted (see onComplete below)
+ case cs => cs.foreach(f => f(resolved)); true
}
}
- def onComplete[U](func: Either[Throwable, T] => U): Unit = {
+ def onComplete[U](func: Either[Throwable, T] => U)(implicit executor: ExecutionContext): Unit = {
+ val bound: Either[Throwable, T] => Unit = (either: Either[Throwable, T]) =>
+ Future.dispatchFuture(executor, () => notifyCompleted(func, either))
+
@tailrec //Tries to add the callback, if already completed, it dispatches the callback to be executed
def dispatchOrAddCallback(): Unit =
getState match {
- case r: Either[_, _] => Future.dispatchFuture(executor, () => notifyCompleted(func, r.asInstanceOf[Either[Throwable, T]]))
- case listeners: List[_] => if (updateState(listeners, func :: listeners)) () else dispatchOrAddCallback()
+ case r: Either[_, _] => bound(r.asInstanceOf[Either[Throwable, T]])
+ case listeners: List[_] => if (updateState(listeners, bound :: listeners)) () else dispatchOrAddCallback()
}
dispatchOrAddCallback()
}
- private final def notifyCompleted(func: Either[Throwable, T] => Any, result: Either[Throwable, T]) {
+ private final def notifyCompleted(func: Either[Throwable, T] => Any, result: Either[Throwable, T])(implicit executor: ExecutionContext) {
try {
func(result)
} catch {
@@ -135,7 +140,7 @@ object Promise {
*
* Useful in Future-composition when a value to contribute is already available.
*/
- final class KeptPromise[T](suppliedValue: Either[Throwable, T])(implicit val executor: ExecutionContext) extends Promise[T] {
+ final class KeptPromise[T](suppliedValue: Either[Throwable, T]) extends Promise[T] {
val value = Some(resolveEither(suppliedValue))
@@ -143,7 +148,7 @@ object Promise {
def tryComplete(value: Either[Throwable, T]): Boolean = false
- def onComplete[U](func: Either[Throwable, T] => U): Unit = {
+ def onComplete[U](func: Either[Throwable, T] => U)(implicit executor: ExecutionContext): Unit = {
val completedAs = value.get // Avoid closing over "this"
Future.dispatchFuture(executor, () => func(completedAs))
}
diff --git a/src/library/scala/languageFeature.scala b/src/library/scala/languageFeature.scala
index c990f714c1..c32f1eb724 100644
--- a/src/library/scala/languageFeature.scala
+++ b/src/library/scala/languageFeature.scala
@@ -4,26 +4,26 @@ import annotation.meta
object languageFeature {
- @meta.languageFeature("extension of type scala.Dynamic", true)
+ @meta.languageFeature("extension of type scala.Dynamic", enableRequired = true)
sealed trait dynamics
- @meta.languageFeature("postfix operator #", false)
+ @meta.languageFeature("postfix operator #", enableRequired = false)
sealed trait postfixOps
- @meta.languageFeature("reflective access of structural type member #", false)
+ @meta.languageFeature("reflective access of structural type member #", enableRequired = false)
sealed trait reflectiveCalls
- @meta.languageFeature("implicit conversion #", false)
+ @meta.languageFeature("implicit conversion #", enableRequired = false)
sealed trait implicitConversions
- @meta.languageFeature("higher-kinded type", false)
+ @meta.languageFeature("higher-kinded type", enableRequired = false)
sealed trait higherKinds
- @meta.languageFeature("#, which cannot be expressed by wildcards, ", false)
+ @meta.languageFeature("#, which cannot be expressed by wildcards, ", enableRequired = false)
sealed trait existentials
object experimental {
- @meta.languageFeature("macro definition", true)
+ @meta.languageFeature("macro definition", enableRequired = true)
sealed trait macros
}
}
diff --git a/src/library/scala/math/Equiv.scala b/src/library/scala/math/Equiv.scala
index bd8414a18d..a8ba0aa40c 100644
--- a/src/library/scala/math/Equiv.scala
+++ b/src/library/scala/math/Equiv.scala
@@ -29,7 +29,7 @@ import java.util.Comparator
* @since 2.7
*/
-trait Equiv[T] extends Any {
+trait Equiv[T] extends Any with Serializable {
/** Returns `true` iff `x` is equivalent to `y`.
*/
def equiv(x: T, y: T): Boolean
diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala
index 80addea7f3..a5efa41b80 100644
--- a/src/library/scala/math/Ordered.scala
+++ b/src/library/scala/math/Ordered.scala
@@ -15,7 +15,7 @@ import language.implicitConversions
* more information about whether to use [[scala.math.Ordering]] instead.
*
* Classes that implement this trait can be sorted with
- * [[scala.utils.Sorting]] and can be compared with standard comparison operators
+ * [[scala.util.Sorting]] and can be compared with standard comparison operators
* (e.g. > and <).
*
* Ordered should be used for data with a single, natural ordering (like
@@ -27,14 +27,15 @@ import language.implicitConversions
*
* [[scala.math.PartiallyOrdered]] is an alternative to this trait for partially ordered data.
*
- * For example, to create a simple class that implements Ordered and then sort it with [[scala.utils.Sorting]]:
+ * For example, create a simple class that implements `Ordered` and then sort it with [[scala.util.Sorting]]:
* {{{
- * class OrderedClass(n:Int) extends Ordered[OrderedClass] {
+ * case class OrderedClass(n:Int) extends Ordered[OrderedClass] {
* def compare(that: OrderedClass) = this.n - that.n
* }
*
- * val x = List(new MyClass(1), new MyClass(5), new MyClass(3))
- * val result = scala.utils.Sorting.quickSort(x)
+ * val x = Array(OrderedClass(1), OrderedClass(5), OrderedClass(3))
+ * scala.util.Sorting.quickSort(x)
+ * x
* }}}
*
* It is important that the `equals` method for an instance of `Ordered[A]` be consistent with the
diff --git a/src/library/scala/ref/WeakReference.scala b/src/library/scala/ref/WeakReference.scala
index 98cfb2c84b..322eab0be4 100644
--- a/src/library/scala/ref/WeakReference.scala
+++ b/src/library/scala/ref/WeakReference.scala
@@ -10,6 +10,9 @@
package scala.ref
/**
+ * A wrapper class for java.lag.ref.WeakReference
+ * The new functionality is (1) results are Option values, instead of using null.
+ * (2) There is an extractor that maps the weak reference itself into an option.
* @author Sean McDirmid
*/
class WeakReference[+T <: AnyRef](value: T, queue: ReferenceQueue[T]) extends ReferenceWrapper[T] {
@@ -18,6 +21,19 @@ class WeakReference[+T <: AnyRef](value: T, queue: ReferenceQueue[T]) extends Re
new WeakReferenceWithWrapper[T](value, queue, this)
}
+/** An extractor for weak reference values */
+object WeakReference {
+
+ /** Creates a weak reference pointing to `value` */
+ def apply[T <: AnyRef](value: T) = new WeakReference(value)
+
+ /** Optionally returns the referenced value, or `None` if that value no longer exists */
+ def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = {
+ val x = wr.underlying.get
+ if (x != null) Some(x) else None
+ }
+}
+
/**
* @author Philipp Haller
*/
diff --git a/src/library/scala/reflect/ArrayTag.scala b/src/library/scala/reflect/ArrayTag.scala
deleted file mode 100644
index ba0c075723..0000000000
--- a/src/library/scala/reflect/ArrayTag.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package scala.reflect
-
-/** An `ArrayTag[T]` is a descriptor that is requested by the compiler every time
- * when an array is instantiated, but the element type is unknown at compile time.
- *
- * Implicit in the contract of `ArrayTag[T]` is the fact that `T`
- * cannot contain unresolved references to type parameters or abstract types.
- *
- * Scala library provides a standard implementation of this trait,
- * `ClassTag[T]` that explicitly carries the `java.lang.Class` erasure of type T
- * and uses Java reflection to instantiate arrays.
- *
- * However other platforms (e.g. a Scala -> JS crosscompiler) may reimplement this trait as they see fit
- * and then expose the implementation via an implicit macro.
- *
- * @see [[scala.reflect.api.TypeTags]]
- */
-@annotation.implicitNotFound(msg = "No ArrayTag available for ${T}")
-trait ArrayTag[T] {
- /** Produces an `ArrayTag` that knows how to build `Array[Array[T]]` */
- def wrap: ArrayTag[Array[T]]
-
- /** Produces a new array with element type `T` and length `len` */
- def newArray(len: Int): Array[T]
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala
index 43e043fd40..d89d31f689 100644
--- a/src/library/scala/reflect/ClassManifest.scala
+++ b/src/library/scala/reflect/ClassManifest.scala
@@ -27,6 +27,7 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with
/** A class representing the type `U` to which `T` would be erased. Note
* that there is no subtyping relationship between `T` and `U`. */
def erasure: jClass[_]
+ override def runtimeClass: jClass[_] = erasure
private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = {
def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = {
diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala
index e485691747..f753dfbcbb 100644
--- a/src/library/scala/reflect/ClassTag.scala
+++ b/src/library/scala/reflect/ClassTag.scala
@@ -1,39 +1,37 @@
package scala.reflect
import java.lang.{ Class => jClass }
-import scala.reflect.{ mirror => rm }
import language.{implicitConversions, existentials}
import scala.runtime.ScalaRunTime.arrayClass
-/** A `ClassTag[T]` wraps a Java class, which can be accessed via the `erasure` method.
+/** A `ClassTag[T]` wraps a runtime class, which can be accessed via the `runtimeClass` method.
*
* This is useful in itself, but also enables very important use case.
* Having this knowledge ClassTag can instantiate `Arrays`
* in those cases where the element type is unknown at compile time.
- * Hence, ClassTag[T] conforms to the ArrayTag[T] trait.
*
* If an implicit value of type u.ClassTag[T] is required, the compiler will make one up on demand.
- * The implicitly created value contains in its erasure field the Java class that is the result of erasing type T.
+ * The implicitly created value contains in its `runtimeClass` field the runtime class that is the result of erasing type T.
* In that value, any occurrences of type parameters or abstract types U which come themselves with a ClassTag
- * or a reflect.mirror.ConcreteTypeTag are represented by the type referenced by that tag.
+ * are represented by the type referenced by that tag.
* If the type T contains unresolved references to type parameters or abstract types, a static error results.
*
- * A ConcreteTypeTag member of the reflect.mirror object is convertible to a ClassTag via an implicit conversion
- * (this is not possible to do in all reflection universes because an operation that converts a type to a Java class might not be available).
- *
- * @see [[scala.reflect.api.TypeTags]]
+ * @see [[scala.reflect.base.TypeTags]]
*/
@annotation.implicitNotFound(msg = "No ClassTag available for ${T}")
-trait ClassTag[T] extends ArrayTag[T] with ErasureTag[T] with Equals with Serializable {
+trait ClassTag[T] extends Equals with Serializable {
// please, don't add any APIs here, like it was with `newWrappedArray` and `newArrayBuilder`
// class tags, and all tags in general, should be as minimalistic as possible
+ /** Returns a runtime class of type `T` */
+ def runtimeClass: jClass[_]
+
/** Produces a `ClassTag` that knows how to build `Array[Array[T]]` */
- def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(erasure))
+ def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(runtimeClass))
/** Produces a new array with element type `T` and length `len` */
def newArray(len: Int): Array[T] =
- erasure match {
+ runtimeClass match {
case java.lang.Byte.TYPE => new Array[Byte](len).asInstanceOf[Array[T]]
case java.lang.Short.TYPE => new Array[Short](len).asInstanceOf[Array[T]]
case java.lang.Character.TYPE => new Array[Char](len).asInstanceOf[Array[T]]
@@ -43,14 +41,24 @@ trait ClassTag[T] extends ArrayTag[T] with ErasureTag[T] with Equals with Serial
case java.lang.Double.TYPE => new Array[Double](len).asInstanceOf[Array[T]]
case java.lang.Boolean.TYPE => new Array[Boolean](len).asInstanceOf[Array[T]]
case java.lang.Void.TYPE => new Array[Unit](len).asInstanceOf[Array[T]]
- case _ => java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]]
+ case _ => java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]]
}
+ /** A ClassTag[T] can serve as an extractor that matches only objects of type T.
+ *
+ * The compiler tries to turn unchecked type tests in pattern matches into checked ones
+ * by wrapping a `(_: T)` type pattern as `ct(_: T)`, where `ct` is the `ClassTag[T]` instance.
+ * Type tests necessary before calling other extractors are treated similarly.
+ * `SomeExtractor(...)` is turned into `ct(SomeExtractor(...))` if `T` in `SomeExtractor.unapply(x: T)`
+ * is uncheckable, but we have an instance of `ClassTag[T]`.
+ */
+ def unapply(x: Any): Option[T] = if (runtimeClass.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[T]) else None
+
/** case class accessories */
override def canEqual(x: Any) = x.isInstanceOf[ClassTag[_]]
- override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && this.erasure == x.asInstanceOf[ClassTag[_]].erasure
- override def hashCode = scala.runtime.ScalaRunTime.hash(erasure)
- override def toString = "ClassTag[" + erasure + "]"
+ override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && this.runtimeClass == x.asInstanceOf[ClassTag[_]].runtimeClass
+ override def hashCode = scala.runtime.ScalaRunTime.hash(runtimeClass)
+ override def toString = "ClassTag[" + runtimeClass + "]"
}
object ClassTag {
@@ -59,25 +67,25 @@ object ClassTag {
private val ObjectTYPE = classOf[java.lang.Object]
private val StringTYPE = classOf[java.lang.String]
- val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def erasure = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte }
- val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def erasure = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short }
- val Char : ClassTag[scala.Char] = new ClassTag[scala.Char]{ def erasure = java.lang.Character.TYPE; private def readResolve() = ClassTag.Char }
- val Int : ClassTag[scala.Int] = new ClassTag[scala.Int]{ def erasure = java.lang.Integer.TYPE; private def readResolve() = ClassTag.Int }
- val Long : ClassTag[scala.Long] = new ClassTag[scala.Long]{ def erasure = java.lang.Long.TYPE; private def readResolve() = ClassTag.Long }
- val Float : ClassTag[scala.Float] = new ClassTag[scala.Float]{ def erasure = java.lang.Float.TYPE; private def readResolve() = ClassTag.Float }
- val Double : ClassTag[scala.Double] = new ClassTag[scala.Double]{ def erasure = java.lang.Double.TYPE; private def readResolve() = ClassTag.Double }
- val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean]{ def erasure = java.lang.Boolean.TYPE; private def readResolve() = ClassTag.Boolean }
- val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def erasure = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit }
- val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.Any }
- val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.Object }
- val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.AnyVal }
- val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.AnyRef }
- val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def erasure = NothingTYPE; private def readResolve() = ClassTag.Nothing }
- val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def erasure = NullTYPE; private def readResolve() = ClassTag.Null }
- val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String]{ def erasure = StringTYPE; private def readResolve() = ClassTag.String }
+ val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def runtimeClass = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte }
+ val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def runtimeClass = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short }
+ val Char : ClassTag[scala.Char] = new ClassTag[scala.Char]{ def runtimeClass = java.lang.Character.TYPE; private def readResolve() = ClassTag.Char }
+ val Int : ClassTag[scala.Int] = new ClassTag[scala.Int]{ def runtimeClass = java.lang.Integer.TYPE; private def readResolve() = ClassTag.Int }
+ val Long : ClassTag[scala.Long] = new ClassTag[scala.Long]{ def runtimeClass = java.lang.Long.TYPE; private def readResolve() = ClassTag.Long }
+ val Float : ClassTag[scala.Float] = new ClassTag[scala.Float]{ def runtimeClass = java.lang.Float.TYPE; private def readResolve() = ClassTag.Float }
+ val Double : ClassTag[scala.Double] = new ClassTag[scala.Double]{ def runtimeClass = java.lang.Double.TYPE; private def readResolve() = ClassTag.Double }
+ val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean]{ def runtimeClass = java.lang.Boolean.TYPE; private def readResolve() = ClassTag.Boolean }
+ val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def runtimeClass = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit }
+ val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Any }
+ val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object }
+ val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyVal }
+ val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyRef }
+ val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing }
+ val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null }
+ val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String]{ def runtimeClass = StringTYPE; private def readResolve() = ClassTag.String }
- def apply[T](erasure1: jClass[_]): ClassTag[T] =
- erasure1 match {
+ def apply[T](runtimeClass1: jClass[_]): ClassTag[T] =
+ runtimeClass1 match {
case java.lang.Byte.TYPE => ClassTag.Byte.asInstanceOf[ClassTag[T]]
case java.lang.Short.TYPE => ClassTag.Short.asInstanceOf[ClassTag[T]]
case java.lang.Character.TYPE => ClassTag.Char.asInstanceOf[ClassTag[T]]
@@ -89,8 +97,8 @@ object ClassTag {
case java.lang.Void.TYPE => ClassTag.Unit.asInstanceOf[ClassTag[T]]
case ObjectTYPE => ClassTag.Object.asInstanceOf[ClassTag[T]]
case StringTYPE => ClassTag.String.asInstanceOf[ClassTag[T]]
- case _ => new ClassTag[T]{ def erasure = erasure1 }
+ case _ => new ClassTag[T]{ def runtimeClass = runtimeClass1 }
}
- def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.erasure)
+ def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.runtimeClass)
} \ No newline at end of file
diff --git a/src/library/scala/reflect/DummyMirror.scala b/src/library/scala/reflect/DummyMirror.scala
deleted file mode 100644
index aa731f62db..0000000000
--- a/src/library/scala/reflect/DummyMirror.scala
+++ /dev/null
@@ -1,783 +0,0 @@
-package scala.reflect
-
-import scala.reflect.api.AbsTreeGen
-import scala.reflect.api.Attachment
-import scala.reflect.api.Modifier
-import scala.reflect.api.Universe
-
-// todo. make Dummy objects not equal to themselves
-class DummyMirror(cl: ClassLoader) extends api.Mirror {
- // Members declared in scala.reflect.api.AnnotationInfos
- implicit def classfileAnnotArgTag: scala.reflect.ClassTag[ClassfileAnnotArg] = notSupported()
- type AnnotationInfo = DummyAnnotationInfo.type
- object DummyAnnotationInfo
- val AnnotationInfo: AnnotationInfoExtractor = DummyAnnotationInfoExtractor
- object DummyAnnotationInfoExtractor extends AnnotationInfoExtractor {
- def apply(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)]): AnnotationInfo = DummyAnnotationInfo
- def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])] = notSupported()
- }
- type ClassfileAnnotArg = AnyRef
- type LiteralAnnotArg = DummyLiteralAnnotArg.type
- object DummyLiteralAnnotArg
- val LiteralAnnotArg: LiteralAnnotArgExtractor = DummyLiteralAnnotArgExtractor
- type ArrayAnnotArg = DummyArrayAnnotArg.type
- object DummyArrayAnnotArg
- val ArrayAnnotArg: ArrayAnnotArgExtractor = DummyArrayAnnotArgExtractor
- type NestedAnnotArg = DummyNestedAnnotArg.type
- object DummyNestedAnnotArg
- val NestedAnnotArg: NestedAnnotArgExtractor = DummyNestedAnnotArgExtractor
- object DummyLiteralAnnotArgExtractor extends LiteralAnnotArgExtractor {
- def apply(const: Constant): LiteralAnnotArg = DummyLiteralAnnotArg
- def unapply(arg: LiteralAnnotArg): Option[Constant] = notSupported()
- }
- object DummyArrayAnnotArgExtractor extends ArrayAnnotArgExtractor {
- def apply(const: Array[ClassfileAnnotArg]): ArrayAnnotArg = DummyArrayAnnotArg
- def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]] = notSupported()
- }
- object DummyNestedAnnotArgExtractor extends NestedAnnotArgExtractor {
- def apply(anninfo: AnnotationInfo): NestedAnnotArg = DummyNestedAnnotArg
- def unapply(arg: NestedAnnotArg): Option[AnnotationInfo] = notSupported()
- }
-
- // Members declared in scala.reflect.api.Constants
- type Constant = DummyConstant.type
- object DummyConstant extends AbsConstant {
- val value: Any = notSupported()
- def tpe: Type = notSupported()
- def isNaN: Boolean = notSupported()
- def booleanValue: Boolean = notSupported()
- def byteValue: Byte = notSupported()
- def shortValue: Short = notSupported()
- def charValue: Char = notSupported()
- def intValue: Int = notSupported()
- def longValue: Long = notSupported()
- def floatValue: Float = notSupported()
- def doubleValue: Double = notSupported()
- def stringValue: String = notSupported()
- def typeValue: Type = notSupported()
- def symbolValue: Symbol = notSupported()
- def convertTo(pt: Type): Constant = notSupported()
- }
- val Constant: ConstantExtractor = DummyConstantExtractor
- object DummyConstantExtractor extends ConstantExtractor {
- def apply(const: Any): Constant = DummyConstant
- def unapply(arg: Constant): Option[Any] = notSupported()
- }
-
- // Members declared in scala.reflect.api.FreeVars
- type FreeTerm = DummyFreeTerm.type
- val DummyFreeTerm = DummySymbol
- val FreeTerm: FreeTermExtractor = DummyFreeTermExtractor
- object DummyFreeTermExtractor extends FreeTermExtractor {
- def unapply(freeTerm: FreeTerm): Option[(TermName, Type, Any, String)] = notSupported()
- }
- type FreeType = DummyFreeType.type
- val DummyFreeType = DummySymbol
- val FreeType: FreeTypeExtractor = DummyFreeTypeExtractor
- object DummyFreeTypeExtractor extends FreeTypeExtractor {
- def unapply(freeType: FreeType): Option[(TypeName, Type, String)] = notSupported()
- }
- def freeTerms(tree: Tree): List[FreeTerm] = notSupported()
- def freeTypes(tree: Tree): List[FreeType] = notSupported()
- def substituteFreeTypes(tpe: Type,subs: Map[FreeType,Type]): Type = notSupported()
- def substituteFreeTypes(tree: Tree,subs: Map[FreeType,Type]): Tree = notSupported()
-
- // Members declared in scala.reflect.api.Importers
- def mkImporter(from0: scala.reflect.api.Universe): Importer{val from: from0.type} = notSupported()
-
- // Members declared in scala.reflect.api.Mirror
- def classLoader: ClassLoader = cl
- def classLoader_=(x$1: ClassLoader): Unit = notSupported()
- def classToSymbol(clazz: Class[_]): Symbol = notSupported()
- def classToType(clazz: Class[_]): Type = notSupported()
- def companionInstance(clazz: Symbol): AnyRef = notSupported()
- def getValueOfField(receiver: AnyRef,field: Symbol): Any = notSupported()
- def invoke(receiver: AnyRef,meth: Symbol)(args: Any*): Any = notSupported()
- def setValueOfField(receiver: AnyRef,field: Symbol,value: Any): Unit = notSupported()
- def symbolForName(name: String): Symbol = notSupported()
- def symbolOfInstance(instance: Any): Symbol = notSupported()
- def symbolToClass(sym: Symbol): Class[_] = notSupported()
- def typeOfInstance(instance: Any): Type = notSupported()
- def typeToClass(tpe: Type): Class[_] = notSupported()
-
- // Members declared in scala.reflect.api.Names
- type Name = DummyName.type
- type TypeName = DummyName.type
- type TermName = DummyName.type
- object DummyName extends AbsName {
- def isTermName: Boolean = notSupported()
- def isTypeName: Boolean = notSupported()
- def toTermName: TermName = notSupported()
- def toTypeName: TypeName = notSupported()
- def decoded: String = notSupported()
- def encoded: String = notSupported()
- def decodedName: Name = notSupported()
- def encodedName: Name = notSupported()
- }
- def newTermName(s: String): TermName = notSupported()
- def newTypeName(s: String): TypeName = notSupported()
-
- // Members declared in scala.reflect.api.Positions
- type Position = DummyPosition.type
- object DummyPosition extends api.Position {
- def pos: Position = notSupported()
- def withPos(newPos: scala.reflect.api.Position): Attachment = notSupported()
- def payload: Any = notSupported()
- def withPayload(newPayload: Any): Attachment = notSupported()
- def fileInfo: java.io.File = notSupported()
- def fileContent: Array[Char] = notSupported()
- def isDefined: Boolean = notSupported()
- def isTransparent: Boolean = notSupported()
- def isRange: Boolean = notSupported()
- def isOpaqueRange: Boolean = notSupported()
- def makeTransparent: Position = notSupported()
- def start: Int = notSupported()
- def startOrPoint: Int = notSupported()
- def point: Int = notSupported()
- def pointOrElse(default: Int): Int = notSupported()
- def end: Int = notSupported()
- def endOrPoint: Int = notSupported()
- def withStart(off: Int): Position = notSupported()
- def withEnd(off: Int): Position = notSupported()
- def withPoint(off: Int): Position = notSupported()
- def union(pos: scala.reflect.api.Position): Position = notSupported()
- def focusStart: Position = notSupported()
- def focus: Position = notSupported()
- def focusEnd: Position = notSupported()
- def includes(pos: scala.reflect.api.Position): Boolean = notSupported()
- def properlyIncludes(pos: scala.reflect.api.Position): Boolean = notSupported()
- def precedes(pos: scala.reflect.api.Position): Boolean = notSupported()
- def properlyPrecedes(pos: scala.reflect.api.Position): Boolean = notSupported()
- def overlaps(pos: scala.reflect.api.Position): Boolean = notSupported()
- def sameRange(pos: scala.reflect.api.Position): Boolean = notSupported()
- def line: Int = notSupported()
- def column: Int = notSupported()
- def toSingleLine: Position = notSupported()
- def lineContent: String = notSupported()
- def show: String = notSupported()
- }
- val NoPosition: Position = DummyPosition
- def atPos[T <: Tree](pos: Position)(tree: T): T = tree
- def ensureNonOverlapping(tree: Tree,others: List[Tree]): Unit = notSupported()
- def wrappingPos(trees: List[Tree]): Position = notSupported()
- def wrappingPos(default: Position,trees: List[Tree]): Position = notSupported()
-
- // Members declared in scala.reflect.api.FrontEnds
- def mkConsoleFrontEnd(minSeverity: Int): FrontEnd = notSupported()
-
- // Members declared in scala.reflect.api.Scopes
- type Scope = DummyScope.type
- object DummyScope extends Iterable[Symbol] {
- def iterator: Iterator[Symbol] = notSupported()
- }
- def newScope: Scope = DummyScope
- def newScopeWith(elems: Symbol*): Scope = DummyScope
- def newNestedScope(outer: Scope): Scope = DummyScope
-
- // Members declared in scala.reflect.api.StandardDefinitions
- val AnyRefTpe: Type = DummyType
- val AnyTpe: Type = DummyType
- val AnyValTpe: Type = DummyType
- val BooleanTpe: Type = DummyType
- val ByteTpe: Type = DummyType
- val CharTpe: Type = DummyType
- val DoubleTpe: Type = DummyType
- val FloatTpe: Type = DummyType
- val IntTpe: Type = DummyType
- val LongTpe: Type = DummyType
- val NothingTpe: Type = DummyType
- val NullTpe: Type = DummyType
- val ObjectTpe: Type = DummyType
- val ShortTpe: Type = DummyType
- val StringTpe: Type = DummyType
- val UnitTpe: Type = DummyType
- val definitions: AbsDefinitions = DummyDefinitions
- object DummyDefinitions extends AbsDefinitions {
- def ByNameParamClass = DummySymbol
- def JavaRepeatedParamClass = DummySymbol
- def RepeatedParamClass = DummySymbol
- def AnyClass = DummyClassSymbol
- def AnyRefClass = DummyTypeSymbol
- def AnyValClass = DummyClassSymbol
- def ArrayClass = DummyClassSymbol
- def ArrayModule = DummySymbol
- def ArrayModule_overloadedApply = DummySymbol
- def Array_apply = DummySymbol
- def Array_clone = DummySymbol
- def Array_length = DummySymbol
- def Array_update = DummySymbol
- def BooleanClass = DummyClassSymbol
- def ByteClass = DummyClassSymbol
- def CharClass = DummyClassSymbol
- def ClassClass = DummyClassSymbol
- def ClassTagClass = DummyClassSymbol
- def ClassTagModule = DummySymbol
- def ConcreteTypeTagClass = DummyClassSymbol
- def ConcreteTypeTagModule = DummySymbol
- def ConsClass = DummySymbol
- def DoubleClass = DummyClassSymbol
- def EmptyPackage = DummyPackageSymbol
- def EmptyPackageClass = DummySymbol
- def FloatClass = DummyClassSymbol
- def FunctionClass: Array[Symbol] = Array()
- def IntClass = DummyClassSymbol
- def IterableClass = DummySymbol
- def IteratorClass = DummySymbol
- def IteratorModule = DummySymbol
- def Iterator_apply = DummySymbol
- def JavaLangPackage = DummyPackageSymbol
- def JavaLangPackageClass = DummySymbol
- def ListClass = DummyClassSymbol
- def ListModule = DummyModuleSymbol
- def List_apply = DummySymbol
- def LongClass = DummyClassSymbol
- def NilModule = DummySymbol
- def NoneModule = DummySymbol
- def NothingClass = DummyClassSymbol
- def NullClass = DummyClassSymbol
- def ObjectClass = DummyClassSymbol
- def OptionClass = DummySymbol
- def PredefModule = DummyModuleSymbol
- def ProductClass: Array[Symbol] = Array()
- def RootClass = DummyClassSymbol
- def RootPackage = DummyPackageSymbol
- def ScalaPackage = DummyPackageSymbol
- def ScalaPackageClass = DummySymbol
- def ScalaPrimitiveValueClasses = Nil
- def SeqClass = DummySymbol
- def SeqModule = DummySymbol
- def ShortClass = DummyClassSymbol
- def SomeClass = DummySymbol
- def SomeModule = DummySymbol
- def StringBuilderClass = DummySymbol
- def StringClass = DummyClassSymbol
- def SymbolClass = DummySymbol
- def TraversableClass = DummySymbol
- def TupleClass: Array[Symbol] = Array()
- def TypeTagClass = DummyClassSymbol
- def TypeTagModule = DummySymbol
- def UnitClass = DummyClassSymbol
- def isNumericValueClass(sym: Symbol): Boolean = notSupported()
- def isPrimitiveValueClass(sym: Symbol): Boolean = notSupported()
- def vmClassType(arg: Type): Type = DummyType
- def vmSignature(sym: Symbol,info: Type): String = notSupported()
- }
-
- // Members declared in scala.reflect.api.StandardNames
- val nme: AbsTermNames = DummyAbsTermNames
- val tpnme: AbsTypeNames = DummyAbsTypeNames
- object DummyAbsTermNames extends AbsTermNames {
- type NameType = TermName
- val EMPTY: NameType = DummyName
- val ANON_FUN_NAME: NameType = DummyName
- val ANON_CLASS_NAME: NameType = DummyName
- val EMPTY_PACKAGE_NAME: NameType = DummyName
- val IMPORT: NameType = DummyName
- val MODULE_VAR_SUFFIX: NameType = DummyName
- val ROOT: NameType = DummyName
- val PACKAGE: NameType = DummyName
- val SPECIALIZED_SUFFIX: NameType = DummyName
- val ERROR: NameType = DummyName
- val NO_NAME: NameType = DummyName
- val WILDCARD: NameType = DummyName
- def flattenedName(segments: Name*): NameType = notSupported()
- val EXPAND_SEPARATOR_STRING: String = ""
- val ANYNAME: TermName = DummyName
- val CONSTRUCTOR: TermName = DummyName
- val FAKE_LOCAL_THIS: TermName = DummyName
- val INITIALIZER: TermName = DummyName
- val LAZY_LOCAL: TermName = DummyName
- val LOCAL_SUFFIX_STRING: String = ""
- val MIRROR_PREFIX: TermName = DummyName
- val MIRROR_SHORT: TermName = DummyName
- val MIRROR_FREE_PREFIX: TermName = DummyName
- val MIRROR_FREE_THIS_SUFFIX: TermName = DummyName
- val MIRROR_FREE_VALUE_SUFFIX: TermName = DummyName
- val MIRROR_SYMDEF_PREFIX: TermName = DummyName
- val MIXIN_CONSTRUCTOR: TermName = DummyName
- val MODULE_INSTANCE_FIELD: TermName = DummyName
- val OUTER: TermName = DummyName
- val OUTER_LOCAL: TermName = DummyName
- val OUTER_SYNTH: TermName = DummyName
- val SELECTOR_DUMMY: TermName = DummyName
- val SELF: TermName = DummyName
- val SPECIALIZED_INSTANCE: TermName = DummyName
- val STAR: TermName = DummyName
- val THIS: TermName = DummyName
- val BITMAP_NORMAL: TermName = DummyName
- val BITMAP_TRANSIENT: TermName = DummyName
- val BITMAP_CHECKINIT: TermName = DummyName
- val BITMAP_CHECKINIT_TRANSIENT: TermName = DummyName
- val INTERPRETER_IMPORT_WRAPPER: String = ""
- val INTERPRETER_LINE_PREFIX: String = ""
- val INTERPRETER_VAR_PREFIX: String = ""
- val INTERPRETER_WRAPPER_SUFFIX: String = ""
- val ROOTPKG: TermName = DummyName
- val ADD: TermName = DummyName
- val AND: TermName = DummyName
- val ASR: TermName = DummyName
- val DIV: TermName = DummyName
- val EQ: TermName = DummyName
- val EQL: TermName = DummyName
- val GE: TermName = DummyName
- val GT: TermName = DummyName
- val HASHHASH: TermName = DummyName
- val LE: TermName = DummyName
- val LSL: TermName = DummyName
- val LSR: TermName = DummyName
- val LT: TermName = DummyName
- val MINUS: TermName = DummyName
- val MOD: TermName = DummyName
- val MUL: TermName = DummyName
- val NE: TermName = DummyName
- val OR: TermName = DummyName
- val PLUS : TermName = DummyName
- val SUB: TermName = DummyName
- val XOR: TermName = DummyName
- val ZAND: TermName = DummyName
- val ZOR: TermName = DummyName
- val UNARY_~ : TermName = DummyName
- val UNARY_+ : TermName = DummyName
- val UNARY_- : TermName = DummyName
- val UNARY_! : TermName = DummyName
- val ??? : TermName = DummyName
- val MODULE_SUFFIX_NAME: TermName = DummyName
- val NAME_JOIN_NAME: TermName = DummyName
- val IMPL_CLASS_SUFFIX: String = ""
- val LOCALDUMMY_PREFIX: String = ""
- val PROTECTED_PREFIX: String = ""
- val PROTECTED_SET_PREFIX: String = ""
- val SINGLETON_SUFFIX: String = ""
- val SUPER_PREFIX_STRING: String = ""
- val TRAIT_SETTER_SEPARATOR_STRING: String = ""
- val SETTER_SUFFIX: TermName = DummyName
- def isConstructorName(name: Name): Boolean = notSupported()
- def isExceptionResultName(name: Name): Boolean = notSupported()
- def isImplClassName(name: Name): Boolean = notSupported()
- def isLocalDummyName(name: Name): Boolean = notSupported()
- def isLocalName(name: Name): Boolean = notSupported()
- def isLoopHeaderLabel(name: Name): Boolean = notSupported()
- def isProtectedAccessorName(name: Name): Boolean = notSupported()
- def isSuperAccessorName(name: Name): Boolean = notSupported()
- def isReplWrapperName(name: Name): Boolean = notSupported()
- def isSetterName(name: Name): Boolean = notSupported()
- def isTraitSetterName(name: Name): Boolean = notSupported()
- def isSingletonName(name: Name): Boolean = notSupported()
- def isModuleName(name: Name): Boolean = notSupported()
- def isOpAssignmentName(name: Name): Boolean = notSupported()
- def segments(name: String, assumeTerm: Boolean): List[Name] = notSupported()
- def originalName(name: Name): Name = notSupported()
- def stripModuleSuffix(name: Name): Name = notSupported()
- def unspecializedName(name: Name): Name = notSupported()
- def splitSpecializedName(name: Name): (Name, String, String) = notSupported()
- def dropLocalSuffix(name: Name): Name = notSupported()
- def expandedName(name: TermName, base: Symbol, separator: String = EXPAND_SEPARATOR_STRING): TermName = notSupported()
- def expandedSetterName(name: TermName, base: Symbol): TermName = notSupported()
- def protName(name: Name): TermName = notSupported()
- def protSetterName(name: Name): TermName = notSupported()
- def getterName(name: TermName): TermName = notSupported()
- def getterToLocal(name: TermName): TermName = notSupported()
- def getterToSetter(name: TermName): TermName = notSupported()
- def localToGetter(name: TermName): TermName = notSupported()
- def setterToGetter(name: TermName): TermName = notSupported()
- def defaultGetterName(name: Name, pos: Int): TermName = notSupported()
- def defaultGetterToMethod(name: Name): TermName = notSupported()
- def localDummyName(clazz: Symbol): TermName = notSupported()
- def superName(name: Name): TermName = notSupported()
- }
- object DummyAbsTypeNames extends AbsTypeNames {
- type NameType = TypeName
- val EMPTY: NameType = DummyName
- val ANON_FUN_NAME: NameType = DummyName
- val ANON_CLASS_NAME: NameType = DummyName
- val EMPTY_PACKAGE_NAME: NameType = DummyName
- val IMPORT: NameType = DummyName
- val MODULE_VAR_SUFFIX: NameType = DummyName
- val ROOT: NameType = DummyName
- val PACKAGE: NameType = DummyName
- val SPECIALIZED_SUFFIX: NameType = DummyName
- val ERROR: NameType = DummyName
- val NO_NAME: NameType = DummyName
- val WILDCARD: NameType = DummyName
- def flattenedName(segments: Name*): NameType = notSupported()
- val REFINE_CLASS_NAME: TypeName = DummyName
- val BYNAME_PARAM_CLASS_NAME: TypeName = DummyName
- val EQUALS_PATTERN_NAME: TypeName = DummyName
- val JAVA_REPEATED_PARAM_CLASS_NAME: TypeName = DummyName
- val LOCAL_CHILD: TypeName = DummyName
- val REPEATED_PARAM_CLASS_NAME: TypeName = DummyName
- val WILDCARD_STAR: TypeName = DummyName
-
- def dropSingletonName(name: Name): TypeName = notSupported()
- def singletonName(name: Name): TypeName = notSupported()
- def implClassName(name: Name): TypeName = notSupported()
- def interfaceName(implname: Name): TypeName = notSupported()
- }
-
- // Members declared in scala.reflect.api.Symbols
- val NoSymbol = DummySymbol
- type Symbol = DummySymbolApi
- object DummySymbol extends DummySymbolApi
- type TypeSymbol = DummyTypeSymbolApi
- object DummyTypeSymbol extends DummyTypeSymbolApi
- type TermSymbol = DummyTermSymbolApi
- object DummyTermSymbol extends DummyTermSymbolApi
- type MethodSymbol = DummyMethodSymbolApi
- object DummyMethodSymbol extends DummyMethodSymbolApi
- type ModuleSymbol = DummyModuleSymbolApi
- object DummyModuleSymbol extends DummyModuleSymbolApi
- type PackageSymbol = DummyPackageSymbolApi
- object DummyPackageSymbol extends DummyPackageSymbolApi
- type ClassSymbol = DummyClassSymbolApi
- object DummyClassSymbol extends DummyClassSymbolApi
- trait DummySymbolApi extends AbsSymbol {
- this: Symbol =>
-
- def pos: Position = notSupported()
- def modifiers: Set[Modifier] = notSupported()
- def hasModifier(mod: Modifier): Boolean = notSupported()
- def annotations: List[AnnotationInfo] = notSupported()
- def hasAnnotation(sym: Symbol): Boolean = notSupported()
- def owner: Symbol = notSupported()
- def name: Name = notSupported()
- def fullName: String = notSupported()
- def id: Int = notSupported()
- def orElse(alt: => Symbol): Symbol = notSupported()
- def filter(cond: Symbol => Boolean): Symbol = notSupported()
- def suchThat(cond: Symbol => Boolean): Symbol = notSupported()
- def privateWithin: Symbol = notSupported()
- def companionSymbol: Symbol = notSupported()
- def moduleClass: Symbol = notSupported()
- def enclosingTopLevelClass: Symbol = notSupported()
- def enclosingClass: Symbol = notSupported()
- def enclosingMethod: Symbol = notSupported()
- def enclosingPackageClass: Symbol = notSupported()
- def isTerm : Boolean = notSupported()
- def isPackage : Boolean = notSupported()
- def isMethod : Boolean = notSupported()
- def isOverloaded : Boolean = notSupported()
- def isFreeTerm : Boolean = notSupported()
- def isType : Boolean = notSupported()
- def isClass : Boolean = notSupported()
- def isPackageClass : Boolean = notSupported()
- def isPrimitiveValueClass: Boolean = notSupported()
- def isDerivedValueClass: Boolean = notSupported()
- def isAliasType : Boolean = notSupported()
- def isAbstractType : Boolean = notSupported()
- def isSkolem : Boolean = notSupported()
- def isExistential : Boolean = notSupported()
- def isFreeType : Boolean = notSupported()
- def isContravariant : Boolean = notSupported()
- def isCovariant : Boolean = notSupported()
- def isErroneous : Boolean = notSupported()
- def typeSignature: Type = notSupported()
- def typeSignatureIn(site: Type): Type = notSupported()
- def asType: Type = notSupported()
- def asTypeIn(site: Type): Type = notSupported()
- def asTypeConstructor: Type = notSupported()
- def thisPrefix: Type = notSupported()
- def selfType: Type = notSupported()
- def alternatives: List[Symbol] = notSupported()
- def resolveOverloaded(pre: Type = NoPrefix, targs: Seq[Type] = List(), actuals: Seq[Type]): Symbol = notSupported()
- def newNestedSymbol(name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol = notSupported()
- def setInternalFlags(flags: Long): this.type = notSupported()
- def setTypeSignature(tpe: Type): this.type = notSupported()
- def setAnnotations(annots: AnnotationInfo*): this.type = notSupported()
- def kind: String = notSupported()
- }
- trait DummyTypeSymbolApi extends DummySymbolApi with TypeSymbolApi {
- this: TypeSymbol =>
- }
- trait DummyTermSymbolApi extends DummySymbolApi with TermSymbolApi {
- this: TermSymbol =>
- }
- trait DummyMethodSymbolApi extends DummyTermSymbolApi with MethodSymbolApi {
- this: MethodSymbol =>
- }
- trait DummyModuleSymbolApi extends DummyTermSymbolApi with ModuleSymbolApi {
- this: ModuleSymbol =>
- }
- trait DummyPackageSymbolApi extends DummyModuleSymbolApi with PackageSymbolApi {
- this: PackageSymbol =>
- }
- trait DummyClassSymbolApi extends DummyTypeSymbolApi with ClassSymbolApi {
- this: ClassSymbol =>
- }
-
- // Members declared in scala.reflect.api.ToolBoxes
- def mkToolBox(frontEnd: FrontEnd, options: String): AbsToolBox = notSupported()
-
- // Members declared in scala.reflect.api.TreeBuildUtil
- // type TreeGen = DummyTreeGen.type // [Eugene] cannot compile if uncomment this
- val gen: TreeGen{val global: DummyMirror.this.type} = DummyTreeGen.asInstanceOf[TreeGen{val global: DummyMirror.this.type}]
- def modifiersFromInternalFlags(flags: Long,privateWithin: Name,annotations: List[Tree]): Modifiers = DummyModifiers
- def newFreeExistential(name: String,info: Type,value: => Any,flags: Long,origin: String) = DummySymbol
- def newFreeTerm(name: String,info: Type,value: => Any,flags: Long,origin: String) = DummySymbol
- def newFreeType(name: String,info: Type,value: => Any,flags: Long,origin: String) = DummySymbol
- def selectOverloadedMethod(owner: Symbol,name: String,index: Int) = DummySymbol
- def selectOverloadedMethodIfDefined(owner: Symbol,name: String,index: Int) = DummySymbol
- def selectTerm(owner: Symbol,name: String) = DummySymbol
- def selectTermIfDefined(owner: Symbol,name: String) = DummySymbol
- def selectType(owner: Symbol,name: String) = DummySymbol
- def selectTypeIfDefined(owner: Symbol,name: String) = DummySymbol
- def staticClass(fullName: String) = DummySymbol
- def staticClassIfDefined(fullName: String) = DummySymbol
- def staticModule(fullName: String) = DummySymbol
- def staticModuleIfDefined(fullName: String) = DummySymbol
- def thisModuleType(fullName: String): Type = DummyType
- object DummyTreeGen extends AbsTreeGen {
- val global: Universe = DummyMirror.this
- type TreeGenTree = global.Tree
- type TreeGenType = global.Type
- type TreeGenSymbol = global.Symbol
- type TreeGenName = global.Name
- def mkAttributedQualifier(tpe: TreeGenType): TreeGenTree = notSupported()
- def mkAttributedQualifier(tpe: TreeGenType, termSym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkAttributedRef(pre: TreeGenType, sym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkAttributedRef(sym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkAttributedThis(sym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkAttributedIdent(sym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkAttributedSelect(qual: TreeGenTree, sym: TreeGenSymbol): TreeGenTree = notSupported()
- def mkMethodCall(target: TreeGenTree,targs: List[TreeGenType],args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(receiver: TreeGenTree,method: TreeGenSymbol,targs: List[TreeGenType],args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(receiver: TreeGenSymbol,methodName: TreeGenName,args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(target: TreeGenTree,args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(method: TreeGenSymbol,args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(method: TreeGenSymbol,targs: List[TreeGenType],args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkMethodCall(receiver: TreeGenSymbol,methodName: TreeGenName,targs: List[TreeGenType],args: List[TreeGenTree]): TreeGenTree = notSupported()
- def mkNullaryCall(method: TreeGenSymbol,targs: List[TreeGenType]): TreeGenTree = notSupported()
- }
-
- // Members declared in scala.reflect.api.TreePrinters
- def newTreePrinter(out: java.io.PrintWriter): TreePrinter = notSupported()
-
- // Members declared in scala.reflect.api.Trees
- def Apply(sym: Symbol,args: Tree*): Tree = Apply(EmptyTree, Nil)
- def Bind(sym: Symbol,body: Tree): Bind = Bind(DummyName, EmptyTree)
- def Block(stats: Tree*): Block = Block()
- def CaseDef(pat: Tree,body: Tree): CaseDef = CaseDef(EmptyTree, EmptyTree, EmptyTree)
- def ClassDef(sym: Symbol,impl: Template): ClassDef = ClassDef(DummyModifiers, DummyName, Nil, Template(Nil, emptyValDef, Nil))
- def DefDef(sym: Symbol,rhs: List[List[Symbol]] => Tree): DefDef = DefDef(DummyModifiers, DummyName, Nil, Nil, EmptyTree, EmptyTree)
- def DefDef(sym: Symbol,rhs: Tree): DefDef = DefDef(DummyModifiers, DummyName, Nil, Nil, EmptyTree, EmptyTree)
- def DefDef(sym: Symbol,mods: Modifiers,rhs: Tree): DefDef = DefDef(DummyModifiers, DummyName, Nil, Nil, EmptyTree, EmptyTree)
- def DefDef(sym: Symbol,vparamss: List[List[ValDef]],rhs: Tree): DefDef = DefDef(DummyModifiers, DummyName, Nil, Nil, EmptyTree, EmptyTree)
- def DefDef(sym: Symbol,mods: Modifiers,vparamss: List[List[ValDef]],rhs: Tree): DefDef = DefDef(DummyModifiers, DummyName, Nil, Nil, EmptyTree, EmptyTree)
- def Ident(sym: Symbol): Ident = Ident(DummyName)
- def Ident(name: String): Ident = Ident(DummyName)
- def LabelDef(sym: Symbol,params: List[Symbol],rhs: Tree): LabelDef = LabelDef(DummyName, Nil, EmptyTree)
- type Modifiers = DummyModifiers.type
- val NoMods: Modifiers = DummyModifiers
- object DummyModifiers extends AbsModifiers {
- def modifiers: Set[Modifier] = notSupported()
- def hasModifier(mod: Modifier): Boolean = notSupported()
- def privateWithin: Name = notSupported()
- def annotations: List[Tree] = notSupported()
- def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers = notSupported()
- }
- def Modifiers(mods: Set[scala.reflect.api.Modifier],privateWithin: Name,annotations: List[Tree]): Modifiers = DummyModifiers
- def ModuleDef(sym: Symbol,impl: Template): ModuleDef = ModuleDef(DummyModifiers, DummyName, Template(Nil, emptyValDef, Nil))
- def New(sym: Symbol,args: Tree*): Tree = New(EmptyTree)
- def New(tpe: Type,args: Tree*): Tree = New(EmptyTree)
- def New(tpt: Tree,argss: List[List[Tree]]): Tree = New(EmptyTree)
- def Select(qualifier: Tree,sym: Symbol): Select = Select(EmptyTree, DummyName)
- def Select(qualifier: Tree,name: String): Select = Select(EmptyTree, DummyName)
- def Super(sym: Symbol,mix: TypeName): Tree = Super(EmptyTree, DummyName)
- def This(sym: Symbol): Tree = This(DummyName)
- def Throw(tpe: Type,args: Tree*): Throw = Throw(EmptyTree)
- def Try(body: Tree,cases: (Tree, Tree)*): Try = Try(EmptyTree)
- def TypeDef(sym: Symbol): TypeDef = TypeDef(DummyModifiers, DummyName, Nil, EmptyTree)
- def TypeDef(sym: Symbol,rhs: Tree): TypeDef = TypeDef(DummyModifiers, DummyName, Nil, EmptyTree)
- def ValDef(sym: Symbol): ValDef = ValDef(DummyModifiers, DummyName, EmptyTree, EmptyTree)
- def ValDef(sym: Symbol,rhs: Tree): ValDef = ValDef(DummyModifiers, DummyName, EmptyTree, EmptyTree)
- protected def duplicateTree(tree: Tree): Tree = notSupported()
- object emptyValDef extends ValDef(DummyModifiers, DummyName, EmptyTree, EmptyTree) { override def isEmpty = true }
- type TreeCopier = DummyTreeCopier.type
- def newStrictTreeCopier: TreeCopier = DummyTreeCopier
- def newLazyTreeCopier: TreeCopier = DummyTreeCopier
- object DummyTreeCopier extends TreeCopierOps {
- def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template): ClassDef = notSupported()
- def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]): PackageDef = notSupported()
- def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template): ModuleDef = notSupported()
- def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree): ValDef = notSupported()
- def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef = notSupported()
- def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree): TypeDef = notSupported()
- def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef = notSupported()
- def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]): Import = notSupported()
- def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]): Template = notSupported()
- def Block(tree: Tree, stats: List[Tree], expr: Tree): Block = notSupported()
- def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree): CaseDef = notSupported()
- def Alternative(tree: Tree, trees: List[Tree]): Alternative = notSupported()
- def Star(tree: Tree, elem: Tree): Star = notSupported()
- def Bind(tree: Tree, name: Name, body: Tree): Bind = notSupported()
- def UnApply(tree: Tree, fun: Tree, args: List[Tree]): UnApply = notSupported()
- def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]): ArrayValue = notSupported()
- def Function(tree: Tree, vparams: List[ValDef], body: Tree): Function = notSupported()
- def Assign(tree: Tree, lhs: Tree, rhs: Tree): Assign = notSupported()
- def AssignOrNamedArg(tree: Tree, lhs: Tree, rhs: Tree): AssignOrNamedArg = notSupported()
- def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree): If = notSupported()
- def Match(tree: Tree, selector: Tree, cases: List[CaseDef]): Match = notSupported()
- def Return(tree: Tree, expr: Tree): Return = notSupported()
- def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree): Try = notSupported()
- def Throw(tree: Tree, expr: Tree): Throw = notSupported()
- def New(tree: Tree, tpt: Tree): New = notSupported()
- def Typed(tree: Tree, expr: Tree, tpt: Tree): Typed = notSupported()
- def TypeApply(tree: Tree, fun: Tree, args: List[Tree]): TypeApply = notSupported()
- def Apply(tree: Tree, fun: Tree, args: List[Tree]): Apply = notSupported()
- def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]): ApplyDynamic = notSupported()
- def Super(tree: Tree, qual: Tree, mix: TypeName): Super = notSupported()
- def This(tree: Tree, qual: Name): This = notSupported()
- def Select(tree: Tree, qualifier: Tree, selector: Name): Select = notSupported()
- def Ident(tree: Tree, name: Name): Ident = notSupported()
- def ReferenceToBoxed(tree: Tree, idt: Ident): ReferenceToBoxed = notSupported()
- def Literal(tree: Tree, value: Constant): Literal = notSupported()
- def TypeTree(tree: Tree): TypeTree = notSupported()
- def Annotated(tree: Tree, annot: Tree, arg: Tree): Annotated = notSupported()
- def SingletonTypeTree(tree: Tree, ref: Tree): SingletonTypeTree = notSupported()
- def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name): SelectFromTypeTree = notSupported()
- def CompoundTypeTree(tree: Tree, templ: Template): CompoundTypeTree = notSupported()
- def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]): AppliedTypeTree = notSupported()
- def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree): TypeBoundsTree = notSupported()
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree = notSupported()
- }
-
- // Members declared in scala.reflect.api.Types
- type Type = DummyType.type
- type SingletonType = DummyType.type
- type CompoundType = DummyType.type
- type AnnotatedType = DummyType.type
- val AnnotatedType: AnnotatedTypeExtractor = DummyAnnotatedTypeExtractor
- type BoundedWildcardType = DummyType.type
- val BoundedWildcardType: BoundedWildcardTypeExtractor = DummyBoundedWildcardTypeExtractor
- type ClassInfoType = DummyType.type
- val ClassInfoType: ClassInfoTypeExtractor = DummyClassInfoTypeExtractor
- type ConstantType = DummyType.type
- val ConstantType: ConstantTypeExtractor = DummyConstantTypeExtractor
- type ExistentialType = DummyType.type
- val ExistentialType: ExistentialTypeExtractor = DummyExistentialTypeExtractor
- type MethodType = DummyType.type
- val MethodType: MethodTypeExtractor = DummyMethodTypeExtractor
- val NoPrefix: Type = DummyType
- val NoType: Type = DummyType
- type NullaryMethodType = DummyType.type
- val NullaryMethodType: NullaryMethodTypeExtractor = DummyNullaryMethodTypeExtractor
- type PolyType = DummyType.type
- val PolyType: PolyTypeExtractor = DummyPolyTypeExtractor
- type RefinedType = DummyType.type
- val RefinedType: RefinedTypeExtractor = DummyRefinedTypeExtractor
- type SingleType = DummyType.type
- val SingleType: SingleTypeExtractor = DummySingleTypeExtractor
- type SuperType = DummyType.type
- val SuperType: SuperTypeExtractor = DummySuperTypeExtractor
- type ThisType = DummyType.type
- val ThisType: ThisTypeExtractor = DummyThisTypeExtractor
- type TypeBounds = DummyType.type
- val TypeBounds: TypeBoundsExtractor = DummyTypeBoundsExtractor
- type TypeRef = DummyType.type
- val TypeRef: TypeRefExtractor = DummyTypeRefExtractor
- val WildcardType: Type = DummyType
- def appliedType(tycon: Type,args: List[Type]): Type = DummyType
- def existentialAbstraction(tparams: List[Symbol],tpe0: Type): Type = DummyType
- def glb(ts: List[Type]): Type = DummyType
- def intersectionType(tps: List[Type],owner: Symbol): Type = DummyType
- def intersectionType(tps: List[Type]): Type = DummyType
- def lub(xs: List[Type]): Type = DummyType
- def polyType(tparams: List[Symbol],tpe: Type): Type = DummyType
- def refinedType(parents: List[Type],owner: Symbol): Type = DummyType
- def refinedType(parents: List[Type],owner: Symbol,decls: Scope,pos: Position): Type = DummyType
- def singleType(pre: Type,sym: Symbol): Type = DummyType
- def typeRef(pre: Type,sym: Symbol,args: List[Type]): Type = DummyType
- object DummyType extends AbsType {
- def =:=(that: Type): Boolean = notSupported()
- def <:<(that: Type): Boolean = notSupported()
- def asSeenFrom(pre: Type,clazz: Symbol): Type = notSupported()
- def baseClasses: List[Symbol] = notSupported()
- def baseType(clazz: Symbol): Type = notSupported()
- def contains(sym: Symbol): Boolean = notSupported()
- def declaration(name: Name): Symbol = notSupported()
- def declarations: Iterable[Symbol] = notSupported()
- def erasure: Type = notSupported()
- def exists(p: Type => Boolean): Boolean = notSupported()
- def find(p: Type => Boolean): Option[Type] = notSupported()
- def foreach(f: Type => Unit): Unit = notSupported()
- def isConcrete: Boolean = notSupported()
- def isHigherKinded: Boolean = notSupported()
- def isSpliceable: Boolean = notSupported()
- def kind: String = notSupported()
- def map(f: Type => Type): Type = notSupported()
- def member(name: Name): Symbol = notSupported()
- def members: Iterable[Symbol] = notSupported()
- def nonPrivateMember(name: Name): Symbol = notSupported()
- def nonPrivateMembers: Iterable[Symbol] = notSupported()
- def normalize: Type = notSupported()
- def parents: List[Type] = notSupported()
- def substituteTypes(from: List[Symbol],to: List[Type]): Type = notSupported()
- def typeArguments: List[Type] = notSupported()
- def typeConstructor: Type = notSupported()
- def typeParams: List[Symbol] = notSupported()
- def typeSymbol: Symbol = notSupported()
- def underlying: Type = notSupported()
- def widen: Type = notSupported()
- }
- object DummyAnnotatedTypeExtractor extends AnnotatedTypeExtractor {
- def apply(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol): AnnotatedType = DummyType
- def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)] = notSupported()
- }
- object DummyBoundedWildcardTypeExtractor extends BoundedWildcardTypeExtractor {
- def apply(bounds: TypeBounds): BoundedWildcardType = DummyType
- def unapply(tpe: BoundedWildcardType): Option[TypeBounds] = notSupported()
- }
- object DummyClassInfoTypeExtractor extends ClassInfoTypeExtractor {
- def apply(parents: List[Type], decls: Scope, clazz: Symbol): ClassInfoType = DummyType
- def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)] = notSupported()
- }
- object DummyConstantTypeExtractor extends ConstantTypeExtractor {
- def apply(value: Constant): ConstantType = DummyType
- def unapply(tpe: ConstantType): Option[Constant] = notSupported()
- }
- object DummyExistentialTypeExtractor extends ExistentialTypeExtractor {
- def apply(quantified: List[Symbol], underlying: Type): ExistentialType = DummyType
- def unapply(tpe: ExistentialType): Option[(List[Symbol], Type)] = notSupported()
- }
- object DummyMethodTypeExtractor extends MethodTypeExtractor {
- def apply(params: List[Symbol], resultType: Type): MethodType = DummyType
- def unapply(tpe: MethodType): Option[(List[Symbol], Type)] = notSupported()
- }
- object DummyNullaryMethodTypeExtractor extends NullaryMethodTypeExtractor {
- def apply(resultType: Type): NullaryMethodType = DummyType
- def unapply(tpe: NullaryMethodType): Option[(Type)] = notSupported()
- }
- object DummyPolyTypeExtractor extends PolyTypeExtractor {
- def apply(typeParams: List[Symbol], resultType: Type): PolyType = DummyType
- def unapply(tpe: PolyType): Option[(List[Symbol], Type)] = notSupported()
- }
- object DummyRefinedTypeExtractor extends RefinedTypeExtractor {
- def apply(parents: List[Type], decls: Scope): RefinedType = DummyType
- def apply(parents: List[Type], decls: Scope, clazz: Symbol): RefinedType = DummyType
- def unapply(tpe: RefinedType): Option[(List[Type], Scope)] = notSupported()
- }
- object DummySingleTypeExtractor extends SingleTypeExtractor {
- def apply(pre: Type, sym: Symbol): Type = DummyType
- def unapply(tpe: SingleType): Option[(Type, Symbol)] = notSupported()
- }
- object DummySuperTypeExtractor extends SuperTypeExtractor {
- def apply(thistpe: Type, supertpe: Type): Type = DummyType
- def unapply(tpe: SuperType): Option[(Type, Type)] = notSupported()
- }
- object DummyThisTypeExtractor extends ThisTypeExtractor {
- def apply(sym: Symbol): Type = DummyType
- def unapply(tpe: ThisType): Option[Symbol] = notSupported()
- }
- object DummyTypeBoundsExtractor extends TypeBoundsExtractor {
- def apply(lo: Type, hi: Type): TypeBounds = DummyType
- def unapply(tpe: TypeBounds): Option[(Type, Type)] = notSupported()
- }
- object DummyTypeRefExtractor extends TypeRefExtractor {
- def apply(pre: Type, sym: Symbol, args: List[Type]): Type = DummyType
- def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])] = notSupported()
- }
-
- // Utils
- def notSupported() = {
- throw new UnsupportedOperationException("Scala reflection not available on this platform." + mirrorDiagnostics(cl))
- }
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/DynamicProxy.scala b/src/library/scala/reflect/DynamicProxy.scala
deleted file mode 100644
index 3ed17fea41..0000000000
--- a/src/library/scala/reflect/DynamicProxy.scala
+++ /dev/null
@@ -1,74 +0,0 @@
-package scala.reflect
-/**
- * A dynamic proxy which redirects method calls and attribute access to a given
- * target object at runtime using reflection.
- *
- * Usage example:
- *
- * object x{ def hello = "hello world" }
- * val d = new DynamicProxy{ val dynamicProxyTarget = x }
- * assert( d.hello == "hello world" )
- *
- * Not supported (yet):
- * - implicit conversions and parameters
- * - multiple arguments lists
- * - explicit type arguments
- */
-trait DynamicProxy extends Dynamic{
- /** Method calls on DynamicProxy are redirected to this object. Needs to be defined in a subclass. */
- val dynamicProxyTarget : AnyRef
-
- import scala.reflect.mirror._
- /**
- * boxing to preserve information on primitive types for overloading resolution
- */
- case class DynamicReflectBoxed( class_ : Class[_], value: Any )
- object DynamicReflectBoxed{
- implicit def box[@specialized T]( v:T ) = DynamicReflectBoxed( v.getClass, v )
- }
-
- def selectDynamic( method:String ) = {
- val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method).encodedName )
- invoke( dynamicProxyTarget, symbol )()
- }
-
- def updateDynamic( method:String )( value : Any ) = {
- val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method+"_=").encodedName )
- invoke( dynamicProxyTarget, symbol )( value )
- }
-
- def applyDynamic( method:String )( args:DynamicReflectBoxed* ) : Any
- = applyDynamicNamed( method )( args.map( value => ("",value) ) :_* )
-
- def applyDynamicNamed( method:String )( args:(String,DynamicReflectBoxed)* ) : Any = {
- val class_ = dynamicProxyTarget.getClass
- var i = 0
- val toolbox = mkToolBox(mkConsoleFrontEnd(),"")
- val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method).encodedName )
- if(args.size == 0){
- invoke( dynamicProxyTarget, symbol )()
- } else {
- val call =
- Apply(
- Select(
- TypeApply(
- Select(
- Select(
- Ident(newFreeTerm("__this", symbolForName("scala.reflect.DynamicProxy").asType, this))
- , newTermName("dynamicProxyTarget")
- ),
- newTermName("asInstanceOf") )
- , List(TypeTree().setType(classToType(class_)))
- )
- ,newTermName(method).encodedName
- )
- ,args.map{ case(name,box) =>
- val value = Ident(newFreeTerm("__arg"+({i+=1;i}.toString), classToType(box.class_), box.value))
- if( name == "" ) value
- else AssignOrNamedArg( Ident(name), value )
- }.toList
- )
- toolbox.runExpr( call )
- }
- }
-}
diff --git a/src/library/scala/reflect/ErasureTag.scala b/src/library/scala/reflect/ErasureTag.scala
deleted file mode 100644
index f95451fab2..0000000000
--- a/src/library/scala/reflect/ErasureTag.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-package scala.reflect
-
-import java.lang.{Class => jClass}
-
-/** An `ErasureTag[T]` is a descriptor that is requested by the compiler every time
- * when it needs to persist an erasure of a type.
- *
- * Scala library provides a standard implementation of this trait,
- * `TypeTag[T]` that carries the `java.lang.Class` erasure for arbitrary types.
- *
- * However other platforms may reimplement this trait as they see fit
- * and then expose the implementation via an implicit macro.
- *
- * If you need to guarantee that the type does not contain
- * references to type parameters or abstract types, use `ClassTag[T]`.
- *
- * @see [[scala.reflect.api.TypeTags]]
- */
-@annotation.implicitNotFound(msg = "No ErasureTag available for ${T}")
-trait ErasureTag[T] {
- /** Returns an erasure of type `T` */
- def erasure: jClass[_]
-}
diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala
index da029f046d..7e320b42eb 100644
--- a/src/library/scala/reflect/Manifest.scala
+++ b/src/library/scala/reflect/Manifest.scala
@@ -9,7 +9,6 @@
package scala.reflect
import scala.collection.mutable.{ ArrayBuilder, WrappedArray }
-import mirror._
/** A `Manifest[T]` is an opaque descriptor for type T. Its supported use
* is to give access to the erasure of the type as a `Class` instance, as
@@ -40,7 +39,7 @@ import mirror._
*
*/
@annotation.implicitNotFound(msg = "No Manifest available for ${T}.")
-@deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
+@deprecated("Use TypeTag instead", "2.10.0")
trait Manifest[T] extends ClassManifest[T] with Equals {
override def typeArguments: List[Manifest[_]] = Nil
@@ -77,7 +76,7 @@ abstract class AnyValManifest[T <: AnyVal](override val toString: String) extend
* It is intended for use by the compiler and should not be used
* in client code.
*/
-@deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
+@deprecated("Use TypeTag instead", "2.10.0")
object Manifest {
def valueManifests: List[AnyValManifest[_]] =
List(Byte, Short, Char, Int, Long, Float, Double, Boolean, Unit)
diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala
index 38fbbc98f2..ff56e20d52 100755
--- a/src/library/scala/reflect/NameTransformer.scala
+++ b/src/library/scala/reflect/NameTransformer.scala
@@ -8,8 +8,8 @@
package scala.reflect
-/**
- * @author Martin Odersky
+/** Provides functions to encode and decode Scala symbolic names.
+ * Also provides some constants.
*/
object NameTransformer {
// XXX Short term: providing a way to alter these without having to recompile
diff --git a/src/library/scala/reflect/ScalaLongSignature.java b/src/library/scala/reflect/ScalaLongSignature.java
index 1ffd6d2520..fce58207f1 100644
--- a/src/library/scala/reflect/ScalaLongSignature.java
+++ b/src/library/scala/reflect/ScalaLongSignature.java
@@ -5,7 +5,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/** */
+/**
+ * [Martin to Eugene++] Todo: Move to somewhere else?
+*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ScalaLongSignature {
diff --git a/src/library/scala/reflect/ScalaSignature.java b/src/library/scala/reflect/ScalaSignature.java
index d1cdbc0589..f0df99fe79 100644
--- a/src/library/scala/reflect/ScalaSignature.java
+++ b/src/library/scala/reflect/ScalaSignature.java
@@ -5,7 +5,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/** */
+/** * [Martin to Eugene++] Todo: Move to somewhere else?
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ScalaSignature {
diff --git a/src/library/scala/reflect/TagInterop.scala b/src/library/scala/reflect/TagInterop.scala
deleted file mode 100644
index 6c6bfcc2f2..0000000000
--- a/src/library/scala/reflect/TagInterop.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-package scala.reflect
-
-import scala.runtime.ScalaRunTime._
-import mirror._
-import definitions._
-
-object TagInterop {
- def arrayTagToClassManifest[T](tag: ArrayTag[T]): ClassManifest[T] = {
- val erasure = arrayElementClass(tag)
- if (erasure.isArray) {
- val elementClass = arrayElementClass(erasure)
- val elementManifest = arrayTagToClassManifest(ClassTag(elementClass))
- ClassManifest.arrayType(elementManifest).asInstanceOf[ClassManifest[T]]
- } else {
- ClassManifest.fromClass(erasure.asInstanceOf[Class[T]])
- }
- }
-
- def concreteTypeTagToManifest[T](tag: ConcreteTypeTag[T]): Manifest[T] = {
- // todo. reproduce manifest generation code here. toolboxes are too slow.
- val implicitly = PredefModule.typeSignature.member(newTermName("implicitly"))
- val taggedTpe = appliedType(staticClass("scala.reflect.Manifest").asTypeConstructor, List(tag.tpe))
- val materializer = TypeApply(Ident(implicitly), List(TypeTree(taggedTpe)))
- try mkToolBox().runExpr(materializer).asInstanceOf[Manifest[T]]
- catch { case ex: Throwable => Manifest.classType(tag.erasure).asInstanceOf[Manifest[T]] }
- }
-
- def manifestToConcreteTypeTag[T](tag: Manifest[T]): ConcreteTypeTag[T] = {
- val tpe =
- if (tag.typeArguments.isEmpty) classToType(tag.erasure)
- else appliedType(classToType(tag.erasure).typeConstructor, tag.typeArguments map (manifestToConcreteTypeTag(_)) map (_.tpe))
- ConcreteTypeTag(tpe, tag.erasure)
- }
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/Attachment.scala b/src/library/scala/reflect/api/Attachment.scala
deleted file mode 100644
index 50f55b4aa5..0000000000
--- a/src/library/scala/reflect/api/Attachment.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-package scala.reflect
-package api
-
-/** Attachment is a generalisation of Position.
- * Typically it stores a Position of a tree, but this can be extended to encompass arbitrary payloads.
- *
- * Attachments have to carry positions, because we don't want to introduce even a single additional field in Tree
- * imposing an unnecessary memory tax because of something that will not be used in most cases.
- */
-trait Attachment {
- /** Gets the underlying position */
- def pos: Position
-
- /** Creates a copy of this attachment with its position updated */
- def withPos(newPos: Position): Attachment
-
- /** Gets the underlying payload */
- def payload: Any
-
- /** Creates a copy of this attachment with its payload updated */
- def withPayload(newPayload: Any): Attachment
-}
-
-// [Eugene] with the introduction of `attach` and `attachment[T]` users don't need to create custom attachments anymore
-// however, we cannot move attachments to scala.reflect.internal, because they are used in Trees, which are implemented completely in scala.reflect.api
-private[scala] case class NontrivialAttachment(pos: api.Position, payload: collection.mutable.ListBuffer[Any]) extends Attachment {
- def withPos(newPos: api.Position) = copy(pos = newPos, payload = payload)
- def withPayload(newPayload: Any) = copy(pos = pos, payload = newPayload.asInstanceOf[collection.mutable.ListBuffer[Any]])
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/ClassLoaders.scala b/src/library/scala/reflect/api/ClassLoaders.scala
deleted file mode 100644
index 7be402d3df..0000000000
--- a/src/library/scala/reflect/api/ClassLoaders.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package scala.reflect
-package api
-
-trait ClassLoaders { self: Universe =>
-
- /** The symbol corresponding to the globally accessible class with the
- * given fully qualified name `fullName`.
- */
- def staticClass(fullName: String): Symbol
-
- /** The symbol corresponding to the globally accessible object with the
- * given fully qualified name `fullName`.
- */
- def staticModule(fullName: String): Symbol
-
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/Exprs.scala b/src/library/scala/reflect/api/Exprs.scala
deleted file mode 100644
index b8db64422e..0000000000
--- a/src/library/scala/reflect/api/Exprs.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Martin Odersky
- */
-
-package scala.reflect
-package api
-import language.implicitConversions
-
-trait Exprs { self: Universe =>
-
- /** An expression tree tagged with its type */
- case class Expr[+T: TypeTag](tree: Tree) {
- def tpe: Type = implicitly[TypeTag[T]].tpe
- def eval: T = mkToolBox().runExpr(tree).asInstanceOf[T]
- lazy val value: T = eval
- override def toString = "Expr["+tpe+"]("+tree+")"
- }
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/FreeVars.scala b/src/library/scala/reflect/api/FreeVars.scala
deleted file mode 100644
index 0bef099a55..0000000000
--- a/src/library/scala/reflect/api/FreeVars.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-package scala.reflect
-package api
-
-trait FreeVars {
- self: Universe =>
-
- /** Represents a free term captured by reification.
- */
- type FreeTerm <: Symbol
-
- val FreeTerm: FreeTermExtractor
-
- abstract class FreeTermExtractor {
- def unapply(freeTerm: FreeTerm): Option[(TermName, Type, Any, String)]
- }
-
- /** Extracts free terms from a tree that is reified or contains reified subtrees.
- */
- def freeTerms(tree: Tree): List[FreeTerm]
-
- /** Represents a free type captured by reification.
- */
- type FreeType <: Symbol
-
- val FreeType: FreeTypeExtractor
-
- abstract class FreeTypeExtractor {
- def unapply(freeType: FreeType): Option[(TypeName, Type, String)]
- }
-
- /** Extracts free types from a tree that is reified or contains reified subtrees.
- */
- def freeTypes(tree: Tree): List[FreeType]
-
- /** Substitutes free types in a reified tree.
- */
- def substituteFreeTypes(tree: Tree, subs: Map[FreeType, Type]): Tree
-
- /** Substitutes free types in a reified type.
- */
- def substituteFreeTypes(tpe: Type, subs: Map[FreeType, Type]): Type
-}
diff --git a/src/library/scala/reflect/api/Mirror.scala b/src/library/scala/reflect/api/Mirror.scala
deleted file mode 100644
index ed8ead7aaf..0000000000
--- a/src/library/scala/reflect/api/Mirror.scala
+++ /dev/null
@@ -1,100 +0,0 @@
-package scala.reflect
-package api
-
-/** A mirror establishes connections of
- * runtime entities such as class names and object instances
- * with a reflexive universe.
- */
-trait Mirror extends Universe {
-
- /** Class loader that is a mastermind behind the reflexive mirror.
- *
- * By default it is set to system classloader (more precisely, to the classloader that loads the `scala.reflect.package` class).
- * However, sometimes it is useful to have a mirror services by a custom classloader.
- *
- * There are two ways to customize the `classLoader`:
- * 1) Create a new mirror using the `scala.reflect.mkMirror(classLoader: ClassLoader)` method
- * 2) Set `classLoader` to the new value
- *
- * The first, immutable, way should be strongly preferred in most situation.
- * However sometimes it is necessary to migrate the default reflexive mirror (`scala.reflect.mirror`) to a new classloader.
- * In that and only that case, use the setter, but be very careful not to introduce inconsistencies.
- */
- var classLoader: ClassLoader
-
- /** The Scala class symbol that has given fully qualified name
- * @param name The fully qualified name of the class to be returned
- * @throws java.lang.ClassNotFoundException if no class with that name exists
- * to do: throws anything else?
- */
- def symbolForName(name: String): Symbol
-
- /** Return a reference to the companion object of the given class symbol.
- */
- def companionInstance(clazz: Symbol): AnyRef
-
- /** The Scala class symbol corresponding to the runtime class of the given instance.
- * @param instance The instance
- * @return The class Symbol for the instance
- * @throws ?
- */
- def symbolOfInstance(instance: Any): Symbol
-
- /** The Scala type corresponding to the runtime type of given instance.
- * If the underlying class is parameterized, this will be an existential type,
- * with unknown type arguments.
- *
- * @param instance The instance.
- * @return The Type of the given instance.
- * @throws ?
- */
- def typeOfInstance(instance: Any): Type
-
- /** The value of a field on a receiver instance.
- * @param receiver The receiver instance
- * @param field The field
- * @return The value contained in `receiver.field`.
- */
- def getValueOfField(receiver: AnyRef, field: Symbol): Any
-
- /** Sets the value of a field on a receiver instance.
- * @param receiver The receiver instance
- * @param field The field
- * @param value The new value to be stored in the field.
- */
- def setValueOfField(receiver: AnyRef, field: Symbol, value: Any): Unit
-
- /** Invokes a method on a receiver instance with some arguments
- * @param receiver The receiver instance
- * @param meth The method
- * @param args The method call's arguments
- * @return The result of invoking `receiver.meth(args)`
- */
- def invoke(receiver: AnyRef, meth: Symbol)(args: Any*): Any
-
- /** Maps a Java class to a Scala type reference
- * @param clazz The Java class object
- * @return A type (of kind `TypeRef`, or `ExistentialType` if `clazz` is polymorphic)
- * that represents the class with all type parameters unknown
- * (i.e. any type parameters of `clazz` are existentially quantified).
- * */
- def classToType(clazz: java.lang.Class[_]): Type
-
- /** Maps a Java class to a Scala class symbol
- * @param clazz The Java class object
- * @return A symbol that represents the Scala view of the class.
- */
- def classToSymbol(clazz: java.lang.Class[_]): Symbol
-
- /** Maps a Scala type to the corresponding Java class object
- */
- def typeToClass(tpe: Type): java.lang.Class[_]
-
- /** Maps a Scala symbol to the corresponding Java class object
- * @throws ClassNotFoundException if there is no Java class
- * corresponding to the given Scala symbol.
- * Note: If the Scala symbol is ArrayClass, a ClassNotFound exception is thrown
- * because there is no unique Java class corresponding to a Scala generic array
- */
- def symbolToClass(sym: Symbol): java.lang.Class[_]
-}
diff --git a/src/library/scala/reflect/api/Modifier.scala b/src/library/scala/reflect/api/Modifier.scala
deleted file mode 100644
index 1b67929e15..0000000000
--- a/src/library/scala/reflect/api/Modifier.scala
+++ /dev/null
@@ -1,82 +0,0 @@
-package scala.reflect.api
-
-import collection.{ immutable, mutable }
-
-abstract class Modifier private[api] () {
- def name: String
- def isKeyword: Boolean
- def sourceString: String = if (isKeyword) "`" + name + "`" else name
-
- override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
- override def hashCode = name.hashCode
- override def toString = name
-}
-final class SymbolModifier private (val name: String, val isKeyword: Boolean) extends Modifier {
- def this(name: String) = this(name, false)
-}
-final class SourceModifier private (val name: String) extends Modifier {
- def isKeyword = true
-}
-
-object SymbolModifier {
- private val seen = mutable.ListBuffer[SymbolModifier]()
- private[api] def apply(name: String): SymbolModifier = {
- val mod = name match {
- case "case" | "trait" => new SymbolModifier(name, isKeyword = true)
- case _ => new SymbolModifier(name)
- }
- seen += mod
- mod
- }
- private[api] def all = seen.toList
-}
-object SourceModifier {
- private val seen = mutable.ListBuffer[SourceModifier]()
- private[api] def apply(name: String): SourceModifier = {
- val mod = new SourceModifier(name)
- seen += mod
- mod
- }
- private[api] def all = seen.toList
-}
-
-object Modifier extends immutable.Set[Modifier] {
- val `abstract` = SourceModifier("abstract")
- val `final` = SourceModifier("final")
- val `implicit` = SourceModifier("implicit")
- val `lazy` = SourceModifier("lazy")
- val `macro` = SourceModifier("macro")
- val `override` = SourceModifier("override")
- val `private` = SourceModifier("private")
- val `protected` = SourceModifier("protected")
- val `sealed` = SourceModifier("sealed")
-
- val `case` = SymbolModifier("case")
- val `trait` = SymbolModifier("trait")
- val abstractOverride = SymbolModifier("abstractOverride")
- val bynameParameter = SymbolModifier("bynameParameter")
- val caseAccessor = SymbolModifier("caseAccessor")
- val contravariant = SymbolModifier("contravariant")
- val covariant = SymbolModifier("covariant")
- val defaultInit = SymbolModifier("defaultInit")
- val defaultParameter = SymbolModifier("defaultParameter")
- val deferred = SymbolModifier("deferred")
- val interface = SymbolModifier("interface")
- val java = SymbolModifier("java")
- val local = SymbolModifier("local")
- val mutable = SymbolModifier("mutable")
- val paramAccessor = SymbolModifier("paramAccessor")
- val parameter = SymbolModifier("parameter")
- val preSuper = SymbolModifier("preSuper")
- val static = SymbolModifier("static")
-
- val sourceModifiers: Set[SourceModifier] = SourceModifier.all.toSet
- val symbolModifiers: Set[SymbolModifier] = SymbolModifier.all.toSet
- val allModifiers: Set[Modifier] = sourceModifiers ++ symbolModifiers
- def values = allModifiers
-
- def contains(key: Modifier) = allModifiers(key)
- def iterator = allModifiers.iterator
- def -(elem: Modifier) = allModifiers - elem
- def +(elem: Modifier) = allModifiers + elem
-}
diff --git a/src/library/scala/reflect/api/StandardDefinitions.scala b/src/library/scala/reflect/api/StandardDefinitions.scala
deleted file mode 100755
index 21f7c9283b..0000000000
--- a/src/library/scala/reflect/api/StandardDefinitions.scala
+++ /dev/null
@@ -1,145 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Martin Odersky
- */
-
-package scala.reflect
-package api
-
-trait StandardTypes {
- self: Universe =>
-
- val ByteTpe: Type
- val ShortTpe: Type
- val CharTpe: Type
- val IntTpe: Type
- val LongTpe: Type
- val FloatTpe: Type
- val DoubleTpe: Type
- val BooleanTpe: Type
- val UnitTpe: Type
-
- val AnyTpe: Type
- val AnyValTpe: Type
- val AnyRefTpe: Type
- val ObjectTpe: Type
-
- val NothingTpe: Type
- val NullTpe: Type
- val StringTpe: Type
-}
-
-trait StandardDefinitions extends StandardTypes {
- self: Universe =>
-
- val definitions: AbsDefinitions
-
- // I intend to pull everything in here out of the public API.
- trait AbsDefinitionsInternal {
- def ArrayModule: Symbol
- def ArrayModule_overloadedApply: Symbol
- def Array_apply: Symbol
- def Array_clone: Symbol
- def Array_length: Symbol
- def Array_update: Symbol
- def ByNameParamClass: Symbol
- def ClassTagModule: Symbol
- def ConcreteTypeTagModule: Symbol
- def ConsClass: Symbol
- def EmptyPackageClass: Symbol
- def FunctionClass : Array[Symbol]
- def IterableClass: Symbol
- def IteratorClass: Symbol
- def IteratorModule: Symbol
- def Iterator_apply: Symbol
- def JavaLangPackageClass: Symbol
- def JavaRepeatedParamClass: Symbol
- def ListModule: Symbol
- def List_apply: Symbol
- def NilModule: Symbol
- def NoneModule: Symbol
- def OptionClass: Symbol
- def ProductClass : Array[Symbol]
- def RepeatedParamClass: Symbol
- def ScalaPackageClass: Symbol
- def SeqClass: Symbol
- def SeqModule: Symbol
- def SomeClass: Symbol
- def SomeModule: Symbol
- def StringBuilderClass: Symbol
- def SymbolClass : Symbol
- def TraversableClass: Symbol
- def TupleClass : Array[Symbol]
- def TypeTagModule: Symbol
- def ScalaPrimitiveValueClasses: List[ClassSymbol]
- }
-
- trait AbsDefinitions extends AbsDefinitionsInternal {
- // packages
- def RootClass: ClassSymbol
- def RootPackage: PackageSymbol
- def EmptyPackage: PackageSymbol
- def ScalaPackage: PackageSymbol
- def JavaLangPackage: PackageSymbol
-
- // top types
- def AnyClass : ClassSymbol
- def AnyValClass: ClassSymbol
- def ObjectClass: ClassSymbol
- def AnyRefClass: TypeSymbol
-
- // bottom types
- def NullClass : ClassSymbol
- def NothingClass: ClassSymbol
-
- // the scala value classes
- def UnitClass : ClassSymbol
- def ByteClass : ClassSymbol
- def ShortClass : ClassSymbol
- def CharClass : ClassSymbol
- def IntClass : ClassSymbol
- def LongClass : ClassSymbol
- def FloatClass : ClassSymbol
- def DoubleClass : ClassSymbol
- def BooleanClass: ClassSymbol
-
- // some special classes
- def StringClass : ClassSymbol
- def ClassClass : ClassSymbol
- def ArrayClass: ClassSymbol
-
- // collections classes
- def ListClass: ClassSymbol
- def ListModule: ModuleSymbol
-
- // collections modules
- def PredefModule: ModuleSymbol
-
- // type tags
- def ClassTagClass: ClassSymbol
- def TypeTagClass: ClassSymbol
- def ConcreteTypeTagClass: ClassSymbol
-
- /** Given a type T, returns the type corresponding to the VM's
- * representation: ClassClass's type constructor applied to `arg`.
- */
- def vmClassType(arg: Type): Type // !!! better name?
- // [Eugene] we already have arg.erasure, right?
- //
- // [Paul] You misunderstand the method (it could be better named).
- // Given List[String], it returns java.lang.Class[List[String]]
- // (or the .Net equivalent), not the erasure of List[String].
- // See def ClassType in definitions - that's what it was called before,
- // and obviously that name has to go.
-
- /** The string representation used by the given type in the VM.
- */
- def vmSignature(sym: Symbol, info: Type): String
-
- /** Is symbol one of the value classes? */
- def isPrimitiveValueClass(sym: Symbol): Boolean // !!! better name?
-
- /** Is symbol one of the numeric value classes? */
- def isNumericValueClass(sym: Symbol): Boolean // !!! better name?
- }
-}
diff --git a/src/library/scala/reflect/api/ToolBoxes.scala b/src/library/scala/reflect/api/ToolBoxes.scala
deleted file mode 100644
index 15c9fcc403..0000000000
--- a/src/library/scala/reflect/api/ToolBoxes.scala
+++ /dev/null
@@ -1,90 +0,0 @@
-package scala.reflect
-package api
-
-trait ToolBoxes { self: Universe =>
-
- type ToolBox <: AbsToolBox
-
- def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = ""): AbsToolBox
-
- // [Eugene] what do you think about the interface? namely about the ``freeTypes'' part.
- trait AbsToolBox {
-
- /** Front end of the toolbox.
- *
- * Accumulates and displays warnings and errors, can drop to interactive mode (if supported).
- * The latter can be useful to study the typechecker or to debug complex macros.
- */
- def frontEnd: FrontEnd
-
- /** Typechecks a tree using this ToolBox.
- * This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.
- *
- * If the tree has unresolved type variables (represented as instances of ``FreeType'' symbols),
- * then they might, might be partially or might not be specified in the ``freeTypes'' parameter.
- *
- * If ``silent'' is false, ``TypeError'' will be thrown in case of a typecheck error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
- * Such errors don't vanish and can be inspected by turning on -Ydebug.
- *
- * Typechecking can be steered with the following optional parameters:
- * ``withImplicitViewsDisabled'' recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
- * ``withMacrosDisabled'' recursively prohibits macro expansions and macro-based implicits, default value is false
- */
- def typeCheck(tree: Tree, pt: Type = WildcardType, freeTypes: Map[FreeType, Type] = Map[FreeType, Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree
-
- /** Infers an implicit value of the expected type ``pt'' in the macro callsite context.
- *
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
- * Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
- */
- def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): Tree
-
- /** Infers an implicit view from the provided tree ``tree'' from the type ``from'' to the type ``to'' in the macro callsite context.
- *
- * Otional parameter, ``reportAmbiguous`` controls whether ambiguous implicit errors should be reported.
- * If we search for a view simply to find out whether one type is coercible to another, it might be desirable to set this flag to ``false''.
- *
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
- * Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
- */
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): Tree
-
- /** Recursively resets symbols and types in a given tree.
- *
- * Note that this does not revert the tree to its pre-typer shape.
- * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
- */
- def resetAllAttrs(tree: Tree): Tree
-
- /** Recursively resets locally defined symbols and types in a given tree.
- *
- * Note that this does not revert the tree to its pre-typer shape.
- * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
- */
- def resetLocalAttrs(tree: Tree): Tree
-
- /** Compiles and runs a tree using this ToolBox.
- *
- * If the tree has unresolved type variables (represented as instances of ``FreeType'' symbols),
- * then they all have to be specified in the ``freeTypes'' parameter or an error occurs.
- *
- * This spawns the compiler at the Namer phase, and pipelines the tree through that compiler.
- * Currently ``runExpr'' does not accept trees that already typechecked, because typechecking isn't idempotent.
- * For more info, take a look at https://issues.scala-lang.org/browse/SI-5464.
- */
- def runExpr(tree: Tree, freeTypes: Map[FreeType, Type] = Map[FreeType, Type]()): Any
-
- /** Represents an error during toolboxing
- */
- type ToolBoxError <: Throwable
- val ToolBoxError: ToolBoxErrorExtractor
- abstract class ToolBoxErrorExtractor {
- def unapply(error: ToolBoxError): Option[(ToolBox, String)]
- }
- }
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/TreeBuildUtil.scala b/src/library/scala/reflect/api/TreeBuildUtil.scala
deleted file mode 100644
index 87790b3812..0000000000
--- a/src/library/scala/reflect/api/TreeBuildUtil.scala
+++ /dev/null
@@ -1,159 +0,0 @@
-package scala.reflect
-package api
-
-trait TreeBuildUtil { self: Universe =>
-
- /** The symbol corresponding to the globally accessible class with the given fully qualified name `fullName`.
- * Unlike `staticClassIfDefined`, throws `MissingRequirementError` is requested class cannot be found.
- */
- def staticClass(fullName: String): Symbol
-
- /** The symbol corresponding to the globally accessible class with the given fully qualified name `fullName`.
- * Unlike `staticClass`, doesn't throw `MissingRequirementError` (returns NoSymbol) is requested class cannot be found.
- */
- def staticClassIfDefined(fullName: String): Symbol
-
- /** The symbol corresponding to the globally accessible object with the given fully qualified name `fullName`.
- * Unlike `staticModuleIfDefined`, throws `MissingRequirementError` is requested object cannot be found.
- */
- def staticModule(fullName: String): Symbol
-
- /** The symbol corresponding to the globally accessible object with the given fully qualified name `fullName`.
- * Unlike `staticModule`, doesn't throw `MissingRequirementError` (returns NoSymbol) is requested object cannot be found.
- */
- def staticModuleIfDefined(fullName: String): Symbol
-
- /** The this-ptype of the globally accessible object with the
- * given fully qualified name `fullName`.
- */
- def thisModuleType(fullName: String): Type
-
- /** Selects type symbol with given simple name `name` from the defined members of `owner`.
- * Unlike `selectTypeIfDefined`, throws `MissingRequirementError` is requested type symbol cannot be found.
- */
- def selectType(owner: Symbol, name: String): Symbol
-
- /** Selects type symbol with given simple name `name` from the defined members of `owner`.
- * Unlike `selectType`, doesn't throw `MissingRequirementError` (returns NoSymbol) is requested type symbol cannot be found.
- */
- def selectTypeIfDefined(owner: Symbol, name: String): Symbol
-
- /** Selects term symbol with given name and type from the defined members of prefix type
- * Unlike `selectTermIfDefined`, throws `MissingRequirementError` is requested term symbol cannot be found.
- */
- def selectTerm(owner: Symbol, name: String): Symbol
-
- /** Selects term symbol with given name and type from the defined members of prefix type
- * Unlike `selectTerm`, doesn't throw `MissingRequirementError` (returns NoSymbol) is requested term symbol cannot be found.
- */
- def selectTermIfDefined(owner: Symbol, name: String): Symbol
-
- /** Selects overloaded method symbol with given name and index
- * Unlike `selectOverloadedMethodIfDefined`, throws `MissingRequirementError` is requested overloaded method cannot be found.
- */
- def selectOverloadedMethod(owner: Symbol, name: String, index: Int): Symbol
-
- /** Selects overloaded method symbol with given name and index
- * Unlike `selectOverloadedMethod`, doesn't throw `MissingRequirementError` (returns NoSymbol) is requested overloaded method cannot be found.
- */
- def selectOverloadedMethodIfDefined(owner: Symbol, name: String, index: Int): Symbol
-
- /** Create a fresh free term symbol.
- * @param name the name of the free variable
- * @param info the type signature of the free variable
- * @param value the value of the free variable at runtime
- * @param flags (optional) flags of the free variable
- * @param origin debug information that tells where this symbol comes from
- */
- def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): Symbol
-
- /** Create a fresh free non-existential type symbol.
- * @param name the name of the free variable
- * @param info the type signature of the free variable
- * @param value a type tag that captures the value of the free variable
- * is completely phantom, since the captured type cannot be propagated to the runtime
- * if it could be, we wouldn't be creating a free type to begin with
- * the only usage for it is preserving the captured symbol for compile-time analysis
- * @param flags (optional) flags of the free variable
- * @param origin debug information that tells where this symbol comes from
- */
- def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): Symbol
-
- /** Create a fresh free existential type symbol.
- * @param name the name of the free variable
- * @param info the type signature of the free variable
- * @param value a type tag that captures the value of the free variable
- * is completely phantom, since the captured type cannot be propagated to the runtime
- * if it could be, we wouldn't be creating a free type to begin with
- * the only usage for it is preserving the captured symbol for compile-time analysis
- * @param flags (optional) flags of the free variable
- * @param origin (optional) debug information that tells where this symbol comes from
- */
- def newFreeExistential(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): Symbol
-
- /** Create a Modiiers structure given internal flags, qualifier, annotations */
- def modifiersFromInternalFlags(flags: Long, privateWithin: Name, annotations: List[Tree]): Modifiers
-
- val gen: TreeGen { val global: TreeBuildUtil.this.type }
-
- type TreeGen <: AbsTreeGen
-}
-
-// [Eugene to Paul] we need to expose some of the functionality provided by TreeGen
-// I added some stuff that was necessary for typetag materialization macros
-// but we should think it over and pick other generally useful stuff
-// same goes for tree traversers/transformers, type maps, etc
-// and once we expose all that, there's another question: how do we stay in sync?
-trait AbsTreeGen {
- val global: Universe
-
- import global._
- import definitions._
-
- /** Builds a reference to value whose type is given stable prefix.
- * The type must be suitable for this. For example, it
- * must not be a TypeRef pointing to an abstract type variable.
- */
- def mkAttributedQualifier(tpe: Type): Tree
-
- /** Builds a reference to value whose type is given stable prefix.
- * If the type is unsuitable, e.g. it is a TypeRef for an
- * abstract type variable, then an Ident will be made using
- * termSym as the Ident's symbol. In that case, termSym must
- * not be NoSymbol.
- */
- def mkAttributedQualifier(tpe: Type, termSym: Symbol): Tree
-
- /** Builds a typed reference to given symbol with given stable prefix. */
- def mkAttributedRef(pre: Type, sym: Symbol): Tree
-
- /** Builds a typed reference to given symbol. */
- def mkAttributedRef(sym: Symbol): Tree
-
- /** Builds a typed This reference to given symbol. */
- def mkAttributedThis(sym: Symbol): Tree
-
- /** Builds a typed Ident with an underlying symbol. */
- def mkAttributedIdent(sym: Symbol): Tree
-
- /** Builds a typed Select with an underlying symbol. */
- def mkAttributedSelect(qual: Tree, sym: Symbol): Tree
-
- /** A creator for method calls, e.g. fn[T1, T2, ...](v1, v2, ...)
- * There are a number of variations.
- *
- * @param receiver symbol of the method receiver
- * @param methodName name of the method to call
- * @param targs type arguments (if Nil, no TypeApply node will be generated)
- * @param args value arguments
- * @return the newly created trees.
- */
- def mkMethodCall(receiver: Symbol, methodName: Name, targs: List[Type], args: List[Tree]): Tree
- def mkMethodCall(method: Symbol, targs: List[Type], args: List[Tree]): Tree
- def mkMethodCall(method: Symbol, args: List[Tree]): Tree
- def mkMethodCall(target: Tree, args: List[Tree]): Tree
- def mkMethodCall(receiver: Symbol, methodName: Name, args: List[Tree]): Tree
- def mkMethodCall(receiver: Tree, method: Symbol, targs: List[Type], args: List[Tree]): Tree
- def mkMethodCall(target: Tree, targs: List[Type], args: List[Tree]): Tree
- def mkNullaryCall(method: Symbol, targs: List[Type]): Tree
-}
diff --git a/src/library/scala/reflect/api/TypeTags.scala b/src/library/scala/reflect/api/TypeTags.scala
deleted file mode 100644
index c58b0fcec2..0000000000
--- a/src/library/scala/reflect/api/TypeTags.scala
+++ /dev/null
@@ -1,254 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2011 LAMP/EPFL
- * @author Martin Odersky
- */
-
-package scala.reflect
-package api
-
-import java.lang.{ Class => jClass }
-import language.implicitConversions
-
-/**
- * Type tags encapsulate a representation of type T.
- * They are supposed to replace the pre-2.10 concept of a [[scala.reflect.Manifest]].
- * TypeTags are much better integrated with reflection than manifests are, and are consequently much simpler.
- *
- * === Overview ===
- *
- * Type tags are organized in a hierarchy of five classes:
- * [[scala.reflect.ArrayTag]], [[scala.reflect.ErasureTag]], [[scala.reflect.ClassTag]],
- * [[scala.reflect.api.Universe#TypeTag]] and [[scala.reflect.api.Universe#ConcreteTypeTag]].
- *
- * An [[scala.reflect.ArrayTag]] value carries knowledge about how to build an array of elements of type T.
- * Typically such operation is performed by storing an erasure and instantiating arrays via Java reflection,
- * but [[scala.reflect.ArrayTag]] only defines an interface, not an implementation, hence it only contains the factory methods
- * `newArray` and `wrap` that can be used to build, correspondingly, single-dimensional and multi-dimensional arrays.
- *
- * An [[scala.reflect.ErasureTag]] value wraps a Java class, which can be accessed via the `erasure` method.
- * This notion, previously embodied in a [[scala.reflect.ClassManifest]] together with the notion of array creation,
- * deserves a concept of itself. Quite often (e.g. for serialization or classloader introspection) it's useful to
- * know an erasure, and only it, so we've implemented this notion in [[scala.reflect.ErasureTag]].
- *
- * A [[scala.reflect.ClassTag]] is a standard implementation of both [[scala.reflect.ArrayTag]] and [[scala.reflect.ErasureTag]].
- * It guarantees that the source type T did not to contain any references to type parameters or abstract types.
- * [[scala.reflect.ClassTag]] corresponds to a previous notion of [[scala.reflect.ClassManifest]].
- *
- * A [[scala.reflect.api.Universe#TypeTag]] value wraps a full Scala type in its tpe field.
- * A [[scala.reflect.api.Universe#ConcreteTypeTag]] value is a [[scala.reflect.api.Universe#TypeTag]]
- * that is guaranteed not to contain any references to type parameters or abstract types.
- * Both flavors of TypeTags also carry an erasure, so [[scala.reflect.api.Universe#TypeTag]] is also an [[scala.reflect.ErasureTag]],
- * and [[scala.reflect.api.Universe#ConcreteTypeTag]] is additionally an [[scala.reflect.ArrayTag]] and a [[scala.reflect.ClassTag]]
- *
- * It is recommended to use the tag supertypes of to precisely express your intent, i.e.:
- * use ArrayTag when you want to construct arrays,
- * use ErasureTag when you need an erasure and don't mind it being generated for untagged abstract types,
- * use ClassTag only when you need an erasure of a type that doesn't refer to untagged abstract types.
- *
- * === Splicing ===
- *
- * Tags can be spliced, i.e. if compiler generates a tag for a type that contains references to tagged
- * type parameters or abstract type members, it will retrieve the corresponding tag and embed it into the result.
- * An example that illustrates the TypeTag embedding, consider the following function:
- *
- * import reflect.mirror._
- * def f[T: TypeTag, U] = {
- * type L = T => U
- * implicitly[TypeTag[L]]
- * }
- *
- * Then a call of f[String, Int] will yield a result of the form
- *
- * TypeTag(<[ String => U ]>).
- *
- * Note that T has been replaced by String, because it comes with a TypeTag in f, whereas U was left as a type parameter.
- *
- * === ErasureTag vs ClassTag and TypeTag vs ConcreteTypeTag ===
- *
- * Be careful with ErasureTag and TypeTag, because they will reify types even if these types are abstract.
- * This makes it easy to forget to tag one of the methods in the call chain and discover it much later in the runtime
- * by getting cryptic errors far away from their source. For example, consider the following snippet:
- *
- * def bind[T: TypeTag](name: String, value: T): IR.Result = bind((name, value))
- * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value)
- * object NamedParam {
- * implicit def namedValue[T: TypeTag](name: String, x: T): NamedParam = apply(name, x)
- * def apply[T: TypeTag](name: String, x: T): NamedParam = new Typed[T](name, x)
- * }
- *
- * This fragment of Scala REPL implementation defines a `bind` function that carries a named value along with its type
- * into the heart of the REPL. Using a [[scala.reflect.api.Universe#TypeTag]] here is reasonable, because it is desirable
- * to work with all types, even if they are type parameters or abstract type members.
- *
- * However if any of the three `TypeTag` context bounds is omitted, the resulting code will be incorrect,
- * because the missing `TypeTag` will be transparently generated by the compiler, carrying meaningless information.
- * Most likely, this problem will manifest itself elsewhere, making debugging complicated.
- * If `TypeTag` context bounds were replaced with `ConcreteTypeTag`, then such errors would be reported statically.
- * But in that case we wouldn't be able to use `bind` in arbitrary contexts.
- *
- * === Backward compatibility ===
- *
- * TypeTags correspond loosely to Manifests. More precisely:
- * The previous notion of a [[scala.reflect.ClassManifest]] corresponds to a scala.reflect.ClassTag,
- * The previous notion of a [[scala.reflect.Manifest]] corresponds to scala.reflect.mirror.ConcreteTypeTag,
- * Whereas scala.reflect.mirror.TypeTag is approximated by the previous notion of [[scala.reflect.OptManifest]].
- *
- * In Scala 2.10, manifests are deprecated, so it's adviseable to migrate them to tags,
- * because manifests might be removed in the next major release.
- *
- * In most cases it will be enough to replace ClassManifests with ClassTags and Manifests with ConcreteTypeTags,
- * however there are a few caveats:
- *
- * 1) The notion of OptManifest is no longer supported. Tags can reify arbitrary types, so they are always available.
- * // [Eugene] it might be useful, though, to guard against abstractness of the incoming type.
- *
- * 2) There's no equivalent for AnyValManifest. Consider comparing your tag with one of the core tags
- * (defined in the corresponding companion objects) to find out whether it represents a primitive value class.
- *
- * 3) There's no replacement for factory methods defined in `ClassManifest` and `Manifest` companion objects.
- * Consider assembling corresponding types using reflection API provided by Java (for classes) and Scala (for types).
- *
- * 4) Certain manifest functions (such as `<:<`, `>:>` and `typeArguments`) weren't included in the tag API.
- * Consider using reflection API provided by Java (for classes) and Scala (for types) instead.
- */
-trait TypeTags { self: Universe =>
-
- /**
- * If an implicit value of type u.TypeTag[T] is required, the compiler will make one up on demand.
- * The implicitly created value contains in its tpe field a value of type u.Type that is a reflective representation of T.
- * In that value, any occurrences of type parameters or abstract types U
- * which come themselves with a TypeTag are represented by the type referenced by that TypeTag.
- *
- * @see [[scala.reflect.api.TypeTags]]
- */
- @annotation.implicitNotFound(msg = "No TypeTag available for ${T}")
- trait TypeTag[T] extends ErasureTag[T] with Equals with Serializable {
-
- def tpe: Type
- def sym: Symbol = tpe.typeSymbol
-
- def isConcrete: Boolean = tpe.isConcrete
- def notConcrete: Boolean = !isConcrete
- def toConcrete: ConcreteTypeTag[T] = ConcreteTypeTag[T](tpe, erasure)
-
- /** case class accessories */
- override def canEqual(x: Any) = x.isInstanceOf[TypeTag[_]]
- override def equals(x: Any) = x.isInstanceOf[TypeTag[_]] && this.tpe == x.asInstanceOf[TypeTag[_]].tpe
- override def hashCode = scala.runtime.ScalaRunTime.hash(tpe)
- override def toString = if (!self.isInstanceOf[DummyMirror]) (if (isConcrete) "*ConcreteTypeTag" else "TypeTag") + "[" + tpe + "]" else "TypeTag[?]"
- }
-
- object TypeTag {
- val Byte : TypeTag[scala.Byte] = ConcreteTypeTag.Byte
- val Short : TypeTag[scala.Short] = ConcreteTypeTag.Short
- val Char : TypeTag[scala.Char] = ConcreteTypeTag.Char
- val Int : TypeTag[scala.Int] = ConcreteTypeTag.Int
- val Long : TypeTag[scala.Long] = ConcreteTypeTag.Long
- val Float : TypeTag[scala.Float] = ConcreteTypeTag.Float
- val Double : TypeTag[scala.Double] = ConcreteTypeTag.Double
- val Boolean : TypeTag[scala.Boolean] = ConcreteTypeTag.Boolean
- val Unit : TypeTag[scala.Unit] = ConcreteTypeTag.Unit
- val Any : TypeTag[scala.Any] = ConcreteTypeTag.Any
- val Object : TypeTag[java.lang.Object] = ConcreteTypeTag.Object
- val AnyVal : TypeTag[scala.AnyVal] = ConcreteTypeTag.AnyVal
- val AnyRef : TypeTag[scala.AnyRef] = ConcreteTypeTag.AnyRef
- val Nothing : TypeTag[scala.Nothing] = ConcreteTypeTag.Nothing
- val Null : TypeTag[scala.Null] = ConcreteTypeTag.Null
- val String : TypeTag[java.lang.String] = ConcreteTypeTag.String
-
- // todo. uncomment after I redo the starr
- // def apply[T](tpe1: Type, erasure1: jClass[_]): TypeTag[T] =
- def apply[T](tpe1: Type, erasure1: jClass[_]): TypeTag[T] =
- tpe1 match {
- case ByteTpe => TypeTag.Byte.asInstanceOf[TypeTag[T]]
- case ShortTpe => TypeTag.Short.asInstanceOf[TypeTag[T]]
- case CharTpe => TypeTag.Char.asInstanceOf[TypeTag[T]]
- case IntTpe => TypeTag.Int.asInstanceOf[TypeTag[T]]
- case LongTpe => TypeTag.Long.asInstanceOf[TypeTag[T]]
- case FloatTpe => TypeTag.Float.asInstanceOf[TypeTag[T]]
- case DoubleTpe => TypeTag.Double.asInstanceOf[TypeTag[T]]
- case BooleanTpe => TypeTag.Boolean.asInstanceOf[TypeTag[T]]
- case UnitTpe => TypeTag.Unit.asInstanceOf[TypeTag[T]]
- case AnyTpe => TypeTag.Any.asInstanceOf[TypeTag[T]]
- case ObjectTpe => TypeTag.Object.asInstanceOf[TypeTag[T]]
- case AnyValTpe => TypeTag.AnyVal.asInstanceOf[TypeTag[T]]
- case AnyRefTpe => TypeTag.AnyRef.asInstanceOf[TypeTag[T]]
- case NothingTpe => TypeTag.Nothing.asInstanceOf[TypeTag[T]]
- case NullTpe => TypeTag.Null.asInstanceOf[TypeTag[T]]
- case StringTpe => TypeTag.String.asInstanceOf[TypeTag[T]]
- case _ => new TypeTag[T]{ def tpe = tpe1; def erasure = erasure1 }
- }
-
- def unapply[T](ttag: TypeTag[T]): Option[Type] = Some(ttag.tpe)
- }
-
- /**
- * If an implicit value of type u.ConcreteTypeTag[T] is required, the compiler will make one up on demand following the same procedure as for TypeTags.
- * However, if the resulting type still contains references to type parameters or abstract types, a static error results.
- *
- * @see [[scala.reflect.api.TypeTags]]
- */
- @annotation.implicitNotFound(msg = "No ConcreteTypeTag available for ${T}")
- trait ConcreteTypeTag[T] extends TypeTag[T] with ClassTag[T] with Equals with Serializable {
- if (!self.isInstanceOf[DummyMirror]) {
- if (notConcrete) throw new Error("%s (%s) is not concrete and cannot be used to construct a concrete type tag".format(tpe, tpe.kind))
- }
-
- /** case class accessories */
- override def canEqual(x: Any) = x.isInstanceOf[TypeTag[_]] // this is done on purpose. TypeTag(tpe) and ConcreteTypeTag(tpe) should be equal if tpe's are equal
- override def equals(x: Any) = x.isInstanceOf[TypeTag[_]] && this.tpe == x.asInstanceOf[TypeTag[_]].tpe
- override def hashCode = scala.runtime.ScalaRunTime.hash(tpe)
- override def toString = if (!self.isInstanceOf[DummyMirror]) "ConcreteTypeTag[" + tpe + "]" else "ConcreteTypeTag[?]"
- }
-
- object ConcreteTypeTag {
- val Byte : ConcreteTypeTag[scala.Byte] = new ConcreteTypeTag[scala.Byte]{ def tpe = ByteTpe; def erasure = ClassTag.Byte.erasure; private def readResolve() = ConcreteTypeTag.Byte }
- val Short : ConcreteTypeTag[scala.Short] = new ConcreteTypeTag[scala.Short]{ def tpe = ShortTpe; def erasure = ClassTag.Short.erasure; private def readResolve() = ConcreteTypeTag.Short }
- val Char : ConcreteTypeTag[scala.Char] = new ConcreteTypeTag[scala.Char]{ def tpe = CharTpe; def erasure = ClassTag.Char.erasure; private def readResolve() = ConcreteTypeTag.Char }
- val Int : ConcreteTypeTag[scala.Int] = new ConcreteTypeTag[scala.Int]{ def tpe = IntTpe; def erasure = ClassTag.Int.erasure; private def readResolve() = ConcreteTypeTag.Int }
- val Long : ConcreteTypeTag[scala.Long] = new ConcreteTypeTag[scala.Long]{ def tpe = LongTpe; def erasure = ClassTag.Long.erasure; private def readResolve() = ConcreteTypeTag.Long }
- val Float : ConcreteTypeTag[scala.Float] = new ConcreteTypeTag[scala.Float]{ def tpe = FloatTpe; def erasure = ClassTag.Float.erasure; private def readResolve() = ConcreteTypeTag.Float }
- val Double : ConcreteTypeTag[scala.Double] = new ConcreteTypeTag[scala.Double]{ def tpe = DoubleTpe; def erasure = ClassTag.Double.erasure; private def readResolve() = ConcreteTypeTag.Double }
- val Boolean : ConcreteTypeTag[scala.Boolean] = new ConcreteTypeTag[scala.Boolean]{ def tpe = BooleanTpe; def erasure = ClassTag.Boolean.erasure; private def readResolve() = ConcreteTypeTag.Boolean }
- val Unit : ConcreteTypeTag[scala.Unit] = new ConcreteTypeTag[scala.Unit]{ def tpe = UnitTpe; def erasure = ClassTag.Unit.erasure; private def readResolve() = ConcreteTypeTag.Unit }
- val Any : ConcreteTypeTag[scala.Any] = new ConcreteTypeTag[scala.Any]{ def tpe = AnyTpe; def erasure = ClassTag.Any.erasure; private def readResolve() = ConcreteTypeTag.Any }
- val Object : ConcreteTypeTag[java.lang.Object] = new ConcreteTypeTag[java.lang.Object]{ def tpe = ObjectTpe; def erasure = ClassTag.Object.erasure; private def readResolve() = ConcreteTypeTag.Object }
- val AnyVal : ConcreteTypeTag[scala.AnyVal] = new ConcreteTypeTag[scala.AnyVal]{ def tpe = AnyValTpe; def erasure = ClassTag.AnyVal.erasure; private def readResolve() = ConcreteTypeTag.AnyVal }
- val AnyRef : ConcreteTypeTag[scala.AnyRef] = new ConcreteTypeTag[scala.AnyRef]{ def tpe = AnyRefTpe; def erasure = ClassTag.AnyRef.erasure; private def readResolve() = ConcreteTypeTag.AnyRef }
- val Nothing : ConcreteTypeTag[scala.Nothing] = new ConcreteTypeTag[scala.Nothing]{ def tpe = NothingTpe; def erasure = ClassTag.Nothing.erasure; private def readResolve() = ConcreteTypeTag.Nothing }
- val Null : ConcreteTypeTag[scala.Null] = new ConcreteTypeTag[scala.Null]{ def tpe = NullTpe; def erasure = ClassTag.Null.erasure; private def readResolve() = ConcreteTypeTag.Null }
- val String : ConcreteTypeTag[java.lang.String] = new ConcreteTypeTag[java.lang.String]{ def tpe = StringTpe; def erasure = ClassTag.String.erasure; private def readResolve() = ConcreteTypeTag.String }
-
- // todo. uncomment after I redo the starr
- // def apply[T](tpe1: Type, erasure1: jClass[_]): ConcreteTypeTag[T] =
- def apply[T](tpe1: Type, erasure1: jClass[_] = null): ConcreteTypeTag[T] =
- tpe1 match {
- case ByteTpe => ConcreteTypeTag.Byte.asInstanceOf[ConcreteTypeTag[T]]
- case ShortTpe => ConcreteTypeTag.Short.asInstanceOf[ConcreteTypeTag[T]]
- case CharTpe => ConcreteTypeTag.Char.asInstanceOf[ConcreteTypeTag[T]]
- case IntTpe => ConcreteTypeTag.Int.asInstanceOf[ConcreteTypeTag[T]]
- case LongTpe => ConcreteTypeTag.Long.asInstanceOf[ConcreteTypeTag[T]]
- case FloatTpe => ConcreteTypeTag.Float.asInstanceOf[ConcreteTypeTag[T]]
- case DoubleTpe => ConcreteTypeTag.Double.asInstanceOf[ConcreteTypeTag[T]]
- case BooleanTpe => ConcreteTypeTag.Boolean.asInstanceOf[ConcreteTypeTag[T]]
- case UnitTpe => ConcreteTypeTag.Unit.asInstanceOf[ConcreteTypeTag[T]]
- case AnyTpe => ConcreteTypeTag.Any.asInstanceOf[ConcreteTypeTag[T]]
- case ObjectTpe => ConcreteTypeTag.Object.asInstanceOf[ConcreteTypeTag[T]]
- case AnyValTpe => ConcreteTypeTag.AnyVal.asInstanceOf[ConcreteTypeTag[T]]
- case AnyRefTpe => ConcreteTypeTag.AnyRef.asInstanceOf[ConcreteTypeTag[T]]
- case NothingTpe => ConcreteTypeTag.Nothing.asInstanceOf[ConcreteTypeTag[T]]
- case NullTpe => ConcreteTypeTag.Null.asInstanceOf[ConcreteTypeTag[T]]
- case StringTpe => ConcreteTypeTag.String.asInstanceOf[ConcreteTypeTag[T]]
- case _ => new ConcreteTypeTag[T]{ def tpe = tpe1; def erasure = erasure1 }
- }
-
- def unapply[T](ttag: TypeTag[T]): Option[Type] = if (ttag.isConcrete) Some(ttag.tpe) else None
- }
-
- // incantations for summoning
- // moved to Context, since rm.tags have their own incantations in Predef, and these guys are only useful in macros
-// def tag[T](implicit ttag: TypeTag[T]) = ttag
-// def typeTag[T](implicit ttag: TypeTag[T]) = ttag
-// def concreteTag[T](implicit gttag: ConcreteTypeTag[T]) = cttag
-// def concreteTypeTag[T](implicit gttag: ConcreteTypeTag[T]) = cttag
-}
diff --git a/src/library/scala/reflect/api/AnnotationInfos.scala b/src/library/scala/reflect/base/AnnotationInfos.scala
index cc1c4d2b6b..f03644deef 100755..100644
--- a/src/library/scala/reflect/api/AnnotationInfos.scala
+++ b/src/library/scala/reflect/base/AnnotationInfos.scala
@@ -1,9 +1,10 @@
package scala.reflect
-package api
+package base
trait AnnotationInfos { self: Universe =>
- type AnnotationInfo <: AnyRef
+ type AnnotationInfo >: Null <: AnyRef
+ implicit val AnnotationInfoTag: ClassTag[AnnotationInfo]
val AnnotationInfo: AnnotationInfoExtractor
abstract class AnnotationInfoExtractor {
@@ -11,32 +12,33 @@ trait AnnotationInfos { self: Universe =>
def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])]
}
- type ClassfileAnnotArg <: AnyRef
- implicit def classfileAnnotArgTag: ArrayTag[ClassfileAnnotArg] // need a precise tag to pass to UnPickle's toArray call
+ type ClassfileAnnotArg >: Null <: AnyRef
+ implicit val ClassfileAnnotArgTag: ClassTag[ClassfileAnnotArg]
- type LiteralAnnotArg <: ClassfileAnnotArg
+ type LiteralAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
+ implicit val LiteralAnnotArgTag: ClassTag[LiteralAnnotArg]
val LiteralAnnotArg: LiteralAnnotArgExtractor
- type ArrayAnnotArg <: ClassfileAnnotArg
- val ArrayAnnotArg: ArrayAnnotArgExtractor
-
- type NestedAnnotArg <: ClassfileAnnotArg
- val NestedAnnotArg: NestedAnnotArgExtractor
-
abstract class LiteralAnnotArgExtractor {
def apply(const: Constant): LiteralAnnotArg
def unapply(arg: LiteralAnnotArg): Option[Constant]
}
+ type ArrayAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
+ implicit val ArrayAnnotArgTag: ClassTag[ArrayAnnotArg]
+ val ArrayAnnotArg: ArrayAnnotArgExtractor
+
abstract class ArrayAnnotArgExtractor {
- def apply(const: Array[ClassfileAnnotArg]): ArrayAnnotArg
+ def apply(args: Array[ClassfileAnnotArg]): ArrayAnnotArg
def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]]
}
+ type NestedAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
+ implicit val NestedAnnotArgTag: ClassTag[NestedAnnotArg]
+ val NestedAnnotArg: NestedAnnotArgExtractor
+
abstract class NestedAnnotArgExtractor {
- def apply(anninfo: AnnotationInfo): NestedAnnotArg
+ def apply(annInfo: AnnotationInfo): NestedAnnotArg
def unapply(arg: NestedAnnotArg): Option[AnnotationInfo]
}
-}
-
-
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/base/Attachments.scala b/src/library/scala/reflect/base/Attachments.scala
new file mode 100644
index 0000000000..43e870fc4f
--- /dev/null
+++ b/src/library/scala/reflect/base/Attachments.scala
@@ -0,0 +1,42 @@
+package scala.reflect
+package base
+
+/** Attachments is a generalisation of Position.
+ * Typically it stores a Position of a tree, but this can be extended to encompass arbitrary payloads.
+ *
+ * Attachments have to carry positions, because we don't want to introduce even a single additional field in Tree
+ * imposing an unnecessary memory tax because of something that will not be used in most cases.
+ */
+abstract class Attachments { self =>
+
+ type Pos >: Null
+
+ /** Gets the underlying position */
+ def pos: Pos
+
+ /** Creates a copy of this attachment with its position updated */
+ def withPos(newPos: Pos): Attachments { type Pos = self.Pos }
+
+ /** Gets the underlying payload */
+ def all: Set[Any] = Set.empty
+
+ def get[T: ClassTag]: Option[T] =
+ (all find (_.getClass == classTag[T].runtimeClass)).asInstanceOf[Option[T]]
+
+ /** Creates a copy of this attachment with its payload updated */
+ def add(attachment: Any): Attachments { type Pos = self.Pos } =
+ new NonemptyAttachments(this.pos, all + attachment)
+
+ def remove[T: ClassTag]: Attachments { type Pos = self.Pos } = {
+ val newAll = all filterNot (_.getClass == classTag[T].runtimeClass)
+ if (newAll.isEmpty) pos.asInstanceOf[Attachments { type Pos = self.Pos }]
+ else new NonemptyAttachments(this.pos, newAll)
+ }
+
+ private class NonemptyAttachments(override val pos: Pos, override val all: Set[Any]) extends Attachments {
+ type Pos = self.Pos
+ def withPos(newPos: Pos) = new NonemptyAttachments(newPos, all)
+ }
+}
+
+
diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala
new file mode 100644
index 0000000000..461eaa2e9e
--- /dev/null
+++ b/src/library/scala/reflect/base/Base.scala
@@ -0,0 +1,763 @@
+package scala.reflect
+package base
+
+import language.experimental.macros
+import java.io.PrintWriter
+import scala.annotation.switch
+import scala.ref.WeakReference
+import collection.mutable
+
+class Base extends Universe { self =>
+
+ private var nextId = 0
+
+ abstract class Symbol(val name: Name, val flags: FlagSet) extends SymbolBase {
+ val id = { nextId += 1; nextId }
+ def owner: Symbol
+ def fullName: String =
+ if (isEffectiveRoot || owner.isEffectiveRoot) name.toString else owner.fullName + "." + name
+ private def isEffectiveRoot =
+ this == NoSymbol || this == rootMirror.RootClass || this == rootMirror.EmptyPackageClass
+
+ def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol =
+ new TermSymbol(this, name, flags)
+
+ def newModuleAndClassSymbol(name: Name, pos: Position = NoPosition, flags: FlagSet = NoFlags): (ModuleSymbol, ClassSymbol) = {
+ val c = newClassSymbol(name.toTypeName, pos, flags)
+ val m = new ModuleSymbol(this, name.toTermName, flags, c)
+ (m, c)
+ }
+
+ def newMethodSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): MethodSymbol
+ = new MethodSymbol(this, name, flags)
+
+ def newTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TypeSymbol =
+ new TypeSymbol(this, name, flags)
+
+ def newClassSymbol(name: TypeName, pos: Position = NoPosition, flags: FlagSet = NoFlags): ClassSymbol =
+ new ClassSymbol(this, name, flags)
+
+ def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null) =
+ new FreeTermSymbol(this, name, flags)
+
+ def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null) =
+ new FreeTypeSymbol(this, name, flags)
+
+ private def kindString: String =
+ if (isModule) "module"
+ else if (isClass) "class"
+ else if (isFreeType) "free type"
+ else if (isType) "type"
+ else if (isMethod) "method"
+ else if (isFreeTerm) "free term"
+ else if (isTerm) "value"
+ else "symbol"
+ // [Eugene++ to Martin] base names should expose `decode`
+ override def toString() = s"$kindString $name"
+ }
+ implicit val SymbolTag = ClassTag[Symbol](classOf[Symbol])
+
+ class TermSymbol(val owner: Symbol, override val name: TermName, flags: FlagSet)
+ extends Symbol(name, flags) with TermSymbolBase
+ implicit val TermSymbolTag = ClassTag[TermSymbol](classOf[TermSymbol])
+
+ class TypeSymbol(val owner: Symbol, override val name: TypeName, flags: FlagSet)
+ extends Symbol(name, flags) with TypeSymbolBase {
+ override val asTypeConstructor = TypeRef(ThisType(owner), this, Nil)
+ }
+ implicit val TypeSymbolTag = ClassTag[TypeSymbol](classOf[TypeSymbol])
+
+ class MethodSymbol(owner: Symbol, name: TermName, flags: FlagSet)
+ extends TermSymbol(owner, name, flags) with MethodSymbolBase
+ implicit val MethodSymbolTag = ClassTag[MethodSymbol](classOf[MethodSymbol])
+
+ class ModuleSymbol(owner: Symbol, name: TermName, flags: FlagSet, override val moduleClass: Symbol)
+ extends TermSymbol(owner, name, flags) with ModuleSymbolBase
+ implicit val ModuleSymbolTag = ClassTag[ModuleSymbol](classOf[ModuleSymbol])
+
+ class ClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet)
+ extends TypeSymbol(owner, name, flags) with ClassSymbolBase
+ implicit val ClassSymbolTag = ClassTag[ClassSymbol](classOf[ClassSymbol])
+
+ class FreeTermSymbol(owner: Symbol, name: TermName, flags: FlagSet)
+ extends TermSymbol(owner, name, flags) with FreeTermSymbolBase
+ implicit val FreeTermSymbolTag = ClassTag[FreeTermSymbol](classOf[FreeTermSymbol])
+
+ class FreeTypeSymbol(owner: Symbol, name: TypeName, flags: FlagSet)
+ extends TypeSymbol(owner, name, flags) with FreeTypeSymbolBase
+ implicit val FreeTypeSymbolTag = ClassTag[FreeTypeSymbol](classOf[FreeTypeSymbol])
+
+
+ object NoSymbol extends Symbol(nme.NO_NAME, NoFlags) {
+ override def owner = throw new UnsupportedOperationException("NoSymbol.owner")
+ }
+
+ // todo. write a decent toString that doesn't crash on recursive types
+ class Type extends TypeBase { def typeSymbol: Symbol = NoSymbol }
+ implicit val TypeTagg = ClassTag[Type](classOf[Type])
+
+ val NoType = new Type
+ val NoPrefix = new Type
+
+ class SingletonType extends Type
+ implicit val SingletonTypeTag = ClassTag[SingletonType](classOf[SingletonType])
+
+ case class ThisType(sym: Symbol) extends SingletonType { override val typeSymbol = sym }
+ object ThisType extends ThisTypeExtractor
+ implicit val ThisTypeTag = ClassTag[ThisType](classOf[ThisType])
+
+ case class SingleType(pre: Type, sym: Symbol) extends SingletonType
+ object SingleType extends SingleTypeExtractor
+ implicit val SingleTypeTag = ClassTag[SingleType](classOf[SingleType])
+
+ case class SuperType(thistpe: Type, supertpe: Type) extends SingletonType
+ object SuperType extends SuperTypeExtractor
+ implicit val SuperTypeTag = ClassTag[SuperType](classOf[SuperType])
+
+ case class ConstantType(value: Constant) extends SingletonType
+ object ConstantType extends ConstantTypeExtractor
+ implicit val ConstantTypeTag = ClassTag[ConstantType](classOf[ConstantType])
+
+ case class TypeRef(pre: Type, sym: Symbol, args: List[Type]) extends Type { override val typeSymbol = sym }
+ object TypeRef extends TypeRefExtractor
+ implicit val TypeRefTag = ClassTag[TypeRef](classOf[TypeRef])
+
+ abstract class CompoundType extends Type
+ implicit val CompoundTypeTag = ClassTag[CompoundType](classOf[CompoundType])
+
+ case class RefinedType(parents: List[Type], decls: Scope) extends CompoundType
+ object RefinedType extends RefinedTypeExtractor {
+ def apply(parents: List[Type], decls: Scope, clazz: Symbol): RefinedType =
+ RefinedType(parents, decls)
+ }
+ implicit val RefinedTypeTag = ClassTag[RefinedType](classOf[RefinedType])
+
+ case class ClassInfoType(parents: List[Type], decls: Scope, override val typeSymbol: Symbol) extends CompoundType
+ object ClassInfoType extends ClassInfoTypeExtractor
+ implicit val ClassInfoTypeTag = ClassTag[ClassInfoType](classOf[ClassInfoType])
+
+ case class MethodType(params: List[Symbol], resultType: Type) extends Type
+ object MethodType extends MethodTypeExtractor
+ implicit val MethodTypeTag = ClassTag[MethodType](classOf[MethodType])
+
+ case class NullaryMethodType(resultType: Type) extends Type
+ object NullaryMethodType extends NullaryMethodTypeExtractor
+ implicit val NullaryMethodTypeTag = ClassTag[NullaryMethodType](classOf[NullaryMethodType])
+
+ case class PolyType(typeParams: List[Symbol], resultType: Type) extends Type
+ object PolyType extends PolyTypeExtractor
+ implicit val PolyTypeTag = ClassTag[PolyType](classOf[PolyType])
+
+ case class ExistentialType(quantified: List[Symbol], underlying: Type) extends Type { override def typeSymbol = underlying.typeSymbol }
+ object ExistentialType extends ExistentialTypeExtractor
+ implicit val ExistentialTypeTag = ClassTag[ExistentialType](classOf[ExistentialType])
+
+ case class AnnotatedType(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol) extends Type { override def typeSymbol = underlying.typeSymbol }
+ object AnnotatedType extends AnnotatedTypeExtractor
+ implicit val AnnotatedTypeTag = ClassTag[AnnotatedType](classOf[AnnotatedType])
+
+ case class TypeBounds(lo: Type, hi: Type) extends Type
+ object TypeBounds extends TypeBoundsExtractor
+ implicit val TypeBoundsTag = ClassTag[TypeBounds](classOf[TypeBounds])
+
+ val WildcardType = new Type
+
+ case class BoundedWildcardType(bounds: TypeBounds) extends Type
+ object BoundedWildcardType extends BoundedWildcardTypeExtractor
+ implicit val BoundedWildcardTypeTag = ClassTag[BoundedWildcardType](classOf[BoundedWildcardType])
+
+ type Scope = Iterable[Symbol]
+ implicit val ScopeTag = ClassTag[Scope](classOf[Scope])
+
+ def newScope = newScopeWith()
+ def newNestedScope(outer: Iterable[Symbol]) = newScope
+ def newScopeWith(elems: Symbol*): Scope = elems
+
+ abstract class Name(str: String) extends NameBase {
+ override def toString = str
+ }
+ implicit val NameTag = ClassTag[Name](classOf[Name])
+
+ class TermName(str: String) extends Name(str) {
+ def isTermName = true
+ def isTypeName = false
+ def toTermName = this
+ def toTypeName = new TypeName(str)
+ }
+ implicit val TermNameTag = ClassTag[TermName](classOf[TermName])
+
+ class TypeName(str: String) extends Name(str) {
+ def isTermName = false
+ def isTypeName = true
+ def toTermName = new TermName(str)
+ def toTypeName = this
+ }
+ implicit val TypeNameTag = ClassTag[TypeName](classOf[TypeName])
+
+ def newTermName(str: String) = new TermName(str)
+ def newTypeName(str: String) = new TypeName(str)
+
+ object nme extends TermNamesBase {
+ type NameType = TermName
+ val EMPTY = newTermName("")
+ val ROOT = newTermName("<root>")
+ val EMPTY_PACKAGE_NAME = newTermName("<empty>")
+ val CONSTRUCTOR = newTermName("<init>")
+ val NO_NAME = newTermName("<none>")
+ val WILDCARD = newTermName("_")
+ }
+
+ object tpnme extends TypeNamesBase {
+ type NameType = TypeName
+ val EMPTY = nme.EMPTY.toTypeName
+ val ROOT = nme.ROOT.toTypeName
+ val EMPTY_PACKAGE_NAME = nme.EMPTY_PACKAGE_NAME.toTypeName
+ val WILDCARD = nme.WILDCARD.toTypeName
+ }
+
+ type FlagSet = Long
+ val NoFlags = 0L
+ implicit val FlagSetTag = ClassTag[FlagSet](classOf[FlagSet])
+
+ class Modifiers(override val flags: FlagSet,
+ override val privateWithin: Name,
+ override val annotations: List[Tree]) extends ModifiersBase {
+ def hasFlag(flags: FlagSet) = (this.flags & flags) != 0
+ def hasAllFlags(flags: FlagSet) = (flags & ~this.flags) == 0
+ }
+
+ implicit val ModifiersTag = ClassTag[Modifiers](classOf[Modifiers])
+
+ object Modifiers extends ModifiersCreator {
+ def apply(flags: Long,
+ privateWithin: Name,
+ annotations: List[Tree]) = new Modifiers(flags, privateWithin, annotations)
+ }
+
+ case class Constant(value: Any)
+ object Constant extends ConstantExtractor
+ implicit val ConstantTag = ClassTag[Constant](classOf[Constant])
+
+ case class AnnotationInfo(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)])
+ object AnnotationInfo extends AnnotationInfoExtractor
+ implicit val AnnotationInfoTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
+
+ abstract class ClassfileAnnotArg
+ implicit val ClassfileAnnotArgTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
+
+ case class LiteralAnnotArg(const: Constant) extends ClassfileAnnotArg
+ object LiteralAnnotArg extends LiteralAnnotArgExtractor
+ implicit val LiteralAnnotArgTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
+
+ case class ArrayAnnotArg(args: Array[ClassfileAnnotArg]) extends ClassfileAnnotArg
+ object ArrayAnnotArg extends ArrayAnnotArgExtractor
+ implicit val ArrayAnnotArgTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
+
+ case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg
+ object NestedAnnotArg extends NestedAnnotArgExtractor
+ implicit val NestedAnnotArgTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
+
+ class Position extends Attachments {
+ override type Pos = Position
+ def pos = this
+ def withPos(newPos: Position) = newPos
+ def isRange = false
+ def focus = this
+ }
+ implicit val PositionTag = ClassTag[Position](classOf[Position])
+
+ val NoPosition = new Position
+
+ def atPos[T <: Tree](pos: Position)(tree: T): T = tree
+
+ private val generated = new mutable.HashMap[String, WeakReference[Symbol]]
+
+ private def cached(name: String)(symExpr: => Symbol): Symbol =
+ generated get name match {
+ case Some(WeakReference(sym)) =>
+ sym
+ case _ =>
+ val sym = symExpr
+ generated(name) = WeakReference(sym)
+ sym
+ }
+
+ object build extends BuildBase {
+ def selectType(owner: Symbol, name: String): TypeSymbol = {
+ val clazz = new ClassSymbol(owner, newTypeName(name), NoFlags)
+ cached(clazz.fullName)(clazz).asTypeSymbol
+ }
+
+ def selectTerm(owner: Symbol, name: String): TermSymbol = {
+ val valu = new MethodSymbol(owner, newTermName(name), NoFlags)
+ cached(valu.fullName)(valu).asTermSymbol
+ }
+
+ def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol =
+ selectTerm(owner, name).asMethodSymbol
+
+ def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol =
+ if (name.isTypeName)
+ if (isClass) new ClassSymbol(owner, name.toTypeName, flags)
+ else new TypeSymbol(owner, name.toTypeName, flags)
+ else new TermSymbol(owner, name.toTermName, flags)
+
+ def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol =
+ new FreeTermSymbol(rootMirror.RootClass, newTermName(name), flags)
+
+ def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
+ new FreeTypeSymbol(rootMirror.RootClass, newTypeName(name), flags)
+
+ def newFreeExistential(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
+ new FreeTypeSymbol(rootMirror.RootClass, newTypeName(name), flags)
+
+ def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S = sym
+
+ def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S = sym
+
+ def flagsFromBits(bits: Long): FlagSet = bits
+
+ object emptyValDef extends ValDef(NoMods, nme.WILDCARD, TypeTree(NoType), EmptyTree) {
+ override def isEmpty = true
+ }
+
+ def This(sym: Symbol): Tree = self.This(sym.name.toTypeName)
+
+ def Select(qualifier: Tree, sym: Symbol): Select = self.Select(qualifier, sym.name)
+
+ def Ident(sym: Symbol): Ident = self.Ident(sym.name)
+
+ def TypeTree(tp: Type): TypeTree = self.TypeTree()
+
+ def thisPrefix(sym: Symbol): Type = SingleType(NoPrefix, sym)
+
+ def setType[T <: Tree](tree: T, tpe: Type): T = tree
+
+ def setSymbol[T <: Tree](tree: T, sym: Symbol): T = tree
+ }
+
+ import build._
+
+ class Mirror extends MirrorOf[self.type] {
+ val universe: self.type = self
+
+ lazy val RootClass = new ClassSymbol(NoSymbol, tpnme.ROOT, NoFlags)
+ lazy val RootPackage = new ModuleSymbol(NoSymbol, nme.ROOT, NoFlags, RootClass)
+ lazy val EmptyPackageClass = new ClassSymbol(RootClass, tpnme.EMPTY_PACKAGE_NAME, NoFlags)
+ lazy val EmptyPackage = new ModuleSymbol(RootClass, nme.EMPTY_PACKAGE_NAME, NoFlags, EmptyPackageClass)
+
+ def staticClass(fullName: String): ClassSymbol =
+ mkStatic[ClassSymbol](fullName)
+
+ def staticModule(fullName: String): ModuleSymbol =
+ mkStatic[ModuleSymbol](fullName)
+
+ private def mkStatic[S <: Symbol : ClassTag](fullName: String): S =
+ cached(fullName) {
+ val point = fullName lastIndexOf '.'
+ val owner =
+ if (point > 0) staticModule(fullName take point).moduleClass
+ else rootMirror.RootClass
+ val name = fullName drop point + 1
+ val symtag = implicitly[ClassTag[S]]
+ if (symtag == ClassSymbolTag) new ClassSymbol(owner, newTypeName(name), NoFlags)
+ else owner.newModuleAndClassSymbol(newTermName(name))._1
+ }.asInstanceOf[S]
+ }
+
+ lazy val rootMirror = new Mirror
+
+ import rootMirror._
+
+ object definitions extends DefinitionsBase {
+ lazy val ScalaPackage = staticModule("scala")
+ lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClassSymbol
+
+ lazy val AnyClass = staticClass("scala.Any")
+ lazy val AnyValClass = staticClass("scala.Any")
+ lazy val ObjectClass = staticClass("java.lang.Object")
+ lazy val AnyRefClass = ObjectClass
+
+ lazy val NullClass = staticClass("scala.Null")
+ lazy val NothingClass = staticClass("scala.Nothing")
+
+ lazy val UnitClass = staticClass("scala.Unit")
+ lazy val ByteClass = staticClass("scala.Byte")
+ lazy val ShortClass = staticClass("scala.Short")
+ lazy val CharClass = staticClass("scala.Char")
+ lazy val IntClass = staticClass("scala.Int")
+ lazy val LongClass = staticClass("scala.Long")
+ lazy val FloatClass = staticClass("scala.Float")
+ lazy val DoubleClass = staticClass("scala.Double")
+ lazy val BooleanClass = staticClass("scala.Boolean")
+
+ lazy val StringClass = staticClass("java.lang.String")
+ lazy val ClassClass = staticClass("java.lang.Class")
+ lazy val ArrayClass = staticClass("scala.Array")
+ lazy val ListClass = staticClass("scala.List")
+
+ lazy val PredefModule = staticModule("scala.Predef")
+ }
+
+ import definitions._
+
+ private def thisModuleType(fullName: String): Type = ThisType(staticModule(fullName).moduleClass)
+ private lazy val ScalaPrefix = thisModuleType("scala")
+ private lazy val JavaLangPrefix = thisModuleType("java.lang")
+
+ lazy val ByteTpe = TypeRef(ScalaPrefix, ByteClass, Nil)
+ lazy val ShortTpe = TypeRef(ScalaPrefix, ShortClass, Nil)
+ lazy val CharTpe = TypeRef(ScalaPrefix, CharClass, Nil)
+ lazy val IntTpe = TypeRef(ScalaPrefix, IntClass, Nil)
+ lazy val LongTpe = TypeRef(ScalaPrefix, LongClass, Nil)
+ lazy val FloatTpe = TypeRef(ScalaPrefix, FloatClass, Nil)
+ lazy val DoubleTpe = TypeRef(ScalaPrefix, DoubleClass, Nil)
+ lazy val BooleanTpe = TypeRef(ScalaPrefix, BooleanClass, Nil)
+ lazy val UnitTpe = TypeRef(ScalaPrefix, UnitClass, Nil)
+ lazy val AnyTpe = TypeRef(ScalaPrefix, AnyClass, Nil)
+ lazy val AnyValTpe = TypeRef(ScalaPrefix, AnyValClass, Nil)
+ lazy val NothingTpe = TypeRef(ScalaPrefix, NothingClass, Nil)
+ lazy val NullTpe = TypeRef(ScalaPrefix, NullClass, Nil)
+ lazy val ObjectTpe = TypeRef(JavaLangPrefix, ObjectClass, Nil)
+ lazy val AnyRefTpe = ObjectTpe
+ lazy val StringTpe = TypeRef(JavaLangPrefix, StringClass, Nil)
+
+ private var nodeCount = 0 // not synchronized
+
+ abstract class Tree extends TreeBase with Product {
+ def isDef: Boolean = false
+ def isEmpty: Boolean = false
+
+ /** The canonical way to test if a Tree represents a term.
+ */
+ def isTerm: Boolean = this match {
+ case _: TermTree => true
+ case Bind(name, _) => name.isTermName
+ case Select(_, name) => name.isTermName
+ case Ident(name) => name.isTermName
+ case Annotated(_, arg) => arg.isTerm
+ case _ => false
+ }
+
+ /** The canonical way to test if a Tree represents a type.
+ */
+ def isType: Boolean = this match {
+ case _: TypTree => true
+ case Bind(name, _) => name.isTypeName
+ case Select(_, name) => name.isTypeName
+ case Ident(name) => name.isTypeName
+ case Annotated(_, arg) => arg.isType
+ case _ => false
+ }
+ }
+
+ def show(tree: Tree) = s"<tree ${tree.getClass}>"
+
+ trait TermTree extends Tree
+
+ trait TypTree extends Tree
+
+ trait SymTree extends Tree
+
+ trait NameTree extends Tree {
+ def name: Name
+ }
+
+ trait RefTree extends SymTree with NameTree {
+ def qualifier: Tree // empty for Idents
+ def name: Name
+ }
+
+ abstract class DefTree extends SymTree with NameTree {
+ def name: Name
+ override def isDef = true
+ }
+
+ case object EmptyTree extends TermTree {
+ override def isEmpty = true
+ }
+
+ abstract class MemberDef extends DefTree {
+ def mods: Modifiers
+ }
+
+ case class PackageDef(pid: RefTree, stats: List[Tree])
+ extends MemberDef {
+ def name = pid.name
+ def mods = NoMods
+ }
+ object PackageDef extends PackageDefExtractor
+
+ abstract class ImplDef extends MemberDef {
+ def impl: Template
+ }
+
+ case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template)
+ extends ImplDef
+ object ClassDef extends ClassDefExtractor
+
+ case class ModuleDef(mods: Modifiers, name: TermName, impl: Template)
+ extends ImplDef
+ object ModuleDef extends ModuleDefExtractor
+
+ abstract class ValOrDefDef extends MemberDef {
+ val name: Name
+ val tpt: Tree
+ val rhs: Tree
+ }
+
+ case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef
+ object ValDef extends ValDefExtractor
+
+ case class DefDef(mods: Modifiers, name: Name, tparams: List[TypeDef],
+ vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef
+ object DefDef extends DefDefExtractor
+
+ case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree)
+ extends MemberDef
+ object TypeDef extends TypeDefExtractor
+
+ case class LabelDef(name: TermName, params: List[Ident], rhs: Tree)
+ extends DefTree with TermTree
+ object LabelDef extends LabelDefExtractor
+
+ case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int)
+ object ImportSelector extends ImportSelectorExtractor
+
+ case class Import(expr: Tree, selectors: List[ImportSelector])
+ extends SymTree
+ object Import extends ImportExtractor
+
+ case class Template(parents: List[Tree], self: ValDef, body: List[Tree])
+ extends SymTree
+ object Template extends TemplateExtractor
+
+ case class Block(stats: List[Tree], expr: Tree)
+ extends TermTree
+ object Block extends BlockExtractor
+
+ case class CaseDef(pat: Tree, guard: Tree, body: Tree)
+ extends Tree
+ object CaseDef extends CaseDefExtractor
+
+ case class Alternative(trees: List[Tree])
+ extends TermTree
+ object Alternative extends AlternativeExtractor
+
+ case class Star(elem: Tree)
+ extends TermTree
+ object Star extends StarExtractor
+
+ case class Bind(name: Name, body: Tree)
+ extends DefTree
+ object Bind extends BindExtractor
+
+ case class UnApply(fun: Tree, args: List[Tree])
+ extends TermTree
+ object UnApply extends UnApplyExtractor
+
+ case class ArrayValue(elemtpt: Tree, elems: List[Tree])
+ extends TermTree
+ object ArrayValue extends ArrayValueExtractor
+
+ case class Function(vparams: List[ValDef], body: Tree)
+ extends TermTree with SymTree
+ object Function extends FunctionExtractor
+
+ case class Assign(lhs: Tree, rhs: Tree)
+ extends TermTree
+ object Assign extends AssignExtractor
+
+ case class AssignOrNamedArg(lhs: Tree, rhs: Tree)
+ extends TermTree
+ object AssignOrNamedArg extends AssignOrNamedArgExtractor
+
+ case class If(cond: Tree, thenp: Tree, elsep: Tree)
+ extends TermTree
+ object If extends IfExtractor
+
+ case class Match(selector: Tree, cases: List[CaseDef])
+ extends TermTree
+ object Match extends MatchExtractor
+
+ case class Return(expr: Tree)
+ extends TermTree with SymTree
+ object Return extends ReturnExtractor
+
+ case class Try(block: Tree, catches: List[CaseDef], finalizer: Tree)
+ extends TermTree
+ object Try extends TryExtractor
+
+ case class Throw(expr: Tree)
+ extends TermTree
+ object Throw extends ThrowExtractor
+
+ case class New(tpt: Tree) extends TermTree
+ object New extends NewExtractor
+
+ case class Typed(expr: Tree, tpt: Tree)
+ extends TermTree
+ object Typed extends TypedExtractor
+
+ abstract class GenericApply extends TermTree {
+ val fun: Tree
+ val args: List[Tree]
+ }
+
+ case class TypeApply(fun: Tree, args: List[Tree])
+ extends GenericApply
+ object TypeApply extends TypeApplyExtractor
+
+ case class Apply(fun: Tree, args: List[Tree])
+ extends GenericApply
+ object Apply extends ApplyExtractor
+
+ case class ApplyDynamic(qual: Tree, args: List[Tree])
+ extends TermTree with SymTree
+ object ApplyDynamic extends ApplyDynamicExtractor
+
+ case class Super(qual: Tree, mix: TypeName) extends TermTree
+ object Super extends SuperExtractor
+
+ case class This(qual: TypeName)
+ extends TermTree with SymTree
+ object This extends ThisExtractor
+
+ case class Select(qualifier: Tree, name: Name)
+ extends RefTree
+ object Select extends SelectExtractor
+
+ case class Ident(name: Name) extends RefTree {
+ def qualifier: Tree = EmptyTree
+ }
+ object Ident extends IdentExtractor
+
+ case class ReferenceToBoxed(ident: Ident) extends TermTree
+ object ReferenceToBoxed extends ReferenceToBoxedExtractor
+
+ case class Literal(value: Constant)
+ extends TermTree {
+ assert(value ne null)
+ }
+ object Literal extends LiteralExtractor
+
+ case class Annotated(annot: Tree, arg: Tree) extends Tree
+ object Annotated extends AnnotatedExtractor
+
+ case class SingletonTypeTree(ref: Tree)
+ extends TypTree
+ object SingletonTypeTree extends SingletonTypeTreeExtractor
+
+ case class SelectFromTypeTree(qualifier: Tree, name: TypeName)
+ extends TypTree with RefTree
+ object SelectFromTypeTree extends SelectFromTypeTreeExtractor
+
+ case class CompoundTypeTree(templ: Template)
+ extends TypTree
+ object CompoundTypeTree extends CompoundTypeTreeExtractor
+
+ case class AppliedTypeTree(tpt: Tree, args: List[Tree])
+ extends TypTree
+ object AppliedTypeTree extends AppliedTypeTreeExtractor
+
+ case class TypeBoundsTree(lo: Tree, hi: Tree)
+ extends TypTree
+ object TypeBoundsTree extends TypeBoundsTreeExtractor
+
+ case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree])
+ extends TypTree
+ object ExistentialTypeTree extends ExistentialTypeTreeExtractor
+
+ case class TypeTree() extends TypTree {
+ val original: Tree = null
+ override def isEmpty = true
+ }
+ object TypeTree extends TypeTreeExtractor
+
+ implicit val TreeTag = ClassTag[Tree](classOf[Tree])
+ implicit val TermTreeTag = ClassTag[TermTree](classOf[TermTree])
+ implicit val TypTreeTag = ClassTag[TypTree](classOf[TypTree])
+ implicit val SymTreeTag = ClassTag[SymTree](classOf[SymTree])
+ implicit val NameTreeTag = ClassTag[NameTree](classOf[NameTree])
+ implicit val RefTreeTag = ClassTag[RefTree](classOf[RefTree])
+ implicit val DefTreeTag = ClassTag[DefTree](classOf[DefTree])
+ implicit val MemberDefTag = ClassTag[MemberDef](classOf[MemberDef])
+ implicit val PackageDefTag = ClassTag[PackageDef](classOf[PackageDef])
+ implicit val ImplDefTag = ClassTag[ImplDef](classOf[ImplDef])
+ implicit val ClassDefTag = ClassTag[ClassDef](classOf[ClassDef])
+ implicit val ModuleDefTag = ClassTag[ModuleDef](classOf[ModuleDef])
+ implicit val ValOrDefDefTag = ClassTag[ValOrDefDef](classOf[ValOrDefDef])
+ implicit val ValDefTag = ClassTag[ValDef](classOf[ValDef])
+ implicit val DefDefTag = ClassTag[DefDef](classOf[DefDef])
+ implicit val TypeDefTag = ClassTag[TypeDef](classOf[TypeDef])
+ implicit val LabelDefTag = ClassTag[LabelDef](classOf[LabelDef])
+ implicit val ImportSelectorTag = ClassTag[ImportSelector](classOf[ImportSelector])
+ implicit val ImportTag = ClassTag[Import](classOf[Import])
+ implicit val TemplateTag = ClassTag[Template](classOf[Template])
+ implicit val BlockTag = ClassTag[Block](classOf[Block])
+ implicit val CaseDefTag = ClassTag[CaseDef](classOf[CaseDef])
+ implicit val AlternativeTag = ClassTag[Alternative](classOf[Alternative])
+ implicit val StarTag = ClassTag[Star](classOf[Star])
+ implicit val BindTag = ClassTag[Bind](classOf[Bind])
+ implicit val UnApplyTag = ClassTag[UnApply](classOf[UnApply])
+ implicit val ArrayValueTag = ClassTag[ArrayValue](classOf[ArrayValue])
+ implicit val FunctionTag = ClassTag[Function](classOf[Function])
+ implicit val AssignTag = ClassTag[Assign](classOf[Assign])
+ implicit val AssignOrNamedArgTag = ClassTag[AssignOrNamedArg](classOf[AssignOrNamedArg])
+ implicit val IfTag = ClassTag[If](classOf[If])
+ implicit val MatchTag = ClassTag[Match](classOf[Match])
+ implicit val ReturnTag = ClassTag[Return](classOf[Return])
+ implicit val TryTag = ClassTag[Try](classOf[Try])
+ implicit val ThrowTag = ClassTag[Throw](classOf[Throw])
+ implicit val NewTag = ClassTag[New](classOf[New])
+ implicit val TypedTag = ClassTag[Typed](classOf[Typed])
+ implicit val GenericApplyTag = ClassTag[GenericApply](classOf[GenericApply])
+ implicit val TypeApplyTag = ClassTag[TypeApply](classOf[TypeApply])
+ implicit val ApplyTag = ClassTag[Apply](classOf[Apply])
+ implicit val ApplyDynamicTag = ClassTag[ApplyDynamic](classOf[ApplyDynamic])
+ implicit val SuperTag = ClassTag[Super](classOf[Super])
+ implicit val ThisTag = ClassTag[This](classOf[This])
+ implicit val SelectTag = ClassTag[Select](classOf[Select])
+ implicit val IdentTag = ClassTag[Ident](classOf[Ident])
+ implicit val ReferenceToBoxedTag = ClassTag[ReferenceToBoxed](classOf[ReferenceToBoxed])
+ implicit val LiteralTag = ClassTag[Literal](classOf[Literal])
+ implicit val AnnotatedTag = ClassTag[Annotated](classOf[Annotated])
+ implicit val SingletonTypeTreeTag = ClassTag[SingletonTypeTree](classOf[SingletonTypeTree])
+ implicit val SelectFromTypeTreeTag = ClassTag[SelectFromTypeTree](classOf[SelectFromTypeTree])
+ implicit val CompoundTypeTreeTag = ClassTag[CompoundTypeTree](classOf[CompoundTypeTree])
+ implicit val AppliedTypeTreeTag = ClassTag[AppliedTypeTree](classOf[AppliedTypeTree])
+ implicit val TypeBoundsTreeTag = ClassTag[TypeBoundsTree](classOf[TypeBoundsTree])
+ implicit val ExistentialTypeTreeTag = ClassTag[ExistentialTypeTree](classOf[ExistentialTypeTree])
+ implicit val TypeTreeTag = ClassTag[TypeTree](classOf[TypeTree])
+
+ // [Eugene++] to be removed after SI-5863 is fixed
+ def ClassDef(sym: Symbol, impl: Template): ClassDef = ???
+ def ModuleDef(sym: Symbol, impl: Template): ModuleDef = ???
+ def ValDef(sym: Symbol, rhs: Tree): ValDef = ???
+ def ValDef(sym: Symbol): ValDef = ???
+ def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef = ???
+ def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef = ???
+ def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef = ???
+ def DefDef(sym: Symbol, rhs: Tree): DefDef = ???
+ def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef = ???
+ def TypeDef(sym: Symbol, rhs: Tree): TypeDef = ???
+ def TypeDef(sym: Symbol): TypeDef = ???
+ def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef = ???
+ def CaseDef(pat: Tree, body: Tree): CaseDef = ???
+ def Bind(sym: Symbol, body: Tree): Bind = ???
+ def Try(body: Tree, cases: (Tree, Tree)*): Try = ???
+ def Throw(tpe: Type, args: Tree*): Throw = ???
+ def Apply(sym: Symbol, args: Tree*): Tree = ???
+ def New(tpt: Tree, argss: List[List[Tree]]): Tree = ???
+ def New(tpe: Type, args: Tree*): Tree = ???
+ def New(sym: Symbol, args: Tree*): Tree = ???
+ def ApplyConstructor(tpt: Tree, args: List[Tree]): Tree = ???
+ def Super(sym: Symbol, mix: TypeName): Tree = ???
+ def This(sym: Symbol): Tree = ???
+ def Select(qualifier: Tree, name: String): Select = ???
+ def Select(qualifier: Tree, sym: Symbol): Select = ???
+ def Ident(name: String): Ident = ???
+ def Ident(sym: Symbol): Ident = ???
+ def Block(stats: Tree*): Block = ???
+ def TypeTree(tp: Type): TypeTree = ???
+}
diff --git a/src/library/scala/reflect/base/BuildUtils.scala b/src/library/scala/reflect/base/BuildUtils.scala
new file mode 100644
index 0000000000..eaba0ec2b7
--- /dev/null
+++ b/src/library/scala/reflect/base/BuildUtils.scala
@@ -0,0 +1,90 @@
+package scala.reflect
+package base
+
+trait BuildUtils { self: Universe =>
+
+ val build: BuildBase
+
+ abstract class BuildBase {
+ /** Selects type symbol with given simple name `name` from the defined members of `owner`.
+ */
+ def selectType(owner: Symbol, name: String): TypeSymbol
+
+ /** Selects term symbol with given name and type from the defined members of prefix type
+ */
+ def selectTerm(owner: Symbol, name: String): TermSymbol
+
+ /** Selects overloaded method symbol with given name and index
+ */
+ def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol
+
+ /** A fresh symbol with given name `name`, position `pos` and flags `flags` that has
+ * the current symbol as its owner.
+ */
+ def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: FlagSet, isClass: Boolean): Symbol
+
+ /** Create a fresh free term symbol.
+ * @param name the name of the free variable
+ * @param info the type signature of the free variable
+ * @param value the value of the free variable at runtime
+ * @param flags (optional) flags of the free variable
+ * @param origin debug information that tells where this symbol comes from
+ */
+ def newFreeTerm(name: String, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTermSymbol
+
+ /** Create a fresh free non-existential type symbol.
+ * @param name the name of the free variable
+ * @param info the type signature of the free variable
+ * @param value a type tag that captures the value of the free variable
+ * is completely phantom, since the captured type cannot be propagated to the runtime
+ * if it could be, we wouldn't be creating a free type to begin with
+ * the only usage for it is preserving the captured symbol for compile-time analysis
+ * @param flags (optional) flags of the free variable
+ * @param origin debug information that tells where this symbol comes from
+ */
+ def newFreeType(name: String, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTypeSymbol
+
+ /** Create a fresh free existential type symbol.
+ * @param name the name of the free variable
+ * @param info the type signature of the free variable
+ * @param value a type tag that captures the value of the free variable
+ * is completely phantom, since the captured type cannot be propagated to the runtime
+ * if it could be, we wouldn't be creating a free type to begin with
+ * the only usage for it is preserving the captured symbol for compile-time analysis
+ * @param flags (optional) flags of the free variable
+ * @param origin (optional) debug information that tells where this symbol comes from
+ * [Martin to Eugene: why needed?]
+ */
+ def newFreeExistential(name: String, info: Type, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTypeSymbol
+
+ /** Set symbol's type signature to given type.
+ * @return the symbol itself
+ */
+ def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S
+
+ /** Set symbol's annotations to given annotations `annots`.
+ */
+ def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S
+
+ def flagsFromBits(bits: Long): FlagSet
+
+ // [Eugene++ to Martin] these are necessary for reification
+ // on a second thought, I added them to BuildUtils instead of base
+
+ def emptyValDef: ValDef
+
+ def This(sym: Symbol): Tree
+
+ def Select(qualifier: Tree, sym: Symbol): Select
+
+ def Ident(sym: Symbol): Ident
+
+ def TypeTree(tp: Type): TypeTree
+
+ def thisPrefix(sym: Symbol): Type
+
+ def setType[T <: Tree](tree: T, tpe: Type): T
+
+ def setSymbol[T <: Tree](tree: T, sym: Symbol): T
+ }
+}
diff --git a/src/library/scala/reflect/base/Constants.scala b/src/library/scala/reflect/base/Constants.scala
new file mode 100644
index 0000000000..8f98e85ad0
--- /dev/null
+++ b/src/library/scala/reflect/base/Constants.scala
@@ -0,0 +1,20 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.reflect
+package base
+
+trait Constants {
+ self: Universe =>
+
+ type Constant >: Null <: AnyRef
+ implicit val ConstantTag: ClassTag[Constant]
+ val Constant: ConstantExtractor
+
+ abstract class ConstantExtractor {
+ def apply(value: Any): Constant
+ def unapply(arg: Constant): Option[Any]
+ }
+}
diff --git a/src/library/scala/reflect/base/FlagSets.scala b/src/library/scala/reflect/base/FlagSets.scala
new file mode 100644
index 0000000000..57946d0f27
--- /dev/null
+++ b/src/library/scala/reflect/base/FlagSets.scala
@@ -0,0 +1,17 @@
+package scala.reflect
+package base
+
+trait FlagSets { self: Universe =>
+
+ /** An abstract type representing sets of flags that apply to definition trees and symbols */
+ type FlagSet
+
+ /** A tag that preserves the identity of the `FlagSet` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val FlagSetTag: ClassTag[FlagSet]
+
+ /** The empty set of flags */
+ val NoFlags: FlagSet
+}
+
diff --git a/src/library/scala/reflect/base/MirrorOf.scala b/src/library/scala/reflect/base/MirrorOf.scala
new file mode 100644
index 0000000000..03e035cd81
--- /dev/null
+++ b/src/library/scala/reflect/base/MirrorOf.scala
@@ -0,0 +1,25 @@
+package scala.reflect
+package base
+
+// [Eugene++ to Martin] why was this a member of `scala.reflect`, but not `scala.reflect.base`?
+
+abstract class MirrorOf[U <: base.Universe with Singleton] {
+ /** .. */
+ val universe: U
+
+ /** .. */
+ def RootClass: U#ClassSymbol
+ def RootPackage: U#ModuleSymbol
+ def EmptyPackageClass: U#ClassSymbol
+ def EmptyPackage: U#ModuleSymbol
+
+ /** The symbol corresponding to the globally accessible class with the
+ * given fully qualified name `fullName`.
+ */
+ def staticClass(fullName: String): U#ClassSymbol
+
+ /** The symbol corresponding to the globally accessible object with the
+ * given fully qualified name `fullName`.
+ */
+ def staticModule(fullName: String): U#ModuleSymbol
+}
diff --git a/src/library/scala/reflect/base/Mirrors.scala b/src/library/scala/reflect/base/Mirrors.scala
new file mode 100644
index 0000000000..50866ef000
--- /dev/null
+++ b/src/library/scala/reflect/base/Mirrors.scala
@@ -0,0 +1,12 @@
+package scala.reflect
+package base
+
+trait Mirrors {
+ self: Universe =>
+
+ /** .. */
+ type Mirror >: Null <: MirrorOf[self.type]
+
+ /** .. */
+ val rootMirror: Mirror
+}
diff --git a/src/library/scala/reflect/api/Names.scala b/src/library/scala/reflect/base/Names.scala
index 96651ffa88..edf2ba7dc9 100755..100644
--- a/src/library/scala/reflect/api/Names.scala
+++ b/src/library/scala/reflect/base/Names.scala
@@ -1,5 +1,5 @@
package scala.reflect
-package api
+package base
/** A trait that manages names.
* A name is a string in one of two name universes: terms and types.
@@ -11,16 +11,21 @@ package api
* `name1 == name2` implies `name1 eq name2`.
*/
trait Names {
+
/** The abstract type of names */
- type Name >: Null <: AbsName
+ type Name >: Null <: NameBase
+ implicit val NameTag: ClassTag[Name]
/** The abstract type of names representing terms */
- type TypeName <: Name
+ type TypeName >: Null <: Name
+ implicit val TypeNameTag: ClassTag[TypeName]
/** The abstract type of names representing types */
- type TermName <: Name
+ type TermName >: Null <: Name
+ implicit val TermNameTag: ClassTag[TermName]
- abstract class AbsName {
+ /** The base API that all names support */
+ abstract class NameBase {
/** Is this name a term name? */
def isTermName: Boolean
@@ -32,24 +37,6 @@ trait Names {
/** Returns a type name that represents the same string as this name */
def toTypeName: TypeName
-
- /** Replaces all occurrences of \$op_names in this name by corresponding operator symbols.
- * Example: `foo_\$plus\$eq` becomes `foo_+=`
- */
- def decoded: String
-
- /** Replaces all occurrences of operator symbols in this name by corresponding \$op_names.
- * Example: `foo_+=` becomes `foo_\$plus\$eq`.
- */
- def encoded: String
-
- /** The decoded name, still represented as a name.
- */
- def decodedName: Name
-
- /** The encoded name, still represented as a name.
- */
- def encodedName: Name
}
/** Create a new term name.
diff --git a/src/library/scala/reflect/base/Positions.scala b/src/library/scala/reflect/base/Positions.scala
new file mode 100644
index 0000000000..cefeb51c9a
--- /dev/null
+++ b/src/library/scala/reflect/base/Positions.scala
@@ -0,0 +1,22 @@
+package scala.reflect
+package base
+
+trait Positions {
+ self: Universe =>
+
+ /** .. */
+ type Position >: Null <: Attachments { type Pos = Position }
+
+ /** A tag that preserves the identity of the `FlagSet` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val PositionTag: ClassTag[Position]
+
+ /** .. */
+ val NoPosition: Position
+
+ /** Assigns a given position to all position-less nodes of a given AST.
+ */
+ def atPos[T <: Tree](pos: Position)(tree: T): T
+ // [Eugene++] why do we have this in base?
+}
diff --git a/src/library/scala/reflect/api/Scopes.scala b/src/library/scala/reflect/base/Scopes.scala
index 4a5702eadc..a5db01c0ce 100755..100644
--- a/src/library/scala/reflect/api/Scopes.scala
+++ b/src/library/scala/reflect/base/Scopes.scala
@@ -1,9 +1,14 @@
package scala.reflect
-package api
+package base
trait Scopes { self: Universe =>
- type Scope <: Iterable[Symbol]
+ type Scope >: Null <: Iterable[Symbol]
+
+ /** A tag that preserves the identity of the `Scope` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ScopeTag: ClassTag[Scope]
/** Create a new scope */
def newScope: Scope
diff --git a/src/library/scala/reflect/base/StandardDefinitions.scala b/src/library/scala/reflect/base/StandardDefinitions.scala
new file mode 100644
index 0000000000..eff23b539e
--- /dev/null
+++ b/src/library/scala/reflect/base/StandardDefinitions.scala
@@ -0,0 +1,75 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.reflect
+package base
+
+// [Eugene++] not sure whether we need this in the top level of the universe
+trait StandardTypes {
+ self: Universe =>
+
+ val ByteTpe: Type
+ val ShortTpe: Type
+ val CharTpe: Type
+ val IntTpe: Type
+ val LongTpe: Type
+ val FloatTpe: Type
+ val DoubleTpe: Type
+ val BooleanTpe: Type
+ val UnitTpe: Type
+
+ val AnyTpe: Type
+ val AnyValTpe: Type
+ val AnyRefTpe: Type
+ val ObjectTpe: Type
+
+ val NothingTpe: Type
+ val NullTpe: Type
+ val StringTpe: Type
+}
+
+trait StandardDefinitions extends StandardTypes {
+ self: Universe =>
+
+ val definitions: DefinitionsBase
+
+ // [Eugene] todo. shortcut to these fields if possible when generating tags
+ // todo. also shortcut to StandardTypes, of course
+ trait DefinitionsBase {
+ // packages
+ def ScalaPackageClass: ClassSymbol
+ def ScalaPackage: ModuleSymbol
+
+ // top types
+ def AnyClass : ClassSymbol
+ def AnyValClass: ClassSymbol
+ def ObjectClass: ClassSymbol
+ def AnyRefClass: TypeSymbol
+
+ // bottom types
+ def NullClass : ClassSymbol
+ def NothingClass: ClassSymbol
+
+ // the scala value classes
+ def UnitClass : ClassSymbol
+ def ByteClass : ClassSymbol
+ def ShortClass : ClassSymbol
+ def CharClass : ClassSymbol
+ def IntClass : ClassSymbol
+ def LongClass : ClassSymbol
+ def FloatClass : ClassSymbol
+ def DoubleClass : ClassSymbol
+ def BooleanClass: ClassSymbol
+
+ // some special classes
+ def StringClass : ClassSymbol
+ def ClassClass : ClassSymbol
+ def ArrayClass : ClassSymbol
+ def ListClass : ClassSymbol // [Eugene] I'd say List has earned its right to be here
+
+ // the Predef object
+ def PredefModule: ModuleSymbol
+ }
+}
diff --git a/src/library/scala/reflect/base/StandardNames.scala b/src/library/scala/reflect/base/StandardNames.scala
new file mode 100644
index 0000000000..8a3fbe9683
--- /dev/null
+++ b/src/library/scala/reflect/base/StandardNames.scala
@@ -0,0 +1,29 @@
+/* NSC -- new Scala compiler
+* Copyright 2005-2011 LAMP/EPFL
+* @author Martin Odersky
+*/
+
+package scala.reflect
+package base
+
+trait StandardNames {
+ self: Universe =>
+
+ val nme: TermNamesBase
+ val tpnme: TypeNamesBase
+
+ trait NamesBase {
+ type NameType >: Null <: Name
+ val EMPTY: NameType
+ val ROOT: NameType
+ val EMPTY_PACKAGE_NAME: NameType
+ val WILDCARD: NameType
+ }
+
+ trait TypeNamesBase extends NamesBase
+
+ trait TermNamesBase extends NamesBase {
+ val CONSTRUCTOR: TermName
+ val NO_NAME: NameType
+ }
+}
diff --git a/src/library/scala/reflect/base/Symbols.scala b/src/library/scala/reflect/base/Symbols.scala
new file mode 100644
index 0000000000..9404520073
--- /dev/null
+++ b/src/library/scala/reflect/base/Symbols.scala
@@ -0,0 +1,272 @@
+package scala.reflect
+package base
+
+trait Symbols { self: Universe =>
+
+ // [Eugene++ to Martin] why is Symbol >: Null, whereas all other symbol types are not nullable?
+ // same question goes for Types
+
+ /** The abstract type of symbols representing declarations */
+ type Symbol >: Null <: SymbolBase
+
+ /** A tag that preserves the identity of the `Symbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SymbolTag: ClassTag[Symbol]
+
+ /** The abstract type of type symbols representing type, class, and trait declarations,
+ * as well as type parameters
+ */
+ type TypeSymbol >: Null <: Symbol with TypeSymbolBase
+
+ /** A tag that preserves the identity of the `TypeSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeSymbolTag: ClassTag[TypeSymbol]
+
+ /** The abstract type of term symbols representing val, var, def, and object declarations as
+ * well as packages and value parameters.
+ */
+ type TermSymbol >: Null <: Symbol with TermSymbolBase
+
+ /** A tag that preserves the identity of the `TermSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TermSymbolTag: ClassTag[TermSymbol]
+
+ /** The abstract type of method symbols representing def declarations */
+ type MethodSymbol >: Null <: TermSymbol with MethodSymbolBase
+
+ /** A tag that preserves the identity of the `MethodSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val MethodSymbolTag: ClassTag[MethodSymbol]
+
+ /** The abstract type of module symbols representing object declarations */
+ type ModuleSymbol >: Null <: TermSymbol with ModuleSymbolBase
+
+ /** A tag that preserves the identity of the `ModuleSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ModuleSymbolTag: ClassTag[ModuleSymbol]
+
+ /** The abstract type of class symbols representing class and trait definitions */
+ type ClassSymbol >: Null <: TypeSymbol with ClassSymbolBase
+
+ /** A tag that preserves the identity of the `ClassSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ClassSymbolTag: ClassTag[ClassSymbol]
+
+ /** The abstract type of free terms introduced by reification */
+ type FreeTermSymbol >: Null <: TermSymbol with FreeTermSymbolBase
+
+ /** A tag that preserves the identity of the `FreeTermSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val FreeTermSymbolTag: ClassTag[FreeTermSymbol]
+
+ /** The abstract type of free types introduced by reification */
+ type FreeTypeSymbol >: Null <: TypeSymbol with FreeTypeSymbolBase
+
+ /** A tag that preserves the identity of the `FreeTypeSymbol` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val FreeTypeSymbolTag: ClassTag[FreeTypeSymbol]
+
+ /** A special "missing" symbol */
+ val NoSymbol: Symbol
+
+ /** The base API that all symbols support */
+ trait SymbolBase { this: Symbol =>
+
+ /** An id number which is unique for all symbols in this universe */
+ // [Eugene++ to Martin] do we leave this here?
+ def id: Int
+
+ /** The owner of this symbol. This is the symbol
+ * that directly contains the current symbol's definition.
+ * The `NoSymbol` symbol does not have an owner, and calling this method
+ * on one causes an internal error.
+ * The owner of the Scala root class [[scala.reflect.api.mirror.RootClass]]
+ * and the Scala root object [[scala.reflect.api.mirror.RootPackage]] is `NoSymbol`.
+ * Every other symbol has a chain of owners that ends in
+ * [[scala.reflect.api.mirror.RootClass]].
+ */
+ def owner: Symbol
+
+ /** The type of the symbol name.
+ * Can be either `TermName` or `TypeName` depending on whether this is a `TermSymbol` or a `TypeSymbol`.
+ *
+ * Type name namespaces do not intersect with term name namespaces.
+ * This fact is reflected in different types for names of `TermSymbol` and `TypeSymbol`.
+ */
+ type NameType >: Null <: Name
+
+ /** The name of the symbol as a member of the `Name` type.
+ */
+ def name: Name
+
+ /** The encoded full path name of this symbol, where outer names and inner names
+ * are separated by periods.
+ */
+ def fullName: String
+
+ /** If this symbol is a class, this symbol; otherwise the next enclosing
+ * class, or `NoSymbol` if none exists.
+ */
+ def enclosingClass: Symbol =
+ if (isClass || this == NoSymbol) this else owner.enclosingClass
+
+ /** If this symbol is a method, this symbol; otherwise the next enclosing
+ * method, or `NoSymbol` if none exists.
+ */
+ def enclosingMethod: Symbol =
+ if (isMethod || this == NoSymbol) this else owner.enclosingMethod
+
+ /** Does this symbol represent the definition of a type?
+ * Note that every symbol is either a term or a type.
+ * So for every symbol `sym`, either `sym.isTerm` is true
+ * or `sym.isType` is true.
+ */
+ def isType: Boolean = false
+
+ /** This symbol cast to a TypeSymbol.
+ * Returns ClassCastException if `isType` is false.
+ */
+ def asTypeSymbol: TypeSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent the definition of a term?
+ * Note that every symbol is either a term or a term.
+ * So for every symbol `sym`, either `sym.isTerm` is true
+ * or `sym.isTerm` is true.
+ */
+ def isTerm: Boolean = false
+
+ /** This symbol cast to a TermSymbol.
+ * Returns ClassCastException if `isTerm` is false.
+ */
+ def asTermSymbol: TermSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent the definition of a method?
+ * If yes, `isTerm` is also guaranteed to be true.
+ */
+ def isMethod: Boolean = false
+
+ /** This symbol cast to a MethodSymbol.
+ * Returns ClassCastException if `isMethod` is false.
+ */
+ def asMethodSymbol: MethodSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent the definition of a module (i.e. it
+ * results from an object definition?).
+ * If yes, `isTerm` is also guaranteed to be true.
+ */
+ def isModule: Boolean = false
+
+ /** This symbol cast to a ModuleSymbol defined by an object definition.
+ * Returns ClassCastException if `isModule` is false.
+ */
+ def asModuleSymbol: ModuleSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent the definition of a class or trait?
+ * If yes, `isType` is also guaranteed to be true.
+ */
+ def isClass: Boolean = false
+
+ /** This symbol cast to a ClassSymbol representing a class or trait.
+ * Returns ClassCastException if `isClass` is false.
+ */
+ def asClassSymbol: ClassSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent a free term captured by reification?
+ * If yes, `isTerm` is also guaranteed to be true.
+ */
+ def isFreeTerm: Boolean = false
+
+ /** This symbol cast to a free term symbol.
+ * Returns ClassCastException if `isFreeTerm` is false.
+ */
+ def asFreeTermSymbol: FreeTermSymbol = throw new ClassCastException(toString)
+
+ /** Does this symbol represent a free type captured by reification?
+ * If yes, `isType` is also guaranteed to be true.
+ */
+ def isFreeType: Boolean = false
+
+ /** This symbol cast to a free type symbol.
+ * Returns ClassCastException if `isFreeType` is false.
+ */
+ def asFreeTypeSymbol: FreeTypeSymbol = throw new ClassCastException(toString)
+
+ def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol
+ def newModuleAndClassSymbol(name: Name, pos: Position = NoPosition, flags: FlagSet = NoFlags): (ModuleSymbol, ClassSymbol)
+ def newMethodSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): MethodSymbol
+ def newTypeSymbol(name: TypeName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TypeSymbol
+ def newClassSymbol(name: TypeName, pos: Position = NoPosition, flags: FlagSet = NoFlags): ClassSymbol
+ }
+
+ /** The base API that all type symbols support */
+ trait TypeSymbolBase extends SymbolBase { this: TypeSymbol =>
+ /** Type symbols have their names of type `TypeName`.
+ */
+ final type NameType = TypeName
+
+ /** The type constructor corresponding to this type symbol.
+ * This is different from `asType` in that type parameters
+ * are part of results of `asType`, but not of `asTypeConstructor`.
+ *
+ * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
+ * `C`. Then `C.asType` is the type `C[T]`, but `C.asTypeConstructor` is `C`.
+ */
+ def asTypeConstructor: Type
+
+ override def isType = true
+ override def asTypeSymbol = this
+ }
+
+ /** The base API that all term symbols support */
+ trait TermSymbolBase extends SymbolBase { this: TermSymbol =>
+ /** Term symbols have their names of type `TermName`.
+ */
+ final type NameType = TermName
+
+ final override def isTerm = true
+ final override def asTermSymbol = this
+ }
+
+ /** The base API that all method symbols support */
+ trait MethodSymbolBase extends TermSymbolBase { this: MethodSymbol =>
+ final override def isMethod = true
+ final override def asMethodSymbol = this
+ }
+
+ /** The base API that all module symbols support */
+ trait ModuleSymbolBase extends TermSymbolBase { this: ModuleSymbol =>
+ /** The class implicitly associated with the object definition.
+ */
+ def moduleClass: Symbol // needed for tree traversals
+ // [Eugene++] when this becomes `moduleClass: ClassSymbol`, it will be the happiest day in my life
+
+ final override def isModule = true
+ final override def asModuleSymbol = this
+ }
+
+ /** The base API that all class symbols support */
+ trait ClassSymbolBase extends TypeSymbolBase { this: ClassSymbol =>
+ final override def isClass = true
+ final override def asClassSymbol = this
+ }
+
+ /** The base API that all free type symbols support */
+ trait FreeTypeSymbolBase extends TypeSymbolBase { this: FreeTypeSymbol =>
+ final override def isFreeType = true
+ final override def asFreeTypeSymbol = this
+ }
+
+ /** The base API that all free term symbols support */
+ trait FreeTermSymbolBase extends TermSymbolBase { this: FreeTermSymbol =>
+ final override def isFreeTerm = true
+ final override def asFreeTermSymbol = this
+ }
+}
diff --git a/src/library/scala/reflect/base/TagInterop.scala b/src/library/scala/reflect/base/TagInterop.scala
new file mode 100644
index 0000000000..158d1979e5
--- /dev/null
+++ b/src/library/scala/reflect/base/TagInterop.scala
@@ -0,0 +1,29 @@
+package scala.reflect
+package base
+
+import scala.runtime.ScalaRunTime._
+
+trait TagInterop { self: Universe =>
+ def classTagToClassManifest[T](tag: ClassTag[T]): ClassManifest[T] = {
+ val runtimeClass = tag.runtimeClass
+ if (runtimeClass.isArray) {
+ val elementClass = arrayElementClass(runtimeClass)
+ val elementManifest = classTagToClassManifest(ClassTag(elementClass))
+ ClassManifest.arrayType(elementManifest).asInstanceOf[ClassManifest[T]]
+ } else {
+ ClassManifest.fromClass(runtimeClass.asInstanceOf[Class[T]])
+ }
+ }
+
+ // [Eugene++] `mirror` parameters are now of type `Any`, because I can't make these path-dependent types work
+ // if you're brave enough, replace `Any` with `Mirror`, recompile and run interop_typetags_are_manifests.scala
+
+ // [Eugene++] would be great if we could approximate the interop without any mirrors
+ // todo. think how to implement that
+
+ def typeTagToManifest[T: ClassTag](mirror: Any, tag: base.Universe # TypeTag[T]): Manifest[T] =
+ throw new UnsupportedOperationException("This universe does not support tag -> manifest conversions. Use scala.reflect.runtime.universe from scala-reflect.jar.")
+
+ def manifestToTypeTag[T](mirror: Any, manifest: Manifest[T]): base.Universe # TypeTag[T] =
+ throw new UnsupportedOperationException("This universe does not support manifest -> tag conversions. Use scala.reflect.runtime.universe from scala-reflect.jar.")
+}
diff --git a/src/library/scala/reflect/base/TreeCreator.scala b/src/library/scala/reflect/base/TreeCreator.scala
new file mode 100644
index 0000000000..c9c8de2307
--- /dev/null
+++ b/src/library/scala/reflect/base/TreeCreator.scala
@@ -0,0 +1,6 @@
+package scala.reflect
+package base
+
+abstract class TreeCreator {
+ def apply[U <: Universe with Singleton](m: MirrorOf[U]): U # Tree
+}
diff --git a/src/library/scala/reflect/base/Trees.scala b/src/library/scala/reflect/base/Trees.scala
new file mode 100644
index 0000000000..298d229570
--- /dev/null
+++ b/src/library/scala/reflect/base/Trees.scala
@@ -0,0 +1,1459 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.reflect
+package base
+
+// [Eugene++] of all reflection APIs, this one is in the biggest need of review and documentation
+
+// Syncnote: Trees are currently not thread-safe.
+// [Eugene++] now when trees are finally abstract types, can we do something for this?
+trait Trees { self: Universe =>
+
+ /** The base API that all trees support */
+ abstract class TreeBase extends Product { this: Tree =>
+ /** ... */
+ def isDef: Boolean
+
+ /** ... */
+ def isEmpty: Boolean
+
+ /** The canonical way to test if a Tree represents a term.
+ */
+ def isTerm: Boolean
+
+ /** The canonical way to test if a Tree represents a type.
+ */
+ def isType: Boolean
+
+ /** Obtains string representation of a tree */
+ override def toString: String = show(this)
+ }
+
+ /** Obtains string representation of a tree */
+ def show(tree: Tree): String
+
+ /** Tree is the basis for scala's abstract syntax. The nodes are
+ * implemented as case classes, and the parameters which initialize
+ * a given tree are immutable: however Trees have several mutable
+ * fields which are manipulated in the course of typechecking,
+ * including pos, symbol, and tpe.
+ *
+ * Newly instantiated trees have tpe set to null (though it
+ * may be set immediately thereafter depending on how it is
+ * constructed.) When a tree is passed to the typer, typically via
+ * `typer.typed(tree)`, under normal circumstances the tpe must be
+ * null or the typer will ignore it. Furthermore, the typer is not
+ * required to return the same tree it was passed.
+ *
+ * Trees can be easily traversed with e.g. foreach on the root node;
+ * for a more nuanced traversal, subclass Traverser. Transformations
+ * can be considerably trickier: see the numerous subclasses of
+ * Transformer found around the compiler.
+ *
+ * Copying Trees should be done with care depending on whether
+ * it need be done lazily or strictly (see LazyTreeCopier and
+ * StrictTreeCopier) and on whether the contents of the mutable
+ * fields should be copied. The tree copiers will copy the mutable
+ * attributes to the new tree; calling Tree#duplicate will copy
+ * symbol and tpe, but all the positions will be focused.
+ *
+ * Trees can be coarsely divided into four mutually exclusive categories:
+ *
+ * - TermTrees, representing terms
+ * - TypTrees, representing types. Note that is `TypTree`, not `TypeTree`.
+ * - SymTrees, which may represent types or terms.
+ * - Other Trees, which have none of those as parents.
+ *
+ * SymTrees include important nodes Ident and Select, which are
+ * used as both terms and types; they are distinguishable based on
+ * whether the Name is a TermName or TypeName. The correct way for
+ * to test for a type or a term (on any Tree) are the isTerm/isType
+ * methods on Tree.
+ *
+ * "Others" are mostly syntactic or short-lived constructs. Examples
+ * include CaseDef, which wraps individual match cases: they are
+ * neither terms nor types, nor do they carry a symbol. Another
+ * example is Parens, which is eliminated during parsing.
+ */
+ type Tree >: Null <: TreeBase
+ // [Eugene++] todo. discuss nullability of abstract types
+
+ /** A tag that preserves the identity of the `Tree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TreeTag: ClassTag[Tree]
+
+ /** The empty tree */
+ val EmptyTree: Tree
+
+ /** A tree for a term. Not all terms are TermTrees; use isTerm
+ * to reliably identify terms.
+ */
+ type TermTree >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `TermTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TermTreeTag: ClassTag[TermTree]
+
+ /** A tree for a type. Not all types are TypTrees; use isType
+ * to reliably identify types.
+ */
+ type TypTree >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `TypTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypTreeTag: ClassTag[TypTree]
+
+ /** A tree with a mutable symbol field, initialized to NoSymbol.
+ */
+ type SymTree >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `SymTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SymTreeTag: ClassTag[SymTree]
+
+ /** A tree with a name - effectively, a DefTree or RefTree.
+ */
+ type NameTree >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `NameTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val NameTreeTag: ClassTag[NameTree]
+
+ /** A tree which references a symbol-carrying entity.
+ * References one, as opposed to defining one; definitions
+ * are in DefTrees.
+ */
+ type RefTree >: Null <: SymTree with NameTree
+
+ /** A tag that preserves the identity of the `RefTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val RefTreeTag: ClassTag[RefTree]
+
+ /** A tree which defines a symbol-carrying entity.
+ */
+ type DefTree >: Null <: SymTree with NameTree
+
+ /** A tag that preserves the identity of the `DefTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val DefTreeTag: ClassTag[DefTree]
+
+ /** Common base class for all member definitions: types, classes,
+ * objects, packages, vals and vars, defs.
+ */
+ type MemberDef >: Null <: DefTree
+
+ /** A tag that preserves the identity of the `MemberDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val MemberDefTag: ClassTag[MemberDef]
+
+ /** A packaging, such as `package pid { stats }`
+ */
+ type PackageDef >: Null <: MemberDef
+
+ /** A tag that preserves the identity of the `PackageDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val PackageDefTag: ClassTag[PackageDef]
+
+ /** The constructor/deconstructor for `PackageDef` instances. */
+ val PackageDef: PackageDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `PackageDef(pid, stats)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `package` pid { stats }
+ */
+ abstract class PackageDefExtractor {
+ def apply(pid: RefTree, stats: List[Tree]): PackageDef
+ def unapply(packageDef: PackageDef): Option[(RefTree, List[Tree])]
+ }
+
+ /** A common base class for class and object definitions.
+ */
+ type ImplDef >: Null <: MemberDef
+
+ /** A tag that preserves the identity of the `ImplDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ImplDefTag: ClassTag[ImplDef]
+
+ /** A class definition.
+ */
+ type ClassDef >: Null <: ImplDef
+
+ /** A tag that preserves the identity of the `ClassDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ClassDefTag: ClassTag[ClassDef]
+
+ /** The constructor/deconstructor for `ClassDef` instances. */
+ val ClassDef: ClassDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `ClassDef(mods, name, tparams, impl)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * mods `class` name [tparams] impl
+ *
+ * Where impl stands for:
+ *
+ * `extends` parents { defs }
+ */
+ abstract class ClassDefExtractor {
+ def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template): ClassDef
+ def unapply(classDef: ClassDef): Option[(Modifiers, TypeName, List[TypeDef], Template)]
+ }
+
+ /** An object definition, e.g. `object Foo`. Internally, objects are
+ * quite frequently called modules to reduce ambiguity.
+ * Eliminated by refcheck.
+ */
+ type ModuleDef >: Null <: ImplDef
+
+ /** A tag that preserves the identity of the `ModuleDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ModuleDefTag: ClassTag[ModuleDef]
+
+ /** The constructor/deconstructor for `ModuleDef` instances. */
+ val ModuleDef: ModuleDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `ModuleDef(mods, name, impl)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * mods `object` name impl
+ *
+ * Where impl stands for:
+ *
+ * `extends` parents { defs }
+ */
+ abstract class ModuleDefExtractor {
+ def apply(mods: Modifiers, name: TermName, impl: Template): ModuleDef
+ def unapply(moduleDef: ModuleDef): Option[(Modifiers, TermName, Template)]
+ }
+
+ /** A common base class for ValDefs and DefDefs.
+ */
+ type ValOrDefDef >: Null <: MemberDef
+
+ /** A tag that preserves the identity of the `ValOrDefDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ValOrDefDefTag: ClassTag[ValOrDefDef]
+
+ /** Broadly speaking, a value definition. All these are encoded as ValDefs:
+ *
+ * - immutable values, e.g. "val x"
+ * - mutable values, e.g. "var x" - the MUTABLE flag set in mods
+ * - lazy values, e.g. "lazy val x" - the LAZY flag set in mods
+ * - method parameters, see vparamss in DefDef - the PARAM flag is set in mods
+ * - explicit self-types, e.g. class A { self: Bar => } - !!! not sure what is set.
+ */
+ type ValDef >: Null <: ValOrDefDef
+
+ /** A tag that preserves the identity of the `ValDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ValDefTag: ClassTag[ValDef]
+
+ /** The constructor/deconstructor for `ValDef` instances. */
+ val ValDef: ValDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `ValDef(mods, name, tpt, rhs)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * mods `val` name: tpt = rhs
+ *
+ * mods `var` name: tpt = rhs
+ *
+ * mods name: tpt = rhs // in signatures of function and method definitions
+ *
+ * self: Bar => // self-types (!!! not sure what is set)
+ *
+ * If the type of a value is not specified explicitly (i.e. is meant to be inferred),
+ * this is expressed by having `tpt` set to `TypeTree()` (but not to an `EmptyTree`!).
+ */
+ abstract class ValDefExtractor {
+ def apply(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree): ValDef
+ def unapply(valDef: ValDef): Option[(Modifiers, TermName, Tree, Tree)]
+ }
+
+ /** A method or macro definition.
+ * @param name The name of the method or macro. Can be a type name in case this is a type macro
+ */
+ type DefDef >: Null <: ValOrDefDef
+
+ /** A tag that preserves the identity of the `DefDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val DefDefTag: ClassTag[DefDef]
+
+ /** The constructor/deconstructor for `DefDef` instances. */
+ val DefDef: DefDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `DefDef(mods, name, tparams, vparamss, tpt, rhs)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * mods `def` name[tparams](vparams_1)...(vparams_n): tpt = rhs
+ *
+ * If the return type is not specified explicitly (i.e. is meant to be inferred),
+ * this is expressed by having `tpt` set to `TypeTree()` (but not to an `EmptyTree`!).
+ */
+ abstract class DefDefExtractor {
+ def apply(mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef
+ def unapply(defDef: DefDef): Option[(Modifiers, Name, List[TypeDef], List[List[ValDef]], Tree, Tree)]
+ }
+
+ /** An abstract type, a type parameter, or a type alias.
+ * Eliminated by erasure.
+ */
+ type TypeDef >: Null <: MemberDef
+
+ /** A tag that preserves the identity of the `TypeDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeDefTag: ClassTag[TypeDef]
+
+ /** The constructor/deconstructor for `TypeDef` instances. */
+ val TypeDef: TypeDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `TypeDef(mods, name, tparams, rhs)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * mods `type` name[tparams] = rhs
+ *
+ * mods `type` name[tparams] >: lo <: hi
+ *
+ * First usage illustrates `TypeDefs` representing type aliases and type parameters.
+ * Second usage illustrates `TypeDefs` representing abstract types,
+ * where lo and hi are both `TypeBoundsTrees` and `Modifier.deferred` is set in mods.
+ */
+ abstract class TypeDefExtractor {
+ def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree): TypeDef
+ def unapply(typeDef: TypeDef): Option[(Modifiers, TypeName, List[TypeDef], Tree)]
+ }
+
+ /** A labelled expression. Not expressible in language syntax, but
+ * generated by the compiler to simulate while/do-while loops, and
+ * also by the pattern matcher.
+ *
+ * The label acts much like a nested function, where `params` represents
+ * the incoming parameters. The symbol given to the LabelDef should have
+ * a MethodType, as if it were a nested function.
+ *
+ * Jumps are apply nodes attributed with a label's symbol. The
+ * arguments from the apply node will be passed to the label and
+ * assigned to the Idents.
+ *
+ * Forward jumps within a block are allowed.
+ */
+ type LabelDef >: Null <: DefTree with TermTree
+
+ /** A tag that preserves the identity of the `LabelDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val LabelDefTag: ClassTag[LabelDef]
+
+ /** The constructor/deconstructor for `LabelDef` instances. */
+ val LabelDef: LabelDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `LabelDef(name, params, rhs)`.
+ *
+ * This AST node does not have direct correspondence to Scala code.
+ * It is used for tailcalls and like.
+ * For example, while/do are desugared to label defs as follows:
+ *
+ * while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ())
+ * do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ())
+ */
+ abstract class LabelDefExtractor {
+ def apply(name: TermName, params: List[Ident], rhs: Tree): LabelDef
+ def unapply(labelDef: LabelDef): Option[(TermName, List[Ident], Tree)]
+ }
+
+ /** Import selector
+ *
+ * Representation of an imported name its optional rename and their optional positions
+ *
+ * Eliminated by typecheck.
+ *
+ * @param name the imported name
+ * @param namePos its position or -1 if undefined
+ * @param rename the name the import is renamed to (== name if no renaming)
+ * @param renamePos the position of the rename or -1 if undefined
+ */
+ type ImportSelector >: Null <: AnyRef
+
+ /** A tag that preserves the identity of the `ImportSelector` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ImportSelectorTag: ClassTag[ImportSelector]
+
+ /** The constructor/deconstructor for `ImportSelector` instances. */
+ val ImportSelector: ImportSelectorExtractor
+
+ /** An extractor class to create and pattern match with syntax `ImportSelector(name:, namePos, rename, renamePos)`.
+ * This is not an AST node, it is used as a part of the `Import` node.
+ */
+ abstract class ImportSelectorExtractor {
+ def apply(name: Name, namePos: Int, rename: Name, renamePos: Int): ImportSelector
+ def unapply(importSelector: ImportSelector): Option[(Name, Int, Name, Int)]
+ }
+
+ /** Import clause
+ *
+ * @param expr
+ * @param selectors
+ */
+ type Import >: Null <: SymTree
+
+ /** A tag that preserves the identity of the `Import` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ImportTag: ClassTag[Import]
+
+ /** The constructor/deconstructor for `Import` instances. */
+ val Import: ImportExtractor
+
+ /** An extractor class to create and pattern match with syntax `Import(expr, selectors)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * import expr.{selectors}
+ *
+ * Selectors are a list of pairs of names (from, to). // [Eugene++] obviously, they no longer are. please, document!
+ * The last (and maybe only name) may be a nme.WILDCARD. For instance:
+ *
+ * import qual.{x, y => z, _}
+ *
+ * Would be represented as:
+ *
+ * Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null)))
+ *
+ * The symbol of an `Import` is an import symbol @see Symbol.newImport.
+ * It's used primarily as a marker to check that the import has been typechecked.
+ */
+ abstract class ImportExtractor {
+ def apply(expr: Tree, selectors: List[ImportSelector]): Import
+ def unapply(import_ : Import): Option[(Tree, List[ImportSelector])]
+ }
+
+ /** Instantiation template of a class or trait
+ *
+ * @param parents
+ * @param body
+ */
+ type Template >: Null <: SymTree
+
+ /** A tag that preserves the identity of the `Template` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TemplateTag: ClassTag[Template]
+
+ /** The constructor/deconstructor for `Template` instances. */
+ val Template: TemplateExtractor
+
+ /** An extractor class to create and pattern match with syntax `Template(parents, self, body)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `extends` parents { self => body }
+ *
+ * In case when the self-type annotation is missing, it is represented as
+ * an empty value definition with nme.WILDCARD as name and NoType as type.
+ *
+ * The symbol of a template is a local dummy. @see Symbol.newLocalDummy
+ * The owner of the local dummy is the enclosing trait or class.
+ * The local dummy is itself the owner of any local blocks. For example:
+ *
+ * class C {
+ * def foo { // owner is C
+ * def bar // owner is local dummy
+ * }
+ * }
+ */
+ abstract class TemplateExtractor {
+ def apply(parents: List[Tree], self: ValDef, body: List[Tree]): Template
+ def unapply(template: Template): Option[(List[Tree], ValDef, List[Tree])]
+ }
+
+ /** Block of expressions (semicolon separated expressions) */
+ type Block >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Block` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val BlockTag: ClassTag[Block]
+
+ /** The constructor/deconstructor for `Block` instances. */
+ val Block: BlockExtractor
+
+ /** An extractor class to create and pattern match with syntax `Block(stats, expr)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * { stats; expr }
+ *
+ * If the block is empty, the `expr` is set to `Literal(Constant(()))`. // [Eugene++] check this
+ */
+ abstract class BlockExtractor {
+ def apply(stats: List[Tree], expr: Tree): Block
+ def unapply(block: Block): Option[(List[Tree], Tree)]
+ }
+
+ /** Case clause in a pattern match, eliminated during explicitouter
+ * (except for occurrences in switch statements).
+ * Eliminated by patmat/explicitouter.
+ */
+ type CaseDef >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `CaseDef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val CaseDefTag: ClassTag[CaseDef]
+
+ /** The constructor/deconstructor for `CaseDef` instances. */
+ val CaseDef: CaseDefExtractor
+
+ /** An extractor class to create and pattern match with syntax `CaseDef(pat, guard, body)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `case` pat `if` guard => body
+ *
+ * If the guard is not present, the `guard` is set to `EmptyTree`. // [Eugene++] check this
+ * If the body is not specified, the `body` is set to `EmptyTree`. // [Eugene++] check this
+ */
+ abstract class CaseDefExtractor {
+ def apply(pat: Tree, guard: Tree, body: Tree): CaseDef
+ def unapply(caseDef: CaseDef): Option[(Tree, Tree, Tree)]
+ }
+
+ /** Alternatives of patterns, eliminated by explicitouter, except for
+ * occurrences in encoded Switch stmt (=remaining Match(CaseDef(...)))
+ * Eliminated by patmat/explicitouter.
+ */
+ type Alternative >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Alternative` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AlternativeTag: ClassTag[Alternative]
+
+ /** The constructor/deconstructor for `Alternative` instances. */
+ val Alternative: AlternativeExtractor
+
+ /** An extractor class to create and pattern match with syntax `Alternative(trees)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * pat1 | ... | patn
+ */
+ abstract class AlternativeExtractor {
+ def apply(trees: List[Tree]): Alternative
+ def unapply(alternative: Alternative): Option[List[Tree]]
+ }
+
+ /** Repetition of pattern.
+ * Eliminated by patmat/explicitouter.
+ */
+ type Star >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Star` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val StarTag: ClassTag[Star]
+
+ /** The constructor/deconstructor for `Star` instances. */
+ val Star: StarExtractor
+
+ /** An extractor class to create and pattern match with syntax `Star(elem)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * pat*
+ */
+ abstract class StarExtractor {
+ def apply(elem: Tree): Star
+ def unapply(star: Star): Option[Tree]
+ }
+
+ /** Bind of a variable to a rhs pattern, eliminated by explicitouter
+ * Eliminated by patmat/explicitouter.
+ *
+ * @param name
+ * @param body
+ */
+ type Bind >: Null <: DefTree
+
+ /** A tag that preserves the identity of the `Bind` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val BindTag: ClassTag[Bind]
+
+ /** The constructor/deconstructor for `Bind` instances. */
+ val Bind: BindExtractor
+
+ /** An extractor class to create and pattern match with syntax `Bind(name, body)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * pat*
+ */
+ abstract class BindExtractor {
+ def apply(name: Name, body: Tree): Bind
+ def unapply(bind: Bind): Option[(Name, Tree)]
+ }
+
+ /** Noone knows what this is.
+ * It is not idempotent w.r.t typechecking.
+ * Can we, please, remove it?
+ * Introduced by typer, eliminated by patmat/explicitouter.
+ */
+ type UnApply >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `UnApply` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val UnApplyTag: ClassTag[UnApply]
+
+ /** The constructor/deconstructor for `UnApply` instances. */
+ val UnApply: UnApplyExtractor
+
+ /** An extractor class to create and pattern match with syntax `UnApply(fun, args)`.
+ * This AST node does not have direct correspondence to Scala code,
+ * and is introduced when typechecking pattern matches and `try` blocks.
+ */
+ abstract class UnApplyExtractor {
+ def apply(fun: Tree, args: List[Tree]): UnApply
+ def unapply(unApply: UnApply): Option[(Tree, List[Tree])]
+ }
+
+ /** Array of expressions, needs to be translated in backend.
+ * This AST node is used to pass arguments to vararg arguments.
+ * Introduced by uncurry.
+ */
+ type ArrayValue >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `ArrayValue` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ArrayValueTag: ClassTag[ArrayValue]
+
+ /** The constructor/deconstructor for `ArrayValue` instances. */
+ val ArrayValue: ArrayValueExtractor
+
+ /** An extractor class to create and pattern match with syntax `ArrayValue(elemtpt, elems)`.
+ * This AST node does not have direct correspondence to Scala code,
+ * and is used to pass arguments to vararg arguments. For instance:
+ *
+ * printf("%s%d", foo, 42)
+ *
+ * Is translated to after uncurry to:
+ *
+ * Apply(
+ * Ident("printf"),
+ * Literal("%s%d"),
+ * ArrayValue(<Any>, List(Ident("foo"), Literal(42))))
+ */
+ abstract class ArrayValueExtractor {
+ def apply(elemtpt: Tree, elems: List[Tree]): ArrayValue
+ def unapply(arrayValue: ArrayValue): Option[(Tree, List[Tree])]
+ }
+
+ /** Anonymous function, eliminated by lambdalift */
+ type Function >: Null <: TermTree with SymTree
+
+ /** A tag that preserves the identity of the `Function` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val FunctionTag: ClassTag[Function]
+
+ /** The constructor/deconstructor for `Function` instances. */
+ val Function: FunctionExtractor
+
+ /** An extractor class to create and pattern match with syntax `Function(vparams, body)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * vparams => body
+ *
+ * The symbol of a Function is a synthetic value of name nme.ANON_FUN_NAME
+ * It is the owner of the function's parameters.
+ */
+ abstract class FunctionExtractor {
+ def apply(vparams: List[ValDef], body: Tree): Function
+ def unapply(function: Function): Option[(List[ValDef], Tree)]
+ }
+
+ /** Assignment */
+ type Assign >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Assign` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AssignTag: ClassTag[Assign]
+
+ /** The constructor/deconstructor for `Assign` instances. */
+ val Assign: AssignExtractor
+
+ /** An extractor class to create and pattern match with syntax `Assign(lhs, rhs)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * lhs = rhs
+ */
+ abstract class AssignExtractor {
+ def apply(lhs: Tree, rhs: Tree): Assign
+ def unapply(assign: Assign): Option[(Tree, Tree)]
+ }
+
+ /** Either an assignment or a named argument. Only appears in argument lists,
+ * eliminated by typecheck (doTypedApply), resurrected by reifier.
+ */
+ type AssignOrNamedArg >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `AssignOrNamedArg` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AssignOrNamedArgTag: ClassTag[AssignOrNamedArg]
+
+ /** The constructor/deconstructor for `AssignOrNamedArg` instances. */
+ val AssignOrNamedArg: AssignOrNamedArgExtractor
+
+ /** An extractor class to create and pattern match with syntax `AssignOrNamedArg(lhs, rhs)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * @annotation(lhs = rhs)
+ *
+ * m.f(lhs = rhs)
+ */
+ abstract class AssignOrNamedArgExtractor {
+ def apply(lhs: Tree, rhs: Tree): AssignOrNamedArg
+ def unapply(assignOrNamedArg: AssignOrNamedArg): Option[(Tree, Tree)]
+ }
+
+ /** Conditional expression */
+ type If >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `If` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val IfTag: ClassTag[If]
+
+ /** The constructor/deconstructor for `If` instances. */
+ val If: IfExtractor
+
+ /** An extractor class to create and pattern match with syntax `If(cond, thenp, elsep)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `if` (cond) thenp `else` elsep
+ *
+ * If the alternative is not present, the `elsep` is set to `EmptyTree`. // [Eugene++] check this
+ */
+ abstract class IfExtractor {
+ def apply(cond: Tree, thenp: Tree, elsep: Tree): If
+ def unapply(if_ : If): Option[(Tree, Tree, Tree)]
+ }
+
+ /** - Pattern matching expression (before explicitouter)
+ * - Switch statements (after explicitouter)
+ *
+ * After explicitouter, cases will satisfy the following constraints:
+ *
+ * - all guards are `EmptyTree`,
+ * - all patterns will be either `Literal(Constant(x:Int))`
+ * or `Alternative(lit|...|lit)`
+ * - except for an "otherwise" branch, which has pattern
+ * `Ident(nme.WILDCARD)`
+ */
+ type Match >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Match` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val MatchTag: ClassTag[Match]
+
+ /** The constructor/deconstructor for `Match` instances. */
+ val Match: MatchExtractor
+
+ /** An extractor class to create and pattern match with syntax `Match(selector, cases)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * selector `match` { cases }
+ *
+ * // [Eugene++] say something about `val (foo, bar) = baz` and likes.
+ */
+ abstract class MatchExtractor {
+ def apply(selector: Tree, cases: List[CaseDef]): Match
+ def unapply(match_ : Match): Option[(Tree, List[CaseDef])]
+ }
+
+ /** Return expression */
+ type Return >: Null <: TermTree with SymTree
+
+ /** A tag that preserves the identity of the `Return` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ReturnTag: ClassTag[Return]
+
+ /** The constructor/deconstructor for `Return` instances. */
+ val Return: ReturnExtractor
+
+ /** An extractor class to create and pattern match with syntax `Return(expr)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `return` expr
+ *
+ * The symbol of a Return node is the enclosing method
+ */
+ abstract class ReturnExtractor {
+ def apply(expr: Tree): Return
+ def unapply(return_ : Return): Option[Tree]
+ }
+
+ /** [Eugene++] comment me! */
+ type Try >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Try` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TryTag: ClassTag[Try]
+
+ /** The constructor/deconstructor for `Try` instances. */
+ val Try: TryExtractor
+
+ /** An extractor class to create and pattern match with syntax `Try(block, catches, finalizer)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `try` block `catch` { catches } `finally` finalizer
+ *
+ * If the finalizer is not present, the `finalizer` is set to `EmptyTree`. // [Eugene++] check this
+ */
+ abstract class TryExtractor {
+ def apply(block: Tree, catches: List[CaseDef], finalizer: Tree): Try
+ def unapply(try_ : Try): Option[(Tree, List[CaseDef], Tree)]
+ }
+
+ /** Throw expression */
+ type Throw >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Throw` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ThrowTag: ClassTag[Throw]
+
+ /** The constructor/deconstructor for `Throw` instances. */
+ val Throw: ThrowExtractor
+
+ /** An extractor class to create and pattern match with syntax `Throw(expr)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `throw` expr
+ */
+ abstract class ThrowExtractor {
+ def apply(expr: Tree): Throw
+ def unapply(throw_ : Throw): Option[Tree]
+ }
+
+ /** Object instantiation
+ * One should always use factory method below to build a user level new.
+ *
+ * @param tpt a class type
+ */
+ type New >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `New` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val NewTag: ClassTag[New]
+
+ /** The constructor/deconstructor for `New` instances. */
+ val New: NewExtractor
+
+ /** An extractor class to create and pattern match with syntax `New(tpt)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * `new` T
+ *
+ * This node always occurs in the following context:
+ *
+ * (`new` tpt).<init>[targs](args)
+ */
+ abstract class NewExtractor {
+ def apply(tpt: Tree): New
+ def unapply(new_ : New): Option[Tree]
+ }
+
+ /** Type annotation, eliminated by cleanup */
+ type Typed >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Typed` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypedTag: ClassTag[Typed]
+
+ /** The constructor/deconstructor for `Typed` instances. */
+ val Typed: TypedExtractor
+
+ /** An extractor class to create and pattern match with syntax `Typed(expr, tpt)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * expr: tpt
+ */
+ abstract class TypedExtractor {
+ def apply(expr: Tree, tpt: Tree): Typed
+ def unapply(typed: Typed): Option[(Tree, Tree)]
+ }
+
+ /** Common base class for Apply and TypeApply. This could in principle
+ * be a SymTree, but whether or not a Tree is a SymTree isn't used
+ * to settle any interesting questions, and it would add a useless
+ * field to all the instances (useless, since GenericApply forwards to
+ * the underlying fun.)
+ */
+ type GenericApply >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `GenericApply` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val GenericApplyTag: ClassTag[GenericApply]
+
+ /** Explicit type application.
+ * @PP: All signs point toward it being a requirement that args.nonEmpty,
+ * but I can't find that explicitly stated anywhere. Unless your last name
+ * is odersky, you should probably treat it as true.
+ */
+ type TypeApply >: Null <: GenericApply
+
+ /** A tag that preserves the identity of the `TypeApply` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeApplyTag: ClassTag[TypeApply]
+
+ /** The constructor/deconstructor for `TypeApply` instances. */
+ val TypeApply: TypeApplyExtractor
+
+ /** An extractor class to create and pattern match with syntax `TypeApply(fun, args)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * fun[args]
+ */
+ abstract class TypeApplyExtractor {
+ def apply(fun: Tree, args: List[Tree]): TypeApply
+ def unapply(typeApply: TypeApply): Option[(Tree, List[Tree])]
+ }
+
+ /** Value application */
+ type Apply >: Null <: GenericApply
+
+ /** A tag that preserves the identity of the `Apply` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ApplyTag: ClassTag[Apply]
+
+ /** The constructor/deconstructor for `Apply` instances. */
+ val Apply: ApplyExtractor
+
+ /** An extractor class to create and pattern match with syntax `Apply(fun, args)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * fun(args)
+ *
+ * For instance:
+ *
+ * fun[targs](args)
+ *
+ * Is expressed as:
+ *
+ * Apply(TypeApply(fun, targs), args)
+ */
+ abstract class ApplyExtractor {
+ def apply(fun: Tree, args: List[Tree]): Apply
+ def unapply(apply: Apply): Option[(Tree, List[Tree])]
+ }
+
+ /** Dynamic value application.
+ * In a dynamic application q.f(as)
+ * - q is stored in qual
+ * - as is stored in args
+ * - f is stored as the node's symbol field.
+ * [Eugene++] what is it used for?
+ * Introduced by erasure, eliminated by cleanup.
+ */
+ type ApplyDynamic >: Null <: TermTree with SymTree
+
+ /** A tag that preserves the identity of the `ApplyDynamic` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ApplyDynamicTag: ClassTag[ApplyDynamic]
+
+ /** The constructor/deconstructor for `ApplyDynamic` instances. */
+ val ApplyDynamic: ApplyDynamicExtractor
+
+ /** An extractor class to create and pattern match with syntax `ApplyDynamic(qual, args)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * fun(args)
+ *
+ * The symbol of an ApplyDynamic is the function symbol of `qual`, or NoSymbol, if there is none.
+ */
+ abstract class ApplyDynamicExtractor {
+ def apply(qual: Tree, args: List[Tree]): ApplyDynamic
+ def unapply(applyDynamic: ApplyDynamic): Option[(Tree, List[Tree])]
+ }
+
+ /** Super reference, qual = corresponding this reference
+ * A super reference C.super[M] is represented as Super(This(C), M).
+ */
+ type Super >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Super` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SuperTag: ClassTag[Super]
+
+ /** The constructor/deconstructor for `Super` instances. */
+ val Super: SuperExtractor
+
+ /** An extractor class to create and pattern match with syntax `Super(qual, mix)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * C.super[M]
+ *
+ * Which is represented as:
+ *
+ * Super(This(C), M)
+ *
+ * If `mix` is empty, it is tpnme.EMPTY.
+ *
+ * The symbol of a Super is the class _from_ which the super reference is made.
+ * For instance in C.super(...), it would be C.
+ */
+ abstract class SuperExtractor {
+ def apply(qual: Tree, mix: TypeName): Super
+ def unapply(super_ : Super): Option[(Tree, TypeName)]
+ }
+
+ /** Self reference */
+ type This >: Null <: TermTree with SymTree
+
+ /** A tag that preserves the identity of the `This` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ThisTag: ClassTag[This]
+
+ /** The constructor/deconstructor for `This` instances. */
+ val This: ThisExtractor
+
+ /** An extractor class to create and pattern match with syntax `This(qual)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * qual.this
+ *
+ * The symbol of a This is the class to which the this refers.
+ * For instance in C.this, it would be C.
+ *
+ * If `mix` is empty, then ???
+ */
+ abstract class ThisExtractor {
+ def apply(qual: TypeName): This
+ def unapply(this_ : This): Option[TypeName]
+ }
+
+ /** Designator <qualifier> . <name> */
+ type Select >: Null <: RefTree
+
+ /** A tag that preserves the identity of the `Select` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SelectTag: ClassTag[Select]
+
+ /** The constructor/deconstructor for `Select` instances. */
+ val Select: SelectExtractor
+
+ /** An extractor class to create and pattern match with syntax `Select(qual, name)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * qualifier.selector
+ */
+ abstract class SelectExtractor {
+ def apply(qualifier: Tree, name: Name): Select
+ def unapply(select: Select): Option[(Tree, Name)]
+ }
+
+ /** Identifier <name> */
+ type Ident >: Null <: RefTree
+
+ /** A tag that preserves the identity of the `Ident` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val IdentTag: ClassTag[Ident]
+
+ /** The constructor/deconstructor for `Ident` instances. */
+ val Ident: IdentExtractor
+
+ /** An extractor class to create and pattern match with syntax `Ident(qual, name)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * name
+ *
+ * Type checker converts idents that refer to enclosing fields or methods to selects.
+ * For example, name ==> this.name
+ */
+ abstract class IdentExtractor {
+ def apply(name: Name): Ident
+ def unapply(ident: Ident): Option[Name]
+ }
+
+ /** Marks underlying reference to id as boxed.
+ * @pre id must refer to a captured variable
+ * A reference such marked will refer to the boxed entity, no dereferencing
+ * with `.elem` is done on it.
+ * This tree node can be emitted by macros such as reify that call referenceCapturedVariable.
+ * It is eliminated in LambdaLift, where the boxing conversion takes place.
+ */
+ type ReferenceToBoxed >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `ReferenceToBoxed` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ReferenceToBoxedTag: ClassTag[ReferenceToBoxed]
+
+ /** The constructor/deconstructor for `ReferenceToBoxed` instances. */
+ val ReferenceToBoxed: ReferenceToBoxedExtractor
+
+ /** An extractor class to create and pattern match with syntax `ReferenceToBoxed(ident)`.
+ * This AST node does not have direct correspondence to Scala code,
+ * and is emitted by macros to reference capture vars directly without going through `elem`.
+ *
+ * For example:
+ *
+ * var x = ...
+ * fun { x }
+ *
+ * Will emit:
+ *
+ * Ident(x)
+ *
+ * Which gets transformed to:
+ *
+ * Select(Ident(x), "elem")
+ *
+ * If `ReferenceToBoxed` were used instead of Ident, no transformation would be performed.
+ */
+ abstract class ReferenceToBoxedExtractor {
+ def apply(ident: Ident): ReferenceToBoxed
+ def unapply(referenceToBoxed: ReferenceToBoxed): Option[Ident]
+ }
+
+ /** Literal */
+ type Literal >: Null <: TermTree
+
+ /** A tag that preserves the identity of the `Literal` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val LiteralTag: ClassTag[Literal]
+
+ /** The constructor/deconstructor for `Literal` instances. */
+ val Literal: LiteralExtractor
+
+ /** An extractor class to create and pattern match with syntax `Literal(value)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * value
+ */
+ abstract class LiteralExtractor {
+ def apply(value: Constant): Literal
+ def unapply(literal: Literal): Option[Constant]
+ }
+
+ /** A tree that has an annotation attached to it. Only used for annotated types and
+ * annotation ascriptions, annotations on definitions are stored in the Modifiers.
+ * Eliminated by typechecker (typedAnnotated), the annotations are then stored in
+ * an AnnotatedType.
+ */
+ type Annotated >: Null <: AnyRef with Tree
+
+ /** A tag that preserves the identity of the `Annotated` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AnnotatedTag: ClassTag[Annotated]
+
+ /** The constructor/deconstructor for `Annotated` instances. */
+ val Annotated: AnnotatedExtractor
+
+ /** An extractor class to create and pattern match with syntax `Annotated(annot, arg)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * arg @annot // for types
+ * arg: @annot // for exprs
+ */
+ abstract class AnnotatedExtractor {
+ def apply(annot: Tree, arg: Tree): Annotated
+ def unapply(annotated: Annotated): Option[(Tree, Tree)]
+ }
+
+ /** Singleton type, eliminated by RefCheck */
+ type SingletonTypeTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `SingletonTypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SingletonTypeTreeTag: ClassTag[SingletonTypeTree]
+
+ /** The constructor/deconstructor for `SingletonTypeTree` instances. */
+ val SingletonTypeTree: SingletonTypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `SingletonTypeTree(ref)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * ref.type
+ */
+ abstract class SingletonTypeTreeExtractor {
+ def apply(ref: Tree): SingletonTypeTree
+ def unapply(singletonTypeTree: SingletonTypeTree): Option[Tree]
+ }
+
+ /** Type selection <qualifier> # <name>, eliminated by RefCheck */
+ // [Eugene++] don't see why we need it, when we have Select
+ type SelectFromTypeTree >: Null <: TypTree with RefTree
+
+ /** A tag that preserves the identity of the `SelectFromTypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SelectFromTypeTreeTag: ClassTag[SelectFromTypeTree]
+
+ /** The constructor/deconstructor for `SelectFromTypeTree` instances. */
+ val SelectFromTypeTree: SelectFromTypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `SelectFromTypeTree(qualifier, name)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * qualifier # selector
+ *
+ * Note: a path-dependent type p.T is expressed as p.type # T
+ */
+ abstract class SelectFromTypeTreeExtractor {
+ def apply(qualifier: Tree, name: TypeName): SelectFromTypeTree
+ def unapply(selectFromTypeTree: SelectFromTypeTree): Option[(Tree, TypeName)]
+ }
+
+ /** Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck */
+ type CompoundTypeTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `CompoundTypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val CompoundTypeTreeTag: ClassTag[CompoundTypeTree]
+
+ /** The constructor/deconstructor for `CompoundTypeTree` instances. */
+ val CompoundTypeTree: CompoundTypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `CompoundTypeTree(templ)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * parent1 with ... with parentN { refinement }
+ */
+ abstract class CompoundTypeTreeExtractor {
+ def apply(templ: Template): CompoundTypeTree
+ def unapply(compoundTypeTree: CompoundTypeTree): Option[Template]
+ }
+
+ /** Applied type <tpt> [ <args> ], eliminated by RefCheck */
+ type AppliedTypeTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `AppliedTypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AppliedTypeTreeTag: ClassTag[AppliedTypeTree]
+
+ /** The constructor/deconstructor for `AppliedTypeTree` instances. */
+ val AppliedTypeTree: AppliedTypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `AppliedTypeTree(tpt, args)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * tpt[args]
+ */
+ abstract class AppliedTypeTreeExtractor {
+ def apply(tpt: Tree, args: List[Tree]): AppliedTypeTree
+ def unapply(appliedTypeTree: AppliedTypeTree): Option[(Tree, List[Tree])]
+ }
+
+ /** Document me! */
+ type TypeBoundsTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `TypeBoundsTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeBoundsTreeTag: ClassTag[TypeBoundsTree]
+
+ /** The constructor/deconstructor for `TypeBoundsTree` instances. */
+ val TypeBoundsTree: TypeBoundsTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `TypeBoundsTree(lo, hi)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * >: lo <: hi
+ */
+ abstract class TypeBoundsTreeExtractor {
+ def apply(lo: Tree, hi: Tree): TypeBoundsTree
+ def unapply(typeBoundsTree: TypeBoundsTree): Option[(Tree, Tree)]
+ }
+
+ /** Document me! */
+ type ExistentialTypeTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `ExistentialTypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ExistentialTypeTreeTag: ClassTag[ExistentialTypeTree]
+
+ /** The constructor/deconstructor for `ExistentialTypeTree` instances. */
+ val ExistentialTypeTree: ExistentialTypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `ExistentialTypeTree(tpt, whereClauses)`.
+ * This AST node corresponds to the following Scala code:
+ *
+ * tpt forSome { whereClauses }
+ */
+ abstract class ExistentialTypeTreeExtractor {
+ def apply(tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
+ def unapply(existentialTypeTree: ExistentialTypeTree): Option[(Tree, List[Tree])]
+ }
+
+ /** A synthetic tree holding an arbitrary type. Not to be confused with
+ * with TypTree, the trait for trees that are only used for type trees.
+ * TypeTree's are inserted in several places, but most notably in
+ * `RefCheck`, where the arbitrary type trees are all replaced by
+ * TypeTree's. */
+ type TypeTree >: Null <: TypTree
+
+ /** A tag that preserves the identity of the `TypeTree` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeTreeTag: ClassTag[TypeTree]
+
+ /** The constructor/deconstructor for `TypeTree` instances. */
+ val TypeTree: TypeTreeExtractor
+
+ /** An extractor class to create and pattern match with syntax `TypeTree()`.
+ * This AST node does not have direct correspondence to Scala code,
+ * and is emitted by everywhere when we want to wrap a `Type` in a `Tree`.
+ */
+ abstract class TypeTreeExtractor {
+ def apply(): TypeTree
+ def unapply(typeTree: TypeTree): Boolean
+ }
+
+ /** ... */
+ type Modifiers >: Null <: ModifiersBase
+
+ /** A tag that preserves the identity of the `Modifiers` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ModifiersTag: ClassTag[Modifiers]
+
+ /** ... */
+ abstract class ModifiersBase {
+ def flags: FlagSet
+ def hasFlag(flags: FlagSet): Boolean
+ def hasAllFlags(flags: FlagSet): Boolean
+ def privateWithin: Name // default: EmptyTypeName
+ def annotations: List[Tree] // default: List()
+ def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers =
+ Modifiers(flags, privateWithin, f(annotations))
+ }
+
+ val Modifiers: ModifiersCreator
+
+ abstract class ModifiersCreator {
+ def apply(): Modifiers = Modifiers(NoFlags, EmptyTypeName, List())
+ def apply(flags: FlagSet, privateWithin: Name, annotations: List[Tree]): Modifiers
+ }
+
+ def Modifiers(flags: FlagSet, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List())
+ def Modifiers(flags: FlagSet): Modifiers = Modifiers(flags, EmptyTypeName)
+
+ /** ... */
+ lazy val NoMods = Modifiers()
+
+ // [Eugene++] temporarily moved here until SI-5863 is fixed
+// ---------------------- factories ----------------------------------------------
+
+ /** @param sym the class symbol
+ * @param impl the implementation template
+ */
+ def ClassDef(sym: Symbol, impl: Template): ClassDef
+
+ /**
+ * @param sym the class symbol
+ * @param impl the implementation template
+ */
+ def ModuleDef(sym: Symbol, impl: Template): ModuleDef
+
+ def ValDef(sym: Symbol, rhs: Tree): ValDef
+
+ def ValDef(sym: Symbol): ValDef
+
+ def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef
+
+ def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef
+
+ def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef
+
+ def DefDef(sym: Symbol, rhs: Tree): DefDef
+
+ def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef
+
+ /** A TypeDef node which defines given `sym` with given tight hand side `rhs`. */
+ def TypeDef(sym: Symbol, rhs: Tree): TypeDef
+
+ /** A TypeDef node which defines abstract type or type parameter for given `sym` */
+ def TypeDef(sym: Symbol): TypeDef
+
+ def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef
+
+ /** Block factory that flattens directly nested blocks.
+ */
+ def Block(stats: Tree*): Block
+
+ /** casedef shorthand */
+ def CaseDef(pat: Tree, body: Tree): CaseDef
+
+ def Bind(sym: Symbol, body: Tree): Bind
+
+ def Try(body: Tree, cases: (Tree, Tree)*): Try
+
+ def Throw(tpe: Type, args: Tree*): Throw
+
+ /** Factory method for object creation `new tpt(args_1)...(args_n)`
+ * A `New(t, as)` is expanded to: `(new t).<init>(as)`
+ */
+ def New(tpt: Tree, argss: List[List[Tree]]): Tree
+
+ /** 0-1 argument list new, based on a type.
+ */
+ def New(tpe: Type, args: Tree*): Tree
+
+ def New(sym: Symbol, args: Tree*): Tree
+
+ def Apply(sym: Symbol, args: Tree*): Tree
+
+ def ApplyConstructor(tpt: Tree, args: List[Tree]): Tree
+
+ def Super(sym: Symbol, mix: TypeName): Tree
+
+ def This(sym: Symbol): Tree
+
+ def Select(qualifier: Tree, name: String): Select
+
+ def Select(qualifier: Tree, sym: Symbol): Select
+
+ def Ident(name: String): Ident
+
+ def Ident(sym: Symbol): Ident
+
+ def TypeTree(tp: Type): TypeTree
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/base/TypeCreator.scala b/src/library/scala/reflect/base/TypeCreator.scala
new file mode 100644
index 0000000000..8a14e53dd3
--- /dev/null
+++ b/src/library/scala/reflect/base/TypeCreator.scala
@@ -0,0 +1,6 @@
+package scala.reflect
+package base
+
+abstract class TypeCreator {
+ def apply[U <: Universe with Singleton](m: MirrorOf[U]): U # Type
+}
diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala
new file mode 100644
index 0000000000..774bc6ebea
--- /dev/null
+++ b/src/library/scala/reflect/base/TypeTags.scala
@@ -0,0 +1,246 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.reflect
+package base
+
+import java.lang.{ Class => jClass }
+import language.implicitConversions
+
+/**
+ * Type tags encapsulate a representation of type T.
+ * They are supposed to replace the pre-2.10 concept of a [[scala.reflect.Manifest]].
+ * TypeTags are much better integrated with reflection than manifests are, and are consequently much simpler.
+ *
+ * === Overview ===
+ *
+ * Type tags are organized in a hierarchy of three classes:
+ * [[scala.reflect.ClassTag]], [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#AbsTypeTag]].
+ *
+ * A [[scala.reflect.ClassTag]] carries a runtime class that corresponds to the source type T.
+ * As of such, it possesses the knowledge about how to build single- and multi-dimensional arrays of elements of that type.
+ * It guarantees that the source type T did not to contain any references to type parameters or abstract types.
+ * [[scala.reflect.ClassTag]] corresponds to a previous notion of [[scala.reflect.ClassManifest]].
+ *
+ * A [[scala.reflect.base.Universe#AbsTypeTag]] value wraps a full Scala type in its tpe field.
+ * A [[scala.reflect.base.Universe#TypeTag]] value is an [[scala.reflect.base.Universe#AbsTypeTag]]
+ * that is guaranteed not to contain any references to type parameters or abstract types.
+ *
+ * [Eugene++] also mention sensitivity to prefixes, i.e. that rb.TypeTag is different from ru.TypeTag
+ * [Eugene++] migratability between mirrors and universes is also worth mentioning
+ *
+ * === Splicing ===
+ *
+ * Tags can be spliced, i.e. if compiler generates a tag for a type that contains references to tagged
+ * type parameters or abstract type members, it will retrieve the corresponding tag and embed it into the result.
+ * An example that illustrates the TypeTag embedding, consider the following function:
+ *
+ * import reflect.mirror._
+ * def f[T: TypeTag, U] = {
+ * type L = T => U
+ * implicitly[AbsTypeTag[L]]
+ * }
+ *
+ * Then a call of f[String, Int] will yield a result of the form
+ *
+ * AbsTypeTag(<[ String => U ]>).
+ *
+ * Note that T has been replaced by String, because it comes with a TypeTag in f, whereas U was left as a type parameter.
+ *
+ * === AbsTypeTag vs TypeTag ===
+ *
+ * Be careful with AbsTypeTag, because it will reify types even if these types are abstract.
+ * This makes it easy to forget to tag one of the methods in the call chain and discover it much later in the runtime
+ * by getting cryptic errors far away from their source. For example, consider the following snippet:
+ *
+ * def bind[T: AbsTypeTag](name: String, value: T): IR.Result = bind((name, value))
+ * def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value)
+ * object NamedParam {
+ * implicit def namedValue[T: AbsTypeTag](name: String, x: T): NamedParam = apply(name, x)
+ * def apply[T: AbsTypeTag](name: String, x: T): NamedParam = new Typed[T](name, x)
+ * }
+ *
+ * This fragment of Scala REPL implementation defines a `bind` function that carries a named value along with its type
+ * into the heart of the REPL. Using a [[scala.reflect.base.Universe#AbsTypeTag]] here is reasonable, because it is desirable
+ * to work with all types, even if they are type parameters or abstract type members.
+ *
+ * However if any of the three `AbsTypeTag` context bounds is omitted, the resulting code will be incorrect,
+ * because the missing `AbsTypeTag` will be transparently generated by the compiler, carrying meaningless information.
+ * Most likely, this problem will manifest itself elsewhere, making debugging complicated.
+ * If `AbsTypeTag` context bounds were replaced with `TypeTag`, then such errors would be reported statically.
+ * But in that case we wouldn't be able to use `bind` in arbitrary contexts.
+ *
+ * === Backward compatibility ===
+ *
+ * Type tags correspond loosely to manifests.
+ *
+ * More precisely:
+ * The previous notion of a [[scala.reflect.ClassManifest]] corresponds to a scala.reflect.ClassTag,
+ * The previous notion of a [[scala.reflect.Manifest]] corresponds to scala.reflect.runtime.universe.TypeTag,
+ *
+ * In Scala 2.10, manifests are deprecated, so it's adviseable to migrate them to tags,
+ * because manifests might be removed in the next major release.
+ *
+ * In most cases it will be enough to replace ClassManifests with ClassTags and Manifests with TypeTags,
+ * however there are a few caveats:
+ *
+ * 1) The notion of OptManifest is no longer supported. Tags can reify arbitrary types, so they are always available.
+ * // [Eugene++] it might be useful, though, to guard against abstractness of the incoming type.
+ *
+ * 2) There's no equivalent for AnyValManifest. Consider comparing your tag with one of the base tags
+ * (defined in the corresponding companion objects) to find out whether it represents a primitive value class.
+ * You can also use `<tag>.tpe.typeSymbol.isPrimitiveValueClass` for that purpose (requires scala-reflect.jar).
+ *
+ * 3) There's no replacement for factory methods defined in `ClassManifest` and `Manifest` companion objects.
+ * Consider assembling corresponding types using reflection API provided by Java (for classes) and Scala (for types).
+ *
+ * 4) Certain manifest functions (such as `<:<`, `>:>` and `typeArguments`) weren't included in the tag API.
+ * Consider using reflection API provided by Java (for classes) and Scala (for types) instead.
+ */
+// [Eugene++] implement serialization for typetags
+trait TypeTags { self: Universe =>
+
+ /**
+ * If an implicit value of type u.AbsTypeTag[T] is required, the compiler will make one up on demand.
+ * The implicitly created value contains in its tpe field a value of type u.Type that is a reflective representation of T.
+ * In that value, any occurrences of type parameters or abstract types U
+ * which come themselves with a TypeTag are represented by the type referenced by that TypeTag.
+ *
+ * @see [[scala.reflect.base.TypeTags]]
+ */
+ @annotation.implicitNotFound(msg = "No AbsTypeTag available for ${T}")
+ trait AbsTypeTag[T] extends Equals with Serializable {
+ val mirror: Mirror
+ def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T]
+ def tpe: Type
+
+ /** case class accessories */
+ override def canEqual(x: Any) = x.isInstanceOf[AbsTypeTag[_]]
+ override def equals(x: Any) = x.isInstanceOf[AbsTypeTag[_]] && this.mirror == x.asInstanceOf[AbsTypeTag[_]].mirror && this.tpe == x.asInstanceOf[AbsTypeTag[_]].tpe
+ override def hashCode = mirror.hashCode * 31 + tpe.hashCode
+ override def toString = "AbsTypeTag[" + tpe + "]"
+ }
+
+ object AbsTypeTag {
+ val Byte : AbsTypeTag[scala.Byte] = TypeTag.Byte
+ val Short : AbsTypeTag[scala.Short] = TypeTag.Short
+ val Char : AbsTypeTag[scala.Char] = TypeTag.Char
+ val Int : AbsTypeTag[scala.Int] = TypeTag.Int
+ val Long : AbsTypeTag[scala.Long] = TypeTag.Long
+ val Float : AbsTypeTag[scala.Float] = TypeTag.Float
+ val Double : AbsTypeTag[scala.Double] = TypeTag.Double
+ val Boolean : AbsTypeTag[scala.Boolean] = TypeTag.Boolean
+ val Unit : AbsTypeTag[scala.Unit] = TypeTag.Unit
+ val Any : AbsTypeTag[scala.Any] = TypeTag.Any
+ val Object : AbsTypeTag[java.lang.Object] = TypeTag.Object
+ val Nothing : AbsTypeTag[scala.Nothing] = TypeTag.Nothing
+ val Null : AbsTypeTag[scala.Null] = TypeTag.Null
+ val String : AbsTypeTag[java.lang.String] = TypeTag.String
+
+ def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): AbsTypeTag[T] =
+ tpec1(mirror1) match {
+ case ByteTpe => AbsTypeTag.Byte.asInstanceOf[AbsTypeTag[T]]
+ case ShortTpe => AbsTypeTag.Short.asInstanceOf[AbsTypeTag[T]]
+ case CharTpe => AbsTypeTag.Char.asInstanceOf[AbsTypeTag[T]]
+ case IntTpe => AbsTypeTag.Int.asInstanceOf[AbsTypeTag[T]]
+ case LongTpe => AbsTypeTag.Long.asInstanceOf[AbsTypeTag[T]]
+ case FloatTpe => AbsTypeTag.Float.asInstanceOf[AbsTypeTag[T]]
+ case DoubleTpe => AbsTypeTag.Double.asInstanceOf[AbsTypeTag[T]]
+ case BooleanTpe => AbsTypeTag.Boolean.asInstanceOf[AbsTypeTag[T]]
+ case UnitTpe => AbsTypeTag.Unit.asInstanceOf[AbsTypeTag[T]]
+ case AnyTpe => AbsTypeTag.Any.asInstanceOf[AbsTypeTag[T]]
+ case ObjectTpe => AbsTypeTag.Object.asInstanceOf[AbsTypeTag[T]]
+ case NothingTpe => AbsTypeTag.Nothing.asInstanceOf[AbsTypeTag[T]]
+ case NullTpe => AbsTypeTag.Null.asInstanceOf[AbsTypeTag[T]]
+ case StringTpe => AbsTypeTag.String.asInstanceOf[AbsTypeTag[T]]
+ case _ => new AbsTypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1)
+ }
+
+ def unapply[T](ttag: AbsTypeTag[T]): Option[Type] = Some(ttag.tpe)
+ }
+
+ private class AbsTypeTagImpl[T](val mirror: Mirror, val tpec: TypeCreator) extends AbsTypeTag[T] {
+ lazy val tpe: Type = tpec[self.type](mirror)
+ def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # AbsTypeTag[T] = {
+ val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]]
+ otherMirror.universe.AbsTypeTag[T](otherMirror1, tpec)
+ }
+ }
+
+ /**
+ * If an implicit value of type u.TypeTag[T] is required, the compiler will make one up on demand following the same procedure as for TypeTags.
+ * However, if the resulting type still contains references to type parameters or abstract types, a static error results.
+ *
+ * @see [[scala.reflect.base.TypeTags]]
+ */
+ @annotation.implicitNotFound(msg = "No TypeTag available for ${T}")
+ trait TypeTag[T] extends AbsTypeTag[T] with Equals with Serializable {
+ override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T]
+
+ /** case class accessories */
+ override def canEqual(x: Any) = x.isInstanceOf[TypeTag[_]]
+ override def equals(x: Any) = x.isInstanceOf[TypeTag[_]] && this.mirror == x.asInstanceOf[TypeTag[_]].mirror && this.tpe == x.asInstanceOf[TypeTag[_]].tpe
+ override def hashCode = mirror.hashCode * 31 + tpe.hashCode
+ override def toString = "TypeTag[" + tpe + "]"
+ }
+
+ object TypeTag {
+ val Byte: TypeTag[scala.Byte] = new PredefTypeTag[scala.Byte] (ByteTpe, _.TypeTag.Byte)
+ val Short: TypeTag[scala.Short] = new PredefTypeTag[scala.Short] (ShortTpe, _.TypeTag.Short)
+ val Char: TypeTag[scala.Char] = new PredefTypeTag[scala.Char] (CharTpe, _.TypeTag.Char)
+ val Int: TypeTag[scala.Int] = new PredefTypeTag[scala.Int] (IntTpe, _.TypeTag.Int)
+ val Long: TypeTag[scala.Long] = new PredefTypeTag[scala.Long] (LongTpe, _.TypeTag.Long)
+ val Float: TypeTag[scala.Float] = new PredefTypeTag[scala.Float] (FloatTpe, _.TypeTag.Float)
+ val Double: TypeTag[scala.Double] = new PredefTypeTag[scala.Double] (DoubleTpe, _.TypeTag.Double)
+ val Boolean: TypeTag[scala.Boolean] = new PredefTypeTag[scala.Boolean] (BooleanTpe, _.TypeTag.Boolean)
+ val Unit: TypeTag[scala.Unit] = new PredefTypeTag[scala.Unit] (UnitTpe, _.TypeTag.Unit)
+ val Any: TypeTag[scala.Any] = new PredefTypeTag[scala.Any] (AnyTpe, _.TypeTag.Any)
+ val Object: TypeTag[java.lang.Object] = new PredefTypeTag[java.lang.Object] (ObjectTpe, _.TypeTag.Object)
+ val Nothing: TypeTag[scala.Nothing] = new PredefTypeTag[scala.Nothing] (NothingTpe, _.TypeTag.Nothing)
+ val Null: TypeTag[scala.Null] = new PredefTypeTag[scala.Null] (NullTpe, _.TypeTag.Null)
+ val String: TypeTag[java.lang.String] = new PredefTypeTag[java.lang.String] (StringTpe, _.TypeTag.String)
+
+ def apply[T](mirror1: MirrorOf[self.type], tpec1: TypeCreator): TypeTag[T] =
+ tpec1(mirror1) match {
+ case ByteTpe => TypeTag.Byte.asInstanceOf[TypeTag[T]]
+ case ShortTpe => TypeTag.Short.asInstanceOf[TypeTag[T]]
+ case CharTpe => TypeTag.Char.asInstanceOf[TypeTag[T]]
+ case IntTpe => TypeTag.Int.asInstanceOf[TypeTag[T]]
+ case LongTpe => TypeTag.Long.asInstanceOf[TypeTag[T]]
+ case FloatTpe => TypeTag.Float.asInstanceOf[TypeTag[T]]
+ case DoubleTpe => TypeTag.Double.asInstanceOf[TypeTag[T]]
+ case BooleanTpe => TypeTag.Boolean.asInstanceOf[TypeTag[T]]
+ case UnitTpe => TypeTag.Unit.asInstanceOf[TypeTag[T]]
+ case AnyTpe => TypeTag.Any.asInstanceOf[TypeTag[T]]
+ case ObjectTpe => TypeTag.Object.asInstanceOf[TypeTag[T]]
+ case NothingTpe => TypeTag.Nothing.asInstanceOf[TypeTag[T]]
+ case NullTpe => TypeTag.Null.asInstanceOf[TypeTag[T]]
+ case StringTpe => TypeTag.String.asInstanceOf[TypeTag[T]]
+ case _ => new TypeTagImpl[T](mirror1.asInstanceOf[Mirror], tpec1)
+ }
+
+ def unapply[T](ttag: TypeTag[T]): Option[Type] = Some(ttag.tpe)
+ }
+
+ private class TypeTagImpl[T](mirror: Mirror, tpec: TypeCreator) extends AbsTypeTagImpl[T](mirror, tpec) with TypeTag[T] {
+ override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = {
+ val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]]
+ otherMirror.universe.TypeTag[T](otherMirror1, tpec)
+ }
+ }
+
+ private class PredefTypeTag[T](_tpe: Type, copyIn: Universe => Universe # TypeTag[T]) extends TypeTagImpl[T](rootMirror, null) {
+ override lazy val tpe: Type = _tpe
+ override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] =
+ copyIn(otherMirror.universe).asInstanceOf[U # TypeTag[T]]
+ private def readResolve() = copyIn(self)
+ }
+
+ // incantations
+ def typeTag[T](implicit ttag: TypeTag[T]) = ttag
+
+ // big thanks to Viktor Klang for this brilliant idea!
+ def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
+}
diff --git a/src/library/scala/reflect/api/Types.scala b/src/library/scala/reflect/base/Types.scala
index 3d42242641..6106e3fde7 100755..100644
--- a/src/library/scala/reflect/api/Types.scala
+++ b/src/library/scala/reflect/base/Types.scala
@@ -1,203 +1,36 @@
package scala.reflect
-package api
+package base
trait Types { self: Universe =>
- /** This class declares operations that are visible in a Type.
- */
- abstract class AbsType {
+ /** The base API that all types support */
+ abstract class TypeBase {
+
/** The type symbol associated with the type, or `NoSymbol` for types
* that do not refer to a type symbol.
*/
def typeSymbol: Symbol
-
- /** The defined or declared members with name `name` in this type;
- * an OverloadedSymbol if several exist, NoSymbol if none exist.
- * Alternatives of overloaded symbol appear in the order they are declared.
- */
- def declaration(name: Name): Symbol
-
- /** The collection of declarations in this type
- */
- def declarations: Iterable[Symbol]
-
- /** The member with given name, either directly declared or inherited,
- * an OverloadedSymbol if several exist, NoSymbol if none exist.
- */
- def member(name: Name): Symbol
-
- /** The non-private member with given name, either directly declared or inherited,
- * an OverloadedSymbol if several exist, NoSymbol if none exist.
- */
- def nonPrivateMember(name: Name): Symbol
-
- /** An iterable containing all members of this type (directly declared or inherited)
- * Members appear in the linearization order of their owners.
- * Members with the same owner appear in reverse order of their declarations.
- */
- def members: Iterable[Symbol]
-
- /** An iterable containing all non-private members of this type (directly declared or inherited)
- * Members appear in the linearization order of their owners.
- * Members with the same owner appear in reverse order of their declarations.
- */
- def nonPrivateMembers: Iterable[Symbol]
-
- /** Substitute types in `to` for corresponding occurrences of references to
- * symbols `from` in this type.
- */
- def substituteTypes(from: List[Symbol], to: List[Type]): Type
-
- /** If this is a parameterized types, the type arguments.
- * Otherwise the empty list
- */
- def typeArguments: List[Type]
-
- /** For a (potentially wrapped) poly type, its type parameters,
- * the empty list for all other types */
- def typeParams: List[Symbol]
-
- /** Is this type a type constructor that is missing its type arguments?
- */
- def isHigherKinded: Boolean // !!! This should be called "isTypeConstructor", no?
-
- /** Returns the corresponding type constructor (e.g. List for List[T] or List[String])
- */
- def typeConstructor: Type
-
- /** Does this type refer to spliceable types or is a spliceable type?
- */
- def isConcrete: Boolean
-
- /** Is this type an abstract type that needs to be resolved?
- */
- def isSpliceable: Boolean
-
- /**
- * Expands type aliases and converts higher-kinded TypeRefs to PolyTypes.
- * Functions on types are also implemented as PolyTypes.
- *
- * Example: (in the below, <List> is the type constructor of List)
- * TypeRef(pre, <List>, List()) is replaced by
- * PolyType(X, TypeRef(pre, <List>, List(X)))
- */
- def normalize: Type // !!! Alternative name? "normalize" is used to mean too many things.
-
- /** Does this type conform to given type argument `that`? */
- def <:< (that: Type): Boolean
-
- /** Is this type equivalent to given type argument `that`? */
- def =:= (that: Type): Boolean
-
- /** The list of all base classes of this type (including its own typeSymbol)
- * in reverse linearization order, starting with the class itself and ending
- * in class Any.
- */
- def baseClasses: List[Symbol] // !!! Alternative name, perhaps linearization?
-
- /** The least type instance of given class which is a supertype
- * of this type. Example:
- * {{{
- * class D[T]
- * class C extends p.D[Int]
- * ThisType(C).baseType(D) = p.D[Int]
- * }}}
- */
- def baseType(clazz: Symbol): Type
-
- /** This type as seen from prefix `pre` and class `clazz`. This means:
- * Replace all thistypes of `clazz` or one of its subclasses
- * by `pre` and instantiate all parameters by arguments of `pre`.
- * Proceed analogously for thistypes referring to outer classes.
- *
- * Example:
- * {{{
- * class D[T] { def m: T }
- * class C extends p.D[Int]
- * T.asSeenFrom(ThisType(C), D) (where D is owner of m)
- * = Int
- * }}}
- */
- def asSeenFrom(pre: Type, clazz: Symbol): Type
-
- /** The erased type corresponding to this type after
- * all transformations from Scala to Java have been performed.
- */
- def erasure: Type // !!! "erasedType", compare with "widen" (so "erase") or "underlying" (so "erased")
- // why not name it "erasure"?
-
- /** Apply `f` to each part of this type, returning
- * a new type. children get mapped before their parents */
- def map(f: Type => Type): Type
-
- /** Apply `f` to each part of this type, for side effects only */
- def foreach(f: Type => Unit)
-
- /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`,
- * or None if none exists.
- */
- def find(p: Type => Boolean): Option[Type]
-
- /** Is there part of this type which satisfies predicate `p`? */
- def exists(p: Type => Boolean): Boolean
-
- /** Does this type contain a reference to given symbol? */
- def contains(sym: Symbol): Boolean
-
- /** If this is a compound type, the list of its parent types;
- * otherwise the empty list
- */
- def parents: List[Type]
-
- /** If this is a singleton type, returns the type underlying it;
- * otherwise returns this type itself.
- */
- def underlying: Type
-
- /** If this is a singleton type, widen it to its nearest underlying non-singleton
- * base type by applying one or more `underlying` dereferences.
- * If this is not a singleton type, returns this type itself.
- *
- * Example:
- *
- * class Outer { class C ; val x: C }
- * val o: Outer
- * <o.x.type>.widen = o.C
- */
- def widen: Type
-
- /** The kind of this type; used for debugging */
- def kind: String
}
- /** An object representing an unknown type, used during type inference.
- * If you see WildcardType outside of inference it is almost certainly a bug.
+ /** The type of Scala types, and also Scala type signatures.
+ * (No difference is internally made between the two).
*/
- val WildcardType: Type
+ type Type >: Null <: TypeBase
- /** BoundedWildcardTypes, used only during type inference, are created in
- * two places that I can find:
- *
- * 1. If the expected type of an expression is an existential type,
- * its hidden symbols are replaced with bounded wildcards.
- * 2. When an implicit conversion is being sought based in part on
- * the name of a method in the converted type, a HasMethodMatching
- * type is created: a MethodType with parameters typed as
- * BoundedWildcardTypes.
+ /** A tag that preserves the identity of the `Type` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
*/
- type BoundedWildcardType >: Null <: Type
+ implicit val TypeTagg: ClassTag[Type] // [Eugene++] rename!
- val BoundedWildcardType: BoundedWildcardTypeExtractor
-
- abstract class BoundedWildcardTypeExtractor {
- def apply(bounds: TypeBounds): BoundedWildcardType
- def unapply(tpe: BoundedWildcardType): Option[TypeBounds]
- }
+ /** This constant is used as a special value that indicates that no meaningful type exists.
+ */
+ val NoType: Type
- /** The type of Scala types, and also Scala type signatures.
- * (No difference is internally made between the two).
+ /** This constant is used as a special value denoting the empty prefix in a path dependent type.
+ * For instance `x.type` is represented as `SingleType(NoPrefix, <x>)`, where `<x>` stands for
+ * the symbol for `x`.
*/
- type Type >: Null <: AbsType
+ val NoPrefix: Type
/** The type of Scala singleton types, i.e. types that are inhabited
* by only one nun-null value. These include types of the forms
@@ -210,15 +43,10 @@ trait Types { self: Universe =>
*/
type SingletonType >: Null <: Type
- /** This constant is used as a special value that indicates that no meaningful type exists.
- */
- val NoType: Type
-
- /** This constant is used as a special value denoting the empty prefix in a path dependent type.
- * For instance `x.type` is represented as `SingleType(NoPrefix, <x>)`, where `<x>` stands for
- * the symbol for `x`.
+ /** A tag that preserves the identity of the `SingletonType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
*/
- val NoPrefix: Type
+ implicit val SingletonTypeTag: ClassTag[SingletonType]
/** The `ThisType` type describes types of the form on the left with the
* correspnding ThisType representations to the right.
@@ -226,7 +54,12 @@ trait Types { self: Universe =>
* C.this.type ThisType(C)
* }}}
*/
- type ThisType <: SingletonType
+ type ThisType >: Null <: AnyRef with SingletonType
+
+ /** A tag that preserves the identity of the `ThisType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ThisTypeTag: ClassTag[ThisType]
/** The constructor/deconstructor for `ThisType` instances. */
val ThisType: ThisTypeExtractor
@@ -235,36 +68,10 @@ trait Types { self: Universe =>
* where `sym` is the class prefix of the this type.
*/
abstract class ThisTypeExtractor {
- def apply(sym: Symbol): Type
+ def apply(sym: Symbol): Type // not ThisTypebecause of implementation details
def unapply(tpe: ThisType): Option[Symbol]
}
- /** The `TypeRef` type describes types of any of the forms on the left,
- * with their TypeRef representations to the right.
- * {{{
- * T # C[T_1, ..., T_n] TypeRef(T, C, List(T_1, ..., T_n))
- * p.C[T_1, ..., T_n] TypeRef(p.type, C, List(T_1, ..., T_n))
- * C[T_1, ..., T_n] TypeRef(NoPrefix, C, List(T_1, ..., T_n))
- * T # C TypeRef(T, C, Nil)
- * p.C TypeRef(p.type, C, Nil)
- * C TypeRef(NoPrefix, C, Nil)
- * }}}
- */
- type TypeRef <: Type
-
- /** The constructor/deconstructor for `TypeRef` instances. */
- val TypeRef: TypeRefExtractor
-
- /** An extractor class to create and pattern match with syntax `TypeRef(pre, sym, args)`
- * Here, `pre` is the prefix of the type reference, `sym` is the symbol
- * referred to by the type reference, and `args` is a possible empty list of
- * type argumenrts.
- */
- abstract class TypeRefExtractor {
- def apply(pre: Type, sym: Symbol, args: List[Type]): Type
- def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])]
- }
-
/** The `SingleType` type describes types of any of the forms on the left,
* with their TypeRef representations to the right.
* {{{
@@ -273,7 +80,12 @@ trait Types { self: Universe =>
* x.type SingleType(NoPrefix, x)
* }}}
*/
- type SingleType <: SingletonType
+ type SingleType >: Null <: AnyRef with SingletonType
+
+ /** A tag that preserves the identity of the `SingleType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SingleTypeTag: ClassTag[SingleType]
/** The constructor/deconstructor for `SingleType` instances. */
val SingleType: SingleTypeExtractor
@@ -283,7 +95,7 @@ trait Types { self: Universe =>
* referred to by the single-type.
*/
abstract class SingleTypeExtractor {
- def apply(pre: Type, sym: Symbol): Type
+ def apply(pre: Type, sym: Symbol): Type // not SingleTypebecause of implementation details
def unapply(tpe: SingleType): Option[(Type, Symbol)]
}
@@ -296,7 +108,12 @@ trait Types { self: Universe =>
* in the type arising from C.super, the `thistpe` part would be `ThisType(C)`.
* `supertpe` is the type of the super class referred to by the `super`.
*/
- type SuperType <: SingletonType
+ type SuperType >: Null <: AnyRef with SingletonType
+
+ /** A tag that preserves the identity of the `SuperType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val SuperTypeTag: ClassTag[SuperType]
/** The constructor/deconstructor for `SuperType` instances. */
val SuperType: SuperTypeExtractor
@@ -304,7 +121,7 @@ trait Types { self: Universe =>
/** An extractor class to create and pattern match with syntax `SingleType(thistpe, supertpe)`
*/
abstract class SuperTypeExtractor {
- def apply(thistpe: Type, supertpe: Type): Type
+ def apply(thistpe: Type, supertpe: Type): Type // not SuperTypebecause of implementation details
def unapply(tpe: SuperType): Option[(Type, Type)]
}
@@ -315,7 +132,12 @@ trait Types { self: Universe =>
* "abc" ConstantType(Constant("abc"))
* }}}
*/
- type ConstantType <: SingletonType
+ type ConstantType >: Null <: AnyRef with SingletonType
+
+ /** A tag that preserves the identity of the `ConstantType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ConstantTypeTag: ClassTag[ConstantType]
/** The constructor/deconstructor for `ConstantType` instances. */
val ConstantType: ConstantTypeExtractor
@@ -328,9 +150,45 @@ trait Types { self: Universe =>
def unapply(tpe: ConstantType): Option[Constant]
}
+ /** The `TypeRef` type describes types of any of the forms on the left,
+ * with their TypeRef representations to the right.
+ * {{{
+ * T # C[T_1, ..., T_n] TypeRef(T, C, List(T_1, ..., T_n))
+ * p.C[T_1, ..., T_n] TypeRef(p.type, C, List(T_1, ..., T_n))
+ * C[T_1, ..., T_n] TypeRef(NoPrefix, C, List(T_1, ..., T_n))
+ * T # C TypeRef(T, C, Nil)
+ * p.C TypeRef(p.type, C, Nil)
+ * C TypeRef(NoPrefix, C, Nil)
+ * }}}
+ */
+ type TypeRef >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `TypeRef` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeRefTag: ClassTag[TypeRef]
+
+ /** The constructor/deconstructor for `TypeRef` instances. */
+ val TypeRef: TypeRefExtractor
+
+ /** An extractor class to create and pattern match with syntax `TypeRef(pre, sym, args)`
+ * Here, `pre` is the prefix of the type reference, `sym` is the symbol
+ * referred to by the type reference, and `args` is a possible empty list of
+ * type argumenrts.
+ */
+ abstract class TypeRefExtractor {
+ def apply(pre: Type, sym: Symbol, args: List[Type]): Type // not TypeRefbecause of implementation details
+ def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])]
+ }
+
/** A subtype of Type representing refined types as well as `ClassInfo` signatures.
*/
- type CompoundType <: Type
+ type CompoundType >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `CompoundType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val CompoundTypeTag: ClassTag[CompoundType]
/** The `RefinedType` type defines types of any of the forms on the left,
* with their RefinedType representations to the right.
@@ -340,7 +198,12 @@ trait Types { self: Universe =>
* { D_1; ...; D_n} RefinedType(List(AnyRef), Scope(D_1, ..., D_n))
* }}}
*/
- type RefinedType <: CompoundType
+ type RefinedType >: Null <: AnyRef with CompoundType
+
+ /** A tag that preserves the identity of the `RefinedType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val RefinedTypeTag: ClassTag[RefinedType]
/** The constructor/deconstructor for `RefinedType` instances. */
val RefinedType: RefinedTypeExtractor
@@ -359,21 +222,44 @@ trait Types { self: Universe =>
def unapply(tpe: RefinedType): Option[(List[Type], Scope)]
}
- type NullaryMethodType <: Type
- val NullaryMethodType: NullaryMethodTypeExtractor
+ /** The `ClassInfo` type signature is used to define parents and declarations
+ * of classes, traits, and objects. If a class, trait, or object C is declared like this
+ * {{{
+ * C extends P_1 with ... with P_m { D_1; ...; D_n}
+ * }}}
+ * its `ClassInfo` type has the following form:
+ * {{{
+ * ClassInfo(List(P_1, ..., P_m), Scope(D_1, ..., D_n), C)
+ * }}}
+ */
+ type ClassInfoType >: Null <: AnyRef with CompoundType
- type PolyType <: Type
- val PolyType: PolyTypeExtractor
+ /** A tag that preserves the identity of the `ClassInfoType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ClassInfoTypeTag: ClassTag[ClassInfoType]
- type ExistentialType <: Type
- val ExistentialType: ExistentialTypeExtractor
+ /** The constructor/deconstructor for `ClassInfoType` instances. */
+ val ClassInfoType: ClassInfoTypeExtractor
- type AnnotatedType <: Type
- val AnnotatedType: AnnotatedTypeExtractor
+ /** An extractor class to create and pattern match with syntax `ClassInfo(parents, decls, clazz)`
+ * Here, `parents` is the list of parent types of the class, `decls` is the scope
+ * containing all declarations in the class, and `clazz` is the symbol of the class
+ * itself.
+ */
+ abstract class ClassInfoTypeExtractor {
+ def apply(parents: List[Type], decls: Scope, typeSymbol: Symbol): ClassInfoType
+ def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)]
+ }
/** The `MethodType` type signature is used to indicate parameters and result type of a method
*/
- type MethodType <: Type
+ type MethodType >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `MethodType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val MethodTypeTag: ClassTag[MethodType]
/** The constructor/deconstructor for `MethodType` instances. */
val MethodType: MethodTypeExtractor
@@ -397,138 +283,150 @@ trait Types { self: Universe =>
def unapply(tpe: MethodType): Option[(List[Symbol], Type)]
}
- /** The `TypeBounds` type signature is used to indicate lower and upper type bounds
- * of type parameters and abstract types. It is not a first-class type.
- * If an abstract type or type parameter is declared with any of the forms
- * on the left, its type signature is the TypeBounds type on the right.
- * {{{
- * T >: L <: U TypeBounds(L, U)
- * T >: L TypeBounds(L, Any)
- * T <: U TypeBounds(Nothing, U)
- * }}}
+ /** The `NullaryMethodType` type signature is used for parameterless methods
+ * with declarations of the form `def foo: T`
*/
- type TypeBounds <: Type
+ type NullaryMethodType >: Null <: AnyRef with Type
- /** The constructor/deconstructor for `TypeBounds` instances. */
- val TypeBounds: TypeBoundsExtractor
-
- /** An extractor class to create and pattern match with syntax `TypeBound(lower, upper)`
- * Here, `lower` is the lower bound of the `TypeBounds` pair, and `upper` is
- * the upper bound.
+ /** A tag that preserves the identity of the `NullaryMethodType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
*/
- abstract class TypeBoundsExtractor {
- def apply(lo: Type, hi: Type): TypeBounds
- def unapply(tpe: TypeBounds): Option[(Type, Type)]
- }
+ implicit val NullaryMethodTypeTag: ClassTag[NullaryMethodType]
- /** The `ClassInfo` type signature is used to define parents and declarations
- * of classes, traits, and objects. If a class, trait, or object C is declared like this
- * {{{
- * C extends P_1 with ... with P_m { D_1; ...; D_n}
- * }}}
- * its `ClassInfo` type has the following form:
- * {{{
- * ClassInfo(List(P_1, ..., P_m), Scope(D_1, ..., D_n), C)
- * }}}
- */
- type ClassInfoType <: CompoundType
-
- /** The constructor/deconstructor for `ClassInfoType` instances. */
- val ClassInfoType: ClassInfoTypeExtractor
+ /** The constructor/deconstructor for `NullaryMethodType` instances. */
+ val NullaryMethodType: NullaryMethodTypeExtractor
- /** An extractor class to create and pattern match with syntax `ClassInfo(parents, decls, clazz)`
- * Here, `parents` is the list of parent types of the class, `decls` is the scope
- * containing all declarations in the class, and `clazz` is the symbol of the class
- * itself.
+ /** An extractor class to create and pattern match with syntax `NullaryMethodType(resultType)`.
+ * Here, `resultType` is the result type of the parameterless method.
*/
- abstract class ClassInfoTypeExtractor {
- def apply(parents: List[Type], decls: Scope, clazz: Symbol): ClassInfoType
- def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)]
- }
-
abstract class NullaryMethodTypeExtractor {
def apply(resultType: Type): NullaryMethodType
def unapply(tpe: NullaryMethodType): Option[(Type)]
}
+ /** The `PolyType` type signature is used for polymorphic methods
+ * that have at least one type parameter.
+ */
+ type PolyType >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `PolyType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val PolyTypeTag: ClassTag[PolyType]
+
+ /** The constructor/deconstructor for `PolyType` instances. */
+ val PolyType: PolyTypeExtractor
+
+ /** An extractor class to create and pattern match with syntax `PolyType(typeParams, resultType)`.
+ * Here, `typeParams` are the type parameters of the method and `resultType`
+ * is the type signature following the type parameters.
+ */
abstract class PolyTypeExtractor {
def apply(typeParams: List[Symbol], resultType: Type): PolyType
def unapply(tpe: PolyType): Option[(List[Symbol], Type)]
}
+ /** The `ExistentialType` type signature is used for existential types and
+ * wildcard types.
+ */
+ type ExistentialType >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `ExistentialType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val ExistentialTypeTag: ClassTag[ExistentialType]
+
+ /** The constructor/deconstructor for `ExistentialType` instances. */
+ val ExistentialType: ExistentialTypeExtractor
+
+ /** An extractor class to create and pattern match with syntax
+ * `ExistentialType(quantified, underlying)`.
+ * Here, `quantified` are the type variables bound by the existential type and `underlying`
+ * is the type that's existentially quantified.
+ */
abstract class ExistentialTypeExtractor {
def apply(quantified: List[Symbol], underlying: Type): ExistentialType
def unapply(tpe: ExistentialType): Option[(List[Symbol], Type)]
}
+ /** The `AnnotatedType` type signature is used for annotated types of the
+ * for `<type> @<annotation>`.
+ */
+ type AnnotatedType >: Null <: AnyRef with Type
+
+ /** A tag that preserves the identity of the `AnnotatedType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val AnnotatedTypeTag: ClassTag[AnnotatedType]
+
+ /** The constructor/deconstructor for `AnnotatedType` instances. */
+ val AnnotatedType: AnnotatedTypeExtractor
+
+ /** An extractor class to create and pattern match with syntax
+ * `AnnotatedType(annotations, underlying, selfsym)`.
+ * Here, `annotations` are the annotations decorating the underlying type `underlying`.
+ * `selfSym` is a symbol representing the annotated type itself.
+ */
abstract class AnnotatedTypeExtractor {
def apply(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol): AnnotatedType
def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)]
}
- /** The least upper bound of a list of types, as determined by `<:<`. */
- def lub(xs: List[Type]): Type
-
- /** The greatest lower bound of a list of types, as determined by `<:<`. */
- def glb(ts: List[Type]): Type
-
- // Creators ---------------------------------------------------------------
- // too useful and too non-trivial to be left out of public API
- // [Eugene to Paul] needs review!
+ /** The `TypeBounds` type signature is used to indicate lower and upper type bounds
+ * of type parameters and abstract types. It is not a first-class type.
+ * If an abstract type or type parameter is declared with any of the forms
+ * on the left, its type signature is the TypeBounds type on the right.
+ * {{{
+ * T >: L <: U TypeBounds(L, U)
+ * T >: L TypeBounds(L, Any)
+ * T <: U TypeBounds(Nothing, U)
+ * }}}
+ */
+ type TypeBounds >: Null <: AnyRef with Type
- /** The canonical creator for single-types */
- def singleType(pre: Type, sym: Symbol): Type
+ /** A tag that preserves the identity of the `TypeBounds` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
+ */
+ implicit val TypeBoundsTag: ClassTag[TypeBounds]
- /** the canonical creator for a refined type with a given scope */
- def refinedType(parents: List[Type], owner: Symbol, decls: Scope, pos: Position): Type
+ /** The constructor/deconstructor for `TypeBounds` instances. */
+ val TypeBounds: TypeBoundsExtractor
- /** The canonical creator for a refined type with an initially empty scope.
+ /** An extractor class to create and pattern match with syntax `TypeBound(lower, upper)`
+ * Here, `lower` is the lower bound of the `TypeBounds` pair, and `upper` is
+ * the upper bound.
*/
- def refinedType(parents: List[Type], owner: Symbol): Type
+ abstract class TypeBoundsExtractor {
+ def apply(lo: Type, hi: Type): TypeBounds
+ def unapply(tpe: TypeBounds): Option[(Type, Type)]
+ }
- /** The canonical creator for typerefs
+ /** An object representing an unknown type, used during type inference.
+ * If you see WildcardType outside of inference it is almost certainly a bug.
*/
- def typeRef(pre: Type, sym: Symbol, args: List[Type]): Type
-
- /** A creator for intersection type where intersections of a single type are
- * replaced by the type itself. */
- def intersectionType(tps: List[Type]): Type
+ val WildcardType: Type
- /** A creator for intersection type where intersections of a single type are
- * replaced by the type itself, and repeated parent classes are merged.
+ /** BoundedWildcardTypes, used only during type inference, are created in
+ * two places that I can find:
*
- * !!! Repeated parent classes are not merged - is this a bug in the
- * comment or in the code?
+ * 1. If the expected type of an expression is an existential type,
+ * its hidden symbols are replaced with bounded wildcards.
+ * 2. When an implicit conversion is being sought based in part on
+ * the name of a method in the converted type, a HasMethodMatching
+ * type is created: a MethodType with parameters typed as
+ * BoundedWildcardTypes.
*/
- def intersectionType(tps: List[Type], owner: Symbol): Type
+ type BoundedWildcardType >: Null <: AnyRef with Type
- /** A creator for type applications */
- def appliedType(tycon: Type, args: List[Type]): Type
-
- /** A creator for type parameterizations that strips empty type parameter lists.
- * Use this factory method to indicate the type has kind * (it's a polymorphic value)
- * until we start tracking explicit kinds equivalent to typeFun (except that the latter requires tparams nonEmpty).
+ /** A tag that preserves the identity of the `BoundedWildcardType` abstract type from erasure.
+ * Can be used for pattern matching, instance tests, serialization and likes.
*/
- def polyType(tparams: List[Symbol], tpe: Type): Type
+ implicit val BoundedWildcardTypeTag: ClassTag[BoundedWildcardType]
- /** A creator for existential types. This generates:
- *
- * {{{
- * tpe1 where { tparams }
- * }}}
- *
- * where `tpe1` is the result of extrapolating `tpe` with regard to `tparams`.
- * Extrapolating means that type variables in `tparams` occurring
- * in covariant positions are replaced by upper bounds, (minus any
- * SingletonClass markers), type variables in `tparams` occurring in
- * contravariant positions are replaced by upper bounds, provided the
- * resulting type is legal with regard to stability, and does not contain
- * any type variable in `tparams`.
- *
- * The abstraction drops all type parameters that are not directly or
- * indirectly referenced by type `tpe1`. If there are no remaining type
- * parameters, simply returns result type `tpe`.
- */
- def existentialAbstraction(tparams: List[Symbol], tpe0: Type): Type
-}
+ val BoundedWildcardType: BoundedWildcardTypeExtractor
+ abstract class BoundedWildcardTypeExtractor {
+ def apply(bounds: TypeBounds): BoundedWildcardType
+ def unapply(tpe: BoundedWildcardType): Option[TypeBounds]
+ }
+}
diff --git a/src/library/scala/reflect/base/Universe.scala b/src/library/scala/reflect/base/Universe.scala
new file mode 100644
index 0000000000..93ddcb9f55
--- /dev/null
+++ b/src/library/scala/reflect/base/Universe.scala
@@ -0,0 +1,18 @@
+package scala.reflect
+package base
+
+abstract class Universe extends Symbols
+ with Types
+ with FlagSets
+ with Scopes
+ with Names
+ with Trees
+ with Constants
+ with AnnotationInfos
+ with Positions
+ with TypeTags
+ with TagInterop
+ with StandardDefinitions
+ with StandardNames
+ with BuildUtils
+ with Mirrors \ No newline at end of file
diff --git a/src/library/scala/reflect/compat.scala b/src/library/scala/reflect/compat.scala
new file mode 100644
index 0000000000..fc0e5fbf9c
--- /dev/null
+++ b/src/library/scala/reflect/compat.scala
@@ -0,0 +1,33 @@
+// [Eugene++] delete this once we merge with trunk and have a working IDE
+
+package scala.reflect {
+ trait ArrayTag[T]
+ trait ErasureTag[T]
+ trait ConcreteTypeTag[T]
+}
+
+package scala.reflect.api {
+ trait TypeTags {
+ trait TypeTag[T]
+ trait ConcreteTypeTag[T]
+ }
+}
+
+package scala {
+ import scala.reflect.base.{Universe => BaseUniverse}
+
+ trait reflect_compat {
+ lazy val mirror: BaseUniverse = ???
+ }
+}
+
+package scala.reflect {
+ import language.experimental.macros
+ import scala.reflect.base.{Universe => BaseUniverse}
+
+ trait internal_compat {
+ private[scala] def materializeArrayTag[T](u: BaseUniverse): ArrayTag[T] = ???
+ private[scala] def materializeErasureTag[T](u: BaseUniverse): ErasureTag[T] = ???
+ private[scala] def materializeConcreteTypeTag[T](u: BaseUniverse): ConcreteTypeTag[T] = ???
+ }
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/makro/Aliases.scala b/src/library/scala/reflect/makro/Aliases.scala
deleted file mode 100644
index 38b1065a40..0000000000
--- a/src/library/scala/reflect/makro/Aliases.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-package scala.reflect.makro
-
-trait Aliases {
- self: Context =>
-
- /** Aliases of mirror types */
- type Symbol = mirror.Symbol
- type Type = mirror.Type
- type Name = mirror.Name
- type Tree = mirror.Tree
- type Position = mirror.Position
- type Scope = mirror.Scope
- type Modifiers = mirror.Modifiers
- type Expr[+T] = mirror.Expr[T]
- type TypeTag[T] = mirror.TypeTag[T]
-
- /** Creator/extractor objects for Expr and TypeTag values */
- val TypeTag = mirror.TypeTag
- val Expr = mirror.Expr
-
- /** incantations for summoning tags */
- def tag[T](implicit ttag: TypeTag[T]) = ttag
- def typeTag[T](implicit ttag: TypeTag[T]) = ttag
- def concreteTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag
- def concreteTypeTag[T](implicit cttag: ConcreteTypeTag[T]) = cttag
-}
diff --git a/src/library/scala/reflect/makro/Context.scala b/src/library/scala/reflect/makro/Context.scala
deleted file mode 100644
index b8fb0dcce5..0000000000
--- a/src/library/scala/reflect/makro/Context.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package scala.reflect.makro
-
-import language.experimental.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.makro (and probably reside in scala-compiler.jar)
-
-trait Context extends Aliases
- with CapturedVariables
- with Enclosures
- with Infrastructure
- with Names
- with Reifiers
- with FrontEnds
- with Settings
- with Symbols
- with Typers
- with Util {
-
- /** The mirror that corresponds to the compile-time universe */
- val mirror: scala.reflect.api.Universe
-
- /** The type of the prefix tree from which the macro is selected */
- type PrefixType
-
- /** The prefix tree from which the macro is selected */
- val prefix: Expr[PrefixType]
-
- /** Alias to the underlying mirror's reify */
- def reify[T](expr: T): Expr[T] = macro Context.reify[T]
-}
-
-object Context {
- def reify[T](cc: Context{ type PrefixType = Context })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = {
- import cc.mirror._
- import scala.reflect.makro.internal._
- // [Eugene] how do I typecheck this without undergoing this tiresome (and, in general, incorrect) procedure?
- val prefix: Tree = Select(cc.prefix.tree, newTermName("mirror"))
- val prefixTpe = cc.typeCheck(TypeApply(Select(prefix, newTermName("asInstanceOf")), List(SingletonTypeTree(prefix)))).tpe
- prefix setType prefixTpe
- cc.Expr(cc.materializeExpr(prefix, expr.tree))
- }
-}
diff --git a/src/library/scala/reflect/makro/Symbols.scala b/src/library/scala/reflect/makro/Symbols.scala
deleted file mode 100644
index ca1c17534c..0000000000
--- a/src/library/scala/reflect/makro/Symbols.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package scala.reflect.makro
-
-trait Symbols {
- self: Context =>
-
- /** Can this symbol be loaded by a reflective mirror?
- *
- * Scalac relies on `ScalaSignature' annotation to retain symbols across compilation runs.
- * Such annotations (also called "pickles") are applied on top-level classes and include information
- * about all symbols reachable from the annotee. However, local symbols (e.g. classes or definitions local to a block)
- * are typically unreachable and information about them gets lost.
- *
- * This method is useful for macro writers who wish to save certain ASTs to be used at runtime.
- * With `isLocatable' it's possible to check whether a tree can be retained as is, or it needs special treatment.
- */
- def isLocatable(sym: Symbol): Boolean
-
- /** Is this symbol static (i.e. with no outer instance)?
- * Q: When exactly is a sym marked as STATIC?
- * A: If it's a member of a toplevel object, or of an object contained in a toplevel object, or any number of levels deep.
- * http://groups.google.com/group/scala-internals/browse_thread/thread/d385bcd60b08faf6
- */
- def isStatic(sym: Symbol): Boolean
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/makro/internal/Utils.scala b/src/library/scala/reflect/makro/internal/Utils.scala
deleted file mode 100644
index 3af58e1c88..0000000000
--- a/src/library/scala/reflect/makro/internal/Utils.scala
+++ /dev/null
@@ -1,146 +0,0 @@
-package scala.reflect.makro
-
-import scala.reflect.api.Universe
-import language.implicitConversions
-import language.experimental.macros
-
-/** This package is required by the compiler and <b>should not be used in client code</b>. */
-package object internal {
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeArrayTag[T](u: Universe): ArrayTag[T] = macro materializeArrayTag_impl[T]
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeArrayTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe]): c.Expr[ArrayTag[T]] =
- c.Expr[Nothing](c.materializeArrayTag(u.tree, implicitly[c.TypeTag[T]].tpe))(c.TypeTag.Nothing)
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeErasureTag[T](u: Universe): ErasureTag[T] = macro materializeErasureTag_impl[T]
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeErasureTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe]): c.Expr[ErasureTag[T]] =
- c.Expr[Nothing](c.materializeErasureTag(u.tree, implicitly[c.TypeTag[T]].tpe, concrete = false))(c.TypeTag.Nothing)
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeClassTag[T](u: Universe): ClassTag[T] = macro materializeClassTag_impl[T]
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeClassTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe]): c.Expr[ClassTag[T]] =
- c.Expr[Nothing](c.materializeClassTag(u.tree, implicitly[c.TypeTag[T]].tpe))(c.TypeTag.Nothing)
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeTypeTag[T](u: Universe): u.TypeTag[T] = macro materializeTypeTag_impl[T]
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeTypeTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe]): c.Expr[u.value.TypeTag[T]] =
- c.Expr[Nothing](c.materializeTypeTag(u.tree, implicitly[c.TypeTag[T]].tpe, concrete = false))(c.TypeTag.Nothing)
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeConcreteTypeTag[T](u: Universe): u.ConcreteTypeTag[T] = macro materializeConcreteTypeTag_impl[T]
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- def materializeConcreteTypeTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe]): c.Expr[u.value.ConcreteTypeTag[T]] =
- c.Expr[Nothing](c.materializeTypeTag(u.tree, implicitly[c.TypeTag[T]].tpe, concrete = true))(c.TypeTag.Nothing)
-
- /** This method is required by the compiler and <b>should not be used in client code</b>. */
- private[scala] implicit def context2utils(c0: Context) : Utils { val c: c0.type } = new { val c: c0.type = c0 } with Utils
-}
-
-package internal {
- private[scala] abstract class Utils {
- val c: Context
-
- import c.mirror._
- import definitions._
-
- val coreTags = Map(
- ByteClass.asType -> newTermName("Byte"),
- ShortClass.asType -> newTermName("Short"),
- CharClass.asType -> newTermName("Char"),
- IntClass.asType -> newTermName("Int"),
- LongClass.asType -> newTermName("Long"),
- FloatClass.asType -> newTermName("Float"),
- DoubleClass.asType -> newTermName("Double"),
- BooleanClass.asType -> newTermName("Boolean"),
- UnitClass.asType -> newTermName("Unit"),
- AnyClass.asType -> newTermName("Any"),
- ObjectClass.asType -> newTermName("Object"),
- AnyValClass.asType -> newTermName("AnyVal"),
- AnyRefClass.asType -> newTermName("AnyRef"),
- NothingClass.asType -> newTermName("Nothing"),
- NullClass.asType -> newTermName("Null"),
- StringClass.asType -> newTermName("String"))
-
- // todo. the following two methods won't be necessary once we implement implicit macro generators for tags
-
- def materializeArrayTag(prefix: Tree, tpe: Type): Tree =
- materializeClassTag(prefix, tpe)
-
- def materializeErasureTag(prefix: Tree, tpe: Type, concrete: Boolean): Tree =
- if (concrete) materializeClassTag(prefix, tpe) else materializeTypeTag(prefix, tpe, concrete = false)
-
- def materializeClassTag(prefix: Tree, tpe: Type): Tree =
- materializeTag(prefix, tpe, ClassTagModule, {
- val erasure = c.reifyErasure(tpe, concrete = true)
- val factory = TypeApply(Select(Ident(ClassTagModule), "apply"), List(TypeTree(tpe)))
- Apply(factory, List(erasure))
- })
-
- def materializeTypeTag(prefix: Tree, tpe: Type, concrete: Boolean): Tree = {
- val tagModule = if (concrete) ConcreteTypeTagModule else TypeTagModule
- materializeTag(prefix, tpe, tagModule, c.reifyType(prefix, tpe, dontSpliceAtTopLevel = true, concrete = concrete))
- }
-
- private def materializeTag(prefix: Tree, tpe: Type, tagModule: Symbol, materializer: => Tree): Tree = {
- val result =
- tpe match {
- case coreTpe if coreTags contains coreTpe =>
- val ref = if (tagModule.owner.isPackageClass) Ident(tagModule) else Select(prefix, tagModule.name)
- Select(ref, coreTags(coreTpe))
- case _ =>
- val manifestInScope = nonSyntheticManifestInScope(tpe)
- if (manifestInScope.isEmpty) translatingReificationErrors(materializer)
- else gen.mkMethodCall(staticModule("scala.reflect.package"), newTermName("manifestToConcreteTypeTag"), List(tpe), List(manifestInScope))
- }
- try c.typeCheck(result)
- catch { case terr @ c.TypeError(pos, msg) => failTag(terr) }
- }
-
- private def nonSyntheticManifestInScope(tpe: Type) = {
- val ManifestClass = staticClass("scala.reflect.Manifest")
- val ManifestModule = staticModule("scala.reflect.Manifest")
- val manifest = c.inferImplicitValue(appliedType(ManifestClass.asTypeConstructor, List(tpe)))
- val notOk = manifest.isEmpty || (manifest exists (sub => sub.symbol != null && (sub.symbol == ManifestModule || sub.symbol.owner == ManifestModule)))
- if (notOk) EmptyTree else manifest
- }
-
- def materializeExpr(prefix: Tree, expr: Tree): Tree = {
- val result = translatingReificationErrors(c.reifyTree(prefix, expr))
- try c.typeCheck(result)
- catch { case terr @ c.TypeError(pos, msg) => failExpr(terr) }
- }
-
- private def translatingReificationErrors(materializer: => Tree): Tree = {
- try materializer
- catch {
- case ReificationError(pos, msg) =>
- c.error(pos.asInstanceOf[c.Position], msg) // this cast is a very small price for the sanity of exception handling
- EmptyTree
- case UnexpectedReificationError(pos, err, cause) if cause != null =>
- throw cause
- }
- }
-
- private def failTag(reason: Any): Nothing = {
- val Apply(TypeApply(fun, List(tpeTree)), _) = c.macroApplication
- val tpe = tpeTree.tpe
- val PolyType(_, MethodType(_, tagTpe)) = fun.tpe
- val tagModule = tagTpe.typeSymbol.companionSymbol
- if (c.compilerSettings.contains("-Xlog-implicits"))
- c.echo(c.enclosingPosition, "cannot materialize " + tagModule.name + "[" + tpe + "] because:\n" + reason)
- c.abort(c.enclosingPosition, "No %s available for %s".format(tagModule.name, tpe))
- }
-
- private def failExpr(reason: Any): Nothing =
- c.abort(c.enclosingPosition, "Cannot materialize Expr because:\n" + reason)
- }
-}
diff --git a/src/library/scala/reflect/makro/internal/macroImpl.scala b/src/library/scala/reflect/makro/internal/macroImpl.scala
index 9cf4d23072..0dfa8d1654 100644
--- a/src/library/scala/reflect/makro/internal/macroImpl.scala
+++ b/src/library/scala/reflect/makro/internal/macroImpl.scala
@@ -1,5 +1,18 @@
package scala.reflect.makro
package internal
-/** This type is required by the compiler and <b>should not be used in client code</b>. */
-class macroImpl(val referenceToMacroImpl: Any) extends annotation.StaticAnnotation
+/** Links macro definitions with their implementation.
+ * This is necessary to preserve macro def -> macro impl links between compilation runs.
+ *
+ * More precisely, after typechecking right-hand side of a macro def
+ * `typedMacroBody` slaps `macroImpl` annotation onto the macro def
+ * with the result of typechecking as a sole parameter.
+ *
+ * As an unfortunate consequence, this annotation must be defined in scala-library.jar,
+ * because anyone (even those programmers who compile their programs with only scala-library on classpath)
+ * must be able to define macros.
+ *
+ * To lessen the weirdness we define this annotation as `private[scala]`.
+ * It will not prevent pickling, but it will prevent application developers (and scaladocs) from seeing the annotation.
+ */
+private[scala] class macroImpl(val referenceToMacroImpl: Any) extends annotation.StaticAnnotation
diff --git a/src/library/scala/reflect/makro/internal/package.scala b/src/library/scala/reflect/makro/internal/package.scala
new file mode 100644
index 0000000000..d31a0f0d14
--- /dev/null
+++ b/src/library/scala/reflect/makro/internal/package.scala
@@ -0,0 +1,16 @@
+package scala.reflect
+package makro
+
+import language.experimental.macros
+import scala.reflect.base.{Universe => BaseUniverse}
+
+// anchors for materialization macros emitted during tag materialization in Implicits.scala
+// implementation is magically hardwired into `scala.reflect.reify.Taggers`
+//
+// todo. once we have implicit macros for tag generation, we can remove these anchors
+// [Eugene++] how do I hide this from scaladoc?
+package object internal extends scala.reflect.internal_compat {
+ private[scala] def materializeClassTag[T](u: BaseUniverse): ClassTag[T] = macro ???
+ private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.AbsTypeTag[T] = macro ???
+ private[scala] def materializeTypeTag[T](u: BaseUniverse): u.TypeTag[T] = macro ???
+}
diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala
index 38a144cd49..0ee58df2cd 100644
--- a/src/library/scala/reflect/package.scala
+++ b/src/library/scala/reflect/package.scala
@@ -1,42 +1,17 @@
package scala
-package object reflect {
+package object reflect extends reflect_compat {
- import ReflectionUtils._
- import scala.compat.Platform.EOL
+ lazy val basis: base.Universe = new base.Base
- // !!! This was a val; we can't throw exceptions that aggressively without breaking
- // non-standard environments, e.g. google app engine. I made it a lazy val, but
- // I think it would be better yet to throw the exception somewhere else - not during
- // initialization, but in response to a doomed attempt to utilize it.
+ def classTag[T](implicit ctag: ClassTag[T]) = ctag
+ // typeTag incantation is defined inside scala.reflect.basis and scala.reflect.runtime.universe
- // todo. default mirror (a static object) might become a source for memory leaks (because it holds a strong reference to a classloader)!
- lazy val mirror: api.Mirror =
- try mkMirror(defaultReflectionClassLoader)
- catch {
- case ex: UnsupportedOperationException =>
- new DummyMirror(defaultReflectionClassLoader)
- }
+ // ClassTag class is defined in ClassTag.scala
+ type TypeTag[T] = scala.reflect.basis.TypeTag[T]
- private[scala] def mirrorDiagnostics(cl: ClassLoader): String = """
- |
- | This error has happened because `scala.reflect.runtime.package` located in
- | scala-compiler.jar cannot be loaded. Classloader you are using is:
- | %s.
- |
- | For the instructions for some of the situations that might be relevant
- | visit our knowledge base at https://gist.github.com/2391081.
- """.stripMargin('|').format(show(cl))
-
- def mkMirror(classLoader: ClassLoader): api.Mirror = {
- val coreClassLoader = getClass.getClassLoader
- val instance = invokeFactoryOpt(coreClassLoader, "scala.reflect.runtime.package", "mkMirror", classLoader)
- instance match {
- case Some(x: api.Mirror) => x
- case Some(_) => throw new UnsupportedOperationException("Available scala reflection implementation is incompatible with this interface." + mirrorDiagnostics(coreClassLoader))
- case None => throw new UnsupportedOperationException("Scala reflection not available on this platform." + mirrorDiagnostics(coreClassLoader))
- }
- }
+ // ClassTag object is defined in ClassTag.scala
+ lazy val TypeTag = scala.reflect.basis.TypeTag
@deprecated("Use `@scala.beans.BeanDescription` instead", "2.10.0")
type BeanDescription = scala.beans.BeanDescription
@@ -52,19 +27,4 @@ package object reflect {
type BooleanBeanProperty = scala.beans.BooleanBeanProperty
@deprecated("Use `@scala.beans.ScalaBeanInfo` instead", "2.10.0")
type ScalaBeanInfo = scala.beans.ScalaBeanInfo
-
- // ArrayTag trait is defined separately from the mirror
- // ErasureTag trait is defined separately from the mirror
- // ConcreteErasureTag trait is defined separately from the mirror
- // ClassTag class is defined separately from the mirror
- type TypeTag[T] = scala.reflect.mirror.TypeTag[T]
- type ConcreteTypeTag[T] = scala.reflect.mirror.ConcreteTypeTag[T]
-
- // ClassTag object is defined separately from the mirror
- lazy val TypeTag = scala.reflect.mirror.TypeTag
- lazy val ConcreteTypeTag = scala.reflect.mirror.ConcreteTypeTag
-
- def arrayTagToClassManifest[T](tag: ArrayTag[T]): ClassManifest[T] = TagInterop.arrayTagToClassManifest[T](tag)
- def concreteTypeTagToManifest[T](tag: ConcreteTypeTag[T]): Manifest[T] = TagInterop.concreteTypeTagToManifest[T](tag)
- def manifestToConcreteTypeTag[T](tag: Manifest[T]): ConcreteTypeTag[T] = TagInterop.manifestToConcreteTypeTag[T](tag)
}
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index 4c5e0e408b..e5f5e9dc5d 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -12,6 +12,7 @@ import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator }
import scala.collection.mutable.WrappedArray
import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: }
import scala.collection.generic.{ Sorted }
+import scala.reflect.{ ClassTag, classTag }
import scala.util.control.ControlThrowable
import scala.xml.{ Node, MetaData }
@@ -59,8 +60,7 @@ object ScalaRunTime {
*/
def arrayElementClass(schematic: Any): Class[_] = schematic match {
case cls: Class[_] => cls.getComponentType
- case tag: ClassTag[_] => tag.erasure
- case tag: ArrayTag[_] => tag.newArray(0).getClass.getComponentType
+ case tag: ClassTag[_] => tag.runtimeClass
case _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass))
}
@@ -69,7 +69,7 @@ object ScalaRunTime {
* rewrites expressions like 5.getClass to come here.
*/
def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] =
- classTag[T].erasure.asInstanceOf[Class[T]]
+ classTag[T].runtimeClass.asInstanceOf[Class[T]]
/** Retrieve generic array element */
def array_apply(xs: AnyRef, idx: Int): Any = xs match {
@@ -199,7 +199,7 @@ object ScalaRunTime {
def _toString(x: Product): String =
x.productIterator.mkString(x.productPrefix + "(", ",", ")")
- def _hashCode(x: Product): Int = scala.util.MurmurHash3.productHash(x)
+ def _hashCode(x: Product): Int = scala.util.hashing.MurmurHash3.productHash(x)
/** A helper for case classes. */
def typedProductIterator[T](x: Product): Iterator[T] = {
diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala
index 6a0fca40ca..86508634e3 100644
--- a/src/library/scala/text/Document.scala
+++ b/src/library/scala/text/Document.scala
@@ -88,6 +88,8 @@ abstract class Document {
case (i, b, DocGroup(d)) :: z =>
val fitsFlat = fits(width - k, (i, false, d) :: z)
fmt(k, (i, !fitsFlat, d) :: z)
+ case _ =>
+ ()
}
fmt(0, (0, false, DocGroup(this)) :: Nil)
diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala
index 209cd6c062..2d3f54a95e 100644
--- a/src/library/scala/util/Marshal.scala
+++ b/src/library/scala/util/Marshal.scala
@@ -39,7 +39,7 @@ object Marshal {
try {
// [Eugene] needs review
// previously was: found <:< expected
- found.erasure.asSubclass(expected.erasure)
+ found.runtimeClass.asSubclass(expected.runtimeClass)
in.readObject.asInstanceOf[A]
} catch {
case _: ClassCastException =>
diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala
index 7d98e57741..5f0edf964f 100644
--- a/src/library/scala/util/Sorting.scala
+++ b/src/library/scala/util/Sorting.scala
@@ -8,7 +8,7 @@
package scala.util
-import scala.reflect.ClassTag
+import scala.reflect.{ ClassTag, classTag }
import scala.math.Ordering
/** The Sorting object provides functions that can sort various kinds of
@@ -39,14 +39,14 @@ object Sorting {
/** Sort an array of K where K is Ordered, preserving the existing order
* where the values are equal. */
- def stableSort[K: ArrayTag: Ordering](a: Array[K]) {
+ def stableSort[K: ClassTag: Ordering](a: Array[K]) {
stableSort(a, 0, a.length-1, new Array[K](a.length), Ordering[K].lt _)
}
/** Sorts an array of `K` given an ordering function `f`.
* `f` should return `true` iff its first parameter is strictly less than its second parameter.
*/
- def stableSort[K: ArrayTag](a: Array[K], f: (K, K) => Boolean) {
+ def stableSort[K: ClassTag](a: Array[K], f: (K, K) => Boolean) {
stableSort(a, 0, a.length-1, new Array[K](a.length), f)
}
@@ -57,14 +57,14 @@ object Sorting {
* @param f the comparison function.
* @return the sorted sequence of items.
*/
- def stableSort[K: ArrayTag](a: Seq[K], f: (K, K) => Boolean): Array[K] = {
+ def stableSort[K: ClassTag](a: Seq[K], f: (K, K) => Boolean): Array[K] = {
val ret = a.toArray
stableSort(ret, f)
ret
}
/** Sorts an arbitrary sequence of items that are viewable as ordered. */
- def stableSort[K: ArrayTag: Ordering](a: Seq[K]): Array[K] =
+ def stableSort[K: ClassTag: Ordering](a: Seq[K]): Array[K] =
stableSort(a, Ordering[K].lt _)
/** Stably sorts a sequence of items given an extraction function that will
@@ -74,8 +74,8 @@ object Sorting {
* @param f the comparison function.
* @return the sorted sequence of items.
*/
- def stableSort[K: ArrayTag, M: Ordering](a: Seq[K], f: K => M): Array[K] =
- stableSort(a)(implicitly[ArrayTag[K]], Ordering[M] on f)
+ def stableSort[K: ClassTag, M: Ordering](a: Seq[K], f: K => M): Array[K] =
+ stableSort(a)(implicitly[ClassTag[K]], Ordering[M] on f)
private def sort1[K: Ordering](x: Array[K], off: Int, len: Int) {
val ord = Ordering[K]
@@ -498,7 +498,7 @@ object Sorting {
sort2(off, len)
}
- private def stableSort[K : ArrayTag](a: Array[K], lo: Int, hi: Int, scratch: Array[K], f: (K,K) => Boolean) {
+ private def stableSort[K : ClassTag](a: Array[K], lo: Int, hi: Int, scratch: Array[K], f: (K,K) => Boolean) {
if (lo < hi) {
val mid = (lo+hi) / 2
stableSort(a, lo, mid, scratch, f)
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index 38f4abb20a..2ee053c92b 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -9,6 +9,7 @@
package scala.util.control
import collection.immutable.List
+import reflect.{ ClassTag, classTag }
import java.lang.reflect.InvocationTargetException
import language.implicitConversions
@@ -32,7 +33,7 @@ object Exception {
def mkCatcher[Ex <: Throwable: ClassTag, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] {
private def downcast(x: Throwable): Option[Ex] =
- if (classTag[Ex].erasure.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex])
+ if (classTag[Ex].runtimeClass.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex])
else None
def isDefinedAt(x: Throwable) = downcast(x) exists isDef
diff --git a/src/library/scala/util/hashing/ByteswapHashing.scala b/src/library/scala/util/hashing/ByteswapHashing.scala
new file mode 100644
index 0000000000..fc8a33a486
--- /dev/null
+++ b/src/library/scala/util/hashing/ByteswapHashing.scala
@@ -0,0 +1,35 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.util.hashing
+
+
+
+
+
+
+/** A fast multiplicative hash by Phil Bagwell.
+ */
+final class ByteswapHashing[T] extends Hashing[T] {
+
+ def hash(v: T) = byteswap32(v.##)
+
+}
+
+
+object ByteswapHashing {
+
+ private class Chained[T](h: Hashing[T]) extends Hashing[T] {
+ def hash(v: T) = byteswap32(h.hash(v))
+ }
+
+ /** Composes another `Hashing` with the Byteswap hash.
+ */
+ def chain[T](h: Hashing[T]): Hashing[T] = new Chained(h)
+
+}
diff --git a/src/library/scala/util/hashing/Hashing.scala b/src/library/scala/util/hashing/Hashing.scala
new file mode 100644
index 0000000000..84b549f35e
--- /dev/null
+++ b/src/library/scala/util/hashing/Hashing.scala
@@ -0,0 +1,42 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.util.hashing
+
+/** `Hashing` is a trait whose instances each represent a strategy for hashing
+ * instances of a type.
+ *
+ * `Hashing`'s companion object defines a default hashing strategy for all
+ * objects - it calls their `##` method.
+ *
+ * Note: when using a custom `Hashing`, make sure to use it with the `Equiv`
+ * such that if any two objects are equal, then their hash codes must be equal.
+ *
+ * @since 2.10
+ */
+@annotation.implicitNotFound(msg = "No implicit Hashing defined for ${T}.")
+trait Hashing[T] extends Serializable {
+
+ def hash(x: T): Int
+
+}
+
+
+object Hashing {
+
+ final class Default[T] extends Hashing[T] {
+ def hash(x: T) = x.##
+ }
+
+ implicit def default[T] = new Default[T]
+
+ def fromFunction[T](f: T => Int) = new Hashing[T] {
+ def hash(x: T) = f(x)
+ }
+
+}
diff --git a/src/library/scala/util/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index fbb67116dd..3efd5b5e72 100644
--- a/src/library/scala/util/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -1,27 +1,16 @@
-package scala.util
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2012, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.util.hashing
import java.lang.Integer.{ rotateLeft => rotl }
-/**
- * An implementation of Austin Appleby's MurmurHash 3 algorithm
- * (MurmurHash3_x86_32).
- *
- * An algorithm designed to generate well-distributed non-cryptographic
- * hashes. It is designed to hash data in 32 bit chunks (ints).
- *
- * The mix method needs to be called at each step to update the intermediate
- * hash value. For the last chunk to incorporate into the hash mixLast may
- * be used instead, which is slightly faster. Finally finalizeHash needs to
- * be called to compute the final hash value.
- *
- * This is based on the earlier MurmurHash3 code by Rex Kerr, but the
- * MurmurHash3 algorithm was since changed by its creator Austin Appleby
- * to remedy some weaknesses and improve performance. This represents the
- * latest and supposedly final version of the algortihm (revision 136).
- *
- * @see [[http://code.google.com/p/smhasher]]
- */
-class MurmurHash3 {
+private[hashing] class MurmurHash3 {
/** Mix in a block of data into an intermediate hash value. */
final def mix(hash: Int, data: Int): Int = {
var h = mixLast(hash, data)
@@ -171,8 +160,25 @@ class MurmurHash3 {
}
/**
- * An instance of MurmurHash3 with predefined seeds for various
- * classes. Used by all the scala collections and case classes.
+ * An implementation of Austin Appleby's MurmurHash 3 algorithm
+ * (MurmurHash3_x86_32). This object contains methods that hash
+ * values of various types as well as means to construct `Hashing`
+ * objects.
+ *
+ * This algorithm is designed to generate well-distributed non-cryptographic
+ * hashes. It is designed to hash data in 32 bit chunks (ints).
+ *
+ * The mix method needs to be called at each step to update the intermediate
+ * hash value. For the last chunk to incorporate into the hash mixLast may
+ * be used instead, which is slightly faster. Finally finalizeHash needs to
+ * be called to compute the final hash value.
+ *
+ * This is based on the earlier MurmurHash3 code by Rex Kerr, but the
+ * MurmurHash3 algorithm was since changed by its creator Austin Appleby
+ * to remedy some weaknesses and improve performance. This represents the
+ * latest and supposedly final version of the algortihm (revision 136).
+ *
+ * @see [[http://code.google.com/p/smhasher]]
*/
object MurmurHash3 extends MurmurHash3 {
final val arraySeed = 0x3c074a61
@@ -197,6 +203,32 @@ object MurmurHash3 extends MurmurHash3 {
def mapHash(xs: collection.Map[_, _]): Int = unorderedHash(xs, mapSeed)
def setHash(xs: collection.Set[_]): Int = unorderedHash(xs, setSeed)
+ class ArrayHashing[@specialized T] extends Hashing[Array[T]] {
+ def hash(a: Array[T]) = arrayHash(a)
+ }
+
+ def arrayHashing[@specialized T] = new ArrayHashing[T]
+
+ def bytesHashing = new Hashing[Array[Byte]] {
+ def hash(data: Array[Byte]) = bytesHash(data)
+ }
+
+ def orderedHashing = new Hashing[TraversableOnce[Any]] {
+ def hash(xs: TraversableOnce[Any]) = orderedHash(xs)
+ }
+
+ def productHashing = new Hashing[Product] {
+ def hash(x: Product) = productHash(x)
+ }
+
+ def stringHashing = new Hashing[String] {
+ def hash(x: String) = stringHash(x)
+ }
+
+ def unorderedHashing = new Hashing[TraversableOnce[Any]] {
+ def hash(xs: TraversableOnce[Any]) = unorderedHash(xs)
+ }
+
/** All this trouble and foreach still appears faster.
* Leaving in place in case someone would like to investigate further.
*/
diff --git a/src/library/scala/util/hashing/package.scala b/src/library/scala/util/hashing/package.scala
new file mode 100644
index 0000000000..becfa4911e
--- /dev/null
+++ b/src/library/scala/util/hashing/package.scala
@@ -0,0 +1,35 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.util
+
+
+
+
+
+
+package object hashing {
+
+ /** Fast multiplicative hash with a nice distribution.
+ */
+ def byteswap32(v: Int): Int = {
+ var hc = v * 0x9e3775cd
+ hc = java.lang.Integer.reverseBytes(hc)
+ hc * 0x9e3775cd
+ }
+
+ /** Fast multiplicative hash with a nice distribution
+ * for 64-bit values.
+ */
+ def byteswap64(v: Long): Long = {
+ var hc = v * 0x9e3775cd9e3775cdL
+ hc = java.lang.Long.reverseBytes(hc)
+ hc * 0x9e3775cd9e3775cdL
+ }
+
+}
diff --git a/src/library/scala/xml/Attribute.scala b/src/library/scala/xml/Attribute.scala
index 6b68e97412..4c50b15e53 100644
--- a/src/library/scala/xml/Attribute.scala
+++ b/src/library/scala/xml/Attribute.scala
@@ -61,8 +61,8 @@ abstract trait Attribute extends MetaData {
else copy(next remove key)
def remove(namespace: String, scope: NamespaceBinding, key: String) =
- if (isPrefixed && this.key == key && (scope getURI pre) == namespace) next
- else next.remove(namespace, scope, key)
+ if (this.key == key && (scope getURI pre) == namespace) next
+ else copy(next.remove(namespace, scope, key))
def isPrefixed: Boolean = pre != null
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala
index 17c91fa52c..bae529c85c 100755
--- a/src/library/scala/xml/Utility.scala
+++ b/src/library/scala/xml/Utility.scala
@@ -268,7 +268,7 @@ object Utility extends AnyRef with parsing.TokenTests {
* Returns a hashcode for the given constituents of a node
*/
def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) =
- scala.util.MurmurHash3.orderedHash(label +: attribHashCode +: scpeHash +: children, pre.##)
+ scala.util.hashing.MurmurHash3.orderedHash(label +: attribHashCode +: scpeHash +: children, pre.##)
def appendQuoted(s: String): String = sbToString(appendQuoted(s, _))
diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala
index 86678760be..89c1a9c2ca 100644
--- a/src/partest/scala/tools/partest/CompilerTest.scala
+++ b/src/partest/scala/tools/partest/CompilerTest.scala
@@ -5,7 +5,7 @@
package scala.tools.partest
-import scala.reflect.{mirror => rm}
+import scala.reflect.{basis => rb}
import scala.tools.nsc._
/** For testing compiler internals directly.
@@ -34,7 +34,7 @@ abstract class CompilerTest extends DirectTest {
// Utility functions
class MkType(sym: Symbol) {
- def apply[M](implicit t: rm.TypeTag[M]): Type =
+ def apply[M](implicit t: rb.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
else appliedType(sym, compilerTypeFromTag(t))
}
@@ -50,7 +50,7 @@ abstract class CompilerTest extends DirectTest {
}
class SymsInPackage(pkgName: String) {
- def pkg = getRequiredModule(pkgName)
+ def pkg = rootMirror.getRequiredModule(pkgName)
def classes = allMembers(pkg) filter (_.isClass)
def modules = allMembers(pkg) filter (_.isModule)
def symbols = classes ++ terms filterNot (_ eq NoSymbol)
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
index 67b38d2e24..2f694b3cc8 100644
--- a/src/partest/scala/tools/partest/PartestTask.scala
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -279,6 +279,16 @@ class PartestTask extends Task with CompilationPathProperty {
}
} getOrElse sys.error("Provided classpath does not contain a Scala library.")
+ val scalaReflect = {
+ (classpath.list map { fs => new File(fs) }) find { f =>
+ f.getName match {
+ case "scala-reflect.jar" => true
+ case "reflect" if (f.getParentFile.getName == "classes") => true
+ case _ => false
+ }
+ }
+ } getOrElse sys.error("Provided classpath does not contain a Scala reflection library.")
+
val scalaCompiler = {
(classpath.list map { fs => new File(fs) }) find { f =>
f.getName match {
@@ -342,6 +352,7 @@ class PartestTask extends Task with CompilationPathProperty {
antFileManager.failed = runFailed
antFileManager.CLASSPATH = ClassPath.join(classpath.list: _*)
antFileManager.LATEST_LIB = scalaLibrary.getAbsolutePath
+ antFileManager.LATEST_REFLECT = scalaReflect.getAbsolutePath
antFileManager.LATEST_COMP = scalaCompiler.getAbsolutePath
antFileManager.LATEST_PARTEST = scalaPartest.getAbsolutePath
antFileManager.LATEST_ACTORS = scalaActors.getAbsolutePath
diff --git a/src/partest/scala/tools/partest/SigTest.scala b/src/partest/scala/tools/partest/SigTest.scala
index 999d901d21..1d8728294b 100644
--- a/src/partest/scala/tools/partest/SigTest.scala
+++ b/src/partest/scala/tools/partest/SigTest.scala
@@ -8,6 +8,7 @@ package scala.tools.partest
import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.ILoop
import java.lang.reflect.{ Method => JMethod, Field => JField }
+import scala.reflect.{ClassTag, classTag}
/** Support code for testing signatures.
*/
@@ -21,13 +22,13 @@ trait SigTest {
def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name)
def fields[T: ClassTag](p: JField => Boolean) = {
- val cl = classTag[T].erasure
+ val cl = classTag[T].runtimeClass
val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName)
fs filter p
}
def methods[T: ClassTag](p: JMethod => Boolean) = {
- val cl = classTag[T].erasure
+ val cl = classTag[T].runtimeClass
val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge))
ms filter p
@@ -44,7 +45,7 @@ trait SigTest {
(methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr)
def show[T: ClassTag](name: String = "") = {
- println(classTag[T].erasure.getName)
+ println(classTag[T].runtimeClass.getName)
if (name == "") allGenericStrings[T]() foreach println
else genericStrings[T](name) foreach println
}
diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala
index dc83e4ea66..ee644c5315 100644
--- a/src/partest/scala/tools/partest/nest/AntRunner.scala
+++ b/src/partest/scala/tools/partest/nest/AntRunner.scala
@@ -20,6 +20,7 @@ class AntRunner extends DirectRunner {
var JAVAC_CMD: String = "javac"
var CLASSPATH: String = _
var LATEST_LIB: String = _
+ var LATEST_REFLECT: String = _
var LATEST_COMP: String = _
var LATEST_PARTEST: String = _
var LATEST_ACTORS: String = _
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index b270a6b65a..68e9753575 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -85,6 +85,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = testClassesDir / "library"
latestActorsFile = testClassesDir / "library" / "actors"
latestActMigFile = testClassesDir / "actors-migration"
+ latestReflectFile = testClassesDir / "reflect"
latestCompFile = testClassesDir / "compiler"
latestPartestFile = testClassesDir / "partest"
latestFjbgFile = testParent / "lib" / "fjbg.jar"
@@ -96,6 +97,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = dir / "lib/scala-library.jar"
latestActorsFile = dir / "lib/scala-actors.jar"
latestActMigFile = dir / "lib/scala-actors-migration.jar"
+ latestReflectFile = dir / "lib/scala-reflect.jar"
latestCompFile = dir / "lib/scala-compiler.jar"
latestPartestFile = dir / "lib/scala-partest.jar"
latestFjbgFile = testParent / "lib" / "fjbg.jar"
@@ -107,6 +109,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = prefixFile("build/quick/classes/library")
latestActorsFile = prefixFile("build/quick/classes/library/actors")
latestActMigFile = prefixFile("build/quick/classes/actors-migration")
+ latestReflectFile = prefixFile("build/quick/classes/reflect")
latestCompFile = prefixFile("build/quick/classes/compiler")
latestPartestFile = prefixFile("build/quick/classes/partest")
}
@@ -118,6 +121,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = prefixFileWith(p, "lib/scala-library.jar")
latestActorsFile = prefixFileWith(p, "lib/scala-actors.jar")
latestActMigFile = prefixFileWith(p, "lib/scala-actors-migration.jar")
+ latestReflectFile = prefixFileWith(p, "lib/scala-reflect.jar")
latestCompFile = prefixFileWith(p, "lib/scala-compiler.jar")
latestPartestFile = prefixFileWith(p, "lib/scala-partest.jar")
}
@@ -128,6 +132,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = prefixFile("dists/latest/lib/scala-library.jar")
latestActorsFile = prefixFile("dists/latest/lib/scala-actors.jar")
latestActMigFile = prefixFile("dists/latest/lib/scala-actors-migration.jar")
+ latestReflectFile = prefixFile("dists/latest/lib/scala-reflect.jar")
latestCompFile = prefixFile("dists/latest/lib/scala-compiler.jar")
latestPartestFile = prefixFile("dists/latest/lib/scala-partest.jar")
}
@@ -138,6 +143,7 @@ class ConsoleFileManager extends FileManager {
latestLibFile = prefixFile("build/pack/lib/scala-library.jar")
latestActorsFile = prefixFile("build/pack/lib/scala-actors.jar")
latestActMigFile = prefixFile("build/pack/lib/scala-actors-migration.jar")
+ latestReflectFile = prefixFile("build/pack/lib/scala-reflect.jar")
latestCompFile = prefixFile("build/pack/lib/scala-compiler.jar")
latestPartestFile = prefixFile("build/pack/lib/scala-partest.jar")
}
@@ -151,10 +157,10 @@ class ConsoleFileManager extends FileManager {
names map (x => prefixFile(base + "/" + x).lastModified) reduceLeft (_ max _)
// detect most recent build
- val quickTime = mostRecentOf("build/quick/classes", "compiler/compiler.properties", "library/library.properties")
- val packTime = mostRecentOf("build/pack/lib", "scala-compiler.jar", "scala-library.jar")
- val distTime = mostRecentOf("dists/latest/lib", "scala-compiler.jar", "scala-library.jar")
- val instTime = mostRecentOf("lib", "scala-compiler.jar", "scala-library.jar")
+ val quickTime = mostRecentOf("build/quick/classes", "compiler/compiler.properties", "reflect/reflect.properties", "library/library.properties")
+ val packTime = mostRecentOf("build/pack/lib", "scala-compiler.jar", "scala-reflect.jar", "scala-library.jar")
+ val distTime = mostRecentOf("dists/latest/lib", "scala-compiler.jar", "scala-reflect.jar", "scala-library.jar")
+ val instTime = mostRecentOf("lib", "scala-compiler.jar", "scala-reflect.jar", "scala-library.jar")
val pairs = Map(
(quickTime, () => setupQuick()),
@@ -170,6 +176,7 @@ class ConsoleFileManager extends FileManager {
}
LATEST_LIB = latestLibFile.getAbsolutePath
+ LATEST_REFLECT = latestReflectFile.getAbsolutePath
LATEST_COMP = latestCompFile.getAbsolutePath
LATEST_PARTEST = latestPartestFile.getAbsolutePath
LATEST_ACTORS = latestActorsFile.getAbsolutePath
@@ -177,6 +184,7 @@ class ConsoleFileManager extends FileManager {
}
var LATEST_LIB: String = ""
+ var LATEST_REFLECT: String = ""
var LATEST_COMP: String = ""
var LATEST_PARTEST: String = ""
var LATEST_ACTORS: String = ""
@@ -186,6 +194,7 @@ class ConsoleFileManager extends FileManager {
var latestLibFile: File = _
var latestActorsFile: File = _
var latestActMigFile: File = _
+ var latestReflectFile: File = _
var latestCompFile: File = _
var latestPartestFile: File = _
var latestFjbgFile: File = _
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
index 815c27f567..09896edc55 100644
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala
@@ -58,13 +58,14 @@ trait DirectRunner {
//val consFM = new ConsoleFileManager
//import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
val latestCompFile = new File(fileManager.LATEST_COMP)
+ val latestReflectFile = new File(fileManager.LATEST_REFLECT)
val latestLibFile = new File(fileManager.LATEST_LIB)
val latestPartestFile = new File(fileManager.LATEST_PARTEST)
val latestActorsFile = new File(fileManager.LATEST_ACTORS)
val latestActMigFile = new File(fileManager.LATEST_ACTORS_MIGRATION)
val scalacheckURL = PathSettings.scalaCheck.toURL
val scalaCheckParentClassLoader = ScalaClassLoader.fromURLs(
- scalacheckURL :: (List(latestCompFile, latestLibFile, latestActorsFile, latestActMigFile, latestPartestFile).map(_.toURI.toURL))
+ scalacheckURL :: (List(latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestActMigFile, latestPartestFile).map(_.toURI.toURL))
)
Output.init()
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index cf7160f521..40bfa36b04 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -60,6 +60,7 @@ trait FileManager extends FileUtil {
var CLASSPATH: String
var LATEST_LIB: String
+ var LATEST_REFLECT: String
var LATEST_COMP: String
var LATEST_PARTEST: String
var LATEST_ACTORS: String
diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala
index 6b81b66a39..7fd503e769 100644
--- a/src/partest/scala/tools/partest/nest/NestUI.scala
+++ b/src/partest/scala/tools/partest/nest/NestUI.scala
@@ -84,7 +84,7 @@ object NestUI {
println(" --grep <expr> run all tests whose source file contains <expr>")
println
println(" Other options:")
- println(" --pack pick compiler/library in build/pack, and run all tests")
+ println(" --pack pick compiler/reflect/library in build/pack, and run all tests")
println(" --show-log show log")
println(" --show-diff show diff between log and check file")
println(" --failed run only those tests that failed during the last run")
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index a5d5952ff7..fa75d96b34 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -48,9 +48,9 @@ class ReflectiveRunner {
new ConsoleFileManager
import fileManager.
- { latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile }
+ { latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile }
val files =
- Array(latestCompFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile) map (x => io.File(x))
+ Array(latestCompFile, latestReflectFile, latestLibFile, latestPartestFile, latestFjbgFile, latestScalapFile, latestActorsFile, latestActMigFile) map (x => io.File(x))
val sepUrls = files map (_.toURL)
var sepLoader = new URLClassLoader(sepUrls, null)
diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala
index 14e2dc3df9..7e2f37374b 100644
--- a/src/partest/scala/tools/partest/nest/SBTRunner.scala
+++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala
@@ -13,6 +13,7 @@ object SBTRunner extends DirectRunner {
var JAVAC_CMD: String = "javac"
var CLASSPATH: String = _
var LATEST_LIB: String = _
+ var LATEST_REFLECT: String = _
var LATEST_COMP: String = _
var LATEST_PARTEST: String = _
var LATEST_ACTORS: String = _
@@ -63,6 +64,7 @@ object SBTRunner extends DirectRunner {
}
// Find scala library jar file...
fileManager.LATEST_LIB = findClasspath("scala-library", "scala-library") getOrElse sys.error("No scala-library found! Classpath = " + fileManager.CLASSPATH)
+ fileManager.LATEST_REFLECT = findClasspath("scala-reflect", "scala-reflect") getOrElse sys.error("No scala-reflect found! Classpath = " + fileManager.CLASSPATH)
fileManager.LATEST_COMP = findClasspath("scala-compiler", "scala-compiler") getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH)
fileManager.LATEST_PARTEST = findClasspath("scala-partest", "partest") getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH)
fileManager.LATEST_ACTORS = findClasspath("scala-actors", "actors") getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH)
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 40325c6375..48f78e9ddc 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -53,6 +53,7 @@ class ScalaCheckFileManager(val origmanager: FileManager) extends FileManager {
var CLASSPATH: String = join(origmanager.CLASSPATH, PathSettings.scalaCheck.path)
var LATEST_LIB: String = origmanager.LATEST_LIB
+ var LATEST_REFLECT: String = origmanager.LATEST_REFLECT
var LATEST_COMP: String = origmanager.LATEST_COMP
var LATEST_PARTEST: String = origmanager.LATEST_PARTEST
var LATEST_ACTORS: String = origmanager.LATEST_ACTORS
@@ -323,6 +324,7 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
"-Djava.library.path="+logFile.getParentFile.getAbsolutePath,
"-Dpartest.output="+outDir.getAbsolutePath,
"-Dpartest.lib="+LATEST_LIB,
+ "-Dpartest.reflect="+LATEST_REFLECT,
"-Dpartest.cwd="+outDir.getParent,
"-Dpartest.test-path="+testFullPath,
"-Dpartest.testname="+fileBase,
diff --git a/src/reflect/scala/reflect/api/AnnotationInfos.scala b/src/reflect/scala/reflect/api/AnnotationInfos.scala
new file mode 100644
index 0000000000..d9f35024d9
--- /dev/null
+++ b/src/reflect/scala/reflect/api/AnnotationInfos.scala
@@ -0,0 +1,27 @@
+package scala.reflect
+package api
+
+trait AnnotationInfos extends base.AnnotationInfos { self: Universe =>
+
+ override type AnnotationInfo >: Null <: AnyRef with AnnotationInfoApi
+ trait AnnotationInfoApi {
+ def atp: Type
+ def args: List[Tree]
+ def assocs: List[(Name, ClassfileAnnotArg)]
+ }
+
+ override type LiteralAnnotArg >: Null <: ClassfileAnnotArg with LiteralAnnotArgApi
+ trait LiteralAnnotArgApi {
+ def const: Constant
+ }
+
+ override type ArrayAnnotArg >: Null <: ClassfileAnnotArg with ArrayAnnotArgApi
+ trait ArrayAnnotArgApi {
+ def args: Array[ClassfileAnnotArg]
+ }
+
+ override type NestedAnnotArg >: Null <: ClassfileAnnotArg with NestedAnnotArgApi
+ trait NestedAnnotArgApi {
+ def annInfo: AnnotationInfo
+ }
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/Constants.scala b/src/reflect/scala/reflect/api/Constants.scala
index 42a0fa8a27..7862ab0d25 100755..100644
--- a/src/library/scala/reflect/api/Constants.scala
+++ b/src/reflect/scala/reflect/api/Constants.scala
@@ -6,13 +6,12 @@
package scala.reflect
package api
-import java.lang.Integer.toOctalString
-import annotation.switch
-
-trait Constants {
+trait Constants extends base.Constants {
self: Universe =>
- abstract class AbsConstant {
+ override type Constant >: Null <: AnyRef with ConstantApi
+
+ abstract class ConstantApi {
val value: Any
def tpe: Type
def isNaN: Boolean
@@ -31,13 +30,4 @@ trait Constants {
def convertTo(pt: Type): Constant
}
-
- type Constant <: AbsConstant
-
- val Constant: ConstantExtractor
-
- abstract class ConstantExtractor {
- def apply(const: Any): Constant
- def unapply(arg: Constant): Option[Any]
- }
}
diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/reflect/scala/reflect/api/Exprs.scala
new file mode 100644
index 0000000000..8b2a3b4ea8
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Exprs.scala
@@ -0,0 +1,62 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.reflect
+package api
+
+import scala.reflect.base.TreeCreator
+
+trait Exprs { self: Universe =>
+
+ /** An expression tree tagged with its type */
+ trait Expr[+T] extends Equals with Serializable {
+ val mirror: Mirror
+ def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T]
+
+ def tree: Tree
+ def staticTpe: Type
+ def actualTpe: Type
+
+ def splice: T
+ val value: T
+
+ /** case class accessories */
+ override def canEqual(x: Any) = x.isInstanceOf[Expr[_]]
+ override def equals(x: Any) = x.isInstanceOf[Expr[_]] && this.mirror == x.asInstanceOf[Expr[_]].mirror && this.tree == x.asInstanceOf[Expr[_]].tree
+ override def hashCode = mirror.hashCode * 31 + tree.hashCode
+ override def toString = "Expr["+staticTpe+"]("+tree+")"
+ }
+
+ object Expr {
+ def apply[T: AbsTypeTag](mirror: MirrorOf[self.type], treec: TreeCreator): Expr[T] = new ExprImpl[T](mirror.asInstanceOf[Mirror], treec)
+ def unapply[T](expr: Expr[T]): Option[Tree] = Some(expr.tree)
+ }
+
+ private class ExprImpl[+T: AbsTypeTag](val mirror: Mirror, val treec: TreeCreator) extends Expr[T] {
+ def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T] = {
+ val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]]
+ val tag1 = (implicitly[AbsTypeTag[T]] in otherMirror).asInstanceOf[otherMirror.universe.AbsTypeTag[T]]
+ otherMirror.universe.Expr[T](otherMirror1, treec)(tag1)
+ }
+
+ lazy val tree: Tree = treec[Exprs.this.type](mirror)
+ // [Eugene++] this is important
+ // !!! remove when we have improved type inference for singletons
+ // search for .type] to find other instances
+ lazy val staticTpe: Type = implicitly[AbsTypeTag[T]].tpe
+ def actualTpe: Type = tree.tpe
+
+ def splice: T = throw new UnsupportedOperationException("""
+ |the function you're calling has not been spliced by the compiler.
+ |this means there is a cross-stage evaluation involved, and it needs to be invoked explicitly.
+ |if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+ |import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.""".trim.stripMargin)
+ lazy val value: T = throw new UnsupportedOperationException("""
+ |the value you're calling is only meant to be used in cross-stage path-dependent types.
+ |if you want to splice the underlying expression, use `<your expr>.splice`.
+ |if you want to get a value of the underlying expression, add scala-compiler.jar to the classpath,
+ |import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.""".trim.stripMargin)
+ }
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala
new file mode 100644
index 0000000000..969176d641
--- /dev/null
+++ b/src/reflect/scala/reflect/api/FlagSets.scala
@@ -0,0 +1,112 @@
+package scala.reflect
+package api
+
+import scala.language.implicitConversions
+
+trait FlagSets { self: Universe =>
+
+ type FlagSet
+
+ trait FlagOps extends Any {
+ def | (right: FlagSet): FlagSet
+ def & (right: FlagSet): FlagSet
+ def containsAll (right: FlagSet): Boolean
+ }
+
+ implicit def addFlagOps(left: FlagSet): FlagOps
+
+ val Flag: FlagValues
+
+ type FlagValues >: Null <: FlagValuesApi
+
+ // [Eugene++] any other flags we would like to expose?
+
+ trait FlagValuesApi {
+
+ /** Flag indicating that symbol or tree represents a trait */
+ val TRAIT: FlagSet
+
+ /** Flag indicating that symbol or tree represents a module or its internal module class */
+ val MODULE: FlagSet
+
+ /** Flag indicating that symbol or tree represents a mutable variable */
+ val MUTABLE: FlagSet
+
+ /** Flag indicating that symbol or tree represents a package or its internal package class */
+ val PACKAGE: FlagSet
+
+ /** Flag indicating that symbol or tree represents a method */
+ val METHOD: FlagSet
+
+ /** Flag indicating that symbol or tree represents a macro definition. */
+ val MACRO: FlagSet
+
+ /** Flag indicating that symbol or tree represents an abstract type, method, or value */
+ val DEFERRED: FlagSet
+
+ /** Flag indicating that symbol or tree represents an abstract class */
+ val ABSTRACT: FlagSet
+
+ /** Flag indicating that symbol or tree has `final` modifier set */
+ val FINAL: FlagSet
+
+ /** Flag indicating that symbol or tree has `sealed` modifier set */
+ val SEALED: FlagSet
+
+ /** Flag indicating that symbol or tree has `implicit` modifier set */
+ val IMPLICIT: FlagSet
+
+ /** Flag indicating that symbol or tree has `lazy` modifier set */
+ val LAZY: FlagSet
+
+ /** Flag indicating that symbol or tree has `override` modifier set */
+ val OVERRIDE: FlagSet
+
+ /** Flag indicating that symbol or tree has `private` modifier set */
+ val PRIVATE: FlagSet
+
+ /** Flag indicating that symbol or tree has `protected` modifier set */
+ val PROTECTED: FlagSet
+
+ /** Flag indicating that symbol or tree has `case` modifier set */
+ val CASE: FlagSet
+
+ /** Flag indicating that symbol or tree has `abstract` and `override` modifiers set */
+ val ABSOVERRIDE: FlagSet
+
+ /** Flag indicating that symbol or tree represents a by-name parameter */
+ val BYNAMEPARAM: FlagSet
+
+ /** Flag indicating that symbol or tree represents a class or parameter.
+ * Both type and value parameters carry the flag. */
+ val PARAM: FlagSet
+
+ /** Flag indicating that symbol or tree represents a field of a class
+ * that was generated from a parameter of that class */
+ val PARAMACCESSOR: FlagSet
+
+ /** Flag indicating that symbol or tree represents a field of a case class
+ * that corresponds to a parameter in the first parameter list of the
+ * primary constructor of that class */
+ val CASEACCESSOR: FlagSet
+
+ /** Flag indicating that symbol or tree represents a contravariant
+ * type parameter (marked with `+`). */
+ val COVARIANT: FlagSet
+
+ /** Flag indicating that symbol or tree represents a contravariant
+ * type parameter (marked with `-`). */
+ val CONTRAVARIANT: FlagSet
+
+ /** Flag indicating that parameter has a default value */
+ val DEFAULTPARAM: FlagSet
+
+ /** Flag indicating that trait has neither method implementations nor fields.
+ * This means the trait can be represented as a Java interface. */
+ val INTERFACE: FlagSet
+
+ def union(flags: FlagSet*): FlagSet
+ def intersection(flag: FlagSet*): FlagSet
+ def containsAll(superset: FlagSet, subset: FlagSet): Boolean
+ }
+}
diff --git a/src/library/scala/reflect/api/FrontEnds.scala b/src/reflect/scala/reflect/api/FrontEnds.scala
index 2c1f3feff6..a201b83444 100644
--- a/src/library/scala/reflect/api/FrontEnds.scala
+++ b/src/reflect/scala/reflect/api/FrontEnds.scala
@@ -1,7 +1,11 @@
package scala.reflect
package api
-trait FrontEnds { self: Universe =>
+// [Martin to Eugene] Todo: Needs to be evicted from API
+// [Eugene++ to Martin] but how? we need them for macros
+trait FrontEnds {
+
+ type Position >: Null
trait FrontEnd {
object severity extends Enumeration
diff --git a/src/library/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala
index 1d8890b7db..69d6414f4f 100644
--- a/src/library/scala/reflect/api/Importers.scala
+++ b/src/reflect/scala/reflect/api/Importers.scala
@@ -1,6 +1,8 @@
package scala.reflect
package api
+// [Martin] Importers need to be made mirror aware.
+// [Eugene++] this is important
trait Importers { self: Universe =>
def mkImporter(from0: Universe): Importer { val from: from0.type }
diff --git a/src/reflect/scala/reflect/api/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala
new file mode 100644
index 0000000000..8bf62a357c
--- /dev/null
+++ b/src/reflect/scala/reflect/api/JavaUniverse.scala
@@ -0,0 +1,19 @@
+package scala.reflect
+package api
+
+// [Martin] Moved to compiler because it needs to see runtime.Universe
+// The two will be united in scala-reflect anyway.
+trait JavaUniverse extends Universe with Mirrors with TagInterop { self =>
+
+ type RuntimeClass = java.lang.Class[_]
+
+ override type Mirror >: Null <: JavaMirror
+
+ trait JavaMirror extends MirrorOf[self.type] with RuntimeMirror {
+ val classLoader: ClassLoader
+ override def toString = s"JavaMirror with ${runtime.ReflectionUtils.show(classLoader)}"
+ }
+
+ def runtimeMirror(cl: ClassLoader): Mirror
+}
+
diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala
new file mode 100644
index 0000000000..348ab3656b
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Mirrors.scala
@@ -0,0 +1,208 @@
+package scala.reflect
+package api
+
+trait Mirrors { self: Universe =>
+
+ type RuntimeClass >: Null
+
+ // [Eugene] also, it might make sense to provide shortcuts for the API
+ //
+ // for example, right now to invoke the same method for several different instances, you need:
+ // 1) get the method symbol
+ // 2) get the instance mirror for every instance
+ // 3) call reflectMethod on the instance mirrors for every instance
+ // 4) call apply for every instance (okay, this can be united with step #3, but still)
+ //
+ // I have several suggestions that we can discuss later:
+ // 1) For every `reflectXXX(sym: Symbol): XXXMirror`, add `reflectXXX(name: String, types: Type*): XXXMirror` and `reflectXXXs(): List[XXXMirror]`
+ // 2) Provide a way to skip obtaining InstanceMirror (step #2 in the outline provided above)
+
+ // [Eugene] another improvement would be have mirrors reproduce the structure of the reflection domain
+ // e.g. a ClassMirror could also have a list of fields, methods, constructors and so on
+ // read up more on the proposed design in "Reflecting Scala" by Y. Coppel
+
+ /** A mirror that reflects a runtime value */
+ trait InstanceMirror {
+
+ /** The instance value reflected by this mirror */
+ def instance: Any
+
+ /** The symbol corresponding to the run-time class of the reflected instance. */
+ def symbol: ClassSymbol
+
+ /** Get value of field in reflected instance.
+ * @field A field symbol that should represent a field of the instance class.
+ * @return The value associated with that field in the reflected instance
+ * @throws ???
+ */
+ def reflectField(field: TermSymbol): FieldMirror
+
+ /** Invokes a method on the reflected instance.
+ * @param meth A method symbol that should represent a method of the instance class
+ * @param args The arguments to pass to the method
+ * @return The result of invoking `meth(args)` on the reflected instance.
+ * @throws ???
+ */
+ def reflectMethod(method: MethodSymbol): MethodMirror
+
+ /** .. */
+ def reflectClass(cls: ClassSymbol): ClassMirror
+
+ /** .. */
+ def reflectModule(mod: ModuleSymbol): ModuleMirror
+ }
+
+ /** A mirror that reflects a field */
+ trait FieldMirror {
+
+ /** The object containing the field */
+ def receiver: AnyRef
+
+ /** The field symbol representing the field */
+ def symbol: TermSymbol
+
+ /** Retrieves the value stored in the field */
+ def get: Any
+
+ /** Updates the value stored in the field */
+ def set(value: Any): Unit
+ }
+
+ /** A mirror that reflects a method handle */
+ trait MethodMirror {
+
+ /** The receiver object of the method */
+ def receiver: AnyRef
+
+ /** The method symbol representing the method */
+ def symbol: MethodSymbol
+
+ /** The result of applying the method to the given arguments */
+ // [Eugene+++] If it's a constructor, it should account for inner classes
+ def apply(args: Any*): Any
+ }
+
+ /** A mirror that reflects the instance or static parts of a runtime class */
+ trait TemplateMirror {
+
+ /** The runtime class reflected by this mirror */
+ def runtimeClass: RuntimeClass
+
+ /** True if the mirror represents the static part
+ * if a runtime class or the companion object of a Scala class.
+ * One has:
+ *
+ * this.isStatic == this.isInstanceOf[ModuleMirror]
+ * !this.isStatic == this.isInstanceOf[ClassMirror]
+ */
+ def isStatic: Boolean
+
+ /** The Scala symbol corresponding to the reflected runtime class or module. */
+ def symbol: Symbol
+
+ /** Optionally, the mirror of the companion reflected by this mirror.
+ * If this mirror reflects a Scala object, the mirror for the companion class, or None
+ * if the mirror represents a Scala object that comes without a class.
+ * Otherwise, if the mirror represents the static part of a runtime class, the
+ * mirror representing the instance part of the same class.
+ * Otherwise, if the mirror represents a Scala instance class, the mirror for the companion
+ * object of that class, or None if no such object exists.
+ * Otherwise, if the mirror represents a runtime instance class, a mirror representing the static
+ * part of the same class.
+ */
+ def companion: Option[TemplateMirror]
+ }
+
+ /** A mirror that reflects a Scala object definition or the static parts of a runtime class */
+ trait ModuleMirror extends TemplateMirror {
+
+ /** The Scala module symbol corresponding to the reflected module. */
+ override def symbol: ModuleSymbol
+
+ /** If the reflected runtime class corresponds to a Scala object definition,
+ * returns the single instance representing that object.
+ * If this mirror reflects the static part of a runtime class, returns `null`.
+ */
+ def instance: Any
+
+ /** Optionally, the mirror of the companion class if the object reflected by this mirror.
+ * If this mirror reflects a Scala object, the mirror for the companion class, or None
+ * if the mirror represents a Scala object that comes without a class.
+ * Otherwise, if the mirror represents the static part of a runtime class, the
+ * mirror representing the instance part of the same class.
+ */
+ def companion: Option[ClassMirror]
+ }
+
+ /** A mirror that reflects the instance parts of a runtime class */
+ trait ClassMirror extends TemplateMirror {
+
+ /** The Scala class symbol corresponding to the reflected class. */
+ override def symbol: ClassSymbol
+
+ /** Returns a fresh instance of by invoking that constructor.
+ * @throws InstantiationException if the class does not have a public
+ * constructor with an empty parameter list.
+ * @throws IllegalAccessException if the class or its constructor is not accessible.
+ * @throws ExceptionInInitializerError if the initialization of the constructor fails.
+ * @throws SecurityException if creating a new instance is not permitted.
+ */
+ def reflectConstructor(constructor: MethodSymbol): MethodMirror
+
+ /** Optionally, the mirror of the companion object of the class reflected by this mirror.
+ * If this mirror represents a Scala instance class, the mirror for the companion
+ * object of that class, or None if no such object exists.
+ * Otherwise, if the mirror represents a runtime instance class, a mirror representing the static
+ * part of the same class.
+ */
+ def companion: Option[ModuleMirror]
+ }
+
+ /** A mirror that reflects instances and static classes */
+ trait ReflectiveMirror extends MirrorOf[Mirrors.this.type] {
+
+ /** A reflective mirror for the given object
+ * @param obj An arbitrary value
+ * @return The mirror for `obj`.
+ */
+ def reflect(obj: Any): InstanceMirror
+
+ /** .. */
+ def reflectClass(cls: ClassSymbol): ClassMirror
+
+ /** .. */
+ def reflectModule(mod: ModuleSymbol): ModuleMirror
+ }
+
+ /** The API of a mirror for a reflective universe */
+ trait RuntimeMirror extends ReflectiveMirror { self =>
+
+ /** Maps a Scala type to the corresponding Java class object
+ */
+ def runtimeClass(tpe: Type): RuntimeClass
+
+ /** Maps a Scala class symbol to the corresponding Java class object
+ * @throws ClassNotFoundException if there is no Java class
+ * corresponding to the given Scala class symbol.
+ * Note: If the Scala symbol is ArrayClass, a ClassNotFound exception is thrown
+ * because there is no unique Java class corresponding to a Scala generic array
+ */
+ def runtimeClass(cls: ClassSymbol): RuntimeClass
+
+ /** A class symbol for the specified runtime class.
+ * @return The class symbol for the runtime class in the current class loader.
+ * @throws java.lang.ClassNotFoundException if no class with that name exists
+ * @throws scala.reflect.internal.MissingRequirementError if no corresponding symbol exists
+ * to do: throws anything else?
+ */
+ def classSymbol(rtcls: RuntimeClass): ClassSymbol
+
+ /** A module symbol for the specified runtime class.
+ * @return The module symbol for the runtime class in the current class loader.
+ * @throws java.lang.ClassNotFoundException if no class with that name exists
+ * @throws scala.reflect.internal.MissingRequirementError if no corresponding symbol exists
+ * to do: throws anything else?
+ */
+ def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol
+ }
+}
diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala
new file mode 100644
index 0000000000..222ee5024b
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Names.scala
@@ -0,0 +1,44 @@
+package scala.reflect
+package api
+
+/** A trait that manages names.
+ * A name is a string in one of two name universes: terms and types.
+ * The same string can be a name in both universes.
+ * Two names are equal if they represent the same string and they are
+ * members of the same universe.
+ *
+ * Names are interned. That is, for two names `name11 and `name2`,
+ * `name1 == name2` implies `name1 eq name2`.
+ */
+trait Names extends base.Names {
+
+ /** The abstract type of names */
+ type Name >: Null <: NameApi
+
+ /** The extended API of names that's supported on reflect mirror via an
+ * implicit conversion in reflect.ops
+ */
+ abstract class NameApi extends NameBase {
+
+ // [Eugene++] this functionality should be in base
+ // this is because stuff will be reified in mangled state, and people will need a way to figure it out
+
+ /** Replaces all occurrences of \$op_names in this name by corresponding operator symbols.
+ * Example: `foo_\$plus\$eq` becomes `foo_+=`
+ */
+ def decoded: String
+
+ /** Replaces all occurrences of operator symbols in this name by corresponding \$op_names.
+ * Example: `foo_+=` becomes `foo_\$plus\$eq`.
+ */
+ def encoded: String
+
+ /** The decoded name, still represented as a name.
+ */
+ def decodedName: Name
+
+ /** The encoded name, still represented as a name.
+ */
+ def encodedName: Name
+ }
+}
diff --git a/src/library/scala/reflect/api/Positions.scala b/src/reflect/scala/reflect/api/Positions.scala
index 8f01e0ced1..9d3d90d9f8 100644
--- a/src/library/scala/reflect/api/Positions.scala
+++ b/src/reflect/scala/reflect/api/Positions.scala
@@ -1,16 +1,11 @@
package scala.reflect
package api
-trait Positions {
+trait Positions extends base.Positions {
self: Universe =>
- // [Eugene] in quite a lot of situations (mostly related to error reporting) we need positions in the API
- // however it seems that neither runtime compilation, nor macros need facilities to create positions from scratch
- // both emit ASTs, which can be automatically transformed into synthetic sources and assigned with synthetic positions
- // hence I added possibilities to inspect everything we can, but add any position factories
- // this simplified a lot of things, the biggest of them is that we don't need to expose SourceFile/AbstractFile
- type Position <: scala.reflect.api.Position
- val NoPosition: Position
+ /** .. */
+ type Position >: Null <: PositionApi { type Pos = Position }
/** A position that wraps a set of trees.
* The point of the wrapping position is the point of the default position.
@@ -31,11 +26,8 @@ trait Positions {
* shortening the range or assigning TransparentPositions
* to some of the nodes in `tree`.
*/
- def ensureNonOverlapping(tree: Tree, others: List[Tree])
-
- /** Assigns a given position to all position-less nodes of a given AST.
- */
- def atPos[T <: Tree](pos: Position)(tree: T): T
+ //def ensureNonOverlapping(tree: Tree, others: List[Tree])
+ // [Eugene++] can this method be of use for macros?
}
/** The Position class and its subclasses represent positions of ASTs and symbols.
@@ -82,7 +74,9 @@ trait Positions {
* pos.makeTransparent converts an opaque range position into a transparent one.
* returns all other positions unchanged.
*/
-trait Position extends Attachment {
+trait PositionApi extends Attachments {
+
+ type Pos >: Null <: PositionApi
/** Java file corresponding to the source file of this position.
*/
@@ -97,17 +91,17 @@ trait Position extends Attachment {
*/
def isDefined: Boolean
- /** Is this position a transparent position? */
- def isTransparent: Boolean
-
/** Is this position a range position? */
def isRange: Boolean
+ /** Is this position a transparent position? */
+ def isTransparent: Boolean
+
/** Is this position a non-transparent range position? */
def isOpaqueRange: Boolean
/** if opaque range, make this position transparent */
- def makeTransparent: Position
+ def makeTransparent: Pos
/** The start of the position's range, error if not a range position */
def start: Int
@@ -128,73 +122,73 @@ trait Position extends Attachment {
def endOrPoint: Int
/** The same position with a different start value (if a range) */
- def withStart(off: Int): Position
+ def withStart(off: Int): Pos
/** The same position with a different end value (if a range) */
- def withEnd(off: Int): Position
+ def withEnd(off: Int): Pos
/** The same position with a different point value (if a range or offset) */
- def withPoint(off: Int): Position
+ def withPoint(off: Int): Pos
/** If this is a range, the union with the other range, with the point of this position.
* Otherwise, this position
*/
- def union(pos: Position): Position
+ def union(pos: Pos): Pos
- /** If this is a range position, the offset position of its start.
+ /** If this is a range position, the offset position of its point.
* Otherwise the position itself
*/
- def focusStart: Position
+ def focus: Pos
- /** If this is a range position, the offset position of its point.
+ /** If this is a range position, the offset position of its start.
* Otherwise the position itself
*/
- def focus: Position
+ def focusStart: Pos
/** If this is a range position, the offset position of its end.
* Otherwise the position itself
*/
- def focusEnd: Position
+ def focusEnd: Pos
/** Does this position include the given position `pos`.
* This holds if `this` is a range position and its range [start..end]
* is the same or covers the range of the given position, which may or may not be a range position.
*/
- def includes(pos: Position): Boolean
+ def includes(pos: Pos): Boolean
/** Does this position properly include the given position `pos` ("properly" meaning their
* ranges are not the same)?
*/
- def properlyIncludes(pos: Position): Boolean
+ def properlyIncludes(pos: Pos): Boolean
/** Does this position precede that position?
* This holds if both positions are defined and the end point of this position
* is not larger than the start point of the given position.
*/
- def precedes(pos: Position): Boolean
+ def precedes(pos: Pos): Boolean
/** Does this position properly precede the given position `pos` ("properly" meaning their ranges
* do not share a common point).
*/
- def properlyPrecedes(pos: Position): Boolean
+ def properlyPrecedes(pos: Pos): Boolean
/** Does this position overlap with that position?
* This holds if both positions are ranges and there is an interval of
* non-zero length that is shared by both position ranges.
*/
- def overlaps(pos: Position): Boolean
+ def overlaps(pos: Pos): Boolean
/** Does this position cover the same range as that position?
* Holds only if both position are ranges
*/
- def sameRange(pos: Position): Boolean
+ def sameRange(pos: Pos): Boolean
def line: Int
def column: Int
/** Convert this to a position around `point` that spans a single source line */
- def toSingleLine: Position
+ def toSingleLine: Pos
def lineContent: String
diff --git a/src/reflect/scala/reflect/api/StandardDefinitions.scala b/src/reflect/scala/reflect/api/StandardDefinitions.scala
new file mode 100644
index 0000000000..c2a89f92dd
--- /dev/null
+++ b/src/reflect/scala/reflect/api/StandardDefinitions.scala
@@ -0,0 +1,48 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.reflect
+package api
+
+trait StandardDefinitions extends base.StandardDefinitions {
+ self: Universe =>
+
+ val definitions: DefinitionsApi
+
+ trait DefinitionsApi extends DefinitionsBase {
+ def JavaLangPackageClass: ClassSymbol
+ def JavaLangPackage: ModuleSymbol
+ def ArrayModule: ModuleSymbol
+ def ArrayModule_overloadedApply: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def Array_apply: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def Array_clone: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def Array_length: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def Array_update: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def ByNameParamClass: ClassSymbol
+ def ConsClass: ClassSymbol
+ def FunctionClass : Array[ClassSymbol]
+ def IterableClass: ClassSymbol
+ def IteratorClass: ClassSymbol
+ def IteratorModule: ModuleSymbol
+ def Iterator_apply: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def JavaRepeatedParamClass: ClassSymbol
+ def ListModule: ModuleSymbol
+ def List_apply: TermSymbol // todo. fix the bug in Definitions.getMemberMethod
+ def NilModule: ModuleSymbol
+ def NoneModule: ModuleSymbol
+ def OptionClass: ClassSymbol
+ def ProductClass : Array[ClassSymbol]
+ def RepeatedParamClass: ClassSymbol
+ def SeqClass: ClassSymbol
+ def SeqModule: ModuleSymbol
+ def SomeClass: ClassSymbol
+ def SomeModule: ModuleSymbol
+ def StringBuilderClass: ClassSymbol
+ def SymbolClass : ClassSymbol
+ def TraversableClass: ClassSymbol
+ def TupleClass: Array[Symbol] // cannot make it Array[ClassSymbol], because TupleClass(0) is supposed to be NoSymbol. weird
+ def ScalaPrimitiveValueClasses: List[ClassSymbol]
+ def ScalaNumericValueClasses: List[ClassSymbol]
+ }
+}
diff --git a/src/library/scala/reflect/api/StandardNames.scala b/src/reflect/scala/reflect/api/StandardNames.scala
index a17ea216f7..9ec66b8531 100644
--- a/src/library/scala/reflect/api/StandardNames.scala
+++ b/src/reflect/scala/reflect/api/StandardNames.scala
@@ -2,36 +2,30 @@
* Copyright 2005-2011 LAMP/EPFL
* @author Martin Odersky
*/
-
package scala.reflect
package api
-trait StandardNames {
+trait StandardNames extends base.StandardNames {
self: Universe =>
- val nme: AbsTermNames
- val tpnme: AbsTypeNames
-
- trait AbsNames {
- type NameType <: Name
+ val nme: TermNamesApi
+ val tpnme: TypeNamesApi
+ trait NamesApi extends NamesBase {
val ANON_CLASS_NAME: NameType
val ANON_FUN_NAME: NameType
val EMPTY: NameType
- val EMPTY_PACKAGE_NAME: NameType
val ERROR: NameType
val IMPORT: NameType
val MODULE_VAR_SUFFIX: NameType
- val NO_NAME: NameType
val PACKAGE: NameType
val ROOT: NameType
val SPECIALIZED_SUFFIX: NameType
- val WILDCARD: NameType
def flattenedName(segments: Name*): NameType
}
- trait AbsTermNames extends AbsNames {
+ trait TermNamesApi extends NamesApi with TermNamesBase {
val EXPAND_SEPARATOR_STRING: String
val IMPL_CLASS_SUFFIX: String
val INTERPRETER_IMPORT_WRAPPER: String
@@ -50,16 +44,20 @@ trait StandardNames {
val TRAIT_SETTER_SEPARATOR_STRING: String
val ANYNAME: TermName
- val CONSTRUCTOR: TermName
val FAKE_LOCAL_THIS: TermName
val INITIALIZER: TermName
val LAZY_LOCAL: TermName
- val MIRROR_FREE_PREFIX: TermName
- val MIRROR_FREE_THIS_SUFFIX: TermName
- val MIRROR_FREE_VALUE_SUFFIX: TermName
- val MIRROR_PREFIX: TermName
- val MIRROR_SHORT: TermName
- val MIRROR_SYMDEF_PREFIX: TermName
+ val UNIVERSE_BUILD: NameType
+ val UNIVERSE_BUILD_PREFIX: NameType
+ val UNIVERSE_PREFIX: NameType
+ val UNIVERSE_SHORT: NameType
+ val MIRROR_PREFIX: NameType
+ val MIRROR_SHORT: NameType
+ val MIRROR_UNTYPED: NameType
+ val REIFY_FREE_PREFIX: NameType
+ val REIFY_FREE_THIS_SUFFIX: NameType
+ val REIFY_FREE_VALUE_SUFFIX: NameType
+ val REIFY_SYMDEF_PREFIX: NameType
val MIXIN_CONSTRUCTOR: TermName
val MODULE_INSTANCE_FIELD: TermName
val OUTER: TermName
@@ -146,7 +144,7 @@ trait StandardNames {
def splitSpecializedName(name: Name): (Name, String, String)
}
- trait AbsTypeNames extends AbsNames {
+ trait TypeNamesApi extends NamesApi with TypeNamesBase {
val BYNAME_PARAM_CLASS_NAME: TypeName
val EQUALS_PATTERN_NAME: TypeName
val JAVA_REPEATED_PARAM_CLASS_NAME: TypeName
@@ -154,6 +152,8 @@ trait StandardNames {
val REFINE_CLASS_NAME: TypeName
val REPEATED_PARAM_CLASS_NAME: TypeName
val WILDCARD_STAR: TypeName
+ val REIFY_TYPECREATOR_PREFIX: NameType
+ val REIFY_TREECREATOR_PREFIX: NameType
def dropSingletonName(name: Name): TypeName
def implClassName(name: Name): TypeName
diff --git a/src/library/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index 32faee2512..1d266dc778 100755..100644
--- a/src/library/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -1,149 +1,55 @@
package scala.reflect
package api
-trait Symbols { self: Universe =>
-
- type Symbol >: Null <: AbsSymbol
- type TypeSymbol <: Symbol with TypeSymbolApi
- type TermSymbol <: Symbol with TermSymbolApi
- type MethodSymbol <: TermSymbol with MethodSymbolApi
- type ModuleSymbol <: TermSymbol with ModuleSymbolApi
- type PackageSymbol <: ModuleSymbol with PackageSymbolApi
- type ClassSymbol <: TypeSymbol with ClassSymbolApi
-
- val NoSymbol: Symbol
-
- trait TypeSymbolApi {
- self: TypeSymbol =>
-
- def name: TypeName
- }
- trait TermSymbolApi {
- self: TermSymbol =>
-
- def name: TermName
- }
- trait MethodSymbolApi extends TermSymbolApi {
- self: MethodSymbol =>
- }
- trait ClassSymbolApi extends TypeSymbolApi {
- self: ClassSymbol =>
- }
- trait ModuleSymbolApi extends TermSymbolApi {
- self: ModuleSymbol =>
- }
- trait PackageSymbolApi extends ModuleSymbolApi {
- self: PackageSymbol =>
- }
-
- // I intend to pull everything in here out of the public API.
- trait AbsSymbolInternal {
- this: Symbol =>
-
- /** A fresh symbol with given name `name`, position `pos` and flags `flags` that has
- * the current symbol as its owner.
- */
- def newNestedSymbol(name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol
- // needed by LiftCode !!! not enough reason to have in the api
-
- /** Low-level operation to set the symbol's flags
- * @return the symbol itself
- */
- def setInternalFlags(flags: Long): this.type
- // needed by LiftCode !!! not enough reason to have in the api
-
- /** Set symbol's type signature to given type
- * @return the symbol itself
- */
- def setTypeSignature(tpe: Type): this.type
- // needed by LiftCode !!! not enough reason to have in the api
-
- /** Set symbol's annotations to given annotations `annots`.
- */
- def setAnnotations(annots: AnnotationInfo*): this.type
- // needed by LiftCode !!! not enough reason to have in the api
-
- /** Does this symbol represent the definition of a skolem?
- * Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
- * If yes, `isType` is also guaranteed to be true.
- */
- def isSkolem : Boolean
-
- /** Does this symbol represent a free type captured by reification?
- */
- // needed for ones who wish to inspect reified trees
- def isFreeType : Boolean
-
- /** The type signature of this symbol.
- * Note if the symbol is a member of a class, one almost always is interested
- * in `typeSignatureIn` with a site type instead.
- */
- def typeSignature: Type // !!! Since one should almost never use this, let's give it a different name.
-
- /** A type reference that refers to this type symbol
- * Note if symbol is a member of a class, one almost always is interested
- * in `asTypeIn` with a site type instead.
- *
- * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
- * `C`. Then `C.asType` is the type `C[T]`.
- *
- * By contrast, `C.typeSignature` would be a type signature of form
- * `PolyType(ClassInfoType(...))` that describes type parameters, value
- * parameters, parent types, and members of `C`.
- */
- def asType: Type // !!! Same as typeSignature.
-
- /** The kind of this symbol; used for debugging */
- def kind: String
+trait Symbols extends base.Symbols { self: Universe =>
+
+ override type Symbol >: Null <: SymbolApi
+ override type TypeSymbol >: Null <: Symbol with TypeSymbolApi
+ override type TermSymbol >: Null <: Symbol with TermSymbolApi
+ override type MethodSymbol >: Null <: TermSymbol with MethodSymbolApi
+ override type ModuleSymbol >: Null <: TermSymbol with ModuleSymbolApi
+ override type ClassSymbol >: Null <: TypeSymbol with ClassSymbolApi
+ override type FreeTermSymbol >: Null <: TermSymbol with FreeTermSymbolApi
+ override type FreeTypeSymbol >: Null <: TypeSymbol with FreeTypeSymbolApi
+
+ trait HasFlagsApi {
+ def flags: FlagSet
+ def hasFlag(fs: FlagSet): Boolean
+ def hasAllFlags(fs: FlagSet): Boolean
+ def flagString: String
}
- trait AbsSymbol extends AbsSymbolInternal {
- this: Symbol =>
+ /** The API of symbols */
+ trait SymbolApi extends SymbolBase with HasFlagsApi { this: Symbol =>
/** The position of this symbol
*/
def pos: Position
- /** The modifiers of this symbol
- */
- def modifiers: Set[Modifier]
-
- /** Does this symbol have given modifier?
- */
- def hasModifier(mod: Modifier): Boolean
-
/** A list of annotations attached to this Symbol.
*/
- def annotations: List[self.AnnotationInfo]
+ // [Eugene++] we cannot expose the `annotations` method because it doesn't auto-initialize a symbol (see SI-5423)
+ // there was an idea to use the `isCompilerUniverse` flag and auto-initialize symbols in `annotations` whenever this flag is false
+ // but it doesn't work, because the unpickler (that is shared between reflective universes and global universes) is very picky about initialization
+ // scala.reflect.internal.Types$TypeError: bad reference while unpickling scala.collection.immutable.Nil: type Nothing not found in scala.type not found.
+ // at scala.reflect.internal.pickling.UnPickler$Scan.toTypeError(UnPickler.scala:836)
+ // at scala.reflect.internal.pickling.UnPickler$Scan$LazyTypeRef.complete(UnPickler.scala:849) // auto-initialize goes boom
+ // at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1140)
+ // at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1272) // this triggers auto-initialize
+ // at scala.reflect.internal.Symbols$Symbol.annotations(Symbols.scala:1438) // unpickler first tries to get pre-existing annotations
+ // at scala.reflect.internal.Symbols$Symbol.addAnnotation(Symbols.scala:1458) // unpickler tries to add the annotation being read
+ // at scala.reflect.internal.pickling.UnPickler$Scan.readSymbolAnnotation(UnPickler.scala:489) // unpickler detects an annotation
+ // at scala.reflect.internal.pickling.UnPickler$Scan.run(UnPickler.scala:88)
+ // at scala.reflect.internal.pickling.UnPickler.unpickle(UnPickler.scala:37)
+ // at scala.reflect.runtime.JavaMirrors$JavaMirror.unpickleClass(JavaMirrors.scala:253) // unpickle from within a reflexive mirror
+ // def annotations: List[AnnotationInfo]
+ def getAnnotations: List[AnnotationInfo]
/** Whether this symbol carries an annotation for which the given
* symbol is its typeSymbol.
*/
def hasAnnotation(sym: Symbol): Boolean
- /** The owner of this symbol. This is the symbol
- * that directly contains the current symbol's definition.
- * The `NoSymbol` symbol does not have an owner, and calling this method
- * on one causes an internal error.
- * The owner of the Scala root class [[scala.reflect.api.mirror.RootClass]]
- * and the Scala root object [[scala.reflect.api.mirror.RootPackage]] is `NoSymbol`.
- * Every other symbol has a chain of owners that ends in
- * [[scala.reflect.api.mirror.RootClass]].
- */
- def owner: Symbol
-
- /** The name of the symbol as a member of the `Name` type.
- */
- def name: Name
-
- /** The encoded full path name of this symbol, where outer names and inner names
- * are separated by periods.
- */
- def fullName: String
-
- /** An id number which is unique for all symbols in this universe */
- def id: Int
-
/** ...
*/
def orElse(alt: => Symbol): Symbol
@@ -152,6 +58,11 @@ trait Symbols { self: Universe =>
*/
def filter(cond: Symbol => Boolean): Symbol
+ /** If this is a NoSymbol, returns NoSymbol, otherwise
+ * returns the result of applying `f` to this symbol.
+ */
+ def map(f: Symbol => Symbol): Symbol
+
/** ...
*/
def suchThat(cond: Symbol => Boolean): Symbol
@@ -189,82 +100,57 @@ trait Symbols { self: Universe =>
*/
def companionSymbol: Symbol
- /** If symbol is an object definition, its implied associated class,
- * otherwise NoSymbol
+ /** If this symbol is a package class, this symbol; otherwise the next enclosing
+ * package class, or `NoSymbol` if none exists.
*/
- def moduleClass: Symbol // needed for LiftCode
+ def enclosingPackageClass: Symbol
/** If this symbol is a top-level class, this symbol; otherwise the next enclosing
* top-level class, or `NoSymbol` if none exists.
*/
def enclosingTopLevelClass: Symbol
- /** If this symbol is a class, this symbol; otherwise the next enclosing
- * class, or `NoSymbol` if none exists.
- */
- def enclosingClass: Symbol
-
- /** If this symbol is a method, this symbol; otherwise the next enclosing
- * method, or `NoSymbol` if none exists.
- */
- def enclosingMethod: Symbol
-
- /** If this symbol is a package class, this symbol; otherwise the next enclosing
- * package class, or `NoSymbol` if none exists.
+ /** Does this symbol represent a value, i.e. not a module and not a method?
+ * If yes, `isTerm` is also guaranteed to be true.
+ * [Eugene++] I need a review of the implementation
*/
- def enclosingPackageClass: Symbol
+ def isValue: Boolean
- /** Does this symbol represent the definition of term?
- * Note that every symbol is either a term or a type.
- * So for every symbol `sym`, either `sym.isTerm` is true
- * or `sym.isType` is true.
+ /** Does this symbol represent a mutable value?
+ * If yes, `isTerm` and `isValue` are also guaranteed to be true.
*/
- def isTerm : Boolean
+ def isVariable: Boolean
- /** Does this symbol represent a package?
+ /** Does this symbol represent the definition of a package?
* If yes, `isTerm` is also guaranteed to be true.
*/
- def isPackage : Boolean
+ def isPackage: Boolean
- /** Does this symbol represent the definition of method?
- * If yes, `isTerm` is also guaranteed to be true.
+ /** Does this symbol represent a package class?
+ * If yes, `isClass` is also guaranteed to be true.
*/
- def isMethod : Boolean
+ def isPackageClass: Boolean
/** Is this symbol an overloaded method?
*/
def isOverloaded : Boolean
- /** Does this symbol represent a free term captured by reification?
- */
- // needed for ones who wish to inspect reified trees
- def isFreeTerm : Boolean
-
- /** Does this symbol represent the definition of type?
- * Note that every symbol is either a term or a type.
- * So for every symbol `sym`, either `sym.isTerm` is true
- * or `sym.isType` is true.
- */
- def isType : Boolean
-
- /** Does this symbol represent the definition of class?
- * If yes, `isType` is also guaranteed to be true.
- */
- def isClass : Boolean
-
- /** Does this symbol represent a package class?
- * If yes, `isClass` is also guaranteed to be true.
- */
- def isPackageClass : Boolean
-
/** Does this symbol represent the definition of a primitive class?
* Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]],
* [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]?
*/
def isPrimitiveValueClass: Boolean
+ /** Does this symbol represent the definition of a numeric value class?
+ * Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]],
+ * [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]?
+ */
+ def isNumericValueClass: Boolean
+
/** Does this symbol represent the definition of a custom value class?
* Namely, is AnyVal among its parent classes?
+ * TODO: Why not just have in reflect.internal?
+ * [Eugene++] because it's useful for macros
*/
def isDerivedValueClass: Boolean
@@ -283,6 +169,38 @@ trait Symbols { self: Universe =>
*/
def isExistential : Boolean
+ /** Does this symbol represent a free type captured by reification?
+ */
+ def isFreeType : Boolean
+
+ /** Does this symbol or its underlying type represent a typechecking error?
+ */
+ def isErroneous : Boolean
+
+ /** The type signature of this symbol seen as a member of given type `site`.
+ */
+ def typeSignatureIn(site: Type): Type
+
+ /** The type signature of this symbol.
+ * Note if the symbol is a member of a class, one almost always is interested
+ * in `typeSignatureIn` with a site type instead.
+ */
+ def typeSignature: Type
+
+ /** The string discriminator of this symbol; useful for debugging */
+ def kind: String
+ }
+
+ /** The API of term symbols */
+ trait TermSymbolApi extends SymbolApi with HasFlagsApi with TermSymbolBase { this: TermSymbol =>
+ /** The overloaded alternatives of this symbol */
+ def alternatives: List[Symbol]
+
+ def resolveOverloaded(pre: Type = NoPrefix, targs: Seq[Type] = List(), actuals: Seq[Type]): Symbol
+ }
+
+ /** The API of type symbols */
+ trait TypeSymbolApi extends SymbolApi with HasFlagsApi with TypeSymbolBase { this: TypeSymbol =>
/** Is the type parameter represented by this symbol contravariant?
*/
def isContravariant : Boolean
@@ -291,40 +209,60 @@ trait Symbols { self: Universe =>
*/
def isCovariant : Boolean
- /** Does this symbol or its underlying type represent a typechecking error?
- */
- def isErroneous : Boolean
-
- /** The type signature of this symbol seen as a member of given type `site`.
+ /** Does this symbol represent the definition of a skolem?
+ * Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
+ * If yes, `isType` is also guaranteed to be true.
*/
- def typeSignatureIn(site: Type): Type
+ def isSkolem : Boolean
/** A type reference that refers to this type symbol seen
* as a member of given type `site`.
*/
def asTypeIn(site: Type): Type
- /** The type constructor corresponding to this type symbol.
- * This is different from `asType` in that type parameters
- * are part of results of `asType`, but not of `asTypeConstructor`.
- *
- * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
- * `C`. Then `C.asType` is the type `C[T]`, but `C.asTypeConstructor` is `C`.
- */
- def asTypeConstructor: Type // needed by LiftCode
+ /** A type reference that refers to this type symbol
+ * Note if symbol is a member of a class, one almost always is interested
+ * in `asTypeIn` with a site type instead.
+ *
+ * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
+ * `C`. Then `C.asType` is the type `C[T]`.
+ *
+ * By contrast, `C.typeSignature` would be a type signature of form
+ * `PolyType(ClassInfoType(...))` that describes type parameters, value
+ * parameters, parent types, and members of `C`.
+ */
+ def asType: Type // !!! Same as typeSignature.
+ }
- /** If this symbol is a class, the type `C.this`, otherwise `NoPrefix`.
- */
- def thisPrefix: Type
+ /** The API of method symbols */
+ type MethodSymbolApi = MethodSymbolBase
+ /** The API of module symbols */
+ type ModuleSymbolApi = ModuleSymbolBase
+
+ /** The API of class symbols */
+ trait ClassSymbolApi extends TypeSymbolApi with ClassSymbolBase { this: ClassSymbol =>
/** If this symbol is a class or trait, its self type, otherwise the type
* of the symbol itself.
*/
def selfType: Type
- /** The overloaded alternatives of this symbol */
- def alternatives: List[Symbol]
+ /** The type `C.this`, where `C` is the current class */
+ def thisPrefix: Type
+ }
- def resolveOverloaded(pre: Type = NoPrefix, targs: Seq[Type] = List(), actuals: Seq[Type]): Symbol
+ /** The API of free term symbols */
+ trait FreeTermSymbolApi extends TermSymbolApi with FreeTermSymbolBase { this: FreeTermSymbol =>
+ /** The place where this symbol has been spawned */
+ def origin: String
+
+ /** The valus this symbol refers to */
+ def value: Any
+ }
+
+ /** The API of free term symbols */
+ trait FreeTypeSymbolApi extends TypeSymbolApi with FreeTypeSymbolBase { this: FreeTypeSymbol =>
+ /** The place where this symbol has been spawned */
+ def origin: String
}
}
diff --git a/src/reflect/scala/reflect/api/TagInterop.scala b/src/reflect/scala/reflect/api/TagInterop.scala
new file mode 100644
index 0000000000..f1938083b5
--- /dev/null
+++ b/src/reflect/scala/reflect/api/TagInterop.scala
@@ -0,0 +1,38 @@
+package scala.reflect
+package api
+
+import scala.reflect.base.TypeCreator
+import scala.reflect.base.{Universe => BaseUniverse}
+
+// [Martin] Moved to compiler because it needs to see runtime.Universe
+// The two will be united in scala-reflect anyway.
+trait TagInterop { self: JavaUniverse =>
+
+ // [Eugene++] would be great if we could approximate the interop without any mirrors
+ // todo. think how to implement that
+
+ override def typeTagToManifest[T: ClassTag](mirror0: Any, tag: base.Universe # TypeTag[T]): Manifest[T] = {
+ // [Eugene++] implement more sophisticated logic
+ // Martin said it'd be okay to simply copypaste `Implicits.manifestOfType`
+ val mirror = mirror0.asInstanceOf[Mirror]
+ val runtimeClass = mirror.runtimeClass(tag.in(mirror).tpe)
+ Manifest.classType(runtimeClass).asInstanceOf[Manifest[T]]
+ }
+
+ override def manifestToTypeTag[T](mirror0: Any, manifest: Manifest[T]): base.Universe # TypeTag[T] =
+ TypeTag(mirror0.asInstanceOf[Mirror], new TypeCreator {
+ def apply[U <: BaseUniverse with Singleton](mirror: MirrorOf[U]): U # Type = {
+ mirror.universe match {
+ case ju: JavaUniverse =>
+ val jm = mirror.asInstanceOf[ju.Mirror]
+ val sym = jm.classSymbol(manifest.erasure)
+ val tpe =
+ if (manifest.typeArguments.isEmpty) sym.asType
+ else ju.appliedType(sym.asTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe))
+ tpe.asInstanceOf[U # Type]
+ case u =>
+ u.manifestToTypeTag(mirror.asInstanceOf[u.Mirror], manifest).in(mirror).tpe
+ }
+ }
+ })
+}
diff --git a/src/library/scala/reflect/api/TreePrinters.scala b/src/reflect/scala/reflect/api/TreePrinters.scala
index 3d64ec8e40..08a08e7b90 100644
--- a/src/library/scala/reflect/api/TreePrinters.scala
+++ b/src/reflect/scala/reflect/api/TreePrinters.scala
@@ -13,7 +13,9 @@ trait TreePrinters { self: Universe =>
def withUniqueIds: this.type = { uniqueIds = true; this }
}
- def show(tree: Tree, mkPrinter: PrintWriter => TreePrinter = newTreePrinter): String = {
+ def show(tree: Tree): String = show(tree, newTreePrinter)
+
+ def show(tree: Tree, mkPrinter: PrintWriter => TreePrinter): String = {
val buffer = new StringWriter()
val writer = new PrintWriter(buffer)
val printer = mkPrinter(writer)
@@ -29,13 +31,12 @@ trait TreePrinters { self: Universe =>
def newTreePrinter(out: PrintWriter): TreePrinter
// emits more or less verbatim representation of the provided tree
+ // [Eugene] todo. needs to be refined
+ // http://groups.google.com/group/scala-user/browse_thread/thread/de5a5be2e083cf8e
class RawTreePrinter(out: PrintWriter) extends TreePrinter {
- val EmptyValDef = self.emptyValDef
def print(args: Any*): Unit = args foreach {
case EmptyTree =>
print("EmptyTree")
- case EmptyValDef =>
- print("emptyValDef")
case tree @ TypeTree() =>
print("TypeTree()")
if (tree.tpe != null)
@@ -45,7 +46,7 @@ trait TreePrinters { self: Universe =>
case Literal(Constant(s: String)) =>
print("Literal(Constant(\"" + s + "\"))")
case tree: Tree =>
- print(tree.printingPrefix+"(")
+ print(tree.productPrefix+"(")
val it = tree.productIterator
while (it.hasNext) {
it.next() match {
@@ -69,16 +70,12 @@ trait TreePrinters { self: Universe =>
print(")")
case mods: Modifiers =>
val parts = collection.mutable.ListBuffer[String]()
- parts += "Set(" + mods.modifiers.map(_.sourceString).mkString(", ") + ")"
- parts += "newTypeName(\"" + mods.privateWithin.toString + "\")"
- parts += "List(" + mods.annotations.map{showRaw}.mkString(", ") + ")"
-
- var keep = 3
- if (keep == 3 && mods.annotations.isEmpty) keep -= 1
- if (keep == 2 && mods.privateWithin == EmptyTypeName) keep -= 1
- if (keep == 1 && mods.modifiers.isEmpty) keep -= 1
-
- print("Modifiers(", parts.take(keep).mkString(", "), ")")
+ parts += mods.flagString
+ if (mods.privateWithin.toString.nonEmpty)
+ parts += "newTypeName(\"" + mods.privateWithin.toString + "\")"
+ if (mods.annotations.nonEmpty)
+ parts += mods.annotations map showRaw mkString ("List(", ", ", ")")
+ print(parts mkString ("Modifiers(", ", ", ")"))
case name: Name =>
if (name.isTermName) print("newTermName(\"") else print("newTypeName(\"")
print(name.toString)
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala
new file mode 100644
index 0000000000..2d130daa4e
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Trees.scala
@@ -0,0 +1,689 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+package scala.reflect
+package api
+
+// Syncnote: Trees are currently not thread-safe.
+trait Trees extends base.Trees { self: Universe =>
+
+ override type Tree >: Null <: TreeApi
+
+ /** ... */
+ trait TreeApi extends TreeBase { this: Tree =>
+
+ /** ... */
+ def pos: Position
+
+ /** ... */
+ def tpe: Type
+
+ /** Note that symbol is fixed as null at this level. In SymTrees,
+ * it is overridden and implemented with a var, initialized to NoSymbol.
+ *
+ * Trees which are not SymTrees but which carry symbols do so by
+ * overriding `def symbol` to forward it elsewhere. Examples:
+ *
+ * Super(qual, _) // has qual's symbol
+ * Apply(fun, args) // has fun's symbol
+ * TypeApply(fun, args) // has fun's symbol
+ * AppliedTypeTree(tpt, args) // has tpt's symbol
+ * TypeTree(tpe) // has tpe's typeSymbol, if tpe != null
+ *
+ * Attempting to set the symbol of a Tree which does not support
+ * it will induce an exception.
+ */
+ def symbol: Symbol
+
+ /** ... */
+ def hasSymbol: Boolean
+
+ /** Provides an alternate if tree is empty
+ * @param alt The alternate tree
+ * @return If this tree is non empty, this tree, otherwise `alt`.
+ */
+ def orElse(alt: => Tree): Tree
+
+ /** Apply `f` to each subtree */
+ def foreach(f: Tree => Unit): Unit
+
+ /** Find all subtrees matching predicate `p`. Same as `filter` */
+ def withFilter(f: Tree => Boolean): List[Tree]
+
+ /** Find all subtrees matching predicate `p`. Same as `withFilter` */
+ def filter(f: Tree => Boolean): List[Tree]
+
+ /** Apply `pf' to each subtree on which the function is defined and collect the results.
+ */
+ def collect[T](pf: PartialFunction[Tree, T]): List[T]
+
+ /** Returns optionally first tree (in a preorder traversal) which satisfies predicate `p`,
+ * or None if none exists.
+ */
+ def find(p: Tree => Boolean): Option[Tree]
+
+ /** Is there exists a part of this tree which satisfies predicate `p`? */
+ def exists(p: Tree => Boolean): Boolean
+
+ /** Do all parts of this tree satisfy predicate `p`? */
+ def forAll(p: Tree => Boolean): Boolean
+
+ /** Tests whether two trees are structurall equal.
+ * Note that `==` on trees is reference equality.
+ */
+ def equalsStructure(that : Tree): Boolean
+
+ /** The direct child trees of this tree.
+ * EmptyTrees are always omitted. Lists are flattened.
+ */
+ def children: List[Tree]
+
+ /** Extracts free term symbols from a tree that is reified or contains reified subtrees.
+ */
+ def freeTerms: List[FreeTermSymbol]
+
+ /** Extracts free type symbols from a tree that is reified or contains reified subtrees.
+ */
+ def freeTypes: List[FreeTypeSymbol]
+
+ /** Substitute symbols in `to` for corresponding occurrences of references to
+ * symbols `from` in this type.
+ */
+ def substituteSymbols(from: List[Symbol], to: List[Symbol]): Tree
+
+ /** Substitute types in `to` for corresponding occurrences of references to
+ * symbols `from` in this tree.
+ */
+ def substituteTypes(from: List[Symbol], to: List[Type]): Tree
+
+ /** Substitute given tree `to` for occurrences of nodes that represent
+ * `C.this`, where `C` referes to the given class `clazz`.
+ */
+ def substituteThis(clazz: Symbol, to: Tree): Tree
+
+ /** Make a copy of this tree, keeping all attributes,
+ * except that all positions are focused (so nothing
+ * in this tree will be found when searching by position).
+ */
+ def duplicate: this.type
+ }
+
+ override type TermTree >: Null <: Tree with TermTreeApi
+
+ /** The API that all term trees support */
+ trait TermTreeApi extends TreeApi { this: TermTree =>
+ }
+
+ override type TypTree >: Null <: Tree with TypTreeApi
+
+ /** The API that all typ trees support */
+ trait TypTreeApi extends TreeApi { this: TypTree =>
+ }
+
+ override type SymTree >: Null <: Tree with SymTreeApi
+
+ /** The API that all sym trees support */
+ trait SymTreeApi extends TreeApi { this: SymTree =>
+ def symbol: Symbol
+ }
+
+ override type NameTree >: Null <: Tree with NameTreeApi
+
+ /** The API that all name trees support */
+ trait NameTreeApi extends TreeApi { this: NameTree =>
+ def name: Name
+ }
+
+ override type RefTree >: Null <: SymTree with NameTree with RefTreeApi
+
+ /** The API that all ref trees support */
+ trait RefTreeApi extends SymTreeApi with NameTreeApi { this: RefTree =>
+ def qualifier: Tree // empty for Idents
+ def name: Name
+ }
+
+ override type DefTree >: Null <: SymTree with NameTree with DefTreeApi
+
+ /** The API that all def trees support */
+ trait DefTreeApi extends SymTreeApi with NameTreeApi { this: DefTree =>
+ def name: Name
+ }
+
+ override type MemberDef >: Null <: DefTree with MemberDefApi
+
+ /** The API that all member defs support */
+ trait MemberDefApi extends DefTreeApi { this: MemberDef =>
+ def mods: Modifiers
+ }
+
+ override type PackageDef >: Null <: MemberDef with PackageDefApi
+
+ /** The API that all package defs support */
+ trait PackageDefApi extends MemberDefApi { this: PackageDef =>
+ val pid: RefTree
+ val stats: List[Tree]
+ }
+
+ override type ImplDef >: Null <: MemberDef with ImplDefApi
+
+ /** The API that all impl defs support */
+ trait ImplDefApi extends MemberDefApi { this: ImplDef =>
+ val impl: Template
+ }
+
+ override type ClassDef >: Null <: ImplDef with ClassDefApi
+
+ /** The API that all class defs support */
+ trait ClassDefApi extends ImplDefApi { this: ClassDef =>
+ val mods: Modifiers
+ val name: TypeName
+ val tparams: List[TypeDef]
+ val impl: Template
+ }
+
+ override type ModuleDef >: Null <: ImplDef with ModuleDefApi
+
+ /** The API that all module defs support */
+ trait ModuleDefApi extends ImplDefApi { this: ModuleDef =>
+ val mods: Modifiers
+ val name: TermName
+ val impl: Template
+ }
+
+ override type ValOrDefDef >: Null <: MemberDef with ValOrDefDefApi
+
+ /** The API that all val defs and def defs support */
+ trait ValOrDefDefApi extends MemberDefApi { this: ValOrDefDef =>
+ def name: Name // can't be a TermName because macros can be type names.
+ def tpt: Tree
+ def rhs: Tree
+ }
+
+ override type ValDef >: Null <: ValOrDefDef with ValDefApi
+
+ /** The API that all val defs support */
+ trait ValDefApi extends ValOrDefDefApi { this: ValDef =>
+ val mods: Modifiers
+ val name: TermName
+ val tpt: Tree
+ val rhs: Tree
+ }
+
+ override type DefDef >: Null <: ValOrDefDef with DefDefApi
+
+ /** The API that all def defs support */
+ trait DefDefApi extends ValOrDefDefApi { this: DefDef =>
+ val mods: Modifiers
+ val name: Name
+ val tparams: List[TypeDef]
+ val vparamss: List[List[ValDef]]
+ val tpt: Tree
+ val rhs: Tree
+ }
+
+ override type TypeDef >: Null <: MemberDef with TypeDefApi
+
+ /** The API that all type defs support */
+ trait TypeDefApi extends MemberDefApi { this: TypeDef =>
+ val mods: Modifiers
+ val name: TypeName
+ val tparams: List[TypeDef]
+ val rhs: Tree
+ }
+
+ override type LabelDef >: Null <: DefTree with TermTree with LabelDefApi
+
+ /** The API that all label defs support */
+ trait LabelDefApi extends DefTreeApi with TermTreeApi { this: LabelDef =>
+ val name: TermName
+ val params: List[Ident]
+ val rhs: Tree
+ }
+
+ override type ImportSelector >: Null <: ImportSelectorApi
+
+ /** The API that all import selectors support */
+ trait ImportSelectorApi { this: ImportSelector =>
+ val name: Name
+ val namePos: Int
+ val rename: Name
+ val renamePos: Int
+ }
+
+ override type Import >: Null <: SymTree with ImportApi
+
+ /** The API that all imports support */
+ trait ImportApi extends SymTreeApi { this: Import =>
+ val expr: Tree
+ val selectors: List[ImportSelector]
+ }
+
+ override type Template >: Null <: SymTree with TemplateApi
+
+ /** The API that all templates support */
+ trait TemplateApi extends SymTreeApi { this: Template =>
+ val parents: List[Tree]
+ val self: ValDef
+ val body: List[Tree]
+ }
+
+ override type Block >: Null <: TermTree with BlockApi
+
+ /** The API that all blocks support */
+ trait BlockApi extends TermTreeApi { this: Block =>
+ val stats: List[Tree]
+ val expr: Tree
+ }
+
+ override type CaseDef >: Null <: Tree with CaseDefApi
+
+ /** The API that all case defs support */
+ trait CaseDefApi extends TreeApi { this: CaseDef =>
+ val pat: Tree
+ val guard: Tree
+ val body: Tree
+ }
+
+ override type Alternative >: Null <: TermTree with AlternativeApi
+
+ /** The API that all alternatives support */
+ trait AlternativeApi extends TermTreeApi { this: Alternative =>
+ val trees: List[Tree]
+ }
+
+ override type Star >: Null <: TermTree with StarApi
+
+ /** The API that all stars support */
+ trait StarApi extends TermTreeApi { this: Star =>
+ val elem: Tree
+ }
+
+ override type Bind >: Null <: DefTree with BindApi
+
+ /** The API that all binds support */
+ trait BindApi extends DefTreeApi { this: Bind =>
+ val name: Name
+ val body: Tree
+ }
+
+ override type UnApply >: Null <: TermTree with UnApplyApi
+
+ /** The API that all unapplies support */
+ trait UnApplyApi extends TermTreeApi { this: UnApply =>
+ val fun: Tree
+ val args: List[Tree]
+ }
+
+ override type ArrayValue >: Null <: TermTree with ArrayValueApi
+
+ /** The API that all array values support */
+ trait ArrayValueApi extends TermTreeApi { this: ArrayValue =>
+ val elemtpt: Tree
+ val elems: List[Tree]
+ }
+
+ override type Function >: Null <: TermTree with SymTree with FunctionApi
+
+ /** The API that all functions support */
+ trait FunctionApi extends TermTreeApi with SymTreeApi { this: Function =>
+ val vparams: List[ValDef]
+ val body: Tree
+ }
+
+ override type Assign >: Null <: TermTree with AssignApi
+
+ /** The API that all assigns support */
+ trait AssignApi extends TermTreeApi { this: Assign =>
+ val lhs: Tree
+ val rhs: Tree
+ }
+
+ override type AssignOrNamedArg >: Null <: TermTree with AssignOrNamedArgApi
+
+ /** The API that all assigns support */
+ trait AssignOrNamedArgApi extends TermTreeApi { this: AssignOrNamedArg =>
+ val lhs: Tree
+ val rhs: Tree
+ }
+
+ override type If >: Null <: TermTree with IfApi
+
+ /** The API that all ifs support */
+ trait IfApi extends TermTreeApi { this: If =>
+ val cond: Tree
+ val thenp: Tree
+ val elsep: Tree
+ }
+
+ override type Match >: Null <: TermTree with MatchApi
+
+ /** The API that all matches support */
+ trait MatchApi extends TermTreeApi { this: Match =>
+ val selector: Tree
+ val cases: List[CaseDef]
+ }
+
+ override type Return >: Null <: TermTree with SymTree with ReturnApi
+
+ /** The API that all returns support */
+ trait ReturnApi extends TermTreeApi { this: Return =>
+ val expr: Tree
+ }
+
+ override type Try >: Null <: TermTree with TryApi
+
+ /** The API that all tries support */
+ trait TryApi extends TermTreeApi { this: Try =>
+ val block: Tree
+ val catches: List[CaseDef]
+ val finalizer: Tree
+ }
+
+ override type Throw >: Null <: TermTree with ThrowApi
+
+ /** The API that all tries support */
+ trait ThrowApi extends TermTreeApi { this: Throw =>
+ val expr: Tree
+ }
+
+ override type New >: Null <: TermTree with NewApi
+
+ /** The API that all news support */
+ trait NewApi extends TermTreeApi { this: New =>
+ val tpt: Tree
+ }
+
+ override type Typed >: Null <: TermTree with TypedApi
+
+ /** The API that all typeds support */
+ trait TypedApi extends TermTreeApi { this: Typed =>
+ val expr: Tree
+ val tpt: Tree
+ }
+
+ override type GenericApply >: Null <: TermTree with GenericApplyApi
+
+ /** The API that all applies support */
+ trait GenericApplyApi extends TermTreeApi { this: GenericApply =>
+ val fun: Tree
+ val args: List[Tree]
+ }
+
+ override type TypeApply >: Null <: GenericApply with TypeApplyApi
+
+ /** The API that all type applies support */
+ trait TypeApplyApi extends GenericApplyApi { this: TypeApply =>
+ }
+
+ override type Apply >: Null <: GenericApply with ApplyApi
+
+ /** The API that all applies support */
+ trait ApplyApi extends GenericApplyApi { this: Apply =>
+ }
+
+ override type ApplyDynamic >: Null <: TermTree with SymTree with ApplyDynamicApi
+
+ /** The API that all apply dynamics support */
+ trait ApplyDynamicApi extends TermTreeApi with SymTreeApi { this: ApplyDynamic =>
+ val qual: Tree
+ val args: List[Tree]
+ }
+
+ override type Super >: Null <: TermTree with SuperApi
+
+ /** The API that all supers support */
+ trait SuperApi extends TermTreeApi { this: Super =>
+ val qual: Tree
+ val mix: TypeName
+ }
+
+ override type This >: Null <: TermTree with SymTree with ThisApi
+
+ /** The API that all thises support */
+ trait ThisApi extends TermTreeApi with SymTreeApi { this: This =>
+ val qual: TypeName
+ }
+
+ override type Select >: Null <: RefTree with SelectApi
+
+ /** The API that all selects support */
+ trait SelectApi extends RefTreeApi { this: Select =>
+ val qualifier: Tree
+ val name: Name
+ }
+
+ override type Ident >: Null <: RefTree with IdentApi
+
+ /** The API that all idents support */
+ trait IdentApi extends RefTreeApi { this: Ident =>
+ val name: Name
+ }
+
+ override type ReferenceToBoxed >: Null <: TermTree with ReferenceToBoxedApi
+
+ /** The API that all references support */
+ trait ReferenceToBoxedApi extends TermTreeApi { this: ReferenceToBoxed =>
+ val ident: Tree
+ }
+
+ override type Literal >: Null <: TermTree with LiteralApi
+
+ /** The API that all literals support */
+ trait LiteralApi extends TermTreeApi { this: Literal =>
+ val value: Constant
+ }
+
+ override type Annotated >: Null <: Tree with AnnotatedApi
+
+ /** The API that all annotateds support */
+ trait AnnotatedApi extends TreeApi { this: Annotated =>
+ val annot: Tree
+ val arg: Tree
+ }
+
+ override type SingletonTypeTree >: Null <: TypTree with SingletonTypeTreeApi
+
+ /** The API that all singleton type trees support */
+ trait SingletonTypeTreeApi extends TypTreeApi { this: SingletonTypeTree =>
+ val ref: Tree
+ }
+
+ override type SelectFromTypeTree >: Null <: TypTree with RefTree with SelectFromTypeTreeApi
+
+ /** The API that all selects from type trees support */
+ trait SelectFromTypeTreeApi extends TypTreeApi with RefTreeApi { this: SelectFromTypeTree =>
+ val qualifier: Tree
+ val name: TypeName
+ }
+
+ override type CompoundTypeTree >: Null <: TypTree with CompoundTypeTreeApi
+
+ /** The API that all compound type trees support */
+ trait CompoundTypeTreeApi extends TypTreeApi { this: CompoundTypeTree =>
+ val templ: Template
+ }
+
+ override type AppliedTypeTree >: Null <: TypTree with AppliedTypeTreeApi
+
+ /** The API that all applied type trees support */
+ trait AppliedTypeTreeApi extends TypTreeApi { this: AppliedTypeTree =>
+ val tpt: Tree
+ val args: List[Tree]
+ }
+
+ override type TypeBoundsTree >: Null <: TypTree with TypeBoundsTreeApi
+
+ /** The API that all type bound trees support */
+ trait TypeBoundsTreeApi extends TypTreeApi { this: TypeBoundsTree =>
+ val lo: Tree
+ val hi: Tree
+ }
+
+ override type ExistentialTypeTree >: Null <: TypTree with ExistentialTypeTreeApi
+
+ /** The API that all existential type trees support */
+ trait ExistentialTypeTreeApi extends TypTreeApi { this: ExistentialTypeTree =>
+ val tpt: Tree
+ val whereClauses: List[Tree]
+ }
+
+ override type TypeTree >: Null <: TypTree with TypeTreeApi
+
+ /** The API that all type trees support */
+ trait TypeTreeApi extends TypTreeApi { this: TypeTree =>
+ def original: Tree
+ }
+
+ /** An empty deferred value definition corresponding to:
+ * val _: _
+ * This is used as a placeholder in the `self` parameter Template if there is
+ * no definition of a self value of self type.
+ */
+ val emptyValDef: ValDef
+
+// ---------------------- copying ------------------------------------------------
+
+ /** The standard (lazy) tree copier
+ */
+ type TreeCopier <: TreeCopierOps
+ val treeCopy: TreeCopier = newLazyTreeCopier
+
+ def newStrictTreeCopier: TreeCopier
+ def newLazyTreeCopier: TreeCopier
+
+ /** The API of a tree copier
+ * tree copiers are made available by an implicit conversion in reflect.ops
+ */
+ abstract class TreeCopierOps {
+ def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template): ClassDef
+ def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]): PackageDef
+ def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template): ModuleDef
+ def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree): ValDef
+ def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef
+ def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree): TypeDef
+ def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef
+ def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]): Import
+ def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]): Template
+ def Block(tree: Tree, stats: List[Tree], expr: Tree): Block
+ def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree): CaseDef
+ def Alternative(tree: Tree, trees: List[Tree]): Alternative
+ def Star(tree: Tree, elem: Tree): Star
+ def Bind(tree: Tree, name: Name, body: Tree): Bind
+ def UnApply(tree: Tree, fun: Tree, args: List[Tree]): UnApply
+ def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]): ArrayValue
+ def Function(tree: Tree, vparams: List[ValDef], body: Tree): Function
+ def Assign(tree: Tree, lhs: Tree, rhs: Tree): Assign
+ def AssignOrNamedArg(tree: Tree, lhs: Tree, rhs: Tree): AssignOrNamedArg
+ def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree): If
+ def Match(tree: Tree, selector: Tree, cases: List[CaseDef]): Match
+ def Return(tree: Tree, expr: Tree): Return
+ def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree): Try
+ def Throw(tree: Tree, expr: Tree): Throw
+ def New(tree: Tree, tpt: Tree): New
+ def Typed(tree: Tree, expr: Tree, tpt: Tree): Typed
+ def TypeApply(tree: Tree, fun: Tree, args: List[Tree]): TypeApply
+ def Apply(tree: Tree, fun: Tree, args: List[Tree]): Apply
+ def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]): ApplyDynamic
+ def Super(tree: Tree, qual: Tree, mix: TypeName): Super
+ def This(tree: Tree, qual: Name): This
+ def Select(tree: Tree, qualifier: Tree, selector: Name): Select
+ def Ident(tree: Tree, name: Name): Ident
+ def ReferenceToBoxed(tree: Tree, idt: Ident): ReferenceToBoxed
+ def Literal(tree: Tree, value: Constant): Literal
+ def TypeTree(tree: Tree): TypeTree
+ def Annotated(tree: Tree, annot: Tree, arg: Tree): Annotated
+ def SingletonTypeTree(tree: Tree, ref: Tree): SingletonTypeTree
+ def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name): SelectFromTypeTree
+ def CompoundTypeTree(tree: Tree, templ: Template): CompoundTypeTree
+ def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]): AppliedTypeTree
+ def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree): TypeBoundsTree
+ def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
+ }
+
+// ---------------------- traversing and transforming ------------------------------
+
+ class Traverser {
+ protected[scala] var currentOwner: Symbol = rootMirror.RootClass
+
+ def traverse(tree: Tree): Unit = itraverse(this, tree)
+
+ def traverseTrees(trees: List[Tree]) {
+ trees foreach traverse
+ }
+ def traverseTreess(treess: List[List[Tree]]) {
+ treess foreach traverseTrees
+ }
+ def traverseStats(stats: List[Tree], exprOwner: Symbol) {
+ stats foreach (stat =>
+ if (exprOwner != currentOwner) atOwner(exprOwner)(traverse(stat))
+ else traverse(stat)
+ )
+ }
+
+ def atOwner(owner: Symbol)(traverse: => Unit) {
+ val prevOwner = currentOwner
+ currentOwner = owner
+ traverse
+ currentOwner = prevOwner
+ }
+
+ /** Leave apply available in the generic traverser to do something else.
+ */
+ def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
+ }
+
+ protected def itraverse(traverser: Traverser, tree: Tree): Unit = throw new MatchError(tree)
+
+ protected def xtraverse(traverser: Traverser, tree: Tree): Unit = throw new MatchError(tree)
+
+ abstract class Transformer {
+ val treeCopy: TreeCopier = newLazyTreeCopier
+ protected[scala] var currentOwner: Symbol = rootMirror.RootClass
+ protected def currentMethod = currentOwner.enclosingMethod
+ protected def currentClass = currentOwner.enclosingClass
+// protected def currentPackage = currentOwner.enclosingTopLevelClass.owner
+ def transform(tree: Tree): Tree = itransform(this, tree)
+
+ def transformTrees(trees: List[Tree]): List[Tree] =
+ trees mapConserve (transform(_))
+ def transformTemplate(tree: Template): Template =
+ transform(tree: Tree).asInstanceOf[Template]
+ def transformTypeDefs(trees: List[TypeDef]): List[TypeDef] =
+ trees mapConserve (tree => transform(tree).asInstanceOf[TypeDef])
+ def transformValDef(tree: ValDef): ValDef =
+ if (tree.isEmpty) tree else transform(tree).asInstanceOf[ValDef]
+ def transformValDefs(trees: List[ValDef]): List[ValDef] =
+ trees mapConserve (transformValDef(_))
+ def transformValDefss(treess: List[List[ValDef]]): List[List[ValDef]] =
+ treess mapConserve (transformValDefs(_))
+ def transformCaseDefs(trees: List[CaseDef]): List[CaseDef] =
+ trees mapConserve (tree => transform(tree).asInstanceOf[CaseDef])
+ def transformIdents(trees: List[Ident]): List[Ident] =
+ trees mapConserve (tree => transform(tree).asInstanceOf[Ident])
+ def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] =
+ stats mapConserve (stat =>
+ if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat))
+ else transform(stat)) filter (EmptyTree != _)
+ def transformModifiers(mods: Modifiers): Modifiers =
+ mods.mapAnnotations(transformTrees)
+
+ def atOwner[A](owner: Symbol)(trans: => A): A = {
+ val prevOwner = currentOwner
+ currentOwner = owner
+ val result = trans
+ currentOwner = prevOwner
+ result
+ }
+ }
+
+ protected def itransform(transformer: Transformer, tree: Tree): Tree = throw new MatchError(tree)
+
+ protected def xtransform(transformer: Transformer, tree: Tree): Tree = throw new MatchError(tree)
+
+ type Modifiers >: Null <: ModifiersApi
+
+ abstract class ModifiersApi extends ModifiersBase with HasFlagsApi
+
+}
+
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala
new file mode 100644
index 0000000000..b62a92cbd7
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Types.scala
@@ -0,0 +1,368 @@
+package scala.reflect
+package api
+
+trait Types extends base.Types { self: Universe =>
+
+ override type Type >: Null <: TypeApi
+
+ /** The extended API of types
+ */
+ abstract class TypeApi extends TypeBase {
+
+ /** The defined or declared members with name `name` in this type;
+ * an OverloadedSymbol if several exist, NoSymbol if none exist.
+ * Alternatives of overloaded symbol appear in the order they are declared.
+ */
+ def declaration(name: Name): Symbol
+
+ /** The collection of declarations in this type
+ * [Eugene++] why not List?
+ */
+ def declarations: Iterable[Symbol]
+
+ /** The member with given name, either directly declared or inherited,
+ * an OverloadedSymbol if several exist, NoSymbol if none exist.
+ */
+ def member(name: Name): Symbol
+
+ /** The non-private member with given name, either directly declared or inherited,
+ * an OverloadedSymbol if several exist, NoSymbol if none exist.
+ */
+ def nonPrivateMember(name: Name): Symbol
+
+ /** An iterable containing all members of this type (directly declared or inherited)
+ * Members appear in the linearization order of their owners.
+ * Members with the same owner appear in reverse order of their declarations.
+ * [Eugene++] the order needs to be reversed back, at least in the public API
+ */
+ def members: Iterable[Symbol]
+
+ /** An iterable containing all non-private members of this type (directly declared or inherited)
+ * Members appear in the linearization order of their owners.
+ * Members with the same owner appear in reverse order of their declarations.
+ */
+ def nonPrivateMembers: Iterable[Symbol]
+
+ /** Substitute symbols in `to` for corresponding occurrences of references to
+ * symbols `from` in this type.
+ */
+ def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type
+
+ /** Substitute types in `to` for corresponding occurrences of references to
+ * symbols `from` in this type.
+ */
+ def substituteTypes(from: List[Symbol], to: List[Type]): Type
+
+ /** If this is a parameterized types, the type arguments.
+ * Otherwise the empty list
+ */
+ def typeArguments: List[Type]
+
+ /** For a (potentially wrapped) poly type, its type parameters,
+ * the empty list for all other types */
+ def typeParams: List[Symbol]
+
+ /** Is this type a type constructor that is missing its type arguments?
+ */
+ def isHigherKinded: Boolean // !!! This should be called "isTypeConstructor", no?
+
+ /** Returns the corresponding type constructor (e.g. List for List[T] or List[String])
+ */
+ def typeConstructor: Type
+
+ /** Does this type refer to spliceable types or is a spliceable type?
+ */
+ def isConcrete: Boolean
+
+ /** Is this type an abstract type that needs to be resolved?
+ */
+ def isSpliceable: Boolean
+
+ /**
+ * Expands type aliases and converts higher-kinded TypeRefs to PolyTypes.
+ * Functions on types are also implemented as PolyTypes.
+ *
+ * Example: (in the below, <List> is the type constructor of List)
+ * TypeRef(pre, <List>, List()) is replaced by
+ * PolyType(X, TypeRef(pre, <List>, List(X)))
+ */
+ def normalize: Type // !!! Alternative name? "normalize" is used to mean too many things.
+
+ /** Does this type conform to given type argument `that`? */
+ def <:< (that: Type): Boolean
+
+ /** Is this type equivalent to given type argument `that`? */
+ def =:= (that: Type): Boolean
+
+ /** The list of all base classes of this type (including its own typeSymbol)
+ * in reverse linearization order, starting with the class itself and ending
+ * in class Any.
+ */
+ def baseClasses: List[Symbol] // !!! Alternative name, perhaps linearization?
+
+ /** The least type instance of given class which is a supertype
+ * of this type. Example:
+ * {{{
+ * class D[T]
+ * class C extends p.D[Int]
+ * ThisType(C).baseType(D) = p.D[Int]
+ * }}}
+ */
+ def baseType(clazz: Symbol): Type
+
+ /** This type as seen from prefix `pre` and class `clazz`. This means:
+ * Replace all thistypes of `clazz` or one of its subclasses
+ * by `pre` and instantiate all parameters by arguments of `pre`.
+ * Proceed analogously for thistypes referring to outer classes.
+ *
+ * Example:
+ * {{{
+ * class D[T] { def m: T }
+ * class C extends p.D[Int]
+ * T.asSeenFrom(ThisType(C), D) (where D is owner of m)
+ * = Int
+ * }}}
+ */
+ def asSeenFrom(pre: Type, clazz: Symbol): Type
+
+ /** The erased type corresponding to this type after
+ * all transformations from Scala to Java have been performed.
+ */
+ def erasure: Type // !!! "erasedType", compare with "widen" (so "erase") or "underlying" (so "erased")
+ // why not name it "erasure"?
+
+ /** Apply `f` to each part of this type, returning
+ * a new type. children get mapped before their parents */
+ def map(f: Type => Type): Type
+
+ /** Apply `f` to each part of this type, for side effects only */
+ def foreach(f: Type => Unit)
+
+ /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`,
+ * or None if none exists.
+ */
+ def find(p: Type => Boolean): Option[Type]
+
+ /** Is there part of this type which satisfies predicate `p`? */
+ def exists(p: Type => Boolean): Boolean
+
+ /** Does this type contain a reference to given symbol? */
+ def contains(sym: Symbol): Boolean
+
+ /** If this is a compound type, the list of its parent types;
+ * otherwise the empty list
+ */
+ def parents: List[Type]
+
+ /** If this is a singleton type, returns the type underlying it;
+ * otherwise returns this type itself.
+ */
+ def underlying: Type
+
+ /** If this is a singleton type, widen it to its nearest underlying non-singleton
+ * base type by applying one or more `underlying` dereferences.
+ * If this is not a singleton type, returns this type itself.
+ *
+ * Example:
+ *
+ * class Outer { class C ; val x: C }
+ * val o: Outer
+ * <o.x.type>.widen = o.C
+ */
+ def widen: Type
+
+ /** The string discriminator of this type; useful for debugging */
+ def kind: String
+ }
+
+ /** .. */
+ override type ThisType >: Null <: SingletonType with ThisTypeApi
+
+ /** The API that all this types support */
+ trait ThisTypeApi extends TypeApi { this: ThisType =>
+ val sym: Symbol
+ }
+
+ /** .. */
+ override type SingleType >: Null <: SingletonType with SingleTypeApi
+
+ /** The API that all single types support */
+ trait SingleTypeApi extends TypeApi { this: SingleType =>
+ val pre: Type
+ val sym: Symbol
+ }
+
+ /** .. */
+ override type SuperType >: Null <: SingletonType with SuperTypeApi
+
+ /** The API that all super types support */
+ trait SuperTypeApi extends TypeApi { this: SuperType =>
+ val thistpe: Type
+ val supertpe: Type
+ }
+
+ /** .. */
+ override type ConstantType >: Null <: SingletonType with ConstantTypeApi
+
+ /** The API that all constant types support */
+ trait ConstantTypeApi extends TypeApi { this: ConstantType =>
+ val value: Constant
+ }
+
+ /** .. */
+ override type TypeRef >: Null <: Type with TypeRefApi
+
+ /** The API that all type refs support */
+ trait TypeRefApi extends TypeApi { this: TypeRef =>
+ val pre: Type
+ val sym: Symbol
+ val args: List[Type]
+ }
+
+ /** .. */
+ override type RefinedType >: Null <: CompoundType with RefinedTypeApi
+
+ /** The API that all refined types support */
+ trait RefinedTypeApi extends TypeApi { this: RefinedType =>
+ val parents: List[Type]
+ val decls: Scope
+ }
+
+ /** .. */
+ override type ClassInfoType >: Null <: CompoundType with ClassInfoTypeApi
+
+ /** The API that all class info types support */
+ trait ClassInfoTypeApi extends TypeApi { this: ClassInfoType =>
+ val parents: List[Type]
+ val decls: Scope
+ val typeSymbol: Symbol
+ }
+
+ /** .. */
+ override type MethodType >: Null <: Type with MethodTypeApi
+
+ /** The API that all method types support */
+ trait MethodTypeApi extends TypeApi { this: MethodType =>
+ val params: List[Symbol]
+ val resultType: Type
+ }
+
+ /** .. */
+ override type NullaryMethodType >: Null <: Type with NullaryMethodTypeApi
+
+ /** The API that all nullary method types support */
+ trait NullaryMethodTypeApi extends TypeApi { this: NullaryMethodType =>
+ val resultType: Type
+ }
+
+ /** .. */
+ override type PolyType >: Null <: Type with PolyTypeApi
+
+ /** The API that all polymorphic types support */
+ trait PolyTypeApi extends TypeApi { this: PolyType =>
+ val typeParams: List[Symbol]
+ val resultType: Type
+ }
+
+ /** .. */
+ override type ExistentialType >: Null <: Type with ExistentialTypeApi
+
+ /** The API that all existential types support */
+ trait ExistentialTypeApi extends TypeApi { this: ExistentialType =>
+ val quantified: List[Symbol]
+ val underlying: Type
+ }
+
+ /** .. */
+ override type AnnotatedType >: Null <: Type with AnnotatedTypeApi
+
+ /** The API that all annotated types support */
+ trait AnnotatedTypeApi extends TypeApi { this: AnnotatedType =>
+ val annotations: List[AnnotationInfo]
+ val underlying: Type
+ val selfsym: Symbol
+ }
+
+ /** .. */
+ override type TypeBounds >: Null <: Type with TypeBoundsApi
+
+ /** The API that all type bounds support */
+ trait TypeBoundsApi extends TypeApi { this: TypeBounds =>
+ val lo: Type
+ val hi: Type
+ }
+
+ /** .. */
+ override type BoundedWildcardType >: Null <: Type with BoundedWildcardTypeApi
+
+ /** The API that all this types support */
+ trait BoundedWildcardTypeApi extends TypeApi { this: BoundedWildcardType =>
+ val bounds: TypeBounds
+ }
+
+ /** The least upper bound of a list of types, as determined by `<:<`. */
+ def lub(xs: List[Type]): Type
+
+ /** The greatest lower bound of a list of types, as determined by `<:<`. */
+ def glb(ts: List[Type]): Type
+
+ // Creators ---------------------------------------------------------------
+ // too useful and too non-trivial to be left out of public API
+ // [Eugene to Paul] needs review!
+
+ /** The canonical creator for single-types */
+ def singleType(pre: Type, sym: Symbol): Type
+
+ /** the canonical creator for a refined type with a given scope */
+ def refinedType(parents: List[Type], owner: Symbol, decls: Scope, pos: Position): Type
+
+ /** The canonical creator for a refined type with an initially empty scope.
+ */
+ def refinedType(parents: List[Type], owner: Symbol): Type
+
+ /** The canonical creator for typerefs
+ */
+ def typeRef(pre: Type, sym: Symbol, args: List[Type]): Type
+
+ /** A creator for intersection type where intersections of a single type are
+ * replaced by the type itself. */
+ def intersectionType(tps: List[Type]): Type
+
+ /** A creator for intersection type where intersections of a single type are
+ * replaced by the type itself, and repeated parent classes are merged.
+ *
+ * !!! Repeated parent classes are not merged - is this a bug in the
+ * comment or in the code?
+ */
+ def intersectionType(tps: List[Type], owner: Symbol): Type
+
+ /** A creator for type applications */
+ def appliedType(tycon: Type, args: List[Type]): Type
+
+ /** A creator for type parameterizations that strips empty type parameter lists.
+ * Use this factory method to indicate the type has kind * (it's a polymorphic value)
+ * until we start tracking explicit kinds equivalent to typeFun (except that the latter requires tparams nonEmpty).
+ */
+ def polyType(tparams: List[Symbol], tpe: Type): Type
+
+ /** A creator for existential types. This generates:
+ *
+ * {{{
+ * tpe1 where { tparams }
+ * }}}
+ *
+ * where `tpe1` is the result of extrapolating `tpe` with regard to `tparams`.
+ * Extrapolating means that type variables in `tparams` occurring
+ * in covariant positions are replaced by upper bounds, (minus any
+ * SingletonClass markers), type variables in `tparams` occurring in
+ * contravariant positions are replaced by upper bounds, provided the
+ * resulting type is legal with regard to stability, and does not contain
+ * any type variable in `tparams`.
+ *
+ * The abstraction drops all type parameters that are not directly or
+ * indirectly referenced by type `tpe1`. If there are no remaining type
+ * parameters, simply returns result type `tpe`.
+ */
+ def existentialAbstraction(tparams: List[Symbol], tpe0: Type): Type
+}
+
diff --git a/src/library/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala
index 05b5963c73..002cd2e673 100755..100644
--- a/src/library/scala/reflect/api/Universe.scala
+++ b/src/reflect/scala/reflect/api/Universe.scala
@@ -3,25 +3,22 @@ package api
import language.experimental.macros
-abstract class Universe extends Symbols
- with FreeVars
+abstract class Universe extends base.Universe
+ with Symbols
with Types
- with Constants
- with Scopes
+ with FlagSets
with Names
with Trees
- with AnnotationInfos
+ with TreePrinters
+ with Constants
with Positions
- with Exprs
+ with Mirrors
with StandardDefinitions
- with TypeTags
- with TreePrinters
with StandardNames
- with ClassLoaders
- with TreeBuildUtil
- with ToolBoxes
- with FrontEnds
- with Importers {
+ with Importers
+ with Exprs
+ with AnnotationInfos
+{
/** Given an expression, generate a tree that when compiled and executed produces the original tree.
* The produced tree will be bound to the Universe it was called from.
@@ -33,20 +30,20 @@ abstract class Universe extends Symbols
* }}}
*
* The reifier transforms it to the following expression:
- *
+ *
* {{{
* <[
- * val $mr: scala.reflect.api.Universe = <reference to the Universe that calls the reify>
- * $mr.Expr[Int]($mr.Apply($mr.Select($mr.Ident($mr.newFreeVar("x", <Int>, x), "+"), List($mr.Literal($mr.Constant(1))))))
+ * val $u: u.type = u // where u is a reference to the Universe that calls the reify
+ * $u.Expr[Int]($u.Apply($u.Select($u.Ident($u.newFreeVar("x", <Int>, x), "+"), List($u.Literal($u.Constant(1))))))
* ]>
* }}}
*
- * Reification performs expression splicing (when processing Expr.eval and Expr.value)
+ * Reification performs expression splicing (when processing Expr.splice)
* and type splicing (for every type T that has a TypeTag[T] implicit in scope):
*
* {{{
- * val two = mirror.reify(2) // Literal(Constant(2))
- * val four = mirror.reify(two.eval + two.eval) // Apply(Select(two.tree, newTermName("$plus")), List(two.tree))
+ * val two = mirror.reify(2) // Literal(Constant(2))
+ * val four = mirror.reify(two.splice + two.splice) // Apply(Select(two.tree, newTermName("$plus")), List(two.tree))
*
* def macroImpl[T](c: Context) = {
* ...
@@ -66,12 +63,6 @@ abstract class Universe extends Symbols
* * Since reified trees can be compiled outside of the scope they've been created in,
* special measures are taken to ensure that all members accessed in the reifee remain visible
*/
- def reify[T](expr: T): Expr[T] = macro Universe.reify[T]
-}
-
-object Universe {
- def reify[T](cc: scala.reflect.makro.Context{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = {
- import scala.reflect.makro.internal._
- cc.Expr(cc.materializeExpr(cc.prefix.tree, expr.tree))
- }
-}
+ // implementation is magically hardwired to `scala.reflect.reify.Taggers`
+ def reify[T](expr: T): Expr[T] = macro ???
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/api/package.scala b/src/reflect/scala/reflect/api/package.scala
new file mode 100644
index 0000000000..d2fce7cf1d
--- /dev/null
+++ b/src/reflect/scala/reflect/api/package.scala
@@ -0,0 +1,12 @@
+package scala.reflect
+
+package object api {
+
+ // type and value aliases for slices of the base Universe cake that are not
+ // repeated in api.Universe
+ type Scopes = base.Scopes
+ type BuildUtils = base.BuildUtils
+ type Attachments = base.Attachments
+
+ type MirrorOf[U <: base.Universe with Singleton] = base.MirrorOf[U]
+}
diff --git a/src/library/scala/reflect/api/RequiredFile.scala b/src/reflect/scala/reflect/internal/AbstractFileApi.scala
index 4a54595940..9f37f4536f 100644
--- a/src/library/scala/reflect/api/RequiredFile.scala
+++ b/src/reflect/scala/reflect/internal/AbstractFileApi.scala
@@ -1,7 +1,7 @@
package scala.reflect
-package api
+package internal
-trait RequiredFile {
+trait AbstractFileApi {
def path: String
def canonicalPath: String
}
diff --git a/src/compiler/scala/reflect/internal/AnnotationCheckers.scala b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala
index 449b0ca0bc..449b0ca0bc 100644
--- a/src/compiler/scala/reflect/internal/AnnotationCheckers.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala
diff --git a/src/compiler/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
index 91e1c3d50d..c283ae408e 100644
--- a/src/compiler/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
@@ -46,23 +46,26 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
* - or nested classfile annotations
*/
abstract class ClassfileAnnotArg extends Product
+ implicit val ClassfileAnnotArgTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
/** Represents a compile-time Constant (`Boolean`, `Byte`, `Short`,
* `Char`, `Int`, `Long`, `Float`, `Double`, `String`, `java.lang.Class` or
* an instance of a Java enumeration value).
*/
case class LiteralAnnotArg(const: Constant)
- extends ClassfileAnnotArg {
+ extends ClassfileAnnotArg with LiteralAnnotArgApi {
override def toString = const.escapedStringValue
}
+ implicit val LiteralAnnotArgTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
object LiteralAnnotArg extends LiteralAnnotArgExtractor
/** Represents an array of classfile annotation arguments */
case class ArrayAnnotArg(args: Array[ClassfileAnnotArg])
- extends ClassfileAnnotArg {
+ extends ClassfileAnnotArg with ArrayAnnotArgApi {
override def toString = args.mkString("[", ", ", "]")
}
+ implicit val ArrayAnnotArgTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
object ArrayAnnotArg extends ArrayAnnotArgExtractor
@@ -105,11 +108,12 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
}
/** Represents a nested classfile annotation */
- case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg {
+ case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg with NestedAnnotArgApi {
// The nested annotation should not have any Scala annotation arguments
assert(annInfo.args.isEmpty, annInfo.args)
override def toString = annInfo.toString
}
+ implicit val NestedAnnotArgTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
object NestedAnnotArg extends NestedAnnotArgExtractor
@@ -191,7 +195,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
*
* `assocs` stores arguments to classfile annotations as name-value pairs.
*/
- sealed abstract class AnnotationInfo {
+ sealed abstract class AnnotationInfo extends AnnotationInfoApi {
def atp: Type
def args: List[Tree]
def assocs: List[(Name, ClassfileAnnotArg)]
@@ -258,7 +262,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
/** Change all ident's with Symbol "from" to instead use symbol "to" */
def substIdentSyms(from: Symbol, to: Symbol) =
- AnnotationInfo(atp, args map (_ substTreeSyms (from -> to)), assocs) setPos pos
+ AnnotationInfo(atp, args map (_ substituteSymbols (List(from), List(to))), assocs) setPos pos
def stringArg(index: Int) = constantAtIndex(index) map (_.stringValue)
def intArg(index: Int) = constantAtIndex(index) map (_.intValue)
@@ -283,7 +287,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
}
}
- lazy val classfileAnnotArgTag: ArrayTag[ClassfileAnnotArg] = arrayTag[ClassfileAnnotArg]
+ implicit val AnnotationInfoTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
object UnmappableAnnotation extends CompleteAnnotationInfo(NoType, Nil, Nil)
}
diff --git a/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala
index 3753a45133..5f78671012 100644
--- a/src/compiler/scala/reflect/internal/BaseTypeSeqs.scala
+++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala
@@ -127,38 +127,11 @@ trait BaseTypeSeqs {
def exists(p: Type => Boolean): Boolean = elems exists p
- lazy val maxDepth: Int = maxDepthOfElems
+ lazy val maxDepth = maxDepthOfElems
- protected def maxDepthOfElems = {
+ protected def maxDepthOfElems: Int = {
var d = 0
- for (i <- 0 until length) d = max(d, maxDpth(elems(i)))
- d
- }
-
- /** The maximum depth of type `tp` */
- protected def maxDpth(tp: Type): Int = tp match {
- case TypeRef(pre, sym, args) =>
- max(maxDpth(pre), maxDpth(args) + 1)
- case RefinedType(parents, decls) =>
- max(maxDpth(parents), maxDpth(decls.toList.map(_.info)) + 1)
- case TypeBounds(lo, hi) =>
- max(maxDpth(lo), maxDpth(hi))
- case MethodType(paramtypes, result) =>
- maxDpth(result)
- case NullaryMethodType(result) =>
- maxDpth(result)
- case PolyType(tparams, result) =>
- max(maxDpth(result), maxDpth(tparams map (_.info)) + 1)
- case ExistentialType(tparams, result) =>
- max(maxDpth(result), maxDpth(tparams map (_.info)) + 1)
- case _ =>
- 1
- }
-
- /** The maximum depth of all types `tps` */
- private def maxDpth(tps: Seq[Type]): Int = {
- var d = 0
- for (tp <- tps) d = max(d, maxDpth(tp))
+ for (i <- 1 until length) d = max(d, typeDepth(elems(i)))
d
}
@@ -225,9 +198,9 @@ trait BaseTypeSeqs {
nextRawElem(i) match {
case RefinedType(variants, decls) =>
for (tp <- variants)
- if (!(minTypes exists (tp =:=))) minTypes = tp :: minTypes
+ if (!(minTypes exists (tp =:= _))) minTypes = tp :: minTypes
case tp =>
- if (!(minTypes exists (tp =:=))) minTypes = tp :: minTypes
+ if (!(minTypes exists (tp =:= _))) minTypes = tp :: minTypes
}
index(i) = index(i) + 1
}
@@ -252,7 +225,7 @@ trait BaseTypeSeqs {
override def map(g: Type => Type) = lateMap(g)
override def lateMap(g: Type => Type) = orig.lateMap(x => g(f(x)))
override def exists(p: Type => Boolean) = elems exists (x => p(f(x)))
- override protected def maxDepthOfElems: Int = elems map (x => maxDpth(f(x))) max
+ override protected def maxDepthOfElems: Int = elems map (x => typeDepth(f(x))) max
override def toString = elems.mkString("MBTS(", ",", ")")
}
diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala
new file mode 100644
index 0000000000..3bde57ded8
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/BuildUtils.scala
@@ -0,0 +1,69 @@
+package scala.reflect
+package internal
+
+import Flags._
+
+trait BuildUtils extends base.BuildUtils { self: SymbolTable =>
+
+ class BuildImpl extends BuildBase {
+
+ def selectType(owner: Symbol, name: String): TypeSymbol = {
+ val result = owner.info.decl(newTypeName(name))
+ if (result ne NoSymbol) result.asTypeSymbol
+ else MissingRequirementError.notFound("type %s in %s".format(name, owner.fullName))
+ }
+
+ def selectTerm(owner: Symbol, name: String): TermSymbol = {
+ val sym = owner.info.decl(newTermName(name))
+ val result =
+ if (sym.isOverloaded) sym.suchThat(!_.isMethod)
+ else sym
+ if (result ne NoSymbol) result.asTermSymbol
+ else MissingRequirementError.notFound("term %s in %s".format(name, owner.fullName))
+ }
+
+ def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = {
+ val result = owner.info.decl(newTermName(name)).alternatives(index)
+ if (result ne NoSymbol) result.asMethodSymbol
+ else MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName))
+ }
+
+ def newFreeTerm(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol =
+ newFreeTermSymbol(newTermName(name), info, value, flags, origin)
+
+ def newFreeType(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
+ newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) PARAM else flags) | DEFERRED, origin)
+
+ def newFreeExistential(name: String, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
+ newFreeTypeSymbol(newTypeName(name), info, value, (if (flags == 0L) EXISTENTIAL else flags) | DEFERRED, origin)
+
+ def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol =
+ owner.newNestedSymbol(name, pos, flags, isClass)
+
+ def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S =
+ sym.setAnnotations(annots)
+
+ def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S =
+ sym.setTypeSignature(tpe)
+
+ def flagsFromBits(bits: Long): FlagSet = bits
+
+ def emptyValDef: ValDef = self.emptyValDef
+
+ def This(sym: Symbol): Tree = self.This(sym)
+
+ def Select(qualifier: Tree, sym: Symbol): Select = self.Select(qualifier, sym)
+
+ def Ident(sym: Symbol): Ident = self.Ident(sym)
+
+ def TypeTree(tp: Type): TypeTree = self.TypeTree(tp)
+
+ def thisPrefix(sym: Symbol): Type = sym.thisPrefix
+
+ def setType[T <: Tree](tree: T, tpe: Type): T = { tree.setType(tpe); tree }
+
+ def setSymbol[T <: Tree](tree: T, sym: Symbol): T = { tree.setSymbol(sym); tree }
+ }
+
+ val build: BuildBase = new BuildImpl
+}
diff --git a/src/compiler/scala/reflect/internal/CapturedVariables.scala b/src/reflect/scala/reflect/internal/CapturedVariables.scala
index 77909d9157..77909d9157 100644
--- a/src/compiler/scala/reflect/internal/CapturedVariables.scala
+++ b/src/reflect/scala/reflect/internal/CapturedVariables.scala
diff --git a/src/compiler/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala
index f2c90a6721..50ec71094a 100644
--- a/src/compiler/scala/reflect/internal/Chars.scala
+++ b/src/reflect/scala/reflect/internal/Chars.scala
@@ -2,10 +2,12 @@
* Copyright 2006-2011 LAMP/EPFL
* @author Martin Odersky
*/
-package scala.reflect.internal
+package scala.reflect
+package internal
import annotation.{ tailrec, switch }
import java.lang.{ Character => JCharacter }
+import language.postfixOps
/** Contains constants and classifier methods for characters */
trait Chars {
diff --git a/src/compiler/scala/reflect/internal/ClassfileConstants.scala b/src/reflect/scala/reflect/internal/ClassfileConstants.scala
index 3346e9cccb..3346e9cccb 100644
--- a/src/compiler/scala/reflect/internal/ClassfileConstants.scala
+++ b/src/reflect/scala/reflect/internal/ClassfileConstants.scala
diff --git a/src/compiler/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala
index 861bc870a7..820dfe0868 100644
--- a/src/compiler/scala/reflect/internal/Constants.scala
+++ b/src/reflect/scala/reflect/internal/Constants.scala
@@ -30,7 +30,7 @@ trait Constants extends api.Constants {
// For supporting java enumerations inside java annotations (see ClassfileParser)
final val EnumTag = 13
- case class Constant(value: Any) extends AbsConstant {
+ case class Constant(value: Any) extends ConstantApi {
val tag: Int = value match {
case null => NullTag
case x: Unit => UnitTag
@@ -235,4 +235,6 @@ trait Constants extends api.Constants {
}
object Constant extends ConstantExtractor
+
+ implicit val ConstantTag = ClassTag[Constant](classOf[Constant])
}
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 0cdef9e79a..a9d9b06621 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -10,11 +10,13 @@ import annotation.{ switch, meta }
import scala.collection.{ mutable, immutable }
import Flags._
import PartialFunction._
-import scala.reflect.{ mirror => rm }
+import scala.reflect.base.{Universe => BaseUniverse}
-trait Definitions extends reflect.api.StandardDefinitions {
+trait Definitions extends api.StandardDefinitions {
self: SymbolTable =>
+ import rootMirror.{getModule, getClassByName, getRequiredClass, getRequiredModule, getRequiredPackage, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageObjectIfDefined, requiredClass, requiredModule}
+
object definitions extends DefinitionsClass
// [Eugene] find a way to make these non-lazy
@@ -99,7 +101,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
case _ => catastrophicFailure()
}
}
- private def valueCompanionMember(className: Name, methodName: TermName): MethodSymbol =
+ private def valueCompanionMember(className: Name, methodName: TermName): TermSymbol =
getMemberMethod(valueClassCompanion(className.toTermName).moduleClass, methodName)
private def classesMap[T](f: Name => T) = symbolsMap(ScalaValueClassesNoUnit, f)
@@ -111,7 +113,7 @@ trait Definitions extends reflect.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 boxedClass = classesMap(x => getClass(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"))
lazy val boxMethod = classesMap(x => valueCompanionMember(x, nme.box))
@@ -138,9 +140,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val FloatClass = valueClassSymbol(tpnme.Float)
lazy val DoubleClass = valueClassSymbol(tpnme.Double)
lazy val BooleanClass = valueClassSymbol(tpnme.Boolean)
- lazy val Boolean_and = getMember(BooleanClass, nme.ZAND)
- lazy val Boolean_or = getMember(BooleanClass, nme.ZOR)
- lazy val Boolean_not = getMember(BooleanClass, nme.UNARY_!)
+ lazy val Boolean_and = getMemberMethod(BooleanClass, nme.ZAND)
+ lazy val Boolean_or = getMemberMethod(BooleanClass, nme.ZOR)
+ lazy val Boolean_not = getMemberMethod(BooleanClass, nme.UNARY_!)
lazy val ScalaNumericValueClasses = ScalaValueClasses filterNot Set[Symbol](UnitClass, BooleanClass)
@@ -160,68 +162,33 @@ trait Definitions extends reflect.api.StandardDefinitions {
def ScalaPrimitiveValueClasses: List[ClassSymbol] = ScalaValueClasses
}
- abstract class DefinitionsClass extends AbsDefinitions with ValueClassDefinitions {
+ abstract class DefinitionsClass extends DefinitionsApi with ValueClassDefinitions {
private var isInitialized = false
def isDefinitionsInitialized = isInitialized
// symbols related to packages
var emptypackagescope: Scope = null //debug
- // TODO - having these as objects means they elude the attempt to
- // add synchronization in SynchronizedSymbols. But we should either
- // flip on object overrides or find some other accomodation, because
- // lazy vals are unnecessarily expensive relative to objects and it
- // is very beneficial for a handful of bootstrap symbols to have
- // first class identities
- sealed trait WellKnownSymbol extends Symbol {
- this initFlags TopLevelCreationFlags
- }
- // Features common to RootClass and RootPackage, the roots of all
- // type and term symbols respectively.
- sealed trait RootSymbol extends WellKnownSymbol {
- final override def isRootSymbol = true
- override def owner = NoSymbol
- override def typeOfThis = thisSym.tpe
- }
- // This is the package _root_. The actual root cannot be referenced at
- // the source level, but _root_ is essentially a function => <root>.
- final object RootPackage extends PackageSymbol(NoSymbol, NoPosition, nme.ROOTPKG) with RootSymbol {
- this setInfo NullaryMethodType(RootClass.tpe)
- RootClass.sourceModule = this
+ @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.RootClass
- override def isRootPackage = true
- }
- // This is <root>, the actual root of everything except the package _root_.
- // <root> and _root_ (RootPackage and RootClass) should be the only "well known"
- // symbols owned by NoSymbol. All owner chains should go through RootClass,
- // although it is probable that some symbols are created as direct children
- // of NoSymbol to ensure they will not be stumbled upon. (We should designate
- // a better encapsulated place for that.)
- final object RootClass extends PackageClassSymbol(NoSymbol, NoPosition, tpnme.ROOT) with RootSymbol {
- this setInfo rootLoader
-
- override def isRoot = true
- override def isEffectiveRoot = true
- override def isStatic = true
- override def isNestedClass = false
- override def ownerOfNewSymbols = EmptyPackageClass
- }
- // The empty package, which holds all top level types without given packages.
- final object EmptyPackage extends PackageSymbol(RootClass, NoPosition, nme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
- override def isEmptyPackage = true
- }
- final object EmptyPackageClass extends PackageClassSymbol(RootClass, NoPosition, tpnme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
- override def isEffectiveRoot = true
- override def isEmptyPackageClass = true
- }
// It becomes tricky to create dedicated objects for other symbols because
// of initialization order issues.
lazy val JavaLangPackage = getRequiredPackage(sn.JavaLang)
- lazy val JavaLangPackageClass = JavaLangPackage.moduleClass
+ lazy val JavaLangPackageClass = JavaLangPackage.moduleClass.asClassSymbol
lazy val ScalaPackage = getRequiredPackage(nme.scala_)
- lazy val ScalaPackageClass = ScalaPackage.moduleClass
+ lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClassSymbol
lazy val RuntimePackage = getRequiredPackage("scala.runtime")
- lazy val RuntimePackageClass = RuntimePackage.moduleClass
+ lazy val RuntimePackageClass = RuntimePackage.moduleClass.asClassSymbol
lazy val JavaLangEnumClass = requiredClass[java.lang.Enum[_]]
@@ -235,9 +202,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
private def inttype = IntClass.tpe
private def stringtype = StringClass.tpe
- // Java types
- def javaTypeName(jclazz: Class[_]): TypeName = newTypeName(jclazz.getName)
-
def javaTypeToValueClass(jtype: Class[_]): Symbol = jtype match {
case java.lang.Void.TYPE => UnitClass
case java.lang.Byte.TYPE => ByteClass
@@ -282,7 +246,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
// Note: this is not the type alias AnyRef, it's a companion-like
// object used by the @specialize annotation.
- lazy val AnyRefModule = getMember(ScalaPackageClass, nme.AnyRef)
+ lazy val AnyRefModule = getMemberModule(ScalaPackageClass, nme.AnyRef)
@deprecated("Use AnyRefModule", "2.10.0")
def Predef_AnyRef = AnyRefModule
@@ -293,11 +257,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
anyval
}).asInstanceOf[ClassSymbol]
- lazy val AnyVal_getClass = enterNewMethod(AnyValClass, nme.getClass_, Nil, getClassReturnType(AnyValClass.tpe))
-
// bottom types
- lazy val RuntimeNothingClass = getClass(fulltpnme.RuntimeNothing)
- lazy val RuntimeNullClass = getClass(fulltpnme.RuntimeNull)
+ lazy val RuntimeNothingClass = getClassByName(fulltpnme.RuntimeNothing)
+ lazy val RuntimeNullClass = getClassByName(fulltpnme.RuntimeNull)
sealed abstract class BottomClassSymbol(name: TypeName, parent: Symbol) extends ClassSymbol(ScalaPackageClass, NoPosition, name) {
locally {
@@ -318,12 +280,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
// exceptions and other throwables
lazy val ClassCastExceptionClass = requiredClass[ClassCastException]
- lazy val IndexOutOfBoundsExceptionClass = getClass(sn.IOOBException)
- lazy val InvocationTargetExceptionClass = getClass(sn.InvTargetException)
+ lazy val IndexOutOfBoundsExceptionClass = getClassByName(sn.IOOBException)
+ lazy val InvocationTargetExceptionClass = getClassByName(sn.InvTargetException)
lazy val MatchErrorClass = requiredClass[MatchError]
lazy val NonLocalReturnControlClass = requiredClass[scala.runtime.NonLocalReturnControl[_]]
- lazy val NullPointerExceptionClass = getClass(sn.NPException)
- lazy val ThrowableClass = getClass(sn.Throwable)
+ lazy val NullPointerExceptionClass = getClassByName(sn.NPException)
+ lazy val ThrowableClass = getClassByName(sn.Throwable)
lazy val UninitializedErrorClass = requiredClass[UninitializedFieldError]
// fundamental reference classes
@@ -333,14 +295,17 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val StringClass = requiredClass[java.lang.String]
lazy val StringModule = StringClass.linkedClassOfClass
lazy val ClassClass = requiredClass[java.lang.Class[_]]
- def Class_getMethod = getMember(ClassClass, nme.getMethod_)
+ def Class_getMethod = getMemberMethod(ClassClass, nme.getMethod_)
lazy val DynamicClass = requiredClass[Dynamic]
// fundamental modules
lazy val SysPackage = getPackageObject("scala.sys")
- def Sys_error = getMember(SysPackage, nme.error)
+ def Sys_error = getMemberMethod(SysPackage, nme.error)
// Modules whose members are in the default namespace
+ // [Eugene++] ScalaPackage and JavaLangPackage are never ever shared between mirrors
+ // as a result, `Int` becomes `scala.Int` and `String` becomes `java.lang.String`
+ // I could just change `isOmittablePrefix`, but there's more to it, so I'm leaving this as a todo for now
lazy val UnqualifiedModules = List(PredefModule, ScalaPackage, JavaLangPackage)
// Those modules and their module classes
lazy val UnqualifiedOwners = UnqualifiedModules.toSet ++ UnqualifiedModules.map(_.moduleClass)
@@ -348,11 +313,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val PredefModule = requiredModule[scala.Predef.type]
lazy val PredefModuleClass = PredefModule.moduleClass
- def Predef_classOf = getMember(PredefModule, nme.classOf)
- def Predef_identity = getMember(PredefModule, nme.identity)
- def Predef_conforms = getMember(PredefModule, nme.conforms)
- def Predef_wrapRefArray = getMember(PredefModule, nme.wrapRefArray)
- def Predef_??? = getMember(PredefModule, nme.???)
+ def Predef_classOf = getMemberMethod(PredefModule, nme.classOf)
+ def Predef_identity = getMemberMethod(PredefModule, nme.identity)
+ def Predef_conforms = getMemberMethod(PredefModule, nme.conforms)
+ def Predef_wrapRefArray = getMemberMethod(PredefModule, nme.wrapRefArray)
+ def Predef_??? = getMemberMethod(PredefModule, nme.???)
+ def Predef_implicitly = getMemberMethod(PredefModule, nme.implicitly)
/** Is `sym` a member of Predef with the given name?
* Note: DON't replace this by sym == Predef_conforms/etc, as Predef_conforms is a `def`
@@ -366,32 +332,32 @@ trait Definitions extends reflect.api.StandardDefinitions {
/** Specialization.
*/
lazy val SpecializableModule = requiredModule[Specializable]
- lazy val GroupOfSpecializable = getMember(SpecializableModule, tpnme.Group)
-
- lazy val ConsoleModule: Symbol = requiredModule[scala.Console.type]
- lazy val ScalaRunTimeModule: Symbol = requiredModule[scala.runtime.ScalaRunTime.type]
- lazy val SymbolModule: Symbol = requiredModule[scala.Symbol.type]
- lazy val Symbol_apply = SymbolModule.info decl nme.apply
-
- def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq)
- def arrayApplyMethod = getMember(ScalaRunTimeModule, nme.array_apply)
- def arrayUpdateMethod = getMember(ScalaRunTimeModule, nme.array_update)
- def arrayLengthMethod = getMember(ScalaRunTimeModule, nme.array_length)
- def arrayCloneMethod = getMember(ScalaRunTimeModule, nme.array_clone)
- def ensureAccessibleMethod = getMember(ScalaRunTimeModule, nme.ensureAccessible)
- def scalaRuntimeSameElements = getMember(ScalaRunTimeModule, nme.sameElements)
- def arrayClassMethod = getMember(ScalaRunTimeModule, nme.arrayClass)
- def arrayElementClassMethod = getMember(ScalaRunTimeModule, nme.arrayElementClass)
+ lazy val GroupOfSpecializable = getMemberClass(SpecializableModule, tpnme.Group)
+
+ lazy val ConsoleModule = requiredModule[scala.Console.type]
+ lazy val ScalaRunTimeModule = requiredModule[scala.runtime.ScalaRunTime.type]
+ lazy val SymbolModule = requiredModule[scala.Symbol.type]
+ lazy val Symbol_apply = getMemberMethod(SymbolModule, nme.apply)
+
+ def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq) // [Eugene++] obsolete?
+ def arrayApplyMethod = getMemberMethod(ScalaRunTimeModule, nme.array_apply)
+ def arrayUpdateMethod = getMemberMethod(ScalaRunTimeModule, nme.array_update)
+ def arrayLengthMethod = getMemberMethod(ScalaRunTimeModule, nme.array_length)
+ def arrayCloneMethod = getMemberMethod(ScalaRunTimeModule, nme.array_clone)
+ def ensureAccessibleMethod = getMemberMethod(ScalaRunTimeModule, nme.ensureAccessible)
+ def scalaRuntimeSameElements = getMemberMethod(ScalaRunTimeModule, nme.sameElements)
+ def arrayClassMethod = getMemberMethod(ScalaRunTimeModule, nme.arrayClass)
+ def arrayElementClassMethod = getMemberMethod(ScalaRunTimeModule, nme.arrayElementClass)
// classes with special meanings
lazy val StringAddClass = requiredClass[scala.runtime.StringAdd]
lazy val ArrowAssocClass = getRequiredClass("scala.Predef.ArrowAssoc") // SI-5731
- lazy val StringAdd_+ = getMember(StringAddClass, nme.PLUS)
+ lazy val StringAdd_+ = getMemberMethod(StringAddClass, nme.PLUS)
lazy val NotNullClass = getRequiredClass("scala.NotNull")
lazy val ScalaNumberClass = requiredClass[scala.math.ScalaNumber]
lazy val TraitSetterAnnotationClass = requiredClass[scala.runtime.TraitSetter]
lazy val DelayedInitClass = requiredClass[scala.DelayedInit]
- def delayedInitMethod = getMember(DelayedInitClass, nme.delayedInit)
+ def delayedInitMethod = getMemberMethod(DelayedInitClass, nme.delayedInit)
// a dummy value that communicates that a delayedInit call is compiler-generated
// from phase UnCurry to phase Constructors
// !!! This is not used anywhere (it was checked in that way.)
@@ -456,37 +422,37 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val TraversableClass = requiredClass[scala.collection.Traversable[_]]
lazy val ListModule = requiredModule[scala.collection.immutable.List.type]
- lazy val List_apply = getMember(ListModule, nme.apply)
+ lazy val List_apply = getMemberMethod(ListModule, nme.apply)
lazy val NilModule = requiredModule[scala.collection.immutable.Nil.type]
lazy val SeqModule = requiredModule[scala.collection.Seq.type]
- lazy val IteratorModule = requiredModule[scala.collection.Iterator.type]
- lazy val Iterator_apply = getMember(IteratorModule, nme.apply)
+ lazy val IteratorModule = requiredModule[scala.collection.Iterator.type]
+ lazy val Iterator_apply = getMemberMethod(IteratorModule, nme.apply)
// arrays and their members
- lazy val ArrayModule = requiredModule[scala.Array.type]
- lazy val ArrayModule_overloadedApply = getMember(ArrayModule, nme.apply)
- lazy val ArrayClass = getRequiredClass("scala.Array") // requiredClass[scala.Array[_]]
- lazy val Array_apply = getMember(ArrayClass, nme.apply)
- lazy val Array_update = getMember(ArrayClass, nme.update)
- lazy val Array_length = getMember(ArrayClass, nme.length)
- lazy val Array_clone = getMember(ArrayClass, nme.clone_)
+ lazy val ArrayModule = requiredModule[scala.Array.type]
+ lazy val ArrayModule_overloadedApply = getMemberMethod(ArrayModule, nme.apply)
+ lazy val ArrayClass = getRequiredClass("scala.Array") // requiredClass[scala.Array[_]]
+ lazy val Array_apply = getMemberMethod(ArrayClass, nme.apply)
+ lazy val Array_update = getMemberMethod(ArrayClass, nme.update)
+ lazy val Array_length = getMemberMethod(ArrayClass, nme.length)
+ lazy val Array_clone = getMemberMethod(ArrayClass, nme.clone_)
// reflection / structural types
lazy val SoftReferenceClass = requiredClass[java.lang.ref.SoftReference[_]]
lazy val WeakReferenceClass = requiredClass[java.lang.ref.WeakReference[_]]
- lazy val MethodClass = getClass(sn.MethodAsObject)
- def methodClass_setAccessible = getMember(MethodClass, nme.setAccessible)
+ lazy val MethodClass = getClassByName(sn.MethodAsObject)
+ def methodClass_setAccessible = getMemberMethod(MethodClass, nme.setAccessible)
lazy val EmptyMethodCacheClass = requiredClass[scala.runtime.EmptyMethodCache]
lazy val MethodCacheClass = requiredClass[scala.runtime.MethodCache]
- def methodCache_find = getMember(MethodCacheClass, nme.find_)
- def methodCache_add = getMember(MethodCacheClass, nme.add_)
+ def methodCache_find = getMemberMethod(MethodCacheClass, nme.find_)
+ def methodCache_add = getMemberMethod(MethodCacheClass, nme.add_)
// scala.reflect
- lazy val ReflectPackageClass = getMember(ScalaPackageClass, nme.reflect)
- lazy val ReflectPackage = requiredModule[scala.reflect.`package`.type]
- def ReflectMirror = getMember(ReflectPackage, nme.mirror)
- // [Eugene] is this a good place for ReflectMirrorPrefix?
- def ReflectMirrorPrefix = gen.mkAttributedRef(ReflectMirror) setType singleType(ReflectMirror.owner.thisPrefix, ReflectMirror)
+ lazy val ReflectPackage = requiredModule[scala.reflect.`package`.type]
+ def ReflectBasis = getMemberValue(ReflectPackage, nme.basis)
+ lazy val ReflectRuntimePackage = getPackageObjectIfDefined("scala.reflect.runtime") // defined in scala-reflect.jar, so we need to be careful
+ def ReflectRuntimeUniverse = if (ReflectRuntimePackage != NoSymbol) getMemberValue(ReflectRuntimePackage, nme.universe) else NoSymbol
+ def ReflectRuntimeCurrentMirror = if (ReflectRuntimePackage != NoSymbol) getMemberMethod(ReflectRuntimePackage, nme.currentMirror) else NoSymbol
lazy val PartialManifestClass = requiredClass[scala.reflect.ClassManifest[_]]
lazy val PartialManifestModule = requiredModule[scala.reflect.ClassManifest.type]
@@ -495,58 +461,53 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val OptManifestClass = requiredClass[scala.reflect.OptManifest[_]]
lazy val NoManifest = requiredModule[scala.reflect.NoManifest.type]
- lazy val ExprClass = getMember(requiredClass[scala.reflect.api.Exprs], tpnme.Expr)
- def ExprTree = getMember(ExprClass, nme.tree)
- def ExprTpe = getMember(ExprClass, nme.tpe)
- def ExprEval = getMember(ExprClass, nme.eval)
- def ExprValue = getMember(ExprClass, nme.value)
- lazy val ExprModule = getMember(requiredClass[scala.reflect.api.Exprs], nme.Expr)
+ lazy val ExprsClass = getClassIfDefined("scala.reflect.api.Exprs") // defined in scala-reflect.jar, so we need to be careful
+ lazy val ExprClass = if (ExprsClass != NoSymbol) getMemberClass(ExprsClass, tpnme.Expr) else NoSymbol
+ def ExprSplice = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.splice) else NoSymbol
+ def ExprValue = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.value) else NoSymbol
+ lazy val ExprModule = if (ExprsClass != NoSymbol) getMemberModule(ExprsClass, nme.Expr) else NoSymbol
- lazy val ArrayTagClass = requiredClass[scala.reflect.ArrayTag[_]]
- lazy val ErasureTagClass = requiredClass[scala.reflect.ErasureTag[_]]
lazy val ClassTagModule = requiredModule[scala.reflect.ClassTag[_]]
lazy val ClassTagClass = requiredClass[scala.reflect.ClassTag[_]]
- lazy val TypeTagsClass = requiredClass[scala.reflect.api.TypeTags]
+ lazy val TypeTagsClass = requiredClass[scala.reflect.base.TypeTags]
+ lazy val AbsTypeTagClass = getMemberClass(TypeTagsClass, tpnme.AbsTypeTag)
+ lazy val AbsTypeTagModule = getMemberModule(TypeTagsClass, nme.AbsTypeTag)
lazy val TypeTagClass = getMemberClass(TypeTagsClass, tpnme.TypeTag)
lazy val TypeTagModule = getMemberModule(TypeTagsClass, nme.TypeTag)
- lazy val ConcreteTypeTagClass = getMemberClass(TypeTagsClass, tpnme.ConcreteTypeTag)
- lazy val ConcreteTypeTagModule = getMemberModule(TypeTagsClass, nme.ConcreteTypeTag)
-
- def ArrayTagWrap = getMemberMethod(ArrayTagClass, nme.wrap)
- def ArrayTagNewArray = getMemberMethod(ArrayTagClass, nme.newArray)
- def ErasureTagErasure = getMemberMethod(ErasureTagClass, nme.erasure)
- def ClassTagTpe = getMemberMethod(ClassTagClass, nme.tpe)
- def TypeTagTpe = getMemberMethod(TypeTagClass, nme.tpe)
-
- lazy val MacroContextClass = requiredClass[scala.reflect.makro.Context]
- def MacroContextPrefix = getMember(MacroContextClass, nme.prefix)
- def MacroContextPrefixType = getMember(MacroContextClass, tpnme.PrefixType)
- def MacroContextMirror = getMember(MacroContextClass, nme.mirror)
- def MacroContextReify = getMember(MacroContextClass, nme.reify)
- lazy val MacroImplAnnotation = requiredClass[scala.reflect.makro.internal.macroImpl]
- lazy val MacroInternalPackage = getPackageObject("scala.reflect.makro.internal")
- def MacroInternal_materializeArrayTag = getMemberMethod(MacroInternalPackage, nme.materializeArrayTag)
- def MacroInternal_materializeErasureTag = getMemberMethod(MacroInternalPackage, nme.materializeErasureTag)
- def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag)
- def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag)
- def MacroInternal_materializeConcreteTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeConcreteTypeTag)
+
+ lazy val BaseUniverseClass = requiredClass[scala.reflect.base.Universe]
+ lazy val ApiUniverseClass = getClassIfDefined("scala.reflect.api.Universe") // defined in scala-reflect.jar, so we need to be careful
+ def ApiUniverseReify = if (ApiUniverseClass != NoSymbol) getMemberMethod(ApiUniverseClass, nme.reify) else NoSymbol
+ lazy val JavaUniverseClass = getClassIfDefined("scala.reflect.api.JavaUniverse") // defined in scala-reflect.jar, so we need to be careful
+
+ lazy val MirrorOfClass = requiredClass[scala.reflect.base.MirrorOf[_]]
+
+ lazy val TypeCreatorClass = requiredClass[scala.reflect.base.TypeCreator]
+ lazy val TreeCreatorClass = requiredClass[scala.reflect.base.TreeCreator]
+
+ lazy val MacroContextClass = getClassIfDefined("scala.reflect.makro.Context") // defined in scala-reflect.jar, so we need to be careful
+ def MacroContextPrefix = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.prefix) else NoSymbol
+ def MacroContextPrefixType = if (MacroContextClass != NoSymbol) getMemberType(MacroContextClass, tpnme.PrefixType) else NoSymbol
+ def MacroContextUniverse = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.universe) else NoSymbol
+ def MacroContextMirror = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.mirror) else NoSymbol
+ def MacroContextReify = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.reify) else NoSymbol
+ lazy val MacroImplAnnotation = requiredClass[scala.reflect.makro.internal.macroImpl]
+ lazy val MacroInternalPackage = getPackageObject("scala.reflect.makro.internal")
+ def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag)
+ def MacroInternal_materializeAbsTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeAbsTypeTag)
+ def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag)
lazy val ScalaSignatureAnnotation = requiredClass[scala.reflect.ScalaSignature]
lazy val ScalaLongSignatureAnnotation = requiredClass[scala.reflect.ScalaLongSignature]
// Option classes
- lazy val OptionClass: Symbol = requiredClass[Option[_]]
- lazy val SomeClass: Symbol = requiredClass[Some[_]]
- lazy val NoneModule: Symbol = requiredModule[scala.None.type]
- lazy val SomeModule: Symbol = requiredModule[scala.Some.type]
+ lazy val OptionClass: ClassSymbol = requiredClass[Option[_]]
+ lazy val SomeClass: ClassSymbol = requiredClass[Some[_]]
+ lazy val NoneModule: ModuleSymbol = requiredModule[scala.None.type]
+ lazy val SomeModule: ModuleSymbol = requiredModule[scala.Some.type]
- // [Eugene] how do I make this work without casts?
- // private lazy val importerFromRm = self.mkImporter(rm)
- private lazy val importerFromRm = self.mkImporter(rm).asInstanceOf[self.Importer { val from: rm.type }]
-
- def compilerTypeFromTag(t: rm.TypeTag[_]): Type = importerFromRm.importType(t.tpe)
-
- def compilerSymbolFromTag(t: rm.TypeTag[_]): Symbol = importerFromRm.importSymbol(t.sym)
+ def compilerTypeFromTag(tt: BaseUniverse # AbsTypeTag[_]): Type = tt.in(rootMirror).tpe
+ def compilerSymbolFromTag(tt: BaseUniverse # AbsTypeTag[_]): Symbol = tt.in(rootMirror).tpe.typeSymbol
// The given symbol represents either String.+ or StringAdd.+
def isStringAddition(sym: Symbol) = sym == String_+ || sym == StringAdd_+
@@ -568,20 +529,21 @@ trait Definitions extends reflect.api.StandardDefinitions {
def isNoneType(tp: Type) = tp.typeSymbol eq NoneModule
// Product, Tuple, Function, AbstractFunction
- private def mkArityArray(name: String, arity: Int, countFrom: Int = 1): Array[Symbol] = {
+ private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[ClassSymbol] = {
val list = countFrom to arity map (i => getRequiredClass("scala." + name + i))
- if (countFrom == 0) list.toArray
- else (NoSymbol +: list).toArray
+ list.toArray
}
- private def aritySpecificType(symbolArray: Array[Symbol], args: List[Type], others: Type*): Type = {
+ def prepend[S >: ClassSymbol : ClassTag](elem0: S, elems: Array[ClassSymbol]): Array[S] = elem0 +: elems
+
+ private def aritySpecificType[S <: Symbol](symbolArray: Array[S], args: List[Type], others: Type*): Type = {
val arity = args.length
if (arity >= symbolArray.length) NoType
else appliedType(symbolArray(arity), args ++ others: _*)
}
val MaxTupleArity, MaxProductArity, MaxFunctionArity = 22
- lazy val ProductClass = { val arr = mkArityArray("Product", MaxProductArity) ; arr(0) = UnitClass ; arr }
- lazy val TupleClass = mkArityArray("Tuple", MaxTupleArity)
+ lazy val ProductClass: Array[ClassSymbol] = prepend(UnitClass, mkArityArray("Product", MaxProductArity, 1))
+ lazy val TupleClass: Array[Symbol] = prepend(NoSymbol, mkArityArray("Tuple", MaxTupleArity, 1))
lazy val FunctionClass = mkArityArray("Function", MaxFunctionArity, 0)
lazy val AbstractFunctionClass = mkArityArray("runtime.AbstractFunction", MaxFunctionArity, 0)
@@ -609,7 +571,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
@deprecated("Use isTupleType", "2.10.0")
def isTupleTypeOrSubtype(tp: Type) = isTupleType(tp)
- def tupleField(n: Int, j: Int) = getMember(TupleClass(n), nme.productAccessorName(j))
+ def tupleField(n: Int, j: Int) = getMemberValue(TupleClass(n), nme.productAccessorName(j))
// NOTE: returns true for NoSymbol since it's included in the TupleClass array -- is this intensional?
def isTupleSymbol(sym: Symbol) = TupleClass contains unspecializedSymbol(sym)
def isProductNClass(sym: Symbol) = ProductClass contains sym
@@ -657,8 +619,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
def Product_canEqual = getMemberMethod(ProductRootClass, nme.canEqual_)
// def Product_productElementName = getMemberMethod(ProductRootClass, nme.productElementName)
- def productProj(z:Symbol, j: Int): Symbol = getMember(z, nme.productAccessorName(j))
- def productProj(n: Int, j: Int): Symbol = productProj(ProductClass(n), j)
+ def productProj(z:Symbol, j: Int): TermSymbol = getMemberValue(z, nme.productAccessorName(j))
+ def productProj(n: Int, j: Int): TermSymbol = productProj(ProductClass(n), j)
/** returns true if this type is exactly ProductN[T1,...,Tn], not some subclass */
def isExactProductType(tp: Type): Boolean = isProductNClass(tp.typeSymbol)
@@ -674,7 +636,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
case tp => tp
}
- def functionApply(n: Int) = getMember(FunctionClass(n), nme.apply)
+ def functionApply(n: Int) = getMemberMethod(FunctionClass(n), nme.apply)
def abstractFunctionForFunctionType(tp: Type) =
if (isFunctionType(tp)) abstractFunctionType(tp.typeArgs.init, tp.typeArgs.last)
@@ -745,9 +707,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val ComparatorClass = getRequiredClass("scala.runtime.Comparator")
// System.ValueType
- lazy val ValueTypeClass: Symbol = getClass(sn.ValueType)
+ lazy val ValueTypeClass: ClassSymbol = getClassByName(sn.ValueType)
// System.MulticastDelegate
- lazy val DelegateClass: Symbol = getClass(sn.Delegate)
+ lazy val DelegateClass: ClassSymbol = getClassByName(sn.Delegate)
var Delegate_scalaCallers: List[Symbol] = List() // Syncnote: No protection necessary yet as only for .NET where reflection is not supported.
// Symbol -> (Symbol, Type): scalaCaller -> (scalaMethodSym, DelegateType)
// var Delegate_scalaCallerInfos: HashMap[Symbol, (Symbol, Type)] = _
@@ -786,7 +748,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
// Since getClass is not actually a polymorphic method, this requires compiler
// participation. At the "Any" level, the return type is Class[_] as it is in
// java.lang.Object. Java also special cases the return type.
- lazy val Any_getClass = enterNewMethod(AnyClass, nme.getClass_, Nil, getMember(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
+ lazy val Any_getClass = enterNewMethod(AnyClass, nme.getClass_, Nil, getMemberMethod(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
lazy val Any_isInstanceOf = newT1NullaryMethod(AnyClass, nme.isInstanceOf_, FINAL)(_ => booltype)
lazy val Any_asInstanceOf = newT1NullaryMethod(AnyClass, nme.asInstanceOf_, FINAL)(_.typeConstructor)
@@ -818,7 +780,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
existentialAbstraction(
eparams,
- ClassType(eparams.head setInfo TypeBounds.upper(upperBound) tpe)
+ ClassType((eparams.head setInfo TypeBounds.upper(upperBound)).tpe)
)
}
}
@@ -886,14 +848,14 @@ trait Definitions extends reflect.api.StandardDefinitions {
)
lazy val String_+ = enterNewMethod(StringClass, nme.raw.PLUS, anyparam, stringtype, FINAL)
- def Object_getClass = getMember(ObjectClass, nme.getClass_)
- def Object_clone = getMember(ObjectClass, nme.clone_)
- def Object_finalize = getMember(ObjectClass, nme.finalize_)
- def Object_notify = getMember(ObjectClass, nme.notify_)
- def Object_notifyAll = getMember(ObjectClass, nme.notifyAll_)
- def Object_equals = getMember(ObjectClass, nme.equals_)
- def Object_hashCode = getMember(ObjectClass, nme.hashCode_)
- def Object_toString = getMember(ObjectClass, nme.toString_)
+ def Object_getClass = getMemberMethod(ObjectClass, nme.getClass_)
+ def Object_clone = getMemberMethod(ObjectClass, nme.clone_)
+ def Object_finalize = getMemberMethod(ObjectClass, nme.finalize_)
+ def Object_notify = getMemberMethod(ObjectClass, nme.notify_)
+ def Object_notifyAll = getMemberMethod(ObjectClass, nme.notifyAll_)
+ def Object_equals = getMemberMethod(ObjectClass, nme.equals_)
+ def Object_hashCode = getMemberMethod(ObjectClass, nme.hashCode_)
+ def Object_toString = getMemberMethod(ObjectClass, nme.toString_)
// boxed classes
lazy val ObjectRefClass = requiredClass[scala.runtime.ObjectRef[_]]
@@ -901,9 +863,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val RuntimeStaticsModule = getRequiredModule("scala.runtime.Statics")
lazy val BoxesRunTimeModule = getRequiredModule("scala.runtime.BoxesRunTime")
lazy val BoxesRunTimeClass = BoxesRunTimeModule.moduleClass
- lazy val BoxedNumberClass = getClass(sn.BoxedNumber)
- lazy val BoxedCharacterClass = getClass(sn.BoxedCharacter)
- lazy val BoxedBooleanClass = getClass(sn.BoxedBoolean)
+ lazy val BoxedNumberClass = getClassByName(sn.BoxedNumber)
+ lazy val BoxedCharacterClass = getClassByName(sn.BoxedCharacter)
+ lazy val BoxedBooleanClass = getClassByName(sn.BoxedBoolean)
lazy val BoxedByteClass = requiredClass[java.lang.Byte]
lazy val BoxedShortClass = requiredClass[java.lang.Short]
lazy val BoxedIntClass = requiredClass[java.lang.Integer]
@@ -911,13 +873,13 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val BoxedFloatClass = requiredClass[java.lang.Float]
lazy val BoxedDoubleClass = requiredClass[java.lang.Double]
- lazy val Boxes_isNumberOrBool = getDecl(BoxesRunTimeClass, nme.isBoxedNumberOrBoolean)
- lazy val Boxes_isNumber = getDecl(BoxesRunTimeClass, nme.isBoxedNumber)
+ lazy val Boxes_isNumberOrBool = getDecl(BoxesRunTimeClass, nme.isBoxedNumberOrBoolean)
+ lazy val Boxes_isNumber = getDecl(BoxesRunTimeClass, nme.isBoxedNumber)
lazy val BoxedUnitClass = requiredClass[scala.runtime.BoxedUnit]
lazy val BoxedUnitModule = getRequiredModule("scala.runtime.BoxedUnit")
- def BoxedUnit_UNIT = getMember(BoxedUnitModule, nme.UNIT)
- def BoxedUnit_TYPE = getMember(BoxedUnitModule, nme.TYPE_)
+ def BoxedUnit_UNIT = getMemberValue(BoxedUnitModule, nme.UNIT)
+ def BoxedUnit_TYPE = getMemberValue(BoxedUnitModule, nme.TYPE_)
// Annotation base classes
lazy val AnnotationClass = requiredClass[scala.annotation.Annotation]
@@ -968,7 +930,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
// Language features
lazy val languageFeatureModule = getRequiredModule("scala.languageFeature")
- lazy val experimentalModule = getMember(languageFeatureModule, nme.experimental)
+ lazy val experimentalModule = getMemberModule(languageFeatureModule, nme.experimental)
lazy val MacrosFeature = getLanguageFeature("macros", experimentalModule)
lazy val DynamicsFeature = getLanguageFeature("dynamics")
lazy val PostfixOpsFeature = getLanguageFeature("postfixOps")
@@ -987,99 +949,33 @@ trait Definitions extends reflect.api.StandardDefinitions {
BeanGetterTargetClass, BeanSetterTargetClass
)
- lazy val AnnotationDefaultAttr: Symbol = {
+ lazy val AnnotationDefaultAttr: ClassSymbol = {
val attr = enterNewClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.tpe))
// This attribute needs a constructor so that modifiers in parsed Java code make sense
attr.info.decls enter attr.newClassConstructor(NoPosition)
attr
}
- def getPackageObjectClass(fullname: String): Symbol =
- getPackageObject(fullname).companionClass
-
- def getPackageObject(fullname: String): Symbol =
- getModule(newTermName(fullname)).info member nme.PACKAGE
+ @deprecated("Moved to rootMirror.getClass", "2.10.0")
+ def getClass(fullname: Name): ClassSymbol = rootMirror.getClassByName(fullname)
- def getModule(fullname: Name): ModuleSymbol =
- getModuleOrClass(fullname.toTermName) match {
- case x: ModuleSymbol => x
- case _ => MissingRequirementError.notFound("object " + fullname)
- }
-
- def getPackage(fullname: Name): PackageSymbol =
- getModuleOrClass(fullname.toTermName) match {
- case x: PackageSymbol => x
- case _ => MissingRequirementError.notFound("package " + fullname)
- }
- @inline private def wrapMissing(body: => Symbol): Symbol =
- try body
- catch { case _: MissingRequirementError => NoSymbol }
+ @deprecated("Moved to rootMirror.getModule", "2.10.0")
+ def getModule(fullname: Name): ModuleSymbol = rootMirror.getModule(fullname)
private def fatalMissingSymbol(owner: Symbol, name: Name, what: String = "member") = {
throw new FatalError(owner + " does not have a " + what + " " + name)
}
- @deprecated("Use getClassByName", "2.10.0")
- def getClass(fullname: Name): Symbol = getClassByName(fullname)
-
- def getRequiredPackage(fullname: String): PackageSymbol =
- getPackage(newTermNameCached(fullname))
-
- def getRequiredModule(fullname: String): ModuleSymbol =
- getModule(newTermNameCached(fullname))
-
- def erasureName[T: ErasureTag] : String = {
- /** We'd like the String representation to be a valid
- * scala type, so we have to decode the jvm's secret language.
- */
- def erasureString(clazz: Class[_]): String = {
- if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]"
- else clazz.getName
- }
- erasureString(implicitly[ErasureTag[T]].erasure)
- }
-
- def requiredClass[T: ClassTag] : ClassSymbol = getRequiredClass(erasureName[T])
-
- // 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
- // no accompanying Predef class, and if you say requiredModule[scala.Predef.type]
- // the name found via the erasure is scala.Predef$. For now I am
- // removing the trailing $, but I think that classTag should have
- // a method which returns a usable name, one which doesn't expose this
- // detail of the backend.
- def requiredModule[T: ClassTag] : ModuleSymbol =
- getRequiredModule(erasureName[T] stripSuffix "$")
-
- def getRequiredClass(fullname: String): ClassSymbol =
- getClassByName(newTypeNameCached(fullname)) match {
- case x: ClassSymbol => x
- case _ => MissingRequirementError.notFound("class " + fullname)
- }
-
- def getClassIfDefined(fullname: String): Symbol =
- getClassIfDefined(newTypeName(fullname))
-
- def getClassIfDefined(fullname: Name): Symbol =
- wrapMissing(getClass(fullname.toTypeName))
-
- def getModuleIfDefined(fullname: String): Symbol =
- getModuleIfDefined(newTermName(fullname))
-
- def getModuleIfDefined(fullname: Name): Symbol =
- wrapMissing(getModule(fullname.toTermName))
-
- def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule) =
+ def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule): Symbol =
+ // [Eugene++] `getMemberClass` leads to crashes in mixin:
+ // "object languageFeature does not have a member class implicitConversions"
+ // that's because by that time `implicitConversions` becomes a module
+ // getMemberClass(owner, newTypeName(name))
getMember(owner, newTypeName(name))
def termMember(owner: Symbol, name: String): Symbol = owner.info.member(newTermName(name))
def typeMember(owner: Symbol, name: String): Symbol = owner.info.member(newTypeName(name))
- def findMemberFromRoot(fullName: Name): Symbol = {
- val segs = nme.segments(fullName.toString, fullName.isTermName)
- if (segs.isEmpty) NoSymbol
- else findNamedMember(segs.tail, definitions.RootClass.info member segs.head)
- }
def findNamedMember(fullName: Name, root: Symbol): Symbol = {
val segs = nme.segments(fullName.toString, fullName.isTermName)
if (segs.isEmpty || segs.head != root.simpleName) NoSymbol
@@ -1099,22 +995,81 @@ trait Definitions extends reflect.api.StandardDefinitions {
else fatalMissingSymbol(owner, name)
}
}
+ def getMemberValue(owner: Symbol, name: Name): TermSymbol = {
+ // [Eugene++] should be a ClassCastException instead?
+ getMember(owner, name.toTermName) match {
+ case x: TermSymbol => x
+ case _ => fatalMissingSymbol(owner, name, "member value")
+ }
+ }
def getMemberModule(owner: Symbol, name: Name): ModuleSymbol = {
+ // [Eugene++] should be a ClassCastException instead?
getMember(owner, name.toTermName) match {
case x: ModuleSymbol => x
case _ => fatalMissingSymbol(owner, name, "member object")
}
}
+ def getMemberType(owner: Symbol, name: Name): TypeSymbol = {
+ // [Eugene++] should be a ClassCastException instead?
+ getMember(owner, name.toTypeName) match {
+ case x: TypeSymbol => x
+ case _ => fatalMissingSymbol(owner, name, "member type")
+ }
+ }
def getMemberClass(owner: Symbol, name: Name): ClassSymbol = {
+ // [Eugene++] should be a ClassCastException instead?
+ val y = getMember(owner, name.toTypeName)
getMember(owner, name.toTypeName) match {
case x: ClassSymbol => x
case _ => fatalMissingSymbol(owner, name, "member class")
}
}
- def getMemberMethod(owner: Symbol, name: Name): MethodSymbol = {
+ def getMemberMethod(owner: Symbol, name: Name): TermSymbol = {
+ // [Eugene++] is this a bug?
+ //
+ // System.err.println(result.getClass)
+ // System.err.println(result.flags)
+ // System.err.println("isMethod = " + result.isMethod)
+ // System.err.println("isTerm = " + result.isTerm)
+ // System.err.println("isValue = " + result.isValue)
+ // result.asMethodSymbol
+ //
+ // prints this:
+ //
+ // quick.lib:
+ // [javac] Compiling 1 source file to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library
+ // [scalacfork] Compiling 769 files to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library
+ // [scalacfork] class scala.reflect.internal.Symbols$TermSymbol
+ // [scalacfork] 8589934592
+ // [scalacfork] isMethod = false
+ // [scalacfork] isTerm = true
+ // [scalacfork] isValue = true
+ // [scalacfork]
+ // [scalacfork] while compiling: C:\Projects\KeplerUnderRefactoring\src\library\scala\LowPriorityImplicits.scala
+ // [scalacfork] current phase: cleanup
+ // [scalacfork] library version: version 2.10.0-20120507-185519-665d1d9127
+ // [scalacfork] compiler version: version 2.10.0-20120507-185519-665d1d9127
+ // [scalacfork] reconstructed args: -Xmacros -classpath C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library;C:\\Projects\\KeplerUnderRefactoring\\lib\\forkjoin.jar -d C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library -sourcepath C:\\Projects\\KeplerUnderRefactoring\\src\\library
+ // [scalacfork]
+ // [scalacfork] unhandled exception while transforming LowPriorityImplicits.scala
+ // [scalacfork] error:
+ // [scalacfork] while compiling: C:\Projects\KeplerUnderRefactoring\src\library\scala\LowPriorityImplicits.scala
+ // [scalacfork] current phase: cleanup
+ // [scalacfork] library version: version 2.10.0-20120507-185519-665d1d9127
+ // [scalacfork] compiler version: version 2.10.0-20120507-185519-665d1d9127
+ // [scalacfork] reconstructed args: -Xmacros -classpath C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library;C:\\Projects\\KeplerUnderRefactoring\\lib\\forkjoin.jar -d C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library -sourcepath C:\\Projects\\KeplerUnderRefactoring\\src\\library
+ // [scalacfork]
+ // [scalacfork] uncaught exception during compilation: java.lang.ClassCastException
+ // [scalacfork] error: java.lang.ClassCastException: value apply
+ // [scalacfork] at scala.reflect.base.Symbols$SymbolBase$class.asMethodSymbol(Symbols.scala:118)
+ // [scalacfork] at scala.reflect.internal.Symbols$SymbolContextApiImpl.asMethodSymbol(Symbols.scala:63)
+ // [scalacfork] at scala.reflect.internal.Definitions$DefinitionsClass.Symbol_apply(Definitions.scala:381)
+
+ // [Eugene++] should be a ClassCastException instead?
getMember(owner, name.toTermName) match {
- case x: MethodSymbol => x
- case _ => fatalMissingSymbol(owner, name, "method")
+ // case x: MethodSymbol => x
+ case x: TermSymbol => x
+ case _ => fatalMissingSymbol(owner, name, "method")
}
}
@@ -1134,34 +1089,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
def packageExists(packageName: String): Boolean =
getModuleIfDefined(packageName).isPackage
- private def getModuleOrClass(path: Name, len: Int): Symbol = {
- val point = path lastPos('.', len - 1)
- val owner =
- if (point > 0) getModuleOrClass(path.toTermName, point)
- else RootClass
- val name = path subName (point + 1, len)
- val sym = owner.info member name
- val result = if (path.isTermName) sym.suchThat(_ hasFlag MODULE) else sym
- if (result != NoSymbol) result
- else {
- if (settings.debug.value) { log(sym.info); log(sym.info.members) }//debug
- missingHook(owner, name) orElse {
- MissingRequirementError.notFound((if (path.isTermName) "object " else "class ")+path)
- }
- }
- }
-
- /** If you're looking for a class, pass a type name.
- * If a module, a term name.
- */
- private def getModuleOrClass(path: Name): Symbol = getModuleOrClass(path, path.length)
-
- def getClassByName(fullname: Name): Symbol = {
- var result = getModuleOrClass(fullname.toTypeName)
- while (result.isAliasType) result = result.info.typeSymbol
- result
- }
-
private def newAlias(owner: Symbol, name: TypeName, alias: Type): AliasTypeSymbol =
owner.newAliasType(name) setInfoAndEnter alias
@@ -1220,7 +1147,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
def unboxedValueClass(sym: Symbol): Symbol =
if (isPrimitiveValueClass(sym)) sym
else if (sym == BoxedUnitClass) UnitClass
- else boxedClass.map(_.swap).getOrElse(sym, NoSymbol)
+ else boxedClass.map(kvp => (kvp._2: Symbol, kvp._1)).getOrElse(sym, NoSymbol)
/** Is type's symbol a numeric value class? */
def isNumericValueType(tp: Type): Boolean = tp match {
@@ -1249,28 +1176,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
else flatNameString(etp.typeSymbol, '.')
}
- /** getModule2/getClass2 aren't needed at present but may be again,
- * so for now they're mothballed.
- */
- // def getModule2(name1: Name, name2: Name) = {
- // try getModuleOrClass(name1.toTermName)
- // catch { case ex1: FatalError =>
- // try getModuleOrClass(name2.toTermName)
- // catch { case ex2: FatalError => throw ex1 }
- // }
- // }
- // def getClass2(name1: Name, name2: Name) = {
- // try {
- // val result = getModuleOrClass(name1.toTypeName)
- // if (result.isAliasType) getClass(name2) else result
- // }
- // catch { case ex1: FatalError =>
- // try getModuleOrClass(name2.toTypeName)
- // catch { case ex2: FatalError => throw ex1 }
- // }
- // }
-
- /** Surgery on the value classes. Without this, AnyVals defined in source
+ /** Surgery on the value classes. Without this, AnyVals defined in source
* files end up with an AnyRef parent. It is likely there is a better way
* to evade that AnyRef.
*/
@@ -1284,17 +1190,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
def init() {
if (isInitialized) return
- // Still fiddling with whether it's cleaner to do some of this setup here
- // or from constructors. The latter approach tends to invite init order issues.
- EmptyPackageClass setInfo ClassInfoType(Nil, newPackageScope(EmptyPackageClass), EmptyPackageClass)
- EmptyPackage setInfo EmptyPackageClass.tpe
-
- connectModuleToClass(EmptyPackage, EmptyPackageClass)
- connectModuleToClass(RootPackage, RootClass)
-
- RootClass.info.decls enter EmptyPackage
- RootClass.info.decls enter RootPackage
-
val forced = List( // force initialization of every symbol that is entered as a side effect
AnnotationDefaultAttr, // #2264
RepeatedParamClass,
@@ -1333,7 +1228,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
} //init
var nbScalaCallers: Int = 0
- def newScalaCaller(delegateType: Type): Symbol = {
+ def newScalaCaller(delegateType: Type): MethodSymbol = {
assert(forMSIL, "scalaCallers can only be created if target is .NET")
// object: reference to object on which to call (scala-)method
val paramTypes: List[Type] = List(ObjectClass.tpe)
diff --git a/src/compiler/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala
index f1fe4fc118..f1fe4fc118 100644
--- a/src/compiler/scala/reflect/internal/ExistentialsAndSkolems.scala
+++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala
diff --git a/src/compiler/scala/reflect/internal/FatalError.scala b/src/reflect/scala/reflect/internal/FatalError.scala
index c843308480..c843308480 100644
--- a/src/compiler/scala/reflect/internal/FatalError.scala
+++ b/src/reflect/scala/reflect/internal/FatalError.scala
diff --git a/src/reflect/scala/reflect/internal/FlagSets.scala b/src/reflect/scala/reflect/internal/FlagSets.scala
new file mode 100644
index 0000000000..0354d2513c
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/FlagSets.scala
@@ -0,0 +1,66 @@
+package scala.reflect
+package internal
+
+import language.implicitConversions
+
+trait FlagSets extends api.FlagSets { self: SymbolTable =>
+
+ type FlagSet = Long
+ implicit val FlagSetTag = ClassTag[FlagSet](classOf[FlagSet])
+
+ implicit def addFlagOps(left: FlagSet): FlagOps =
+ new FlagOpsImpl(left)
+
+ private class FlagOpsImpl(left: Long) extends FlagOps {
+ def | (right: Long): Long = left | right
+ def & (right: Long): Long = left & right
+ def containsAll (right: Long): Boolean = (right & ~left) == 0
+ }
+
+ val NoFlags: FlagSet = 0L
+
+ trait FlagValues extends FlagValuesApi
+
+ object Flag extends FlagValues {
+ val TRAIT : FlagSet = Flags.TRAIT
+ val MODULE : FlagSet = Flags.MODULE
+ val MUTABLE : FlagSet = Flags.MUTABLE
+ val PACKAGE : FlagSet = Flags.PACKAGE
+ val METHOD : FlagSet = Flags.METHOD
+ val MACRO : FlagSet = Flags.MACRO
+ val DEFERRED : FlagSet = Flags.DEFERRED
+ val ABSTRACT : FlagSet = Flags.ABSTRACT
+ val FINAL : FlagSet = Flags.FINAL
+ val SEALED : FlagSet = Flags.SEALED
+ val IMPLICIT : FlagSet = Flags.IMPLICIT
+ val LAZY : FlagSet = Flags.LAZY
+ val OVERRIDE : FlagSet = Flags.OVERRIDE
+ val PRIVATE : FlagSet = Flags.PRIVATE
+ val PROTECTED : FlagSet = Flags.PROTECTED
+ val CASE : FlagSet = Flags.CASE
+ val ABSOVERRIDE : FlagSet = Flags.ABSOVERRIDE
+ val BYNAMEPARAM : FlagSet = Flags.BYNAMEPARAM
+ val PARAM : FlagSet = Flags.PARAM
+ val PARAMACCESSOR : FlagSet = Flags.PARAMACCESSOR
+ val CASEACCESSOR : FlagSet = Flags.CASEACCESSOR
+ val COVARIANT : FlagSet = Flags.COVARIANT
+ val CONTRAVARIANT : FlagSet = Flags.CONTRAVARIANT
+ val DEFAULTPARAM : FlagSet = Flags.DEFAULTPARAM
+ val INTERFACE : FlagSet = Flags.INTERFACE
+
+ def union(flags: FlagSet*): FlagSet = {
+ var acc = 0L
+ for (flag <- flags) acc |= flag
+ acc
+ }
+
+ def intersection(flags: FlagSet*): FlagSet = {
+ var acc = -1L
+ for (flag <- flags) acc &= flag
+ acc
+ }
+
+ def containsAll(superset: FlagSet, subset: FlagSet): Boolean =
+ (subset & ~superset) == 0
+ }
+}
diff --git a/src/compiler/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala
index e6820cf78a..37e5a23819 100644
--- a/src/compiler/scala/reflect/internal/Flags.scala
+++ b/src/reflect/scala/reflect/internal/Flags.scala
@@ -6,7 +6,6 @@
package scala.reflect
package internal
-import api.Modifier
import scala.collection.{ mutable, immutable }
// Flags at each index of a flags Long. Those marked with /M are used in
@@ -479,46 +478,6 @@ class Flags extends ModifierFlags {
front.toList ++ (all filterNot (front contains _))
}
final val rawFlagPickledOrder: Array[Long] = pickledListOrder.toArray
-
- def flagOfModifier(mod: Modifier): Long = mod match {
- case Modifier.`protected` => PROTECTED
- case Modifier.`private` => PRIVATE
- case Modifier.`override` => OVERRIDE
- case Modifier.`abstract` => ABSTRACT
- case Modifier.`final` => FINAL
- case Modifier.`sealed` => SEALED
- case Modifier.`implicit` => IMPLICIT
- case Modifier.`lazy` => LAZY
- case Modifier.`case` => CASE
- case Modifier.`trait` => TRAIT
- case Modifier.deferred => DEFERRED
- case Modifier.interface => INTERFACE
- case Modifier.mutable => MUTABLE
- case Modifier.parameter => PARAM
- case Modifier.`macro` => MACRO
- case Modifier.covariant => COVARIANT
- case Modifier.contravariant => CONTRAVARIANT
- case Modifier.preSuper => PRESUPER
- case Modifier.abstractOverride => ABSOVERRIDE
- case Modifier.local => LOCAL
- case Modifier.java => JAVA
- case Modifier.static => STATIC
- case Modifier.caseAccessor => CASEACCESSOR
- case Modifier.defaultParameter => DEFAULTPARAM
- case Modifier.defaultInit => DEFAULTINIT
- case Modifier.paramAccessor => PARAMACCESSOR
- case Modifier.bynameParameter => BYNAMEPARAM
- case _ => 0
- }
-
- def flagsOfModifiers(mods: List[Modifier]): Long =
- (mods :\ 0L) { (mod, curr) => curr | flagOfModifier(mod) }
-
- def modifierOfFlag(flag: Long): Option[Modifier] =
- Modifier.values find { mod => flagOfModifier(mod) == flag }
-
- def modifiersOfFlags(flags: Long): List[Modifier] =
- pickledListOrder map (mask => modifierOfFlag(flags & mask)) flatMap { mod => mod }
}
object Flags extends Flags { }
diff --git a/src/compiler/scala/reflect/internal/HasFlags.scala b/src/reflect/scala/reflect/internal/HasFlags.scala
index 0937577ca3..c7c0882209 100644
--- a/src/compiler/scala/reflect/internal/HasFlags.scala
+++ b/src/reflect/scala/reflect/internal/HasFlags.scala
@@ -102,6 +102,7 @@ trait HasFlags {
def isOverride = hasFlag(OVERRIDE)
def isParamAccessor = hasFlag(PARAMACCESSOR)
def isPrivate = hasFlag(PRIVATE)
+ def isPackage = hasFlag(PACKAGE)
def isPrivateLocal = hasAllFlags(PrivateLocal)
def isProtected = hasFlag(PROTECTED)
def isProtectedLocal = hasAllFlags(ProtectedLocal)
diff --git a/src/compiler/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index 6d6a0ec317..431d9819a5 100644
--- a/src/compiler/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -2,6 +2,7 @@ package scala.reflect
package internal
import scala.collection.mutable.WeakHashMap
+// todo: move importers to a mirror
trait Importers { self: SymbolTable =>
// [Eugene] possible to make this less cast-heavy?
@@ -70,9 +71,9 @@ trait Importers { self: SymbolTable =>
linkReferenced(myowner.newMethod(myname, mypos, myflags), x, importSymbol)
case x: from.ModuleSymbol =>
linkReferenced(myowner.newModuleSymbol(myname, mypos, myflags), x, importSymbol)
- case x: from.FreeTerm =>
+ case x: from.FreeTermSymbol =>
newFreeTermSymbol(importName(x.name).toTermName, importType(x.info), x.value, x.flags, x.origin)
- case x: from.FreeType =>
+ case x: from.FreeTypeSymbol =>
newFreeTypeSymbol(importName(x.name).toTypeName, importType(x.info), x.value, x.flags, x.origin)
case x: from.TermSymbol =>
linkReferenced(myowner.newValue(myname, mypos, myflags), x, importSymbol)
@@ -124,7 +125,7 @@ trait Importers { self: SymbolTable =>
else if (sym == from.NoSymbol)
NoSymbol
else if (sym.isRoot)
- definitions.RootClass
+ rootMirror.RootClass // !!! replace with actual mirror when we move importers to the mirror
else {
val name = sym.name
val owner = sym.owner
@@ -376,8 +377,6 @@ trait Importers { self: SymbolTable =>
new ApplyToImplicitArgs(importTree(fun), args map importTree)
case _: from.ApplyImplicitView =>
new ApplyImplicitView(importTree(fun), args map importTree)
- case _: from.ApplyConstructor =>
- new ApplyConstructor(importTree(fun), args map importTree)
case _ =>
new Apply(importTree(fun), args map importTree)
}
@@ -418,17 +417,17 @@ trait Importers { self: SymbolTable =>
}
addFixup({
if (mytree != null) {
- val mysym = if (tree hasSymbol) importSymbol(tree.symbol) else NoSymbol
+ val mysym = if (tree.hasSymbol) importSymbol(tree.symbol) else NoSymbol
val mytpe = importType(tree.tpe)
mytree match {
case mytt: TypeTree =>
val tt = tree.asInstanceOf[from.TypeTree]
- if (mytree hasSymbol) mytt.symbol = mysym
+ if (mytree.hasSymbol) mytt.symbol = mysym
if (tt.wasEmpty) mytt.defineType(mytpe) else mytt.setType(mytpe)
if (tt.original != null) mytt.setOriginal(importTree(tt.original))
case _ =>
- if (mytree hasSymbol) mytree.symbol = importSymbol(tree.symbol)
+ if (mytree.hasSymbol) mytree.symbol = importSymbol(tree.symbol)
mytree.tpe = importType(tree.tpe)
}
}
diff --git a/src/compiler/scala/reflect/internal/InfoTransformers.scala b/src/reflect/scala/reflect/internal/InfoTransformers.scala
index e53f714c0c..e53f714c0c 100644
--- a/src/compiler/scala/reflect/internal/InfoTransformers.scala
+++ b/src/reflect/scala/reflect/internal/InfoTransformers.scala
diff --git a/src/compiler/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala
index eca63c7c15..b736a9192f 100644
--- a/src/compiler/scala/reflect/internal/Kinds.scala
+++ b/src/reflect/scala/reflect/internal/Kinds.scala
@@ -7,7 +7,7 @@ package scala.reflect
package internal
import scala.collection.{ mutable, immutable }
-import scala.tools.util.StringOps.{ countAsString, countElementsAsString }
+import scala.reflect.internal.util.StringOps.{ countAsString, countElementsAsString }
trait Kinds {
self: SymbolTable =>
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala
new file mode 100644
index 0000000000..e3680b14d5
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/Mirrors.scala
@@ -0,0 +1,243 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.reflect
+package internal
+
+import Flags._
+
+trait Mirrors extends api.Mirrors {
+ self: SymbolTable =>
+
+ override type Mirror >: Null <: RootsBase
+
+ abstract class RootsBase(rootOwner: Symbol) extends MirrorOf[Mirrors.this.type] { thisMirror =>
+
+ protected[scala] def rootLoader: LazyType
+
+ val RootClass: ClassSymbol
+ val RootPackage: ModuleSymbol
+ val EmptyPackageClass: ClassSymbol
+ val EmptyPackage: ModuleSymbol
+
+ def findMemberFromRoot(fullName: Name): Symbol = {
+ val segs = nme.segments(fullName.toString, fullName.isTermName)
+ if (segs.isEmpty) NoSymbol
+ else definitions.findNamedMember(segs.tail, RootClass.info member segs.head)
+ }
+
+ /** Todo: organize similar to mkStatic in reflect.Base */
+ private def getModuleOrClass(path: Name, len: Int): Symbol = {
+ val point = path lastPos('.', len - 1)
+ val owner =
+ if (point > 0) getModuleOrClass(path.toTermName, point)
+ else RootClass
+ val name = path subName (point + 1, len)
+ val sym = owner.info member name
+ val result = if (path.isTermName) sym.suchThat(_ hasFlag MODULE) else sym
+ if (result != NoSymbol) result
+ else {
+ if (settings.debug.value) { log(sym.info); log(sym.info.members) }//debug
+ mirrorMissingHook(owner, name) orElse symbolTableMissingHook(owner, name) orElse {
+ MissingRequirementError.notFound((if (path.isTermName) "object " else "class ")+path+" in "+thisMirror)
+ }
+ }
+ }
+
+ protected def mirrorMissingHook(owner: Symbol, name: Name): Symbol = NoSymbol
+
+ protected def symbolTableMissingHook(owner: Symbol, name: Name): Symbol = self.missingHook(owner, name)
+
+ /** If you're looking for a class, pass a type name.
+ * If a module, a term name.
+ */
+ private def getModuleOrClass(path: Name): Symbol = getModuleOrClass(path, path.length)
+
+ override def staticClass(fullName: String): ClassSymbol = getRequiredClass(fullName)
+
+ // todo: get rid of most creation methods and keep just staticClass/Module/Package
+
+ def getClassByName(fullname: Name): ClassSymbol = {
+ var result = getModuleOrClass(fullname.toTypeName)
+ while (result.isAliasType) result = result.info.typeSymbol
+ result match {
+ case x: ClassSymbol => x
+ case _ => MissingRequirementError.notFound("class " + fullname)
+ }
+ }
+
+ override def staticModule(fullName: String): ModuleSymbol = getRequiredModule(fullName)
+
+ def getModule(fullname: Name): ModuleSymbol =
+ // [Eugene++] should be a ClassCastException instead?
+ getModuleOrClass(fullname.toTermName) match {
+ case x: ModuleSymbol => x
+ case _ => MissingRequirementError.notFound("object " + fullname)
+ }
+
+ def getPackage(fullname: Name): ModuleSymbol = getModule(fullname)
+
+ def getRequiredPackage(fullname: String): ModuleSymbol =
+ getPackage(newTermNameCached(fullname))
+
+ @deprecated("Use getClassByName", "2.10.0")
+ def getClass(fullname: Name): ClassSymbol = getClassByName(fullname)
+
+ def getRequiredClass(fullname: String): ClassSymbol =
+ getClassByName(newTypeNameCached(fullname)) match {
+ case x: ClassSymbol => x
+ case _ => MissingRequirementError.notFound("class " + fullname)
+ }
+
+ def getRequiredModule(fullname: String): ModuleSymbol =
+ getModule(newTermNameCached(fullname))
+
+ def erasureName[T: ClassTag] : String = {
+ /** We'd like the String representation to be a valid
+ * scala type, so we have to decode the jvm's secret language.
+ */
+ def erasureString(clazz: Class[_]): String = {
+ if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]"
+ else clazz.getName
+ }
+ erasureString(classTag[T].runtimeClass)
+ }
+
+ def requiredClass[T: ClassTag] : ClassSymbol =
+ getRequiredClass(erasureName[T])
+
+ // 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
+ // no accompanying Predef class, and if you say requiredModule[scala.Predef.type]
+ // the name found via the erasure is scala.Predef$. For now I am
+ // removing the trailing $, but I think that classTag should have
+ // a method which returns a usable name, one which doesn't expose this
+ // detail of the backend.
+ def requiredModule[T: ClassTag] : ModuleSymbol =
+ getRequiredModule(erasureName[T] stripSuffix "$")
+
+ def getClassIfDefined(fullname: String): Symbol =
+ getClassIfDefined(newTypeName(fullname))
+
+ def getClassIfDefined(fullname: Name): Symbol =
+ wrapMissing(getClassByName(fullname.toTypeName))
+
+ def getModuleIfDefined(fullname: String): Symbol =
+ getModuleIfDefined(newTermName(fullname))
+
+ def getModuleIfDefined(fullname: Name): Symbol =
+ wrapMissing(getModule(fullname.toTermName))
+
+ def getPackageObject(fullname: String): ModuleSymbol =
+ (getModule(newTermName(fullname)).info member nme.PACKAGE) match {
+ case x: ModuleSymbol => x
+ case _ => MissingRequirementError.notFound("package object " + fullname)
+ }
+
+ def getPackageObjectIfDefined(fullname: String): Symbol = {
+ val module = getModuleIfDefined(newTermName(fullname))
+ if (module == NoSymbol) NoSymbol
+ else {
+ val packageObject = module.info member nme.PACKAGE
+ packageObject match {
+ case x: ModuleSymbol => x
+ case _ => NoSymbol
+ }
+ }
+ }
+
+ @inline private def wrapMissing(body: => Symbol): Symbol =
+ try body
+ catch { case _: MissingRequirementError => NoSymbol }
+
+ /** getModule2/getClass2 aren't needed at present but may be again,
+ * so for now they're mothballed.
+ */
+ // def getModule2(name1: Name, name2: Name) = {
+ // try getModuleOrClass(name1.toTermName)
+ // catch { case ex1: FatalError =>
+ // try getModuleOrClass(name2.toTermName)
+ // catch { case ex2: FatalError => throw ex1 }
+ // }
+ // }
+ // def getClass2(name1: Name, name2: Name) = {
+ // try {
+ // val result = getModuleOrClass(name1.toTypeName)
+ // if (result.isAliasType) getClass(name2) else result
+ // }
+ // catch { case ex1: FatalError =>
+ // try getModuleOrClass(name2.toTypeName)
+ // catch { case ex2: FatalError => throw ex1 }
+ // }
+ // }
+
+ def init() {
+ // Still fiddling with whether it's cleaner to do some of this setup here
+ // or from constructors. The latter approach tends to invite init order issues.
+
+ EmptyPackageClass setInfo ClassInfoType(Nil, newPackageScope(EmptyPackageClass), EmptyPackageClass)
+ EmptyPackage setInfo EmptyPackageClass.tpe
+
+ connectModuleToClass(EmptyPackage, EmptyPackageClass)
+ connectModuleToClass(RootPackage, RootClass)
+
+ RootClass.info.decls enter EmptyPackage
+ RootClass.info.decls enter RootPackage
+ }
+ }
+
+ abstract class Roots(rootOwner: Symbol) extends RootsBase(rootOwner) { thisMirror =>
+
+ // TODO - having these as objects means they elude the attempt to
+ // add synchronization in SynchronizedSymbols. But we should either
+ // flip on object overrides or find some other accomodation, because
+ // lazy vals are unnecessarily expensive relative to objects and it
+ // is very beneficial for a handful of bootstrap symbols to have
+ // first class identities
+ sealed trait WellKnownSymbol extends Symbol {
+ this initFlags TopLevelCreationFlags
+ }
+ // Features common to RootClass and RootPackage, the roots of all
+ // type and term symbols respectively.
+ sealed trait RootSymbol extends WellKnownSymbol {
+ final override def isRootSymbol = true
+ override def owner = rootOwner
+ override def typeOfThis = thisSym.tpe
+ }
+
+ // This is the package _root_. The actual root cannot be referenced at
+ // the source level, but _root_ is essentially a function => <root>.
+ final object RootPackage extends ModuleSymbol(rootOwner, NoPosition, nme.ROOTPKG) with RootSymbol {
+ this setInfo NullaryMethodType(RootClass.tpe)
+ RootClass.sourceModule = this
+
+ override def isRootPackage = true
+ }
+ // This is <root>, the actual root of everything except the package _root_.
+ // <root> and _root_ (RootPackage and RootClass) should be the only "well known"
+ // symbols owned by NoSymbol. All owner chains should go through RootClass,
+ // although it is probable that some symbols are created as direct children
+ // of NoSymbol to ensure they will not be stumbled upon. (We should designate
+ // a better encapsulated place for that.)
+ final object RootClass extends PackageClassSymbol(rootOwner, NoPosition, tpnme.ROOT) with RootSymbol {
+ this setInfo rootLoader
+
+ override def isRoot = true
+ override def isEffectiveRoot = true
+ override def isStatic = true
+ override def isNestedClass = false
+ override def ownerOfNewSymbols = EmptyPackageClass
+ }
+ // The empty package, which holds all top level types without given packages.
+ final object EmptyPackage extends ModuleSymbol(RootClass, NoPosition, nme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
+ override def isEmptyPackage = true
+ }
+ final object EmptyPackageClass extends PackageClassSymbol(RootClass, NoPosition, tpnme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
+ override def isEffectiveRoot = true
+ override def isEmptyPackageClass = true
+ }
+ }
+}
diff --git a/src/compiler/scala/reflect/internal/MissingRequirementError.scala b/src/reflect/scala/reflect/internal/MissingRequirementError.scala
index fbbbcc1928..fbbbcc1928 100644
--- a/src/compiler/scala/reflect/internal/MissingRequirementError.scala
+++ b/src/reflect/scala/reflect/internal/MissingRequirementError.scala
diff --git a/src/compiler/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala
index 23eaa1088c..18671871ae 100644
--- a/src/compiler/scala/reflect/internal/Names.scala
+++ b/src/reflect/scala/reflect/internal/Names.scala
@@ -139,8 +139,8 @@ trait Names extends api.Names {
* or Strings as Names. Give names the key functions the absence of which
* make people want Strings all the time.
*/
- sealed abstract class Name(protected val index: Int, protected val len: Int) extends AbsName with Function1[Int, Char] {
- type ThisNameType <: Name
+ sealed abstract class Name(protected val index: Int, protected val len: Int) extends NameApi with Function1[Int, Char] {
+ type ThisNameType >: Null <: Name
protected[this] def thisName: ThisNameType
/** Index into name table */
@@ -429,15 +429,20 @@ trait Names extends api.Names {
def debugString = { val s = decode ; if (isTypeName) s + "!" else s }
}
+ implicit val NameTag = ClassTag[Name](classOf[Name])
+
/** A name that contains no operator chars nor dollar signs.
* TODO - see if it's any faster to do something along these lines.
+ * Cute: now that exhaustivity kind of works, the mere presence of
+ * this trait causes TermName and TypeName to stop being exhaustive.
+ * Commented out.
*/
- trait AlphaNumName extends Name {
- final override def encode = thisName
- final override def decodedName = thisName
- final override def decode = toString
- final override def isOperatorName = false
- }
+ // trait AlphaNumName extends Name {
+ // final override def encode = thisName
+ // final override def decodedName = thisName
+ // final override def decode = toString
+ // final override def isOperatorName = false
+ // }
/** TermName_S and TypeName_S have fields containing the string version of the name.
* TermName_R and TypeName_R recreate it each time toString is called.
@@ -488,6 +493,8 @@ trait Names extends api.Names {
protected def createCompanionName(h: Int): TypeName
}
+ implicit val TermNameTag = ClassTag[TermName](classOf[TermName])
+
sealed abstract class TypeName(index0: Int, len0: Int, hash: Int) extends Name(index0, len0) {
type ThisNameType = TypeName
protected[this] def thisName: TypeName = this
@@ -515,4 +522,6 @@ trait Names extends api.Names {
override def decode = if (nameDebug) super.decode + "!" else super.decode
protected def createCompanionName(h: Int): TermName
}
+
+ implicit val TypeNameTag = ClassTag[TypeName](classOf[TypeName])
}
diff --git a/src/compiler/scala/reflect/internal/Phase.scala b/src/reflect/scala/reflect/internal/Phase.scala
index 68dc5ce783..68dc5ce783 100644
--- a/src/compiler/scala/reflect/internal/Phase.scala
+++ b/src/reflect/scala/reflect/internal/Phase.scala
diff --git a/src/compiler/scala/reflect/internal/Positions.scala b/src/reflect/scala/reflect/internal/Positions.scala
index 5ec2659098..6ae9b40fcb 100644
--- a/src/compiler/scala/reflect/internal/Positions.scala
+++ b/src/reflect/scala/reflect/internal/Positions.scala
@@ -3,8 +3,9 @@ package internal
trait Positions extends api.Positions { self: SymbolTable =>
- type Position = scala.tools.nsc.util.Position
- val NoPosition = scala.tools.nsc.util.NoPosition
+ type Position = scala.reflect.internal.util.Position
+ val NoPosition = scala.reflect.internal.util.NoPosition
+ implicit val PositionTag = ClassTag[Position](classOf[Position])
/** A position that wraps a set of trees.
* The point of the wrapping position is the point of the default position.
diff --git a/src/compiler/scala/reflect/internal/Required.scala b/src/reflect/scala/reflect/internal/Required.scala
index 6d146354a3..abbe8fbfb7 100644
--- a/src/compiler/scala/reflect/internal/Required.scala
+++ b/src/reflect/scala/reflect/internal/Required.scala
@@ -5,7 +5,7 @@ import settings.MutableSettings
trait Required { self: SymbolTable =>
- type AbstractFileType >: Null <: api.RequiredFile
+ type AbstractFileType >: Null <: AbstractFileApi
def picklerPhase: Phase
diff --git a/src/compiler/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala
index 36e8ebb212..ceacd2afb0 100644
--- a/src/compiler/scala/reflect/internal/Scopes.scala
+++ b/src/reflect/scala/reflect/internal/Scopes.scala
@@ -317,6 +317,8 @@ trait Scopes extends api.Scopes { self: SymbolTable =>
}
+ implicit val ScopeTag = ClassTag[Scope](classOf[Scope])
+
/** Create a new scope */
def newScope: Scope = new Scope()
diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala
new file mode 100644
index 0000000000..4ea9b27da9
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/StdAttachments.scala
@@ -0,0 +1,12 @@
+package scala.reflect
+package internal
+
+trait StdAttachments {
+ self: SymbolTable =>
+
+ case object BackquotedIdentifierAttachment
+
+ case class CompoundTypeTreeOriginalAttachment(parents: List[Tree], stats: List[Tree])
+
+ case class MacroExpansionAttachment(original: Tree)
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/internal/StdCreators.scala b/src/reflect/scala/reflect/internal/StdCreators.scala
new file mode 100644
index 0000000000..3e6b7c1ab4
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/StdCreators.scala
@@ -0,0 +1,21 @@
+package scala.reflect
+package internal
+
+import scala.reflect.base.{TreeCreator, TypeCreator}
+import scala.reflect.base.{Universe => BaseUniverse}
+
+trait StdCreators {
+ self: SymbolTable =>
+
+ case class FixedMirrorTreeCreator(mirror: MirrorOf[StdCreators.this.type], tree: Tree) extends TreeCreator {
+ def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Tree =
+ if (m eq mirror) tree.asInstanceOf[U # Tree]
+ else throw new IllegalArgumentException(s"Expr defined in $mirror cannot be migrated to other mirrors.")
+ }
+
+ case class FixedMirrorTypeCreator(mirror: MirrorOf[StdCreators.this.type], tpe: Type) extends TypeCreator {
+ def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type =
+ if (m eq mirror) tpe.asInstanceOf[U # Type]
+ else throw new IllegalArgumentException(s"Type tag defined in $mirror cannot be migrated to other mirrors.")
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index bd4d9a9f34..bd02013037 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -72,7 +72,7 @@ trait StdNames {
val cs = s.toArray
val bytes = Codec toUTF8 cs
md5 update bytes
- val md5chars = md5.digest() map (b => (b & 0xFF).toHexString) mkString
+ val md5chars = (md5.digest() map (b => (b & 0xFF).toHexString)).mkString
prefix + marker + md5chars + marker + suffix
}
@@ -82,8 +82,8 @@ trait StdNames {
)
}
- abstract class CommonNames {
- type NameType <: Name
+ abstract class CommonNames extends NamesApi {
+ type NameType >: Null <: Name
protected implicit def createNameType(name: String): NameType
def flattenedName(segments: Name*): NameType =
@@ -122,14 +122,16 @@ trait StdNames {
scala.List(Byte, Char, Short, Int, Long, Float, Double, Boolean, Unit)
// some types whose companions we utilize
- final val AnyRef: NameType = "AnyRef"
- final val Array: NameType = "Array"
- final val List: NameType = "List"
- final val Seq: NameType = "Seq"
- final val Symbol: NameType = "Symbol"
- final val ClassTag: NameType = "ClassTag"
- final val TypeTag : NameType = "TypeTag"
- final val ConcreteTypeTag: NameType = "ConcreteTypeTag"
+ final val AnyRef: NameType = "AnyRef"
+ final val Array: NameType = "Array"
+ final val List: NameType = "List"
+ final val Seq: NameType = "Seq"
+ final val Symbol: NameType = "Symbol"
+ final val ClassTag: NameType = "ClassTag"
+ final val AbsTypeTag: NameType = "AbsTypeTag"
+ final val TypeTag : NameType = "TypeTag"
+ final val Expr: NameType = "Expr"
+ final val String: NameType = "String"
// fictions we use as both types and terms
final val ERROR: NameType = "<error>"
@@ -200,7 +202,7 @@ trait StdNames {
final val javaKeywords = new JavaKeywords()
}
- abstract class TypeNames extends Keywords {
+ abstract class TypeNames extends Keywords with TypeNamesApi {
type NameType = TypeName
protected implicit def createNameType(name: String): TypeName = newTypeNameCached(name)
@@ -211,10 +213,13 @@ trait StdNames {
final val REFINE_CLASS_NAME: NameType = "<refinement>"
final val REPEATED_PARAM_CLASS_NAME: NameType = "<repeated>"
final val WILDCARD_STAR: NameType = "_*"
+ final val REIFY_TREECREATOR_PREFIX: NameType = "$treecreator"
+ final val REIFY_TYPECREATOR_PREFIX: NameType = "$typecreator"
final val Any: NameType = "Any"
final val AnyVal: NameType = "AnyVal"
- final val Expr: NameType = "Expr"
+ final val ExprApi: NameType = "ExprApi"
+ final val Mirror: NameType = "Mirror"
final val Nothing: NameType = "Nothing"
final val Null: NameType = "Null"
final val Object: NameType = "Object"
@@ -223,15 +228,15 @@ trait StdNames {
final val Product: NameType = "Product"
final val Serializable: NameType = "Serializable"
final val Singleton: NameType = "Singleton"
- final val String: NameType = "String"
final val Throwable: NameType = "Throwable"
final val Annotation: NameType = "Annotation"
final val ClassfileAnnotation: NameType = "ClassfileAnnotation"
final val Enum: NameType = "Enum"
- final val Group: NameType = "Group"
- final val Tree: NameType = "Tree"
- final val TypeTree: NameType = "TypeTree"
+ final val Group: NameType = "Group"
+ final val Tree: NameType = "Tree"
+ final val Type : NameType = "Type"
+ final val TypeTree: NameType = "TypeTree"
// Annotation simple names, used in Namer
final val BeanPropertyAnnot: NameType = "BeanProperty"
@@ -257,13 +262,13 @@ trait StdNames {
final val SourceFileATTR: NameType = "SourceFile"
final val SyntheticATTR: NameType = "Synthetic"
- def dropSingletonName(name: Name): TypeName = name dropRight SINGLETON_SUFFIX.length toTypeName
- def singletonName(name: Name): TypeName = name append SINGLETON_SUFFIX toTypeName
- def implClassName(name: Name): TypeName = name append IMPL_CLASS_SUFFIX toTypeName
- def interfaceName(implname: Name): TypeName = implname dropRight IMPL_CLASS_SUFFIX.length toTypeName
+ def dropSingletonName(name: Name): TypeName = (name dropRight SINGLETON_SUFFIX.length).toTypeName
+ def singletonName(name: Name): TypeName = (name append SINGLETON_SUFFIX).toTypeName
+ def implClassName(name: Name): TypeName = (name append IMPL_CLASS_SUFFIX).toTypeName
+ def interfaceName(implname: Name): TypeName = (implname dropRight IMPL_CLASS_SUFFIX.length).toTypeName
}
- abstract class TermNames extends Keywords {
+ abstract class TermNames extends Keywords with TermNamesApi {
type NameType = TermName
protected implicit def createNameType(name: String): TermName = newTermNameCached(name)
@@ -290,22 +295,29 @@ trait StdNames {
// Compiler internal names
val ANYNAME: NameType = "<anyname>"
val CONSTRUCTOR: NameType = "<init>"
+ val EQEQ_LOCAL_VAR: NameType = "eqEqTemp$"
val FAKE_LOCAL_THIS: NameType = "this$"
val INITIALIZER: NameType = CONSTRUCTOR // Is this buying us something?
val LAZY_LOCAL: NameType = "$lzy"
val LAZY_SLOW_SUFFIX: NameType = "$lzycompute"
val LOCAL_SUFFIX_STRING = " "
- val MIRROR_FREE_PREFIX: NameType = "free$"
- val MIRROR_FREE_THIS_SUFFIX: NameType = "$this"
- val MIRROR_FREE_VALUE_SUFFIX: NameType = "$value"
- val MIRROR_PREFIX: NameType = "$mr."
- val MIRROR_SHORT: NameType = "$mr"
- val MIRROR_SYMDEF_PREFIX: NameType = "symdef$"
+ val UNIVERSE_BUILD_PREFIX: NameType = "$u.build."
+ val UNIVERSE_BUILD: NameType = "$u.build"
+ val UNIVERSE_PREFIX: NameType = "$u."
+ val UNIVERSE_SHORT: NameType = "$u"
+ val MIRROR_PREFIX: NameType = "$m."
+ val MIRROR_SHORT: NameType = "$m"
+ val MIRROR_UNTYPED: NameType = "$m$untyped"
+ val REIFY_FREE_PREFIX: NameType = "free$"
+ val REIFY_FREE_THIS_SUFFIX: NameType = "$this"
+ val REIFY_FREE_VALUE_SUFFIX: NameType = "$value"
+ val REIFY_SYMDEF_PREFIX: NameType = "symdef$"
val MIXIN_CONSTRUCTOR: NameType = "$init$"
val MODULE_INSTANCE_FIELD: NameType = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$"
val OUTER: NameType = "$outer"
val OUTER_LOCAL: NameType = OUTER + LOCAL_SUFFIX_STRING // "$outer ", note the space
val OUTER_SYNTH: NameType = "<outer>" // emitted by virtual pattern matcher, replaced by outer accessor in explicitouter
+ val ROOTPKG: NameType = "_root_"
val SELECTOR_DUMMY: NameType = "<unapply-selector>"
val SELF: NameType = "$this"
val SETTER_SUFFIX: NameType = encode("_=")
@@ -511,6 +523,32 @@ trait StdNames {
case _ => newTermName("x$" + i)
}
+ @switch def productAccessorName(j: Int): TermName = j match {
+ case 1 => nme._1
+ case 2 => nme._2
+ case 3 => nme._3
+ case 4 => nme._4
+ case 5 => nme._5
+ case 6 => nme._6
+ case 7 => nme._7
+ case 8 => nme._8
+ case 9 => nme._9
+ case 10 => nme._10
+ case 11 => nme._11
+ case 12 => nme._12
+ case 13 => nme._13
+ case 14 => nme._14
+ case 15 => nme._15
+ case 16 => nme._16
+ case 17 => nme._17
+ case 18 => nme._18
+ case 19 => nme._19
+ case 20 => nme._20
+ case 21 => nme._21
+ case 22 => nme._22
+ case _ => newTermName("_" + j)
+ }
+
val ??? = encode("???")
val wrapRefArray: NameType = "wrapRefArray"
@@ -539,12 +577,14 @@ trait StdNames {
val EmptyPackage: NameType = "EmptyPackage"
val EmptyPackageClass: NameType = "EmptyPackageClass"
val ExistentialTypeTree: NameType = "ExistentialTypeTree"
- val Expr: NameType = "Expr"
+ val Flag : NameType = "Flag"
val Ident: NameType = "Ident"
val Import: NameType = "Import"
val Literal: NameType = "Literal"
val LiteralAnnotArg: NameType = "LiteralAnnotArg"
+ val Modifiers: NameType = "Modifiers"
val NestedAnnotArg: NameType = "NestedAnnotArg"
+ val NoFlags: NameType = "NoFlags"
val NoPrefix: NameType = "NoPrefix"
val NoSymbol: NameType = "NoSymbol"
val Nothing: NameType = "Nothing"
@@ -556,6 +596,7 @@ trait StdNames {
val Select: NameType = "Select"
val StringContext: NameType = "StringContext"
val This: NameType = "This"
+ val ThisType: NameType = "ThisType"
val Tree : NameType = "Tree"
val Tuple2: NameType = "Tuple2"
val TYPE_ : NameType = "TYPE"
@@ -570,32 +611,40 @@ trait StdNames {
val apply: NameType = "apply"
val applyDynamic: NameType = "applyDynamic"
val applyDynamicNamed: NameType = "applyDynamicNamed"
+ val applyImpl: NameType = "applyImpl"
val applyOrElse: NameType = "applyOrElse"
val args : NameType = "args"
val argv : NameType = "argv"
val arrayClass: NameType = "arrayClass"
val arrayElementClass: NameType = "arrayElementClass"
- val arrayTagToClassManifest: NameType = "arrayTagToClassManifest"
val arrayValue: NameType = "arrayValue"
val array_apply : NameType = "array_apply"
val array_clone : NameType = "array_clone"
val array_length : NameType = "array_length"
val array_update : NameType = "array_update"
val arraycopy: NameType = "arraycopy"
+ val asTermSymbol: NameType = "asTermSymbol"
+ val asModuleSymbol: NameType = "asModuleSymbol"
+ val asMethodSymbol: NameType = "asMethodSymbol"
+ val asTypeSymbol: NameType = "asTypeSymbol"
+ val asClassSymbol: NameType = "asClassSymbol"
val asInstanceOf_ : NameType = "asInstanceOf"
val asInstanceOf_Ob : NameType = "$asInstanceOf"
val asTypeConstructor: NameType = "asTypeConstructor"
val assert_ : NameType = "assert"
val assume_ : NameType = "assume"
+ val basis : NameType = "basis"
val box: NameType = "box"
+ val build : NameType = "build"
val bytes: NameType = "bytes"
val canEqual_ : NameType = "canEqual"
val checkInitialized: NameType = "checkInitialized"
val classOf: NameType = "classOf"
+ val classTagToClassManifest: NameType = "classTagToClassManifest"
val clone_ : NameType = if (forMSIL) "MemberwiseClone" else "clone" // sn.OClone causes checkinit failure
- val concreteTypeTagToManifest: NameType = "concreteTypeTagToManifest"
val conforms: NameType = "conforms"
val copy: NameType = "copy"
+ val currentMirror: NameType = "currentMirror"
val definitions: NameType = "definitions"
val delayedInit: NameType = "delayedInit"
val delayedInitArg: NameType = "delayedInit$body"
@@ -608,7 +657,6 @@ trait StdNames {
val equalsNumNum : NameType = "equalsNumNum"
val equalsNumObject : NameType = "equalsNumObject"
val equals_ : NameType = if (forMSIL) "Equals" else "equals"
- val erasure: NameType = "erasure"
val error: NameType = "error"
val eval: NameType = "eval"
val ex: NameType = "ex"
@@ -617,6 +665,7 @@ trait StdNames {
val filter: NameType = "filter"
val finalize_ : NameType = if (forMSIL) "Finalize" else "finalize"
val find_ : NameType = "find"
+ val flagsFromBits : NameType = "flagsFromBits"
val flatMap: NameType = "flatMap"
val foreach: NameType = "foreach"
val genericArrayOps: NameType = "genericArrayOps"
@@ -627,6 +676,8 @@ trait StdNames {
val hash_ : NameType = "hash"
val head: NameType = "head"
val identity: NameType = "identity"
+ val implicitly: NameType = "implicitly"
+ val in: NameType = "in"
val info: NameType = "info"
val inlinedEquals: NameType = "inlinedEquals"
val isArray: NameType = "isArray"
@@ -645,12 +696,10 @@ trait StdNames {
val macroContext : NameType = "c"
val main: NameType = "main"
val manifest: NameType = "manifest"
- val manifestToConcreteTypeTag: NameType = "manifestToConcreteTypeTag"
+ val manifestToTypeTag: NameType = "manifestToTypeTag"
val map: NameType = "map"
- val materializeArrayTag: NameType = "materializeArrayTag"
val materializeClassTag: NameType = "materializeClassTag"
- val materializeConcreteTypeTag: NameType = "materializeConcreteTypeTag"
- val materializeErasureTag: NameType= "materializeErasureTag"
+ val materializeAbsTypeTag: NameType = "materializeAbsTypeTag"
val materializeTypeTag: NameType = "materializeTypeTag"
val mirror : NameType = "mirror"
val moduleClass : NameType = "moduleClass"
@@ -679,8 +728,11 @@ trait StdNames {
val readResolve: NameType = "readResolve"
val reflect : NameType = "reflect"
val reify : NameType = "reify"
+ val rootMirror : NameType = "rootMirror"
val runOrElse: NameType = "runOrElse"
val runtime: NameType = "runtime"
+ val runtimeClass: NameType = "runtimeClass"
+ val runtimeMirror: NameType = "runtimeMirror"
val sameElements: NameType = "sameElements"
val scala_ : NameType = "scala"
val selectDynamic: NameType = "selectDynamic"
@@ -693,13 +745,14 @@ trait StdNames {
val setSymbol: NameType = "setSymbol"
val setType: NameType = "setType"
val setTypeSignature: NameType = "setTypeSignature"
+ val splice: NameType = "splice"
val staticClass : NameType = "staticClass"
val staticModule : NameType = "staticModule"
val synchronized_ : NameType = "synchronized"
val tail: NameType = "tail"
val `then` : NameType = "then"
- val thisModuleType: NameType = "thisModuleType"
val this_ : NameType = "this"
+ val thisPrefix : NameType = "thisPrefix"
val throw_ : NameType = "throw"
val toArray: NameType = "toArray"
val toList: NameType = "toList"
@@ -710,9 +763,11 @@ trait StdNames {
val tree : NameType = "tree"
val true_ : NameType = "true"
val typedProductIterator: NameType = "typedProductIterator"
+ val typeTagToManifest: NameType = "typeTagToManifest"
val unapply: NameType = "unapply"
val unapplySeq: NameType = "unapplySeq"
val unbox: NameType = "unbox"
+ val universe: NameType = "universe"
val update: NameType = "update"
val updateDynamic: NameType = "updateDynamic"
val value: NameType = "value"
@@ -757,90 +812,10 @@ trait StdNames {
// overlap with the above, but not for these two.
val toCharacter: NameType = "toCharacter"
val toInteger: NameType = "toInteger"
- }
-
- object tpnme extends TypeNames with AbsTypeNames { }
-
- /** For fully qualified type names.
- */
- object fulltpnme extends TypeNames {
- val RuntimeNothing: NameType = "scala.runtime.Nothing$"
- val RuntimeNull: NameType = "scala.runtime.Null$"
- }
-
- /** Java binary names, like scala/runtime/Nothing$.
- */
- object binarynme {
- def toBinary(name: Name) = name mapName (_.replace('.', '/'))
-
- val RuntimeNothing = toBinary(fulltpnme.RuntimeNothing).toTypeName
- val RuntimeNull = toBinary(fulltpnme.RuntimeNull).toTypeName
- }
-
- val javanme = nme.javaKeywords
-
- object nme extends TermNames with AbsTermNames {
-
- /** Translate a String into a list of simple TypeNames and TermNames.
- * In all segments before the last, type/term is determined by whether
- * the following separator char is '.' or '#'. In the last segment,
- * the argument "assumeTerm" determines it. Examples:
- *
- * package foo {
- * object Lorax { object Wog ; class Wog }
- * class Lorax { object Zax ; class Zax }
- * }
- *
- * f("foo.Lorax", true) == List("foo": Term, "Lorax": Term) // object Lorax
- * f("foo.Lorax", false) == List("foo": Term, "Lorax": Type) // class Lorax
- * f("Lorax.Wog", true) == List("Lorax": Term, "Wog": Term) // object Wog
- * f("Lorax.Wog", false) == List("Lorax": Term, "Wog": Type) // class Wog
- * f("Lorax#Zax", true) == List("Lorax": Type, "Zax": Term) // object Zax
- * f("Lorax#Zax", false) == List("Lorax": Type, "Zax": Type) // class Zax
- *
- * Note that in actual scala syntax you cannot refer to object Zax without an
- * instance of Lorax, so Lorax#Zax could only mean the type. One might think
- * that Lorax#Zax.type would work, but this is not accepted by the parser.
- * For the purposes of referencing that object, the syntax is allowed.
- */
- def segments(name: String, assumeTerm: Boolean): List[Name] = {
- def mkName(str: String, term: Boolean): Name =
- if (term) newTermName(str) else newTypeName(str)
-
- name.indexWhere(ch => ch == '.' || ch == '#') match {
- // it's the last segment: the parameter tells us whether type or term
- case -1 => if (name == "") scala.Nil else scala.List(mkName(name, assumeTerm))
- // otherwise, we can tell based on whether '#' or '.' is the following char.
- case idx =>
- val (simple, div, rest) = (name take idx, name charAt idx, newTermName(name) drop (idx + 1))
- mkName(simple, div == '.') :: segments(rest, assumeTerm)
- }
- }
-
- def newBitmapName(bitmapPrefix: Name, n: Int) = bitmapPrefix append ("" + n)
-
- val BITMAP_NORMAL: NameType = BITMAP_PREFIX + "" // initialization bitmap for public/protected lazy vals
- val BITMAP_TRANSIENT: NameType = BITMAP_PREFIX + "trans$" // initialization bitmap for transient lazy vals
- val BITMAP_CHECKINIT: NameType = BITMAP_PREFIX + "init$" // initialization bitmap for checkinit values
- val BITMAP_CHECKINIT_TRANSIENT: NameType = BITMAP_PREFIX + "inittrans$" // initialization bitmap for transient checkinit values
def newLazyValSlowComputeName(lzyValName: Name) = lzyValName append LAZY_SLOW_SUFFIX
- def isModuleVarName(name: Name): Boolean =
- stripAnonNumberSuffix(name) endsWith MODULE_VAR_SUFFIX
-
- def moduleVarName(name: TermName): TermName =
- newTermNameCached("" + name + MODULE_VAR_SUFFIX)
-
- val ROOTPKG: TermName = "_root_"
- val EQEQ_LOCAL_VAR: TermName = "eqEqTemp$"
-
- def getCause = sn.GetCause
- def getClass_ = sn.GetClass
- def getComponentType = sn.GetComponentType
- def getMethod_ = sn.GetMethod
- def invoke_ = sn.Invoke
-
+ // ASCII names for operators
val ADD = encode("+")
val AND = encode("&")
val ASR = encode(">>")
@@ -906,9 +881,6 @@ trait StdNames {
val testLessThan: NameType = "testLessThan"
val testNotEqual: NameType = "testNotEqual"
- val isBoxedNumberOrBoolean: NameType = "isBoxedNumberOrBoolean"
- val isBoxedNumber: NameType = "isBoxedNumber"
-
def toUnaryName(name: TermName): TermName = name match {
case raw.MINUS => UNARY_-
case raw.PLUS => UNARY_+
@@ -958,6 +930,90 @@ trait StdNames {
case _ => NO_NAME
}
+ /** Translate a String into a list of simple TypeNames and TermNames.
+ * In all segments before the last, type/term is determined by whether
+ * the following separator char is '.' or '#'. In the last segment,
+ * the argument "assumeTerm" determines it. Examples:
+ *
+ * package foo {
+ * object Lorax { object Wog ; class Wog }
+ * class Lorax { object Zax ; class Zax }
+ * }
+ *
+ * f("foo.Lorax", true) == List("foo": Term, "Lorax": Term) // object Lorax
+ * f("foo.Lorax", false) == List("foo": Term, "Lorax": Type) // class Lorax
+ * f("Lorax.Wog", true) == List("Lorax": Term, "Wog": Term) // object Wog
+ * f("Lorax.Wog", false) == List("Lorax": Term, "Wog": Type) // class Wog
+ * f("Lorax#Zax", true) == List("Lorax": Type, "Zax": Term) // object Zax
+ * f("Lorax#Zax", false) == List("Lorax": Type, "Zax": Type) // class Zax
+ *
+ * Note that in actual scala syntax you cannot refer to object Zax without an
+ * instance of Lorax, so Lorax#Zax could only mean the type. One might think
+ * that Lorax#Zax.type would work, but this is not accepted by the parser.
+ * For the purposes of referencing that object, the syntax is allowed.
+ */
+ def segments(name: String, assumeTerm: Boolean): List[Name] = {
+ def mkName(str: String, term: Boolean): Name =
+ if (term) newTermName(str) else newTypeName(str)
+
+ name.indexWhere(ch => ch == '.' || ch == '#') match {
+ // it's the last segment: the parameter tells us whether type or term
+ case -1 => if (name == "") scala.Nil else scala.List(mkName(name, assumeTerm))
+ // otherwise, we can tell based on whether '#' or '.' is the following char.
+ case idx =>
+ val (simple, div, rest) = (name take idx, name charAt idx, newTermName(name) drop (idx + 1))
+ mkName(simple, div == '.') :: segments(rest, assumeTerm)
+ }
+ }
+
+ def newBitmapName(bitmapPrefix: Name, n: Int) = bitmapPrefix append ("" + n)
+
+ val BITMAP_NORMAL: NameType = BITMAP_PREFIX + "" // initialization bitmap for public/protected lazy vals
+ val BITMAP_TRANSIENT: NameType = BITMAP_PREFIX + "trans$" // initialization bitmap for transient lazy vals
+ val BITMAP_CHECKINIT: NameType = BITMAP_PREFIX + "init$" // initialization bitmap for checkinit values
+ val BITMAP_CHECKINIT_TRANSIENT: NameType = BITMAP_PREFIX + "inittrans$" // initialization bitmap for transient checkinit values
+ }
+
+ object tpnme extends TypeNames { }
+
+ /** For fully qualified type names.
+ */
+ object fulltpnme extends TypeNames {
+ val RuntimeNothing: NameType = "scala.runtime.Nothing$"
+ val RuntimeNull: NameType = "scala.runtime.Null$"
+ val JavaLangEnum: NameType = "java.lang.Enum"
+ }
+
+ /** Java binary names, like scala/runtime/Nothing$.
+ */
+ object binarynme {
+ def toBinary(name: Name) = name mapName (_.replace('.', '/'))
+
+ val RuntimeNothing = toBinary(fulltpnme.RuntimeNothing).toTypeName
+ val RuntimeNull = toBinary(fulltpnme.RuntimeNull).toTypeName
+ }
+
+ val javanme = nme.javaKeywords
+
+ // [Eugene++ to Martin] had to move a lot of stuff from here to TermNames to satisfy the contract
+ // why do we even have stuff in object nme? cf. object tpnme
+ object nme extends TermNames {
+
+ def isModuleVarName(name: Name): Boolean =
+ stripAnonNumberSuffix(name) endsWith MODULE_VAR_SUFFIX
+
+ def moduleVarName(name: TermName): TermName =
+ newTermNameCached("" + name + MODULE_VAR_SUFFIX)
+
+ def getCause = sn.GetCause
+ def getClass_ = sn.GetClass
+ def getComponentType = sn.GetComponentType
+ def getMethod_ = sn.GetMethod
+ def invoke_ = sn.Invoke
+
+ val isBoxedNumberOrBoolean: NameType = "isBoxedNumberOrBoolean"
+ val isBoxedNumber: NameType = "isBoxedNumber"
+
val reflPolyCacheName: NameType = "reflPoly$Cache"
val reflClassCacheName: NameType = "reflClass$Cache"
val reflParamsCacheName: NameType = "reflParams$Cache"
@@ -973,32 +1029,6 @@ trait StdNames {
)
def isReflectionCacheName(name: Name) = reflectionCacheNames exists (name startsWith _)
- @switch def productAccessorName(j: Int): TermName = j match {
- case 1 => nme._1
- case 2 => nme._2
- case 3 => nme._3
- case 4 => nme._4
- case 5 => nme._5
- case 6 => nme._6
- case 7 => nme._7
- case 8 => nme._8
- case 9 => nme._9
- case 10 => nme._10
- case 11 => nme._11
- case 12 => nme._12
- case 13 => nme._13
- case 14 => nme._14
- case 15 => nme._15
- case 16 => nme._16
- case 17 => nme._17
- case 18 => nme._18
- case 19 => nme._19
- case 20 => nme._20
- case 21 => nme._21
- case 22 => nme._22
- case _ => newTermName("_" + j)
- }
-
@deprecated("Use a method in tpnme", "2.10.0") def dropSingletonName(name: Name): TypeName = tpnme.dropSingletonName(name)
@deprecated("Use a method in tpnme", "2.10.0") def singletonName(name: Name): TypeName = tpnme.singletonName(name)
@deprecated("Use a method in tpnme", "2.10.0") def implClassName(name: Name): TypeName = tpnme.implClassName(name)
@@ -1028,6 +1058,7 @@ trait StdNames {
val ForName : TermName
val GetCause : TermName
val GetClass : TermName
+ val GetClassLoader : TermName
val GetComponentType : TermName
val GetMethod : TermName
val Invoke : TermName
@@ -1117,6 +1148,7 @@ trait StdNames {
final val ForName: TermName = newTermName("forName")
final val GetCause: TermName = newTermName("getCause")
final val GetClass: TermName = newTermName("getClass")
+ final val GetClassLoader: TermName = newTermName("getClassLoader")
final val GetComponentType: TermName = newTermName("getComponentType")
final val GetMethod: TermName = newTermName("getMethod")
final val Invoke: TermName = newTermName("invoke")
@@ -1155,6 +1187,7 @@ trait StdNames {
final val ForName: TermName = newTermName("GetType")
final val GetCause: TermName = newTermName("InnerException") /* System.Reflection.TargetInvocationException.InnerException */
final val GetClass: TermName = newTermName("GetType")
+ final lazy val GetClassLoader: TermName = throw new UnsupportedOperationException("Scala reflection is not supported on this platform");
final val GetComponentType: TermName = newTermName("GetElementType")
final val GetMethod: TermName = newTermName("GetMethod")
final val Invoke: TermName = newTermName("Invoke")
diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index ddd6c43031..cadd76b1ba 100644
--- a/src/compiler/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -8,17 +8,17 @@ package internal
import scala.collection.{ mutable, immutable }
import util._
-import scala.tools.nsc.util.WeakHashSet
-abstract class SymbolTable extends api.Universe
+abstract class SymbolTable extends makro.Universe
with Collections
with Names
with Symbols
- with FreeVars
with Types
with Kinds
with ExistentialsAndSkolems
+ with FlagSets
with Scopes
+ with Mirrors
with Definitions
with Constants
with BaseTypeSeqs
@@ -33,12 +33,15 @@ abstract class SymbolTable extends api.Universe
with TypeDebugging
with Importers
with Required
- with TreeBuildUtil
- with FrontEnds
with CapturedVariables
with StdAttachments
+ with StdCreators
+ with BuildUtils
{
- def rootLoader: LazyType
+
+ val gen = new TreeGen { val global: SymbolTable.this.type = SymbolTable.this }
+ val treeBuild = gen
+
def log(msg: => AnyRef): Unit
def abort(msg: String): Nothing = throw new FatalError(supplementErrorMessage(msg))
@@ -110,6 +113,9 @@ abstract class SymbolTable extends api.Universe
*/
def missingHook(owner: Symbol, name: Name): Symbol = NoSymbol
+ /** Returns the mirror that loaded given symbol */
+ def mirrorThatLoaded(sym: Symbol): Mirror
+
/** A period is an ordinal number for a phase in a run.
* Phases in later runs have higher periods than phases in earlier runs.
* Later phases have higher periods than earlier phases in the same run.
@@ -295,7 +301,6 @@ abstract class SymbolTable extends api.Universe
def clearAll() = {
debuglog("Clearing " + caches.size + " caches.")
-
caches foreach { ref =>
val cache = ref.get()
if (cache == null)
@@ -321,8 +326,7 @@ abstract class SymbolTable extends api.Universe
/** The phase which has given index as identifier. */
val phaseWithId: Array[Phase]
- /** Is this symbol table part of reflexive mirror? In this case
- * operations need to be made thread safe.
+ /** Is this symbol table a part of a compiler universe?
*/
- def inReflexiveMirror = false
+ def isCompilerUniverse = false
}
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index b32b955631..288eb63332 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -10,7 +10,6 @@ import scala.collection.{ mutable, immutable }
import scala.collection.mutable.ListBuffer
import util.Statistics._
import Flags._
-import api.Modifier
trait Symbols extends api.Symbols { self: SymbolTable =>
import definitions._
@@ -47,20 +46,20 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** Create a new free term. Its owner is NoSymbol.
*/
- def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeTerm =
- new FreeTerm(name, value, origin) initFlags flags setInfo info
+ def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeTermSymbol =
+ new FreeTermSymbol(name, value, origin) initFlags flags setInfo info
/** Create a new free type. Its owner is NoSymbol.
*/
- def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeType =
- new FreeType(name, value, origin) initFlags flags setInfo info
+ def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String): FreeTypeSymbol =
+ new FreeTypeSymbol(name, value, origin) initFlags flags setInfo info
/** The original owner of a class. Used by the backend to generate
* EnclosingMethod attributes.
*/
val originalOwner = perRunCaches.newMap[Symbol, Symbol]()
- abstract class AbsSymbolImpl extends AbsSymbol {
+ abstract class SymbolContextApiImpl extends SymbolContextApi {
this: Symbol =>
def kind: String = kindString
@@ -71,8 +70,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
case n: TypeName => if (isClass) newClassSymbol(n, pos, newFlags) else newNonClassSymbol(n, pos, newFlags)
}
- def enclosingClass: Symbol = enclClass
- def enclosingMethod: Symbol = enclMethod
def thisPrefix: Type = thisType
def selfType: Type = typeOfThis
def typeSignature: Type = info
@@ -83,6 +80,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def asTypeConstructor: Type = typeConstructor
def setInternalFlags(flag: Long): this.type = { setFlag(flag); this }
def setTypeSignature(tpe: Type): this.type = { setInfo(tpe); this }
+ def getAnnotations: List[AnnotationInfo] = { initialize; annotations }
def setAnnotations(annots: AnnotationInfo*): this.type = { setAnnotations(annots.toList); this }
private def lastElemType(ts: Seq[Type]): Type = ts.last.normalize.typeArgs.head
@@ -155,7 +153,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** The class for all symbols */
abstract class Symbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: Name)
- extends AbsSymbolImpl
+ extends SymbolContextApiImpl
with HasFlags
with Annotatable[Symbol] {
@@ -164,7 +162,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// TODO - don't allow names to be renamed in this unstructured a fashion.
// Rename as little as possible. Enforce invariants on all renames.
- type NameType >: Null <: Name
type TypeOfClonedSymbol >: Null <: Symbol { type NameType = Symbol.this.NameType }
// Abstract here so TypeSymbol and TermSymbol can have a private[this] field
@@ -183,6 +180,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
private var rawpos = initPos
val id = nextId() // identity displayed when -uniqid
+ //assert(id != 3390, initName)
+
private[this] var _validTo: Period = NoPeriod
if (traceSymbolActivity)
@@ -236,19 +235,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
)
)
- /** !!! The logic after "hasFlag" is far too opaque to be unexplained.
- * I'm guessing it's attempting to compensate for flag overloading,
- * and embedding such logic in an undocumented island like this is a
- * notarized guarantee of future breakage.
- */
- override def hasModifier(mod: Modifier) =
- hasFlag(flagOfModifier(mod)) &&
- (!(mod == Modifier.bynameParameter) || isTerm) &&
- (!(mod == Modifier.covariant) || isType)
-
- override def modifiers: Set[Modifier] =
- Modifier.values filter hasModifier
-
// ------ creators -------------------------------------------------------------------
final def newValue(name: TermName, pos: Position = NoPosition, newFlags: Long = 0L): TermSymbol =
@@ -263,6 +249,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
newTermSymbol(nme.localDummyName(this), pos) setInfo NoType
final def newMethod(name: TermName, pos: Position = NoPosition, newFlags: Long = 0L): MethodSymbol =
createMethodSymbol(name, pos, METHOD | newFlags)
+ final def newMethodSymbol(name: TermName, pos: Position = NoPosition, newFlags: Long = 0L): MethodSymbol =
+ createMethodSymbol(name, pos, METHOD | newFlags)
final def newLabel(name: TermName, pos: Position = NoPosition): MethodSymbol =
newMethod(name, pos, LABEL)
@@ -302,6 +290,16 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final def newModuleSymbol(name: TermName, pos: Position = NoPosition, newFlags: Long = 0L): ModuleSymbol =
newTermSymbol(name, pos, newFlags).asInstanceOf[ModuleSymbol]
+ final def newModuleAndClassSymbol(name: Name, pos: Position, flags: FlagSet): (ModuleSymbol, ClassSymbol) = {
+ val m = newModuleSymbol(name, pos, flags | MODULE)
+ val c = newModuleClass(name.toTypeName, pos, m getFlag ModuleToClassFlags)
+ connectModuleToClass(m, c)
+ (m, c)
+ }
+
+ final def newPackageSymbol(name: TermName, pos: Position = NoPosition, newFlags: Long = 0L): ModuleSymbol =
+ newTermSymbol(name, pos, newFlags).asInstanceOf[ModuleSymbol]
+
final def newModuleClassSymbol(name: TypeName, pos: Position = NoPosition, newFlags: Long = 0L): ModuleClassSymbol =
newClassSymbol(name, pos, newFlags).asInstanceOf[ModuleClassSymbol]
@@ -349,6 +347,11 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final def newTypeParameter(name: TypeName, pos: Position = NoPosition, newFlags: Long = 0L): TypeSymbol =
newAbstractType(name, pos, PARAM | newFlags)
+// is defined in SymbolCreations
+// final def newTypeSymbol(name: TypeName, pos: Position = NoPosition, newFlags: Long = 0L): TypeSymbol =
+// (if ((newFlags & DEFERRED) != 0) new AbstractTypeSymbol(this, pos, name)
+// else new AbstractTypeSymbol(this, pos, name)) setFlag newFlags
+
/** Symbol of an existential type T forSome { ... }
*/
final def newExistential(name: TypeName, pos: Position = NoPosition, newFlags: Long = 0L): TypeSymbol =
@@ -445,18 +448,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
case x: TermName => newErrorValue(x)
}
- /** To overcome the crazy challenge of more specific types appearing
- * in incoming positions. Don't need this much.
- */
- def asTypeSymbol: TypeSymbol = this match {
- case x: TypeSymbol => x
- case x => throw new FatalError(this + " is not a TypeSymbol")
- }
- def asTermSymbol: TermSymbol = this match {
- case x: TermSymbol => x
- case x => throw new FatalError(this + " is not a TermSymbol")
- }
-
@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")
@@ -526,19 +517,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// ----- tests ----------------------------------------------------------------------
- /** All symbols are one of three categories: TermSymbol, TypeSymbol, or NoSymbol.
- * There is only one NoSymbol.
- */
- def isTerm = false
- def isType = false
-
- /** TypeSymbols fall into four named direct subclasses:
- * - ClassSymbol
- * - AliasTypeSymbol
- * - AbstractTypeSymbol
- * - TypeSkolem
- */
- def isClass = false
def isAliasType = false
def isAbstractType = false
def isSkolem = false
@@ -580,7 +558,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def isTypeParameterOrSkolem = false
def isTypeSkolem = false
def isTypeMacro = false
- def isFreeType = false
/** Qualities of Terms, always false for TypeSymbols.
*/
@@ -593,7 +570,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def isGetter = false
def isLocalDummy = false
def isMixinConstructor = false
- def isModule = false
def isOverloaded = false
def isSetter = false
def isSetterParameter = false
@@ -602,20 +578,17 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def isVariable = false
override def hasDefault = false
def isTermMacro = false
- def isFreeTerm = false
/** Qualities of MethodSymbols, always false for TypeSymbols
* and other TermSymbols.
*/
def isCaseAccessorMethod = false
def isLiftedMethod = false
- def isMethod = false
def isSourceMethod = false
def isVarargsMethod = false
override def isLabel = false
/** Package/package object tests */
- def isPackage = false
def isPackageClass = false
def isPackageObject = false
def isPackageObjectClass = false
@@ -693,7 +666,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def isClassLocalToConstructor = false
final def isDerivedValueClass =
- isClass && info.firstParent.typeSymbol == AnyValClass && !isPrimitiveValueClass
+ isClass && !hasFlag(PACKAGE | TRAIT) &&
+ info.firstParent.typeSymbol == AnyValClass && !isPrimitiveValueClass
final def isMethodWithExtension =
isMethod && owner.isDerivedValueClass && !isParamAccessor && !isConstructor && !hasFlag(SUPERACCESSOR)
@@ -916,7 +890,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final def isInitialized: Boolean =
validTo != NoPeriod
- // [Eugene] is this correct?
+ // [Eugene] todo. needs to be reviewed and [only then] rewritten without explicit returns
/** Determines whether this symbol can be loaded by subsequent reflective compilation */
final def isLocatable: Boolean = {
if (this == NoSymbol) return false
@@ -976,7 +950,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
if (originalOwner contains this) ()
else originalOwner(this) = rawowner
}
- assert(!inReflexiveMirror, "owner_= is not thread-safe; cannot be run in reflexive code")
+ assert(isCompilerUniverse, "owner_= is not thread-safe; cannot be run in reflexive code")
if (traceSymbolActivity)
traceSymbols.recordNewSymbolOwner(this, owner)
_rawowner = owner
@@ -1103,8 +1077,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
protected def createModuleSymbol(name: TermName, pos: Position, newFlags: Long): ModuleSymbol =
new ModuleSymbol(this, pos, name) initFlags newFlags
- protected def createPackageSymbol(name: TermName, pos: Position, newFlags: Long): PackageSymbol =
- new PackageSymbol(this, pos, name) initFlags newFlags
+ protected def createPackageSymbol(name: TermName, pos: Position, newFlags: Long): ModuleSymbol =
+ new ModuleSymbol(this, pos, name) initFlags newFlags
protected def createValueParameterSymbol(name: TermName, pos: Position, newFlags: Long): TermSymbol =
new TermSymbol(this, pos, name) initFlags newFlags
@@ -1157,10 +1131,10 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
*/
def accessBoundary(base: Symbol): Symbol = {
if (hasFlag(PRIVATE) || isLocal) owner
- else if (hasAllFlags(PROTECTED | STATIC | JAVA)) RootClass
+ else if (hasAllFlags(PROTECTED | STATIC | JAVA)) enclosingRootClass
else if (hasAccessBoundary && !phase.erasedTypes) privateWithin
else if (hasFlag(PROTECTED)) base
- else RootClass
+ else enclosingRootClass
}
def isLessAccessibleThan(other: Symbol): Boolean = {
@@ -1335,7 +1309,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// adapt to new run in fsc.
private def adaptInfos(infos: TypeHistory): TypeHistory = {
- assert(!inReflexiveMirror)
+ assert(isCompilerUniverse)
if (infos == null || runId(infos.validFrom) == currentRunId) {
infos
} else {
@@ -1370,7 +1344,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** Was symbol's type updated during given phase? */
final def isUpdatedAt(pid: Phase#Id): Boolean = {
- assert(!inReflexiveMirror)
+ assert(isCompilerUniverse)
var infos = this.infos
while ((infos ne null) && phaseId(infos.validFrom) != pid + 1) infos = infos.prev
infos ne null
@@ -1378,7 +1352,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** Was symbol's type updated during given phase? */
final def hasTypeAt(pid: Phase#Id): Boolean = {
- assert(!inReflexiveMirror)
+ assert(isCompilerUniverse)
var infos = this.infos
while ((infos ne null) && phaseId(infos.validFrom) > pid) infos = infos.prev
infos ne null
@@ -1527,13 +1501,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** After the typer phase (before, look at the definition's Modifiers), contains
* the annotations attached to member a definition (class, method, type, field).
*/
- def annotations: List[AnnotationInfo] = {
- // Necessary for reflection, see SI-5423
- if (inReflexiveMirror)
- initialize
-
+ def annotations: List[AnnotationInfo] =
_annotations
- }
def setAnnotations(annots: List[AnnotationInfo]): this.type = {
_annotations = annots
@@ -1619,6 +1588,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
result
}
+ @inline final def map(f: Symbol => Symbol): Symbol = if (this eq NoSymbol) this else f(this)
+
// ------ cloneing -------------------------------------------------------------------
/** A clone of this symbol. */
@@ -1697,7 +1668,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* The empty list for all other classes.
*/
final def caseFieldAccessors: List[Symbol] =
- info.decls filter (_.isCaseAccessorMethod) toList
+ (info.decls filter (_.isCaseAccessorMethod)).toList
final def constrParamAccessors: List[Symbol] =
info.decls.toList filter (sym => !sym.isMethod && sym.isParamAccessor)
@@ -1760,21 +1731,36 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
*/
def mixinClasses: List[Symbol] = {
val sc = superClass
- ancestors takeWhile (sc ne)
+ ancestors takeWhile (sc ne _)
}
/** All directly or indirectly inherited classes. */
def ancestors: List[Symbol] = info.baseClasses drop 1
+ @inline final def enclosingSuchThat(p: Symbol => Boolean): Symbol = {
+ var sym = this
+ while (sym != NoSymbol && !p(sym))
+ sym = sym.owner
+ sym
+ }
+
/** The package class containing this symbol, or NoSymbol if there
- * is not one. */
+ * is not one.
+ * TODO: formulate as enclosingSuchThat, after making sure
+ * we can start with current symbol rather than onwner.
+ * TODO: Also harmonize with enclClass, enclMethod etc.
+ */
def enclosingPackageClass: Symbol = {
- var packSym = this.owner
- while (packSym != NoSymbol && !packSym.isPackageClass)
- packSym = packSym.owner
- packSym
+ var sym = this.owner
+ while (sym != NoSymbol && !sym.isPackageClass)
+ sym = sym.owner
+ sym
}
+ /** The package class containing this symbol, or NoSymbol if there
+ * is not one. */
+ def enclosingRootClass: Symbol = enclosingSuchThat(_.isRoot)
+
/** The package containing this symbol, or NoSymbol if there
* is not one. */
def enclosingPackage: Symbol = enclosingPackageClass.companionModule
@@ -2009,7 +1995,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* pre: `this.owner` is in the base class sequence of `base`.
*/
final def superSymbol(base: Symbol): Symbol = {
- var bcs = base.info.baseClasses.dropWhile(owner !=).tail
+ var bcs = base.info.baseClasses.dropWhile(owner != _).tail
var sym: Symbol = NoSymbol
while (!bcs.isEmpty && sym == NoSymbol) {
if (!bcs.head.isImplClass)
@@ -2167,8 +2153,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
private def symbolKind: SymbolKind = {
var kind =
if (isTermMacro) ("macro method", "macro method", "MAC")
- else if (isInstanceOf[FreeTerm]) ("free term", "free term", "FTE")
- else if (isInstanceOf[FreeType]) ("free type", "free type", "FTY")
+ else if (isInstanceOf[FreeTermSymbol]) ("free term", "free term", "FTE")
+ else if (isInstanceOf[FreeTypeSymbol]) ("free type", "free type", "FTY")
else if (isPackage) ("package", "package", "PK")
else if (isPackageClass) ("package class", "package", "PKC")
else if (isPackageObject) ("package object", "package", "PKO")
@@ -2327,6 +2313,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
"val " + tpnme.dropSingletonName(name) + ": " + dropSingletonType(info.bounds.hi)
else defString
}
+ implicit val SymbolTag = ClassTag[Symbol](classOf[Symbol])
/** A class for term symbols */
class TermSymbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: TermName)
@@ -2334,7 +2321,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
private[this] var _referenced: Symbol = NoSymbol
privateWithin = NoSymbol
- final type NameType = TermName
type TypeOfClonedSymbol = TermSymbol
private[this] var _rawname: TermName = initName
@@ -2349,8 +2335,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
final def asNameType(n: Name) = n.toTermName
- final override def isTerm = true
-
/** Term symbols with the exception of static parts of Java classes and packages.
*/
override def isValue = !(isModule && hasFlag(PACKAGE | JAVA))
@@ -2496,6 +2480,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
cook(sym2)
}
}
+ implicit val TermSymbolTag = ClassTag[TermSymbol](classOf[TermSymbol])
/** A class for module symbols */
class ModuleSymbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: TermName)
@@ -2505,7 +2490,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def associatedFile = moduleClass.associatedFile
override def associatedFile_=(f: AbstractFileType) { moduleClass.associatedFile = f }
- override def isModule = true
override def moduleClass = referenced
override def companionClass =
flatOwnerInfo.decl(name.toTypeName).suchThat(_ isCoDefinedWith this)
@@ -2524,11 +2508,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
else rawname
)
}
-
- class PackageSymbol protected[Symbols] (owner0: Symbol, pos0: Position, name0: TermName)
- extends ModuleSymbol(owner0, pos0, name0) with PackageSymbolApi {
- override def isPackage = true
- }
+ implicit val ModuleSymbolTag = ClassTag[ModuleSymbol](classOf[ModuleSymbol])
/** A class for method symbols */
class MethodSymbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: TermName)
@@ -2538,7 +2518,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
private[this] var mtpeResult: Type = _
private[this] var mtpeInfo: Type = _
- override def isMethod = true
override def isLabel = this hasFlag LABEL
override def isVarargsMethod = this hasFlag VARARGS
override def isLiftedMethod = this hasFlag LIFTED
@@ -2566,6 +2545,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
res
}
}
+ implicit val MethodSymbolTag = ClassTag[MethodSymbol](classOf[MethodSymbol])
class AliasTypeSymbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: TypeName)
extends TypeSymbol(initOwner, initPos, initName) {
@@ -2593,7 +2573,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
privateWithin = NoSymbol
private[this] var _rawname: TypeName = initName
- final type NameType = TypeName
type TypeOfClonedSymbol >: Null <: TypeSymbol
// cloneSymbolImpl still abstract in TypeSymbol.
@@ -2601,7 +2580,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def name = _rawname
final def asNameType(n: Name) = n.toTypeName
- final override def isType = true
override def isNonClassType = true
override def isTypeMacro = hasFlag(MACRO)
@@ -2737,6 +2715,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
incCounter(typeSymbolCount)
}
+ implicit val TypeSymbolTag = ClassTag[TypeSymbol](classOf[TypeSymbol])
/** A class for type parameters viewed from inside their scopes
*
@@ -2808,7 +2787,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
case _ => super.resolveOverloadedFlag(flag)
}
- final override def isClass = true
final override def isNonClassType = false
final override def isAbstractType = false
final override def isAliasType = false
@@ -2953,6 +2931,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
incCounter(classSymbolCount)
}
+ implicit val ClassSymbolTag = ClassTag[ClassSymbol](classOf[ClassSymbol])
/** A class for module class symbols
* Note: Not all module classes are of this type; when unpickled, we get
@@ -3048,15 +3027,15 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
trait FreeSymbol extends Symbol {
def origin: String
}
- class FreeTerm(name0: TermName, value0: => Any, val origin: String) extends TermSymbol(NoSymbol, NoPosition, name0) with FreeSymbol {
+ class FreeTermSymbol(name0: TermName, value0: => Any, val origin: String) extends TermSymbol(NoSymbol, NoPosition, name0) with FreeSymbol with FreeTermSymbolApi {
def value = value0
- override def isFreeTerm = true
}
+ implicit val FreeTermSymbolTag = ClassTag[FreeTermSymbol](classOf[FreeTermSymbol])
- class FreeType(name0: TypeName, value0: => Any, val origin: String) extends TypeSkolem(NoSymbol, NoPosition, name0, NoSymbol) with FreeSymbol {
+ class FreeTypeSymbol(name0: TypeName, value0: => Any, val origin: String) extends TypeSkolem(NoSymbol, NoPosition, name0, NoSymbol) with FreeSymbol with FreeTypeSymbolApi {
def value = value0
- override def isFreeType = true
}
+ implicit val FreeTypeSymbolTag = ClassTag[FreeTypeSymbol](classOf[FreeTypeSymbol])
/** An object representing a missing symbol */
class NoSymbol protected[Symbols]() extends Symbol(null, NoPosition, nme.NO_NAME) {
@@ -3101,7 +3080,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def existentialBound: Type = NoType
override def rawInfo: Type = NoType
protected def doCookJavaRawInfo() {}
- override def accessBoundary(base: Symbol): Symbol = RootClass
+ override def accessBoundary(base: Symbol): Symbol = enclosingRootClass
def cloneSymbolImpl(owner: Symbol, newFlags: Long) = abort("NoSymbol.clone()")
override def originalEnclosingMethod = this
diff --git a/src/compiler/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index f2f9842595..c3a6fce164 100644
--- a/src/compiler/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -1,7 +1,7 @@
package scala.reflect
package internal
-abstract class TreeGen extends api.AbsTreeGen {
+abstract class TreeGen extends makro.TreeBuilder {
val global: SymbolTable
import global._
@@ -269,4 +269,12 @@ abstract class TreeGen extends api.AbsTreeGen {
// tree1 OR tree2
def mkOr(tree1: Tree, tree2: Tree): Tree =
Apply(Select(tree1, Boolean_or), List(tree2))
+
+ def mkBasisUniverseRef: Tree =
+ mkAttributedRef(ReflectBasis) setType singleType(ReflectBasis.owner.thisPrefix, ReflectBasis)
+
+ def mkRuntimeUniverseRef: Tree = {
+ assert(ReflectRuntimeUniverse != NoSymbol)
+ mkAttributedRef(ReflectRuntimeUniverse) setType singleType(ReflectRuntimeUniverse.owner.thisPrefix, ReflectRuntimeUniverse)
+ }
}
diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 1528061adb..698d219634 100644
--- a/src/compiler/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -326,6 +326,12 @@ abstract class TreeInfo {
case _ => false
}
+ /** a Match(Typed(_, tpt), _) is unchecked if isUncheckedAnnotation(tpt.tpe) */
+ def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation definitions.UncheckedClass
+
+ /** a Match(Typed(_, tpt), _) must be translated into a switch if isSwitchAnnotation(tpt.tpe) */
+ def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation definitions.SwitchClass
+
/** can this type be a type pattern */
def mayBeTypePat(tree: Tree): Boolean = tree match {
case CompoundTypeTree(Template(tps, _, Nil)) => tps exists mayBeTypePat
@@ -568,200 +574,4 @@ abstract class TreeInfo {
object DynamicUpdate extends DynamicApplicationExtractor(_ == nme.updateDynamic)
object DynamicApplication extends DynamicApplicationExtractor(isApplyDynamicName)
object DynamicApplicationNamed extends DynamicApplicationExtractor(_ == nme.applyDynamicNamed)
-
-
- // domain-specific extractors for reification
-
- import definitions._
-
- object TypedOrAnnotated {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case ty @ Typed(_, _) =>
- Some(ty)
- case at @ Annotated(_, _) =>
- Some(at)
- case _ =>
- None
- }
- }
-
- object TreeSplice {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(splicee, _) if tree.symbol == ExprEval || tree.symbol == ExprValue =>
- Some(splicee)
- case _ =>
- None
- }
- }
-
- object EvalSplice {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(splicee, _) if tree.symbol == ExprEval =>
- Some(splicee)
- case _ =>
- None
- }
- }
-
- object ValueSplice {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(splicee, _) if tree.symbol == ExprValue =>
- Some(splicee)
- case _ =>
- None
- }
- }
-
- object Reified {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case ReifiedTree(reifee, symbolTable, reified, _) =>
- Some(reifee, symbolTable, reified)
- case ReifiedType(reifee, symbolTable, reified) =>
- Some(reifee, symbolTable, reified)
- case _ =>
- None
- }
- }
-
- object ReifiedTree {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree)] = tree match {
- case reifee @ Block((mrDef @ ValDef(_, _, _, _)) :: symbolTable, Apply(Apply(_, List(tree)), List(Apply(_, tpe :: _)))) if mrDef.name == nme.MIRROR_SHORT =>
- Some(reifee, symbolTable, tree, tpe)
- case _ =>
- None
- }
- }
-
- object InlineableTreeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree, Symbol)] = tree match {
- case select @ Select(ReifiedTree(splicee, symbolTable, tree, tpe), _) if select.symbol == ExprEval || select.symbol == ExprValue =>
- Some(splicee, symbolTable, tree, tpe, select.symbol)
- case _ =>
- None
- }
- }
-
- object InlinedTreeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree)] = tree match {
- case Select(ReifiedTree(splicee, symbolTable, tree, tpe), name) if name == ExprTree.name =>
- Some(splicee, symbolTable, tree, tpe)
- case _ =>
- None
- }
- }
-
- object ReifiedType {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case reifee @ Block((mrDef @ ValDef(_, _, _, _)) :: symbolTable, Apply(_, tpe :: _)) if mrDef.name == nme.MIRROR_SHORT =>
- Some(reifee, symbolTable, tpe)
- case _ =>
- None
- }
- }
-
- object InlinedTypeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case Select(ReifiedType(splicee, symbolTable, tpe), name) if name == TypeTagTpe.name =>
- Some(splicee, symbolTable, tpe)
- case _ =>
- None
- }
- }
-
- object FreeDef {
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case FreeTermDef(mrRef, name, binding, flags, origin) =>
- Some(mrRef, name, binding, flags, origin)
- case FreeTypeDef(mrRef, name, binding, flags, origin) =>
- Some(mrRef, name, binding, flags, origin)
- case _ =>
- None
- }
- }
-
- object FreeTermDef {
- lazy val newFreeTermMethod = getMember(getRequiredClass("scala.reflect.api.TreeBuildUtil"), nme.newFreeTerm)
-
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case ValDef(_, name, _, Apply(Select(mrRef @ Ident(_), newFreeTerm), List(_, _, binding, Literal(Constant(flags: Long)), Literal(Constant(origin: String)))))
- if mrRef.name == nme.MIRROR_SHORT && newFreeTerm == newFreeTermMethod.name =>
- Some(mrRef, name, binding, flags, origin)
- case _ =>
- None
- }
- }
-
- object FreeTypeDef {
- lazy val newFreeExistentialMethod = getMember(getRequiredClass("scala.reflect.api.TreeBuildUtil"), nme.newFreeType)
- lazy val newFreeTypeMethod = getMember(getRequiredClass("scala.reflect.api.TreeBuildUtil"), nme.newFreeExistential)
-
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case ValDef(_, name, _, Apply(Select(mrRef1 @ Ident(_), newFreeType), List(_, _, value, Literal(Constant(flags: Long)), Literal(Constant(origin: String)))))
- if mrRef1.name == nme.MIRROR_SHORT && (newFreeType == newFreeTypeMethod.name || newFreeType == newFreeExistentialMethod.name) =>
- value match {
- case Apply(TypeApply(Select(Select(mrRef2 @ Ident(_), typeTag), apply), List(binding)), List(Literal(Constant(null)), _))
- if mrRef2.name == nme.MIRROR_SHORT && typeTag == nme.TypeTag && apply == nme.apply =>
- Some(mrRef1, name, binding, flags, origin)
- case Apply(TypeApply(Select(mrRef2 @ Ident(_), typeTag), List(binding)), List(Literal(Constant(null)), _))
- if mrRef2.name == nme.MIRROR_SHORT && typeTag == nme.TypeTag =>
- Some(mrRef1, name, binding, flags, origin)
- case _ =>
- throw new Error("unsupported free type def: %s%n%s".format(value, showRaw(value)))
- }
- case _ =>
- None
- }
- }
-
- object FreeRef {
- def unapply(tree: Tree): Option[(Tree, TermName)] = tree match {
- case Apply(Select(mrRef @ Ident(_), ident), List(Ident(name: TermName))) if ident == nme.Ident && name.startsWith(nme.MIRROR_FREE_PREFIX) =>
- Some(mrRef, name)
- case _ =>
- None
- }
- }
-
- object TypeRefToFreeType {
- def unapply(tree: Tree): Option[TermName] = tree match {
- case Apply(Select(Select(mrRef @ Ident(_), typeRef), apply), List(Select(_, noSymbol), Ident(freeType: TermName), nil))
- if (mrRef.name == nme.MIRROR_SHORT && typeRef == nme.TypeRef && noSymbol == nme.NoSymbol && freeType.startsWith(nme.MIRROR_FREE_PREFIX)) =>
- Some(freeType)
- case _ =>
- None
- }
- }
-
- object NestedExpr {
- def unapply(tree: Tree): Option[(Tree, Tree, Tree)] = tree match {
- case Apply(Apply(factory @ Select(expr, apply), List(tree)), List(typetag)) if expr.symbol == ExprModule && apply == nme.apply =>
- Some(factory, tree, typetag)
- case _ =>
- None
- }
- }
-
- object BoundTerm {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Ident(name) if name.isTermName =>
- Some(tree)
- case This(_) =>
- Some(tree)
- case _ =>
- None
- }
- }
-
- object BoundType {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(_, name) if name.isTypeName =>
- Some(tree)
- case SelectFromTypeTree(_, name) if name.isTypeName =>
- Some(tree)
- case Ident(name) if name.isTypeName =>
- Some(tree)
- case _ =>
- None
- }
- }
}
diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/reflect/scala/reflect/internal/TreePrinters.scala
index b3e4318fdc..6d035c8b9d 100644
--- a/src/compiler/scala/reflect/internal/TreePrinters.scala
+++ b/src/reflect/scala/reflect/internal/TreePrinters.scala
@@ -3,6 +3,8 @@
* @author Martin Odersky
*/
+// [Eugene++ to Martin] we need to unify this prettyprinter with NodePrinters
+
package scala.reflect
package internal
@@ -27,7 +29,9 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
private def symNameInternal(tree: Tree, name: Name, decoded: Boolean): String = {
val sym = tree.symbol
- if (sym != null && sym != NoSymbol) {
+ if (sym.name.toString == nme.ERROR.toString) {
+ "<" + quotedName(name, decoded) + ": error>"
+ } else if (sym != null && sym != NoSymbol) {
val prefix = if (sym.isMixinConstructor) "/*%s*/".format(quotedName(sym.owner.name, decoded)) else ""
var suffix = ""
if (settings.uniqid.value) suffix += ("#" + sym.id)
@@ -167,6 +171,12 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
}
def printAnnotations(tree: Tree) {
+ if (!isCompilerUniverse && tree.symbol != null && tree.symbol != NoSymbol)
+ // [Eugene++] todo. this is not 100% correct, but is necessary for sane printing
+ // the problem is that getting annotations doesn't automatically initialize the symbol
+ // so we might easily print something as if it doesn't have annotations, whereas it does
+ tree.symbol.initialize
+
val annots = tree.symbol.annotations match {
case Nil => tree.asInstanceOf[MemberDef].mods.annotations
case anns => anns
@@ -445,7 +455,7 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
/** Hook for extensions */
def xprintTree(treePrinter: TreePrinter, tree: Tree) =
- treePrinter.print(tree.printingPrefix+tree.productIterator.mkString("(", ", ", ")"))
+ treePrinter.print(tree.productPrefix+tree.productIterator.mkString("(", ", ", ")"))
def newTreePrinter(writer: PrintWriter): TreePrinter = new TreePrinter(writer)
def newTreePrinter(stream: OutputStream): TreePrinter = newTreePrinter(new PrintWriter(stream))
diff --git a/src/library/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 3427136fde..75bb0e6d49 100644
--- a/src/library/scala/reflect/api/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -4,198 +4,43 @@
*/
package scala.reflect
-package api
+package internal
-import scala.collection.mutable.ListBuffer
+import Flags._
+import base.Attachments
+import collection.mutable.{ListBuffer, LinkedHashSet}
-// Syncnote: Trees are currently not thread-safe.
-trait Trees { self: Universe =>
+trait Trees extends api.Trees { self: SymbolTable =>
private[scala] var nodeCount = 0
- type Modifiers >: Null <: AbsModifiers
- val NoMods: Modifiers
-
- // TODO - Where do I put this?
- object BackquotedIdentifier
-
- abstract class AbsModifiers {
- def modifiers: Set[Modifier]
- def hasModifier(mod: Modifier): Boolean
- def privateWithin: Name // default: EmptyTypeName
- def annotations: List[Tree] // default: List()
- def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers
- }
-
- def Modifiers(mods: Set[Modifier] = Set(),
- privateWithin: Name = EmptyTypeName,
- annotations: List[Tree] = List()): Modifiers
-
- /** Tree is the basis for scala's abstract syntax. The nodes are
- * implemented as case classes, and the parameters which initialize
- * a given tree are immutable: however Trees have several mutable
- * fields which are manipulated in the course of typechecking,
- * including pos, symbol, and tpe.
- *
- * Newly instantiated trees have tpe set to null (though it
- * may be set immediately thereafter depending on how it is
- * constructed.) When a tree is passed to the typer, typically via
- * `typer.typed(tree)`, under normal circumstances the tpe must be
- * null or the typer will ignore it. Furthermore, the typer is not
- * required to return the same tree it was passed.
- *
- * Trees can be easily traversed with e.g. foreach on the root node;
- * for a more nuanced traversal, subclass Traverser. Transformations
- * can be considerably trickier: see the numerous subclasses of
- * Transformer found around the compiler.
- *
- * Copying Trees should be done with care depending on whether
- * it need be done lazily or strictly (see LazyTreeCopier and
- * StrictTreeCopier) and on whether the contents of the mutable
- * fields should be copied. The tree copiers will copy the mutable
- * attributes to the new tree; calling Tree#duplicate will copy
- * symbol and tpe, but all the positions will be focused.
- *
- * Trees can be coarsely divided into four mutually exclusive categories:
- *
- * - TermTrees, representing terms
- * - TypTrees, representing types. Note that is `TypTree`, not `TypeTree`.
- * - SymTrees, which may represent types or terms.
- * - Other Trees, which have none of those as parents.
- *
- * SymTrees include important nodes Ident and Select, which are
- * used as both terms and types; they are distinguishable based on
- * whether the Name is a TermName or TypeName. The correct way for
- * to test for a type or a term (on any Tree) are the isTerm/isType
- * methods on Tree.
- *
- * "Others" are mostly syntactic or short-lived constructs. Examples
- * include CaseDef, which wraps individual match cases: they are
- * neither terms nor types, nor do they carry a symbol. Another
- * example is Parens, which is eliminated during parsing.
- */
- abstract class Tree extends Product {
- val id = nodeCount
+ abstract class Tree extends TreeContextApiImpl with Product {
+ val id = nodeCount // TODO: add to attachment?
nodeCount += 1
- /** Prefix under which to print this tree type. Defaults to product
- * prefix (e.g. DefTree) but because that is used in reification
- * it cannot be altered without breaking reflection.
- */
- def printingPrefix = productPrefix
-
- def pos: Position = rawatt.pos.asInstanceOf[Position] // [Eugene] how do we get rid of this cast?
- def pos_=(pos: Position): Unit = rawatt = (rawatt withPos pos) // the "withPos" part is crucial to robustness
+ @inline final def pos: Position = rawatt.pos
+ def pos_=(pos: Position): Unit = rawatt = (rawatt withPos pos)
def setPos(newpos: Position): this.type = { pos = newpos; this }
- // [Eugene] can we make this more type-safe
- private var rawatt: Attachment = NoPosition
- def attach(att: Any): Unit =
- rawatt match {
- case NontrivialAttachment(pos, payload) =>
- val index = payload.indexWhere(p => p.getClass == att.getClass)
- if (index == -1) payload += att
- else payload(index) = att
- case _ =>
- rawatt = NontrivialAttachment(pos, collection.mutable.ListBuffer[Any](att))
- }
-
- // a) why didn't this method already exist
- // b) what is all this "Any" business?
- // c) am I reverse-engineering this correctly? It shouldn't be hard
- // to figure out what is attached.
- def attachments: List[Any] = rawatt match {
- case NoPosition => Nil
- case NontrivialAttachment(pos, atts) => pos :: atts.toList
- case x => List(x)
- }
- // Writing "Any" repeatedly to work within this structure
- // is making my skin crawl.
- def hasAttachment(x: Any) = attachments contains x
-
- def withAttachment(att: Any): this.type = { attach(att); this }
- def detach(att: Any): Unit =
- detach(att.getClass)
- def detach(clazz: java.lang.Class[_]): Unit =
- rawatt match {
- case NontrivialAttachment(pos, payload) =>
- val index = payload.indexWhere(p => p.getClass == clazz)
- if (index != -1) payload.remove(index)
- case _ =>
- // do nothing
- }
- def withoutAttachment(att: Any): this.type = { detach(att); this }
- def attachment[T: ClassTag]: T = attachmentOpt[T] getOrElse { throw new Error("no attachment of type %s".format(classTag[T].erasure)) }
- def attachmentOpt[T: ClassTag]: Option[T] =
- firstAttachment { case attachment if attachment.getClass == classTag[T].erasure => attachment.asInstanceOf[T] }
-
- def firstAttachment[T](p: PartialFunction[Any, T]): Option[T] =
- rawatt match {
- case NontrivialAttachment(pos, payload) => payload.collectFirst(p)
- case _ => None
- }
+ private var rawatt: Attachments { type Pos = Position } = NoPosition
+ def attachments = rawatt
+ def addAttachment(attachment: Any): this.type = { rawatt = rawatt.add(attachment); this }
+ def removeAttachment[T: ClassTag]: this.type = { rawatt = rawatt.remove[T]; this }
private[this] var rawtpe: Type = _
-
- def tpe = rawtpe
+ @inline final def tpe = rawtpe
def tpe_=(t: Type) = rawtpe = t
-
- def resetType(): this.type = { tpe = null ; this }
- def resetSymbol(): this.type = { if (hasSymbol) symbol = NoSymbol ; this }
-
- /** Set tpe to give `tp` and return this.
- */
def setType(tp: Type): this.type = { rawtpe = tp; this }
-
- /** Like `setType`, but if this is a previously empty TypeTree that
- * fact is remembered so that resetAllAttrs will snap back.
- *
- * @PP: Attempting to elaborate on the above, I find: If defineType
- * is called on a TypeTree whose type field is null or NoType,
- * this is recorded as "wasEmpty = true". That value is used in
- * ResetAttrs, which nulls out the type field of TypeTrees
- * for which wasEmpty is true, leaving the others alone.
- *
- * resetAllAttrs is used in situations where some speculative
- * typing of a tree takes place, fails, and the tree needs to be
- * returned to its former state to try again. So according to me:
- * using `defineType` instead of `setType` is how you communicate
- * that the type being set does not depend on any previous state,
- * and therefore should be abandoned if the current line of type
- * inquiry doesn't work out.
- */
def defineType(tp: Type): this.type = setType(tp)
- /** Note that symbol is fixed as null at this level. In SymTrees,
- * it is overridden and implemented with a var, initialized to NoSymbol.
- *
- * Trees which are not SymTrees but which carry symbols do so by
- * overriding `def symbol` to forward it elsewhere. Examples:
- *
- * Super(qual, _) // has qual's symbol
- * Apply(fun, args) // has fun's symbol
- * TypeApply(fun, args) // has fun's symbol
- * AppliedTypeTree(tpt, args) // has tpt's symbol
- * TypeTree(tpe) // has tpe's typeSymbol, if tpe != null
- *
- * Attempting to set the symbol of a Tree which does not support
- * it will induce an exception.
- */
def symbol: Symbol = null
def symbol_=(sym: Symbol) { throw new UnsupportedOperationException("symbol_= inapplicable for " + this) }
def setSymbol(sym: Symbol): this.type = { symbol = sym; this }
-
def hasSymbol = false
- def isDef = false
- def isEmpty = false
- @inline final def orElse(alt: => Tree) = if (!isEmpty) this else alt
- @inline final def andAlso(f: Tree => Unit): Tree = { if (!this.isEmpty) f(this) ; this }
- def hasAssignedType = (tpe ne null) && (tpe ne NoType)
- def hasAssignedSymbol = (symbol ne null) && (symbol ne NoSymbol)
+ def isDef = false
- @inline final def hasSymbolWhich(f: Symbol => Boolean) = hasAssignedSymbol && f(symbol)
- @inline final def hasTypeWhich(f: Type => Boolean) = hasAssignedType && f(tpe)
+ def isEmpty = false
/** The canonical way to test if a Tree represents a term.
*/
@@ -219,61 +64,70 @@ trait Trees { self: Universe =>
case _ => false
}
- /** Apply `f` to each subtree */
- def foreach(f: Tree => Unit) { new ForeachTreeTraverser(f).traverse(this) }
+ private[scala] def copyAttrs(tree: Tree): this.type = {
+ rawatt = tree.rawatt
+ tpe = tree.tpe
+ if (hasSymbol) symbol = tree.symbol
+ this
+ }
+
+ override def hashCode(): Int = System.identityHashCode(this)
+ override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
+
+ override def duplicate: this.type =
+ (duplicator transform this).asInstanceOf[this.type]
+ }
- /** Find all subtrees matching predicate `p` */
- def withFilter(f: Tree => Boolean): List[Tree] = {
+ abstract class TreeContextApiImpl extends TreeContextApi { this: Tree =>
+
+ override def orElse(alt: => Tree) = if (!isEmpty) this else alt
+
+ override def foreach(f: Tree => Unit) { new ForeachTreeTraverser(f).traverse(this) }
+
+ override def withFilter(f: Tree => Boolean): List[Tree] = {
val ft = new FilterTreeTraverser(f)
ft.traverse(this)
ft.hits.toList
}
- def filter(f: Tree => Boolean): List[Tree] = withFilter(f)
- /** Apply `pf' to each subtree on which the function is defined */
- def collect[T](pf: PartialFunction[Tree, T]): List[T] = {
+ override def filter(f: Tree => Boolean): List[Tree] = withFilter(f)
+
+ override def collect[T](pf: PartialFunction[Tree, T]): List[T] = {
val ctt = new CollectTreeTraverser[T](pf)
ctt.traverse(this)
ctt.results.toList
}
- /** Returns optionally first tree (in a preorder traversal) which satisfies predicate `p`,
- * or None if none exists.
- */
- def find(p: Tree => Boolean): Option[Tree] = {
+ override def find(p: Tree => Boolean): Option[Tree] = {
val ft = new FindTreeTraverser(p)
ft.traverse(this)
ft.result
}
- /** Is there exists a part of this tree which satisfies predicate `p`? */
- def exists(p: Tree => Boolean): Boolean = !find(p).isEmpty
+ override def exists(p: Tree => Boolean): Boolean = !find(p).isEmpty
+
+ override def forAll(p: Tree => Boolean): Boolean = find(!p(_)).isEmpty
- /** Do all parts of this tree satisfy predicate `p`? */
- def forAll(p: Tree => Boolean): Boolean = find(!p(_)).isEmpty
+ override def equalsStructure(that : Tree) = correspondsStructure(that)(_ eq _)
- def equalsStructure(that : Tree) = equalsStructure0(that)(_ eq _)
- def equalsStructure0(that: Tree)(f: (Tree,Tree) => Boolean): Boolean =
- f(this, that) || ((this.productArity == that.productArity) && {
+ def correspondsStructure(that: Tree)(f: (Tree,Tree) => Boolean): Boolean =
+ f(this, that) || ((productArity == that.productArity) && {
def equals0(this0: Any, that0: Any): Boolean = (this0, that0) match {
- case (x: Tree, y: Tree) => f(x, y) || (x equalsStructure0 y)(f)
+ case (x: Tree, y: Tree) => f(x, y) || (x correspondsStructure y)(f)
case (xs: List[_], ys: List[_]) => (xs corresponds ys)(equals0)
case _ => this0 == that0
}
def compareOriginals() = (this, that) match {
case (x: TypeTree, y: TypeTree) if x.original != null && y.original != null =>
- (x.original equalsStructure0 y.original)(f)
+ (x.original correspondsStructure y.original)(f)
case _ =>
true
}
- (this.productIterator zip that.productIterator forall { case (x, y) => equals0(x, y) }) && compareOriginals()
+ (productIterator zip that.productIterator forall { case (x, y) => equals0(x, y) }) && compareOriginals()
})
- /** The direct child trees of this tree.
- * EmptyTrees are always omitted. Lists are flattened.
- */
- def children: List[Tree] = {
+ override def children: List[Tree] = {
def subtrees(x: Any): List[Tree] = x match {
case EmptyTree => Nil
case t: Tree => List(t)
@@ -283,385 +137,258 @@ trait Trees { self: Universe =>
productIterator.toList flatMap subtrees
}
- /** Make a copy of this tree, keeping all attributes,
- * except that all positions are focused (so nothing
- * in this tree will be found when searching by position).
+ override def freeTerms: List[FreeTermSymbol] = freeSyms[FreeTermSymbol](_.isFreeTerm, _.termSymbol)
+ override def freeTypes: List[FreeTypeSymbol] = freeSyms[FreeTypeSymbol](_.isFreeType, _.typeSymbol)
+
+ private def freeSyms[S <: Symbol](isFree: Symbol => Boolean, symOfType: Type => Symbol): List[S] = {
+ val s = collection.mutable.LinkedHashSet[S]()
+ def addIfFree(sym: Symbol): Unit = if (sym != null && isFree(sym)) s += sym.asInstanceOf[S]
+ for (t <- this) {
+ addIfFree(t.symbol)
+ if (t.tpe != null) {
+ for (tp <- t.tpe) {
+ addIfFree(symOfType(tp))
+ }
+ }
+ }
+ s.toList
+ }
+
+ override def substituteSymbols(from: List[Symbol], to: List[Symbol]): Tree =
+ new TreeSymSubstituter(from, to)(this)
+
+ override def substituteTypes(from: List[Symbol], to: List[Type]): Tree =
+ new TreeTypeSubstituter(from, to)(this)
+
+ override def substituteThis(clazz: Symbol, to: Tree): Tree =
+ new ThisSubstituter(clazz, to) transform this
+
+ def hasSymbolWhich(f: Symbol => Boolean) =
+ hasSymbol && symbol != null && f(symbol)
+
+ def isErroneous = (tpe ne null) && tpe.isErroneous
+ def isTyped = (tpe ne null) && !tpe.isErroneous
+
+ /** Sets the tree's type to the result of the given function.
+ * If the type is null, it remains null - the function is not called.
*/
- def duplicate: this.type =
- duplicateTree(this).asInstanceOf[this.type]
+ def modifyType(f: Type => Type): Tree =
+ if (tpe eq null) this
+ else this setType f(tpe)
- private[scala] def copyAttrs(tree: Tree): this.type = {
- rawatt = tree.rawatt
- tpe = tree.tpe
- if (hasSymbol) symbol = tree.symbol
- this
+ /** If `pf` is defined for a given subtree, call super.traverse(pf(tree)),
+ * otherwise super.traverse(tree).
+ */
+ def foreachPartial(pf: PartialFunction[Tree, Tree]) {
+ new ForeachPartialTreeTraverser(pf).traverse(this)
}
- override def toString: String = show(this)
- override def hashCode(): Int = System.identityHashCode(this)
- override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
+ def changeOwner(pairs: (Symbol, Symbol)*): Tree = {
+ pairs.foldLeft(this) { case (t, (oldOwner, newOwner)) =>
+ new ChangeOwnerTraverser(oldOwner, newOwner) apply t
+ }
+ }
+
+ def shallowDuplicate: Tree = new ShallowDuplicator(this) transform this
+ def shortClass: String = (getClass.getName split "[.$]").last
+
+ def isErrorTyped = (tpe ne null) && tpe.isError
+
+ /** When you want to know a little more than the class, but a lot
+ * less than the whole tree.
+ */
+ def summaryString: String = this match {
+ case Literal(const) => "Literal(" + const + ")"
+ case Ident(name) => "Ident(%s)".format(name.decode)
+ case Select(qual, name) => "Select(%s, %s)".format(qual.summaryString, name.decode)
+ case t: NameTree => t.name.longString
+ case t =>
+ t.shortClass + (
+ if (t.symbol != null && t.symbol != NoSymbol) "(" + t.symbol + ")"
+ else ""
+ )
+ }
}
- /** A tree for a term. Not all terms are TermTrees; use isTerm
- * to reliably identify terms.
- */
- trait TermTree extends Tree
+ trait TermTree extends Tree with TermTreeApi
- /** A tree for a type. Not all types are TypTrees; use isType
- * to reliably identify types.
- */
- trait TypTree extends Tree
+ trait TypTree extends Tree with TypTreeApi
- /** A tree with a mutable symbol field, initialized to NoSymbol.
- */
- trait SymTree extends Tree {
+ trait SymTree extends Tree with SymTreeContextApi {
override def hasSymbol = true
override var symbol: Symbol = NoSymbol
}
- /** A tree with a name - effectively, a DefTree or RefTree.
- */
- trait NameTree extends Tree {
+ trait NameTree extends Tree with NameTreeApi {
def name: Name
}
- /** A tree which references a symbol-carrying entity.
- * References one, as opposed to defining one; definitions
- * are in DefTrees.
- */
- trait RefTree extends SymTree with NameTree {
+ trait RefTree extends SymTree with NameTree with RefTreeApi {
def qualifier: Tree // empty for Idents
def name: Name
}
- /** A tree which defines a symbol-carrying entity.
- */
- abstract class DefTree extends SymTree with NameTree {
+ abstract class DefTree extends SymTree with NameTree with DefTreeApi {
def name: Name
override def isDef = true
}
-// ----- tree node alternatives --------------------------------------
-
- /** The empty tree */
case object EmptyTree extends TermTree {
super.tpe_=(NoType)
override def tpe_=(t: Type) =
if (t != NoType) throw new UnsupportedOperationException("tpe_=("+t+") inapplicable for <empty>")
override def isEmpty = true
- override def resetType(): this.type = this
}
- /** Common base class for all member definitions: types, classes,
- * objects, packages, vals and vars, defs.
- */
- abstract class MemberDef extends DefTree {
+ abstract class MemberDef extends DefTree with MemberDefApi {
def mods: Modifiers
def keyword: String = this match {
case TypeDef(_, _, _, _) => "type"
- case ClassDef(mods, _, _, _) => if (mods hasModifier Modifier.`trait`) "trait" else "class"
+ case ClassDef(mods, _, _, _) => if (mods hasFlag TRAIT) "trait" else "class"
case DefDef(_, _, _, _, _, _) => "def"
case ModuleDef(_, _, _) => "object"
case PackageDef(_, _) => "package"
- case ValDef(mods, _, _, _) => if (mods hasModifier Modifier.mutable) "var" else "val"
+ case ValDef(mods, _, _, _) => if (mods hasFlag MUTABLE) "var" else "val"
case _ => ""
}
}
- /** A packaging, such as `package pid { stats }`
- */
case class PackageDef(pid: RefTree, stats: List[Tree])
- extends MemberDef {
+ extends MemberDef with PackageDefApi {
def name = pid.name
- def mods = Modifiers()
+ def mods = NoMods
}
+ object PackageDef extends PackageDefExtractor
- /** A common base class for class and object definitions.
- */
- abstract class ImplDef extends MemberDef {
+ abstract class ImplDef extends MemberDef with ImplDefApi {
def impl: Template
}
- /** A class definition.
- */
case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template)
- extends ImplDef
-
- /** @param sym the class symbol
- * @return the implementation template
- */
- def ClassDef(sym: Symbol, impl: Template): ClassDef
+ extends ImplDef with ClassDefApi
+ object ClassDef extends ClassDefExtractor
- /** An object definition, e.g. `object Foo`. Internally, objects are
- * quite frequently called modules to reduce ambiguity.
- */
case class ModuleDef(mods: Modifiers, name: TermName, impl: Template)
- extends ImplDef
-
- /**
- * @param sym the class symbol
- * @param impl the implementation template
- */
- def ModuleDef(sym: Symbol, impl: Template): ModuleDef
+ extends ImplDef with ModuleDefApi
+ object ModuleDef extends ModuleDefExtractor
- /** A common base class for ValDefs and DefDefs.
- */
- abstract class ValOrDefDef extends MemberDef {
- def name: Name // can't be a TermName because macros can be type names.
+ abstract class ValOrDefDef extends MemberDef with ValOrDefDefApi {
+ def name: Name
def tpt: Tree
def rhs: Tree
}
- /** Broadly speaking, a value definition. All these are encoded as ValDefs:
- *
- * - immutable values, e.g. "val x"
- * - mutable values, e.g. "var x" - the MUTABLE flag set in mods
- * - lazy values, e.g. "lazy val x" - the LAZY flag set in mods
- * - method parameters, see vparamss in DefDef - the PARAM flag is set in mods
- * - explicit self-types, e.g. class A { self: Bar => } - !!! not sure what is set.
- */
- case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef
-
- def ValDef(sym: Symbol, rhs: Tree): ValDef
-
- def ValDef(sym: Symbol): ValDef
+ case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef with ValDefApi
+ object ValDef extends ValDefExtractor
- /** A method or macro definition.
- * @param name The name of the method or macro. Can be a type name in case this is a type macro
- */
case class DefDef(mods: Modifiers, name: Name, tparams: List[TypeDef],
- vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef
-
- def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef
-
- def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef
-
- def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef
-
- def DefDef(sym: Symbol, rhs: Tree): DefDef
-
- def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef
+ vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef with DefDefApi
+ object DefDef extends DefDefExtractor
- /** An abstract type, a type parameter, or a type alias.
- */
case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree)
- extends MemberDef
-
- /** A TypeDef node which defines given `sym` with given tight hand side `rhs`. */
- def TypeDef(sym: Symbol, rhs: Tree): TypeDef
+ extends MemberDef with TypeDefApi
+ object TypeDef extends TypeDefExtractor
- /** A TypeDef node which defines abstract type or type parameter for given `sym` */
- def TypeDef(sym: Symbol): TypeDef
-
- /** A labelled expression. Not expressible in language syntax, but
- * generated by the compiler to simulate while/do-while loops, and
- * also by the pattern matcher.
- *
- * The label acts much like a nested function, where `params` represents
- * the incoming parameters. The symbol given to the LabelDef should have
- * a MethodType, as if it were a nested function.
- *
- * Jumps are apply nodes attributed with a label's symbol. The
- * arguments from the apply node will be passed to the label and
- * assigned to the Idents.
- *
- * Forward jumps within a block are allowed.
- */
case class LabelDef(name: TermName, params: List[Ident], rhs: Tree)
- extends DefTree with TermTree
-
- def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef
-
- /** Import selector
- *
- * Representation of an imported name its optional rename and their optional positions
- *
- * @param name the imported name
- * @param namePos its position or -1 if undefined
- * @param rename the name the import is renamed to (== name if no renaming)
- * @param renamePos the position of the rename or -1 if undefined
- */
- case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int)
+ extends DefTree with TermTree with LabelDefApi
+ object LabelDef extends LabelDefExtractor
+
+ case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int) extends ImportSelectorApi
+ object ImportSelector extends ImportSelectorExtractor
- /** Import clause
- *
- * @param expr
- * @param selectors
- */
case class Import(expr: Tree, selectors: List[ImportSelector])
- extends SymTree
- // The symbol of an Import is an import symbol @see Symbol.newImport
- // It's used primarily as a marker to check that the import has been typechecked.
-
- /** Instantiation template of a class or trait
- *
- * @param parents
- * @param body
- */
+ extends SymTree with ImportApi
+ object Import extends ImportExtractor
+
case class Template(parents: List[Tree], self: ValDef, body: List[Tree])
- extends SymTree {
- // the symbol of a template is a local dummy. @see Symbol.newLocalDummy
- // the owner of the local dummy is the enclosing trait or class.
- // the local dummy is itself the owner of any local blocks
- // For example:
- //
- // class C {
- // def foo // owner is C
- // {
- // def bar // owner is local dummy
- // }
- }
+ extends SymTree with TemplateApi
+ object Template extends TemplateExtractor
- /** Block of expressions (semicolon separated expressions) */
case class Block(stats: List[Tree], expr: Tree)
- extends TermTree
+ extends TermTree with BlockApi
+ object Block extends BlockExtractor
- /** Block factory that flattens directly nested blocks.
- */
- def Block(stats: Tree*): Block
-
- /** Case clause in a pattern match, eliminated during explicitouter
- * (except for occurrences in switch statements)
- */
case class CaseDef(pat: Tree, guard: Tree, body: Tree)
- extends Tree
-
- /** casedef shorthand */
- def CaseDef(pat: Tree, body: Tree): CaseDef
+ extends Tree with CaseDefApi
+ object CaseDef extends CaseDefExtractor
- /** Alternatives of patterns, eliminated by explicitouter, except for
- * occurrences in encoded Switch stmt (=remaining Match(CaseDef(...))
- */
case class Alternative(trees: List[Tree])
- extends TermTree
+ extends TermTree with AlternativeApi
+ object Alternative extends AlternativeExtractor
- /** Repetition of pattern, eliminated by explicitouter */
case class Star(elem: Tree)
- extends TermTree
+ extends TermTree with StarApi
+ object Star extends StarExtractor
- /** Bind of a variable to a rhs pattern, eliminated by explicitouter
- *
- * @param name
- * @param body
- */
case class Bind(name: Name, body: Tree)
- extends DefTree
-
- def Bind(sym: Symbol, body: Tree): Bind
+ extends DefTree with BindApi
+ object Bind extends BindExtractor
case class UnApply(fun: Tree, args: List[Tree])
- extends TermTree
+ extends TermTree with UnApplyApi
+ object UnApply extends UnApplyExtractor
- /** Array of expressions, needs to be translated in backend,
- */
case class ArrayValue(elemtpt: Tree, elems: List[Tree])
- extends TermTree
+ extends TermTree with ArrayValueApi
+ object ArrayValue extends ArrayValueExtractor
- /** Anonymous function, eliminated by analyzer */
case class Function(vparams: List[ValDef], body: Tree)
- extends TermTree with SymTree
- // The symbol of a Function is a synthetic value of name nme.ANON_FUN_NAME
- // It is the owner of the function's parameters.
+ extends TermTree with SymTree with FunctionApi
+ object Function extends FunctionExtractor
- /** Assignment */
case class Assign(lhs: Tree, rhs: Tree)
- extends TermTree
+ extends TermTree with AssignApi
+ object Assign extends AssignExtractor
- /** Either an assignment or a named argument. Only appears in argument lists,
- * eliminated by typecheck (doTypedApply)
- */
case class AssignOrNamedArg(lhs: Tree, rhs: Tree)
- extends TermTree
+ extends TermTree with AssignOrNamedArgApi
+ object AssignOrNamedArg extends AssignOrNamedArgExtractor
- /** Conditional expression */
case class If(cond: Tree, thenp: Tree, elsep: Tree)
- extends TermTree
-
- /** - Pattern matching expression (before explicitouter)
- * - Switch statements (after explicitouter)
- *
- * After explicitouter, cases will satisfy the following constraints:
- *
- * - all guards are `EmptyTree`,
- * - all patterns will be either `Literal(Constant(x:Int))`
- * or `Alternative(lit|...|lit)`
- * - except for an "otherwise" branch, which has pattern
- * `Ident(nme.WILDCARD)`
- */
+ extends TermTree with IfApi
+ object If extends IfExtractor
+
case class Match(selector: Tree, cases: List[CaseDef])
- extends TermTree
+ extends TermTree with MatchApi
+ object Match extends MatchExtractor
- /** Return expression */
case class Return(expr: Tree)
- extends TermTree with SymTree
- // The symbol of a Return node is the enclosing method.
+ extends TermTree with SymTree with ReturnApi
+ object Return extends ReturnExtractor
case class Try(block: Tree, catches: List[CaseDef], finalizer: Tree)
- extends TermTree
-
- def Try(body: Tree, cases: (Tree, Tree)*): Try
+ extends TermTree with TryApi
+ object Try extends TryExtractor
- /** Throw expression */
case class Throw(expr: Tree)
- extends TermTree
-
- def Throw(tpe: Type, args: Tree*): Throw
-
- /** Object instantiation
- * One should always use factory method below to build a user level new.
- *
- * @param tpt a class type
- */
- case class New(tpt: Tree) extends TermTree
-
- /** Factory method for object creation `new tpt(args_1)...(args_n)`
- * A `New(t, as)` is expanded to: `(new t).<init>(as)`
- */
- def New(tpt: Tree, argss: List[List[Tree]]): Tree
-
- /** 0-1 argument list new, based on a type.
- */
- def New(tpe: Type, args: Tree*): Tree
+ extends TermTree with ThrowApi
+ object Throw extends ThrowExtractor
- def New(sym: Symbol, args: Tree*): Tree
+ case class New(tpt: Tree) extends TermTree with NewApi
+ object New extends NewExtractor
- /** Type annotation, eliminated by explicit outer */
case class Typed(expr: Tree, tpt: Tree)
- extends TermTree
+ extends TermTree with TypedApi
+ object Typed extends TypedExtractor
- /** Common base class for Apply and TypeApply. This could in principle
- * be a SymTree, but whether or not a Tree is a SymTree isn't used
- * to settle any interesting questions, and it would add a useless
- * field to all the instances (useless, since GenericApply forwards to
- * the underlying fun.)
- */
- abstract class GenericApply extends TermTree {
+ abstract class GenericApply extends TermTree with GenericApplyApi {
val fun: Tree
val args: List[Tree]
}
- /** Explicit type application.
- * @PP: All signs point toward it being a requirement that args.nonEmpty,
- * but I can't find that explicitly stated anywhere. Unless your last name
- * is odersky, you should probably treat it as true.
- */
case class TypeApply(fun: Tree, args: List[Tree])
- extends GenericApply {
-
- // Testing the above theory re: args.nonEmpty.
- require(args.nonEmpty, this)
+ extends GenericApply with TypeApplyApi {
override def symbol: Symbol = fun.symbol
override def symbol_=(sym: Symbol) { fun.symbol = sym }
}
+ object TypeApply extends TypeApplyExtractor
- /** Value application */
case class Apply(fun: Tree, args: List[Tree])
- extends GenericApply {
+ extends GenericApply with ApplyApi {
override def symbol: Symbol = fun.symbol
override def symbol_=(sym: Symbol) { fun.symbol = sym }
}
-
- def Apply(sym: Symbol, args: Tree*): Tree
+ object Apply extends ApplyExtractor
// TODO remove this class, add a tree attachment to Apply to track whether implicits were involved
// copying trees will all too easily forget to distinguish subclasses
@@ -671,120 +398,78 @@ trait Trees { self: Universe =>
// copying trees will all too easily forget to distinguish subclasses
class ApplyImplicitView(fun: Tree, args: List[Tree]) extends Apply(fun, args)
- // TODO: use a factory method, not a class (???)
- // as a case in point of the comment that should go here by similarity to ApplyToImplicitArgs,
- // this tree is considered in importers, but not in treecopier
- class ApplyConstructor(tpt: Tree, args: List[Tree]) extends Apply(Select(New(tpt), nme.CONSTRUCTOR), args) {
- override def printingPrefix = "ApplyConstructor"
- }
+ def ApplyConstructor(tpt: Tree, args: List[Tree]) = Apply(Select(New(tpt), nme.CONSTRUCTOR), args)
- /** Dynamic value application.
- * In a dynamic application q.f(as)
- * - q is stored in qual
- * - as is stored in args
- * - f is stored as the node's symbol field.
- */
case class ApplyDynamic(qual: Tree, args: List[Tree])
- extends TermTree with SymTree
- // The symbol of an ApplyDynamic is the function symbol of `qual`, or NoSymbol, if there is none.
+ extends TermTree with SymTree with ApplyDynamicApi
+ object ApplyDynamic extends ApplyDynamicExtractor
- /** Super reference, qual = corresponding this reference
- * A super reference C.super[M] is represented as Super(This(C), M).
- */
- case class Super(qual: Tree, mix: TypeName) extends TermTree {
- // The symbol of a Super is the class _from_ which the super reference is made.
- // For instance in C.super(...), it would be C.
+ case class Super(qual: Tree, mix: TypeName) extends TermTree with SuperApi {
override def symbol: Symbol = qual.symbol
override def symbol_=(sym: Symbol) { qual.symbol = sym }
}
+ object Super extends SuperExtractor
- def Super(sym: Symbol, mix: TypeName): Tree
-
- /** Self reference */
case class This(qual: TypeName)
- extends TermTree with SymTree
- // The symbol of a This is the class to which the this refers.
- // For instance in C.this, it would be C.
-
- def This(sym: Symbol): Tree
+ extends TermTree with SymTree with ThisApi
+ object This extends ThisExtractor
- /** Designator <qualifier> . <name> */
case class Select(qualifier: Tree, name: Name)
- extends RefTree
+ extends RefTree with SelectApi
+ object Select extends SelectExtractor
- def Select(qualifier: Tree, name: String): Select
-
- def Select(qualifier: Tree, sym: Symbol): Select
-
- /** Identifier <name> */
- case class Ident(name: Name) extends RefTree {
+ case class Ident(name: Name) extends RefTree with IdentContextApi {
def qualifier: Tree = EmptyTree
- def isBackquoted = this hasAttachment BackquotedIdentifier
+ def isBackquoted = this.attachments.get[BackquotedIdentifierAttachment.type].isDefined
}
+ object Ident extends IdentExtractor
- def Ident(name: String): Ident
-
- def Ident(sym: Symbol): Ident
-
- /** Marks underlying reference to id as boxed.
- * @pre id must refer to a captured variable
- * A reference such marked will refer to the boxed entity, no dereferencing
- * with `.elem` is done on it.
- * This tree node can be emitted by macros such as reify that call referenceCapturedVariable.
- * It is eliminated in LambdaLift, where the boxing conversion takes place.
- */
- case class ReferenceToBoxed(ident: Ident) extends TermTree {
+ case class ReferenceToBoxed(ident: Ident) extends TermTree with ReferenceToBoxedApi {
override def symbol: Symbol = ident.symbol
override def symbol_=(sym: Symbol) { ident.symbol = sym }
}
+ object ReferenceToBoxed extends ReferenceToBoxedExtractor
- /** Literal */
case class Literal(value: Constant)
- extends TermTree {
+ extends TermTree with LiteralApi {
assert(value ne null)
}
+ object Literal extends LiteralExtractor
// @deprecated("will be removed and then be re-introduced with changed semantics, use Literal(Constant(x)) instead")
// def Literal(x: Any) = new Literal(Constant(x))
- /** A tree that has an annotation attached to it. Only used for annotated types and
- * annotation ascriptions, annotations on definitions are stored in the Modifiers.
- * Eliminated by typechecker (typedAnnotated), the annotations are then stored in
- * an AnnotatedType.
- */
- case class Annotated(annot: Tree, arg: Tree) extends Tree
+ case class Annotated(annot: Tree, arg: Tree) extends Tree with AnnotatedApi
+ object Annotated extends AnnotatedExtractor
- /** Singleton type, eliminated by RefCheck */
case class SingletonTypeTree(ref: Tree)
- extends TypTree
+ extends TypTree with SingletonTypeTreeApi
+ object SingletonTypeTree extends SingletonTypeTreeExtractor
- /** Type selection <qualifier> # <name>, eliminated by RefCheck */
case class SelectFromTypeTree(qualifier: Tree, name: TypeName)
- extends TypTree with RefTree
+ extends TypTree with RefTree with SelectFromTypeTreeApi
+ object SelectFromTypeTree extends SelectFromTypeTreeExtractor
- /** Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck */
case class CompoundTypeTree(templ: Template)
- extends TypTree
+ extends TypTree with CompoundTypeTreeApi
+ object CompoundTypeTree extends CompoundTypeTreeExtractor
- /** Applied type <tpt> [ <args> ], eliminated by RefCheck */
case class AppliedTypeTree(tpt: Tree, args: List[Tree])
- extends TypTree {
+ extends TypTree with AppliedTypeTreeApi {
override def symbol: Symbol = tpt.symbol
override def symbol_=(sym: Symbol) { tpt.symbol = sym }
}
+ object AppliedTypeTree extends AppliedTypeTreeExtractor
case class TypeBoundsTree(lo: Tree, hi: Tree)
- extends TypTree
+ extends TypTree with TypeBoundsTreeApi
+ object TypeBoundsTree extends TypeBoundsTreeExtractor
case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree])
- extends TypTree
-
- /** A synthetic tree holding an arbitrary type. Not to be confused with
- * with TypTree, the trait for trees that are only used for type trees.
- * TypeTree's are inserted in several places, but most notably in
- * `RefCheck`, where the arbitrary type trees are all replaced by
- * TypeTree's. */
- case class TypeTree() extends TypTree {
+ extends TypTree with ExistentialTypeTreeApi
+ object ExistentialTypeTree extends ExistentialTypeTreeExtractor
+
+ case class TypeTree() extends TypTree with TypeTreeContextApi {
private var orig: Tree = null
private[scala] var wasEmpty: Boolean = false
@@ -798,8 +483,8 @@ trait Trees { self: Universe =>
case t => t
}
- orig = followOriginal(tree)
- this setPos tree.pos
+ orig = followOriginal(tree); setPos(tree.pos);
+ this
}
override def defineType(tp: Type): this.type = {
@@ -807,306 +492,10 @@ trait Trees { self: Universe =>
setType(tp)
}
}
+ object TypeTree extends TypeTreeExtractor
def TypeTree(tp: Type): TypeTree = TypeTree() setType tp
- /** An empty deferred value definition corresponding to:
- * val _: _
- * This is used as a placeholder in the `self` parameter Template if there is
- * no definition of a self value of self type.
- */
- def emptyValDef: ValDef
-
- // ------ traversers, copiers, and transformers ---------------------------------------------
-
- val treeCopy = newLazyTreeCopier
-
- def copyDefDef(tree: Tree)(
- mods: Modifiers = null,
- name: Name = null,
- tparams: List[TypeDef] = null,
- vparamss: List[List[ValDef]] = null,
- tpt: Tree = null,
- rhs: Tree = null
- ): DefDef = tree match {
- case DefDef(mods0, name0, tparams0, vparamss0, tpt0, rhs0) =>
- treeCopy.DefDef(tree,
- if (mods eq null) mods0 else mods,
- if (name eq null) name0 else name,
- if (tparams eq null) tparams0 else tparams,
- if (vparamss eq null) vparamss0 else vparamss,
- if (tpt eq null) tpt0 else tpt,
- if (rhs eq null) rhs0 else rhs
- )
- case t =>
- sys.error("Not a DefDef: " + t + "/" + t.getClass)
- }
- def copyValDef(tree: Tree)(
- mods: Modifiers = null,
- name: Name = null,
- tpt: Tree = null,
- rhs: Tree = null
- ): ValDef = tree match {
- case ValDef(mods0, name0, tpt0, rhs0) =>
- treeCopy.ValDef(tree,
- if (mods eq null) mods0 else mods,
- if (name eq null) name0 else name,
- if (tpt eq null) tpt0 else tpt,
- if (rhs eq null) rhs0 else rhs
- )
- case t =>
- sys.error("Not a ValDef: " + t + "/" + t.getClass)
- }
- def copyClassDef(tree: Tree)(
- mods: Modifiers = null,
- name: Name = null,
- tparams: List[TypeDef] = null,
- impl: Template = null
- ): ClassDef = tree match {
- case ClassDef(mods0, name0, tparams0, impl0) =>
- treeCopy.ClassDef(tree,
- if (mods eq null) mods0 else mods,
- if (name eq null) name0 else name,
- if (tparams eq null) tparams0 else tparams,
- if (impl eq null) impl0 else impl
- )
- case t =>
- sys.error("Not a ClassDef: " + t + "/" + t.getClass)
- }
-
- def deriveDefDef(ddef: Tree)(applyToRhs: Tree => Tree): DefDef = ddef match {
- case DefDef(mods0, name0, tparams0, vparamss0, tpt0, rhs0) =>
- treeCopy.DefDef(ddef, mods0, name0, tparams0, vparamss0, tpt0, applyToRhs(rhs0))
- case t =>
- sys.error("Not a DefDef: " + t + "/" + t.getClass)
- }
- def deriveValDef(vdef: Tree)(applyToRhs: Tree => Tree): ValDef = vdef match {
- case ValDef(mods0, name0, tpt0, rhs0) =>
- treeCopy.ValDef(vdef, mods0, name0, tpt0, applyToRhs(rhs0))
- case t =>
- sys.error("Not a ValDef: " + t + "/" + t.getClass)
- }
- def deriveTemplate(templ: Tree)(applyToBody: List[Tree] => List[Tree]): Template = templ match {
- case Template(parents0, self0, body0) =>
- treeCopy.Template(templ, parents0, self0, applyToBody(body0))
- case t =>
- sys.error("Not a Template: " + t + "/" + t.getClass)
- }
- def deriveClassDef(cdef: Tree)(applyToImpl: Template => Template): ClassDef = cdef match {
- case ClassDef(mods0, name0, tparams0, impl0) =>
- treeCopy.ClassDef(cdef, mods0, name0, tparams0, applyToImpl(impl0))
- case t =>
- sys.error("Not a ClassDef: " + t + "/" + t.getClass)
- }
- def deriveModuleDef(mdef: Tree)(applyToImpl: Template => Template): ModuleDef = mdef match {
- case ModuleDef(mods0, name0, impl0) =>
- treeCopy.ModuleDef(mdef, mods0, name0, applyToImpl(impl0))
- case t =>
- sys.error("Not a ModuleDef: " + t + "/" + t.getClass)
- }
- def deriveCaseDef(cdef: Tree)(applyToBody: Tree => Tree): CaseDef = cdef match {
- case CaseDef(pat0, guard0, body0) =>
- treeCopy.CaseDef(cdef, pat0, guard0, applyToBody(body0))
- case t =>
- sys.error("Not a CaseDef: " + t + "/" + t.getClass)
- }
- def deriveLabelDef(ldef: Tree)(applyToRhs: Tree => Tree): LabelDef = ldef match {
- case LabelDef(name0, params0, rhs0) =>
- treeCopy.LabelDef(ldef, name0, params0, applyToRhs(rhs0))
- case t =>
- sys.error("Not a LabelDef: " + t + "/" + t.getClass)
- }
-
- class Traverser {
- protected var currentOwner: Symbol = definitions.RootClass
-
- def traverse(tree: Tree): Unit = tree match {
- case EmptyTree =>
- ;
- case PackageDef(pid, stats) =>
- traverse(pid)
- atOwner(tree.symbol.moduleClass) {
- traverseTrees(stats)
- }
- case ClassDef(mods, name, tparams, impl) =>
- atOwner(tree.symbol) {
- traverseTrees(mods.annotations); traverseTrees(tparams); traverse(impl)
- }
- case ModuleDef(mods, name, impl) =>
- atOwner(tree.symbol.moduleClass) {
- traverseTrees(mods.annotations); traverse(impl)
- }
- case ValDef(mods, name, tpt, rhs) =>
- atOwner(tree.symbol) {
- traverseTrees(mods.annotations); traverse(tpt); traverse(rhs)
- }
- case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
- atOwner(tree.symbol) {
- traverseTrees(mods.annotations); traverseTrees(tparams); traverseTreess(vparamss); traverse(tpt); traverse(rhs)
- }
- case TypeDef(mods, name, tparams, rhs) =>
- atOwner(tree.symbol) {
- traverseTrees(mods.annotations); traverseTrees(tparams); traverse(rhs)
- }
- case LabelDef(name, params, rhs) =>
- traverseTrees(params); traverse(rhs)
- case Import(expr, selectors) =>
- traverse(expr)
- case Annotated(annot, arg) =>
- traverse(annot); traverse(arg)
- case Template(parents, self, body) =>
- traverseTrees(parents)
- if (!self.isEmpty) traverse(self)
- traverseStats(body, tree.symbol)
- case Block(stats, expr) =>
- traverseTrees(stats); traverse(expr)
- case CaseDef(pat, guard, body) =>
- traverse(pat); traverse(guard); traverse(body)
- case Alternative(trees) =>
- traverseTrees(trees)
- case Star(elem) =>
- traverse(elem)
- case Bind(name, body) =>
- traverse(body)
- case UnApply(fun, args) =>
- traverse(fun); traverseTrees(args)
- case ArrayValue(elemtpt, trees) =>
- traverse(elemtpt); traverseTrees(trees)
- case Function(vparams, body) =>
- atOwner(tree.symbol) {
- traverseTrees(vparams); traverse(body)
- }
- case Assign(lhs, rhs) =>
- traverse(lhs); traverse(rhs)
- case AssignOrNamedArg(lhs, rhs) =>
- traverse(lhs); traverse(rhs)
- case If(cond, thenp, elsep) =>
- traverse(cond); traverse(thenp); traverse(elsep)
- case Match(selector, cases) =>
- traverse(selector); traverseTrees(cases)
- case Return(expr) =>
- traverse(expr)
- case Try(block, catches, finalizer) =>
- traverse(block); traverseTrees(catches); traverse(finalizer)
- case Throw(expr) =>
- traverse(expr)
- case New(tpt) =>
- traverse(tpt)
- case Typed(expr, tpt) =>
- traverse(expr); traverse(tpt)
- case TypeApply(fun, args) =>
- traverse(fun); traverseTrees(args)
- case Apply(fun, args) =>
- traverse(fun); traverseTrees(args)
- case ApplyDynamic(qual, args) =>
- traverse(qual); traverseTrees(args)
- case Super(qual, _) =>
- traverse(qual)
- case This(_) =>
- ;
- case Select(qualifier, selector) =>
- traverse(qualifier)
- case Ident(_) =>
- ;
- case ReferenceToBoxed(idt) =>
- traverse(idt)
- case Literal(_) =>
- ;
- case TypeTree() =>
- ;
- case SingletonTypeTree(ref) =>
- traverse(ref)
- case SelectFromTypeTree(qualifier, selector) =>
- traverse(qualifier)
- case CompoundTypeTree(templ) =>
- traverse(templ)
- case AppliedTypeTree(tpt, args) =>
- traverse(tpt); traverseTrees(args)
- case TypeBoundsTree(lo, hi) =>
- traverse(lo); traverse(hi)
- case ExistentialTypeTree(tpt, whereClauses) =>
- traverse(tpt); traverseTrees(whereClauses)
- case _ => xtraverse(this, tree)
- }
-
- def traverseTrees(trees: List[Tree]) {
- trees foreach traverse
- }
- def traverseTreess(treess: List[List[Tree]]) {
- treess foreach traverseTrees
- }
- def traverseStats(stats: List[Tree], exprOwner: Symbol) {
- stats foreach (stat =>
- if (exprOwner != currentOwner) atOwner(exprOwner)(traverse(stat))
- else traverse(stat)
- )
- }
-
- def atOwner(owner: Symbol)(traverse: => Unit) {
- val prevOwner = currentOwner
- currentOwner = owner
- traverse
- currentOwner = prevOwner
- }
-
- /** Leave apply available in the generic traverser to do something else.
- */
- def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
- }
-
- protected def xtraverse(traverser: Traverser, tree: Tree): Unit = throw new MatchError(tree)
-
- // to be implemented in subclasses:
- type TreeCopier <: TreeCopierOps
- def newStrictTreeCopier: TreeCopier
- def newLazyTreeCopier: TreeCopier
-
- trait TreeCopierOps {
- def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template): ClassDef
- def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]): PackageDef
- def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template): ModuleDef
- def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree): ValDef
- def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef
- def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree): TypeDef
- def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef
- def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]): Import
- def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]): Template
- def Block(tree: Tree, stats: List[Tree], expr: Tree): Block
- def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree): CaseDef
- def Alternative(tree: Tree, trees: List[Tree]): Alternative
- def Star(tree: Tree, elem: Tree): Star
- def Bind(tree: Tree, name: Name, body: Tree): Bind
- def UnApply(tree: Tree, fun: Tree, args: List[Tree]): UnApply
- def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]): ArrayValue
- def Function(tree: Tree, vparams: List[ValDef], body: Tree): Function
- def Assign(tree: Tree, lhs: Tree, rhs: Tree): Assign
- def AssignOrNamedArg(tree: Tree, lhs: Tree, rhs: Tree): AssignOrNamedArg
- def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree): If
- def Match(tree: Tree, selector: Tree, cases: List[CaseDef]): Match
- def Return(tree: Tree, expr: Tree): Return
- def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree): Try
- def Throw(tree: Tree, expr: Tree): Throw
- def New(tree: Tree, tpt: Tree): New
- def Typed(tree: Tree, expr: Tree, tpt: Tree): Typed
- def TypeApply(tree: Tree, fun: Tree, args: List[Tree]): TypeApply
- def Apply(tree: Tree, fun: Tree, args: List[Tree]): Apply
- def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]): ApplyDynamic
- def Super(tree: Tree, qual: Tree, mix: TypeName): Super
- def This(tree: Tree, qual: Name): This
- def Select(tree: Tree, qualifier: Tree, selector: Name): Select
- def Ident(tree: Tree, name: Name): Ident
- def ReferenceToBoxed(tree: Tree, idt: Ident): ReferenceToBoxed
- def Literal(tree: Tree, value: Constant): Literal
- def TypeTree(tree: Tree): TypeTree
- def Annotated(tree: Tree, annot: Tree, arg: Tree): Annotated
- def SingletonTypeTree(tree: Tree, ref: Tree): SingletonTypeTree
- def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name): SelectFromTypeTree
- def CompoundTypeTree(tree: Tree, templ: Template): CompoundTypeTree
- def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]): AppliedTypeTree
- def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree): TypeBoundsTree
- def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
- }
-
class StrictTreeCopier extends TreeCopierOps {
def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template) =
new ClassDef(mods, name.toTypeName, tparams, impl).copyAttrs(tree)
@@ -1177,11 +566,8 @@ trait Trees { self: Universe =>
new This(qual.toTypeName).copyAttrs(tree)
def Select(tree: Tree, qualifier: Tree, selector: Name) =
new Select(qualifier, selector).copyAttrs(tree)
- def Ident(tree: Tree, name: Name) = {
- val t = new Ident(name) copyAttrs tree
- if (tree hasAttachment BackquotedIdentifier) t withAttachment BackquotedIdentifier
- else t
- }
+ def Ident(tree: Tree, name: Name) =
+ new Ident(name) copyAttrs tree
def ReferenceToBoxed(tree: Tree, idt: Ident) =
new ReferenceToBoxed(idt).copyAttrs(tree)
def Literal(tree: Tree, value: Constant) =
@@ -1423,19 +809,349 @@ trait Trees { self: Universe =>
}
}
- abstract class Transformer {
- val treeCopy: TreeCopier = newLazyTreeCopier
- protected var currentOwner: Symbol = definitions.RootClass
- protected def currentMethod = currentOwner.enclosingMethod
- protected def currentClass = currentOwner.enclosingClass
- protected def currentPackage = currentOwner.enclosingTopLevelClass.owner
- def transform(tree: Tree): Tree = tree match {
+ // Belongs in TreeInfo but then I can't reach it from TreePrinters.
+ def isReferenceToScalaMember(t: Tree, Id: Name) = t match {
+ case Ident(Id) => true
+ case Select(Ident(nme.scala_), Id) => true
+ case Select(Select(Ident(nme.ROOTPKG), nme.scala_), Id) => true
+ case _ => false
+ }
+ /** Is the tree Predef, scala.Predef, or _root_.scala.Predef?
+ */
+ def isReferenceToPredef(t: Tree) = isReferenceToScalaMember(t, nme.Predef)
+ def isReferenceToAnyVal(t: Tree) = isReferenceToScalaMember(t, tpnme.AnyVal)
+
+ // --- modifiers implementation ---------------------------------------
+
+ /** @param privateWithin the qualifier for a private (a type name)
+ * or tpnme.EMPTY, if none is given.
+ * @param annotations the annotations for the definition.
+ * '''Note:''' the typechecker drops these annotations,
+ * use the AnnotationInfo's (Symbol.annotations) in later phases.
+ */
+ case class Modifiers(flags: Long,
+ privateWithin: Name,
+ annotations: List[Tree]) extends ModifiersApi with HasFlags {
+
+ var positions: Map[Long, Position] = Map()
+
+ def setPositions(poss: Map[Long, Position]): this.type = {
+ positions = poss; this
+ }
+
+ /* Abstract types from HasFlags. */
+ type AccessBoundaryType = Name
+ type AnnotationType = Tree
+
+ def hasAnnotationNamed(name: TypeName) = {
+ annotations exists {
+ case Apply(Select(New(Ident(`name`)), _), _) => true
+ case Apply(Select(New(Select(_, `name`)), _), _) => true
+ case _ => false
+ }
+ }
+
+ def hasAccessBoundary = privateWithin != tpnme.EMPTY
+ def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
+ def hasFlag(flag: Long) = (flag & flags) != 0L
+
+ def & (flag: Long): Modifiers = {
+ val flags1 = flags & flag
+ if (flags1 == flags) this
+ else Modifiers(flags1, privateWithin, annotations) setPositions positions
+ }
+ def &~ (flag: Long): Modifiers = {
+ val flags1 = flags & (~flag)
+ if (flags1 == flags) this
+ else Modifiers(flags1, privateWithin, annotations) setPositions positions
+ }
+ def | (flag: Long): Modifiers = {
+ val flags1 = flags | flag
+ if (flags1 == flags) this
+ else Modifiers(flags1, privateWithin, annotations) setPositions positions
+ }
+ def withAnnotations(annots: List[Tree]) =
+ if (annots.isEmpty) this
+ else copy(annotations = annotations ::: annots) setPositions positions
+
+ def withPosition(flag: Long, position: Position) =
+ copy() setPositions positions + (flag -> position)
+
+ override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers =
+ Modifiers(flags, privateWithin, f(annotations)) setPositions positions
+
+ override def toString = "Modifiers(%s, %s, %s)".format(flagString, annotations mkString ", ", positions)
+ }
+
+ object Modifiers extends ModifiersCreator
+
+ implicit val ModifiersTag = ClassTag[Modifiers](classOf[Modifiers])
+
+ // ---- values and creators ---------------------------------------
+
+ /** @param sym the class symbol
+ * @return the implementation template
+ */
+ def ClassDef(sym: Symbol, impl: Template): ClassDef =
+ atPos(sym.pos) {
+ ClassDef(Modifiers(sym.flags),
+ sym.name.toTypeName,
+ sym.typeParams map TypeDef,
+ impl) setSymbol sym
+ }
+
+ /**
+ * @param sym the class symbol
+ * @param impl the implementation template
+ */
+ def ModuleDef(sym: Symbol, impl: Template): ModuleDef =
+ atPos(sym.pos) {
+ ModuleDef(Modifiers(sym.flags), sym.name.toTermName, impl) setSymbol sym
+ }
+
+ def ValDef(sym: Symbol, rhs: Tree): ValDef =
+ atPos(sym.pos) {
+ ValDef(Modifiers(sym.flags), sym.name.toTermName,
+ TypeTree(sym.tpe) setPos sym.pos.focus,
+ rhs) setSymbol sym
+ }
+
+ def ValDef(sym: Symbol): ValDef = ValDef(sym, EmptyTree)
+
+ object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) {
+ override def isEmpty = true
+ super.setPos(NoPosition)
+ override def setPos(pos: Position) = { assert(false); this }
+ }
+
+ def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef =
+ atPos(sym.pos) {
+ assert(sym != NoSymbol)
+ DefDef(mods,
+ sym.name.toTermName,
+ sym.typeParams map TypeDef,
+ vparamss,
+ TypeTree(sym.tpe.finalResultType) setPos sym.pos.focus,
+ rhs) setSymbol sym
+ }
+
+ def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef =
+ DefDef(sym, Modifiers(sym.flags), vparamss, rhs)
+
+ def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef =
+ DefDef(sym, mods, mapParamss(sym)(ValDef), rhs)
+
+ def DefDef(sym: Symbol, rhs: Tree): DefDef =
+ DefDef(sym, Modifiers(sym.flags), rhs)
+
+ def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef =
+ DefDef(sym, rhs(sym.info.paramss))
+
+ /** A TypeDef node which defines given `sym` with given tight hand side `rhs`. */
+ def TypeDef(sym: Symbol, rhs: Tree): TypeDef =
+ atPos(sym.pos) {
+ TypeDef(Modifiers(sym.flags), sym.name.toTypeName, sym.typeParams map TypeDef, rhs) setSymbol sym
+ }
+
+ /** A TypeDef node which defines abstract type or type parameter for given `sym` */
+ def TypeDef(sym: Symbol): TypeDef =
+ TypeDef(sym, TypeBoundsTree(TypeTree(sym.info.bounds.lo), TypeTree(sym.info.bounds.hi)))
+
+ def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef =
+ atPos(sym.pos) {
+ LabelDef(sym.name.toTermName, params map Ident, rhs) setSymbol sym
+ }
+
+ /** casedef shorthand */
+ def CaseDef(pat: Tree, body: Tree): CaseDef =
+ CaseDef(pat, EmptyTree, body)
+
+ def Bind(sym: Symbol, body: Tree): Bind =
+ Bind(sym.name, body) setSymbol sym
+
+ def Try(body: Tree, cases: (Tree, Tree)*): Try =
+ Try(body, cases.toList map { case (pat, rhs) => CaseDef(pat, EmptyTree, rhs) }, EmptyTree)
+
+ def Throw(tpe: Type, args: Tree*): Throw =
+ Throw(New(tpe, args: _*))
+
+ def Apply(sym: Symbol, args: Tree*): Tree =
+ Apply(Ident(sym), args.toList)
+
+ /** Factory method for object creation `new tpt(args_1)...(args_n)`
+ * A `New(t, as)` is expanded to: `(new t).<init>(as)`
+ */
+ def New(tpt: Tree, argss: List[List[Tree]]): Tree = argss match {
+ case Nil => ApplyConstructor(tpt, Nil)
+ case xs :: rest => {
+ def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
+ rest.foldLeft(ApplyConstructor(tpt, xs): Tree)(mkApply)
+ // [Eugene++] no longer compiles after I moved the `Apply` case class here
+ // rest.foldLeft(ApplyConstructor(tpt, xs): Tree)(Apply)
+ }
+ }
+
+ /** 0-1 argument list new, based on a type.
+ */
+ def New(tpe: Type, args: Tree*): Tree =
+ ApplyConstructor(TypeTree(tpe), args.toList)
+
+ def New(sym: Symbol, args: Tree*): Tree =
+ New(sym.tpe, args: _*)
+
+ def Super(sym: Symbol, mix: TypeName): Tree =
+ Super(This(sym), mix)
+
+ def This(sym: Symbol): Tree =
+ This(sym.name.toTypeName) setSymbol sym
+
+ def Select(qualifier: Tree, name: String): Select =
+ Select(qualifier, newTermName(name))
+
+ def Select(qualifier: Tree, sym: Symbol): Select =
+ Select(qualifier, sym.name) setSymbol sym
+
+ def Ident(name: String): Ident =
+ Ident(newTermName(name))
+
+ def Ident(sym: Symbol): Ident =
+ Ident(sym.name) setSymbol sym
+
+ /** Block factory that flattens directly nested blocks.
+ */
+ def Block(stats: Tree*): Block = {
+ if (stats.isEmpty) Block(Nil, Literal(Constant(())))
+ else stats match {
+ case Seq(b @ Block(_, _)) => b
+ case Seq(stat) => Block(stats.toList, Literal(Constant(())))
+ case Seq(_, rest @ _*) => Block(stats.init.toList, stats.last)
+ }
+ }
+
+ // --- generic traversers and transformers
+
+ override protected def itraverse(traverser: Traverser, tree: Tree): Unit = {
+ import traverser._
+ tree match {
+ case EmptyTree =>
+ ;
+ case PackageDef(pid, stats) =>
+ traverse(pid)
+ atOwner(mclass(tree.symbol)) {
+ traverseTrees(stats)
+ }
+ case ClassDef(mods, name, tparams, impl) =>
+ atOwner(tree.symbol) {
+ traverseTrees(mods.annotations); traverseTrees(tparams); traverse(impl)
+ }
+ case ModuleDef(mods, name, impl) =>
+ atOwner(mclass(tree.symbol)) {
+ traverseTrees(mods.annotations); traverse(impl)
+ }
+ case ValDef(mods, name, tpt, rhs) =>
+ atOwner(tree.symbol) {
+ traverseTrees(mods.annotations); traverse(tpt); traverse(rhs)
+ }
+ case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
+ atOwner(tree.symbol) {
+ traverseTrees(mods.annotations); traverseTrees(tparams); traverseTreess(vparamss); traverse(tpt); traverse(rhs)
+ }
+ case TypeDef(mods, name, tparams, rhs) =>
+ atOwner(tree.symbol) {
+ traverseTrees(mods.annotations); traverseTrees(tparams); traverse(rhs)
+ }
+ case LabelDef(name, params, rhs) =>
+ traverseTrees(params); traverse(rhs)
+ case Import(expr, selectors) =>
+ traverse(expr)
+ case Annotated(annot, arg) =>
+ traverse(annot); traverse(arg)
+ case Template(parents, self, body) =>
+ traverseTrees(parents)
+ if (!self.isEmpty) traverse(self)
+ traverseStats(body, tree.symbol)
+ case Block(stats, expr) =>
+ traverseTrees(stats); traverse(expr)
+ case CaseDef(pat, guard, body) =>
+ traverse(pat); traverse(guard); traverse(body)
+ case Alternative(trees) =>
+ traverseTrees(trees)
+ case Star(elem) =>
+ traverse(elem)
+ case Bind(name, body) =>
+ traverse(body)
+ case UnApply(fun, args) =>
+ traverse(fun); traverseTrees(args)
+ case ArrayValue(elemtpt, trees) =>
+ traverse(elemtpt); traverseTrees(trees)
+ case Function(vparams, body) =>
+ atOwner(tree.symbol) {
+ traverseTrees(vparams); traverse(body)
+ }
+ case Assign(lhs, rhs) =>
+ traverse(lhs); traverse(rhs)
+ case AssignOrNamedArg(lhs, rhs) =>
+ traverse(lhs); traverse(rhs)
+ case If(cond, thenp, elsep) =>
+ traverse(cond); traverse(thenp); traverse(elsep)
+ case Match(selector, cases) =>
+ traverse(selector); traverseTrees(cases)
+ case Return(expr) =>
+ traverse(expr)
+ case Try(block, catches, finalizer) =>
+ traverse(block); traverseTrees(catches); traverse(finalizer)
+ case Throw(expr) =>
+ traverse(expr)
+ case New(tpt) =>
+ traverse(tpt)
+ case Typed(expr, tpt) =>
+ traverse(expr); traverse(tpt)
+ case TypeApply(fun, args) =>
+ traverse(fun); traverseTrees(args)
+ case Apply(fun, args) =>
+ traverse(fun); traverseTrees(args)
+ case ApplyDynamic(qual, args) =>
+ traverse(qual); traverseTrees(args)
+ case Super(qual, _) =>
+ traverse(qual)
+ case This(_) =>
+ ;
+ case Select(qualifier, selector) =>
+ traverse(qualifier)
+ case Ident(_) =>
+ ;
+ case ReferenceToBoxed(idt) =>
+ traverse(idt)
+ case Literal(_) =>
+ ;
+ case TypeTree() =>
+ ;
+ case SingletonTypeTree(ref) =>
+ traverse(ref)
+ case SelectFromTypeTree(qualifier, selector) =>
+ traverse(qualifier)
+ case CompoundTypeTree(templ) =>
+ traverse(templ)
+ case AppliedTypeTree(tpt, args) =>
+ traverse(tpt); traverseTrees(args)
+ case TypeBoundsTree(lo, hi) =>
+ traverse(lo); traverse(hi)
+ case ExistentialTypeTree(tpt, whereClauses) =>
+ traverse(tpt); traverseTrees(whereClauses)
+ case _ => xtraverse(traverser, tree)
+ }
+ }
+
+ override protected def itransform(transformer: Transformer, tree: Tree): Tree = {
+ import transformer._
+ val treeCopy = transformer.treeCopy
+ tree match {
case EmptyTree =>
tree
case PackageDef(pid, stats) =>
treeCopy.PackageDef(
tree, transform(pid).asInstanceOf[RefTree],
- atOwner(tree.symbol.moduleClass) {
+ atOwner(mclass(tree.symbol)) {
transformStats(stats, currentOwner)
}
)
@@ -1445,7 +1161,7 @@ trait Trees { self: Universe =>
transformTypeDefs(tparams), transformTemplate(impl))
}
case ModuleDef(mods, name, impl) =>
- atOwner(tree.symbol.moduleClass) {
+ atOwner(mclass(tree.symbol)) {
treeCopy.ModuleDef(tree, transformModifiers(mods),
name, transformTemplate(impl))
}
@@ -1542,42 +1258,144 @@ trait Trees { self: Universe =>
case ExistentialTypeTree(tpt, whereClauses) =>
treeCopy.ExistentialTypeTree(tree, transform(tpt), transformTrees(whereClauses))
case _ =>
- xtransform(this, tree)
- }
-
- def transformTrees(trees: List[Tree]): List[Tree] =
- trees mapConserve (transform(_))
- def transformTemplate(tree: Template): Template =
- transform(tree: Tree).asInstanceOf[Template]
- def transformTypeDefs(trees: List[TypeDef]): List[TypeDef] =
- trees mapConserve (tree => transform(tree).asInstanceOf[TypeDef])
- def transformValDef(tree: ValDef): ValDef =
- if (tree.isEmpty) tree else transform(tree).asInstanceOf[ValDef]
- def transformValDefs(trees: List[ValDef]): List[ValDef] =
- trees mapConserve (transformValDef(_))
- def transformValDefss(treess: List[List[ValDef]]): List[List[ValDef]] =
- treess mapConserve (transformValDefs(_))
- def transformCaseDefs(trees: List[CaseDef]): List[CaseDef] =
- trees mapConserve (tree => transform(tree).asInstanceOf[CaseDef])
- def transformIdents(trees: List[Ident]): List[Ident] =
- trees mapConserve (tree => transform(tree).asInstanceOf[Ident])
- def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] =
- stats mapConserve (stat =>
- if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat))
- else transform(stat)) filter (EmptyTree != _)
- def transformModifiers(mods: Modifiers): Modifiers =
- mods.mapAnnotations(transformTrees)
-
- def atOwner[A](owner: Symbol)(trans: => A): A = {
- val prevOwner = currentOwner
- currentOwner = owner
- val result = trans
- currentOwner = prevOwner
- result
+ xtransform(transformer, tree)
+ }
+ }
+
+ private def mclass(sym: Symbol) = sym map (_.asModuleSymbol.moduleClass)
+
+ // --- specific traversers and transformers
+
+ @deprecated("Moved to tree.duplicate", "2.10.0")
+ protected[scala] def duplicateTree(tree: Tree): Tree = tree.duplicate
+
+ class ForeachPartialTreeTraverser(pf: PartialFunction[Tree, Tree]) extends Traverser {
+ override def traverse(tree: Tree) {
+ val t = if (pf isDefinedAt tree) pf(tree) else tree
+ super.traverse(t)
+ }
+ }
+
+ class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser {
+ def changeOwner(tree: Tree) = tree match {
+ case Return(expr) =>
+ if (tree.symbol == oldowner) {
+ // SI-5612
+ if (newowner hasTransOwner oldowner)
+ log("NOT changing owner of %s because %s is nested in %s".format(tree, newowner, oldowner))
+ else {
+ log("changing owner of %s: %s => %s".format(tree, oldowner, newowner))
+ tree.symbol = newowner
+ }
+ }
+ case _: DefTree | _: Function =>
+ if (tree.symbol != NoSymbol && tree.symbol.owner == oldowner) {
+ tree.symbol.owner = newowner
+ }
+ case _ =>
+ }
+ override def traverse(tree: Tree) {
+ changeOwner(tree)
+ super.traverse(tree)
+ }
+ }
+
+ private class ShallowDuplicator(orig: Tree) extends Transformer {
+ override val treeCopy = newStrictTreeCopier
+ override def transform(tree: Tree) =
+ if (tree eq orig) super.transform(tree)
+ else tree
+ }
+ // Create a readable string describing a substitution.
+ private def substituterString(fromStr: String, toStr: String, from: List[Any], to: List[Any]): String = {
+ "subst[%s, %s](%s)".format(fromStr, toStr, (from, to).zipped map (_ + " -> " + _) mkString ", ")
+ }
+
+ // NOTE: calls shallowDuplicate on trees in `to` to avoid problems when symbols in `from`
+ // occur multiple times in the `tree` passed to `transform`,
+ // otherwise, the resulting Tree would be a graph, not a tree... this breaks all sorts of stuff,
+ // notably concerning the mutable aspects of Trees (such as setting their .tpe)
+ class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer {
+ override def transform(tree: Tree): Tree = tree match {
+ case Ident(_) =>
+ def subst(from: List[Symbol], to: List[Tree]): Tree =
+ if (from.isEmpty) tree
+ else if (tree.symbol == from.head) to.head.shallowDuplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`?
+ else subst(from.tail, to.tail);
+ subst(from, to)
+ case _ =>
+ super.transform(tree)
+ }
+ override def toString = substituterString("Symbol", "Tree", from, to)
+ }
+
+ /** Substitute clazz.this with `to`. `to` must be an attributed tree.
+ */
+ class ThisSubstituter(clazz: Symbol, to: => Tree) extends Transformer {
+ val newtpe = to.tpe
+ override def transform(tree: Tree) = {
+ if (tree.tpe ne null) tree.tpe = tree.tpe.substThis(clazz, newtpe)
+ tree match {
+ case This(_) if tree.symbol == clazz => to
+ case _ => super.transform(tree)
+ }
+ }
+ }
+
+ class TypeMapTreeSubstituter(val typeMap: TypeMap) extends Traverser {
+ override def traverse(tree: Tree) {
+ if (tree.tpe ne null)
+ tree.tpe = typeMap(tree.tpe)
+ if (tree.isDef)
+ tree.symbol modifyInfo typeMap
+
+ super.traverse(tree)
+ }
+ override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
+ }
+
+ class TreeTypeSubstituter(val from: List[Symbol], val to: List[Type]) extends TypeMapTreeSubstituter(new SubstTypeMap(from, to)) {
+ def isEmpty = from.isEmpty && to.isEmpty
+ override def toString() = "TreeTypeSubstituter("+from+","+to+")"
+ }
+
+ lazy val EmptyTreeTypeSubstituter = new TreeTypeSubstituter(List(), List())
+
+ class TreeSymSubstTraverser(val from: List[Symbol], val to: List[Symbol]) extends TypeMapTreeSubstituter(new SubstSymMap(from, to)) {
+ override def toString() = "TreeSymSubstTraverser/" + substituterString("Symbol", "Symbol", from, to)
+ }
+
+ /** Substitute symbols in `from` with symbols in `to`. Returns a new
+ * tree using the new symbols and whose Ident and Select nodes are
+ * name-consistent with the new symbols.
+ */
+ class TreeSymSubstituter(from: List[Symbol], to: List[Symbol]) extends Transformer {
+ val symSubst = new SubstSymMap(from, to)
+ override def transform(tree: Tree): Tree = {
+ def subst(from: List[Symbol], to: List[Symbol]) {
+ if (!from.isEmpty)
+ if (tree.symbol == from.head) tree setSymbol to.head
+ else subst(from.tail, to.tail)
+ }
+
+ if (tree.tpe ne null) tree.tpe = symSubst(tree.tpe)
+ if (tree.hasSymbol) {
+ subst(from, to)
+ tree match {
+ case Ident(name0) if tree.symbol != NoSymbol =>
+ treeCopy.Ident(tree, tree.symbol.name)
+ case Select(qual, name0) if tree.symbol != NoSymbol =>
+ treeCopy.Select(tree, transform(qual), tree.symbol.name)
+ case _ =>
+ super.transform(tree)
+ }
+ } else
+ super.transform(tree)
}
+ def apply[T <: Tree](tree: T): T = transform(tree).asInstanceOf[T]
+ override def toString() = "TreeSymSubstituter/" + substituterString("Symbol", "Symbol", from, to)
}
- protected def xtransform(transformer: Transformer, tree: Tree): Tree = throw new MatchError(tree)
class ForeachTreeTraverser(f: Tree => Unit) extends Traverser {
override def traverse(t: Tree) {
@@ -1612,119 +1430,166 @@ trait Trees { self: Universe =>
}
}
- protected def duplicateTree(tree: Tree): Tree
-
-/* A standard pattern match
- case EmptyTree =>
- case PackageDef(pid, stats) =>
- // package pid { stats }
- case ClassDef(mods, name, tparams, impl) =>
- // mods class name [tparams] impl where impl = extends parents { defs }
- case ModuleDef(mods, name, impl) => (eliminated by refcheck)
- // mods object name impl where impl = extends parents { defs }
- case ValDef(mods, name, tpt, rhs) =>
- // mods val name: tpt = rhs
- // note missing type information is expressed by tpt = TypeTree()
- case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
- // mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs
- // note missing type information is expressed by tpt = TypeTree()
- case TypeDef(mods, name, tparams, rhs) => (eliminated by erasure)
- // mods type name[tparams] = rhs
- // mods type name[tparams] >: lo <: hi, where lo, hi are in a TypeBoundsTree,
- and DEFERRED is set in mods
- case LabelDef(name, params, rhs) =>
- // used for tailcalls and like
- // while/do are desugared to label defs as follows:
- // while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ())
- // do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ())
- case Import(expr, selectors) => (eliminated by typecheck)
- // import expr.{selectors}
- // Selectors are a list of pairs of names (from, to).
- // The last (and maybe only name) may be a nme.WILDCARD
- // for instance
- // import qual.{x, y => z, _} would be represented as
- // Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null)))
- case Template(parents, self, body) =>
- // extends parents { self => body }
- // if self is missing it is represented as emptyValDef
- case Block(stats, expr) =>
- // { stats; expr }
- case CaseDef(pat, guard, body) => (eliminated by transmatch/explicitouter)
- // case pat if guard => body
- case Alternative(trees) => (eliminated by transmatch/explicitouter)
- // pat1 | ... | patn
- case Star(elem) => (eliminated by transmatch/explicitouter)
- // pat*
- case Bind(name, body) => (eliminated by transmatch/explicitouter)
- // name @ pat
- case UnApply(fun: Tree, args) (introduced by typer, eliminated by transmatch/explicitouter)
- // used for unapply's
- case ArrayValue(elemtpt, trees) => (introduced by uncurry)
- // used to pass arguments to vararg arguments
- // for instance, printf("%s%d", foo, 42) is translated to after uncurry to:
- // Apply(
- // Ident("printf"),
- // Literal("%s%d"),
- // ArrayValue(<Any>, List(Ident("foo"), Literal(42))))
- case Function(vparams, body) => (eliminated by lambdaLift)
- // vparams => body where vparams:List[ValDef]
- case Assign(lhs, rhs) =>
- // lhs = rhs
- case AssignOrNamedArg(lhs, rhs) => (eliminated by typer, resurrected by reifier)
- // @annotation(lhs = rhs)
- case If(cond, thenp, elsep) =>
- // if (cond) thenp else elsep
- case Match(selector, cases) =>
- // selector match { cases }
- case Return(expr) =>
- // return expr
- case Try(block, catches, finalizer) =>
- // try block catch { catches } finally finalizer where catches: List[CaseDef]
- case Throw(expr) =>
- // throw expr
- case New(tpt) =>
- // new tpt always in the context: (new tpt).<init>[targs](args)
- case Typed(expr, tpt) => (eliminated by erasure)
- // expr: tpt
- case TypeApply(fun, args) =>
- // fun[args]
- case Apply(fun, args) =>
- // fun(args)
- // for instance fun[targs](args) is expressed as Apply(TypeApply(fun, targs), args)
- case ApplyDynamic(qual, args) (introduced by erasure, eliminated by cleanup)
- // fun(args)
- case Super(qual, mix) =>
- // qual.super[mix] qual is always This(something), if mix is empty, it is tpnme.EMPTY
- case This(qual) =>
- // qual.this
- case Select(qualifier, selector) =>
- // qualifier.selector
- case Ident(name) =>
- // name
- // note: type checker converts idents that refer to enclosing fields or methods
- // to selects; name ==> this.name
- case ReferenceToBoxed(ident) => (created by typer, eliminated by lambdalift)
- // synthetic node emitted by macros to reference capture vars directly without going through ``elem''
- // var x = ...; fun { x } will emit Ident(x), which gets transformed to Select(Ident(x), "elem")
- // if ReferenceToBoxed were used instead of Ident, no transformation would be performed
- case Literal(value) =>
- // value
- case TypeTree() => (introduced by refcheck)
- // a type that's not written out, but given in the tpe attribute
- case Annotated(annot, arg) => (eliminated by typer)
- // arg @annot for types, arg: @annot for exprs
- case SingletonTypeTree(ref) => (eliminated by uncurry)
- // ref.type
- case SelectFromTypeTree(qualifier, selector) => (eliminated by uncurry)
- // qualifier # selector, a path-dependent type p.T is expressed as p.type # T
- case CompoundTypeTree(templ: Template) => (eliminated by uncurry)
- // parent1 with ... with parentN { refinement }
- case AppliedTypeTree(tpt, args) => (eliminated by uncurry)
- // tpt[args]
- case TypeBoundsTree(lo, hi) => (eliminated by uncurry)
- // >: lo <: hi
- case ExistentialTypeTree(tpt, whereClauses) => (eliminated by uncurry)
- // tpt forSome { whereClauses }
-*/
-}
+ private lazy val duplicator = new Transformer {
+ override val treeCopy = newStrictTreeCopier
+ override def transform(t: Tree) = {
+ val t1 = super.transform(t)
+ if ((t1 ne t) && t1.pos.isRange) t1 setPos t.pos.focus
+ t1
+ }
+ }
+
+ // ------ copiers -------------------------------------------
+
+ def copyDefDef(tree: Tree)(
+ mods: Modifiers = null,
+ name: Name = null,
+ tparams: List[TypeDef] = null,
+ vparamss: List[List[ValDef]] = null,
+ tpt: Tree = null,
+ rhs: Tree = null
+ ): DefDef = tree match {
+ case DefDef(mods0, name0, tparams0, vparamss0, tpt0, rhs0) =>
+ treeCopy.DefDef(tree,
+ if (mods eq null) mods0 else mods,
+ if (name eq null) name0 else name,
+ if (tparams eq null) tparams0 else tparams,
+ if (vparamss eq null) vparamss0 else vparamss,
+ if (tpt eq null) tpt0 else tpt,
+ if (rhs eq null) rhs0 else rhs
+ )
+ case t =>
+ sys.error("Not a DefDef: " + t + "/" + t.getClass)
+ }
+ def copyValDef(tree: Tree)(
+ mods: Modifiers = null,
+ name: Name = null,
+ tpt: Tree = null,
+ rhs: Tree = null
+ ): ValDef = tree match {
+ case ValDef(mods0, name0, tpt0, rhs0) =>
+ treeCopy.ValDef(tree,
+ if (mods eq null) mods0 else mods,
+ if (name eq null) name0 else name,
+ if (tpt eq null) tpt0 else tpt,
+ if (rhs eq null) rhs0 else rhs
+ )
+ case t =>
+ sys.error("Not a ValDef: " + t + "/" + t.getClass)
+ }
+ def copyClassDef(tree: Tree)(
+ mods: Modifiers = null,
+ name: Name = null,
+ tparams: List[TypeDef] = null,
+ impl: Template = null
+ ): ClassDef = tree match {
+ case ClassDef(mods0, name0, tparams0, impl0) =>
+ treeCopy.ClassDef(tree,
+ if (mods eq null) mods0 else mods,
+ if (name eq null) name0 else name,
+ if (tparams eq null) tparams0 else tparams,
+ if (impl eq null) impl0 else impl
+ )
+ case t =>
+ sys.error("Not a ClassDef: " + t + "/" + t.getClass)
+ }
+ def deriveDefDef(ddef: Tree)(applyToRhs: Tree => Tree): DefDef = ddef match {
+ case DefDef(mods0, name0, tparams0, vparamss0, tpt0, rhs0) =>
+ treeCopy.DefDef(ddef, mods0, name0, tparams0, vparamss0, tpt0, applyToRhs(rhs0))
+ case t =>
+ sys.error("Not a DefDef: " + t + "/" + t.getClass)
+ }
+ def deriveValDef(vdef: Tree)(applyToRhs: Tree => Tree): ValDef = vdef match {
+ case ValDef(mods0, name0, tpt0, rhs0) =>
+ treeCopy.ValDef(vdef, mods0, name0, tpt0, applyToRhs(rhs0))
+ case t =>
+ sys.error("Not a ValDef: " + t + "/" + t.getClass)
+ }
+ def deriveTemplate(templ: Tree)(applyToBody: List[Tree] => List[Tree]): Template = templ match {
+ case Template(parents0, self0, body0) =>
+ treeCopy.Template(templ, parents0, self0, applyToBody(body0))
+ case t =>
+ sys.error("Not a Template: " + t + "/" + t.getClass)
+ }
+ def deriveClassDef(cdef: Tree)(applyToImpl: Template => Template): ClassDef = cdef match {
+ case ClassDef(mods0, name0, tparams0, impl0) =>
+ treeCopy.ClassDef(cdef, mods0, name0, tparams0, applyToImpl(impl0))
+ case t =>
+ sys.error("Not a ClassDef: " + t + "/" + t.getClass)
+ }
+ def deriveModuleDef(mdef: Tree)(applyToImpl: Template => Template): ModuleDef = mdef match {
+ case ModuleDef(mods0, name0, impl0) =>
+ treeCopy.ModuleDef(mdef, mods0, name0, applyToImpl(impl0))
+ case t =>
+ sys.error("Not a ModuleDef: " + t + "/" + t.getClass)
+ }
+ def deriveCaseDef(cdef: Tree)(applyToBody: Tree => Tree): CaseDef = cdef match {
+ case CaseDef(pat0, guard0, body0) =>
+ treeCopy.CaseDef(cdef, pat0, guard0, applyToBody(body0))
+ case t =>
+ sys.error("Not a CaseDef: " + t + "/" + t.getClass)
+ }
+ def deriveLabelDef(ldef: Tree)(applyToRhs: Tree => Tree): LabelDef = ldef match {
+ case LabelDef(name0, params0, rhs0) =>
+ treeCopy.LabelDef(ldef, name0, params0, applyToRhs(rhs0))
+ case t =>
+ sys.error("Not a LabelDef: " + t + "/" + t.getClass)
+ }
+
+ implicit val TreeTag = ClassTag[Tree](classOf[Tree])
+ implicit val TermTreeTag = ClassTag[TermTree](classOf[TermTree])
+ implicit val TypTreeTag = ClassTag[TypTree](classOf[TypTree])
+ implicit val SymTreeTag = ClassTag[SymTree](classOf[SymTree])
+ implicit val NameTreeTag = ClassTag[NameTree](classOf[NameTree])
+ implicit val RefTreeTag = ClassTag[RefTree](classOf[RefTree])
+ implicit val DefTreeTag = ClassTag[DefTree](classOf[DefTree])
+ implicit val MemberDefTag = ClassTag[MemberDef](classOf[MemberDef])
+ implicit val PackageDefTag = ClassTag[PackageDef](classOf[PackageDef])
+ implicit val ImplDefTag = ClassTag[ImplDef](classOf[ImplDef])
+ implicit val ClassDefTag = ClassTag[ClassDef](classOf[ClassDef])
+ implicit val ModuleDefTag = ClassTag[ModuleDef](classOf[ModuleDef])
+ implicit val ValOrDefDefTag = ClassTag[ValOrDefDef](classOf[ValOrDefDef])
+ implicit val ValDefTag = ClassTag[ValDef](classOf[ValDef])
+ implicit val DefDefTag = ClassTag[DefDef](classOf[DefDef])
+ implicit val TypeDefTag = ClassTag[TypeDef](classOf[TypeDef])
+ implicit val LabelDefTag = ClassTag[LabelDef](classOf[LabelDef])
+ implicit val ImportSelectorTag = ClassTag[ImportSelector](classOf[ImportSelector])
+ implicit val ImportTag = ClassTag[Import](classOf[Import])
+ implicit val TemplateTag = ClassTag[Template](classOf[Template])
+ implicit val BlockTag = ClassTag[Block](classOf[Block])
+ implicit val CaseDefTag = ClassTag[CaseDef](classOf[CaseDef])
+ implicit val AlternativeTag = ClassTag[Alternative](classOf[Alternative])
+ implicit val StarTag = ClassTag[Star](classOf[Star])
+ implicit val BindTag = ClassTag[Bind](classOf[Bind])
+ implicit val UnApplyTag = ClassTag[UnApply](classOf[UnApply])
+ implicit val ArrayValueTag = ClassTag[ArrayValue](classOf[ArrayValue])
+ implicit val FunctionTag = ClassTag[Function](classOf[Function])
+ implicit val AssignTag = ClassTag[Assign](classOf[Assign])
+ implicit val AssignOrNamedArgTag = ClassTag[AssignOrNamedArg](classOf[AssignOrNamedArg])
+ implicit val IfTag = ClassTag[If](classOf[If])
+ implicit val MatchTag = ClassTag[Match](classOf[Match])
+ implicit val ReturnTag = ClassTag[Return](classOf[Return])
+ implicit val TryTag = ClassTag[Try](classOf[Try])
+ implicit val ThrowTag = ClassTag[Throw](classOf[Throw])
+ implicit val NewTag = ClassTag[New](classOf[New])
+ implicit val TypedTag = ClassTag[Typed](classOf[Typed])
+ implicit val GenericApplyTag = ClassTag[GenericApply](classOf[GenericApply])
+ implicit val TypeApplyTag = ClassTag[TypeApply](classOf[TypeApply])
+ implicit val ApplyTag = ClassTag[Apply](classOf[Apply])
+ implicit val ApplyDynamicTag = ClassTag[ApplyDynamic](classOf[ApplyDynamic])
+ implicit val SuperTag = ClassTag[Super](classOf[Super])
+ implicit val ThisTag = ClassTag[This](classOf[This])
+ implicit val SelectTag = ClassTag[Select](classOf[Select])
+ implicit val IdentTag = ClassTag[Ident](classOf[Ident])
+ implicit val ReferenceToBoxedTag = ClassTag[ReferenceToBoxed](classOf[ReferenceToBoxed])
+ implicit val LiteralTag = ClassTag[Literal](classOf[Literal])
+ implicit val AnnotatedTag = ClassTag[Annotated](classOf[Annotated])
+ implicit val SingletonTypeTreeTag = ClassTag[SingletonTypeTree](classOf[SingletonTypeTree])
+ implicit val SelectFromTypeTreeTag = ClassTag[SelectFromTypeTree](classOf[SelectFromTypeTree])
+ implicit val CompoundTypeTreeTag = ClassTag[CompoundTypeTree](classOf[CompoundTypeTree])
+ implicit val AppliedTypeTreeTag = ClassTag[AppliedTypeTree](classOf[AppliedTypeTree])
+ implicit val TypeBoundsTreeTag = ClassTag[TypeBoundsTree](classOf[TypeBoundsTree])
+ implicit val ExistentialTypeTreeTag = ClassTag[ExistentialTypeTree](classOf[ExistentialTypeTree])
+ implicit val TypeTreeTag = ClassTag[TypeTree](classOf[TypeTree])
+}
diff --git a/src/compiler/scala/reflect/internal/TypeDebugging.scala b/src/reflect/scala/reflect/internal/TypeDebugging.scala
index 85a1767067..33f6a645e8 100644
--- a/src/compiler/scala/reflect/internal/TypeDebugging.scala
+++ b/src/reflect/scala/reflect/internal/TypeDebugging.scala
@@ -24,7 +24,7 @@ trait TypeDebugging {
def ptBlock(label: String, pairs: (String, Any)*): String = {
if (pairs.isEmpty) label + "{ }"
else {
- val width = pairs map (_._1.length) max
+ val width = (pairs map (_._1.length)).max
val fmt = "%-" + (width + 1) + "s %s"
val strs = pairs map { case (k, v) => fmt.format(k, to_s(v)) }
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 93f359ae12..8a4394bf1d 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -14,6 +14,7 @@ import Flags._
import scala.util.control.ControlThrowable
import scala.annotation.tailrec
import util.Statistics._
+import language.postfixOps
/* A standard type pattern match:
case ErrorType =>
@@ -260,7 +261,7 @@ trait Types extends api.Types { self: SymbolTable =>
}
}
- abstract class AbsTypeImpl extends AbsType { this: Type =>
+ abstract class TypeApiImpl extends TypeApi { this: Type =>
def declaration(name: Name): Symbol = decl(name)
def nonPrivateDeclaration(name: Name): Symbol = nonPrivateDecl(name)
def declarations = decls
@@ -268,7 +269,7 @@ trait Types extends api.Types { self: SymbolTable =>
def erasure = this match {
case ConstantType(value) => widen.erasure // [Eugene to Martin] constant types are unaffected by erasure. weird.
case _ =>
- var result = transformedType(this)
+ var result: Type = transformedType(this)
result = result.normalize match { // necessary to deal with erasures of HK types, typeConstructor won't work
case PolyType(undets, underlying) => existentialAbstraction(undets, underlying) // we don't want undets in the result
case _ => result
@@ -282,6 +283,7 @@ trait Types extends api.Types { self: SymbolTable =>
})
result
}
+ def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type = substSym(from, to)
def substituteTypes(from: List[Symbol], to: List[Type]): Type = subst(from, to)
// [Eugene] to be discussed and refactored
@@ -315,7 +317,7 @@ trait Types extends api.Types { self: SymbolTable =>
}
/** The base class for all types */
- abstract class Type extends AbsTypeImpl with Annotatable[Type] {
+ abstract class Type extends TypeApiImpl with Annotatable[Type] {
/** Types for which asSeenFrom always is the identity, no matter what
* prefix or owner.
*/
@@ -749,12 +751,18 @@ trait Types extends api.Types { self: SymbolTable =>
def substThis(from: Symbol, to: Symbol): Type =
substThis(from, to.thisType)
- /** Performs both substThis and substSym in one traversal.
+ /** Performs both substThis and substSym, in that order.
+ *
+ * [JZ] Reverted `SubstThisAndSymMap` from 334872, which was not the same as
+ * `substThis(from, to).substSym(symsFrom, symsTo)`.
+ *
+ * `SubstThisAndSymMap` performs a breadth-first map over this type, which meant that
+ * symbol substitution occured before `ThisType` substitution. Consequently, in substitution
+ * of a `SingleType(ThisType(`from`), sym), symbols were rebound to `from` rather than `to`.
*/
- def substThisAndSym(from: Symbol, to: Type, symsFrom: List[Symbol], symsTo: List[Symbol]): Type = {
+ def substThisAndSym(from: Symbol, to: Type, symsFrom: List[Symbol], symsTo: List[Symbol]): Type =
if (symsFrom eq symsTo) substThis(from, to)
- else new SubstThisAndSymMap(from, to, symsFrom, symsTo) apply this
- }
+ else substThis(from, to).substSym(symsFrom, symsTo)
/** Returns all parts of this type which satisfy predicate `p` */
def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p) collect this
@@ -892,8 +900,8 @@ trait Types extends api.Types { self: SymbolTable =>
*/
def baseTypeSeq: BaseTypeSeq = baseTypeSingletonSeq(this)
- /** The maximum depth (@see maxDepth)
- * of each type in the BaseTypeSeq of this type.
+ /** The maximum depth (@see typeDepth)
+ * of each type in the BaseTypeSeq of this type except the first.
*/
def baseTypeSeqDepth: Int = 1
@@ -1237,7 +1245,7 @@ trait Types extends api.Types { self: SymbolTable =>
* type is created: a MethodType with parameters typed as
* BoundedWildcardTypes.
*/
- case class BoundedWildcardType(override val bounds: TypeBounds) extends Type {
+ case class BoundedWildcardType(override val bounds: TypeBounds) extends Type with BoundedWildcardTypeApi {
override def isWildcard = true
override def safeToString: String = "?" + bounds
override def kind = "BoundedWildcardType"
@@ -1265,7 +1273,7 @@ trait Types extends api.Types { self: SymbolTable =>
/** A class for this-types of the form <sym>.this.type
*/
- abstract case class ThisType(sym: Symbol) extends SingletonType {
+ abstract case class ThisType(sym: Symbol) extends SingletonType with ThisTypeApi {
assert(sym.isClass)
//assert(sym.isClass && !sym.isModuleClass || sym.isRoot, sym)
override def isTrivial: Boolean = sym.isPackageClass
@@ -1300,7 +1308,7 @@ trait Types extends api.Types { self: SymbolTable =>
/** A class for singleton types of the form `<prefix>.<sym.name>.type`.
* Cannot be created directly; one should always use `singleType` for creation.
*/
- abstract case class SingleType(pre: Type, sym: Symbol) extends SingletonType {
+ abstract case class SingleType(pre: Type, sym: Symbol) extends SingletonType with SingleTypeApi {
override val isTrivial: Boolean = pre.isTrivial
override def isGround = sym.isPackageClass || pre.isGround
@@ -1360,13 +1368,13 @@ trait Types extends api.Types { self: SymbolTable =>
tpe.underlyingPeriod = currentPeriod
if (!isValid(period)) {
// [Eugene to Paul] needs review
- tpe.underlyingCache = if (tpe.sym == NoSymbol) ThisType(RootClass) else tpe.pre.memberType(tpe.sym).resultType;
+ tpe.underlyingCache = if (tpe.sym == NoSymbol) ThisType(rootMirror.RootClass) else tpe.pre.memberType(tpe.sym).resultType;
assert(tpe.underlyingCache ne tpe, tpe)
}
}
}
- abstract case class SuperType(thistpe: Type, supertpe: Type) extends SingletonType {
+ abstract case class SuperType(thistpe: Type, supertpe: Type) extends SingletonType with SuperTypeApi {
override val isTrivial: Boolean = thistpe.isTrivial && supertpe.isTrivial
override def isNotNull = true;
override def typeSymbol = thistpe.typeSymbol
@@ -1388,7 +1396,7 @@ trait Types extends api.Types { self: SymbolTable =>
/** A class for the bounds of abstract types and type parameters
*/
- abstract case class TypeBounds(lo: Type, hi: Type) extends SubType {
+ abstract case class TypeBounds(lo: Type, hi: Type) extends SubType with TypeBoundsApi {
def supertype = hi
override val isTrivial: Boolean = lo.isTrivial && hi.isTrivial
override def bounds: TypeBounds = this
@@ -1594,7 +1602,7 @@ trait Types extends api.Types { self: SymbolTable =>
* one should always use `refinedType` for creation.
*/
case class RefinedType(override val parents: List[Type],
- override val decls: Scope) extends CompoundType {
+ override val decls: Scope) extends CompoundType with RefinedTypeApi {
override def isHigherKinded = (
parents.nonEmpty &&
@@ -1689,7 +1697,7 @@ trait Types extends api.Types { self: SymbolTable =>
case class ClassInfoType(
override val parents: List[Type],
override val decls: Scope,
- override val typeSymbol: Symbol) extends CompoundType
+ override val typeSymbol: Symbol) extends CompoundType with ClassInfoTypeApi
{
validateClassInfo(this)
@@ -1868,7 +1876,7 @@ trait Types extends api.Types { self: SymbolTable =>
*
* @param value ...
*/
- abstract case class ConstantType(value: Constant) extends SingletonType {
+ abstract case class ConstantType(value: Constant) extends SingletonType with ConstantTypeApi {
override def underlying: Type = value.tpe
assert(underlying.typeSymbol != UnitClass)
override def isTrivial: Boolean = true
@@ -1973,7 +1981,7 @@ trait Types extends api.Types { self: SymbolTable =>
require(sym.isPackageClass, sym)
override protected def finishPrefix(rest: String) = packagePrefix + rest
}
- class RefinementTypeRef(sym0: Symbol) extends NoArgsTypeRef(NoType, sym0) with ClassTypeRef {
+ class RefinementTypeRef(pre0: Type, sym0: Symbol) extends NoArgsTypeRef(pre0, sym0) with ClassTypeRef {
require(sym.isRefinementClass, sym)
// I think this is okay, but see #1241 (r12414), #2208, and typedTypeConstructor in Typers
@@ -2177,7 +2185,7 @@ trait Types extends api.Types { self: SymbolTable =>
*
* @M: a higher-kinded type is represented as a TypeRef with sym.typeParams.nonEmpty, but args.isEmpty
*/
- abstract case class TypeRef(pre: Type, sym: Symbol, args: List[Type]) extends Type {
+ abstract case class TypeRef(pre: Type, sym: Symbol, args: List[Type]) extends Type with TypeRefApi {
private[reflect] var parentsCache: List[Type] = _
private[reflect] var parentsPeriod = NoPeriod
private[reflect] var baseTypeSeqCache: BaseTypeSeq = _
@@ -2359,7 +2367,7 @@ trait Types extends api.Types { self: SymbolTable =>
else {
if (sym.isAliasType) new NoArgsTypeRef(pre, sym) with AliasTypeRef
else if (sym.isAbstractType) new NoArgsTypeRef(pre, sym) with AbstractTypeRef
- else if (sym.isRefinementClass) new RefinementTypeRef(sym)
+ else if (sym.isRefinementClass) new RefinementTypeRef(pre, sym)
else if (sym.isPackageClass) new PackageTypeRef(pre, sym)
else if (sym.isModuleClass) new ModuleTypeRef(pre, sym)
else new NoArgsTypeRef(pre, sym) with ClassTypeRef
@@ -2400,7 +2408,7 @@ trait Types extends api.Types { self: SymbolTable =>
* def m: Int NullaryMethodType(Int)
*/
case class MethodType(override val params: List[Symbol],
- override val resultType: Type) extends Type {
+ override val resultType: Type) extends Type with MethodTypeApi {
override def isTrivial: Boolean = isTrivial0 && (resultType eq resultType.withoutAnnotations)
private lazy val isTrivial0 =
resultType.isTrivial && params.forall{p => p.tpe.isTrivial && (
@@ -2456,7 +2464,7 @@ trait Types extends api.Types { self: SymbolTable =>
override def isJava = true
}
- case class NullaryMethodType(override val resultType: Type) extends Type {
+ case class NullaryMethodType(override val resultType: Type) extends Type with NullaryMethodTypeApi {
override def isTrivial = resultType.isTrivial && (resultType eq resultType.withoutAnnotations)
override def prefix: Type = resultType.prefix
override def narrow: Type = resultType.narrow
@@ -2490,7 +2498,7 @@ trait Types extends api.Types { self: SymbolTable =>
* A polytype is of kind * iff its resultType is a (nullary) method type.
*/
case class PolyType(override val typeParams: List[Symbol], override val resultType: Type)
- extends Type {
+ extends Type with PolyTypeApi {
//assert(!(typeParams contains NoSymbol), this)
assert(typeParams nonEmpty, this) // used to be a marker for nullary method type, illegal now (see @NullaryMethodType)
@@ -2550,7 +2558,7 @@ trait Types extends api.Types { self: SymbolTable =>
}
case class ExistentialType(quantified: List[Symbol],
- override val underlying: Type) extends RewrappingTypeProxy
+ override val underlying: Type) extends RewrappingTypeProxy with ExistentialTypeApi
{
override protected def rewrap(newtp: Type) = existentialAbstraction(quantified, newtp)
@@ -3019,7 +3027,7 @@ trait Types extends api.Types { self: SymbolTable =>
// this is a higher-kinded type var with same arity as tp.
// side effect: adds the type constructor itself as a bound
addBound(tp.typeConstructor)
- isSubArgs(lhs, rhs, params)
+ isSubArgs(lhs, rhs, params, AnyDepth)
}
}
}
@@ -3171,7 +3179,7 @@ trait Types extends api.Types { self: SymbolTable =>
case class AnnotatedType(override val annotations: List[AnnotationInfo],
override val underlying: Type,
override val selfsym: Symbol)
- extends RewrappingTypeProxy {
+ extends RewrappingTypeProxy with AnnotatedTypeApi {
assert(!annotations.isEmpty, "" + underlying)
@@ -3244,7 +3252,7 @@ trait Types extends api.Types { self: SymbolTable =>
if (annots.isEmpty) underlying
else AnnotatedType(annots, underlying, selfsym)
- object AnnotatedType extends AnnotatedTypeExtractor { }
+ object AnnotatedType extends AnnotatedTypeExtractor
/** A class representing types with a name. When an application uses
* named arguments, the named argument types for calling isApplicable
@@ -3325,7 +3333,7 @@ trait Types extends api.Types { self: SymbolTable =>
if (phase.erasedTypes)
sym.tpe.resultType
else if (sym.isRootPackage)
- ThisType(RootClass)
+ ThisType(sym.moduleClass)
else {
var sym1 = rebind(pre, sym)
val pre1 = removeSuper(pre, sym1)
@@ -4318,7 +4326,7 @@ trait Types extends api.Types { self: SymbolTable =>
def throwError = abort("" + tp + sym.locationString + " cannot be instantiated from " + pre.widen)
val symclazz = sym.owner
- if (symclazz == clazz && !pre.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) {
+ if (symclazz == clazz && !pre.widen.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) {
// have to deconst because it may be a Class[T].
pre.baseType(symclazz).deconst match {
case TypeRef(_, basesym, baseargs) =>
@@ -4518,13 +4526,6 @@ trait Types extends api.Types { self: SymbolTable =>
case _ => mapOver(tp)
}
}
- class SubstThisAndSymMap(fromThis: Symbol, toThis: Type, fromSyms: List[Symbol], toSyms: List[Symbol])
- extends SubstSymMap(fromSyms, toSyms) {
- override def apply(tp: Type): Type = tp match {
- case ThisType(sym) if sym == fromThis => apply(toThis)
- case _ => super.apply(tp)
- }
- }
class SubstWildcardMap(from: List[Symbol]) extends TypeMap {
def apply(tp: Type): Type = try {
@@ -4948,18 +4949,54 @@ trait Types extends api.Types { self: SymbolTable =>
// Helper Methods -------------------------------------------------------------
- final val LubGlbMargin = 0
-
/** The maximum allowable depth of lubs or glbs over types `ts`.
- * This is the maximum depth of all types in the base type sequences
- * of each of the types `ts`, plus LubGlbMargin.
*/
- def lubDepth(ts: List[Type]) = {
+ def lubDepth(ts: List[Type]): Int = {
+ val td = typeDepth(ts)
+ val bd = baseTypeSeqDepth(ts)
+ lubDepthAdjust(td, td max bd)
+ }
+
+ /** The maximum allowable depth of lubs or glbs over given types,
+ * as a function over the maximum depth `td` of these types, and
+ * the maximum depth `bd` of all types in the base type sequences of these types.
+ */
+ private def lubDepthAdjust(td: Int, bd: Int): Int =
+ if (settings.XfullLubs.value) bd
+ else if (bd <= 3) bd
+ else if (bd <= 5) td max (bd - 1)
+ else if (bd <= 7) td max (bd - 2)
+ else (td - 1) max (bd - 3)
+
+ /** The maximum depth of type `tp` */
+ def typeDepth(tp: Type): Int = tp match {
+ case TypeRef(pre, sym, args) =>
+ typeDepth(pre) max typeDepth(args) + 1
+ case RefinedType(parents, decls) =>
+ typeDepth(parents) max typeDepth(decls.toList.map(_.info)) + 1
+ case TypeBounds(lo, hi) =>
+ typeDepth(lo) max typeDepth(hi)
+ case MethodType(paramtypes, result) =>
+ typeDepth(result)
+ case NullaryMethodType(result) =>
+ typeDepth(result)
+ case PolyType(tparams, result) =>
+ typeDepth(result) max typeDepth(tparams map (_.info)) + 1
+ case ExistentialType(tparams, result) =>
+ typeDepth(result) max typeDepth(tparams map (_.info)) + 1
+ case _ =>
+ 1
+ }
+
+ private def maxDepth(tps: Seq[Type], by: Type => Int): Int = {
var d = 0
- for (tp <- ts) d = math.max(d, tp.baseTypeSeqDepth)
- d + LubGlbMargin
+ for (tp <- tps) d = d max by(tp)
+ d
}
+ private def typeDepth(tps: Seq[Type]): Int = maxDepth(tps, typeDepth)
+ private def baseTypeSeqDepth(tps: Seq[Type]): Int = maxDepth(tps, _.baseTypeSeqDepth)
+
/** Is intersection of given types populated? That is,
* for all types tp1, tp2 in intersection
* for all common base classes bc of tp1 and tp2
@@ -5054,6 +5091,13 @@ trait Types extends api.Types { self: SymbolTable =>
pre1 =:= pre2
}
+ private def isSubPre(pre1: Type, pre2: Type, sym: Symbol) =
+ if ((pre1 ne pre2) && (pre1 ne NoPrefix) && (pre2 ne NoPrefix) && pre1 <:< pre2) {
+ if (settings.debug.value) println(s"new isSubPre $sym: $pre1 <:< $pre2")
+ true
+ } else
+ false
+
private def equalSymsAndPrefixes(sym1: Symbol, pre1: Type, sym2: Symbol, pre2: Type): Boolean =
if (sym1 == sym2) sym1.hasPackageFlag || phase.erasedTypes || pre1 =:= pre2
else (sym1.name == sym2.name) && isUnifiable(pre1, pre2)
@@ -5216,9 +5260,9 @@ trait Types extends api.Types { self: SymbolTable =>
true
else if ((tp1 eq NoType) || (tp2 eq NoType))
false
- else if (tp1 eq NoPrefix)
+ else if (tp1 eq NoPrefix) // !! I do not see how this would be warranted by the spec
tp2.typeSymbol.isPackageClass
- else if (tp2 eq NoPrefix)
+ else if (tp2 eq NoPrefix) // !! I do not see how this would be warranted by the spec
tp1.typeSymbol.isPackageClass
else {
isSameType2(tp1, tp2) || {
@@ -5510,11 +5554,12 @@ trait Types extends api.Types { self: SymbolTable =>
// --> thus, cannot be subtypes (Any/Nothing has already been checked)
}))
- def isSubArg(t1: Type, t2: Type, variance: Int) =
- (variance > 0 || t2 <:< t1) && (variance < 0 || t1 <:< t2)
-
- def isSubArgs(tps1: List[Type], tps2: List[Type], tparams: List[Symbol]): Boolean =
+ def isSubArgs(tps1: List[Type], tps2: List[Type], tparams: List[Symbol], depth: Int): Boolean = {
+ def isSubArg(t1: Type, t2: Type, variance: Int) =
+ (variance > 0 || isSubType(t2, t1, depth)) &&
+ (variance < 0 || isSubType(t1, t2, depth))
corresponds3(tps1, tps2, tparams map (_.variance))(isSubArg)
+ }
def differentOrNone(tp1: Type, tp2: Type) = if (tp1 eq tp2) NoType else tp1
@@ -5522,7 +5567,7 @@ trait Types extends api.Types { self: SymbolTable =>
private def isSubType2(tp1: Type, tp2: Type, depth: Int): Boolean = {
if ((tp1 eq tp2) || isErrorOrWildcard(tp1) || isErrorOrWildcard(tp2)) return true
if ((tp1 eq NoType) || (tp2 eq NoType)) return false
- if (tp1 eq NoPrefix) return (tp2 eq NoPrefix) || tp2.typeSymbol.isPackageClass
+ if (tp1 eq NoPrefix) return (tp2 eq NoPrefix) || tp2.typeSymbol.isPackageClass // !! I do not see how the "isPackageClass" would be warranted by the spec
if (tp2 eq NoPrefix) return tp1.typeSymbol.isPackageClass
if (isSingleType(tp1) && isSingleType(tp2) || isConstantType(tp1) && isConstantType(tp2)) return tp1 =:= tp2
if (tp1.isHigherKinded || tp2.isHigherKinded) return isHKSubType0(tp1, tp2, depth)
@@ -5541,14 +5586,16 @@ trait Types extends api.Types { self: SymbolTable =>
val sym2 = tr2.sym
val pre1 = tr1.pre
val pre2 = tr2.pre
- (((if (sym1 == sym2) phase.erasedTypes || pre1 <:< pre2
+ (((if (sym1 == sym2) phase.erasedTypes || isSubType(pre1, pre2, depth)
else (sym1.name == sym2.name && !sym1.isModuleClass && !sym2.isModuleClass &&
- (isUnifiable(pre1, pre2) || isSameSpecializedSkolem(sym1, sym2, pre1, pre2)))) &&
- isSubArgs(tr1.args, tr2.args, sym1.typeParams))
+ (isUnifiable(pre1, pre2) ||
+ isSameSpecializedSkolem(sym1, sym2, pre1, pre2) ||
+ sym2.isAbstractType && isSubPre(pre1, pre2, sym2)))) &&
+ isSubArgs(tr1.args, tr2.args, sym1.typeParams, depth))
||
sym2.isClass && {
val base = tr1 baseType sym2
- (base ne tr1) && base <:< tr2
+ (base ne tr1) && isSubType(base, tr2, depth)
}
||
thirdTryRef(tr1, tr2))
@@ -5556,9 +5603,10 @@ trait Types extends api.Types { self: SymbolTable =>
secondTry
}
case AnnotatedType(_, _, _) =>
- tp1.withoutAnnotations <:< tp2.withoutAnnotations && annotationsConform(tp1, tp2)
+ isSubType(tp1.withoutAnnotations, tp2.withoutAnnotations, depth) &&
+ annotationsConform(tp1, tp2)
case BoundedWildcardType(bounds) =>
- tp1 <:< bounds.hi
+ isSubType(tp1, bounds.hi, depth)
case tv2 @ TypeVar(_, constr2) =>
tp1 match {
case AnnotatedType(_, _, _) | BoundedWildcardType(_) =>
@@ -5577,15 +5625,16 @@ trait Types extends api.Types { self: SymbolTable =>
*/
def secondTry = tp1 match {
case AnnotatedType(_, _, _) =>
- tp1.withoutAnnotations <:< tp2.withoutAnnotations && annotationsConform(tp1, tp2)
+ isSubType(tp1.withoutAnnotations, tp2.withoutAnnotations, depth) &&
+ annotationsConform(tp1, tp2)
case BoundedWildcardType(bounds) =>
- tp1.bounds.lo <:< tp2
+ isSubType(tp1.bounds.lo, tp2, depth)
case tv @ TypeVar(_,_) =>
tv.registerBound(tp2, false)
case ExistentialType(_, _) =>
try {
skolemizationLevel += 1
- tp1.skolemizeExistential <:< tp2
+ isSubType(tp1.skolemizeExistential, tp2, depth)
} finally {
skolemizationLevel -= 1
}
@@ -5608,7 +5657,9 @@ trait Types extends api.Types { self: SymbolTable =>
case _: TypeSymbol =>
if (sym2 hasFlag DEFERRED) {
val tp2a = tp2.bounds.lo
- isDifferentTypeConstructor(tp2, tp2a) && tp1 <:< tp2a || fourthTry
+ isDifferentTypeConstructor(tp2, tp2a) &&
+ isSubType(tp1, tp2a, depth) ||
+ fourthTry
} else {
isSubType(tp1.normalize, tp2.normalize, depth)
}
@@ -5626,12 +5677,12 @@ trait Types extends api.Types { self: SymbolTable =>
case tr2: TypeRef =>
thirdTryRef(tp1, tr2)
case rt2: RefinedType =>
- (rt2.parents forall (tp1 <:< _)) &&
- (rt2.decls forall tp1.specializes)
+ (rt2.parents forall (isSubType(tp1, _, depth))) &&
+ (rt2.decls forall (specializesSym(tp1, _, depth)))
case et2: ExistentialType =>
- et2.withTypeVars(tp1 <:< _, depth) || fourthTry
+ et2.withTypeVars(isSubType(tp1, _, depth), depth) || fourthTry
case nn2: NotNullType =>
- tp1.isNotNull && tp1 <:< nn2.underlying
+ tp1.isNotNull && isSubType(tp1, nn2.underlying, depth)
case mt2: MethodType =>
tp1 match {
case mt1 @ MethodType(params1, res1) =>
@@ -5640,7 +5691,7 @@ trait Types extends api.Types { self: SymbolTable =>
(sameLength(params1, params2) &&
mt1.isImplicit == mt2.isImplicit &&
matchingParams(params1, params2, mt1.isJava, mt2.isJava) &&
- (res1 <:< res2.substSym(params2, params1)))
+ isSubType(res1, res2.substSym(params2, params1), depth))
// TODO: if mt1.params.isEmpty, consider NullaryMethodType?
case _ =>
false
@@ -5649,14 +5700,14 @@ trait Types extends api.Types { self: SymbolTable =>
tp1 match {
// TODO: consider MethodType mt for which mt.params.isEmpty??
case pt1 @ NullaryMethodType(_) =>
- pt1.resultType <:< pt2.resultType
+ isSubType(pt1.resultType, pt2.resultType, depth)
case _ =>
false
}
case TypeBounds(lo2, hi2) =>
tp1 match {
case TypeBounds(lo1, hi1) =>
- lo2 <:< lo1 && hi1 <:< hi2
+ isSubType(lo2, lo1, depth) && isSubType(hi1, hi2, depth)
case _ =>
false
}
@@ -5676,7 +5727,7 @@ trait Types extends api.Types { self: SymbolTable =>
case TypeRef(_, sym2, _) =>
containsNull(sym2)
case _ =>
- isSingleType(tp2) && tp1 <:< tp2.widen
+ isSingleType(tp2) && isSubType(tp1, tp2.widen, depth)
}
case _: ClassSymbol =>
if (isRaw(sym1, tr1.args))
@@ -5692,7 +5743,7 @@ trait Types extends api.Types { self: SymbolTable =>
case _: TypeSymbol =>
if (sym1 hasFlag DEFERRED) {
val tp1a = tp1.bounds.hi
- isDifferentTypeConstructor(tp1, tp1a) && tp1a <:< tp2
+ isDifferentTypeConstructor(tp1, tp1a) && isSubType(tp1a, tp2, depth)
} else {
isSubType(tp1.normalize, tp2.normalize, depth)
}
@@ -5700,9 +5751,9 @@ trait Types extends api.Types { self: SymbolTable =>
false
}
case RefinedType(parents1, _) =>
- parents1 exists (_ <:< tp2)
+ parents1 exists (isSubType(_, tp2, depth))
case _: SingletonType | _: NotNullType =>
- tp1.underlying <:< tp2
+ isSubType(tp1.underlying, tp2, depth)
case _ =>
false
}
@@ -5725,19 +5776,22 @@ trait Types extends api.Types { self: SymbolTable =>
* refinement type, otherwise we might return false negatives.
*/
def specializesSym(tp: Type, sym: Symbol): Boolean =
+ specializesSym(tp, sym, AnyDepth)
+
+ def specializesSym(tp: Type, sym: Symbol, depth: Int): Boolean =
tp.typeSymbol == NothingClass ||
tp.typeSymbol == NullClass && containsNull(sym.owner) ||
(tp.nonPrivateMember(sym.name).alternatives exists
- (alt => sym == alt || specializesSym(tp.narrow, alt, sym.owner.thisType, sym)))
+ (alt => sym == alt || specializesSym(tp.narrow, alt, sym.owner.thisType, sym, depth)))
/** Does member `sym1` of `tp1` have a stronger type
* than member `sym2` of `tp2`?
*/
- private def specializesSym(tp1: Type, sym1: Symbol, tp2: Type, sym2: Symbol): Boolean = {
+ private def specializesSym(tp1: Type, sym1: Symbol, tp2: Type, sym2: Symbol, depth: Int): Boolean = {
val info1 = tp1.memberInfo(sym1)
val info2 = tp2.memberInfo(sym2).substThis(tp2.typeSymbol, tp1)
//System.out.println("specializes "+tp1+"."+sym1+":"+info1+sym1.locationString+" AND "+tp2+"."+sym2+":"+info2)//DEBUG
- ( sym2.isTerm && (info1 <:< info2) && (!sym2.isStable || sym1.isStable)
+ ( sym2.isTerm && isSubType(info1, info2, depth) && (!sym2.isStable || sym1.isStable)
|| sym2.isAbstractType && {
val memberTp1 = tp1.memberType(sym1)
// println("kinds conform? "+(memberTp1, tp1, sym2, kindsConform(List(sym2), List(memberTp1), tp2, sym2.owner)))
@@ -5985,7 +6039,7 @@ trait Types extends api.Types { self: SymbolTable =>
// Lubs and Glbs ---------------------------------------------------------
private def printLubMatrix(btsMap: Map[Type, List[Type]], depth: Int) {
- import scala.tools.nsc.util.TableDef
+ import util.TableDef
import TableDef.Column
def str(tp: Type) = {
if (tp == NoType) ""
@@ -6254,11 +6308,14 @@ trait Types extends api.Types { self: SymbolTable =>
case List() => NothingClass.tpe
case List(t) => t
case _ =>
+ incCounter(lubCount)
+ val start = startTimer(lubNanos)
try {
- lub(ts, lubDepth(ts))
+ lub(ts, lubDepth(ts))
} finally {
lubResults.clear()
glbResults.clear()
+ stopTimer(lubNanos, start)
}
}
@@ -6333,14 +6390,14 @@ trait Types extends api.Types { self: SymbolTable =>
!syms.isEmpty && (syms forall (alt =>
// todo alt != sym is strictly speaking not correct, but without it we lose
// efficiency.
- alt != sym && !specializesSym(lubThisType, sym, tp, alt)))
+ alt != sym && !specializesSym(lubThisType, sym, tp, alt, depth)))
}
// add a refinement symbol for all non-class members of lubBase
// which are refined by every type in ts.
for (sym <- lubBase.nonPrivateMembers ; if !excludeFromLub(sym)) {
try {
val lsym = lubsym(sym)
- if (lsym != NoSymbol) addMember(lubThisType, lubRefined, lsym)
+ if (lsym != NoSymbol) addMember(lubThisType, lubRefined, lsym, depth)
} catch {
case ex: NoCommonType =>
}
@@ -6352,7 +6409,7 @@ trait Types extends api.Types { self: SymbolTable =>
// In theory this should not be necessary, but higher-order type
// parameters are not handled correctly.
val ok = ts forall { t =>
- (t <:< lubRefined) || {
+ isSubType(t, lubRefined, depth) || {
if (settings.debug.value || printLubs) {
Console.println(
"Malformed lub: " + lubRefined + "\n" +
@@ -6374,6 +6431,7 @@ trait Types extends api.Types { self: SymbolTable =>
indent = indent + " "
assert(indent.length <= 100)
}
+ incCounter(nestedLubCount)
val res = lub0(ts)
if (printLubs) {
indent = indent stripSuffix " "
@@ -6398,12 +6456,15 @@ trait Types extends api.Types { self: SymbolTable =>
case List() => AnyClass.tpe
case List(t) => t
case ts0 =>
+ incCounter(lubCount)
+ val start = startTimer(lubNanos)
try {
glbNorm(ts0, lubDepth(ts0))
} finally {
lubResults.clear()
glbResults.clear()
- }
+ stopTimer(lubNanos, start)
+ }
}
private def glb(ts: List[Type], depth: Int): Type = elimSuper(ts) match {
@@ -6497,9 +6558,9 @@ trait Types extends api.Types { self: SymbolTable =>
globalGlbDepth += 1
val dss = ts flatMap refinedToDecls
for (ds <- dss; sym <- ds.iterator)
- if (globalGlbDepth < globalGlbLimit && !(glbThisType specializes sym))
+ if (globalGlbDepth < globalGlbLimit && !specializesSym(glbThisType, sym, depth))
try {
- addMember(glbThisType, glbRefined, glbsym(sym))
+ addMember(glbThisType, glbRefined, glbsym(sym), depth)
} catch {
case ex: NoCommonType =>
}
@@ -6517,6 +6578,7 @@ trait Types extends api.Types { self: SymbolTable =>
}
// if (settings.debug.value) { println(indent + "glb of " + ts + " at depth "+depth); indent = indent + " " } //DEBUG
+ incCounter(nestedLubCount)
val res = glb0(ts)
// if (settings.debug.value) { indent = indent.substring(0, indent.length() - 2); log(indent + "glb of " + ts + " is " + res) }//DEBUG
@@ -6572,47 +6634,50 @@ trait Types extends api.Types { self: SymbolTable =>
else Some(typeRef(pre, sym, List(lub(args))))
}
}
- else {
- val args = map2(sym.typeParams, argss.transpose) { (tparam, as) =>
- if (depth == 0) {
- if (tparam.variance == variance) {
- // Take the intersection of the upper bounds of the type parameters
- // rather than falling all the way back to "Any", otherwise we end up not
- // conforming to bounds.
- val bounds0 = sym.typeParams map (_.info.bounds.hi) filterNot (_.typeSymbol == AnyClass)
- if (bounds0.isEmpty) AnyClass.tpe
- else intersectionType(bounds0 map (b => b.asSeenFrom(tps.head, sym)))
+ else transposeSafe(argss) match {
+ case None =>
+ // transpose freaked out because of irregular argss
+ // catching just in case (shouldn't happen, but also doesn't cost us)
+ // [JZ] It happens: see SI-5683.
+ debuglog("transposed irregular matrix!?" +(tps, argss))
+ None
+ case Some(argsst) =>
+ val args = map2(sym.typeParams, argsst) { (tparam, as) =>
+ if (depth == 0) {
+ if (tparam.variance == variance) {
+ // Take the intersection of the upper bounds of the type parameters
+ // rather than falling all the way back to "Any", otherwise we end up not
+ // conforming to bounds.
+ val bounds0 = sym.typeParams map (_.info.bounds.hi) filterNot (_.typeSymbol == AnyClass)
+ if (bounds0.isEmpty) AnyClass.tpe
+ else intersectionType(bounds0 map (b => b.asSeenFrom(tps.head, sym)))
+ }
+ else if (tparam.variance == -variance) NothingClass.tpe
+ else NoType
}
- else if (tparam.variance == -variance) NothingClass.tpe
- else NoType
- }
- else {
- if (tparam.variance == variance) lub(as, decr(depth))
- else if (tparam.variance == -variance) glb(as, decr(depth))
else {
- val l = lub(as, decr(depth))
- val g = glb(as, decr(depth))
- if (l <:< g) l
+ if (tparam.variance == variance) lub(as, decr(depth))
+ else if (tparam.variance == -variance) glb(as, decr(depth))
+ else {
+ val l = lub(as, decr(depth))
+ val g = glb(as, decr(depth))
+ if (l <:< g) l
else { // Martin: I removed this, because incomplete. Not sure there is a good way to fix it. For the moment we
// just err on the conservative side, i.e. with a bound that is too high.
// if(!(tparam.info.bounds contains tparam)) //@M can't deal with f-bounds, see #2251
- val qvar = commonOwner(as) freshExistential "" setInfo TypeBounds(g, l)
- capturedParams += qvar
- qvar.tpe
+ val qvar = commonOwner(as) freshExistential "" setInfo TypeBounds(g, l)
+ capturedParams += qvar
+ qvar.tpe
+ }
}
}
}
- }
- if (args contains NoType) None
- else Some(existentialAbstraction(capturedParams.toList, typeRef(pre, sym, args)))
+ if (args contains NoType) None
+ else Some(existentialAbstraction(capturedParams.toList, typeRef(pre, sym, args)))
}
} catch {
case ex: MalformedType => None
- case ex: IndexOutOfBoundsException => // transpose freaked out because of irregular argss
- // catching just in case (shouldn't happen, but also doesn't cost us)
- debuglog("transposed irregular matrix!?"+ (tps, argss))
- None
}
case SingleType(_, sym) :: rest =>
val pres = tps map (_.prefix)
@@ -6628,16 +6693,18 @@ trait Types extends api.Types { self: SymbolTable =>
assert(false, tps); None
}
+ def addMember(thistp: Type, tp: Type, sym: Symbol): Unit = addMember(thistp, tp, sym, AnyDepth)
+
/** Make symbol `sym` a member of scope `tp.decls`
* where `thistp` is the narrowed owner type of the scope.
*/
- def addMember(thistp: Type, tp: Type, sym: Symbol) {
+ def addMember(thistp: Type, tp: Type, sym: Symbol, depth: Int) {
assert(sym != NoSymbol)
// debuglog("add member " + sym+":"+sym.info+" to "+thistp) //DEBUG
- if (!(thistp specializes sym)) {
+ if (!specializesSym(thistp, sym, depth)) {
if (sym.isTerm)
for (alt <- tp.nonPrivateDecl(sym.name).alternatives)
- if (specializesSym(thistp, sym, thistp, alt))
+ if (specializesSym(thistp, sym, thistp, alt, depth))
tp.decls unlink alt;
tp.decls enter sym
}
@@ -6787,4 +6854,21 @@ trait Types extends api.Types { self: SymbolTable =>
tostringRecursions -= 1
}
+ implicit val AnnotatedTypeTag = ClassTag[AnnotatedType](classOf[AnnotatedType])
+ implicit val BoundedWildcardTypeTag = ClassTag[BoundedWildcardType](classOf[BoundedWildcardType])
+ implicit val ClassInfoTypeTag = ClassTag[ClassInfoType](classOf[ClassInfoType])
+ implicit val CompoundTypeTag = ClassTag[CompoundType](classOf[CompoundType])
+ implicit val ConstantTypeTag = ClassTag[ConstantType](classOf[ConstantType])
+ implicit val ExistentialTypeTag = ClassTag[ExistentialType](classOf[ExistentialType])
+ implicit val MethodTypeTag = ClassTag[MethodType](classOf[MethodType])
+ implicit val NullaryMethodTypeTag = ClassTag[NullaryMethodType](classOf[NullaryMethodType])
+ implicit val PolyTypeTag = ClassTag[PolyType](classOf[PolyType])
+ implicit val RefinedTypeTag = ClassTag[RefinedType](classOf[RefinedType])
+ implicit val SingletonTypeTag = ClassTag[SingletonType](classOf[SingletonType])
+ implicit val SingleTypeTag = ClassTag[SingleType](classOf[SingleType])
+ implicit val SuperTypeTag = ClassTag[SuperType](classOf[SuperType])
+ implicit val ThisTypeTag = ClassTag[ThisType](classOf[ThisType])
+ implicit val TypeBoundsTag = ClassTag[TypeBounds](classOf[TypeBounds])
+ implicit val TypeRefTag = ClassTag[TypeRef](classOf[TypeRef])
+ implicit val TypeTagg = ClassTag[Type](classOf[Type])
}
diff --git a/src/reflect/scala/reflect/internal/package.scala b/src/reflect/scala/reflect/internal/package.scala
new file mode 100644
index 0000000000..99b837152d
--- /dev/null
+++ b/src/reflect/scala/reflect/internal/package.scala
@@ -0,0 +1,6 @@
+package scala.reflect
+
+package object internal {
+
+ type MirrorOf[U <: base.Universe with Singleton] = base.MirrorOf[U]
+}
diff --git a/src/compiler/scala/reflect/internal/pickling/ByteCodecs.scala b/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala
index 4670bd4eef..4670bd4eef 100644
--- a/src/compiler/scala/reflect/internal/pickling/ByteCodecs.scala
+++ b/src/reflect/scala/reflect/internal/pickling/ByteCodecs.scala
diff --git a/src/compiler/scala/reflect/internal/pickling/PickleBuffer.scala b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala
index 7f0895ce64..7f0895ce64 100644
--- a/src/compiler/scala/reflect/internal/pickling/PickleBuffer.scala
+++ b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala
diff --git a/src/compiler/scala/reflect/internal/pickling/PickleFormat.scala b/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala
index 16747af08a..16747af08a 100644
--- a/src/compiler/scala/reflect/internal/pickling/PickleFormat.scala
+++ b/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala
diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index fd3fac1b37..757163a074 100644
--- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -53,6 +53,8 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
checkVersion()
+ private val loadingMirror = mirrorThatLoaded(classRoot)
+
/** A map from entry numbers to array offsets */
private val index = createIndex
@@ -195,13 +197,13 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
def readExtSymbol(): Symbol = {
val name = readNameRef()
- val owner = if (atEnd) definitions.RootClass else readSymbolRef()
+ val owner = if (atEnd) loadingMirror.RootClass else readSymbolRef()
def adjust(sym: Symbol) = if (tag == EXTref) sym else sym.moduleClass
def fromName(name: Name) = name.toTermName match {
- case nme.ROOT => definitions.RootClass
- case nme.ROOTPKG => definitions.RootPackage
+ case nme.ROOT => loadingMirror.RootClass
+ case nme.ROOTPKG => loadingMirror.RootPackage
case _ => adjust(owner.info.decl(name))
}
def nestedObjectSymbol: Symbol = {
@@ -356,7 +358,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
case POLYtpe =>
val restpe = readTypeRef()
val typeParams = until(end, readSymbolRef)
- if(typeParams nonEmpty) {
+ if (typeParams.nonEmpty) {
// NMT_TRANSITION: old class files denoted a polymorphic nullary method as PolyType(tps, restpe), we now require PolyType(tps, NullaryMethodType(restpe))
// when a type of kind * is expected (forceProperType is true), we know restpe should be wrapped in a NullaryMethodType (if it wasn't suitably wrapped yet)
def transitionNMT(restpe: Type) = {
@@ -447,7 +449,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
private def readArrayAnnot() = {
readByte() // skip the `annotargarray` tag
val end = readNat() + readIndex
- until(end, () => readClassfileAnnotArg(readNat())).toArray(classfileAnnotArgTag)
+ until(end, () => readClassfileAnnotArg(readNat())).toArray(ClassfileAnnotArgTag)
}
protected def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match {
case ANNOTINFO => NestedAnnotArg(at(i, readAnnotation))
@@ -816,9 +818,8 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg)
protected def errorMissingRequirement(name: Name, owner: Symbol): Symbol =
- missingHook(owner, name) orElse MissingRequirementError.notFound(
- "bad reference while unpickling %s: %s not found in %s".format(
- filename, name.longString, owner.tpe.widen)
+ missingHook(owner, name) orElse MissingRequirementError.signal(
+ s"bad reference while unpickling $filename: ${name.longString} not found in ${owner.tpe.widen}"
)
def inferMethodAlternative(fun: Tree, argtpes: List[Type], restpe: Type) {} // can't do it; need a compiler for that.
diff --git a/src/compiler/scala/reflect/internal/settings/AbsSettings.scala b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala
index 9bbba3f079..9bbba3f079 100644
--- a/src/compiler/scala/reflect/internal/settings/AbsSettings.scala
+++ b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala
diff --git a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala
index 45ba4ed3e6..e9899f690d 100644
--- a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala
+++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala
@@ -44,4 +44,6 @@ abstract class MutableSettings extends AbsSettings {
def maxClassfileName: IntSetting
def Xexperimental: BooleanSetting
def XoldPatmat: BooleanSetting
+ def XnoPatmatAnalysis: BooleanSetting
+ def XfullLubs: BooleanSetting
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala
index 5beec70d62..5beec70d62 100644
--- a/src/compiler/scala/reflect/internal/transform/Erasure.scala
+++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala
diff --git a/src/compiler/scala/reflect/internal/transform/RefChecks.scala b/src/reflect/scala/reflect/internal/transform/RefChecks.scala
index d6108ab665..d6108ab665 100644
--- a/src/compiler/scala/reflect/internal/transform/RefChecks.scala
+++ b/src/reflect/scala/reflect/internal/transform/RefChecks.scala
diff --git a/src/compiler/scala/reflect/internal/transform/Transforms.scala b/src/reflect/scala/reflect/internal/transform/Transforms.scala
index a7cc99ba3b..c4c5dc3a1c 100644
--- a/src/compiler/scala/reflect/internal/transform/Transforms.scala
+++ b/src/reflect/scala/reflect/internal/transform/Transforms.scala
@@ -2,6 +2,8 @@ package scala.reflect
package internal
package transform
+import language.existentials
+
trait Transforms { self: SymbolTable =>
/** We need to encode laziness by hand here because the three components refChecks, uncurry and erasure
diff --git a/src/compiler/scala/reflect/internal/transform/UnCurry.scala b/src/reflect/scala/reflect/internal/transform/UnCurry.scala
index 0c1640ceb9..0c1640ceb9 100644
--- a/src/compiler/scala/reflect/internal/transform/UnCurry.scala
+++ b/src/reflect/scala/reflect/internal/transform/UnCurry.scala
diff --git a/src/compiler/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala
index 2e119f8ccc..1f8eb15c90 100644
--- a/src/compiler/scala/reflect/internal/util/Collections.scala
+++ b/src/reflect/scala/reflect/internal/util/Collections.scala
@@ -201,6 +201,12 @@ trait Collections {
}
true
}
+
+ final def transposeSafe[A](ass: List[List[A]]): Option[List[List[A]]] = try {
+ Some(ass.transpose)
+ } catch {
+ case _: IllegalArgumentException => None
+ }
}
object Collections extends Collections { }
diff --git a/src/compiler/scala/reflect/internal/util/HashSet.scala b/src/reflect/scala/reflect/internal/util/HashSet.scala
index a771dad2b0..a771dad2b0 100644
--- a/src/compiler/scala/reflect/internal/util/HashSet.scala
+++ b/src/reflect/scala/reflect/internal/util/HashSet.scala
diff --git a/src/compiler/scala/reflect/internal/util/Origins.scala b/src/reflect/scala/reflect/internal/util/Origins.scala
index 0bd5ad55ca..0bd5ad55ca 100644
--- a/src/compiler/scala/reflect/internal/util/Origins.scala
+++ b/src/reflect/scala/reflect/internal/util/Origins.scala
diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala
index 208cd5703a..3c251b3b31 100644
--- a/src/compiler/scala/tools/nsc/util/Position.scala
+++ b/src/reflect/scala/reflect/internal/util/Position.scala
@@ -4,8 +4,11 @@
*
*/
-package scala.tools.nsc
-package util
+package scala.reflect.internal.util
+
+import reflect.ClassTag
+import reflect.base.Attachments
+import reflect.api.PositionApi
object Position {
val tabInc = 8
@@ -33,22 +36,13 @@ object Position {
}
}
-trait Position extends scala.reflect.api.Position with scala.reflect.api.Attachment {
- /** Exposes itself as payload of Attachment */
- // necessary for conformance with Attachment
- def pos: Position = this
+abstract class Position extends PositionApi { self =>
- /** A bit weird method that is necessary to safely update positions without destroying custom attachments */
- // necessary for conformance with Attachment
- def withPos(newPos: scala.reflect.api.Position): scala.reflect.api.Attachment = newPos
+ type Pos = Position
- /** Exposes itself as payload of Attachment */
- // necessary for conformance with Attachment
- def payload: Position = this
+ def pos: Position = this
- /** A bit weird method that is necessary to safely update positions without destroying custom attachments */
- // necessary for conformance with Attachment
- def withPayload(newPos: Any): scala.reflect.api.Attachment = newPos.asInstanceOf[Position]
+ def withPos(newPos: Position): Attachments { type Pos = self.Pos } = newPos
/** Java file corresponding to the source file of this position.
*/
@@ -118,7 +112,7 @@ trait Position extends scala.reflect.api.Position with scala.reflect.api.Attachm
/** If this is a range, the union with the other range, with the point of this position.
* Otherwise, this position
*/
- def union(pos: scala.reflect.api.Position): Position = this
+ def union(pos: Position): Position = this
/** If this is a range position, the offset position of its start.
* Otherwise the position itself
@@ -139,39 +133,39 @@ trait Position extends scala.reflect.api.Position with scala.reflect.api.Attachm
* This holds if `this` is a range position and its range [start..end]
* is the same or covers the range of the given position, which may or may not be a range position.
*/
- def includes(pos: scala.reflect.api.Position): Boolean = false
+ def includes(pos: Position): Boolean = false
/** Does this position properly include the given position `pos` ("properly" meaning their
* ranges are not the same)?
*/
- def properlyIncludes(pos: scala.reflect.api.Position): Boolean =
+ def properlyIncludes(pos: Position): Boolean =
includes(pos) && (start < pos.startOrPoint || pos.endOrPoint < end)
/** Does this position precede that position?
* This holds if both positions are defined and the end point of this position
* is not larger than the start point of the given position.
*/
- def precedes(pos: scala.reflect.api.Position): Boolean =
+ def precedes(pos: Position): Boolean =
isDefined && pos.isDefined && endOrPoint <= pos.startOrPoint
/** Does this position properly precede the given position `pos` ("properly" meaning their ranges
* do not share a common point).
*/
- def properlyPrecedes(pos: scala.reflect.api.Position): Boolean =
+ def properlyPrecedes(pos: Position): Boolean =
isDefined && pos.isDefined && endOrPoint < pos.startOrPoint
/** Does this position overlap with that position?
* This holds if both positions are ranges and there is an interval of
* non-zero length that is shared by both position ranges.
*/
- def overlaps(pos: scala.reflect.api.Position): Boolean =
+ def overlaps(pos: Position): Boolean =
isRange && pos.isRange &&
((pos.start < end && start < pos.end) || (start < pos.end && pos.start < end))
/** Does this position cover the same range as that position?
* Holds only if both position are ranges
*/
- def sameRange(pos: scala.reflect.api.Position): Boolean =
+ def sameRange(pos: Position): Boolean =
isRange && pos.isRange && start == pos.start && end == pos.end
def line: Int = throw new UnsupportedOperationException("Position.line")
@@ -224,10 +218,7 @@ class OffsetPosition(override val source: SourceFile, override val point: Int) e
col + 1
}
- override def union(pos: scala.reflect.api.Position) =
- // [Eugene] how do I get rid of this cast?
- // I could introduce a "type PositionType <: scala.reflect.api.Position", but that's also ugly
- if (pos.isRange) pos.asInstanceOf[Position] else this
+ override def union(pos: Position) = if (pos.isRange) pos else this
override def equals(that : Any) = that match {
case that : OffsetPosition => point == that.point && source.file == that.source.file
@@ -261,8 +252,8 @@ extends OffsetPosition(source, point) {
}
override def focusEnd = new OffsetPosition(source, end)
override def makeTransparent = new TransparentPosition(source, start, point, end)
- override def includes(pos: scala.reflect.api.Position) = pos.isDefined && start <= pos.startOrPoint && pos.endOrPoint <= end
- override def union(pos: scala.reflect.api.Position): Position =
+ override def includes(pos: Position) = pos.isDefined && start <= pos.startOrPoint && pos.endOrPoint <= end
+ override def union(pos: Position): Position =
if (pos.isRange) new RangePosition(source, start min pos.start, point, end max pos.end) else this
override def toSingleLine: Position = source match {
diff --git a/src/compiler/scala/reflect/internal/util/Set.scala b/src/reflect/scala/reflect/internal/util/Set.scala
index cfc3e7eada..cfc3e7eada 100644
--- a/src/compiler/scala/reflect/internal/util/Set.scala
+++ b/src/reflect/scala/reflect/internal/util/Set.scala
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/reflect/scala/reflect/internal/util/SourceFile.scala
index e1ae96da8c..7c80ddd37d 100644
--- a/src/compiler/scala/tools/nsc/util/SourceFile.scala
+++ b/src/reflect/scala/reflect/internal/util/SourceFile.scala
@@ -4,10 +4,9 @@
*/
-package scala.tools.nsc
-package util
+package scala.reflect.internal.util
-import io.{ AbstractFile, VirtualFile }
+import scala.tools.nsc.io.{ AbstractFile, VirtualFile }
import scala.collection.mutable.ArrayBuffer
import annotation.tailrec
import java.util.regex.Pattern
diff --git a/src/compiler/scala/reflect/internal/util/StatBase.scala b/src/reflect/scala/reflect/internal/util/StatBase.scala
index b033ff98bc..b033ff98bc 100644
--- a/src/compiler/scala/reflect/internal/util/StatBase.scala
+++ b/src/reflect/scala/reflect/internal/util/StatBase.scala
diff --git a/src/compiler/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala
index ef17327fda..de0830aa3a 100644
--- a/src/compiler/scala/reflect/internal/util/Statistics.scala
+++ b/src/reflect/scala/reflect/internal/util/Statistics.scala
@@ -28,6 +28,9 @@ class Statistics extends StatBase {
val baseTypeSeqLenTotal = new Counter
val typeSymbolCount = new Counter
val classSymbolCount = new Counter
+ val lubCount = new Counter
+ val nestedLubCount = new Counter
+ val lubNanos = new Timer
}
object Statistics extends Statistics
diff --git a/src/compiler/scala/tools/util/StringOps.scala b/src/reflect/scala/reflect/internal/util/StringOps.scala
index 725e0afb79..281ade8134 100644
--- a/src/compiler/scala/tools/util/StringOps.scala
+++ b/src/reflect/scala/reflect/internal/util/StringOps.scala
@@ -7,8 +7,7 @@
\* */
-package scala.tools
-package util
+package scala.reflect.internal.util
/** This object provides utility methods to extract elements
* from Strings.
diff --git a/src/compiler/scala/tools/nsc/util/TableDef.scala b/src/reflect/scala/reflect/internal/util/TableDef.scala
index 10c63eeee2..d692a6d8f5 100644
--- a/src/compiler/scala/tools/nsc/util/TableDef.scala
+++ b/src/reflect/scala/reflect/internal/util/TableDef.scala
@@ -1,5 +1,4 @@
-package scala.tools.nsc
-package util
+package scala.reflect.internal.util
import TableDef._
diff --git a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
index 1424226042..5fbeb5f576 100644
--- a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala
+++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala
@@ -2,12 +2,13 @@ package scala.reflect.internal
package util
import scala.collection.{ mutable, immutable }
+import language.postfixOps
trait TraceSymbolActivity {
val global: SymbolTable
import global._
- if (traceSymbolActivity && !global.inReflexiveMirror)
+ if (traceSymbolActivity && global.isCompilerUniverse)
scala.sys addShutdownHook showAllSymbols()
private type Set[T] = scala.collection.immutable.Set[T]
diff --git a/src/compiler/scala/tools/nsc/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala
index 5bbb766e21..9882aad5e5 100644
--- a/src/compiler/scala/tools/nsc/util/WeakHashSet.scala
+++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala
@@ -1,4 +1,4 @@
-package scala.tools.nsc.util
+package scala.reflect.internal.util
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
diff --git a/src/reflect/scala/reflect/makro/Aliases.scala b/src/reflect/scala/reflect/makro/Aliases.scala
new file mode 100644
index 0000000000..4bd246572f
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Aliases.scala
@@ -0,0 +1,26 @@
+package scala.reflect
+package makro
+
+trait Aliases {
+ self: Context =>
+
+ type Symbol = universe.Symbol
+ type Type = universe.Type
+ type Name = universe.Name
+ type TermName = universe.TermName
+ type TypeName = universe.TypeName
+ type Tree = universe.Tree
+ // type Position = universe.Position
+ type Scope = universe.Scope
+ type Modifiers = universe.Modifiers
+
+ type Expr[+T] = universe.Expr[T]
+ val Expr = universe.Expr
+
+ type AbsTypeTag[T] = universe.AbsTypeTag[T]
+ type TypeTag[T] = universe.TypeTag[T]
+ val AbsTypeTag = universe.AbsTypeTag
+ val TypeTag = universe.TypeTag
+ def typeTag[T](implicit ttag: TypeTag[T]) = ttag
+ def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
+}
diff --git a/src/library/scala/reflect/makro/CapturedVariables.scala b/src/reflect/scala/reflect/makro/CapturedVariables.scala
index 6ce832b2b3..592e28b3b2 100644
--- a/src/library/scala/reflect/makro/CapturedVariables.scala
+++ b/src/reflect/scala/reflect/makro/CapturedVariables.scala
@@ -1,4 +1,5 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait CapturedVariables {
self: Context =>
diff --git a/src/reflect/scala/reflect/makro/Context.scala b/src/reflect/scala/reflect/makro/Context.scala
new file mode 100644
index 0000000000..f9858a063c
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Context.scala
@@ -0,0 +1,40 @@
+package scala.reflect
+package makro
+
+import language.experimental.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.makro (and probably reside in scala-compiler.jar)
+
+trait Context extends Aliases
+ with CapturedVariables
+ with Enclosures
+ with Infrastructure
+ with Names
+ with Reifiers
+ with FrontEnds
+ with Settings
+ with Typers
+ with Parsers
+ with Exprs
+ with TypeTags
+ with Evals
+ with ExprUtils {
+
+ /** The compile-time universe */
+ val universe: Universe
+
+ /** The mirror of the compile-time universe */
+ val mirror: MirrorOf[universe.type]
+
+ /** The type of the prefix tree from which the macro is selected */
+ type PrefixType
+
+ /** The prefix tree from which the macro is selected */
+ val prefix: Expr[PrefixType]
+
+ /** Alias to the underlying mirror's reify */
+ // implementation is magically hardwired to `scala.reflect.makro.runtime.ContextReifiers`
+ def reify[T](expr: T): Expr[T] = macro ???
+}
diff --git a/src/library/scala/reflect/makro/Enclosures.scala b/src/reflect/scala/reflect/makro/Enclosures.scala
index 136d39498e..69bd8d09c7 100644
--- a/src/library/scala/reflect/makro/Enclosures.scala
+++ b/src/reflect/scala/reflect/makro/Enclosures.scala
@@ -1,4 +1,5 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Enclosures {
self: Context =>
diff --git a/src/reflect/scala/reflect/makro/Evals.scala b/src/reflect/scala/reflect/makro/Evals.scala
new file mode 100644
index 0000000000..4e5fc2f97f
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Evals.scala
@@ -0,0 +1,9 @@
+package scala.reflect
+package makro
+
+trait Evals {
+ self: Context =>
+
+ /** .. */
+ def eval[T](expr: Expr[T]): T
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/makro/Util.scala b/src/reflect/scala/reflect/makro/ExprUtils.scala
index 16eb2395a9..c3e5cc6bc1 100644
--- a/src/library/scala/reflect/makro/Util.scala
+++ b/src/reflect/scala/reflect/makro/ExprUtils.scala
@@ -1,6 +1,7 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
-trait Util {
+trait ExprUtils {
self: Context =>
def literalNull: Expr[Null]
diff --git a/src/reflect/scala/reflect/makro/Exprs.scala b/src/reflect/scala/reflect/makro/Exprs.scala
new file mode 100644
index 0000000000..91d3dafbf2
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Exprs.scala
@@ -0,0 +1,8 @@
+package scala.reflect
+package makro
+
+trait Exprs {
+ self: Context =>
+
+ def Expr[T: AbsTypeTag](tree: Tree): Expr[T]
+}
diff --git a/src/library/scala/reflect/makro/FrontEnds.scala b/src/reflect/scala/reflect/makro/FrontEnds.scala
index a1e24dcea3..5087f90174 100644
--- a/src/library/scala/reflect/makro/FrontEnds.scala
+++ b/src/reflect/scala/reflect/makro/FrontEnds.scala
@@ -1,10 +1,13 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
-trait FrontEnds {
+trait FrontEnds extends scala.reflect.api.FrontEnds {
self: Context =>
import mirror._
+ type Position = universe.Position
+
/** Exposes means to control the compiler UI */
def frontEnd: FrontEnd
def setFrontEnd(frontEnd: FrontEnd): this.type
diff --git a/src/library/scala/reflect/makro/Infrastructure.scala b/src/reflect/scala/reflect/makro/Infrastructure.scala
index 2bf49dca77..e6bfe33366 100644
--- a/src/library/scala/reflect/makro/Infrastructure.scala
+++ b/src/reflect/scala/reflect/makro/Infrastructure.scala
@@ -1,4 +1,5 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Infrastructure {
self: Context =>
@@ -23,6 +24,35 @@ trait Infrastructure {
*/
val currentRun: Run
+ /** Exposes library classpath.
+ */
+ val libraryClassPath: List[java.net.URL]
+
+ /** Exposes a classloader that corresponds to the library classpath.
+ *
+ * With this classloader you can perform on-the-fly evaluation of macro arguments.
+ * For example, consider this code snippet:
+ *
+ * def staticEval[T](x: T) = macro staticEval[T]
+ *
+ * def staticEval[T: c.TypeTag](c: Context)(x: c.Expr[T]) = {
+ * import scala.reflect.runtime.{universe => ru}
+ * val mirror = ru.runtimeMirror(c.libraryClassLoader)
+ * import scala.tools.reflect.ToolBox
+ * val toolBox = mirror.mkToolBox()
+ * val importer = ru.mkImporter(c.universe).asInstanceOf[ru.Importer { val from: c.universe.type }]
+ * val tree = c.resetAllAttrs(x.tree.duplicate)
+ * val imported = importer.importTree(tree)
+ * val valueOfX = toolBox.runExpr(imported).asInstanceOf[T]
+ * ...
+ * }
+ *
+ * // [Eugene++] using this guy will tremendously slow down the compilation
+ * // https://twitter.com/xeno_by/status/201248317831774208
+ * // todo. we need to address this somehow
+ */
+ def libraryClassLoader: ClassLoader
+
/** As seen by macro API, compilation run is an opaque type that can be deconstructed into:
* 1) Current compilation unit
* 2) List of all compilation units that comprise the run
diff --git a/src/library/scala/reflect/makro/Names.scala b/src/reflect/scala/reflect/makro/Names.scala
index 8a823d19cb..909976d83c 100644
--- a/src/library/scala/reflect/makro/Names.scala
+++ b/src/reflect/scala/reflect/makro/Names.scala
@@ -1,4 +1,5 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Names {
self: Context =>
@@ -10,5 +11,5 @@ trait Names {
def fresh(name: String): String
/** Creates a fresh name from the provided name */
- def fresh(name: Name): Name
+ def fresh[NameType <: Name](name: NameType): NameType
}
diff --git a/src/reflect/scala/reflect/makro/Parsers.scala b/src/reflect/scala/reflect/makro/Parsers.scala
new file mode 100644
index 0000000000..9866b7e491
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Parsers.scala
@@ -0,0 +1,18 @@
+package scala.reflect
+package makro
+
+trait Parsers {
+ self: Context =>
+
+ /** .. */
+ // todo. distinguish between `parseExpr` and `parse`
+ def parse(code: String): Tree
+
+ /** Represents an error during parsing
+ */
+ type ParseError <: Throwable
+ val ParseError: ParseErrorExtractor
+ abstract class ParseErrorExtractor {
+ def unapply(error: ParseError): Option[(Position, String)]
+ }
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/makro/Reifiers.scala b/src/reflect/scala/reflect/makro/Reifiers.scala
index b1de8d9957..f39f56f935 100644
--- a/src/library/scala/reflect/makro/Reifiers.scala
+++ b/src/reflect/scala/reflect/makro/Reifiers.scala
@@ -1,17 +1,26 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Reifiers {
self: Context =>
- /** Reification prefix that refers to the standard reflexive mirror, ``scala.reflect.mirror''.
+ /** Reification prefix that refers to the base reflexive universe, ``scala.reflect.basis''.
* Providing it for the ``prefix'' parameter of ``reifyTree'' or ``reifyType'' will create a tree that can be inspected at runtime.
*/
- val reflectMirrorPrefix: Tree
+ val basisUniverse: Tree
+
+ /** Reification prefix that refers to the runtime reflexive universe, ``scala.reflect.runtime.universe''.
+ * Providing it for the ``prefix'' parameter of ``reifyTree'' or ``reifyType'' will create a full-fledged tree that can be inspected at runtime.
+ */
+ val runtimeUniverse: Tree
/** Given a tree, generate a tree that when compiled and executed produces the original tree.
- * The produced tree will be bound to the mirror specified by ``prefix'' (also see ``reflectMirrorPrefix'').
* For more information and examples see the documentation for ``Universe.reify''.
*
+ * The produced tree will be bound to the specified ``universe'' and ``mirror''.
+ * Possible values for ``universe'' include ``basisUniverse'' and ``runtimeUniverse''.
+ * Possible values for ``mirror'' include ``EmptyTree'' (in that case the reifier will automatically pick an appropriate mirror).
+ *
* This function is deeply connected to ``Universe.reify'', a macro that reifies arbitrary expressions into runtime trees.
* They do very similar things (``Universe.reify'' calls ``Context.reifyTree'' to implement itself), but they operate on different metalevels (see below).
*
@@ -40,18 +49,23 @@ trait Reifiers {
* Typical usage of this function is to retain some of the trees received/created by a macro
* into the form that can be inspected (via pattern matching) or compiled/run (by a reflective ToolBox) during the runtime.
*/
- def reifyTree(prefix: Tree, tree: Tree): Tree
+ def reifyTree(universe: Tree, mirror: Tree, tree: Tree): Tree
/** Given a type, generate a tree that when compiled and executed produces the original type.
- * The produced tree will be bound to the mirror specified by ``prefix'' (also see ``reflectMirrorPrefix'').
+ * The produced tree will be bound to the specified ``universe'' and ``mirror''.
* For more information and examples see the documentation for ``Context.reifyTree'' and ``Universe.reify''.
*/
- def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Tree
+ def reifyType(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean = false): Tree
+
+ /** Given a type, generate a tree that when compiled and executed produces the runtime class of the original type.
+ * If ``concrete'' is true, then this function will bail on types, who refer to abstract types (like `ClassTag` does).
+ */
+ def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree
- /** Given a type, generate a tree that when compiled and executed produces the erasure of the original type.
- * If ``concrete'' is true, then this function will bail on types, whose erasure includes abstract types (like `ClassTag` does).
+ /** Given a type, generate a tree that when compiled and executed produces the runtime class of the enclosing class or module.
+ * Returns `EmptyTree` if there does not exist an enclosing class or module.
*/
- def reifyErasure(tpe: Type, concrete: Boolean = true): Tree
+ def reifyEnclosingRuntimeClass: Tree
/** Undoes reification of a tree.
*
@@ -72,6 +86,6 @@ trait Reifiers {
// made these guys non path-dependent, otherwise exception handling quickly becomes a mess
-case class ReificationError(var pos: reflect.api.Position, val msg: String) extends Throwable(msg)
+case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
-case class UnexpectedReificationError(val pos: reflect.api.Position, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause) \ No newline at end of file
+case class UnexpectedReificationError(val pos: reflect.api.PositionApi, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause)
diff --git a/src/library/scala/reflect/makro/Settings.scala b/src/reflect/scala/reflect/makro/Settings.scala
index c4a8ebd1b5..c6c7e5870b 100644
--- a/src/library/scala/reflect/makro/Settings.scala
+++ b/src/reflect/scala/reflect/makro/Settings.scala
@@ -1,4 +1,5 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Settings {
self: Context =>
@@ -18,6 +19,7 @@ trait Settings {
/** Updates current compiler settings with an option string.
* Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options.
+ * todo. http://groups.google.com/group/scala-internals/browse_thread/thread/07c18cff41f59203
*/
def setCompilerSettings(options: String): this.type
diff --git a/src/reflect/scala/reflect/makro/TreeBuilder.scala b/src/reflect/scala/reflect/makro/TreeBuilder.scala
new file mode 100644
index 0000000000..c4179b9c80
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/TreeBuilder.scala
@@ -0,0 +1,60 @@
+package scala.reflect
+package makro
+
+// [Eugene] I added some stuff that was necessary for typetag materialization macros
+// but we should think it over and pick other generally useful stuff
+// same goes for tree traversers/transformers, type maps, etc
+// and once we expose all that, there's another question: how do we stay in sync?
+abstract class TreeBuilder {
+ val global: Universe
+
+ import global._
+ import definitions._
+
+ /** Builds a reference to value whose type is given stable prefix.
+ * The type must be suitable for this. For example, it
+ * must not be a TypeRef pointing to an abstract type variable.
+ */
+ def mkAttributedQualifier(tpe: Type): Tree
+
+ /** Builds a reference to value whose type is given stable prefix.
+ * If the type is unsuitable, e.g. it is a TypeRef for an
+ * abstract type variable, then an Ident will be made using
+ * termSym as the Ident's symbol. In that case, termSym must
+ * not be NoSymbol.
+ */
+ def mkAttributedQualifier(tpe: Type, termSym: Symbol): Tree
+
+ /** Builds a typed reference to given symbol with given stable prefix. */
+ def mkAttributedRef(pre: Type, sym: Symbol): Tree
+
+ /** Builds a typed reference to given symbol. */
+ def mkAttributedRef(sym: Symbol): Tree
+
+ /** Builds a typed This reference to given symbol. */
+ def mkAttributedThis(sym: Symbol): Tree
+
+ /** Builds a typed Ident with an underlying symbol. */
+ def mkAttributedIdent(sym: Symbol): Tree
+
+ /** Builds a typed Select with an underlying symbol. */
+ def mkAttributedSelect(qual: Tree, sym: Symbol): Tree
+
+ /** A creator for method calls, e.g. fn[T1, T2, ...](v1, v2, ...)
+ * There are a number of variations.
+ *
+ * @param receiver symbol of the method receiver
+ * @param methodName name of the method to call
+ * @param targs type arguments (if Nil, no TypeApply node will be generated)
+ * @param args value arguments
+ * @return the newly created trees.
+ */
+ def mkMethodCall(receiver: Symbol, methodName: Name, targs: List[Type], args: List[Tree]): Tree
+ def mkMethodCall(method: Symbol, targs: List[Type], args: List[Tree]): Tree
+ def mkMethodCall(method: Symbol, args: List[Tree]): Tree
+ def mkMethodCall(target: Tree, args: List[Tree]): Tree
+ def mkMethodCall(receiver: Symbol, methodName: Name, args: List[Tree]): Tree
+ def mkMethodCall(receiver: Tree, method: Symbol, targs: List[Type], args: List[Tree]): Tree
+ def mkMethodCall(target: Tree, targs: List[Type], args: List[Tree]): Tree
+ def mkNullaryCall(method: Symbol, targs: List[Type]): Tree
+}
diff --git a/src/reflect/scala/reflect/makro/TypeTags.scala b/src/reflect/scala/reflect/makro/TypeTags.scala
new file mode 100644
index 0000000000..53a9b116e3
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/TypeTags.scala
@@ -0,0 +1,9 @@
+package scala.reflect
+package makro
+
+trait TypeTags {
+ self: Context =>
+
+ def AbsTypeTag[T](tpe: Type): AbsTypeTag[T]
+ def TypeTag[T](tpe: Type): TypeTag[T]
+}
diff --git a/src/library/scala/reflect/makro/Typers.scala b/src/reflect/scala/reflect/makro/Typers.scala
index 90024a4f7a..2610d7dd50 100644
--- a/src/library/scala/reflect/makro/Typers.scala
+++ b/src/reflect/scala/reflect/makro/Typers.scala
@@ -1,9 +1,10 @@
-package scala.reflect.makro
+package scala.reflect
+package makro
trait Typers {
self: Context =>
- import mirror._
+ import universe._
/** 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.
diff --git a/src/reflect/scala/reflect/makro/Universe.scala b/src/reflect/scala/reflect/makro/Universe.scala
new file mode 100644
index 0000000000..ffc4042a0a
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/Universe.scala
@@ -0,0 +1,118 @@
+package scala.reflect
+package makro
+
+abstract class Universe extends scala.reflect.api.Universe {
+
+ val treeBuild: TreeBuilder { val global: Universe.this.type }
+
+ // Symbol extensions ---------------------------------------------------------------
+
+ override type Symbol >: Null <: SymbolContextApi
+
+ /** The extended API of symbols that's supported in macro context universes
+ */
+ trait SymbolContextApi extends SymbolApi { this: Symbol =>
+
+ // [Eugene++ to Martin] should we also add mutability methods here (similarly to what's done below for trees)?
+ // I'm talking about `setAnnotations` and friends
+
+ /** Can this symbol be loaded by a reflective mirror?
+ *
+ * Scalac relies on `ScalaSignature' annotation to retain symbols across compilation runs.
+ * Such annotations (also called "pickles") are applied on top-level classes and include information
+ * about all symbols reachable from the annotee. However, local symbols (e.g. classes or definitions local to a block)
+ * are typically unreachable and information about them gets lost.
+ *
+ * This method is useful for macro writers who wish to save certain ASTs to be used at runtime.
+ * With `isLocatable' it's possible to check whether a tree can be retained as is, or it needs special treatment.
+ */
+ def isLocatable: Boolean
+
+ /** Is this symbol static (i.e. with no outer instance)?
+ * Q: When exactly is a sym marked as STATIC?
+ * A: If it's a member of a toplevel object, or of an object contained in a toplevel object, or any number of levels deep.
+ * http://groups.google.com/group/scala-internals/browse_thread/thread/d385bcd60b08faf6
+ */
+ def isStatic: Boolean
+ }
+
+ // Tree extensions ---------------------------------------------------------------
+
+ override type Tree >: Null <: TreeContextApi
+
+ /** The extended API of trees that's supported in macro context universes
+ */
+ trait TreeContextApi extends TreeApi { this: Tree =>
+
+ /** ... */
+ def pos_=(pos: Position): Unit
+
+ /** ... */
+ def setPos(newpos: Position): this.type
+
+ /** ... */
+ def tpe_=(t: Type): Unit
+
+ /** Set tpe to give `tp` and return this.
+ */
+ def setType(tp: Type): this.type
+
+ /** Like `setType`, but if this is a previously empty TypeTree that
+ * fact is remembered so that resetAllAttrs will snap back.
+ *
+ * @PP: Attempting to elaborate on the above, I find: If defineType
+ * is called on a TypeTree whose type field is null or NoType,
+ * this is recorded as "wasEmpty = true". That value is used in
+ * ResetAttrsTraverser, which nulls out the type field of TypeTrees
+ * for which wasEmpty is true, leaving the others alone.
+ *
+ * resetAllAttrs is used in situations where some speculative
+ * typing of a tree takes place, fails, and the tree needs to be
+ * returned to its former state to try again. So according to me:
+ * using `defineType` instead of `setType` is how you communicate
+ * that the type being set does not depend on any previous state,
+ * and therefore should be abandoned if the current line of type
+ * inquiry doesn't work out.
+ */
+ def defineType(tp: Type): this.type
+
+ /** ... */
+ def symbol_=(sym: Symbol): Unit
+
+ /** ... */
+ def setSymbol(sym: Symbol): this.type
+
+ /** ... */
+ def attachments: base.Attachments { type Pos = Position }
+
+ /** ... */
+ def addAttachment(attachment: Any): this.type
+
+ /** ... */
+ def removeAttachment[T: ClassTag]: this.type
+ }
+
+ override type SymTree >: Null <: Tree with SymTreeContextApi
+
+ /** The extended API of sym trees that's supported in macro context universes
+ */
+ trait SymTreeContextApi extends SymTreeApi { this: SymTree =>
+ var symbol: Symbol
+ }
+
+ override type TypeTree >: Null <: TypTree with TypeTreeContextApi
+
+ /** The extended API of sym trees that's supported in macro context universes
+ */
+ trait TypeTreeContextApi extends TypeTreeApi { this: TypeTree =>
+ def setOriginal(tree: Tree): this.type
+ }
+
+ override type Ident >: Null <: RefTree with IdentContextApi
+
+ /** The extended API of idents that's supported in macro context universes
+ */
+ trait IdentContextApi extends IdentApi { this: Ident =>
+ def isBackquoted: Boolean
+ }
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/makro/package.scala b/src/reflect/scala/reflect/makro/package.scala
new file mode 100644
index 0000000000..3c0e51030e
--- /dev/null
+++ b/src/reflect/scala/reflect/makro/package.scala
@@ -0,0 +1,6 @@
+package scala.reflect
+
+package object makro {
+
+ type MirrorOf[U <: base.Universe with Singleton] = base.MirrorOf[U]
+}
diff --git a/src/compiler/scala/reflect/runtime/AbstractFile.scala b/src/reflect/scala/reflect/runtime/AbstractFile.scala
index 414bba020b..0f88af1b0a 100644
--- a/src/compiler/scala/reflect/runtime/AbstractFile.scala
+++ b/src/reflect/scala/reflect/runtime/AbstractFile.scala
@@ -1,7 +1,7 @@
package scala.reflect
package runtime
-class AbstractFile(val jfile: java.io.File) extends api.RequiredFile {
+class AbstractFile(val jfile: java.io.File) extends internal.AbstractFileApi {
def path: String = jfile.getPath()
def canonicalPath: String = jfile.getCanonicalPath()
}
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
new file mode 100644
index 0000000000..38d280ec73
--- /dev/null
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -0,0 +1,1037 @@
+package scala.reflect
+package runtime
+
+import scala.ref.WeakReference
+import scala.collection.mutable.WeakHashMap
+
+import java.lang.{Class => jClass, Package => jPackage}
+import java.lang.reflect.{
+ Method => jMethod, Constructor => jConstructor, Modifier => jModifier, Field => jField,
+ Member => jMember, Type => jType, TypeVariable => jTypeVariable, Array => jArray,
+ GenericDeclaration, GenericArrayType, ParameterizedType, WildcardType, AnnotatedElement }
+import java.io.IOException
+import internal.MissingRequirementError
+import internal.pickling.ByteCodecs
+import internal.ClassfileConstants._
+import internal.pickling.UnPickler
+import collection.mutable.{ HashMap, ListBuffer }
+import internal.Flags._
+//import scala.tools.nsc.util.ScalaClassLoader
+//import scala.tools.nsc.util.ScalaClassLoader._
+import ReflectionUtils.{singletonInstance}
+import language.existentials
+
+trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: SymbolTable =>
+
+ private lazy val mirrors = new WeakHashMap[ClassLoader, WeakReference[JavaMirror]]()
+
+ private def createMirror(owner: Symbol, cl: ClassLoader): Mirror = {
+ val jm = new JavaMirror(owner, cl)
+ mirrors(cl) = new WeakReference(jm)
+ jm.init()
+ jm
+ }
+
+ override type RuntimeClass = java.lang.Class[_]
+
+ override type Mirror = JavaMirror
+
+ override lazy val rootMirror: Mirror = createMirror(NoSymbol, rootClassLoader)
+
+ // overriden by ReflectGlobal
+ def rootClassLoader: ClassLoader = this.getClass.getClassLoader
+
+ def init() = {
+ definitions.AnyValClass // force it.
+
+ // establish root association to avoid cyclic dependency errors later
+ rootMirror.classToScala(classOf[java.lang.Object]).initialize
+
+ // println("initializing definitions")
+ definitions.init()
+ }
+
+ def runtimeMirror(cl: ClassLoader): Mirror = mirrors get cl match {
+ case Some(WeakReference(m)) => m
+ case _ => createMirror(rootMirror.RootClass, cl)
+ }
+
+ /** The API of a mirror for a reflective universe */
+ class JavaMirror(owner: Symbol,
+ /** Class loader that is a mastermind behind the reflexive mirror */
+ val classLoader: ClassLoader
+ ) extends Roots(owner) with super.JavaMirror { wholemirror =>
+
+ val universe: self.type = self
+
+ import definitions._
+
+ /** The lazy type for root.
+ */
+ override lazy val rootLoader = new LazyType {
+ override def complete(sym: Symbol) = sym setInfo new LazyPackageType
+ }
+
+// ----------- Caching ------------------------------------------------------------------
+
+ // [Eugene++ to Martin] not weak? why?
+ private val classCache = new TwoWayCache[jClass[_], ClassSymbol]
+ private val packageCache = new TwoWayCache[Package, ModuleSymbol]
+ private val methodCache = new TwoWayCache[jMethod, MethodSymbol]
+ private val constructorCache = new TwoWayCache[jConstructor[_], MethodSymbol]
+ private val fieldCache = new TwoWayCache[jField, TermSymbol]
+ private val tparamCache = new TwoWayCache[jTypeVariable[_ <: GenericDeclaration], TypeSymbol]
+
+ def toScala[J: HasJavaClass, S](cache: TwoWayCache[J, S], key: J)(body: (JavaMirror, J) => S): S =
+ cache.toScala(key){
+ val jclazz = implicitly[HasJavaClass[J]] getClazz key
+ body(mirrorDefining(jclazz), key)
+ }
+
+ private implicit val classHasJavaClass: HasJavaClass[jClass[_]] =
+ new HasJavaClass(identity)
+ private implicit val methHasJavaClass: HasJavaClass[jMethod]
+ = new HasJavaClass(_.getDeclaringClass)
+ private implicit val fieldHasJavaClass: HasJavaClass[jField] =
+ new HasJavaClass(_.getDeclaringClass)
+ private implicit val constrHasJavaClass: HasJavaClass[jConstructor[_]] =
+ new HasJavaClass(_.getDeclaringClass)
+ private implicit val tparamHasJavaClass: HasJavaClass[jTypeVariable[_ <: GenericDeclaration]] =
+ new HasJavaClass ( (tparam: jTypeVariable[_ <: GenericDeclaration]) => {
+ tparam.getGenericDeclaration match {
+ case jclazz: jClass[_] => jclazz
+ case jmeth: jMethod => jmeth.getDeclaringClass
+ case jconstr: jConstructor[_] => jconstr.getDeclaringClass
+ }
+ })
+
+// ----------- Implementations of mirror operations and classes -------------------
+
+ def reflect(obj: Any): InstanceMirror = new JavaInstanceMirror(obj.asInstanceOf[AnyRef])
+
+ def reflectClass(cls: ClassSymbol): ClassMirror = {
+ if (!cls.isStatic) throw new Error("this is an inner class, use reflectClass on an InstanceMirror to obtain its ClassMirror")
+ new JavaClassMirror(null, cls)
+ }
+
+ def reflectModule(mod: ModuleSymbol): ModuleMirror = {
+ if (!mod.isStatic) throw new Error("this is an inner module, use reflectModule on an InstanceMirror to obtain its ModuleMirror")
+ new JavaModuleMirror(null, mod)
+ }
+
+ def runtimeClass(tpe: Type): RuntimeClass = typeToJavaClass(tpe)
+
+ def runtimeClass(cls: ClassSymbol): RuntimeClass = classToJava(cls)
+
+ def classSymbol(rtcls: RuntimeClass): ClassSymbol = classToScala(rtcls)
+
+ def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol = classToScala(rtcls).companionModule.asModuleSymbol
+
+ private class JavaInstanceMirror(obj: AnyRef)
+ extends InstanceMirror {
+ def instance = obj
+ def symbol = wholemirror.classSymbol(obj.getClass)
+ def reflectField(field: TermSymbol): FieldMirror = {
+ // [Eugene+++] check whether `field` represents a member of a `symbol`
+ if (field.isMethod || field.isModule) throw new Error(s"""
+ |expected a field symbol, you provided a ${field.kind} symbol
+ |A typical cause of this problem is using a field accessor symbol instead of a field symbol.
+ |To obtain a field symbol append nme.LOCAL_SUFFIX_STRING to the name of the field,
+ |when searching for a member with Type.members or Type.declarations.
+ |This is a temporary inconvenience that will be resolved before 2.10.0-final.
+ |More information can be found here: https://issues.scala-lang.org/browse/SI-5895.
+ """.trim.stripMargin)
+ new JavaFieldMirror(obj, field)
+ }
+ def reflectMethod(method: MethodSymbol): MethodMirror = {
+ // [Eugene+++] check whether `method` represents a member of a `symbol`
+ new JavaMethodMirror(obj, method)
+ }
+ def reflectClass(cls: ClassSymbol): ClassMirror = {
+ // [Eugene+++] check whether `cls` represents a member of a `symbol`
+ if (cls.isStatic) throw new Error("this is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror")
+ new JavaClassMirror(instance, cls)
+ }
+ def reflectModule(mod: ModuleSymbol): ModuleMirror = {
+ // [Eugene+++] check whether `mod` represents a member of a `symbol`
+ if (mod.isStatic) throw new Error("this is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror")
+ new JavaModuleMirror(instance, mod)
+ }
+ }
+
+ private class JavaFieldMirror(val receiver: AnyRef, val symbol: TermSymbol)
+ extends FieldMirror {
+ lazy val jfield = {
+ val jfield = fieldToJava(symbol)
+ if (!jfield.isAccessible) jfield.setAccessible(true)
+ jfield
+ }
+ def get = jfield.get(receiver)
+ def set(value: Any) = {
+ if (!symbol.isMutable) throw new Error("cannot set an immutable field")
+ jfield.set(receiver, value)
+ }
+ }
+
+ private class JavaMethodMirror(val receiver: AnyRef, val symbol: MethodSymbol)
+ extends MethodMirror {
+ lazy val jmeth = {
+ val jmeth = methodToJava(symbol)
+ if (!jmeth.isAccessible) jmeth.setAccessible(true)
+ jmeth
+ }
+ def apply(args: Any*): Any =
+ if (symbol.owner == ArrayClass)
+ symbol.name match {
+ case nme.length => jArray.getLength(receiver)
+ case nme.apply => jArray.get(receiver, args(0).asInstanceOf[Int])
+ case nme.update => jArray.set(receiver, args(0).asInstanceOf[Int], args(1))
+ case _ => throw new Error(s"unexpected array method $symbol")
+ }
+ else
+ jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*)
+ }
+
+ private class JavaConstructorMirror(val outer: AnyRef, val symbol: MethodSymbol)
+ extends MethodMirror {
+ override val receiver = outer
+ lazy val jconstr = {
+ val jconstr = constructorToJava(symbol)
+ if (!jconstr.isAccessible) jconstr.setAccessible(true)
+ jconstr
+ }
+ def apply(args: Any*): Any = {
+ val effectiveArgs =
+ if (outer == null) args.asInstanceOf[Seq[AnyRef]]
+ else outer +: args.asInstanceOf[Seq[AnyRef]]
+ jconstr.newInstance(effectiveArgs: _*)
+ }
+ }
+
+
+ private abstract class JavaTemplateMirror
+ extends TemplateMirror {
+ def outer: AnyRef
+ def erasure: ClassSymbol
+ lazy val runtimeClass = classToJava(erasure)
+ lazy val signature = typeToScala(runtimeClass)
+ }
+
+ private class JavaClassMirror(val outer: AnyRef, val symbol: ClassSymbol)
+ extends JavaTemplateMirror with ClassMirror {
+ def erasure = symbol
+ def isStatic = false
+ def reflectConstructor(constructor: MethodSymbol) = new JavaConstructorMirror(outer, constructor)
+ def companion: Option[ModuleMirror] = symbol.companionModule match {
+ case module: ModuleSymbol => Some(new JavaModuleMirror(outer, module))
+ case _ => None
+ }
+ }
+
+ private class JavaModuleMirror(val outer: AnyRef, val symbol: ModuleSymbol)
+ extends JavaTemplateMirror with ModuleMirror {
+ def erasure = symbol.moduleClass.asClassSymbol
+ def isStatic = true
+ def instance = {
+ if (!symbol.owner.isPackageClass) throw new Error("inner and nested modules are not supported yet")
+ singletonInstance(classLoader, symbol.fullName)
+ }
+ def companion: Option[ClassMirror] = symbol.companionClass match {
+ case cls: ClassSymbol => Some(new JavaClassMirror(outer, cls))
+ case _ => None
+ }
+ }
+
+// -------------------- Java to Scala -----------------------------------
+
+ /** Does method `meth` erase to Java method `jmeth`?
+ * This is true if the Java method type is the same as the Scala method type after performing
+ * all Scala-specific transformations in InfoTransformers. (to be done)
+ */
+ private def erasesTo(meth: Symbol, jmeth: jMethod): Boolean = {
+ val mtpe = transformedType(meth)
+ (mtpe.paramTypes map runtimeClass) == jmeth.getParameterTypes.toList &&
+ runtimeClass(mtpe.resultType) == jmeth.getReturnType
+ }
+
+ private def erasesTo(meth: Symbol, jconstr: jConstructor[_]): Boolean = {
+ val mtpe = transformedType(meth)
+ (mtpe.paramTypes map runtimeClass) == jconstr.getParameterTypes.toList &&
+ runtimeClass(mtpe.resultType) == jconstr.getDeclaringClass
+ }
+
+ def javaClass(path: String): jClass[_] =
+ Class.forName(path, true, classLoader)
+
+ /** Does `path` correspond to a Java class with that fully qualified name in the current class loader? */
+ def tryJavaClass(path: String): Option[jClass[_]] =
+ try {
+ Some(javaClass(path))
+ } catch {
+ case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
+ None
+ }
+
+ /** The mirror that corresponds to the classloader that original defined the given Java class */
+ def mirrorDefining(jclazz: jClass[_]): JavaMirror = {
+ val cl = jclazz.getClassLoader
+ if (cl == this.classLoader) this else runtimeMirror(cl)
+ }
+
+ private object unpickler extends UnPickler {
+ val global: self.type = self
+ }
+
+ /** how connected????
+ * Generate types for top-level Scala root class and root companion object
+ * from the pickled information stored in a corresponding Java class
+ * @param clazz The top-level Scala class for which info is unpickled
+ * @param module The top-level Scala companion object for which info is unpickled
+ * @param jclazz The Java class which contains the unpickled information in a
+ * ScalaSignature or ScalaLongSignature annotation.
+ */
+ def unpickleClass(clazz: Symbol, module: Symbol, jclazz: jClass[_]): Unit = {
+ def markAbsent(tpe: Type) = setAllInfos(clazz, module, tpe)
+ def handleError(ex: Exception) = {
+ markAbsent(ErrorType)
+ if (settings.debug.value) ex.printStackTrace()
+ val msg = ex.getMessage()
+ MissingRequirementError.signal(
+ (if (msg eq null) "reflection error while loading " + clazz.name
+ else "error while loading " + clazz.name) + ", " + msg)
+ }
+ // don't use classOf[scala.reflect.ScalaSignature] here, because it will use getClass.getClassLoader, not mirror's classLoader
+ // don't use asInstanceOf either because of the same reason (lol, I cannot believe I fell for it)
+ // don't use structural types to simplify reflective invocations because of the same reason
+ def loadAnnotation(name: String): Option[java.lang.annotation.Annotation] =
+ tryJavaClass(name) flatMap { annotClass =>
+ val anns = jclazz.getAnnotations
+ val result = anns find (_.annotationType == annotClass)
+ if (result.isEmpty && (anns exists (_.annotationType.getName == name)))
+ throw new ClassNotFoundException(
+ s"""Mirror classloader mismatch: $jclazz (loaded by ${ReflectionUtils.show(jclazz.getClassLoader)})
+ |is unrelated to the mirror's classloader: (${ReflectionUtils.show(classLoader)})""".stripMargin)
+ result
+ }
+ def loadBytes[T: ClassTag](name: String): Option[T] =
+ loadAnnotation(name) map { ssig =>
+ val bytesMethod = ssig.annotationType.getMethod("bytes")
+ bytesMethod.invoke(ssig).asInstanceOf[T]
+ }
+
+ try {
+ markAbsent(NoType)
+ loadBytes[String]("scala.reflect.ScalaSignature") match {
+ case Some(ssig) =>
+ info(s"unpickling Scala $clazz and $module, owner = ${clazz.owner}")
+ val bytes = ssig.getBytes
+ val len = ByteCodecs.decode(bytes)
+ unpickler.unpickle(bytes take len, 0, clazz, module, jclazz.getName)
+ case None =>
+ loadBytes[Array[String]]("scala.reflect.ScalaLongSignature") match {
+ case Some(slsig) =>
+ info(s"unpickling Scala $clazz and $module with long Scala signature")
+ val byteSegments = slsig map (_.getBytes)
+ val lens = byteSegments map ByteCodecs.decode
+ val bytes = Array.ofDim[Byte](lens.sum)
+ var len = 0
+ for ((bs, l) <- byteSegments zip lens) {
+ bs.copyToArray(bytes, len, l)
+ len += l
+ }
+ unpickler.unpickle(bytes, 0, clazz, module, jclazz.getName)
+ case None =>
+ // class does not have a Scala signature; it's a Java class
+ info("translating reflection info for Java " + jclazz) //debug
+ initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz))
+ }
+ }
+ } catch {
+ case ex: MissingRequirementError =>
+ handleError(ex)
+ case ex: IOException =>
+ handleError(ex)
+ }
+ }
+
+ /**
+ * A fresh Scala type parameter that corresponds to a Java type variable.
+ * The association between Scala type parameter and Java type variable is entered in the cache.
+ * @param jtvar The Java type variable
+ */
+ private def createTypeParameter(jtvar: jTypeVariable[_ <: GenericDeclaration]): TypeSymbol = {
+ val tparam = sOwner(jtvar).newTypeParameter(newTypeName(jtvar.getName))
+ .setInfo(new TypeParamCompleter(jtvar))
+ tparamCache enter (jtvar, tparam)
+ tparam
+ }
+
+ /**
+ * A completer that fills in the type of a Scala type parameter from the bounds of a Java type variable.
+ * @param jtvar The Java type variable
+ */
+ private class TypeParamCompleter(jtvar: jTypeVariable[_ <: GenericDeclaration]) extends LazyType {
+ override def load(sym: Symbol) = complete(sym)
+ override def complete(sym: Symbol) = {
+ sym setInfo TypeBounds.upper(glb(jtvar.getBounds.toList map typeToScala map objToAny))
+ }
+ }
+
+ /**
+ * Copy all annotations of Java annotated element `jann` over to Scala symbol `sym`.
+ * Pre: `sym` is already initialized with a concrete type.
+ * Note: If `sym` is a method or constructor, its parameter annotations are copied as well.
+ */
+ private def copyAnnotations(sym: Symbol, jann: AnnotatedElement) {
+ // to do: implement
+ }
+
+ /**
+ * A completer that fills in the types of a Scala class and its companion object
+ * by copying corresponding type info from a Java class. This completer is used
+ * to reflect classes in Scala that do not have a Scala pickle info, be it
+ * because they are local classes or have been compiled from Java sources.
+ * @param clazz The Scala class for which info is copied
+ * @param module The Scala companion object for which info is copied
+ * @param jclazz The Java class
+ */
+ private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType {
+
+ /** used to avoid cycles while initializing classes */
+ private var parentsLevel = 0
+ private var pendingLoadActions: List[() => Unit] = Nil
+
+ override def load(sym: Symbol): Unit = {
+ debugInfo("completing from Java " + sym + "/" + clazz.fullName)//debug
+ assert(sym == clazz || (module != NoSymbol && (sym == module || sym == module.moduleClass)), sym)
+ val flags = toScalaClassFlags(jclazz.getModifiers)
+ clazz setFlag (flags | JAVA)
+ if (module != NoSymbol) {
+ module setFlag (flags & PRIVATE | JAVA)
+ module.moduleClass setFlag (flags & PRIVATE | JAVA)
+ }
+
+ copyAnnotations(clazz, jclazz)
+ // to do: annotations to set also for module?
+
+ clazz setInfo new LazyPolyType(jclazz.getTypeParameters.toList map createTypeParameter)
+ if (module != NoSymbol) {
+ module setInfo module.moduleClass.tpe
+ module.moduleClass setInfo new LazyPolyType(List())
+ }
+ }
+
+ override def complete(sym: Symbol): Unit = {
+ load(sym)
+ completeRest()
+ }
+
+ def completeRest(): Unit = self.synchronized {
+ val tparams = clazz.rawInfo.typeParams
+
+ val parents = try {
+ parentsLevel += 1
+ val jsuperclazz = jclazz.getGenericSuperclass
+ val superclazz = if (jsuperclazz == null) AnyClass.tpe else typeToScala(jsuperclazz)
+ superclazz :: (jclazz.getGenericInterfaces.toList map typeToScala)
+ } finally {
+ parentsLevel -= 1
+ }
+ clazz setInfo GenPolyType(tparams, new ClassInfoType(parents, newScope, clazz))
+ if (module != NoSymbol) {
+ module.moduleClass setInfo new ClassInfoType(List(), newScope, module.moduleClass)
+ }
+
+ def enter(sym: Symbol, mods: Int) =
+ (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym
+
+ for (jinner <- jclazz.getDeclaredClasses) {
+ enter(jclassAsScala(jinner, clazz), jinner.getModifiers)
+ }
+
+ pendingLoadActions = { () =>
+
+ for (jfield <- jclazz.getDeclaredFields)
+ enter(jfieldAsScala(jfield), jfield.getModifiers)
+
+ for (jmeth <- jclazz.getDeclaredMethods)
+ enter(jmethodAsScala(jmeth), jmeth.getModifiers)
+
+ for (jconstr <- jclazz.getConstructors)
+ enter(jconstrAsScala(jconstr), jconstr.getModifiers)
+
+ } :: pendingLoadActions
+
+ if (parentsLevel == 0) {
+ while (!pendingLoadActions.isEmpty) {
+ val item = pendingLoadActions.head
+ pendingLoadActions = pendingLoadActions.tail
+ item()
+ }
+ }
+ }
+
+ class LazyPolyType(override val typeParams: List[Symbol]) extends LazyType {
+ override def complete(sym: Symbol) {
+ completeRest()
+ }
+ }
+ }
+
+ /**
+ * If Java modifiers `mods` contain STATIC, return the module class
+ * of the companion module of `clazz`, otherwise the class `clazz` itself.
+ */
+ private def followStatic(clazz: Symbol, mods: Int) =
+ if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz
+
+ implicit class RichClass(jclazz: jClass[_]) {
+ // [Eugene++] `jclazz.isLocalClass` doesn't work because of problems with `getSimpleName`
+ // java.lang.Error: sOwner(class Test$A$1) has failed
+ // Caused by: java.lang.InternalError: Malformed class name
+ // at java.lang.Class.getSimpleName(Class.java:1133)
+ // at java.lang.Class.isAnonymousClass(Class.java:1188)
+ // at java.lang.Class.isLocalClass(Class.java:1199)
+ // (see t5256c.scala for more details)
+ // hence we have to approximate by removing the `isAnonymousClass` check
+// def isLocalClass0: Boolean = jclazz.isLocalClass
+ def isLocalClass0: Boolean = jclazz.getEnclosingMethod != null || jclazz.getEnclosingConstructor != null
+ }
+
+ // [Eugene++] overflow from Paul's changes made concurrently with reflection refactoring
+ // https://github.com/scala/scala/commit/90d2bee45b25844f809f8c5300aefcb1bfe9e336
+ //
+ // /** Methods which need to be wrapped because they either are getSimpleName
+ // * or call getSimpleName:
+ // *
+ // * public String getSimpleName()
+ // * public boolean isAnonymousClass()
+ // * public boolean isLocalClass()
+ // * public boolean isMemberClass()
+ // * public String getCanonicalName()
+ // *
+ // * TODO - find all such calls and wrap them.
+ // * TODO - create mechanism to avoid the recurrence of unwrapped calls.
+ // */
+ // private def wrapClassCheck[T](alt: T)(body: => T): T =
+ // try body catch { case x: InternalError if x.getMessage == "Malformed class name" => alt }
+
+ // private def wrapIsLocalClass(clazz: jClass[_]): Boolean =
+ // wrapClassCheck(false)(clazz.isLocalClass)
+
+ // private def wrapGetSimpleName(clazz: jClass[_]): String =
+ // wrapClassCheck("")(clazz.getSimpleName)
+
+ /**
+ * The Scala owner of the Scala class corresponding to the Java class `jclazz`
+ */
+ private def sOwner(jclazz: jClass[_]): Symbol =
+ if (jclazz.isMemberClass) {
+ val jEnclosingClass = jclazz.getEnclosingClass
+ val sEnclosingClass = classToScala(jEnclosingClass)
+ followStatic(sEnclosingClass, jclazz.getModifiers)
+ } else if (jclazz.isLocalClass0) {
+ val jEnclosingMethod = jclazz.getEnclosingMethod
+ if (jEnclosingMethod != null) {
+ methodToScala(jEnclosingMethod)
+ } else {
+ val jEnclosingConstructor = jclazz.getEnclosingConstructor
+ constructorToScala(jEnclosingConstructor)
+ }
+ } else if (jclazz.isPrimitive || jclazz.isArray) {
+ ScalaPackageClass
+ } else if (jclazz.getPackage != null) {
+ val jPackage = jclazz.getPackage
+ packageToScala(jPackage).moduleClass
+ } else {
+ // @eb: a weird classloader might return a null package for something with a non-empty package name
+ // for example, http://groups.google.com/group/scala-internals/browse_thread/thread/7be09ff8f67a1e5c
+ // in that case we could invoke packageNameToScala(jPackageName) and, probably, be okay
+ // however, I think, it's better to blow up, since weirdness of the class loader might bite us elsewhere
+ // [martin] I think it's better to be forgiving here. Restoring packageNameToScala.
+ val jPackageName = jclazz.getName take jclazz.getName.lastIndexOf('.')
+ packageNameToScala(jPackageName).moduleClass
+ }
+
+ /**
+ * The Scala owner of the Scala symbol corresponding to the Java member `jmember`
+ */
+ private def sOwner(jmember: jMember): Symbol = {
+ followStatic(classToScala(jmember.getDeclaringClass), jmember.getModifiers)
+ }
+
+ /**
+ * The Scala owner of the Scala type parameter corresponding to the Java type variable `jtvar`
+ */
+ private def sOwner(jtvar: jTypeVariable[_ <: GenericDeclaration]): Symbol =
+ genericDeclarationToScala(jtvar.getGenericDeclaration)
+
+ /**
+ * Find declarations or definition in class `clazz` that maps to a Java
+ * entity with name `jname`. Because of name-mangling, this is more difficult
+ * than a simple name-based lookup via `decl`. If `decl` fails, members
+ * that start with the given name are searched instead.
+ */
+ private def lookup(clazz: Symbol, jname: String): Symbol = {
+ def approximateMatch(sym: Symbol, jstr: String): Boolean =
+ (sym.name.toString == jstr) ||
+ sym.isPrivate && nme.expandedName(sym.name.toTermName, sym.owner).toString == jstr
+
+ clazz.info.decl(newTermName(jname)) orElse {
+ (clazz.info.decls.iterator filter (approximateMatch(_, jname))).toList match {
+ case List() => NoSymbol
+ case List(sym) => sym
+ case alts => clazz.newOverloaded(alts.head.tpe.prefix, alts)
+ }
+ }
+ }
+
+ /**
+ * The Scala method corresponding to given Java method.
+ * @param jmeth The Java method
+ * @return A Scala method object that corresponds to `jmeth`.
+ */
+ def methodToScala(jmeth: jMethod): MethodSymbol =
+ toScala(methodCache, jmeth)(_ methodToScala1 _)
+
+ private def methodToScala1(jmeth: jMethod): MethodSymbol = {
+ val jOwner = jmeth.getDeclaringClass
+ val preOwner = classToScala(jOwner)
+ val owner = followStatic(preOwner, jmeth.getModifiers)
+ (lookup(owner, jmeth.getName) suchThat (erasesTo(_, jmeth)) orElse jmethodAsScala(jmeth))
+ .asMethodSymbol
+ }
+
+ /**
+ * The Scala constructor corresponding to given Java constructor.
+ * @param jconstr The Java constructor
+ * @return A Scala method object that corresponds to `jconstr`.
+ */
+ def constructorToScala(jconstr: jConstructor[_]): MethodSymbol =
+ toScala(constructorCache, jconstr)(_ constructorToScala1 _)
+
+ private def constructorToScala1(jconstr: jConstructor[_]): MethodSymbol = {
+ val owner = followStatic(classToScala(jconstr.getDeclaringClass), jconstr.getModifiers)
+ (lookup(owner, jconstr.getName) suchThat (erasesTo(_, jconstr)) orElse jconstrAsScala(jconstr))
+ .asMethodSymbol
+ }
+
+ /**
+ * The Scala field corresponding to given Java field.
+ * @param jfield The Java field
+ * @return A Scala field object that corresponds to `jfield`.
+ * // ??? should we return the getter instead?
+ */
+ def fieldToScala(jfield: jField): TermSymbol =
+ toScala(fieldCache, jfield)(_ fieldToScala1 _)
+
+ private def fieldToScala1(jfield: jField): TermSymbol = {
+ val owner = followStatic(classToScala(jfield.getDeclaringClass), jfield.getModifiers)
+ (lookup(owner, jfield.getName) suchThat (!_.isMethod) orElse jfieldAsScala(jfield))
+ .asTermSymbol
+ }
+
+ /**
+ * The Scala package corresponding to given Java package
+ */
+ def packageToScala(jpkg: jPackage): ModuleSymbol = packageCache.toScala(jpkg) {
+ makeScalaPackage(jpkg.getName)
+ }
+
+ /**
+ * The Scala package with given fully qualified name.
+ */
+ def packageNameToScala(fullname: String): ModuleSymbol = {
+ if (fullname == "") EmptyPackage
+ else {
+ val jpkg = jPackage.getPackage(fullname)
+ if (jpkg != null) packageToScala(jpkg) else makeScalaPackage(fullname)
+ }
+ }
+
+ /**
+ * The Scala package with given fully qualified name. Unlike `packageNameToScala`,
+ * this one bypasses the cache.
+ */
+ private[JavaMirrors] def makeScalaPackage(fullname: String): ModuleSymbol = {
+ val split = fullname lastIndexOf '.'
+ val ownerModule: ModuleSymbol =
+ if (split > 0) packageNameToScala(fullname take split) else this.RootPackage
+ val owner = ownerModule.moduleClass
+ val name = newTermName(fullname drop (split + 1))
+ val opkg = owner.info decl name
+ if (opkg.isPackage)
+ opkg.asModuleSymbol
+ else if (opkg == NoSymbol) {
+ val pkg = owner.newPackage(name)
+ pkg.moduleClass setInfo new LazyPackageType
+ pkg setInfoAndEnter pkg.moduleClass.tpe
+ info("made Scala "+pkg)
+ pkg
+ } else
+ throw new ReflectError(opkg+" is not a package")
+ }
+
+ private def scalaSimpleName(jclazz: jClass[_]): TypeName = {
+ val owner = sOwner(jclazz)
+ val enclosingClass = jclazz.getEnclosingClass
+ var prefix = if (enclosingClass != null) enclosingClass.getName else ""
+ val isObject = owner.isModuleClass && !owner.isPackageClass
+ if (isObject && !prefix.endsWith(nme.MODULE_SUFFIX_STRING)) prefix += nme.MODULE_SUFFIX_STRING
+ assert(jclazz.getName.startsWith(prefix))
+ var name = jclazz.getName.substring(prefix.length)
+ name = name.substring(name.lastIndexOf(".") + 1)
+ newTypeName(name)
+ }
+
+ /**
+ * The Scala class that corresponds to a given Java class.
+ * @param jclazz The Java class
+ * @return A Scala class symbol that reflects all elements of the Java class,
+ * in the form they appear in the Scala pickling info, or, if that is
+ * not available, wrapped from the Java reflection info.
+ */
+ def classToScala(jclazz: jClass[_]): ClassSymbol =
+ toScala(classCache, jclazz)(_ classToScala1 _)
+
+ private def classToScala1(jclazz: jClass[_]): ClassSymbol = {
+ val jname = newTypeName(jclazz.getName)
+ if (jname == fulltpnme.RuntimeNothing) NothingClass
+ else if (jname == fulltpnme.RuntimeNull) NullClass
+ else {
+ val owner = sOwner(jclazz)
+ val simpleName = scalaSimpleName(jclazz)
+
+ def lookupClass = {
+ def coreLookup(name: Name): Symbol =
+ owner.info.decl(name) orElse {
+ if (name.startsWith(nme.NAME_JOIN_STRING)) coreLookup(name drop 1) else NoSymbol
+ }
+ if (nme.isModuleName(simpleName))
+ coreLookup(nme.stripModuleSuffix(simpleName).toTermName) map (_.moduleClass)
+ else
+ coreLookup(simpleName)
+ }
+
+ val cls =
+ if (jclazz.isMemberClass && !nme.isImplClassName(jname))
+ lookupClass
+ else if (jclazz.isLocalClass0 || isInvalidClassName(jname))
+ // local classes and implementation classes not preserved by unpickling - treat as Java
+ jclassAsScala(jclazz)
+ else if (jclazz.isArray)
+ ArrayClass
+ else
+ javaTypeToValueClass(jclazz) orElse lookupClass
+
+ assert (cls.isType,
+ s"""${if (cls == NoSymbol) "not a type: symbol" else "no symbol could be"}
+ | loaded from $jclazz in $owner with name $simpleName and classloader $classLoader""".stripMargin)
+
+ cls.asClassSymbol
+ }
+ }
+
+ /**
+ * The Scala type parameter that corresponds to a given Java type parameter.
+ * @param jparam The Java type parameter
+ * @return A Scala type parameter symbol that has the same owner and name as the Java type parameter
+ */
+ def typeParamToScala(jparam: jTypeVariable[_ <: GenericDeclaration]): TypeSymbol =
+ toScala(tparamCache, jparam)(_ typeParamToScala1 _)
+
+ private def typeParamToScala1(jparam: jTypeVariable[_ <: GenericDeclaration]): TypeSymbol = {
+ val owner = genericDeclarationToScala(jparam.getGenericDeclaration)
+ owner.info match {
+ case PolyType(tparams, _) => tparams.find(_.name.toString == jparam.getName).get.asTypeSymbol
+ }
+ }
+
+ /**
+ * The Scala symbol that corresponds to a given Java generic declaration (class, method, or constructor)
+ */
+ def genericDeclarationToScala(jdecl: GenericDeclaration): Symbol = jdecl match {
+ case jclazz: jClass[_] => classToScala(jclazz)
+ case jmeth: jMethod => methodToScala(jmeth)
+ case jconstr: jConstructor[_] => constructorToScala(jconstr)
+ }
+
+ /**
+ * Given some Java type arguments, a corresponding list of Scala types, plus potentially
+ * some existentially bound type variables that represent wildcard arguments.
+ */
+ private def targsToScala(owner: Symbol, args: List[jType]): (List[Type], List[TypeSymbol]) = {
+ val tparams = new ListBuffer[TypeSymbol]
+ def targToScala(arg: jType): Type = arg match {
+ case jwild: WildcardType =>
+ val tparam = owner.newExistential(newTypeName("T$" + tparams.length))
+ .setInfo(TypeBounds(
+ lub(jwild.getLowerBounds.toList map typeToScala),
+ glb(jwild.getUpperBounds.toList map typeToScala map objToAny)))
+ tparams += tparam
+ typeRef(NoPrefix, tparam, List())
+ case _ =>
+ typeToScala(arg)
+ }
+ (args map targToScala, tparams.toList)
+ }
+
+ /**
+ * The Scala type that corresponds to given Java type
+ */
+ def typeToScala(jtpe: jType): Type = jtpe match {
+ case jclazz: jClass[_] =>
+ if (jclazz.isArray)
+ arrayType(typeToScala(jclazz.getComponentType))
+ else {
+ val clazz = classToScala(jclazz)
+ rawToExistential(typeRef(clazz.owner.thisType, clazz, List()))
+ }
+ case japplied: ParameterizedType =>
+ val (pre, sym) = typeToScala(japplied.getRawType) match {
+ case ExistentialType(tparams, TypeRef(pre, sym, _)) => (pre, sym)
+ case TypeRef(pre, sym, _) => (pre, sym)
+ }
+ val args0 = japplied.getActualTypeArguments
+ val (args, bounds) = targsToScala(pre.typeSymbol, args0.toList)
+ ExistentialType(bounds, typeRef(pre, sym, args))
+ case jarr: GenericArrayType =>
+ arrayType(typeToScala(jarr.getGenericComponentType))
+ case jtvar: jTypeVariable[_] =>
+ val tparam = typeParamToScala(jtvar)
+ typeRef(NoPrefix, tparam, List())
+ }
+
+ /**
+ * The Scala class that corresponds to given Java class without taking
+ * Scala pickling info into account.
+ * @param jclazz The Java class
+ * @return A Scala class symbol that wraps all reflection info of `jclazz`
+ */
+ private def jclassAsScala(jclazz: jClass[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz))
+
+ private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = {
+ val name = scalaSimpleName(jclazz)
+ val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz)
+ val (clazz, module) = createClassModule(owner, name, completer)
+ classCache enter (jclazz, clazz)
+ clazz
+ }
+
+ /**
+ * The Scala field that corresponds to given Java field without taking
+ * Scala pickling info into account.
+ * @param jfield The Java field
+ * @return A Scala value symbol that wraps all reflection info of `jfield`
+ */
+ private def jfieldAsScala(jfield: jField): TermSymbol =
+ toScala(fieldCache, jfield)(_ jfieldAsScala1 _)
+
+ private def jfieldAsScala1(jfield: jField): TermSymbol = {
+ val field = sOwner(jfield)
+ .newValue(newTermName(jfield.getName), NoPosition, toScalaFieldFlags(jfield.getModifiers))
+ .setInfo(typeToScala(jfield.getGenericType))
+ fieldCache enter (jfield, field)
+ copyAnnotations(field, jfield)
+ field
+ }
+
+ private def setMethType(meth: Symbol, tparams: List[Symbol], paramtpes: List[Type], restpe: Type) = {
+ meth setInfo GenPolyType(tparams, MethodType(meth.owner.newSyntheticValueParams(paramtpes map objToAny), restpe))
+ }
+
+ /**
+ * The Scala method that corresponds to given Java method without taking
+ * Scala pickling info into account.
+ * @param jmeth The Java method
+ * @return A Scala method symbol that wraps all reflection info of `jmethod`
+ */
+ private def jmethodAsScala(jmeth: jMethod): MethodSymbol =
+ toScala(methodCache, jmeth)(_ jmethodAsScala1 _)
+
+ private def jmethodAsScala1(jmeth: jMethod): MethodSymbol = {
+ val clazz = sOwner(jmeth)
+ val meth = clazz.newMethod(newTermName(jmeth.getName), NoPosition, toScalaMethodFlags(jmeth.getModifiers))
+ methodCache enter (jmeth, meth)
+ val tparams = jmeth.getTypeParameters.toList map createTypeParameter
+ val paramtpes = jmeth.getGenericParameterTypes.toList map typeToScala
+ val resulttpe = typeToScala(jmeth.getGenericReturnType)
+ setMethType(meth, tparams, paramtpes, resulttpe)
+ copyAnnotations(meth, jmeth)
+ if ((jmeth.getModifiers & JAVA_ACC_VARARGS) != 0) meth.setInfo(arrayToRepeated(meth.info))
+ meth
+ }
+
+ /**
+ * The Scala constructor that corresponds to given Java constructor without taking
+ * Scala pickling info into account.
+ * @param jconstr The Java constructor
+ * @return A Scala constructor symbol that wraps all reflection info of `jconstr`
+ */
+ private def jconstrAsScala(jconstr: jConstructor[_]): MethodSymbol =
+ toScala(constructorCache, jconstr)(_ jconstrAsScala1 _)
+
+ private def jconstrAsScala1(jconstr: jConstructor[_]): MethodSymbol = {
+ // [Martin] Note: I know there's a lot of duplication wrt jmethodAsScala, but don't think it's worth it to factor this out.
+ val clazz = sOwner(jconstr)
+ val constr = clazz.newConstructor(NoPosition, toScalaMethodFlags(jconstr.getModifiers))
+ constructorCache enter (jconstr, constr)
+ val tparams = jconstr.getTypeParameters.toList map createTypeParameter
+ val paramtpes = jconstr.getGenericParameterTypes.toList map typeToScala
+ setMethType(constr, tparams, paramtpes, clazz.tpe)
+ constr setInfo GenPolyType(tparams, MethodType(clazz.newSyntheticValueParams(paramtpes), clazz.tpe))
+ copyAnnotations(constr, jconstr)
+ constr
+ }
+
+// -------------------- Scala to Java -----------------------------------
+
+ /** Optionally, the Java package corresponding to a given Scala package, or None if no such Java package exists.
+ * @param pkg The Scala package
+ */
+ def packageToJavaOption(pkg: ModuleSymbol): Option[jPackage] = packageCache.toJavaOption(pkg) {
+ Option(jPackage.getPackage(pkg.fullName.toString))
+ }
+
+ /** The Java class corresponding to given Scala class.
+ * Note: This only works for
+ * - top-level classes
+ * - Scala classes that were generated via jclassToScala
+ * - classes that have a class owner that has a corresponding Java class
+ * @throws A `ClassNotFoundException` for all Scala classes not in one of these categories.
+ */
+ @throws(classOf[ClassNotFoundException])
+ def classToJava(clazz: ClassSymbol): jClass[_] = classCache.toJava(clazz) {
+ def noClass = throw new ClassNotFoundException("no Java class corresponding to "+clazz+" found")
+ //println("classToJava "+clazz+" "+clazz.owner+" "+clazz.owner.isPackageClass)//debug
+ if (clazz.isPrimitiveValueClass)
+ valueClassToJavaType(clazz)
+ else if (clazz == ArrayClass)
+ noClass
+ else if (clazz.owner.isPackageClass)
+ javaClass(clazz.javaClassName)
+ else if (clazz.owner.isClass)
+ classToJava(clazz.owner.asClassSymbol)
+ .getDeclaredClasses
+ .find(_.getSimpleName == clazz.name.toString)
+ .getOrElse(noClass)
+ else
+ noClass
+ }
+
+ private def expandedName(sym: Symbol): String =
+ if (sym.isPrivate) nme.expandedName(sym.name.toTermName, sym.owner).toString
+ else sym.name.toString
+
+ /** The Java field corresponding to a given Scala field.
+ * @param meth The Scala field.
+ */
+ def fieldToJava(fld: TermSymbol): jField = fieldCache.toJava(fld) {
+ val jclazz = classToJava(fld.owner.asClassSymbol)
+ val jname = nme.dropLocalSuffix(fld.name).toString
+ try jclazz getDeclaredField jname
+ catch {
+ case ex: NoSuchFieldException => jclazz getDeclaredField expandedName(fld)
+ }
+ }
+
+ /** The Java method corresponding to a given Scala method.
+ * @param meth The Scala method
+ */
+ def methodToJava(meth: MethodSymbol): jMethod = methodCache.toJava(meth) {
+ val jclazz = classToJava(meth.owner.asClassSymbol)
+ val paramClasses = transformedType(meth).paramTypes map typeToJavaClass
+ val jname = nme.dropLocalSuffix(meth.name).toString
+ try jclazz getDeclaredMethod (jname, paramClasses: _*)
+ catch {
+ case ex: NoSuchMethodException =>
+ jclazz getDeclaredMethod (expandedName(meth), paramClasses: _*)
+ }
+ }
+
+ /** The Java constructor corresponding to a given Scala constructor.
+ * @param constr The Scala constructor
+ */
+ def constructorToJava(constr: MethodSymbol): jConstructor[_] = constructorCache.toJava(constr) {
+ val jclazz = classToJava(constr.owner.asClassSymbol)
+ val paramClasses = transformedType(constr).paramTypes map typeToJavaClass
+ val effectiveParamClasses =
+ if (!constr.owner.owner.isStaticOwner) jclazz.getEnclosingClass +: paramClasses
+ else paramClasses
+ jclazz getConstructor (effectiveParamClasses: _*)
+ }
+
+ private def jArrayClass(elemClazz: jClass[_]): jClass[_] = {
+ jArray.newInstance(elemClazz, 0).getClass
+ }
+
+ /** The Java class that corresponds to given Scala type.
+ * Pre: Scala type is already transformed to Java level.
+ */
+ def typeToJavaClass(tpe: Type): jClass[_] = tpe match {
+ case ExistentialType(_, rtpe) => typeToJavaClass(rtpe)
+ case TypeRef(_, ArrayClass, List(elemtpe)) => jArrayClass(typeToJavaClass(elemtpe))
+ case TypeRef(_, sym: ClassSymbol, _) => classToJava(sym.asClassSymbol)
+ case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found")
+ }
+ }
+
+ /** Assert that packages have package scopes */
+ override def validateClassInfo(tp: ClassInfoType) {
+ assert(!tp.typeSymbol.isPackageClass || tp.decls.isInstanceOf[PackageScope])
+ }
+
+ override def newPackageScope(pkgClass: Symbol) = new PackageScope(pkgClass)
+
+ override def scopeTransform(owner: Symbol)(op: => Scope): Scope =
+ if (owner.isPackageClass) owner.info.decls else op
+
+ private lazy val rootToLoader = new WeakHashMap[Symbol, ClassLoader]
+
+ override def mirrorThatLoaded(sym: Symbol): Mirror = {
+ val root = sym.enclosingRootClass
+ def findLoader = {
+ val loaders = (mirrors collect { case (cl, ref) if ref.get.get.RootClass == root => cl })
+ assert(loaders.nonEmpty, sym)
+ loaders.head
+ }
+ mirrors(rootToLoader getOrElseUpdate(root, findLoader)).get.get
+ }
+
+ private def byName(sym: Symbol): (Name, Symbol) = sym.name -> sym
+
+ private lazy val phantomTypes: Map[Name, Symbol] =
+ Map(byName(definitions.AnyRefClass)) ++ (definitions.isPhantomClass map byName)
+
+ /** 1. If `owner` is a package class (but not the empty package) and `name` is a term name, make a new package
+ * <owner>.<name>, otherwise return NoSymbol.
+ * Exception: If owner is root and a java class with given name exists, create symbol in empty package instead
+ * 2. If `owner` is the scala package and `name` designates a phantom class, return
+ * the corresponding class symbol and enter it into this mirror's ScalaPackage.
+ */
+ override def missingHook(owner: Symbol, name: Name): Symbol = {
+ if (owner.hasPackageFlag) {
+ val mirror = mirrorThatLoaded(owner)
+ // [Eugene++] this makes toolbox tests pass, but it's a mere workaround for SI-5865
+// assert((owner.info decl name) == NoSymbol, s"already exists: $owner . $name")
+ if (owner.isRootSymbol && mirror.tryJavaClass(name.toString).isDefined)
+ return mirror.EmptyPackageClass.info decl name
+ if (name.isTermName && !owner.isEmptyPackageClass)
+ return mirror.makeScalaPackage(
+ if (owner.isRootSymbol) name.toString else owner.fullName+"."+name)
+ if (owner.name.toTermName == nme.scala_ && owner.owner.isRoot)
+ phantomTypes get name match {
+ case Some(tsym) =>
+ owner.info.decls enter tsym
+ return tsym
+ case None =>
+ }
+ }
+ info("*** missing: "+name+"/"+name.isTermName+"/"+owner+"/"+owner.hasPackageFlag+"/"+owner.info.decls.getClass)
+ super.missingHook(owner, name)
+ }
+}
+
+class ReflectError(msg: String) extends java.lang.Error(msg)
+
+class HasJavaClass[J](val getClazz: J => java.lang.Class[_])
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverse.scala b/src/reflect/scala/reflect/runtime/JavaUniverse.scala
new file mode 100644
index 0000000000..d4a83b960d
--- /dev/null
+++ b/src/reflect/scala/reflect/runtime/JavaUniverse.scala
@@ -0,0 +1,33 @@
+package scala.reflect
+package runtime
+
+import internal.{SomePhase, NoPhase, Phase, TreeGen}
+
+/** The universe for standard runtime reflection from Java.
+ * This type implements all abstract term members in internal.SymbolTable.
+ */
+class JavaUniverse extends internal.SymbolTable with ReflectSetup with runtime.SymbolTable { self =>
+
+ type AbstractFileType = AbstractFile
+
+ def picklerPhase = SomePhase
+
+ type TreeGen = internal.TreeGen
+
+ override type Position = scala.reflect.internal.util.Position
+
+ override val gen = new TreeGen { val global: self.type = self }
+
+ lazy val settings = new Settings
+ def forInteractive = false
+ def forScaladoc = false
+
+ def log(msg: => AnyRef): Unit = println(" [] "+msg)
+
+ type TreeCopier = TreeCopierOps
+ def newStrictTreeCopier: TreeCopier = new StrictTreeCopier
+ def newLazyTreeCopier: TreeCopier = new LazyTreeCopier
+
+ init()
+}
+
diff --git a/src/reflect/scala/reflect/runtime/ReflectSetup.scala b/src/reflect/scala/reflect/runtime/ReflectSetup.scala
new file mode 100644
index 0000000000..6e28fc8520
--- /dev/null
+++ b/src/reflect/scala/reflect/runtime/ReflectSetup.scala
@@ -0,0 +1,12 @@
+package scala.reflect
+package runtime
+
+import internal.{SomePhase, NoPhase, Phase, TreeGen}
+
+/** A helper trait to initialize things that need to be set before JavaMirrors and other
+ * reflect specific traits are initialized */
+private[runtime] trait ReflectSetup extends internal.SymbolTable {
+ override val phaseWithId: Array[Phase] = Array(NoPhase, SomePhase)
+ override val currentRunId = 1 // fake a run id so that it is different from NoRunId
+ phase = SomePhase // set to a phase different from NoPhase
+}
diff --git a/src/library/scala/reflect/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala
index 6ea69cb80d..4e82fe8ad2 100644
--- a/src/library/scala/reflect/ReflectionUtils.scala
+++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala
@@ -3,7 +3,7 @@
* @author Paul Phillips
*/
-package scala.reflect
+package scala.reflect.runtime
import java.lang.{Class => jClass}
import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableException }
@@ -33,33 +33,29 @@ object ReflectionUtils {
System.getProperties.asScala.iterator
}
- private def searchForBootClasspath = (
+ private def inferBootClasspath: String = (
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
)
def show(cl: ClassLoader) = {
- def inferClasspath(cl: ClassLoader) = cl match {
- case cl: java.net.URLClassLoader => "[" + (cl.getURLs mkString ",") + "]"
- case _ => "<unknown>"
+ def inferClasspath(cl: ClassLoader): String = cl match {
+ case cl: java.net.URLClassLoader =>
+ "[" + (cl.getURLs mkString ",") + "]"
+ case cl if cl != null && cl.getClass.getName == "scala.tools.nsc.interpreter.AbstractFileClassLoader" =>
+ "[" + cl.asInstanceOf[{val root: scala.reflect.internal.AbstractFileApi}].root + "] and " + inferClasspath(cl.getParent)
+ case null =>
+ inferBootClasspath
+ case _ =>
+ "<unknown>"
}
cl match {
case cl if cl != null =>
"%s of type %s with classpath %s".format(cl, cl.getClass, inferClasspath(cl))
case null =>
- "primordial classloader with boot classpath [%s]".format(searchForBootClasspath)
+ "primordial classloader with boot classpath [%s]".format(inferClasspath(cl))
}
}
- def defaultReflectionClassLoader() = {
- // say no to non-determinism of mirror classloaders
- // default classloader will be instantiated using current system classloader
- // if you wish so, you can rebind it by setting ``mirror.classLoader'' to whatever is necessary
-// val cl = Thread.currentThread.getContextClassLoader
-// if (cl == null) getClass.getClassLoader else cl
-// cl
- getClass.getClassLoader
- }
-
def singletonInstance(cl: ClassLoader, className: String): AnyRef = {
val name = if (className endsWith "$") className else className + "$"
val clazz = java.lang.Class.forName(name, true, cl)
diff --git a/src/compiler/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala
index bbe4d60e9c..eedb88320b 100644
--- a/src/compiler/scala/reflect/runtime/Settings.scala
+++ b/src/reflect/scala/reflect/runtime/Settings.scala
@@ -35,4 +35,6 @@ class Settings extends internal.settings.MutableSettings {
val Xexperimental = new BooleanSetting(false)
val deepCloning = new BooleanSetting (false)
val XoldPatmat = new BooleanSetting(false)
+ val XnoPatmatAnalysis = new BooleanSetting(false)
+ val XfullLubs = new BooleanSetting(false)
}
diff --git a/src/compiler/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala
index 7c1cc16152..c1cd5d2911 100644
--- a/src/compiler/scala/reflect/runtime/SymbolLoaders.scala
+++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala
@@ -7,12 +7,6 @@ import collection.mutable
trait SymbolLoaders { self: SymbolTable =>
- /** The lazy type for root.
- */
- override val rootLoader = new LazyType {
- override def complete(sym: Symbol) = sym setInfo new LazyPackageType
- }
-
/** The standard completer for top-level classes
* @param clazz The top-level class
* @param module The companion object of `clazz`
@@ -35,7 +29,9 @@ trait SymbolLoaders { self: SymbolTable =>
assert(sym == clazz || sym == module || sym == module.moduleClass)
// try {
atPhaseNotLaterThan(picklerPhase) {
- unpickleClass(clazz, module, javaClass(clazz.javaClassName))
+ val loadingMirror = mirrorThatLoaded(sym)
+ val javaClass = loadingMirror.javaClass(clazz.javaClassName)
+ loadingMirror.unpickleClass(clazz, module, javaClass)
// } catch {
// case ex: ClassNotFoundException => makePackage()
// case ex: NoClassDefFoundError => makePackage()
@@ -65,8 +61,14 @@ trait SymbolLoaders { self: SymbolTable =>
assert(!(name.toString endsWith "[]"), name)
val clazz = owner.newClass(name)
val module = owner.newModule(name.toTermName)
- owner.info.decls enter clazz
- owner.info.decls enter module
+ // [Eugene++] am I doing this right?
+ // todo: drop condition, see what goes wrong
+ // [Eugene++ to Martin] test/files/run/t5256g and test/files/run/t5256h will crash
+ // reflection meeting verdict: need to enter the symbols into the first symbol in the owner chain that has a non-empty scope
+ if (owner.info.decls != EmptyScope) {
+ owner.info.decls enter clazz
+ owner.info.decls enter module
+ }
initClassModule(clazz, module, completer(clazz, module))
(clazz, module)
}
@@ -92,7 +94,7 @@ trait SymbolLoaders { self: SymbolTable =>
/** Is the given name valid for a top-level class? We exclude names with embedded $-signs, because
* these are nested classes or anonymous classes,
*/
- def invalidClassName(name: Name) = {
+ def isInvalidClassName(name: Name) = {
val dp = name pos '$'
0 < dp && dp < (name.length - 1)
}
@@ -104,20 +106,35 @@ trait SymbolLoaders { self: SymbolTable =>
val e = super.lookupEntry(name)
if (e != null)
e
- else if (invalidClassName(name) || (negatives contains name))
+ else if (isInvalidClassName(name) || (negatives contains name))
null
else {
val path =
if (pkgClass.isEmptyPackageClass) name.toString
else pkgClass.fullName + "." + name
- if (isJavaClass(path)) {
- val (clazz, module) = createClassModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _))
- debugInfo("created "+module+"/"+module.moduleClass+" in "+pkgClass)
- lookupEntry(name)
- } else {
- debugInfo("*** not found : "+path)
- negatives += name
- null
+ val currentMirror = mirrorThatLoaded(pkgClass)
+ currentMirror.tryJavaClass(path) match {
+ case Some(cls) =>
+ val loadingMirror = currentMirror.mirrorDefining(cls)
+ val (clazz, module) =
+ if (loadingMirror eq currentMirror) {
+ createClassModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _))
+ } else {
+ val origOwner = loadingMirror.packageNameToScala(pkgClass.fullName)
+ val clazz = origOwner.info decl name.toTypeName
+ val module = origOwner.info decl name.toTermName
+ assert(clazz != NoSymbol)
+ assert(module != NoSymbol)
+ pkgClass.info.decls enter clazz
+ pkgClass.info.decls enter module
+ (clazz, module)
+ }
+ debugInfo(s"created $module/${module.moduleClass} in $pkgClass")
+ lookupEntry(name)
+ case none =>
+ debugInfo("*** not found : "+path)
+ negatives += name
+ null
}
}
}
diff --git a/src/compiler/scala/reflect/runtime/SymbolTable.scala b/src/reflect/scala/reflect/runtime/SymbolTable.scala
index 64a5894d01..c90665508b 100644
--- a/src/compiler/scala/reflect/runtime/SymbolTable.scala
+++ b/src/reflect/scala/reflect/runtime/SymbolTable.scala
@@ -3,14 +3,15 @@ package runtime
/**
* This symbol table trait fills in the definitions so that class information is obtained by refection.
- * It can be used either from the reflexive mirror itself (class Mirror), or else from
+ * It can be used either from a reflexive universe (class scala.reflect.runtime.JavaUniverse), or else from
* a runtime compiler that uses reflection to get a class information (class scala.tools.nsc.ReflectGlobal)
*/
-trait SymbolTable extends internal.SymbolTable with JavaToScala with ScalaToJava with ClassLoaders with SymbolLoaders with SynchronizedOps {
+trait SymbolTable extends internal.SymbolTable with JavaMirrors with SymbolLoaders with SynchronizedOps {
def info(msg: => String) =
if (settings.verbose.value) println("[reflect-compiler] "+msg)
def debugInfo(msg: => String) =
if (settings.debug.value) info(msg)
+
}
diff --git a/src/compiler/scala/reflect/runtime/SynchronizedOps.scala b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala
index 907c0dd369..907c0dd369 100644
--- a/src/compiler/scala/reflect/runtime/SynchronizedOps.scala
+++ b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala
diff --git a/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala
index 2322911220..3b28ddf42c 100644
--- a/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala
+++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala
@@ -14,11 +14,11 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable =>
override def connectModuleToClass(m: ModuleSymbol, moduleClass: ClassSymbol): ModuleSymbol =
synchronized { super.connectModuleToClass(m, moduleClass) }
- override def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTerm =
- new FreeTerm(name, value, origin) with SynchronizedTermSymbol initFlags flags setInfo info
+ override def newFreeTermSymbol(name: TermName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTermSymbol =
+ new FreeTermSymbol(name, value, origin) with SynchronizedTermSymbol initFlags flags setInfo info
- override def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeType =
- new FreeType(name, value, origin) with SynchronizedTypeSymbol initFlags flags setInfo info
+ override def newFreeTypeSymbol(name: TypeName, info: Type, value: => Any, flags: Long = 0L, origin: String = null): FreeTypeSymbol =
+ new FreeTypeSymbol(name, value, origin) with SynchronizedTypeSymbol initFlags flags setInfo info
override protected def makeNoSymbol: NoSymbol = new NoSymbol with SynchronizedSymbol
@@ -92,8 +92,7 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable =>
override protected def createModuleSymbol(name: TermName, pos: Position, newFlags: Long): ModuleSymbol =
new ModuleSymbol(this, pos, name) with SynchronizedTermSymbol initFlags newFlags
- override protected def createPackageSymbol(name: TermName, pos: Position, newFlags: Long): PackageSymbol =
- new PackageSymbol(this, pos, name) with SynchronizedTermSymbol initFlags newFlags
+ override protected def createPackageSymbol(name: TermName, pos: Position, newFlags: Long): ModuleSymbol = createModuleSymbol(name, pos, newFlags)
// TODO
// override protected def createValueParameterSymbol(name: TermName, pos: Position, newFlags: Long)
@@ -133,7 +132,8 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable =>
trait SynchronizedModuleClassSymbol extends ModuleClassSymbol with SynchronizedClassSymbol {
override def sourceModule = synchronized { super.sourceModule }
- override def sourceModule_=(module: Symbol) = synchronized { super.sourceModule_=(module: Symbol) }
+ // [Eugene++ to Martin] doesn't override anything. no longer necessary?
+ // def sourceModule_=(module: ModuleSymbol) = synchronized { super.sourceModule_=(module) }
override def implicitMembers: List[Symbol] = synchronized { super.implicitMembers }
}
}
diff --git a/src/compiler/scala/reflect/runtime/SynchronizedTypes.scala b/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala
index e5a508f802..e1eb7a57fe 100644
--- a/src/compiler/scala/reflect/runtime/SynchronizedTypes.scala
+++ b/src/reflect/scala/reflect/runtime/SynchronizedTypes.scala
@@ -9,7 +9,8 @@ trait SynchronizedTypes extends internal.Types { self: SymbolTable =>
// No sharing of map objects:
override protected def commonOwnerMap = new CommonOwnerMap
- private val uniqueLock = new Object
+ private object uniqueLock
+
override def unique[T <: Type](tp: T): T = uniqueLock.synchronized { super.unique(tp) }
class SynchronizedUndoLog extends UndoLog {
@@ -29,7 +30,7 @@ trait SynchronizedTypes extends internal.Types { self: SymbolTable =>
override protected def baseTypeOfNonClassTypeRef(tpe: NonClassTypeRef, clazz: Symbol) =
synchronized { super.baseTypeOfNonClassTypeRef(tpe, clazz) }
- private val subsametypeLock = new Object
+ private object subsametypeLock
override def isSameType(tp1: Type, tp2: Type): Boolean =
subsametypeLock.synchronized { super.isSameType(tp1, tp2) }
@@ -40,7 +41,7 @@ trait SynchronizedTypes extends internal.Types { self: SymbolTable =>
override def isSubType(tp1: Type, tp2: Type, depth: Int): Boolean =
subsametypeLock.synchronized { super.isSubType(tp1, tp2, depth) }
- private val lubglbLock = new Object
+ private object lubglbLock
override def glb(ts: List[Type]): Type =
lubglbLock.synchronized { super.glb(ts) }
@@ -48,13 +49,13 @@ trait SynchronizedTypes extends internal.Types { self: SymbolTable =>
override def lub(ts: List[Type]): Type =
lubglbLock.synchronized { super.lub(ts) }
- private val indentLock = new Object
+ private object indentLock
override protected def explain[T](op: String, p: (Type, T) => Boolean, tp1: Type, arg2: T): Boolean = {
indentLock.synchronized { super.explain(op, p, tp1, arg2) }
}
- private val toStringLock = new Object
+ private object toStringLock
override protected def typeToString(tpe: Type): String =
toStringLock.synchronized(super.typeToString(tpe))
@@ -84,4 +85,4 @@ trait SynchronizedTypes extends internal.Types { self: SymbolTable =>
override protected def defineBaseTypeSeqOfTypeRef(tpe: TypeRef) =
tpe.synchronized { super.defineBaseTypeSeqOfTypeRef(tpe) }
-} \ No newline at end of file
+}
diff --git a/src/reflect/scala/reflect/runtime/TwoWayCache.scala b/src/reflect/scala/reflect/runtime/TwoWayCache.scala
new file mode 100644
index 0000000000..c7bfb3435d
--- /dev/null
+++ b/src/reflect/scala/reflect/runtime/TwoWayCache.scala
@@ -0,0 +1,52 @@
+package scala.reflect
+package runtime
+
+/** A cache that maintains a bijection between Java reflection type `J`
+ * and Scala reflection type `S`.
+ */
+import collection.mutable.HashMap
+
+private[runtime] class TwoWayCache[J, S] {
+
+ private val toScalaMap = new HashMap[J, S]
+ private val toJavaMap = new HashMap[S, J]
+
+ def enter(j: J, s: S) = synchronized {
+ // debugInfo("cached: "+j+"/"+s)
+ toScalaMap(j) = s
+ toJavaMap(s) = j
+ }
+
+ def toScala(key: J)(body: => S): S = synchronized {
+ toScalaMap get key match {
+ case Some(v) =>
+ v
+ case none =>
+ val result = body
+ enter(key, result)
+ result
+ }
+ }
+
+ def toJava(key: S)(body: => J): J = synchronized {
+ toJavaMap get key match {
+ case Some(v) =>
+ v
+ case none =>
+ val result = body
+ enter(result, key)
+ result
+ }
+ }
+
+ def toJavaOption(key: S)(body: => Option[J]): Option[J] = synchronized {
+ toJavaMap get key match {
+ case None =>
+ val result = body
+ for (value <- result) enter(value, key)
+ result
+ case some => some
+ }
+ }
+}
+
diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala
new file mode 100644
index 0000000000..a5809a2629
--- /dev/null
+++ b/src/reflect/scala/reflect/runtime/package.scala
@@ -0,0 +1,26 @@
+package scala.reflect
+
+import language.experimental.macros
+
+package object runtime {
+
+ // type is api.JavaUniverse because we only want to expose the `scala.reflect.api.*` subset of reflection
+ lazy val universe: api.JavaUniverse = new runtime.JavaUniverse
+
+ // [Eugene++ to Martin] removed `mirrorOfLoader`, because one can use `universe.runtimeMirror` instead
+
+ def currentMirror: universe.Mirror = macro Macros.currentMirror
+}
+
+package runtime {
+ object Macros {
+ def currentMirror(c: scala.reflect.makro.Context): c.Expr[universe.Mirror] = {
+ import c.universe._
+ val runtimeClass = c.reifyEnclosingRuntimeClass
+ if (runtimeClass.isEmpty) c.abort(c.enclosingPosition, "call site does not have an enclosing class")
+ val runtimeUniverse = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("universe"))
+ val currentMirror = Apply(Select(runtimeUniverse, newTermName("runtimeMirror")), List(Select(runtimeClass, newTermName("getClassLoader"))))
+ c.Expr[Nothing](currentMirror)(c.TypeTag.Nothing)
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/reflect/scala/tools/nsc/io/AbstractFile.scala
index deb914f806..fd56608fab 100644
--- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala
+++ b/src/reflect/scala/tools/nsc/io/AbstractFile.scala
@@ -8,9 +8,9 @@ package scala.tools.nsc
package io
import java.io.{ FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream }
+import java.io.{ File => JFile }
import java.net.URL
import scala.collection.mutable.ArrayBuffer
-import scala.reflect.api.RequiredFile
/**
* @author Philippe Altherr
@@ -82,7 +82,7 @@ object AbstractFile {
* <code>global.settings.encoding.value</code>.
* </p>
*/
-abstract class AbstractFile extends AnyRef with RequiredFile with Iterable[AbstractFile] {
+abstract class AbstractFile extends reflect.internal.AbstractFileApi with Iterable[AbstractFile] {
/** Returns the name of this abstract file. */
def name: String
diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/reflect/scala/tools/nsc/io/Directory.scala
index b4ceba682a..ebd6edc8d8 100644
--- a/src/compiler/scala/tools/nsc/io/Directory.scala
+++ b/src/reflect/scala/tools/nsc/io/Directory.scala
@@ -9,6 +9,8 @@
package scala.tools.nsc
package io
+import java.io.{ File => JFile }
+
object Directory {
import scala.util.Properties.{ tmpDir, userHome, userDir }
diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/reflect/scala/tools/nsc/io/File.scala
index 06cb20e4ac..eedf92ef98 100644
--- a/src/compiler/scala/tools/nsc/io/File.scala
+++ b/src/reflect/scala/tools/nsc/io/File.scala
@@ -13,6 +13,7 @@ package io
import java.io.{
FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter,
BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable }
+import java.io.{ File => JFile }
import java.nio.channels.{ Channel, FileChannel }
import scala.io.Codec
import language.{reflectiveCalls, implicitConversions}
diff --git a/src/compiler/scala/tools/nsc/io/FileOperationException.scala b/src/reflect/scala/tools/nsc/io/FileOperationException.scala
index f23658efbc..f23658efbc 100644
--- a/src/compiler/scala/tools/nsc/io/FileOperationException.scala
+++ b/src/reflect/scala/tools/nsc/io/FileOperationException.scala
diff --git a/src/compiler/scala/tools/nsc/io/NoAbstractFile.scala b/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala
index 36cf42d7ec..04568b0e2e 100644
--- a/src/compiler/scala/tools/nsc/io/NoAbstractFile.scala
+++ b/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala
@@ -7,6 +7,7 @@ package scala.tools.nsc
package io
import java.io.InputStream
+import java.io.{ File => JFile }
/** A distinguished object so you can avoid both null
* and Option.
diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/reflect/scala/tools/nsc/io/Path.scala
index b8cf15bfcf..984c96dfbb 100644
--- a/src/compiler/scala/tools/nsc/io/Path.scala
+++ b/src/reflect/scala/tools/nsc/io/Path.scala
@@ -9,6 +9,7 @@ package io
import java.io.{
FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter,
BufferedInputStream, BufferedOutputStream, RandomAccessFile }
+import java.io.{ File => JFile }
import java.net.{ URI, URL }
import scala.util.Random.alphanumeric
import language.implicitConversions
@@ -42,7 +43,8 @@ object Path {
if (i < 0) ""
else name.substring(i + 1).toLowerCase
}
- def isJarOrZip(f: Path, examineFile: Boolean = true) = Jar.isJarOrZip(f, examineFile)
+ // [Eugene++] I hope that noone relied on this method
+// def isJarOrZip(f: Path, examineFile: Boolean = true) = Jar.isJarOrZip(f, examineFile)
// not certain these won't be problematic, but looks good so far
implicit def string2path(s: String): Path = apply(s)
diff --git a/src/compiler/scala/tools/nsc/io/PlainFile.scala b/src/reflect/scala/tools/nsc/io/PlainFile.scala
index 21276e8740..21276e8740 100644
--- a/src/compiler/scala/tools/nsc/io/PlainFile.scala
+++ b/src/reflect/scala/tools/nsc/io/PlainFile.scala
diff --git a/src/compiler/scala/tools/nsc/io/Streamable.scala b/src/reflect/scala/tools/nsc/io/Streamable.scala
index 03318674ee..03318674ee 100644
--- a/src/compiler/scala/tools/nsc/io/Streamable.scala
+++ b/src/reflect/scala/tools/nsc/io/Streamable.scala
diff --git a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala b/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala
index 0bcb2de43f..0bcb2de43f 100644
--- a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala
+++ b/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala
diff --git a/src/compiler/scala/tools/nsc/io/VirtualFile.scala b/src/reflect/scala/tools/nsc/io/VirtualFile.scala
index 450d86b599..b9a946598c 100644
--- a/src/compiler/scala/tools/nsc/io/VirtualFile.scala
+++ b/src/reflect/scala/tools/nsc/io/VirtualFile.scala
@@ -8,6 +8,7 @@ package scala.tools.nsc
package io
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream }
+import java.io.{ File => JFile }
/** This class implements an in-memory file.
*
diff --git a/src/compiler/scala/tools/nsc/io/ZipArchive.scala b/src/reflect/scala/tools/nsc/io/ZipArchive.scala
index 01f3619ba7..766b1fd093 100644
--- a/src/compiler/scala/tools/nsc/io/ZipArchive.scala
+++ b/src/reflect/scala/tools/nsc/io/ZipArchive.scala
@@ -8,6 +8,7 @@ package io
import java.net.URL
import java.io.{ IOException, InputStream, ByteArrayInputStream }
+import java.io.{ File => JFile }
import java.util.zip.{ ZipEntry, ZipFile, ZipInputStream }
import scala.collection.{ immutable, mutable }
import annotation.tailrec
diff --git a/src/scalacheck/org/scalacheck/Arbitrary.scala b/src/scalacheck/org/scalacheck/Arbitrary.scala
index 9bb235f917..28e116b479 100644
--- a/src/scalacheck/org/scalacheck/Arbitrary.scala
+++ b/src/scalacheck/org/scalacheck/Arbitrary.scala
@@ -10,6 +10,7 @@
package org.scalacheck
import util.{FreqMap,Buildable}
+import scala.reflect.ClassTag
sealed abstract class Arbitrary[T] {
val arbitrary: Gen[T]
diff --git a/src/scalacheck/org/scalacheck/util/Buildable.scala b/src/scalacheck/org/scalacheck/util/Buildable.scala
index 662bc6146b..5c960c3ba8 100644
--- a/src/scalacheck/org/scalacheck/util/Buildable.scala
+++ b/src/scalacheck/org/scalacheck/util/Buildable.scala
@@ -10,6 +10,7 @@
package org.scalacheck.util
import scala.collection._
+import scala.reflect.ClassTag
trait Buildable[T,C[_]] {
def builder: mutable.Builder[T,C[T]]
diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
index aa454934c1..411a87e4bb 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
@@ -156,7 +156,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
val printer = new ScalaSigPrinter(stream, printPrivates)
printer.printMethodType(m.infoType, false)(())
baos.toString
- case None =>
+ case _ =>
""
}
}
diff --git a/test/disabled/lib b/test/disabled/lib
deleted file mode 120000
index c1294f7c38..0000000000
--- a/test/disabled/lib
+++ /dev/null
@@ -1 +0,0 @@
-../files/lib \ No newline at end of file
diff --git a/test/disabled/run/code.check b/test/disabled/run/code.check
deleted file mode 100644
index 23263600ea..0000000000
--- a/test/disabled/run/code.check
+++ /dev/null
@@ -1,18 +0,0 @@
-testing: ((x: Int) => x.$plus(ys.length))
-result = ((x: Int) => x.+{(x: <?>)Int}(ys.length{Int}){Int}){Int => Int}
-testing: (() => {
- val e: Element = new Element("someName");
- e
-})
-result = (() => {
- val e: Element = new Element{Element}{(name: <?>)Element}("someName"{String("someName")}){Element};
- e{Element}
-}{Element}){() => Element}
-testing: (() => truc.elem = 6)
-result = (() => truc.elem{Int} = 6{Int(6)}{Unit}){() => Unit}
-testing: (() => truc.elem = truc.elem.$plus(6))
-result = (() => truc.elem{Int} = truc.elem.+{(x: <?>)Int}(6{Int(6)}){Int}{Unit}){() => Unit}
-testing: (() => new baz.BazElement("someName"))
-result = (() => new baz.BazElement{baz.BazElement}{(name: <?>)baz.BazElement}("someName"{String("someName")}){baz.BazElement}){() => baz.BazElement}
-testing: ((x: Int) => x.$plus(ys.length))
-result = ((x: Int) => x.+{(x: <?>)Int}(ys.length{Int}){Int}){Int => Int}
diff --git a/test/files/buildmanager/t2792/t2792.check b/test/files/buildmanager/t2792/t2792.check
index 68e14c6386..00a2b83469 100644
--- a/test/files/buildmanager/t2792/t2792.check
+++ b/test/files/buildmanager/t2792/t2792.check
@@ -9,3 +9,6 @@ compiling Set(A2.scala)
A2.scala:2: error: stable identifier required, but A.x found.
import A.x.y
^
+A2.scala:3: error: not found: value y
+ val z = y
+ ^
diff --git a/test/files/codelib/code.jar.desired.sha1 b/test/files/codelib/code.jar.desired.sha1
index 21c4dccb30..d2b8d9add9 100644
--- a/test/files/codelib/code.jar.desired.sha1
+++ b/test/files/codelib/code.jar.desired.sha1
@@ -1 +1 @@
-3ddb9fded6e19ca591a78b8a294284c9e945da30 ?code.jar
+e737b123d31eede5594ceda07caafed1673ec472 ?code.jar
diff --git a/test/files/jvm/actmig-PinS.check b/test/files/jvm/actmig-PinS.check
deleted file mode 100644
index 97d1c5be02..0000000000
--- a/test/files/jvm/actmig-PinS.check
+++ /dev/null
@@ -1,18 +0,0 @@
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-received message: hi there
-received message: 15
-Got an Int: 12
diff --git a/test/files/jvm/actmig-PinS.scala b/test/files/jvm/actmig-PinS.scala
deleted file mode 100644
index db5713dde4..0000000000
--- a/test/files/jvm/actmig-PinS.scala
+++ /dev/null
@@ -1,118 +0,0 @@
-import scala.actors._
-
-import scala.actors.Actor._
-
-/* PinS, Listing 32.1: A simple actor
- */
-object SillyActor extends Actor {
- def act() {
- for (i <- 1 to 5) {
- println("I'm acting!")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- }
-}
-
-object SeriousActor extends Actor {
- def act() {
- for (i <- 1 to 5) {
- println("To be or not to be.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- }
-}
-
-/* PinS, Listing 32.3: An actor that calls react
- */
-object NameResolver extends Actor {
- import java.net.{InetAddress, UnknownHostException}
-
- def act() {
- react {
- case (name: String, actor: Actor) =>
- actor ! getIp(name)
- act()
- case "EXIT" =>
- println("Name resolver exiting.")
- // quit
- case msg =>
- println("Unhandled message: " + msg)
- act()
- }
- }
-
- def getIp(name: String): Option[InetAddress] = {
- try {
- Some(InetAddress.getByName(name))
- } catch {
- case _: UnknownHostException => None
- }
- }
-
-}
-
-object Test extends App {
-
- /* PinS, Listing 32.2: An actor that calls receive
- */
- def makeEchoActor(): Actor = actor {
- while (true) {
- receive {
- case 'stop =>
- exit()
- case msg =>
- println("received message: " + msg)
- }
- }
- }
-
- /* PinS, page 696
- */
- def makeIntActor(): Actor = actor {
- receive {
- case x: Int => // I only want Ints
- println("Got an Int: " + x)
- }
- }
-
-
- actor {
- self.trapExit = true
- self.link(SillyActor)
- SillyActor.start()
-
- react {
- case Exit(SillyActor, _) =>
- self.link(SeriousActor)
- SeriousActor.start()
- react {
- case Exit(SeriousActor, _) =>
- // PinS, page 694
- val seriousActor2 = actor {
- for (i <- 1 to 5)
- println("That is the question.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
-
- Thread.sleep(200)
- val echoActor = makeEchoActor()
- self.link(echoActor)
- echoActor ! "hi there"
- echoActor ! 15
- echoActor ! 'stop
-
- react {
- case Exit(_, _) =>
- val intActor = makeIntActor()
- intActor ! "hello"
- intActor ! math.Pi
- // only the following send leads to output
- intActor ! 12
- }
- }
- }
- }
-}
diff --git a/test/files/jvm/actmig-PinS_1.check b/test/files/jvm/actmig-PinS_1.check
deleted file mode 100644
index 97d1c5be02..0000000000
--- a/test/files/jvm/actmig-PinS_1.check
+++ /dev/null
@@ -1,18 +0,0 @@
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-received message: hi there
-received message: 15
-Got an Int: 12
diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala
deleted file mode 100644
index d203526513..0000000000
--- a/test/files/jvm/actmig-PinS_1.scala
+++ /dev/null
@@ -1,130 +0,0 @@
-import scala.actors._
-
-object SillyActor {
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "akka.actor.default-stash-dispatcher"))
-}
-
-/* PinS, Listing 32.1: A simple actor
- */
-class SillyActor extends Actor {
- def act() {
- for (i <- 1 to 5) {
- println("I'm acting!")
- Thread.sleep(10)
- }
- }
-}
-
-object SeriousActor {
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "akka.actor.default-stash-dispatcher"))
-}
-
-class SeriousActor extends Actor {
- def act() {
- for (i <- 1 to 5) {
- println("To be or not to be.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- }
-}
-
-/* PinS, Listing 32.3: An actor that calls react
- */
-object NameResolver extends Actor {
- import java.net.{ InetAddress, UnknownHostException }
-
- def act() {
- react {
- case (name: String, actor: Actor) =>
- actor ! getIp(name)
- act()
- case "EXIT" =>
- println("Name resolver exiting.")
- // quit
- case msg =>
- println("Unhandled message: " + msg)
- act()
- }
- }
-
- def getIp(name: String): Option[InetAddress] = {
- try {
- Some(InetAddress.getByName(name))
- } catch {
- case _: UnknownHostException => None
- }
- }
-
-}
-
-object Test extends App {
-
- /* PinS, Listing 32.2: An actor that calls receive
- */
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() => new Actor {
- def act() {
- while (true) {
- receive {
- case 'stop =>
- exit()
- case msg =>
- println("received message: " + msg)
- }
- }
- }
- }, "akka.actor.default-stash-dispatcher"))
-
- /* PinS, page 696
- */
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() => new Actor {
- def act() {
- receive {
- case x: Int => // I only want Ints
- println("Got an Int: " + x)
- }
- }
- }, "akka.actor.default-stash-dispatcher"))
-
- MigrationSystem.actorOf(Props(() => new Actor {
- def act() {
- trapExit = true
- link(SillyActor.ref)
- react {
- case Exit(_: SillyActor, _) =>
- link(SeriousActor.ref)
- react {
- case Exit(_: SeriousActor, _) =>
- // PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() =>
- new Actor {
- def act() {
- for (i <- 1 to 5) {
- println("That is the question.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- }
- }
- , "akka.actor.default-stash-dispatcher"))
-
- Thread.sleep(200)
- val echoActor = makeEchoActor()
- link(echoActor)
- echoActor ! "hi there"
- echoActor ! 15
- echoActor ! 'stop
-
- react {
- case Exit(_, _) =>
- val intActor = makeIntActor()
- intActor ! "hello"
- intActor ! math.Pi
- // only the following send leads to output
- intActor ! 12
- }
- }
- }
- }
- }, "akka.actor.default-stash-dispatcher"))
-}
diff --git a/test/files/jvm/actmig-PinS_2.check b/test/files/jvm/actmig-PinS_2.check
deleted file mode 100644
index 97d1c5be02..0000000000
--- a/test/files/jvm/actmig-PinS_2.check
+++ /dev/null
@@ -1,18 +0,0 @@
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-received message: hi there
-received message: 15
-Got an Int: 12
diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala
deleted file mode 100644
index 9f52cca369..0000000000
--- a/test/files/jvm/actmig-PinS_2.scala
+++ /dev/null
@@ -1,150 +0,0 @@
-import scala.actors.{ MigrationSystem, StashingActor, ActorRef, Props, Exit }
-
-object SillyActor {
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "default-stash-dispatcher"))
-}
-
-/* PinS, Listing 32.1: A simple actor
- */
-class SillyActor extends StashingActor {
-
- def receive = { case _ => println("Nop") }
-
- override def act() {
- for (i <- 1 to 5) {
- println("I'm acting!")
- Thread.sleep(10)
- }
- }
-}
-
-object SeriousActor {
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "default-stash-dispatcher"))
-}
-
-class SeriousActor extends StashingActor {
- def receive = { case _ => println("Nop") }
- override def act() {
- for (i <- 1 to 5) {
- println("To be or not to be.")
- Thread.sleep(10)
- }
- }
-}
-
-/* PinS, Listing 32.3: An actor that calls react
- */
-object NameResolver {
- val ref = MigrationSystem.actorOf(Props(() => new NameResolver, "default-stash-dispatcher"))
-}
-
-class NameResolver extends StashingActor {
- import java.net.{ InetAddress, UnknownHostException }
-
- def receive = { case _ => println("Nop") }
-
- override def act() {
- react {
- case (name: String, actor: ActorRef) =>
- actor ! getIp(name)
- act()
- case "EXIT" =>
- println("Name resolver exiting.")
- // quit
- case msg =>
- println("Unhandled message: " + msg)
- act()
- }
- }
-
- def getIp(name: String): Option[InetAddress] = {
- try {
- Some(InetAddress.getByName(name))
- } catch {
- case _: UnknownHostException => None
- }
- }
-
-}
-
-object Test extends App {
-
- /* PinS, Listing 32.2: An actor that calls receive
- */
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() =>
- new StashingActor {
- def receive = { case _ => println("Nop") }
-
- override def act() {
- loop {
- react {
- case 'stop =>
- exit()
- case msg =>
- println("received message: " + msg)
- }
- }
- }
- }, "default-stash-dispatcher"))
-
- /* PinS, page 696
- */
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() =>new StashingActor {
-
- def receive = { case _ => println("Nop") }
-
- override def act() {
- react {
- case x: Int => // I only want Ints
- println("Got an Int: " + x)
- }
- }
- }, "default-stash-dispatcher"))
-
- MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = { case _ => println("Nop") }
-
- override def act() {
- trapExit = true
- link(SillyActor.ref)
- react {
- case Exit(_: SillyActor, _) =>
- link(SeriousActor.ref)
- react {
- case Exit(_: SeriousActor, _) =>
- // PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() =>{
- new StashingActor {
-
- def receive = { case _ => println("Nop") }
-
- override def act() {
- for (i <- 1 to 5) {
- println("That is the question.")
- Thread.sleep(10)
- }
- }
- }
- }, "default-stash-dispatcher"))
-
- Thread.sleep(200)
- val echoActor = makeEchoActor()
- link(echoActor)
- echoActor ! "hi there"
- echoActor ! 15
- echoActor ! 'stop
-
- react {
- case Exit(_, _) =>
- val intActor = makeIntActor()
- intActor ! "hello"
- intActor ! math.Pi
- // only the following send leads to output
- intActor ! 12
- }
- }
- }
- }
- }, "default-stash-dispatcher"))
-}
diff --git a/test/files/jvm/actmig-PinS_3.check b/test/files/jvm/actmig-PinS_3.check
deleted file mode 100644
index bdbdf8a692..0000000000
--- a/test/files/jvm/actmig-PinS_3.check
+++ /dev/null
@@ -1,19 +0,0 @@
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-I'm acting!
-Post stop
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-To be or not to be.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-That is the question.
-received message: hi there
-received message: 15
-Got an Int: 12
diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala
deleted file mode 100644
index 047bf53c32..0000000000
--- a/test/files/jvm/actmig-PinS_3.scala
+++ /dev/null
@@ -1,159 +0,0 @@
-import scala.actors.{ MigrationSystem, StashingActor, ActorRef, Terminated, Props }
-
-object SillyActor {
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "default-stash-dispatcher"))
-}
-
-/* PinS, Listing 32.1: A simple actor
- */
-class SillyActor extends StashingActor {
- def receive = { case _ => println("Why are you not dead"); context.stop(self) }
-
- override def preStart() {
- for (i <- 1 to 5) {
- println("I'm acting!")
- Thread.sleep(10)
- }
- context.stop(self)
- }
-
- override def postStop() {
- println("Post stop")
- }
-}
-
-object SeriousActor {
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "default-stash-dispatcher"))
-}
-
-class SeriousActor extends StashingActor {
- def receive = { case _ => println("Nop") }
- override def preStart() {
- for (i <- 1 to 5) {
- println("To be or not to be.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- context.stop(self)
- }
-}
-
-/* PinS, Listing 32.3: An actor that calls react
- */
-object NameResolver {
- val ref = MigrationSystem.actorOf(Props(() => new NameResolver, "default-stash-dispatcher"))
-}
-
-class NameResolver extends StashingActor {
- import java.net.{ InetAddress, UnknownHostException }
-
- def receive = {
- case (name: String, actor: ActorRef) =>
- actor ! getIp(name)
- case "EXIT" =>
- println("Name resolver exiting.")
- context.stop(self) // quit
- case msg =>
- println("Unhandled message: " + msg)
- }
-
- def getIp(name: String): Option[InetAddress] = {
- try {
- Some(InetAddress.getByName(name))
- } catch {
- case _: UnknownHostException => None
- }
- }
-
-}
-
-object Test extends App {
-
- /* PinS, Listing 32.2: An actor that calls receive
- */
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = { // how to handle receive
- case 'stop =>
- context.stop(self)
- case msg =>
- println("received message: " + msg)
- }
- }, "default-stash-dispatcher"))
-
- /* PinS, page 696
- */
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = {
- case x: Int => // I only want Ints
- unstashAll()
- println("Got an Int: " + x)
- context.stop(self)
- case _ => stash()
- }
- }, "default-stash-dispatcher"))
-
- MigrationSystem.actorOf(Props(() => new StashingActor {
- val silly = SillyActor.ref
-
- override def preStart() {
- context.watch(SillyActor.ref)
- }
-
- def receive = {
- case Terminated(`silly`) =>
- unstashAll()
- val serious = SeriousActor.ref
- context.watch(SeriousActor.ref)
- context.become {
- case Terminated(`serious`) =>
- // PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() => {
- new StashingActor {
-
- def receive = { case _ => context.stop(self) }
-
- override def preStart() = {
- for (i <- 1 to 5) {
- println("That is the question.")
- //Thread.sleep(1000)
- Thread.sleep(10)
- }
- context.stop(self)
- }
- }
- }, "default-stash-dispatcher"))
-
- Thread.sleep(200)
- val echoActor = makeEchoActor()
- context.watch(echoActor)
- echoActor ! "hi there"
- echoActor ! 15
- echoActor ! 'stop
-
- context.become {
- case Terminated(_) =>
- unstashAll()
- val intActor = makeIntActor()
- intActor ! "hello"
- intActor ! math.Pi
- // only the following send leads to output
- intActor ! 12
- context.unbecome()
- context.unbecome()
- context.stop(self)
- case m =>
- println("Stash 1 " + m)
- stash(m)
- }
- case m =>
- println("Stash 2 " + m)
- stash(m)
- }
- case m =>
- println("Stash 3 " + m)
- stash(m)
- }
- }, "default-stash-dispatcher"))
-}
diff --git a/test/files/jvm/actmig-hierarchy.check b/test/files/jvm/actmig-hierarchy.check
deleted file mode 100644
index 317e9677c3..0000000000
--- a/test/files/jvm/actmig-hierarchy.check
+++ /dev/null
@@ -1,2 +0,0 @@
-hello
-hello
diff --git a/test/files/jvm/actmig-hierarchy.scala b/test/files/jvm/actmig-hierarchy.scala
deleted file mode 100644
index 7277329d85..0000000000
--- a/test/files/jvm/actmig-hierarchy.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-import scala.actors._
-
-
-class ReactorActor extends Reactor[String] {
- def act() {
- var cond = true
- loopWhile(cond) {
- react {
- case x if x == "hello1" => println(x.dropRight(1))
- case "exit" => cond = false
- }
- }
- }
-}
-
-class ReplyActor extends ReplyReactor {
- def act() {
- var cond = true
- loopWhile(cond) {
- react {
- case "hello" => println("hello")
- case "exit" => cond = false;
- }
- }
- }
-}
-
-
-
-object Test {
-
- def main(args: Array[String]) {
- val reactorActor = new ReactorActor
- val replyActor = new ReplyActor
- reactorActor.start()
- replyActor.start()
-
- reactorActor ! "hello1"
- replyActor ! "hello"
-
- reactorActor ! "exit"
- replyActor ! "exit"
- }
-}
diff --git a/test/files/jvm/actmig-hierarchy_1.check b/test/files/jvm/actmig-hierarchy_1.check
deleted file mode 100644
index 317e9677c3..0000000000
--- a/test/files/jvm/actmig-hierarchy_1.check
+++ /dev/null
@@ -1,2 +0,0 @@
-hello
-hello
diff --git a/test/files/jvm/actmig-hierarchy_1.scala b/test/files/jvm/actmig-hierarchy_1.scala
deleted file mode 100644
index 559ebe7b11..0000000000
--- a/test/files/jvm/actmig-hierarchy_1.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-import scala.actors._
-
-class ReactorActor extends Actor {
- def act() {
- var cond = true
- loopWhile(cond) {
- react {
- case x: String if x == "hello1" => println(x.dropRight(1))
- case "exit" => cond = false
- }
- }
- }
-}
-
-class ReplyActor extends Actor {
- def act() {
- var cond = true
- loopWhile(cond) {
- react {
- case "hello" => println("hello")
- case "exit" => cond = false;
- }
- }
- }
-}
-
-object Test {
-
- def main(args: Array[String]) {
- val reactorActor = new ReactorActor
- val replyActor = new ReplyActor
- reactorActor.start()
- replyActor.start()
-
- reactorActor ! "hello1"
- replyActor ! "hello"
-
- reactorActor ! "exit"
- replyActor ! "exit"
- }
-}
diff --git a/test/files/jvm/actmig-instantiation.check b/test/files/jvm/actmig-instantiation.check
deleted file mode 100644
index 4c13d5c0a1..0000000000
--- a/test/files/jvm/actmig-instantiation.check
+++ /dev/null
@@ -1,8 +0,0 @@
-OK error: java.lang.RuntimeException: In order to create StashingActor one must use actorOf.
-OK error: java.lang.RuntimeException: Only one actor can be created per actorOf call.
-0
-100
-200
-300
-400
-500
diff --git a/test/files/jvm/actmig-instantiation.scala b/test/files/jvm/actmig-instantiation.scala
deleted file mode 100644
index 4170dbd3ad..0000000000
--- a/test/files/jvm/actmig-instantiation.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-import scala.actors.MigrationSystem._
-import scala.actors.Actor._
-import scala.actors.{ Actor, StashingActor, ActorRef, Props, MigrationSystem, PoisonPill }
-import java.util.concurrent.{ TimeUnit, CountDownLatch }
-import scala.collection.mutable.ArrayBuffer
-
-class TestStashingActor extends StashingActor {
-
- def receive = { case v: Int => Test.append(v); Test.latch.countDown() }
-
-}
-
-object Test {
- val NUMBER_OF_TESTS = 5
-
- // used for sorting non-deterministic output
- val buff = ArrayBuffer[Int](0)
- val latch = new CountDownLatch(NUMBER_OF_TESTS)
- val toStop = ArrayBuffer[ActorRef]()
-
- def append(v: Int) = synchronized {
- buff += v
- }
-
- def main(args: Array[String]) = {
- // plain scala actor
- val a1 = actor {
- react { case v: Int => Test.append(v); Test.latch.countDown() }
- }
- a1 ! 100
-
- // simple instantiation
- val a2 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
- a2 ! 200
- toStop += a2
-
- // actor of with scala actor
- val a3 = actorOf(Props(() => actor {
- react { case v: Int => Test.append(v); Test.latch.countDown() }
- }, "akka.actor.default-stash-dispatcher"))
- a3 ! 300
-
- // using the manifest
- val a4 = actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
- a4 ! 400
- toStop += a4
-
- // deterministic part of a test
- // creation without actorOf
- try {
- val a3 = new TestStashingActor
- a3 ! -1
- } catch {
- case e => println("OK error: " + e)
- }
-
- // actorOf double creation
- try {
- val a3 = actorOf(Props(() => {
- new TestStashingActor
- new TestStashingActor
- }, "akka.actor.default-stash-dispatcher"))
- a3 ! -1
- } catch {
- case e => println("OK error: " + e)
- }
-
- // actorOf nesting
- try {
- val a5 = actorOf(Props(() => {
- val a6 = actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
- toStop += a6
- new TestStashingActor
- }, "akka.actor.default-stash-dispatcher"))
-
- a5 ! 500
- toStop += a5
- } catch {
- case e => println("Should not throw an exception: " + e)
- }
-
- // output
- latch.await(200, TimeUnit.MILLISECONDS)
- if (latch.getCount() > 0) {
- println("Error: Tasks have not finished!!!")
- }
-
- buff.sorted.foreach(println)
- toStop.foreach(_ ! PoisonPill)
- }
-}
diff --git a/test/files/jvm/actmig-loop-react.check b/test/files/jvm/actmig-loop-react.check
deleted file mode 100644
index 7b955aa9b9..0000000000
--- a/test/files/jvm/actmig-loop-react.check
+++ /dev/null
@@ -1,16 +0,0 @@
-do task
-do task
-do task
-do task
-working
-scala got exception
-working
-akka got exception
-do task 1
-do string I am a String
-do task 42
-after react
-Terminated
-do task 1
-do string I am a String
-do task 42
diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala
deleted file mode 100644
index 8452f9766a..0000000000
--- a/test/files/jvm/actmig-loop-react.scala
+++ /dev/null
@@ -1,170 +0,0 @@
-import scala.actors.MigrationSystem._
-import scala.actors.Actor._
-import scala.actors.{ Actor, StashingActor, ActorRef, Props, MigrationSystem, PoisonPill }
-import java.util.concurrent.{ TimeUnit, CountDownLatch }
-import scala.collection.mutable.ArrayBuffer
-
-object Test {
-
- def testLoopWithConditionReact() = {
- // Snippet showing composition of receives
- // Loop with Condition Snippet - before
- val myActor = actor {
- var c = true
- loopWhile(c) {
- react {
- case x: Int =>
- // do task
- println("do task")
- if (x == 42) c = false
- }
- }
- }
-
- myActor.start()
- myActor ! 1
- myActor ! 42
-
- // Loop with Condition Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = {
- case x: Int =>
- // do task
- println("do task")
- if (x == 42) context.stop(self)
- }
- }, "default-stashing-dispatcher"))
- myAkkaActor ! 1
- myAkkaActor ! 42
- }
-
- def testNestedReact() = {
- // Snippet showing composition of receives
- // Loop with Condition Snippet - before
- val myActor = actor {
- var c = true
- loopWhile(c) {
- react {
- case x: Int =>
- // do task
- println("do task " + x)
- if (x == 42) c = false
- else
- react {
- case y: String =>
- println("do string " + y)
- }
- println("after react")
- }
- }
- }
- myActor.start()
-
- myActor ! 1
- myActor ! "I am a String"
- myActor ! 42
-
- Thread.sleep(100)
- println(myActor.getState)
-
- // Loop with Condition Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = {
- case x: Int =>
- // do task
- println("do task " + x)
- if (x == 42)
- context.stop(self)
- else
- context.become(({
- case y: String =>
- println("do string " + y)
- }: Receive).andThen(x => {
- unstashAll()
- context.unbecome()
- }).orElse { case x => stash() })
- }
- }, "default-stashing-dispatcher"))
-
- myAkkaActor ! 1
- myAkkaActor ! "I am a String"
- myAkkaActor ! 42
-
- }
-
- def exceptionHandling() = {
- // Stashing actor with act and exception handler
- val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
-
- def receive = { case _ => println("Dummy method.") }
- override def act() = {
- loop {
- react {
- case "fail" =>
- throw new Exception("failed")
- case "work" =>
- println("working")
- case "die" =>
- exit()
- }
- }
- }
-
- override def exceptionHandler = {
- case x: Exception => println("scala got exception")
- }
-
- }, "default-stashing-dispatcher"))
-
- myActor ! "work"
- myActor ! "fail"
- myActor ! "die"
-
- Thread.sleep(100)
- // Stashing actor in Akka style
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
- def receive = PFCatch({
- case "fail" =>
- throw new Exception("failed")
- case "work" =>
- println("working")
- case "die" =>
- context.stop(self)
- }, { case x: Exception => println("akka got exception") })
- }, "default-stashing-dispatcher"))
-
- myAkkaActor ! "work"
- myAkkaActor ! "fail"
- myAkkaActor ! "die"
- }
-
- def main(args: Array[String]) = {
- testLoopWithConditionReact()
- Thread.sleep(100)
- exceptionHandling()
- Thread.sleep(100)
- testNestedReact()
- }
-
-}
-
-// As per Jim Mcbeath blog (http://jim-mcbeath.blogspot.com/2008/07/actor-exceptions.html)
-class PFCatch(f: PartialFunction[Any, Unit], handler: PartialFunction[Exception, Unit])
- extends PartialFunction[Any, Unit] {
-
- def apply(x: Any) = {
- try {
- f(x)
- } catch {
- case e: Exception if handler.isDefinedAt(e) => handler(e)
- }
- }
-
- def isDefinedAt(x: Any) = f.isDefinedAt(x)
-}
-
-object PFCatch {
- def apply(f: PartialFunction[Any, Unit], handler: PartialFunction[Exception, Unit]) = new PFCatch(f, handler)
-}
diff --git a/test/files/jvm/actmig-public-methods.check b/test/files/jvm/actmig-public-methods.check
deleted file mode 100644
index bb6530c926..0000000000
--- a/test/files/jvm/actmig-public-methods.check
+++ /dev/null
@@ -1,6 +0,0 @@
-None
-Some(bang qmark after 1)
-bang
-bang qmark after 0
-bang qmark in future after 0
-typed bang qmark in future after 0
diff --git a/test/files/jvm/actmig-public-methods.scala b/test/files/jvm/actmig-public-methods.scala
deleted file mode 100644
index c4c8560122..0000000000
--- a/test/files/jvm/actmig-public-methods.scala
+++ /dev/null
@@ -1,69 +0,0 @@
-import scala.collection.mutable.ArrayBuffer
-import scala.actors.Actor._
-import scala.actors._
-import scala.actors.MigrationSystem
-import scala.util.continuations._
-import java.util.concurrent.{ TimeUnit, CountDownLatch }
-
-object Test {
- val NUMBER_OF_TESTS = 6
-
- // used for sorting non-deterministic output
- val buff = ArrayBuffer[String]()
- val latch = new CountDownLatch(NUMBER_OF_TESTS)
- val toStop = ArrayBuffer[Actor]()
-
- def append(v: String) = synchronized {
- buff += v
- }
-
- def main(args: Array[String]) = {
-
- val respActor = actor {
- loop {
- react {
- case (x: String, time: Long) =>
- Thread.sleep(time)
- reply(x + " after " + time)
- case str: String =>
- append(str)
- latch.countDown()
- case _ => exit()
- }
- }
- }
-
- toStop += respActor
-
- respActor ! ("bang")
-
- val res1 = respActor !? (("bang qmark", 0L))
- append(res1.toString)
- latch.countDown()
-
- val res2 = respActor !? (200, ("bang qmark", 1L))
- append(res2.toString)
- latch.countDown()
-
- val res21 = respActor !? (1, ("bang qmark", 200L))
- append(res21.toString)
- latch.countDown()
-
- val fut1 = respActor !! (("bang qmark in future", 0L))
- append(fut1().toString())
- latch.countDown()
-
- val fut2 = respActor !! (("typed bang qmark in future", 0L), { case x: String => x })
- append(fut2())
- latch.countDown()
-
- // output
- latch.await(10, TimeUnit.MILLISECONDS)
- if (latch.getCount() > 0) {
- println("Error: Tasks have not finished!!!")
- }
-
- buff.sorted.foreach(println)
- toStop.foreach(_ ! 'stop)
- }
-}
diff --git a/test/files/jvm/actmig-public-methods_1.check b/test/files/jvm/actmig-public-methods_1.check
deleted file mode 100644
index bb6530c926..0000000000
--- a/test/files/jvm/actmig-public-methods_1.check
+++ /dev/null
@@ -1,6 +0,0 @@
-None
-Some(bang qmark after 1)
-bang
-bang qmark after 0
-bang qmark in future after 0
-typed bang qmark in future after 0
diff --git a/test/files/jvm/actmig-public-methods_1.scala b/test/files/jvm/actmig-public-methods_1.scala
deleted file mode 100644
index 41798c4c37..0000000000
--- a/test/files/jvm/actmig-public-methods_1.scala
+++ /dev/null
@@ -1,88 +0,0 @@
-import scala.collection.mutable.ArrayBuffer
-import scala.actors.Actor._
-import scala.actors._
-import scala.util._
-import java.util.concurrent.{ TimeUnit, CountDownLatch }
-import scala.concurrent.util.Duration
-import scala.actors.pattern._
-
-object Test {
- val NUMBER_OF_TESTS = 6
-
- // used for sorting non-deterministic output
- val buff = ArrayBuffer[String]()
- val latch = new CountDownLatch(NUMBER_OF_TESTS)
- val toStop = ArrayBuffer[ActorRef]()
-
- def append(v: String) = synchronized {
- buff += v
- }
-
- def main(args: Array[String]) = {
-
- val respActor = MigrationSystem.actorOf(Props(() => actor {
- loop {
- react {
- case (x: String, time: Long) =>
- Thread.sleep(time)
- reply(x + " after " + time)
- case str: String =>
- append(str)
- latch.countDown()
- case x =>
- exit()
- }
- }
- }, "akka.actor.default-stash-dispatcher"))
-
- toStop += respActor
-
- respActor ! "bang"
-
- implicit val timeout = Timeout(Duration(200, TimeUnit.MILLISECONDS))
- val msg = ("bang qmark", 0L)
- val res1 = respActor.?(msg)(Timeout(Duration.Inf))
- append(res1().toString)
- latch.countDown()
-
- val msg1 = ("bang qmark", 1L)
- val res2 = respActor.?(msg1)(Timeout(Duration(200, TimeUnit.MILLISECONDS)))
- append((res2() match {
- case x: AskTimeoutException => None
- case v => Some(v)
- }).toString)
- latch.countDown()
-
- // this one should time out
- val msg11 = ("bang qmark", 200L)
- val res21 = respActor.?(msg11)(Timeout(Duration(1, TimeUnit.MILLISECONDS)))
- append((res21() match {
- case x: AskTimeoutException => None
- case v => Some(v)
- }).toString)
- latch.countDown()
-
- val msg2 = ("bang qmark in future", 0L)
- val fut1 = respActor.?(msg2)(Duration.Inf)
- append(fut1().toString())
- latch.countDown()
-
- val handler: PartialFunction[Any, String] = {
- case x: String => x.toString
- }
-
- val msg3 = ("typed bang qmark in future", 0L)
- val fut2 = (respActor.?(msg3)(Duration.Inf))
- append(Futures.future { handler.apply(fut2()) }().toString)
- latch.countDown()
-
- // output
- latch.await(10, TimeUnit.MILLISECONDS)
- if (latch.getCount() > 0) {
- println("Error: Tasks have not finished!!!")
- }
-
- buff.sorted.foreach(println)
- toStop.foreach(_ ! PoisonPill)
- }
-}
diff --git a/test/files/jvm/actmig-react-receive.check b/test/files/jvm/actmig-react-receive.check
deleted file mode 100644
index cc2a426e68..0000000000
--- a/test/files/jvm/actmig-react-receive.check
+++ /dev/null
@@ -1,16 +0,0 @@
-do before
-do task
-do after
-do before
-do task
-do after
-do before
-do task
-do in between
-do string
-do after
-do before
-do task
-do in between
-do string
-do after
diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala
deleted file mode 100644
index fbc10a8d52..0000000000
--- a/test/files/jvm/actmig-react-receive.scala
+++ /dev/null
@@ -1,104 +0,0 @@
-import scala.actors.MigrationSystem._
-import scala.actors.Actor._
-import scala.actors.{ Actor, StashingActor, ActorRef, Props, MigrationSystem, PoisonPill }
-import java.util.concurrent.{ TimeUnit, CountDownLatch }
-import scala.collection.mutable.ArrayBuffer
-
-object Test {
-
- def testComposition() = {
- // Snippet showing composition of receives
- // React Snippet - before
- val myActor = actor {
- // do before
- println("do before")
- receive {
- case x: Int =>
- // do task
- println("do task")
- }
- println("do in between")
- receive {
- case x: String =>
- // do string now
- println("do string")
- }
- println("do after")
- }
- myActor.start()
- myActor ! 1
- myActor ! "1"
- Thread.sleep(200)
- // React Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
- override def preStart() = {
- println("do before")
- }
-
- def receive = ({
- case x: Int =>
- // do task
- println("do task")
- }: Receive) andThen { v =>
- context.become {
- case x: String =>
- //do string
- println("do string")
- context.stop(self)
- }
- println("do in between")
- }
-
- override def postStop() = {
- println("do after")
- }
-
- }, "default-stashing-dispatcher"))
- myAkkaActor ! 1
- myAkkaActor ! "1"
- Thread.sleep(200)
- }
-
- def main(args: Array[String]) = {
- // React Snippet - before
- val myActor = actor {
- // do before
- println("do before")
- receive {
- case x: Int =>
- // do task
- println("do task")
- }
- println("do after")
- }
- myActor.start()
- myActor ! 1
-
- Thread.sleep(200)
-
- // React Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
- override def preStart() = {
- println("do before")
- }
-
- def receive = {
- case x: Int =>
- // do task
- println("do task")
- context.stop(self)
- }
-
- override def postStop() = {
- println("do after")
- }
-
- }, "default-stashing-dispatcher"))
- myAkkaActor ! 1
-
- Thread.sleep(200)
- // Starting composition test
- testComposition()
-
- }
-}
diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check
index 896a5c1cef..9ff49ef8b4 100644
--- a/test/files/jvm/manifests-new.check
+++ b/test/files/jvm/manifests-new.check
@@ -1,38 +1,38 @@
-x=(), t=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit
-x=true, t=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean
-x=a, t=ConcreteTypeTag[Char], k=TypeRef, s=class Char
-x=1, t=ConcreteTypeTag[Int], k=TypeRef, s=class Int
-x=abc, t=ConcreteTypeTag[String], k=TypeRef, s=class String
-x='abc, t=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol
-
-x=List(()), t=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List
-x=List(true), t=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List
-x=List(1), t=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List
-x=List(abc), t=ConcreteTypeTag[List[String]], k=TypeRef, s=class List
-x=List('abc), t=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List
-
-x=[Z, t=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array
-x=[C, t=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array
-x=[I, t=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array
-x=[Ljava.lang.String;, t=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array
-x=[Lscala.Symbol;, t=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array
-
-x=((),()), t=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
-x=(true,false), t=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
-x=(1,2), t=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
-x=(abc,xyz), t=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2
-x=('abc,'xyz), t=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
-
-x=Test$, t=ConcreteTypeTag[Test.type], k=SingleType, s=object Test
-x=scala.collection.immutable.List$, t=ConcreteTypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List
-
-x=Foo, t=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
-x=Foo, t=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
-
-x=Test1$$anon$1, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-x=Test1$$anon$2, t=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+x=(), t=TypeTag[Unit], k=TypeRef, s=class Unit
+x=true, t=TypeTag[Boolean], k=TypeRef, s=class Boolean
+x=a, t=TypeTag[Char], k=TypeRef, s=class Char
+x=1, t=TypeTag[Int], k=TypeRef, s=class Int
+x=abc, t=TypeTag[java.lang.String], k=TypeRef, s=class String
+x='abc, t=TypeTag[Symbol], k=TypeRef, s=class Symbol
+
+x=List(()), t=TypeTag[List[Unit]], k=TypeRef, s=class List
+x=List(true), t=TypeTag[List[Boolean]], k=TypeRef, s=class List
+x=List(1), t=TypeTag[List[Int]], k=TypeRef, s=class List
+x=List(abc), t=TypeTag[List[java.lang.String]], k=TypeRef, s=class List
+x=List('abc), t=TypeTag[List[Symbol]], k=TypeRef, s=class List
+
+x=[Z, t=TypeTag[Array[Boolean]], k=TypeRef, s=class Array
+x=[C, t=TypeTag[Array[Char]], k=TypeRef, s=class Array
+x=[I, t=TypeTag[Array[Int]], k=TypeRef, s=class Array
+x=[Ljava.lang.String;, t=TypeTag[Array[java.lang.String]], k=TypeRef, s=class Array
+x=[Lscala.Symbol;, t=TypeTag[Array[Symbol]], k=TypeRef, s=class Array
+
+x=((),()), t=TypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
+x=(true,false), t=TypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
+x=(1,2), t=TypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
+x=(abc,xyz), t=TypeTag[(java.lang.String, java.lang.String)], k=TypeRef, s=class Tuple2
+x=('abc,'xyz), t=TypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
+
+x=Test$, t=TypeTag[Test.type], k=SingleType, s=object Test
+x=scala.collection.immutable.List$, t=TypeTag[scala.collection.immutable.List.type], k=SingleType, s=object List
+
+x=Foo, t=TypeTag[Foo[Int]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
+x=Foo, t=TypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
+
+x=Test1$$anon$1, t=TypeTag[Bar[java.lang.String]], k=RefinedType, s=<local Test1>
+x=Test1$$anon$2, t=TypeTag[Bar[java.lang.String]], k=RefinedType, s=<local Test1>
()=()
true=true
diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala
index d02f6ee608..8706881640 100644
--- a/test/files/jvm/manifests-new.scala
+++ b/test/files/jvm/manifests-new.scala
@@ -1,3 +1,6 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
Test1
Test2
@@ -58,12 +61,12 @@ object Test2 {
println("true="+load[Boolean](dump(true)))
println("a="+load[Char](dump('a')))
println("1="+load[Int](dump(1)))
- println("'abc="+load[Symbol](dump('abc)))
+ println("'abc="+load[scala.Symbol](dump('abc)))
println()
println("List(())="+load[List[Unit]](dump(List(()))))
println("List(true)="+load[List[Boolean]](dump(List(true))))
- println("List('abc)="+load[List[Symbol]](dump(List('abc))))
+ println("List('abc)="+load[List[scala.Symbol]](dump(List('abc))))
println()
def loadArray[T](x: Array[Byte])(implicit t: reflect.ClassTag[Array[T]]) =
@@ -98,12 +101,11 @@ trait TestUtil {
val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
in.readObject().asInstanceOf[A]
}
- import scala.reflect._
- def print[T](x: T)(implicit t: ConcreteTypeTag[T]) {
+ def print[T](x: T)(implicit t: TypeTag[T]) {
// todo. type tags are not yet serializable
-// val t1: ConcreteTypeTag[T] = read(write(t))
- val t1: ConcreteTypeTag[T] = t
+// val t1: TypeTag[T] = read(write(t))
+ val t1: TypeTag[T] = t
val x1 = x.toString.replaceAll("@[0-9a-z]+$", "")
- println("x="+x1+", t="+t1+", k="+t1.tpe.kind+", s="+t1.sym.toString)
+ println("x="+x1+", t="+t1+", k="+t1.tpe.kind+", s="+t1.tpe.typeSymbol.toString)
}
-}
+} \ No newline at end of file
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index 86655ad89c..012460147a 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -808,6 +808,126 @@ trait TryEitherExtractor extends TestBase {
testLeftMatch()
}
+trait CustomExecutionContext extends TestBase {
+ import scala.concurrent.{ ExecutionContext, Awaitable }
+
+ def defaultEC = ExecutionContext.defaultExecutionContext
+
+ val inEC = new java.lang.ThreadLocal[Int]() {
+ override def initialValue = 0
+ }
+
+ def enterEC() = inEC.set(inEC.get + 1)
+ def leaveEC() = inEC.set(inEC.get - 1)
+ def assertEC() = assert(inEC.get > 0)
+ def assertNoEC() = assert(inEC.get == 0)
+
+ class CountingExecutionContext extends ExecutionContext {
+ val _count = new java.util.concurrent.atomic.AtomicInteger(0)
+ def count = _count.get
+
+ def delegate = ExecutionContext.defaultExecutionContext
+
+ override def execute(runnable: Runnable) = {
+ _count.incrementAndGet()
+ val wrapper = new Runnable() {
+ override def run() = {
+ enterEC()
+ try {
+ runnable.run()
+ } finally {
+ leaveEC()
+ }
+ }
+ }
+ delegate.execute(wrapper)
+ }
+
+ override def internalBlockingCall[T](awaitable: Awaitable[T], atMost: Duration): T =
+ delegate.internalBlockingCall(awaitable, atMost)
+
+ override def reportFailure(t: Throwable): Unit = {
+ System.err.println("Failure: " + t.getClass.getSimpleName + ": " + t.getMessage)
+ delegate.reportFailure(t)
+ }
+ }
+
+ def countExecs(block: (ExecutionContext) => Unit): Int = {
+ val context = new CountingExecutionContext()
+ block(context)
+ context.count
+ }
+
+ def testOnSuccessCustomEC(): Unit = {
+ val count = countExecs { implicit ec =>
+ once { done =>
+ val f = future({ assertNoEC() })(defaultEC)
+ f onSuccess {
+ case _ =>
+ assertEC()
+ done()
+ }
+ assertNoEC()
+ }
+ }
+
+ // should be onSuccess, but not future body
+ assert(count == 1)
+ }
+
+ def testKeptPromiseCustomEC(): Unit = {
+ val count = countExecs { implicit ec =>
+ once { done =>
+ val f = Promise.successful(10).future
+ f onSuccess {
+ case _ =>
+ assertEC()
+ done()
+ }
+ }
+ }
+
+ // should be onSuccess called once in proper EC
+ assert(count == 1)
+ }
+
+ def testCallbackChainCustomEC(): Unit = {
+ val count = countExecs { implicit ec =>
+ once { done =>
+ assertNoEC()
+ val addOne = { x: Int => assertEC(); x + 1 }
+ val f = Promise.successful(10).future
+ f.map(addOne).filter { x =>
+ assertEC()
+ x == 11
+ } flatMap { x =>
+ Promise.successful(x + 1).future.map(addOne).map(addOne)
+ } onComplete {
+ case Left(t) =>
+ try {
+ throw new AssertionError("error in test: " + t.getMessage, t)
+ } finally {
+ done()
+ }
+ case Right(x) =>
+ assertEC()
+ assert(x == 14)
+ done()
+ }
+ assertNoEC()
+ }
+ }
+
+ // the count is not defined (other than >=1)
+ // due to the batching optimizations.
+ assert(count >= 1)
+ }
+
+ testOnSuccessCustomEC()
+ testKeptPromiseCustomEC()
+ testCallbackChainCustomEC()
+}
+
object Test
extends App
with FutureCallbacks
@@ -816,6 +936,7 @@ with FutureProjections
with Promises
with Exceptions
with TryEitherExtractor
+with CustomExecutionContext
{
System.exit(0)
}
diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala
index bb971fdf36..91eb52928f 100644
--- a/test/files/jvm/serialization-new.scala
+++ b/test/files/jvm/serialization-new.scala
@@ -282,7 +282,7 @@ object Test2_immutable {
// Test classes in package "scala.collection.mutable"
object Test3_mutable {
- import scala.reflect.ArrayTag
+ import scala.reflect.ClassTag
import scala.collection.mutable.{
ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList,
HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue,
@@ -299,11 +299,11 @@ object Test3_mutable {
// ArrayBuilder
val abu1 = ArrayBuilder.make[Long]
- val _abu1: ArrayBuilder[ArrayTag[Long]] = read(write(abu1))
+ val _abu1: ArrayBuilder[ClassTag[Long]] = read(write(abu1))
check(abu1, _abu1)
val abu2 = ArrayBuilder.make[Float]
- val _abu2: ArrayBuilder[ArrayTag[Float]] = read(write(abu2))
+ val _abu2: ArrayBuilder[ClassTag[Float]] = read(write(abu2))
check(abu2, _abu2)
// ArraySeq
@@ -648,4 +648,4 @@ object Test9_parallel {
println("Error in Test5_parallel: " + e)
throw e
}
-}
+} \ No newline at end of file
diff --git a/test/files/jvm/t1652.check b/test/files/jvm/t1652.check
deleted file mode 100644
index dfa480ce6e..0000000000
--- a/test/files/jvm/t1652.check
+++ /dev/null
@@ -1,2 +0,0 @@
-OK1
-OK2
diff --git a/test/files/neg/classtags_contextbound_a.check b/test/files/neg/classtags_contextbound_a.check
index a4fd37506d..f4b6ff5af1 100644
--- a/test/files/neg/classtags_contextbound_a.check
+++ b/test/files/neg/classtags_contextbound_a.check
@@ -1,4 +1,4 @@
-classtags_contextbound_a.scala:2: error: No ArrayTag available for T
+classtags_contextbound_a.scala:2: error: No ClassTag available for T
def foo[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_contextbound_b.check b/test/files/neg/classtags_contextbound_b.check
index f1f48bed72..e08ab504bc 100644
--- a/test/files/neg/classtags_contextbound_b.check
+++ b/test/files/neg/classtags_contextbound_b.check
@@ -1,4 +1,4 @@
-classtags_contextbound_b.scala:3: error: No ClassTag available for T
+classtags_contextbound_b.scala:5: error: No ClassTag available for T
def foo[T] = mkArray[T]
^
one error found
diff --git a/test/files/neg/classtags_contextbound_b.scala b/test/files/neg/classtags_contextbound_b.scala
index 3247a8ff29..a189f9aa65 100644
--- a/test/files/neg/classtags_contextbound_b.scala
+++ b/test/files/neg/classtags_contextbound_b.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
def mkArray[T: ClassTag] = Array[T]()
def foo[T] = mkArray[T]
diff --git a/test/files/neg/classtags_contextbound_c.check b/test/files/neg/classtags_contextbound_c.check
index a1c5eddfe1..f8768eea2b 100644
--- a/test/files/neg/classtags_contextbound_c.check
+++ b/test/files/neg/classtags_contextbound_c.check
@@ -1,4 +1,4 @@
-classtags_contextbound_c.scala:2: error: No ArrayTag available for T
+classtags_contextbound_c.scala:4: error: No ClassTag available for T
def mkArray[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_contextbound_c.scala b/test/files/neg/classtags_contextbound_c.scala
index 0b63f8407e..54c616ce7e 100644
--- a/test/files/neg/classtags_contextbound_c.scala
+++ b/test/files/neg/classtags_contextbound_c.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
def mkArray[T] = Array[T]()
def foo[T: ClassTag] = mkArray[T]
diff --git a/test/files/neg/classtags_dont_use_typetags.check b/test/files/neg/classtags_dont_use_typetags.check
index c7d2fba35b..24585e7c3f 100644
--- a/test/files/neg/classtags_dont_use_typetags.check
+++ b/test/files/neg/classtags_dont_use_typetags.check
@@ -1,4 +1,4 @@
-classtags_dont_use_typetags.scala:2: error: No ArrayTag available for T
+classtags_dont_use_typetags.scala:4: error: No ClassTag available for T
def foo[T: TypeTag] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_dont_use_typetags.scala b/test/files/neg/classtags_dont_use_typetags.scala
index 0f675f71aa..2eb842b860 100644
--- a/test/files/neg/classtags_dont_use_typetags.scala
+++ b/test/files/neg/classtags_dont_use_typetags.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
def foo[T: TypeTag] = Array[T]()
} \ No newline at end of file
diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.check b/test/files/neg/interop_abstypetags_arenot_classmanifests.check
index 4bb81108d1..3134aadb58 100644
--- a/test/files/neg/interop_erasuretags_arenot_classmanifests.check
+++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.check
@@ -1,4 +1,4 @@
-interop_erasuretags_arenot_classmanifests.scala:3: error: could not find implicit value for parameter m: ClassManifest[T]
+interop_abstypetags_arenot_classmanifests.scala:5: error: could not find implicit value for parameter m: ClassManifest[T]
println(classManifest[T])
^
one error found
diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala
new file mode 100644
index 0000000000..c8567be5d4
--- /dev/null
+++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def absTypeTagIsnotClassManifest[T: AbsTypeTag] = {
+ println(classManifest[T])
+ }
+
+ absTypeTagIsnotClassManifest[Int]
+ absTypeTagIsnotClassManifest[String]
+ absTypeTagIsnotClassManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.check b/test/files/neg/interop_abstypetags_arenot_classtags.check
new file mode 100644
index 0000000000..637db83e57
--- /dev/null
+++ b/test/files/neg/interop_abstypetags_arenot_classtags.check
@@ -0,0 +1,4 @@
+interop_abstypetags_arenot_classtags.scala:6: error: No ClassTag available for T
+ println(classTag[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.scala b/test/files/neg/interop_abstypetags_arenot_classtags.scala
new file mode 100644
index 0000000000..e3911c1588
--- /dev/null
+++ b/test/files/neg/interop_abstypetags_arenot_classtags.scala
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.{ClassTag, classTag}
+
+object Test extends App {
+ def absTypeTagIsnotClassTag[T: AbsTypeTag] = {
+ println(classTag[T])
+ }
+
+ absTypeTagIsnotClassTag[Int]
+ absTypeTagIsnotClassTag[String]
+ absTypeTagIsnotClassTag[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_erasuretags_arenot_manifests.check b/test/files/neg/interop_abstypetags_arenot_manifests.check
index da3c03d371..c80635543f 100644
--- a/test/files/neg/interop_erasuretags_arenot_manifests.check
+++ b/test/files/neg/interop_abstypetags_arenot_manifests.check
@@ -1,4 +1,4 @@
-interop_erasuretags_arenot_manifests.scala:3: error: No Manifest available for T.
+interop_abstypetags_arenot_manifests.scala:5: error: No Manifest available for T.
println(manifest[T])
^
one error found
diff --git a/test/files/neg/interop_abstypetags_arenot_manifests.scala b/test/files/neg/interop_abstypetags_arenot_manifests.scala
new file mode 100644
index 0000000000..77a95048fd
--- /dev/null
+++ b/test/files/neg/interop_abstypetags_arenot_manifests.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def absTypeTagIsnotManifest[T: AbsTypeTag] = {
+ println(manifest[T])
+ }
+
+ absTypeTagIsnotManifest[Int]
+ absTypeTagIsnotManifest[String]
+ absTypeTagIsnotManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_classmanifests_arenot_concretetypetags.check b/test/files/neg/interop_classmanifests_arenot_concretetypetags.check
deleted file mode 100644
index d6fa564df4..0000000000
--- a/test/files/neg/interop_classmanifests_arenot_concretetypetags.check
+++ /dev/null
@@ -1,4 +0,0 @@
-interop_classmanifests_arenot_concretetypetags.scala:3: error: No ConcreteTypeTag available for T
- println(concreteTypeTag[T])
- ^
-one error found
diff --git a/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala b/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala
deleted file mode 100644
index 5b1ed55e47..0000000000
--- a/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def classManifestIsnotConcreteTypeTag[T: ClassManifest] = {
- println(concreteTypeTag[T])
- }
-
- classManifestIsnotConcreteTypeTag[Int]
- classManifestIsnotConcreteTypeTag[String]
- classManifestIsnotConcreteTypeTag[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/neg/interop_classmanifests_arenot_typetags.check b/test/files/neg/interop_classmanifests_arenot_typetags.check
new file mode 100644
index 0000000000..6675fd9eae
--- /dev/null
+++ b/test/files/neg/interop_classmanifests_arenot_typetags.check
@@ -0,0 +1,4 @@
+interop_classmanifests_arenot_typetags.scala:5: error: No TypeTag available for T
+ println(implicitly[TypeTag[T]])
+ ^
+one error found
diff --git a/test/files/neg/interop_classmanifests_arenot_typetags.scala b/test/files/neg/interop_classmanifests_arenot_typetags.scala
new file mode 100644
index 0000000000..29d03a8ec8
--- /dev/null
+++ b/test/files/neg/interop_classmanifests_arenot_typetags.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def classManifestIsnotTypeTag[T: ClassManifest] = {
+ println(implicitly[TypeTag[T]])
+ }
+
+ classManifestIsnotTypeTag[Int]
+ classManifestIsnotTypeTag[String]
+ classManifestIsnotTypeTag[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_classtags_arenot_manifests.check b/test/files/neg/interop_classtags_arenot_manifests.check
index 95f6a94d4b..6982f0b805 100644
--- a/test/files/neg/interop_classtags_arenot_manifests.check
+++ b/test/files/neg/interop_classtags_arenot_manifests.check
@@ -1,7 +1,4 @@
-interop_classtags_arenot_manifests.scala:3: error: No Manifest available for T.
+interop_classtags_arenot_manifests.scala:5: error: No Manifest available for T.
println(manifest[T])
^
-interop_classtags_arenot_manifests.scala:11: error: No Manifest available for T.
- println(manifest[T])
- ^
-two errors found
+one error found
diff --git a/test/files/neg/interop_classtags_arenot_manifests.scala b/test/files/neg/interop_classtags_arenot_manifests.scala
index 7351f7e305..391143c6e8 100644
--- a/test/files/neg/interop_classtags_arenot_manifests.scala
+++ b/test/files/neg/interop_classtags_arenot_manifests.scala
@@ -1,12 +1,6 @@
-object Test extends App {
- def arrayTagIsnotManifest[T: ArrayTag] = {
- println(manifest[T])
- }
-
- arrayTagIsnotManifest[Int]
- arrayTagIsnotManifest[String]
- arrayTagIsnotManifest[Array[Int]]
+import scala.reflect.{ClassTag, classTag}
+object Test extends App {
def classTagIsnotManifest[T: ClassTag] = {
println(manifest[T])
}
diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.scala b/test/files/neg/interop_erasuretags_arenot_classmanifests.scala
deleted file mode 100644
index cf7d1ac257..0000000000
--- a/test/files/neg/interop_erasuretags_arenot_classmanifests.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def erasureTagIsnotClassManifest[T: ErasureTag] = {
- println(classManifest[T])
- }
-
- erasureTagIsnotClassManifest[Int]
- erasureTagIsnotClassManifest[String]
- erasureTagIsnotClassManifest[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/neg/interop_erasuretags_arenot_manifests.scala b/test/files/neg/interop_erasuretags_arenot_manifests.scala
deleted file mode 100644
index 5c326549d8..0000000000
--- a/test/files/neg/interop_erasuretags_arenot_manifests.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def erasureTagIsnotManifest[T: ErasureTag] = {
- println(manifest[T])
- }
-
- erasureTagIsnotManifest[Int]
- erasureTagIsnotManifest[String]
- erasureTagIsnotManifest[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/neg/interop_typetags_arenot_classmanifests.check b/test/files/neg/interop_typetags_arenot_classmanifests.check
index 9ed4fd43d4..403625b4da 100644
--- a/test/files/neg/interop_typetags_arenot_classmanifests.check
+++ b/test/files/neg/interop_typetags_arenot_classmanifests.check
@@ -1,4 +1,4 @@
-interop_typetags_arenot_classmanifests.scala:3: error: could not find implicit value for parameter m: ClassManifest[T]
+interop_typetags_arenot_classmanifests.scala:5: error: could not find implicit value for parameter m: ClassManifest[T]
println(classManifest[T])
^
one error found
diff --git a/test/files/neg/interop_typetags_arenot_classmanifests.scala b/test/files/neg/interop_typetags_arenot_classmanifests.scala
index b1fbb7b5a6..d07f4726f5 100644
--- a/test/files/neg/interop_typetags_arenot_classmanifests.scala
+++ b/test/files/neg/interop_typetags_arenot_classmanifests.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
def typeTagIsnotClassManifest[T: TypeTag] = {
println(classManifest[T])
diff --git a/test/files/neg/interop_typetags_arenot_classtags.check b/test/files/neg/interop_typetags_arenot_classtags.check
new file mode 100644
index 0000000000..673ad2f941
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_classtags.check
@@ -0,0 +1,4 @@
+interop_typetags_arenot_classtags.scala:6: error: No ClassTag available for T
+ println(classTag[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_typetags_arenot_classtags.scala b/test/files/neg/interop_typetags_arenot_classtags.scala
new file mode 100644
index 0000000000..072c12adb0
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_classtags.scala
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.{ClassTag, classTag}
+
+object Test extends App {
+ def typeTagIsnotClassTag[T: TypeTag] = {
+ println(classTag[T])
+ }
+
+ typeTagIsnotClassTag[Int]
+ typeTagIsnotClassTag[String]
+ typeTagIsnotClassTag[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_typetags_arenot_manifests.check b/test/files/neg/interop_typetags_arenot_manifests.check
deleted file mode 100644
index 7761a747ff..0000000000
--- a/test/files/neg/interop_typetags_arenot_manifests.check
+++ /dev/null
@@ -1,4 +0,0 @@
-interop_typetags_arenot_manifests.scala:3: error: No Manifest available for T.
- println(manifest[T])
- ^
-one error found
diff --git a/test/files/neg/interop_typetags_arenot_manifests.scala b/test/files/neg/interop_typetags_arenot_manifests.scala
deleted file mode 100644
index 4e2a04489b..0000000000
--- a/test/files/neg/interop_typetags_arenot_manifests.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def typeTagIsnotManifest[T: TypeTag] = {
- println(manifest[T])
- }
-
- typeTagIsnotManifest[Int]
- typeTagIsnotManifest[String]
- typeTagIsnotManifest[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/neg/interop_typetags_without_classtags_arenot_manifests.check b/test/files/neg/interop_typetags_without_classtags_arenot_manifests.check
new file mode 100644
index 0000000000..a95f1ad308
--- /dev/null
+++ b/test/files/neg/interop_typetags_without_classtags_arenot_manifests.check
@@ -0,0 +1,6 @@
+interop_typetags_without_classtags_arenot_manifests.scala:6: error: to create a manifest here, it is necessary to interoperate with the type tag `evidence$1` in scope.
+however typetag -> manifest conversion requires a class tag for the corresponding type to be present.
+to proceed add a class tag to the type `T` (e.g. by introducing a context bound) and recompile.
+ println(manifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_typetags_without_classtags_arenot_manifests.scala b/test/files/neg/interop_typetags_without_classtags_arenot_manifests.scala
new file mode 100644
index 0000000000..0d48ae5cd0
--- /dev/null
+++ b/test/files/neg/interop_typetags_without_classtags_arenot_manifests.scala
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+object Test extends App {
+ def typeTagWithoutClassTagIsnotManifest[T: TypeTag] = {
+ println(manifest[T])
+ }
+
+ typeTagWithoutClassTagIsnotManifest[Int]
+ typeTagWithoutClassTagIsnotManifest[String]
+ typeTagWithoutClassTagIsnotManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/macro-argtype-mismatch.check b/test/files/neg/macro-argtype-mismatch.check
deleted file mode 100644
index dd867be804..0000000000
--- a/test/files/neg/macro-argtype-mismatch.check
+++ /dev/null
@@ -1,6 +0,0 @@
-Test_2.scala:3: error: type mismatch;
- found : String("2")
- required: Int
- foo("2")
- ^
-one error found
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 e9876e32e9..8abde907bb 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
@@ -2,21 +2,21 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
}
diff --git a/test/files/neg/macro-invalidimpl-f/Impls_1.scala b/test/files/neg/macro-invalidimpl-f/Impls_1.scala
index 06c6efbb1f..3b8f15b90c 100644
--- a/test/files/neg/macro-invalidimpl-f/Impls_1.scala
+++ b/test/files/neg/macro-invalidimpl-f/Impls_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def fooNullary(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooEmpty(c: Ctx)() = fooNullary(c)
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidimpl-g/Impls_1.scala b/test/files/neg/macro-invalidimpl-g/Impls_1.scala
index 06c6efbb1f..3b8f15b90c 100644
--- a/test/files/neg/macro-invalidimpl-g/Impls_1.scala
+++ b/test/files/neg/macro-invalidimpl-g/Impls_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def fooNullary(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooEmpty(c: Ctx)() = fooNullary(c)
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check
index 0401993335..b2ce4b1caa 100644
--- a/test/files/neg/macro-invalidsig-context-bounds.check
+++ b/test/files/neg/macro-invalidsig-context-bounds.check
@@ -1,4 +1,4 @@
-Impls_1.scala:4: error: macro implementations cannot have implicit parameters other than TypeTag evidences
- def foo[U: c.TypeTag: Numeric](c: Ctx) = {
- ^
-one error found
+Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than TypeTag evidences
+ def foo[U: c.TypeTag: Numeric](c: Ctx) = {
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala
index 2eb2ab3947..2eef7aac8b 100644
--- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala
@@ -1,8 +1,9 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U: c.TypeTag: Numeric](c: Ctx) = {
- import c.mirror._
+ import c.universe._
Literal(Constant(42))
}
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala
index da28944d27..4d5d29158f 100644
--- a/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala
@@ -1,5 +1,3 @@
-import scala.reflect.api.{Mirror => Ctx}
-
object Impls {
def foo = ???
}
diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.check b/test/files/neg/macro-invalidsig-ctx-badtype.check
index 3913a8e3cb..b1702bbca6 100644
--- a/test/files/neg/macro-invalidsig-ctx-badtype.check
+++ b/test/files/neg/macro-invalidsig-ctx-badtype.check
@@ -1,7 +1,7 @@
-Macros_Test_2.scala:2: error: macro implementation has wrong shape:
- required: (c: scala.reflect.makro.Context): c.Expr[Any]
- found : (c: scala.reflect.api.Mirror): Nothing
-type mismatch for parameter c: scala.reflect.makro.Context does not conform to scala.reflect.api.Mirror
- def foo = macro Impls.foo
- ^
-one error found
+Macros_Test_2.scala:2: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.makro.Context): c.Expr[Any]
+ found : (c: scala.reflect.api.Universe): Nothing
+type mismatch for parameter c: scala.reflect.makro.Context does not conform to scala.reflect.api.Universe
+ def foo = macro Impls.foo
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala
index 747a2e9ca8..cf1a4cf85c 100644
--- a/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.api.{Mirror => Ctx}
+import scala.reflect.api.{Universe => Ctx}
object Impls {
def foo(c: Ctx) = ???
diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check
index 0dd1c27b50..6416ed0a09 100644
--- a/test/files/neg/macro-invalidsig-implicit-params.check
+++ b/test/files/neg/macro-invalidsig-implicit-params.check
@@ -1,4 +1,4 @@
-Impls_Macros_1.scala:4: error: macro implementations cannot have implicit parameters other than TypeTag evidences
+Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than TypeTag evidences
def foo_targs[T, U: c.TypeTag](c: Ctx)(implicit x: c.Expr[Int]) = {
^
one error found
diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala
index 662ad2ab52..5bfe73ec59 100644
--- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala
+++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala
@@ -1,18 +1,19 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo_targs[T, U: c.TypeTag](c: Ctx)(implicit x: c.Expr[Int]) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val body = Block(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))),
- Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.tpe)))),
+ Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticTpe)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.TypeTag[U]].tpe)))),
Literal(Constant(())))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
}
class Macros[T] {
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check
index 71a65aec84..e4f67e650a 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.makro.Context)(x: c.Expr[Int]): c.Expr[Any]
- found : (c: scala.reflect.makro.Context)(x: c.mirror.Tree): Nothing
-type mismatch for parameter x: c.Expr[Int] does not conform to c.mirror.Tree
- def foo(x: Int) = macro Impls.foo
- ^
-one error found
+Impls_Macros_1.scala:8: error: macro implementation has wrong shape:
+ required: (c: scala.reflect.makro.Context)(x: c.Expr[Int]): c.Expr[Any]
+ found : (c: scala.reflect.makro.Context)(x: c.universe.Tree): Nothing
+type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Tree
+ def foo(x: Int) = macro Impls.foo
+ ^
+one error found
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 29220c1c82..6393e6d395 100644
--- a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala
+++ b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala
@@ -1,7 +1,7 @@
import scala.reflect.makro.{Context => Ctx}
object Impls {
- def foo(c: Ctx)(x: c.mirror.Tree) = ???
+ def foo(c: Ctx)(x: c.universe.Tree) = ???
}
object Macros {
diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.check b/test/files/neg/macro-invalidsig-tparams-badtype.check
index bd1acc4a0a..9166db3574 100644
--- a/test/files/neg/macro-invalidsig-tparams-badtype.check
+++ b/test/files/neg/macro-invalidsig-tparams-badtype.check
@@ -1,6 +1,6 @@
Macros_Test_2.scala:2: error: macro implementation has wrong shape:
required: (c: scala.reflect.makro.Context): c.Expr[Any]
- found : (c: scala.reflect.makro.Context)(U: c.mirror.Type): Nothing
+ found : (c: scala.reflect.makro.Context)(U: c.universe.Type): Nothing
number of parameter sections differ
def foo[U] = macro Impls.foo[U]
^
diff --git a/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala
index b43251df33..9886331502 100644
--- a/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.makro.{Context => Ctx}
object Impls {
- def foo[U](c: Ctx)(U: c.mirror.Type) = ???
+ def foo[U](c: Ctx)(U: c.universe.Type) = ???
}
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala
index bbe5b4e519..ea472e6f91 100644
--- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala
@@ -1,5 +1,6 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U: c.TypeTag](c: Ctx) = ???
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala
index db79ddbcd8..c4eb3d9b4a 100644
--- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala
@@ -1,3 +1,4 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
@@ -7,4 +8,4 @@ object Impls {
println(V)
c.literalUnit
}
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala
index 43c5a2acd5..41facc881e 100644
--- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala
+++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala
@@ -1,11 +1,12 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T: c.TypeTag, U: c.TypeTag, V](c: Ctx)(implicit V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
+ import c.universe._
println(implicitly[c.TypeTag[T]])
println(implicitly[c.TypeTag[U]])
println(V)
c.literalUnit
}
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
index 8e52613b6d..31e758e9a0 100644
--- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
+++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-noncompilertree.check b/test/files/neg/macro-noncompilertree.check
deleted file mode 100644
index 616765a39e..0000000000
--- a/test/files/neg/macro-noncompilertree.check
+++ /dev/null
@@ -1,6 +0,0 @@
-Macros_1.scala:2: error: type mismatch;
- found : reflect.mirror.Literal
- required: _context.Tree
- def macro foo = scala.reflect.mirror.Literal(scala.reflect.mirror.Constant(2))
- ^
-one error found
diff --git a/test/files/neg/macro-nontree.check b/test/files/neg/macro-nontree.check
deleted file mode 100644
index a1c7139580..0000000000
--- a/test/files/neg/macro-nontree.check
+++ /dev/null
@@ -1,6 +0,0 @@
-Macros_1.scala:2: error: type mismatch;
- found : Int(2)
- required: _context.Tree
- def macro foo = 2
- ^
-one error found
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 0b127f5a59..d6493caad9 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
@@ -3,13 +3,13 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x)
def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x)
def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x)
def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x)
-}
+} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags.check b/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags.check
deleted file mode 100644
index 39e90f827e..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags.check
+++ /dev/null
@@ -1,7 +0,0 @@
-Test.scala:5: error: No ConcreteTypeTag available for C[T]
- println(implicitly[ConcreteTypeTag[C[T]]])
- ^
-Test.scala:6: error: No ConcreteTypeTag available for List[C[T]]
- println(implicitly[ConcreteTypeTag[List[C[T]]]])
- ^
-two errors found
diff --git a/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags/Test.scala b/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags/Test.scala
deleted file mode 100644
index 1302999da6..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-hktypeparams-notags/Test.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- def fooNoTypeTagHK[C[_], T] = {
- println(implicitly[ConcreteTypeTag[C[T]]])
- println(implicitly[ConcreteTypeTag[List[C[T]]]])
- }
- fooNoTypeTagHK[List, Int]
-} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-groundtypetag-typeparams-notags.check b/test/files/neg/macro-reify-groundtypetag-typeparams-notags.check
deleted file mode 100644
index 164ca3543f..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-typeparams-notags.check
+++ /dev/null
@@ -1,7 +0,0 @@
-Test.scala:5: error: No ConcreteTypeTag available for T
- println(implicitly[ConcreteTypeTag[T]])
- ^
-Test.scala:6: error: No ConcreteTypeTag available for List[T]
- println(implicitly[ConcreteTypeTag[List[T]]])
- ^
-two errors found
diff --git a/test/files/neg/macro-reify-groundtypetag-typeparams-notags/Test.scala b/test/files/neg/macro-reify-groundtypetag-typeparams-notags/Test.scala
deleted file mode 100644
index d2276ce333..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-typeparams-notags/Test.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- def fooNoTypeTag[T] = {
- println(implicitly[ConcreteTypeTag[T]])
- println(implicitly[ConcreteTypeTag[List[T]]])
- }
- fooNoTypeTag[Int]
-} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-groundtypetag-usetypetag.check b/test/files/neg/macro-reify-groundtypetag-usetypetag.check
deleted file mode 100644
index 164ca3543f..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-usetypetag.check
+++ /dev/null
@@ -1,7 +0,0 @@
-Test.scala:5: error: No ConcreteTypeTag available for T
- println(implicitly[ConcreteTypeTag[T]])
- ^
-Test.scala:6: error: No ConcreteTypeTag available for List[T]
- println(implicitly[ConcreteTypeTag[List[T]]])
- ^
-two errors found
diff --git a/test/files/neg/macro-reify-groundtypetag-usetypetag/Test.scala b/test/files/neg/macro-reify-groundtypetag-usetypetag/Test.scala
deleted file mode 100644
index d82cdc33e9..0000000000
--- a/test/files/neg/macro-reify-groundtypetag-usetypetag/Test.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- def fooTypeTag[T: TypeTag] = {
- println(implicitly[ConcreteTypeTag[T]])
- println(implicitly[ConcreteTypeTag[List[T]]])
- }
- fooTypeTag[Int]
-} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-typetag-hktypeparams-notags.check b/test/files/neg/macro-reify-typetag-hktypeparams-notags.check
new file mode 100644
index 0000000000..742d87b0a4
--- /dev/null
+++ b/test/files/neg/macro-reify-typetag-hktypeparams-notags.check
@@ -0,0 +1,7 @@
+Test.scala:5: error: No TypeTag available for C[T]
+ println(implicitly[TypeTag[C[T]]])
+ ^
+Test.scala:6: error: No TypeTag available for List[C[T]]
+ println(implicitly[TypeTag[List[C[T]]]])
+ ^
+two errors found
diff --git a/test/files/neg/macro-reify-typetag-hktypeparams-notags/Test.scala b/test/files/neg/macro-reify-typetag-hktypeparams-notags/Test.scala
new file mode 100644
index 0000000000..c7b1cedcd2
--- /dev/null
+++ b/test/files/neg/macro-reify-typetag-hktypeparams-notags/Test.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def fooNoTypeTagHK[C[_], T] = {
+ println(implicitly[TypeTag[C[T]]])
+ println(implicitly[TypeTag[List[C[T]]]])
+ }
+ fooNoTypeTagHK[List, Int]
+} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-typetag-typeparams-notags.check b/test/files/neg/macro-reify-typetag-typeparams-notags.check
new file mode 100644
index 0000000000..db88260047
--- /dev/null
+++ b/test/files/neg/macro-reify-typetag-typeparams-notags.check
@@ -0,0 +1,7 @@
+Test.scala:5: error: No TypeTag available for T
+ println(implicitly[TypeTag[T]])
+ ^
+Test.scala:6: error: No TypeTag available for List[T]
+ println(implicitly[TypeTag[List[T]]])
+ ^
+two errors found
diff --git a/test/files/run/macro-reify-typetag-typeparams-notags/Test.scala b/test/files/neg/macro-reify-typetag-typeparams-notags/Test.scala
index a89499e7fe..6d849cde3f 100644
--- a/test/files/run/macro-reify-typetag-typeparams-notags/Test.scala
+++ b/test/files/neg/macro-reify-typetag-typeparams-notags/Test.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def fooNoTypeTag[T] = {
diff --git a/test/files/neg/macro-reify-typetag-useabstypetag.check b/test/files/neg/macro-reify-typetag-useabstypetag.check
new file mode 100644
index 0000000000..db88260047
--- /dev/null
+++ b/test/files/neg/macro-reify-typetag-useabstypetag.check
@@ -0,0 +1,7 @@
+Test.scala:5: error: No TypeTag available for T
+ println(implicitly[TypeTag[T]])
+ ^
+Test.scala:6: error: No TypeTag available for List[T]
+ println(implicitly[TypeTag[List[T]]])
+ ^
+two errors found
diff --git a/test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala
index de235f51cc..b66ad6c523 100644
--- a/test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala
+++ b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala
@@ -1,7 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
- def fooTypeTag[T: ConcreteTypeTag] = {
+ def fooTypeTag[T: AbsTypeTag] = {
println(implicitly[TypeTag[T]])
println(implicitly[TypeTag[List[T]]])
}
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 e6cee46e85..0b6fbe240e 100644
--- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
@@ -2,17 +2,17 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
}
def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
}
def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))))
}
-}
+} \ No newline at end of file
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 e6cee46e85..0b6fbe240e 100644
--- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
@@ -2,17 +2,17 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
}
def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
}
def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))))
}
-}
+} \ No newline at end of file
diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check
index 6172811e13..4556e6622f 100644
--- a/test/files/neg/patmatexhaust.check
+++ b/test/files/neg/patmatexhaust.check
@@ -14,14 +14,13 @@ patmatexhaust.scala:49: error: match may not be exhaustive.
It would fail on the following inputs: Gp(), Gu
def ma4(x:Deep) = x match { // missing cases: Gu, Gp
^
+patmatexhaust.scala:55: error: unreachable code
+ case _ if 1 == 0 =>
+ ^
patmatexhaust.scala:53: error: match may not be exhaustive.
It would fail on the following input: Gp()
def ma5(x:Deep) = x match {
^
-patmatexhaust.scala:59: error: match may not be exhaustive.
-It would fail on the following input: Nil
- def ma6() = List(1,2) match { // give up
- ^
patmatexhaust.scala:75: error: match may not be exhaustive.
It would fail on the following input: B()
def ma9(x: B) = x match {
diff --git a/test/files/neg/reify_ann2b.check b/test/files/neg/reify_ann2b.check
index 52bdbe5b7c..1cef405bef 100644
--- a/test/files/neg/reify_ann2b.check
+++ b/test/files/neg/reify_ann2b.check
@@ -1,4 +1,4 @@
-reify_ann2b.scala:6: error: inner classes cannot be classfile annotations
- class ann(bar: String) extends annotation.ClassfileAnnotation
- ^
-one error found
+reify_ann2b.scala:9: error: inner classes cannot be classfile annotations
+ class ann(bar: String) extends annotation.ClassfileAnnotation
+ ^
+one error found
diff --git a/test/files/neg/reify_ann2b.scala b/test/files/neg/reify_ann2b.scala
index 397d00210d..2076af34c8 100644
--- a/test/files/neg/reify_ann2b.scala
+++ b/test/files/neg/reify_ann2b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
// test 1: reify
@@ -16,7 +19,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/neg/reify_metalevel_breach_+0_refers_to_1.check b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.check
new file mode 100644
index 0000000000..efdbd7e282
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.check
@@ -0,0 +1,7 @@
+reify_metalevel_breach_+0_refers_to_1.scala:10: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ inner.splice
+ ^
+one error found
diff --git a/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala
new file mode 100644
index 0000000000..9499960480
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala
@@ -0,0 +1,16 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val code = reify{
+ val x = 2
+ val inner = reify{x}
+ inner.splice
+ };
+
+ val toolbox = cm.mkToolBox()
+ val evaluated = toolbox.runExpr(code.tree)
+ println("evaluated = " + evaluated)
+} \ No newline at end of file
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.check b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.check
new file mode 100644
index 0000000000..91755c789a
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.check
@@ -0,0 +1,7 @@
+reify_metalevel_breach_-1_refers_to_0_a.scala:9: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ val code = reify{outer.splice.splice}
+ ^
+one error found
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala
new file mode 100644
index 0000000000..e6aaeb9426
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala
@@ -0,0 +1,14 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val x = 2
+ val outer = reify{reify{x}}
+ val code = reify{outer.splice.splice}
+
+ val toolbox = cm.mkToolBox()
+ val evaluated = toolbox.runExpr(code.tree)
+ println("evaluated = " + evaluated)
+} \ No newline at end of file
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.check b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.check
new file mode 100644
index 0000000000..f703bfb05f
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.check
@@ -0,0 +1,7 @@
+reify_metalevel_breach_-1_refers_to_0_b.scala:12: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ }.splice
+ ^
+one error found
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala
new file mode 100644
index 0000000000..16dcae8683
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala
@@ -0,0 +1,18 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val x = 2
+ val code = reify{
+ {
+ val inner = reify{reify{x}}
+ inner.splice
+ }.splice
+ }
+
+ val toolbox = cm.mkToolBox()
+ val evaluated = toolbox.runExpr(code.tree)
+ println("evaluated = " + evaluated)
+} \ No newline at end of file
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_1.check b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.check
new file mode 100644
index 0000000000..068e4accd2
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.check
@@ -0,0 +1,7 @@
+reify_metalevel_breach_-1_refers_to_1.scala:10: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ inner.splice.splice
+ ^
+one error found
diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala
new file mode 100644
index 0000000000..9600489f35
--- /dev/null
+++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala
@@ -0,0 +1,16 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val code = reify{
+ val x = 2
+ val inner = reify{reify{x}}
+ inner.splice.splice
+ };
+
+ val toolbox = cm.mkToolBox()
+ val evaluated = toolbox.runExpr(code.tree)
+ println("evaluated = " + evaluated)
+} \ No newline at end of file
diff --git a/test/files/neg/reify_nested_inner_refers_to_local.check b/test/files/neg/reify_nested_inner_refers_to_local.check
new file mode 100644
index 0000000000..3f897bded9
--- /dev/null
+++ b/test/files/neg/reify_nested_inner_refers_to_local.check
@@ -0,0 +1,7 @@
+reify_nested_inner_refers_to_local.scala:9: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ reify{x}.splice
+ ^
+one error found
diff --git a/test/files/neg/reify_nested_inner_refers_to_local.scala b/test/files/neg/reify_nested_inner_refers_to_local.scala
new file mode 100644
index 0000000000..fcbc1f7865
--- /dev/null
+++ b/test/files/neg/reify_nested_inner_refers_to_local.scala
@@ -0,0 +1,15 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val code = reify{
+ val x = 2
+ reify{x}.splice
+ };
+
+ val toolbox = cm.mkToolBox()
+ val evaluated = toolbox.runExpr(code.tree)
+ println("evaluated = " + evaluated)
+} \ No newline at end of file
diff --git a/test/files/neg/switch.flags b/test/files/neg/switch.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/switch.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check
index a1e950cf73..f357221cd9 100644
--- a/test/files/neg/t2775.check
+++ b/test/files/neg/t2775.check
@@ -1,4 +1,4 @@
-t2775.scala:1: error: cannot find array tag for element type B.this.T
-trait B[S] { type T = S; val c = new Array[T](1) }
- ^
-one error found
+t2775.scala:1: error: cannot find class tag for element type B.this.T
+trait B[S] { type T = S; val c = new Array[T](1) }
+ ^
+one error found
diff --git a/test/files/neg/t3692-new.check b/test/files/neg/t3692-new.check
index e013daca74..349e4fe48a 100644
--- a/test/files/neg/t3692-new.check
+++ b/test/files/neg/t3692-new.check
@@ -1,4 +1,4 @@
-t3692-new.scala:15: error: unreachable code
+t3692-new.scala:16: error: unreachable code
case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
^
one error found
diff --git a/test/files/neg/t3692-new.scala b/test/files/neg/t3692-new.scala
index 46874b02e3..cebdcea393 100644
--- a/test/files/neg/t3692-new.scala
+++ b/test/files/neg/t3692-new.scala
@@ -1,3 +1,4 @@
+import scala.reflect.{ClassTag, classTag}
import java.lang.Integer
object Tester {
diff --git a/test/files/neg/t3692-old.check b/test/files/neg/t3692-old.check
index 9da7033239..a97a7d31ec 100644
--- a/test/files/neg/t3692-old.check
+++ b/test/files/neg/t3692-old.check
@@ -1,4 +1,4 @@
-t3692-old.scala:6: warning: object Manifest in package reflect is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
+t3692-old.scala:6: warning: object Manifest in package reflect is deprecated: Use TypeTag instead
new ManifestTester().toJavaMap(map)
^
t3692-old.scala:15: error: unreachable code
diff --git a/test/files/neg/t4818.check b/test/files/neg/t4818.check
new file mode 100644
index 0000000000..a5e15e456b
--- /dev/null
+++ b/test/files/neg/t4818.check
@@ -0,0 +1,6 @@
+t4818.scala:4: error: type mismatch;
+ found : Int(5)
+ required: Nothing
+ def f(x: Any) = x match { case Fn(f) => f(5) }
+ ^
+one error found
diff --git a/test/files/neg/t4818.scala b/test/files/neg/t4818.scala
new file mode 100644
index 0000000000..faae229206
--- /dev/null
+++ b/test/files/neg/t4818.scala
@@ -0,0 +1,7 @@
+object Test {
+ case class Fn[A, B](f: A => B)
+
+ def f(x: Any) = x match { case Fn(f) => f(5) }
+
+ Fn((x: String) => x)
+}
diff --git a/test/files/neg/t5318.check b/test/files/neg/t5318.check
new file mode 100644
index 0000000000..d6a3a57935
--- /dev/null
+++ b/test/files/neg/t5318.check
@@ -0,0 +1,5 @@
+t5318.scala:7: error: diverging implicit expansion for type CompilerHang.this.TC[F]
+starting with method tc in class CompilerHang
+ breakage // type checker doesn't terminate, should report inference failure
+ ^
+one error found
diff --git a/test/files/neg/t5318.scala b/test/files/neg/t5318.scala
new file mode 100644
index 0000000000..8009c66e6b
--- /dev/null
+++ b/test/files/neg/t5318.scala
@@ -0,0 +1,8 @@
+class CompilerHang {
+ trait TC[M[_]]
+ trait S[A]
+
+ implicit def tc[M[_]](implicit M0: TC[M]): TC[S] = null
+ def breakage[F[_] : TC] = 0
+ breakage // type checker doesn't terminate, should report inference failure
+} \ No newline at end of file
diff --git a/test/files/neg/t5318b.check b/test/files/neg/t5318b.check
new file mode 100644
index 0000000000..47a10d6733
--- /dev/null
+++ b/test/files/neg/t5318b.check
@@ -0,0 +1,5 @@
+t5318b.scala:7: error: diverging implicit expansion for type DivergingImplicitReported.this.TC[F]
+starting with method tc in class DivergingImplicitReported
+ breakage // correct: diverging implicit expansion
+ ^
+one error found \ No newline at end of file
diff --git a/test/files/neg/t5318b.scala b/test/files/neg/t5318b.scala
new file mode 100644
index 0000000000..123f8b4e04
--- /dev/null
+++ b/test/files/neg/t5318b.scala
@@ -0,0 +1,8 @@
+class DivergingImplicitReported {
+ trait TC[M]
+ trait S
+
+ implicit def tc[M](implicit M0: TC[M]): TC[S] = null
+ def breakage[F: TC] = 0
+ breakage // correct: diverging implicit expansion
+} \ No newline at end of file
diff --git a/test/files/neg/t5318c.check b/test/files/neg/t5318c.check
new file mode 100644
index 0000000000..594539be69
--- /dev/null
+++ b/test/files/neg/t5318c.check
@@ -0,0 +1,5 @@
+t5318c.scala:13: error: diverging implicit expansion for type CompilerHang.this.TC[F]
+starting with method tc in class CompilerHang
+ breakage // type checker doesn't terminate, should report inference failure
+ ^
+one error found
diff --git a/test/files/neg/t5318c.scala b/test/files/neg/t5318c.scala
new file mode 100644
index 0000000000..477a9874ad
--- /dev/null
+++ b/test/files/neg/t5318c.scala
@@ -0,0 +1,14 @@
+class CompilerHang {
+ trait TC[M[_]]
+ trait S[A]
+
+ class C[M[_]] {
+ type TCM = TC[M]
+ }
+
+ // A nefarious implicit, to motivate the removal of `&& sym.owner.isTerm` from
+ // `isFreeTypeParamNoSkolem`.
+ implicit def tc[x[_], CC[x[_]] <: C[x]](implicit M0: CC[x]#TCM): CC[x]#TCM = null
+ def breakage[F[_] : TC] = 0
+ breakage // type checker doesn't terminate, should report inference failure
+}
diff --git a/test/files/neg/t5334_1.check b/test/files/neg/t5334_1.check
index 1d5a7cbc01..eca854964a 100644
--- a/test/files/neg/t5334_1.check
+++ b/test/files/neg/t5334_1.check
@@ -1,4 +1,4 @@
-t5334_1.scala:4: error: implementation restriction: cannot reify block of type C that involves a type declared inside the block being reified. consider casting the return value to a suitable type
+t5334_1.scala:5: error: implementation restriction: cannot reify block of type C that involves a type declared inside the block being reified. consider casting the return value to a suitable type
reify {
^
one error found
diff --git a/test/files/neg/t5334_1.scala b/test/files/neg/t5334_1.scala
index a7de5a0915..b75badb145 100644
--- a/test/files/neg/t5334_1.scala
+++ b/test/files/neg/t5334_1.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
class C { override def toString = "C" }
new C
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/neg/t5334_2.check b/test/files/neg/t5334_2.check
index a62bfff7a5..e21f0d5967 100644
--- a/test/files/neg/t5334_2.check
+++ b/test/files/neg/t5334_2.check
@@ -1,4 +1,4 @@
-t5334_2.scala:4: error: implementation restriction: cannot reify block of type List[(C, C)] that involves a type declared inside the block being reified. consider casting the return value to a suitable type
+t5334_2.scala:5: error: implementation restriction: cannot reify block of type List[(C, C)] that involves a type declared inside the block being reified. consider casting the return value to a suitable type
reify {
^
one error found
diff --git a/test/files/neg/t5334_2.scala b/test/files/neg/t5334_2.scala
index fc6dfcd0c1..e082e3b8e3 100644
--- a/test/files/neg/t5334_2.scala
+++ b/test/files/neg/t5334_2.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
class C { override def toString() = "C" }
List((new C, new C))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/neg/t5452-new.check b/test/files/neg/t5452-new.check
index bbd3734f74..4bbeff3644 100644
--- a/test/files/neg/t5452-new.check
+++ b/test/files/neg/t5452-new.check
@@ -1,7 +1,7 @@
-t5452-new.scala:28: error: overloaded method value apply with alternatives:
+t5452-new.scala:30: error: overloaded method value apply with alternatives:
()Queryable[CoffeesTable] <and>
- (t: Tree)(implicit evidence$2: ClassTag[CoffeesTable])Nothing <and>
- (implicit evidence$1: ClassTag[CoffeesTable])Nothing
+ (t: Tree)(implicit evidence$2: scala.reflect.ClassTag[CoffeesTable])Nothing <and>
+ (implicit evidence$1: scala.reflect.ClassTag[CoffeesTable])Nothing
cannot be applied to (Queryable[CoffeesTable])
Queryable[CoffeesTable]( q.treeFilter(null) )
^
diff --git a/test/files/neg/t5452-new.scala b/test/files/neg/t5452-new.scala
index c829de7d7c..b74b1550bd 100644
--- a/test/files/neg/t5452-new.scala
+++ b/test/files/neg/t5452-new.scala
@@ -1,7 +1,9 @@
+import scala.reflect.{ClassTag, classTag}
+
// /scala/trac/5452/a.scala
// Mon Feb 13 22:52:36 PST 2012
-// import scala.reflect.mirror._
+// import scala.reflect.runtime.universe._
trait Tree
@@ -26,4 +28,4 @@ trait CoffeesTable{
object Test extends App{
val q = new Queryable[CoffeesTable]
Queryable[CoffeesTable]( q.treeFilter(null) )
-}
+} \ No newline at end of file
diff --git a/test/files/neg/t5452-old.scala b/test/files/neg/t5452-old.scala
index 1032db7a4b..4f6dcbbe46 100644
--- a/test/files/neg/t5452-old.scala
+++ b/test/files/neg/t5452-old.scala
@@ -1,7 +1,7 @@
// /scala/trac/5452/a.scala
// Mon Feb 13 22:52:36 PST 2012
-// import scala.reflect.mirror._
+// import scala.reflect.runtime.universe._
trait Tree
diff --git a/test/files/neg/t5666.check b/test/files/neg/t5666.check
index 4289b00ade..1c714796ba 100644
--- a/test/files/neg/t5666.check
+++ b/test/files/neg/t5666.check
@@ -4,33 +4,33 @@ t5666.scala:2: error: class Any is abstract; cannot be instantiated
t5666.scala:3: error: class AnyVal is abstract; cannot be instantiated
new AnyVal
^
-t5666.scala:4: error: Double does not have a constructor
+t5666.scala:4: error: class Double is abstract; cannot be instantiated
new Double
- ^
-t5666.scala:5: error: Float does not have a constructor
+ ^
+t5666.scala:5: error: class Float is abstract; cannot be instantiated
new Float
- ^
-t5666.scala:6: error: Long does not have a constructor
+ ^
+t5666.scala:6: error: class Long is abstract; cannot be instantiated
new Long
- ^
-t5666.scala:7: error: Int does not have a constructor
+ ^
+t5666.scala:7: error: class Int is abstract; cannot be instantiated
new Int
- ^
-t5666.scala:8: error: Char does not have a constructor
+ ^
+t5666.scala:8: error: class Char is abstract; cannot be instantiated
new Char
- ^
-t5666.scala:9: error: Short does not have a constructor
+ ^
+t5666.scala:9: error: class Short is abstract; cannot be instantiated
new Short
- ^
-t5666.scala:10: error: Byte does not have a constructor
+ ^
+t5666.scala:10: error: class Byte is abstract; cannot be instantiated
new Byte
- ^
-t5666.scala:11: error: Boolean does not have a constructor
+ ^
+t5666.scala:11: error: class Boolean is abstract; cannot be instantiated
new Boolean
- ^
-t5666.scala:12: error: Unit does not have a constructor
+ ^
+t5666.scala:12: error: class Unit is abstract; cannot be instantiated
new Unit
- ^
+ ^
t5666.scala:13: error: class Nothing is abstract; cannot be instantiated
new Nothing
^
diff --git a/test/files/neg/t5683.check b/test/files/neg/t5683.check
new file mode 100644
index 0000000000..7c0e50113c
--- /dev/null
+++ b/test/files/neg/t5683.check
@@ -0,0 +1,16 @@
+t5683.scala:12: error: inferred kinds of the type arguments (Object,Int) do not conform to the expected kinds of the type parameters (type M,type B).
+Object's type parameters do not match type M's expected parameters:
+class Object has no type parameters, but type M has one
+ val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
+ ^
+t5683.scala:12: error: type mismatch;
+ found : Int => Test.W[String,Int]
+ required: Int => M[B]
+ val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
+ ^
+t5683.scala:12: error: type mismatch;
+ found : Test.K[M,Int,B]
+ required: Test.K[Test.StringW,Int,Int]
+ val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
+ ^
+three errors found
diff --git a/test/files/neg/t5683.scala b/test/files/neg/t5683.scala
new file mode 100644
index 0000000000..05ab035792
--- /dev/null
+++ b/test/files/neg/t5683.scala
@@ -0,0 +1,23 @@
+object Test {
+ trait NT[X]
+ trait W[W, A] extends NT[Int]
+ type StringW[T] = W[String, T]
+ trait K[M[_], A, B]
+
+ def k[M[_], B](f: Int => M[B]): K[M, Int, B] = null
+
+ val okay1: K[StringW,Int,Int] = k{ (y: Int) => null: StringW[Int] }
+ val okay2 = k[StringW,Int]{ (y: Int) => null: W[String, Int] }
+
+ val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
+
+ // remove `extends NT[Int]`, and the last line gives an inference error
+ // rather than a crash.
+ // test/files/pos/t5683.scala:12: error: no type parameters for method k: (f: Int => M[B])Test.K[M,Int,B] exist so that it can be applied to arguments (Int => Test.W[String,Int])
+ // --- because ---
+ // argument expression's type is not compatible with formal parameter type;
+ // found : Int => Test.W[String,Int]
+ // required: Int => ?M[?B]
+ // val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
+ // ^
+}
diff --git a/test/files/neg/t5821.check b/test/files/neg/t5821.check
new file mode 100644
index 0000000000..f9c00604bc
--- /dev/null
+++ b/test/files/neg/t5821.check
@@ -0,0 +1,4 @@
+t5821.scala:1: error: not found: object SthImportant
+import SthImportant._
+ ^
+one error found
diff --git a/test/files/neg/t5821.scala b/test/files/neg/t5821.scala
new file mode 100644
index 0000000000..4af0a2bf7f
--- /dev/null
+++ b/test/files/neg/t5821.scala
@@ -0,0 +1,8 @@
+import SthImportant._
+
+class Bar
+
+class Foo2 {
+ type Sth = Array[Bar]
+ def foo(xs: Sth): Bar = if ((xs eq null) || (xs.length == 0)) null else xs(0)
+}
diff --git a/test/files/neg/t5845.check b/test/files/neg/t5845.check
new file mode 100644
index 0000000000..8c6100d6de
--- /dev/null
+++ b/test/files/neg/t5845.check
@@ -0,0 +1,7 @@
+t5845.scala:9: error: value +++ is not a member of Int
+ println(5 +++ 5)
+ ^
+t5845.scala:15: error: value +++ is not a member of Int
+ println(5 +++ 5)
+ ^
+two errors found
diff --git a/test/files/neg/t5845.scala b/test/files/neg/t5845.scala
new file mode 100644
index 0000000000..823c722c14
--- /dev/null
+++ b/test/files/neg/t5845.scala
@@ -0,0 +1,16 @@
+class Num[T] {
+ def mkOps = new Ops
+ class Ops { def +++(rhs: T) = () }
+}
+
+class A {
+ implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps
+ implicit val n1 = new Num[Int] { }
+ println(5 +++ 5)
+}
+
+class B {
+ implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps
+ implicit val n1 = new Num[Int] {}
+ println(5 +++ 5)
+}
diff --git a/test/files/neg/t639.check b/test/files/neg/t639.check
index 3b53da0515..6d41d872de 100644
--- a/test/files/neg/t639.check
+++ b/test/files/neg/t639.check
@@ -1,4 +1,7 @@
t639.scala:3: error: not found: object a
import a._
^
-one error found
+t639.scala:5: error: not found: type B
+@B
+ ^
+two errors found
diff --git a/test/files/neg/virtpatmat_reach_null.check b/test/files/neg/virtpatmat_reach_null.check
new file mode 100644
index 0000000000..595c8ec889
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_null.check
@@ -0,0 +1,4 @@
+virtpatmat_reach_null.scala:13: error: unreachable code
+ case _ => // unreachable
+ ^
+one error found
diff --git a/test/files/neg/virtpatmat_reach_null.flags b/test/files/neg/virtpatmat_reach_null.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_null.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/virtpatmat_reach_null.scala b/test/files/neg/virtpatmat_reach_null.scala
new file mode 100644
index 0000000000..6314a5b1d8
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_null.scala
@@ -0,0 +1,19 @@
+sealed abstract class Const {
+ final def excludes(other: Const) =
+ (this, other) match {
+ case (_, NullConst) =>
+ case (NullConst, _) =>
+ case (_: ValueConst, _: ValueConst) =>
+ case (_: ValueConst, _: TypeConst) =>
+ case (_: TypeConst, _: ValueConst) =>
+ case (_: TypeConst, _: TypeConst) =>
+ case (null, _) =>
+ case (_, null) =>
+ case null =>
+ case _ => // unreachable
+ }
+}
+
+sealed class TypeConst extends Const
+sealed class ValueConst extends Const
+case object NullConst extends Const
diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.check b/test/files/neg/virtpatmat_reach_sealed_unsealed.check
new file mode 100644
index 0000000000..10638eff52
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.check
@@ -0,0 +1,14 @@
+virtpatmat_reach_sealed_unsealed.scala:16: error: match may not be exhaustive.
+It would fail on the following input: false
+ (true: Boolean) match { case true => } // not exhaustive, but reachable
+ ^
+virtpatmat_reach_sealed_unsealed.scala:18: error: unreachable code
+ (true: Boolean) match { case true => case false => case _ => } // exhaustive, last case is unreachable
+ ^
+virtpatmat_reach_sealed_unsealed.scala:19: error: unreachable code
+ (true: Boolean) match { case true => case false => case _: Boolean => } // exhaustive, last case is unreachable
+ ^
+virtpatmat_reach_sealed_unsealed.scala:20: error: unreachable code
+ (true: Boolean) match { case true => case false => case _: Any => } // exhaustive, last case is unreachable
+ ^
+four errors found
diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.flags b/test/files/neg/virtpatmat_reach_sealed_unsealed.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.scala b/test/files/neg/virtpatmat_reach_sealed_unsealed.scala
new file mode 100644
index 0000000000..13911dbd78
--- /dev/null
+++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.scala
@@ -0,0 +1,21 @@
+sealed abstract class X
+sealed case class A(x: Int) extends X
+
+// test reachability on mixed sealed / non-sealed matches
+object Test extends App {
+ val B: X = A(0)
+ val C: X = A(1)
+
+ // all cases are reachable and the match is exhaustive
+ (C: X) match {
+ case B =>
+ case C =>
+ case A(_) =>
+ }
+
+ (true: Boolean) match { case true => } // not exhaustive, but reachable
+ (true: Boolean) match { case true => case false => } // exhaustive, reachable
+ (true: Boolean) match { case true => case false => case _ => } // exhaustive, last case is unreachable
+ (true: Boolean) match { case true => case false => case _: Boolean => } // exhaustive, last case is unreachable
+ (true: Boolean) match { case true => case false => case _: Any => } // exhaustive, last case is unreachable
+} \ No newline at end of file
diff --git a/test/files/pos/anyval-children.flags b/test/files/pos/anyval-children.flags
deleted file mode 100644
index 80fce051e6..0000000000
--- a/test/files/pos/anyval-children.flags
+++ /dev/null
@@ -1 +0,0 @@
--Ystop-after:erasure \ No newline at end of file
diff --git a/test/files/pos/contextbounds-implicits-new.scala b/test/files/pos/contextbounds-implicits-new.scala
index 71b3cca36f..327c4a98dc 100644
--- a/test/files/pos/contextbounds-implicits-new.scala
+++ b/test/files/pos/contextbounds-implicits-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
/* Tests implicit parameters in the presence of context bounds.
* See Section 7.4 of the Scala Language Specification.
*/
@@ -5,4 +7,4 @@ class C {
def f[T: TypeTag, S: TypeTag](x: T, y: S)(implicit p: C) { }
-}
+} \ No newline at end of file
diff --git a/test/files/pos/exhaustive_heuristics.scala b/test/files/pos/exhaustive_heuristics.scala
index f6bea455a5..297900510b 100644
--- a/test/files/pos/exhaustive_heuristics.scala
+++ b/test/files/pos/exhaustive_heuristics.scala
@@ -12,5 +12,15 @@ object Test {
case _ if turnOffChecks =>
}
- // TODO: we back off when there are any user-defined extractors
+ // we back off when there are any user-defined extractors
+ // in fact this is exhaustive, but we pretend we don't know since List's unapplySeq is not special to the compiler
+ // to compensate our ignorance, we back off
+ // well, in truth, we do rewrite List() to Nil, but otherwise we do nothing
+ // the full rewrite List(a, b) to a :: b :: Nil, for example is planned (but not sure it's a good idea)
+ List(true, false) match {
+ case List(_, _, _*) =>
+ case List(node, _*) =>
+ case Nil =>
+ }
+
} \ No newline at end of file
diff --git a/test/files/pos/implicits-new.scala b/test/files/pos/implicits-new.scala
index 7eb7e100c3..ffc387132a 100644
--- a/test/files/pos/implicits-new.scala
+++ b/test/files/pos/implicits-new.scala
@@ -1,3 +1,6 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.{ClassTag, classTag}
+
// #1435
object t1435 {
implicit def a(s:String):String = error("")
@@ -57,7 +60,7 @@ object Test1625 {
}
object Test2188 {
- implicit def toJavaList[A: ArrayTag](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*)
+ implicit def toJavaList[A: ClassTag](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*)
val x: java.util.List[String] = List("foo")
}
@@ -85,5 +88,5 @@ package foo2709 {
// Problem with specs
object specsProblem {
- println(implicitly[ConcreteTypeTag[Class[_]]])
-}
+ println(implicitly[TypeTag[Class[_]]])
+} \ No newline at end of file
diff --git a/test/files/pos/liftcode_polymorphic.scala b/test/files/pos/liftcode_polymorphic.scala
index 9c59b34bee..8f537d278a 100644
--- a/test/files/pos/liftcode_polymorphic.scala
+++ b/test/files/pos/liftcode_polymorphic.scala
@@ -1,13 +1,12 @@
-import scala.reflect.mirror._
-
-object Append extends Application {
-
- def append[A](l1: List[A], l2: List[A]):List[A] =
- l1 match {
- case Nil => l2
- case x::xs => x :: append(xs, l2)
- }
-
- println(reify(append _).tree)
-}
-
+import scala.reflect.runtime.universe._
+
+object Append extends Application {
+
+ def append[A](l1: List[A], l2: List[A]):List[A] =
+ l1 match {
+ case Nil => l2
+ case x::xs => x :: append(xs, l2)
+ }
+
+ println(reify(append _).tree)
+}
diff --git a/test/files/pos/manifest1-new.scala b/test/files/pos/manifest1-new.scala
index 645bd42665..3907d7854b 100644
--- a/test/files/pos/manifest1-new.scala
+++ b/test/files/pos/manifest1-new.scala
@@ -1,4 +1,4 @@
-import scala.reflect.TypeTag
+import scala.reflect.runtime.universe._
object Test {
def foo[T](x: T)(implicit m: TypeTag[T]) {
@@ -18,4 +18,4 @@ object Test {
val d: D = new D { type T = String; val m = stringm; val x = "x" }
import d.m
foo(d.x)
-}
+} \ No newline at end of file
diff --git a/test/files/pos/nothing_manifest_disambig-new.scala b/test/files/pos/nothing_manifest_disambig-new.scala
index a60b0fdbf8..ed3a9e8fb1 100644
--- a/test/files/pos/nothing_manifest_disambig-new.scala
+++ b/test/files/pos/nothing_manifest_disambig-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test {
def mani[T: TypeTag](xs: T) = xs
mani(List())
diff --git a/test/files/pos/spec-constr-new.scala b/test/files/pos/spec-constr-new.scala
index 7cd02b0680..7beff91d8d 100644
--- a/test/files/pos/spec-constr-new.scala
+++ b/test/files/pos/spec-constr-new.scala
@@ -1,7 +1,9 @@
-class SparseArray2[@specialized(Int) T:ArrayTag](val maxSize: Int, initialLength:Int = 3) {
+import scala.reflect.{ClassTag, classTag}
+
+class SparseArray2[@specialized(Int) T:ClassTag](val maxSize: Int, initialLength:Int = 3) {
private var data = new Array[T](initialLength);
private var index = new Array[Int](initialLength);
// comment out to compile correctly
data.length + 3;
-}
+} \ No newline at end of file
diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala
index 33f1e82b6e..ad9c6399a5 100644
--- a/test/files/pos/spec-doubledef-new.scala
+++ b/test/files/pos/spec-doubledef-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test {
def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T =
null.asInstanceOf[T]
@@ -25,4 +27,4 @@ abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int)
Pair(u, v2)
}
}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/spec-fields-new.scala b/test/files/pos/spec-fields-new.scala
index ddd8bd6624..de75b4b748 100644
--- a/test/files/pos/spec-fields-new.scala
+++ b/test/files/pos/spec-fields-new.scala
@@ -1,4 +1,6 @@
-abstract class Foo[@specialized T: ArrayTag, U <: Ordered[U]](x: T, size: Int) {
+import scala.reflect.{ClassTag, classTag}
+
+abstract class Foo[@specialized T: ClassTag, U <: Ordered[U]](x: T, size: Int) {
var y: T
var z: T = x
@@ -7,4 +9,4 @@ abstract class Foo[@specialized T: ArrayTag, U <: Ordered[U]](x: T, size: Int) {
def getZ = z
def setZ(zz: T) = z = zz
-}
+} \ No newline at end of file
diff --git a/test/files/pos/spec-params-new.scala b/test/files/pos/spec-params-new.scala
index 5fe0c82d40..661e686f0e 100644
--- a/test/files/pos/spec-params-new.scala
+++ b/test/files/pos/spec-params-new.scala
@@ -1,4 +1,6 @@
-class Foo[@specialized A: ArrayTag] {
+import scala.reflect.{ClassTag, classTag}
+
+class Foo[@specialized A: ClassTag] {
// conflicting in bounds, expect a normalized member calling m
// and bridge + implementation in specialized subclasses
@@ -29,4 +31,4 @@ class Foo[@specialized A: ArrayTag] {
val xs = new Array[A](1)
xs(0) = x
}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/spec-sparsearray-new.scala b/test/files/pos/spec-sparsearray-new.scala
index 0659bf7926..7b3934c476 100644
--- a/test/files/pos/spec-sparsearray-new.scala
+++ b/test/files/pos/spec-sparsearray-new.scala
@@ -1,6 +1,7 @@
+import scala.reflect.{ClassTag, classTag}
import scala.collection.mutable.MapLike
-class SparseArray[@specialized(Int) T:ArrayTag] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] {
+class SparseArray[@specialized(Int) T:ClassTag] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] {
override def get(x: Int) = {
val ind = findOffset(x)
if(ind < 0) None else Some(error("ignore"))
@@ -21,4 +22,4 @@ class SparseArray[@specialized(Int) T:ArrayTag] extends collection.mutable.Map[I
def -=(ind: Int) = error("ignore")
def +=(kv: (Int,T)) = error("ignore")
override final def iterator = error("ignore")
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t1381-new.scala b/test/files/pos/t1381-new.scala
index 8781ef4fdb..57e0f31fba 100644
--- a/test/files/pos/t1381-new.scala
+++ b/test/files/pos/t1381-new.scala
@@ -1,4 +1,4 @@
-import scala.reflect.TypeTag
+import scala.reflect.runtime.universe._
class D[V <: Variable]
@@ -28,4 +28,4 @@ abstract class EV[T](initval:T) extends PV[T](initval) with IV {
override def d : ID[VT] = null
// Comment this out to eliminate crash
protected var indx = d.index(initval)
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t2795-new.scala b/test/files/pos/t2795-new.scala
index af9c4e8b1c..a6a5fdb127 100644
--- a/test/files/pos/t2795-new.scala
+++ b/test/files/pos/t2795-new.scala
@@ -1,11 +1,13 @@
package t1
+import scala.reflect.{ClassTag, classTag}
+
trait Element[T] {
}
trait Config {
type T <: Element[T]
- implicit val m: ArrayTag[T]
+ implicit val m: ClassTag[T]
// XXX Following works fine:
// type T <: Element[_]
}
@@ -14,4 +16,4 @@ trait Transform { self: Config =>
def processBlock(block: Array[T]): Unit = {
var X = new Array[T](1)
}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t3097.flags b/test/files/pos/t3097.flags
deleted file mode 100644
index 144ddac9d3..0000000000
--- a/test/files/pos/t3097.flags
+++ /dev/null
@@ -1 +0,0 @@
--unchecked -Xfatal-warnings
diff --git a/test/files/pos/t3363-new.scala b/test/files/pos/t3363-new.scala
index 270462745c..e609f4d55f 100644
--- a/test/files/pos/t3363-new.scala
+++ b/test/files/pos/t3363-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object TestCase {
//now matter if you put (abstract) class or trait it will fail in all cases
@@ -15,4 +17,4 @@ object TestCase {
println(Map(1 -> "2") is List(2))
}
- }
+ } \ No newline at end of file
diff --git a/test/files/pos/t3498-new.scala b/test/files/pos/t3498-new.scala
index 653c50042a..eaf00cc351 100644
--- a/test/files/pos/t3498-new.scala
+++ b/test/files/pos/t3498-new.scala
@@ -1,4 +1,6 @@
-abstract class A[T, @specialized(scala.Int) U : ArrayTag] {
+import scala.reflect.{ClassTag, classTag}
+
+abstract class A[T, @specialized(scala.Int) U : ClassTag] {
def f(state: T): Array[U]
}
diff --git a/test/files/pos/t4579.flags b/test/files/pos/t4579.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/pos/t4579.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala
new file mode 100644
index 0000000000..2404b19da1
--- /dev/null
+++ b/test/files/pos/t4579.scala
@@ -0,0 +1,518 @@
+//############################################################################
+// Lisp interpreter (revived as an optimizer test.)
+//############################################################################
+
+//############################################################################
+// Lisp Scanner
+
+class LispTokenizer(s: String) extends Iterator[String] {
+ private var i = 0;
+ private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')'
+ def hasNext: Boolean = {
+ while (i < s.length() && s.charAt(i) <= ' ') i += 1
+ i < s.length()
+ }
+ def next: String =
+ if (hasNext) {
+ val start = i
+ if (isDelimiter(s charAt i)) i += 1
+ else
+ do i = i + 1
+ while (!isDelimiter(s charAt i))
+ s.substring(start, i)
+ } else sys.error("premature end of string")
+}
+
+//############################################################################
+// Lisp Interface
+
+trait Lisp {
+ type Data
+
+ def string2lisp(s: String): Data
+ def lisp2string(s: Data): String
+
+ def evaluate(d: Data): Data
+ // !!! def evaluate(s: String): Data = evaluate(string2lisp(s))
+ def evaluate(s: String): Data
+}
+
+//############################################################################
+// Lisp Implementation Using Case Classes
+
+object LispCaseClasses extends Lisp {
+
+ import List.range
+
+ trait Data {
+ def elemsToString(): String = toString();
+ }
+ case class CONS(car: Data, cdr: Data) extends Data {
+ override def toString() = "(" + elemsToString() + ")";
+ override def elemsToString() = car.toString() + (cdr match {
+ case NIL() => ""
+ case _ => " " + cdr.elemsToString();
+ })
+ }
+ case class NIL() extends Data { // !!! use case object
+ override def toString() = "()";
+ }
+ case class SYM(name: String) extends Data {
+ override def toString() = name;
+ }
+ case class NUM(x: Int) extends Data {
+ override def toString() = x.toString();
+ }
+ case class STR(x: String) extends Data {
+ override def toString() = "\"" + x + "\"";
+ }
+ case class FUN(f: List[Data] => Data) extends Data {
+ override def toString() = "<fn>";
+ }
+
+ def list(): Data =
+ NIL();
+ def list(x0: Data): Data =
+ CONS(x0, NIL());
+ def list(x0: Data, x1: Data): Data =
+ CONS(x0, list(x1));
+ def list(x0: Data, x1: Data, x2: Data): Data =
+ CONS(x0, list(x1, x2));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data): Data =
+ CONS(x0, list(x1, x2, x3));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4, x5));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
+ x6: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4, x5, x6));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
+ x6: Data, x7: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4, x5, x6, x7));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
+ x6: Data, x7: Data, x8: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8));
+ def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
+ x6: Data, x7: Data, x8: Data, x9: Data): Data =
+ CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9));
+
+ var curexp: Data = null
+ var trace: Boolean = false
+ var indent: Int = 0
+
+ def lispError[a](msg: String): a =
+ sys.error("error: " + msg + "\n" + curexp);
+
+ trait Environment {
+ def lookup(n: String): Data;
+ def extendRec(name: String, expr: Environment => Data) =
+ new Environment {
+ def lookup(n: String): Data =
+ if (n == name) expr(this) else Environment.this.lookup(n);
+ }
+ def extend(name: String, v: Data) = extendRec(name, (env1 => v));
+ }
+ val EmptyEnvironment = new Environment {
+ def lookup(n: String): Data = lispError("undefined: " + n);
+ }
+
+ def toList(x: Data): List[Data] = x match {
+ case NIL() => List()
+ case CONS(y, ys) => y :: toList(ys)
+ case _ => lispError("malformed list: " + x);
+ }
+
+ def toBoolean(x: Data) = x match {
+ case NUM(0) => false
+ case _ => true
+ }
+
+ def normalize(x: Data): Data = x match {
+ case CONS(SYM("def"),
+ CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) =>
+ normalize(list(SYM("def"),
+ SYM(name), list(SYM("lambda"), args, body), expr))
+ case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) =>
+ normalize(expr)
+ case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) =>
+ normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest)))
+ case CONS(h, t) => CONS(normalize(h), normalize(t))
+ case _ => x
+ }
+
+ def eval(x: Data, env: Environment): Data = {
+ val prevexp = curexp;
+ curexp = x;
+ if (trace) {
+ for (x <- range(1, indent)) Console.print(" ");
+ Console.println("===> " + x);
+ indent = indent + 1;
+ }
+ val result = eval1(x, env);
+ if (trace) {
+ indent = indent - 1;
+ for (x <- range(1, indent)) Console.print(" ");
+ Console.println("<=== " + result);
+ }
+ curexp = prevexp;
+ result
+ }
+
+ def eval1(x: Data, env: Environment): Data = x match {
+ case SYM(name) =>
+ env lookup name
+ case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) =>
+ eval(z, env.extendRec(name, (env1 => eval(y, env1))))
+ case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) =>
+ eval(z, env.extend(name, eval(y, env)))
+ case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) =>
+ mkLambda(params, y, env)
+ case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) =>
+ if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env)
+ case CONS(SYM("quote"), CONS(x, NIL())) =>
+ x
+ case CONS(y, xs) =>
+ apply(eval(y, env), toList(xs) map (x => eval(x, env)))
+ case NUM(_) => x
+ case STR(_) => x
+ case FUN(_) => x
+ case _ =>
+ lispError("illegal term")
+ }
+
+ def apply(fn: Data, args: List[Data]): Data = fn match {
+ case FUN(f) => f(args);
+ case _ => lispError("application of non-function: " + fn);
+ }
+
+ def mkLambda(params: Data, expr: Data, env: Environment): Data = {
+
+ def extendEnv(env: Environment,
+ ps: List[String], args: List[Data]): Environment =
+ Pair(ps, args) match {
+ case Pair(List(), List()) =>
+ env
+ case Pair(p :: ps1, arg :: args1) =>
+ extendEnv(env.extend(p, arg), ps1, args1)
+ case _ =>
+ lispError("wrong number of arguments")
+ }
+
+ val ps: List[String] = toList(params) map {
+ case SYM(name) => name
+ case _ => sys.error("illegal parameter list");
+ }
+
+ FUN(args => eval(expr, extendEnv(env, ps, args)))
+ }
+
+ val globalEnv = EmptyEnvironment
+ .extend("=", FUN({
+ case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0)
+ case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)}))
+ .extend("+", FUN({
+ case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2)
+ case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)}))
+ .extend("-", FUN({
+ case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)}))
+ .extend("*", FUN({
+ case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)}))
+ .extend("/", FUN({
+ case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)}))
+ .extend("car", FUN({
+ case List(CONS(x, xs)) => x}))
+ .extend("cdr", FUN({
+ case List(CONS(x, xs)) => xs}))
+ .extend("null?", FUN({
+ case List(NIL()) => NUM(1)
+ case _ => NUM(0)}))
+ .extend("cons", FUN({
+ case List(x, y) => CONS(x, y)}));
+
+ def evaluate(x: Data): Data = eval(normalize(x), globalEnv);
+ def evaluate(s: String): Data = evaluate(string2lisp(s));
+
+ def string2lisp(s: String): Data = {
+ val it = new LispTokenizer(s);
+ def parseExpr(token: String): Data = {
+ if (token == "(") parseList
+ else if (token == ")") sys.error("unbalanced parentheses")
+ else if ('0' <= token.charAt(0) && token.charAt(0) <= '9')
+ NUM(token.toInt)
+ else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"')
+ STR(token.substring(1,token.length() - 1))
+ else SYM(token)
+ }
+ def parseList: Data = {
+ val token = it.next;
+ if (token == ")") NIL() else CONS(parseExpr(token), parseList)
+ }
+ parseExpr(it.next)
+ }
+
+ def lisp2string(d: Data): String = d.toString();
+}
+
+//############################################################################
+// Lisp Implementation Using Any
+
+object LispAny extends Lisp {
+
+ import List._;
+
+ type Data = Any;
+
+ case class Lambda(f: List[Data] => Data);
+
+ var curexp: Data = null;
+ var trace: Boolean = false;
+ var indent: Int = 0;
+
+ def lispError[a](msg: String): a =
+ sys.error("error: " + msg + "\n" + curexp);
+
+ trait Environment {
+ def lookup(n: String): Data;
+ def extendRec(name: String, expr: Environment => Data) =
+ new Environment {
+ def lookup(n: String): Data =
+ if (n == name) expr(this) else Environment.this.lookup(n);
+ }
+ def extend(name: String, v: Data) = extendRec(name, (env1 => v));
+ }
+ val EmptyEnvironment = new Environment {
+ def lookup(n: String): Data = lispError("undefined: " + n);
+ }
+
+ def asList(x: Data): List[Data] = x match {
+ case y: List[_] => y
+ case _ => lispError("malformed list: " + x)
+ }
+
+ def asInt(x: Data): Int = x match {
+ case y: Int => y
+ case _ => lispError("not an integer: " + x)
+ }
+
+ def asString(x: Data): String = x match {
+ case y: String => y
+ case _ => lispError("not a string: " + x)
+ }
+
+ def asBoolean(x: Data): Boolean = x != 0
+
+ def normalize(x: Data): Data = x match {
+ case 'and :: x :: y :: Nil =>
+ normalize('if :: x :: y :: 0 :: Nil)
+ case 'or :: x :: y :: Nil =>
+ normalize('if :: x :: 1 :: y :: Nil)
+ case 'def :: (name :: args) :: body :: expr :: Nil =>
+ normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil)
+ case 'cond :: ('else :: expr :: Nil) :: rest =>
+ normalize(expr);
+ case 'cond :: (test :: expr :: Nil) :: rest =>
+ normalize('if :: test :: expr :: ('cond :: rest) :: Nil)
+ case 'cond :: 'else :: expr :: Nil =>
+ normalize(expr)
+ case h :: t =>
+ normalize(h) :: asList(normalize(t))
+ case _ =>
+ x
+ }
+
+ def eval(x: Data, env: Environment): Data = {
+ val prevexp = curexp;
+ curexp = x;
+ if (trace) {
+ for (x <- range(1, indent)) Console.print(" ");
+ Console.println("===> " + x);
+ indent += 1;
+ }
+ val result = eval1(x, env);
+ if (trace) {
+ indent -= 1;
+ for (x <- range(1, indent)) Console.print(" ");
+ Console.println("<=== " + result);
+ }
+ curexp = prevexp;
+ result
+ }
+
+ def eval1(x: Data, env: Environment): Data = x match {
+ case Symbol(name) =>
+ env lookup name
+ case 'def :: Symbol(name) :: y :: z :: Nil =>
+ eval(z, env.extendRec(name, (env1 => eval(y, env1))))
+ case 'val :: Symbol(name) :: y :: z :: Nil =>
+ eval(z, env.extend(name, eval(y, env)))
+ case 'lambda :: params :: y :: Nil =>
+ mkLambda(params, y, env)
+ case 'if :: c :: y :: z :: Nil =>
+ if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env)
+ case 'quote :: y :: Nil =>
+ y
+ case y :: z =>
+ apply(eval(y, env), z map (x => eval(x, env)))
+ case Lambda(_) => x
+ case y: String => x
+ case y: Int => x
+ case y => lispError("illegal term")
+ }
+
+ def lisp2string(x: Data): String = x match {
+ case Symbol(name) => name
+ case Nil => "()"
+ case y :: ys =>
+ def list2string(xs: List[Data]): String = xs match {
+ case List() => ""
+ case y :: ys => " " + lisp2string(y) + list2string(ys)
+ }
+ "(" + lisp2string(y) + list2string(ys) + ")"
+ case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString()
+ }
+
+ def apply(fn: Data, args: List[Data]): Data = fn match {
+ case Lambda(f) => f(args);
+ case _ => lispError("application of non-function: " + fn + " to " + args);
+ }
+
+ def mkLambda(params: Data, expr: Data, env: Environment): Data = {
+
+ def extendEnv(env: Environment,
+ ps: List[String], args: List[Data]): Environment =
+ Pair(ps, args) match {
+ case Pair(List(), List()) =>
+ env
+ case Pair(p :: ps1, arg :: args1) =>
+ extendEnv(env.extend(p, arg), ps1, args1)
+ case _ =>
+ lispError("wrong number of arguments")
+ }
+
+ val ps: List[String] = asList(params) map {
+ case Symbol(name) => name
+ case _ => sys.error("illegal parameter list");
+ }
+
+ Lambda(args => eval(expr, extendEnv(env, ps, args)))
+ }
+
+ val globalEnv = EmptyEnvironment
+ .extend("=", Lambda{
+ case List(arg1, arg2) => if(arg1 == arg2) 1 else 0})
+ .extend("+", Lambda{
+ case List(arg1: Int, arg2: Int) => arg1 + arg2
+ case List(arg1: String, arg2: String) => arg1 + arg2})
+ .extend("-", Lambda{
+ case List(arg1: Int, arg2: Int) => arg1 - arg2})
+ .extend("*", Lambda{
+ case List(arg1: Int, arg2: Int) => arg1 * arg2})
+ .extend("/", Lambda{
+ case List(arg1: Int, arg2: Int) => arg1 / arg2})
+ .extend("nil", Nil)
+ .extend("cons", Lambda{
+ case List(arg1, arg2) => arg1 :: asList(arg2)})
+ .extend("car", Lambda{
+ case List(x :: xs) => x})
+ .extend("cdr", Lambda{
+ case List(x :: xs) => xs})
+ .extend("null?", Lambda{
+ case List(Nil) => 1
+ case _ => 0});
+
+ def evaluate(x: Data): Data = eval(normalize(x), globalEnv);
+ def evaluate(s: String): Data = evaluate(string2lisp(s));
+
+ def string2lisp(s: String): Data = {
+ val it = new LispTokenizer(s);
+ def parseExpr(token: String): Data = {
+ if (token == "(") parseList
+ else if (token == ")") sys.error("unbalanced parentheses")
+ //else if (Character.isDigit(token.charAt(0)))
+ else if (token.charAt(0).isDigit)
+ token.toInt
+ else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"')
+ token.substring(1,token.length() - 1)
+ else Symbol(token)
+ }
+ def parseList: List[Data] = {
+ val token = it.next;
+ if (token == ")") Nil else parseExpr(token) :: parseList
+ }
+ parseExpr(it.next)
+ }
+}
+
+//############################################################################
+// List User
+
+class LispUser(lisp: Lisp) {
+
+ import lisp._;
+
+ def evaluate(s: String) = lisp2string(lisp.evaluate(s));
+
+ def run = {
+
+ Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]);
+ Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))")));
+ Console.println;
+
+ Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))"));
+ Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))"));
+ Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))"));
+ Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))"));
+ Console.println("(null? '()) = " + evaluate("(null? (quote()))"));
+ Console.println;
+
+ Console.println("faculty(10) = " + evaluate(
+ "(def (faculty n) " +
+ "(if (= n 0) " +
+ "1 " +
+ "(* n (faculty (- n 1)))) " +
+ "(faculty 10))"));
+ Console.println("faculty(10) = " + evaluate(
+ "(def (faculty n) " +
+ "(cond " +
+ "((= n 0) 1) " +
+ "(else (* n (faculty (- n 1))))) " +
+ "(faculty 10))"));
+ Console.println("foobar = " + evaluate(
+ "(def (foo n) " +
+ "(cond " +
+ "((= n 0) \"a\")" +
+ "((= n 1) \"b\")" +
+ "((= (/ n 2) 1) " +
+ "(cond " +
+ "((= n 2) \"c\")" +
+ "(else \"d\")))" +
+ "(else " +
+ "(def (bar m) " +
+ "(cond " +
+ "((= m 0) \"e\")" +
+ "((= m 1) \"f\")" +
+ "(else \"z\"))" +
+ "(bar (- n 4)))))" +
+ "(val nil (quote ())" +
+ "(val v1 (foo 0) " +
+ "(val v2 (+ (foo 1) (foo 2)) " +
+ "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " +
+ "(val v4 (foo 6) " +
+ "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))"));
+ Console.println;
+ }
+}
+
+//############################################################################
+// Main
+
+object Test {
+ def main(args: Array[String]) {
+ new LispUser(LispCaseClasses).run;
+ new LispUser(LispAny).run;
+ ()
+ }
+}
+
+//############################################################################
diff --git a/test/files/pos/t4911.flags b/test/files/pos/t4911.flags
new file mode 100644
index 0000000000..779916d58f
--- /dev/null
+++ b/test/files/pos/t4911.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t4911.scala b/test/files/pos/t4911.scala
new file mode 100644
index 0000000000..66c867a37f
--- /dev/null
+++ b/test/files/pos/t4911.scala
@@ -0,0 +1,16 @@
+import language._
+
+object Test {
+ class Foo[T](val x: T) ; object Foo { def unapply[T](x: Foo[T]) = Some(x.x) }
+ def f1[T](x: Foo[T]) = x match { case Foo(y) => y }
+ def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y }
+
+ case class Bar[T](x: T)
+ def f3[T](x: Bar[T]) = x match { case Bar(y) => y }
+ def f4[M[_], T](x: M[T]) = x match { case Bar(y) => y }
+}
+//
+// ./b.scala:4: warning: non variable type-argument T in type pattern Test.Foo[T] is unchecked since it is eliminated by erasure
+// def f2[M[_], T](x: M[T]) = x match { case Foo(y) => y }
+// ^
+// one warning found \ No newline at end of file
diff --git a/test/files/pos/t5041.scala b/test/files/pos/t5041.scala
new file mode 100644
index 0000000000..78a1b27d5a
--- /dev/null
+++ b/test/files/pos/t5041.scala
@@ -0,0 +1,9 @@
+case class Token(text: String, startIndex: Int)
+
+object Comment {
+ def unapply(s: String): Option[Token] = None
+}
+
+object HiddenTokens {
+ "foo" match { case Comment(_) => }
+}
diff --git a/test/files/pos/t5223.scala b/test/files/pos/t5223.scala
index 398630dc61..0b2528e367 100644
--- a/test/files/pos/t5223.scala
+++ b/test/files/pos/t5223.scala
@@ -1,6 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Foo extends App {
reify{def printf(format: String, args: Any*): String = null }
reify{def printf(format: String, args: Any*): String = ("abc": @cloneable)}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t5305.scala b/test/files/pos/t5305.scala
index 4c32cd7c6d..c0237ca3bd 100644
--- a/test/files/pos/t5305.scala
+++ b/test/files/pos/t5305.scala
@@ -7,7 +7,7 @@ object t5305 {
}
in {
- import O.{F, v}
+ import O.{F, v}
type x = {type l = (F, v.type)} // not found: type F
}
}
diff --git a/test/files/pos/t531.scala b/test/files/pos/t531.scala
index 5176912ef0..d53539f34f 100644
--- a/test/files/pos/t531.scala
+++ b/test/files/pos/t531.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def titi = {
@@ -8,4 +8,4 @@ object Test extends App {
}}
()
}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t5313.scala b/test/files/pos/t5313.scala
new file mode 100644
index 0000000000..e77b73ca4c
--- /dev/null
+++ b/test/files/pos/t5313.scala
@@ -0,0 +1,30 @@
+object DepBug {
+ class A {
+ class B
+ def mkB = new B
+ def m(b : B) = b
+ }
+
+ trait Dep {
+ val a : A
+ val b : a.B
+ }
+
+ val dep = new Dep {
+ val a = new A
+ val b = a.mkB
+ }
+
+ def useDep(d : Dep) {
+ import d._
+ a.m(b) // OK
+ }
+
+ {
+ import dep._
+ a.m(b) // OK with 2.9.1.final, error on trunk
+ }
+
+ dep.a.m(dep.b)
+
+}
diff --git a/test/files/pos/t532.scala b/test/files/pos/t532.scala
index a319fdfa27..7c33637b5d 100644
--- a/test/files/pos/t532.scala
+++ b/test/files/pos/t532.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def titi: Unit = {
@@ -8,4 +8,4 @@ object Test extends App {
}}
()
}
-}
+} \ No newline at end of file
diff --git a/test/files/pos/t5399.scala b/test/files/pos/t5399.scala
new file mode 100644
index 0000000000..ebae7dbd9e
--- /dev/null
+++ b/test/files/pos/t5399.scala
@@ -0,0 +1,45 @@
+class Test {
+ class A[T]
+ class B[T](val a: A[T])
+
+ case class CaseClass[T](x: T)
+
+ def break(existB: B[_]) =
+ CaseClass(existB.a) match { case CaseClass(_) => }
+}
+
+class Foo {
+ trait Init[T]
+ class ScopedKey[T] extends Init[T]
+
+ trait Setting[T] {
+ val key: ScopedKey[T]
+ }
+
+ case class ScopedKey1[T](val foo: Init[T]) extends ScopedKey[T]
+
+ val scalaHome: Setting[Option[String]] = null
+ val scalaVersion: Setting[String] = null
+
+ def testPatternMatch(s: Setting[_]) {
+ s.key match {
+ case ScopedKey1(scalaHome.key | scalaVersion.key) => ()
+ }
+ }
+}
+
+class Test2 {
+ type AnyCyclic = Execute[Task]#CyclicException[_]
+
+ trait Task[T]
+
+ trait Execute[A[_] <: AnyRef] {
+ class CyclicException[T](val caller: A[T], val target: A[T])
+ }
+
+ def convertCyclic(c: AnyCyclic): String =
+ (c.caller, c.target) match {
+ case (caller: Task[_], target: Task[_]) => "bazinga!"
+ }
+}
+
diff --git a/test/files/pos/t5769.scala b/test/files/pos/t5769.scala
index 723d37bfee..fdc46b65e9 100644
--- a/test/files/pos/t5769.scala
+++ b/test/files/pos/t5769.scala
@@ -1,8 +1,9 @@
// a.scala
+import scala.reflect.{ClassTag, classTag}
class A {
type AI = Array[Int]
- def f1 = arrayTag[Array[Int]]
- def f2 = arrayTag[AI]
+ def f1 = classTag[Array[Int]]
+ def f2 = classTag[AI]
} \ No newline at end of file
diff --git a/test/files/pos/t5809.scala b/test/files/pos/t5809.scala
index 8f6ce708d2..133e13c4ed 100644
--- a/test/files/pos/t5809.scala
+++ b/test/files/pos/t5809.scala
@@ -1,10 +1,5 @@
-package scala.reflect
-
-package object api {
- implicit class PimpedExpr[T](expr: Universe # Expr[T]) {
- def runtimeEval: T = {
- println("hello, dear")
- expr.eval
- }
+package object foo {
+ implicit class PimpedInt(foo: Int) {
+ def bar = ???
}
} \ No newline at end of file
diff --git a/test/files/pos/t5829.scala b/test/files/pos/t5829.scala
new file mode 100644
index 0000000000..236045ed11
--- /dev/null
+++ b/test/files/pos/t5829.scala
@@ -0,0 +1,18 @@
+trait Universe {
+ type Tree
+
+ type SymTree <: Tree
+ type NameTree <: Tree
+ type RefTree <: SymTree with NameTree
+
+ type Ident <: RefTree
+ type Select <: RefTree
+}
+
+object Test extends App {
+ val universe: Universe = null
+ import universe._
+ def select: Select = ???
+ def ident: Ident = ???
+ List(select, ident)
+} \ No newline at end of file
diff --git a/test/files/pos/t5853.scala b/test/files/pos/t5853.scala
new file mode 100644
index 0000000000..21d80206ab
--- /dev/null
+++ b/test/files/pos/t5853.scala
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+final class C(val x: Int) extends AnyVal {
+ def ppp[@specialized(Int) T](y: T) = ()
+}
+
+
+class Foo {
+ def f = new C(1) ppp 2
+}
+
+
+/* Original SI-5853 test-case. */
+
+object Bippy {
+ implicit final class C(val x: Int) extends AnyVal {
+ def +++[@specialized T](y: T) = ()
+ }
+ def f = 1 +++ 2
+}
+
+
+/* Few more examples. */
+
+final class C2(val x: Int) extends AnyVal {
+ def +++[@specialized(Int) T](y: T) = ()
+}
+
+
+class Foo2 {
+ def f = new C2(1) +++ 2
+}
+
+
+object Arrow {
+ implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal {
+ @inline def ->>[B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y)
+ }
+
+ def foo = 1 ->> 2
+}
+
+
+object SpecArrow {
+ implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal {
+ @inline def ->> [@specialized(Int) B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y)
+ }
+
+ def foo = 1 ->> 2
+}
diff --git a/test/files/pos/t5862.scala b/test/files/pos/t5862.scala
new file mode 100644
index 0000000000..e3006ddc3f
--- /dev/null
+++ b/test/files/pos/t5862.scala
@@ -0,0 +1,38 @@
+package test
+
+import java.io.DataOutput
+import java.io.DataInput
+
+/** Interface for writing outputs from a DoFn. */
+trait Emitter[A] {
+ def emit(value: A): Unit
+}
+
+/** A wrapper for a 'map' function tagged for a specific output channel. */
+abstract class TaggedMapper[A, K, V]
+ (val tags: Set[Int])
+ (implicit val mA: Manifest[A], val wtA: WireFormat[A],
+ val mK: Manifest[K], val wtK: WireFormat[K], val ordK: Ordering[K],
+ val mV: Manifest[V], val wtV: WireFormat[V])
+ extends Serializable {
+}
+
+/** Type-class for sending types across the Hadoop wire. */
+trait WireFormat[A]
+
+class MapReduceJob {
+ trait DataSource
+
+ import scala.collection.mutable.{ Set => MSet, Map => MMap }
+ private val mappers: MMap[DataSource, MSet[TaggedMapper[_, _, _]]] = MMap.empty
+
+ def addTaggedMapper[A, K, V](input: DataSource, m: TaggedMapper[A, K, V]): Unit = {
+ if (!mappers.contains(input))
+ mappers += (input -> MSet(m))
+ else
+ mappers(input) += m // : Unit
+
+ m.tags.foreach { tag =>
+ }
+ }
+}
diff --git a/test/files/pos/typetags.scala b/test/files/pos/typetags.scala
new file mode 100644
index 0000000000..33390d7b89
--- /dev/null
+++ b/test/files/pos/typetags.scala
@@ -0,0 +1,12 @@
+import scala.reflect.{basis => rb}
+import scala.reflect.runtime.{universe => ru}
+
+object Test {
+ def main(args: Array[String]) {
+ def foo(implicit t: rb.TypeTag[List[Int]]) {
+ println(t)
+ val t2: ru.TypeTag[_] = t in ru.rootMirror
+ println(t2)
+ }
+ }
+}
diff --git a/test/files/pos/value-class-override-no-spec.flags b/test/files/pos/value-class-override-no-spec.flags
new file mode 100644
index 0000000000..a7e64e4f0c
--- /dev/null
+++ b/test/files/pos/value-class-override-no-spec.flags
@@ -0,0 +1 @@
+-no-specialization \ No newline at end of file
diff --git a/test/files/pos/value-class-override-no-spec.scala b/test/files/pos/value-class-override-no-spec.scala
new file mode 100644
index 0000000000..79de5d9305
--- /dev/null
+++ b/test/files/pos/value-class-override-no-spec.scala
@@ -0,0 +1,9 @@
+// There are two versions of this tests: one with and one without specialization.
+// The bug was only exposed *without* specialization.
+trait T extends Any {
+ def x: Any
+}
+
+final class StringOps(val repr0: String) extends AnyVal with T {
+ def x = ()
+}
diff --git a/test/files/pos/value-class-override-spec.scala b/test/files/pos/value-class-override-spec.scala
new file mode 100644
index 0000000000..79de5d9305
--- /dev/null
+++ b/test/files/pos/value-class-override-spec.scala
@@ -0,0 +1,9 @@
+// There are two versions of this tests: one with and one without specialization.
+// The bug was only exposed *without* specialization.
+trait T extends Any {
+ def x: Any
+}
+
+final class StringOps(val repr0: String) extends AnyVal with T {
+ def x = ()
+}
diff --git a/test/files/pos/virtpatmat_reach_const.scala b/test/files/pos/virtpatmat_reach_const.scala
new file mode 100644
index 0000000000..b55b7cb229
--- /dev/null
+++ b/test/files/pos/virtpatmat_reach_const.scala
@@ -0,0 +1,11 @@
+// check the interaction between constants and type tests in creating the equality axioms
+object Test {
+ type Formula = List[String]
+ val TrueF: Formula = List()
+ def distribute(a: Formula, b: Formula) = (a, b) match {
+ case (TrueF, _) =>
+ case (_, TrueF) => // bug: considered unreachable
+ case (a :: Nil, b :: Nil) =>
+ case _ =>
+ }
+} \ No newline at end of file
diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check
index dcbd440801..e813ce119b 100644
--- a/test/files/presentation/ide-bug-1000531.check
+++ b/test/files/presentation/ide-bug-1000531.check
@@ -97,7 +97,7 @@ retrieved 124 members
[accessible: true] `method synchronized[T0](x$1: T0)T0`
[accessible: true] `method take(n: Int)Iterator[B]`
[accessible: true] `method takeWhile(p: B => Boolean)Iterator[B]`
-[accessible: true] `method toArray[B >: B](implicit evidence$1: ArrayTag[B])Array[B]`
+[accessible: true] `method toArray[B >: B](implicit evidence$1: scala.reflect.ClassTag[B])Array[B]`
[accessible: true] `method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]`
[accessible: true] `method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]`
[accessible: true] `method toIterable=> Iterable[B]`
diff --git a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
index 45b38da85b..857beac7df 100644
--- a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
+++ b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
@@ -7,16 +7,16 @@ import scala.tools.nsc.util._
import scala.tools.nsc.io._
/** This test runs the presentation compiler on the Scala compiler project itself and records memory consumption.
- *
+ *
* The test scenario is to open Typers, Trees and Types, then repeatedly add and remove one character
* in Typers.scala. Each step causes the parser, namer, and type checker to run.
- *
- * At each step we record the memory usage after the GC has run. At the end of the test,
+ *
+ * At each step we record the memory usage after the GC has run. At the end of the test,
* simple linear regression is used to compute the straight line that best fits the
* curve, and if the slope is higher than 1 (meaning a leak of 1MB/run), we fail the test.
- *
+ *
* The Scala compiler sources are assumed to be under 'basedir/src/compiler'.
- *
+ *
* The individual data points are saved under 'usedMem-<date>.txt', under the test project
* directory. Use the cool graph-it.R (https://github.com/scala-ide/scala-ide/blob/master/org.scala-ide.sdt.core.tests/graph-it.R)
* script to see the memory curve for the given test run.
@@ -37,10 +37,10 @@ object Test extends InteractiveTest {
val filename = "usedmem-%tF.txt".format(Calendar.getInstance.getTime)
val typerUnit = AbstractFile.getFile(baseDir.parent.parent.parent.parent / "src/compiler/scala/tools/nsc/typechecker/Typers.scala")
- val typesUnit = AbstractFile.getFile(baseDir.parent.parent.parent.parent / "src/compiler/scala/reflect/internal/Types.scala")
- val treesUnit = AbstractFile.getFile(baseDir.parent.parent.parent.parent / "src/compiler/scala/reflect/internal/Trees.scala")
+ val typesUnit = AbstractFile.getFile(baseDir.parent.parent.parent.parent / "src/reflect/scala/reflect/internal/Types.scala")
+ val treesUnit = AbstractFile.getFile(baseDir.parent.parent.parent.parent / "src/reflect/scala/reflect/internal/Trees.scala")
- askReload(Seq(new BatchSourceFile(typerUnit), new BatchSourceFile(typesUnit), new BatchSourceFile(treesUnit)))
+ askReload(Seq(new BatchSourceFile(typerUnit), new BatchSourceFile(typesUnit), new BatchSourceFile(treesUnit)))
typeCheckWith(treesUnit, new String(treesUnit.toCharArray))
typeCheckWith(typesUnit, new String(typesUnit.toCharArray))
@@ -58,12 +58,12 @@ object Test extends InteractiveTest {
usedMem / mega // report size in MB
}
-
+
//dumpDataToFile(filename, usedMem)
// drop the first two measurements, since the compiler needs some memory when initializing
val (a, b) = linearModel((3L to N).toSeq, usedMem.drop(2))
//println("LinearModel: constant: %.4f\tslope:%.4f".format(a, b))
-
+
if (b > 1.0)
println("Rate of memory consumption is alarming! %.4f MB/run".format(b))
else
@@ -84,33 +84,33 @@ object Test extends InteractiveTest {
}
outputFile.close()
}
-
-
- /** Return the linear model of these values, (a, b). First value is the constant factor,
+
+
+ /** Return the linear model of these values, (a, b). First value is the constant factor,
* second value is the slope, i.e. `y = a + bx`
- *
- * The linear model of a set of points is a straight line that minimizes the square distance
+ *
+ * The linear model of a set of points is a straight line that minimizes the square distance
* between the each point and the line.
- *
+ *
* See: http://en.wikipedia.org/wiki/Simple_linear_regression
*/
def linearModel(xs: Seq[Long], ys: Seq[Long]): (Double, Double) = {
require(xs.length == ys.length)
-
+
def mean(v: Seq[Long]): Double = v.sum.toDouble / v.length
-
+
val meanXs = mean(xs)
val meanYs = mean(ys)
-
+
val beta = (mean((xs, ys).zipped.map(_ * _)) - meanXs * meanYs) / (mean(xs.map(x => x * x)) - meanXs * meanXs)
val alfa = meanYs - beta * meanXs
-
+
(alfa, beta)
}
/** Run the given closure and return the amount of used memory at the end of its execution.
- *
- * Runs the GC before and after the execution of `f'.
+ *
+ * Runs the GC before and after the execution of `f'.
*/
def withGC(f: => Unit): Long = {
val r = Runtime.getRuntime
diff --git a/test/files/run/Course-2002-01-msil.check b/test/files/run/Course-2002-01-msil.check
deleted file mode 100644
index ca9d7ac54b..0000000000
--- a/test/files/run/Course-2002-01-msil.check
+++ /dev/null
@@ -1,34 +0,0 @@
-232
-667
-11
-10
-62.8318
-62.8318
-62.8318
-4
-81
-256
-25
-1
-737
-1
-0
-1
-76
-1.41421568627451
-1.73214285714286
-2.00000009292229
-1.41421568627451
-1.73214285714286
-2.00000009292229
-1.41421568627451
-1.73214285714286
-2.00000009292229
-sqrt(2) = 1.41421356237469
-sqrt(2) = 1.41421356237469
-cbrt(2) = 1.25992105001777
-1
-1 1
-1 2 1
-1 3 3 1
-1 4 6 4 1
diff --git a/test/files/run/Course-2002-02-msil.check b/test/files/run/Course-2002-02-msil.check
deleted file mode 100644
index 12ac0b1739..0000000000
--- a/test/files/run/Course-2002-02-msil.check
+++ /dev/null
@@ -1,187 +0,0 @@
-7
-120
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-
-pi = 3.18110488557771
-pi = 3.18110488557771
-
-10
-100
-2.08333333333333
-3025.76877140318
-pi = 3.16597927284322
-pi = 3.18110488557771
-pi = 3.18110488557771
-
-1.5
-1.41666666666667
-1.41421568627451
-1.41421356237469
-sqrt(2) = 1.41421356237469
-
-1.5
-1.41666666666667
-1.41421568627451
-1.41421356237469
-sqrt(2) = 1.41421356237469
-
-1 + 2 + .. + 5 = 15
-1 * 2 * .. * 5 = 120
-
-1^2 + 2^2 + .. + 5^2 = 55
-1^2 * 2^2 * .. * 5^2 = 14400
-
-factorial(0) = 1
-factorial(1) = 1
-factorial(2) = 2
-factorial(3) = 6
-factorial(4) = 24
-factorial(5) = 120
-
-1 + 2 + .. + 5 = 15
-1 * 2 * .. * 5 = 120
-
-1^2 + 2^2 + .. + 5^2 = 55
-1^2 * 2^2 * .. * 5^2 = 14400
-
-factorial(0) = 1
-factorial(1) = 1
-factorial(2) = 2
-factorial(3) = 6
-factorial(4) = 24
-factorial(5) = 120
-
-1 + 2 + .. + 5 = 15
-1 * 2 * .. * 5 = 120
-
-1^2 + 2^2 + .. + 5^2 = 55
-1^2 * 2^2 * .. * 5^2 = 14400
-
-factorial(0) = 1
-factorial(1) = 1
-factorial(2) = 2
-factorial(3) = 6
-factorial(4) = 24
-factorial(5) = 120
-
-fib(0) = 0
-fib(1) = 1
-fib(2) = 1
-fib(3) = 2
-fib(4) = 3
-fib(5) = 5
-fib(6) = 8
-fib(7) = 13
-fib(8) = 21
-fib(9) = 34
-fib(0) = 0
-fib(1) = 1
-fib(2) = 1
-fib(3) = 2
-fib(4) = 3
-fib(5) = 5
-fib(6) = 8
-fib(7) = 13
-fib(8) = 21
-fib(9) = 34
-power(0,0) = 1
-power(0,1) = 0
-power(0,2) = 0
-power(0,3) = 0
-power(0,4) = 0
-power(0,5) = 0
-power(0,6) = 0
-power(0,7) = 0
-power(0,8) = 0
-
-power(1,0) = 1
-power(1,1) = 1
-power(1,2) = 1
-power(1,3) = 1
-power(1,4) = 1
-power(1,5) = 1
-power(1,6) = 1
-power(1,7) = 1
-power(1,8) = 1
-
-power(2,0) = 1
-power(2,1) = 2
-power(2,2) = 4
-power(2,3) = 8
-power(2,4) = 16
-power(2,5) = 32
-power(2,6) = 64
-power(2,7) = 128
-power(2,8) = 256
-
-power(3,0) = 1
-power(3,1) = 3
-power(3,2) = 9
-power(3,3) = 27
-power(3,4) = 81
-power(3,5) = 243
-power(3,6) = 729
-power(3,7) = 2187
-power(3,8) = 6561
-
-power(4,0) = 1
-power(4,1) = 4
-power(4,2) = 16
-power(4,3) = 64
-power(4,4) = 256
-power(4,5) = 1024
-power(4,6) = 4096
-power(4,7) = 16384
-power(4,8) = 65536
-
-power(5,0) = 1
-power(5,1) = 5
-power(5,2) = 25
-power(5,3) = 125
-power(5,4) = 625
-power(5,5) = 3125
-power(5,6) = 15625
-power(5,7) = 78125
-power(5,8) = 390625
-
diff --git a/test/files/run/Course-2002-03-msil.check b/test/files/run/Course-2002-03-msil.check
deleted file mode 100644
index 3556893e16..0000000000
--- a/test/files/run/Course-2002-03-msil.check
+++ /dev/null
@@ -1,67 +0,0 @@
-1
-2
-1/2
-5/6
-
-1/3
-5/7
-3/2
-66/42
-
-1/3
-5/7
-3/2
-11/7
-
-11/7
-7/11
-11/7
-11/7
-
-13/36
-
-False
-True
-True
-False
-
-set0 = []
-set1 = [1]
-set2 = [1,2]
-set3 = [1,2,3]
-set4 = [1,2,3,4]
-
-set2 contains the following elements:
-1
-2
-
-set3 contains the following elements:
-1
-2
-3
-
-set4 contains the following elements:
-1
-2
-3
-4
-
-2 <- set2: True
-3 <- set2: False
-
-setx = [-10,-1,0,3,5,21]
-setx * 2 = [-20,-2,0,6,10,42]
-
-setx = [-10,-1,0,3,5,21]
-sety = [-9,-5,-1,0,3,7,8]
-setx & sety = [-1,0,3]
-sety & setx = [-1,0,3]
-setx > 0 = [3,5,21]
-sety > 0 = [3,7,8]
-setx & sety = [-1,0,3]
-sety & setx = [-1,0,3]
-
-1/1
-1/1
-1/1
-
diff --git a/test/files/run/Course-2002-04-msil.check b/test/files/run/Course-2002-04-msil.check
deleted file mode 100644
index fc6ad96eed..0000000000
--- a/test/files/run/Course-2002-04-msil.check
+++ /dev/null
@@ -1,64 +0,0 @@
-list0 = List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4, 3, 4, 8)
-list1 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
-list2 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
-list3 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
-list4 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
-list5 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)
-list6 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)
-
-list0: List() -> List()
-list1: List(0) -> List(0)
-list2: List(0, 1) -> List(0, 1)
-list3: List(1, 0) -> List(0, 1)
-list4: List(0, 1, 2) -> List(0, 1, 2)
-list5: List(1, 0, 2) -> List(0, 1, 2)
-list6: List(0, 1, 2) -> List(0, 1, 2)
-list7: List(1, 0, 2) -> List(0, 1, 2)
-list8: List(2, 0, 1) -> List(0, 1, 2)
-list9: List(2, 1, 0) -> List(0, 1, 2)
-listA: List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4) -> List(1, 1, 2, 3, 4, 5, 6, 7, 8, 8)
-
-f(x) = 5x^3+7x^2+5x+9
-f(0) = 9
-f(1) = 26
-f(2) = 87
-f(3) = 222
-
-v1 = List(2, 3, 4)
-v2 = List(6, 7, 8)
-
-id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
-m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
-m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
-
-v1 * v1 = 29
-v1 * v2 = 65
-v2 * v1 = 65
-v1 * v2 = 65
-
-id * v1 = List(2, 3, 4)
-m1 * v1 = List(4, 6, 8)
-m2 * v1 = List(20, 47, 74)
-
-trn(id) = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
-trn(m1) = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
-trn(m2) = List(List(1, 4, 7), List(2, 5, 8), List(3, 6, 9))
-
-List(v1) * id = List(List(2, 3, 4))
-List(v1) * m1 = List(List(4, 6, 8))
-List(v1) * m2 = List(List(42, 51, 60))
-
-id * List(v1) = List(List(2, 3, 4), List(0, 0, 0), List(0, 0, 0))
-m1 * List(v1) = List(List(4, 6, 8), List(0, 0, 0), List(0, 0, 0))
-m2 * List(v1) = List(List(2, 3, 4), List(8, 12, 16), List(14, 21, 28))
-
-id * id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
-id * m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
-m1 * id = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
-m1 * m1 = List(List(4, 0, 0), List(0, 4, 0), List(0, 0, 4))
-id * m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
-m2 * id = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
-m1 * m2 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18))
-m2 * m1 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18))
-m2 * m2 = List(List(30, 36, 42), List(66, 81, 96), List(102, 126, 150))
-
diff --git a/test/files/run/Course-2002-08-msil.check b/test/files/run/Course-2002-08-msil.check
deleted file mode 100644
index c5b26c719b..0000000000
--- a/test/files/run/Course-2002-08-msil.check
+++ /dev/null
@@ -1,171 +0,0 @@
-x = abc
-count = 111
-x = hello
-count = 112
-
-account deposit 50 -> ()
-account withdraw 20 -> 30
-account withdraw 20 -> 10
-account withdraw 15 ->
-
-x deposit 30 -> ()
-y withdraw 20 ->
-
-x deposit 30 -> ()
-x withdraw 20 -> 10
-
-x deposit 30 -> ()
-y withdraw 20 -> 10
-
-2^0 = 1
-2^1 = 2
-2^2 = 4
-2^3 = 8
-
-2^0 = 1
-2^1 = 2
-2^2 = 4
-2^3 = 8
-
-1 2 3
-List(1,2,3)
-
-out 0 new-value = False
-*** simulation started ***
-out 1 new-value = True
-!0 = 1
-
-*** simulation started ***
-out 2 new-value = False
-!1 = 0
-
-out 2 new-value = False
-
-*** simulation started ***
-0 & 0 = 0
-
-*** simulation started ***
-0 & 1 = 0
-
-*** simulation started ***
-out 11 new-value = True
-out 11 new-value = False
-1 & 0 = 0
-
-*** simulation started ***
-out 14 new-value = True
-1 & 1 = 1
-
-out 14 new-value = False
-
-*** simulation started ***
-0 | 0 = 0
-
-*** simulation started ***
-out 24 new-value = True
-0 | 1 = 1
-
-*** simulation started ***
-1 | 0 = 1
-
-*** simulation started ***
-1 | 1 = 1
-
-sum 34 new-value = False
-carry 34 new-value = False
-
-*** simulation started ***
-0 + 0 = 0
-
-*** simulation started ***
-sum 47 new-value = True
-0 + 1 = 1
-
-*** simulation started ***
-carry 50 new-value = True
-carry 50 new-value = False
-sum 54 new-value = False
-sum 54 new-value = True
-1 + 0 = 1
-
-*** simulation started ***
-carry 57 new-value = True
-sum 61 new-value = False
-1 + 1 = 2
-
-sum 61 new-value = False
-carry 61 new-value = False
-
-*** simulation started ***
-0 + 0 + 0 = 0
-
-*** simulation started ***
-sum 82 new-value = True
-0 + 0 + 1 = 1
-
-*** simulation started ***
-sum 89 new-value = False
-carry 90 new-value = True
-sum 97 new-value = True
-carry 98 new-value = False
-0 + 1 + 0 = 1
-
-*** simulation started ***
-sum 113 new-value = False
-carry 114 new-value = True
-0 + 1 + 1 = 2
-
-*** simulation started ***
-sum 121 new-value = True
-carry 122 new-value = False
-sum 129 new-value = False
-sum 129 new-value = True
-1 + 0 + 0 = 1
-
-*** simulation started ***
-carry 137 new-value = True
-sum 144 new-value = False
-1 + 0 + 1 = 2
-
-*** simulation started ***
-carry 152 new-value = False
-sum 152 new-value = True
-sum 158 new-value = False
-carry 159 new-value = True
-1 + 1 + 0 = 2
-
-*** simulation started ***
-sum 173 new-value = True
-1 + 1 + 1 = 3
-
-in 0 new-value = False
-ctrl0 0 new-value = False
-ctrl1 0 new-value = False
-ctrl2 0 new-value = False
-out0 0 new-value = False
-out1 0 new-value = False
-out2 0 new-value = False
-out3 0 new-value = False
-out4 0 new-value = False
-out5 0 new-value = False
-out6 0 new-value = False
-out7 0 new-value = False
-in 0 new-value = True
-*** simulation started ***
-out0 10 new-value = True
-ctrl0 10 new-value = True
-*** simulation started ***
-out1 13 new-value = True
-out0 14 new-value = False
-ctrl1 14 new-value = True
-*** simulation started ***
-out3 20 new-value = True
-out1 21 new-value = False
-ctrl2 21 new-value = True
-*** simulation started ***
-out7 30 new-value = True
-out3 31 new-value = False
-ctrl0 31 new-value = False
-*** simulation started ***
-out7 34 new-value = False
-out6 35 new-value = True
diff --git a/test/files/run/Course-2002-09-msil.check b/test/files/run/Course-2002-09-msil.check
deleted file mode 100644
index c921361db7..0000000000
--- a/test/files/run/Course-2002-09-msil.check
+++ /dev/null
@@ -1,50 +0,0 @@
-Probe: f = 32
-Probe: c = 0
-Probe: f = ?
-Probe: c = ?
-
-Probe: f = 212
-Probe: c = 100
-Probe: f = ?
-Probe: c = ?
-
-Probe: c = 0
-Probe: f = 32
-Probe: c = ?
-Probe: f = ?
-
-Probe: c = 100
-Probe: f = 212
-Probe: c = ?
-Probe: f = ?
-
-0 Celsius -> 32 Fahrenheits
-100 Celsius -> 212 Fahrenheits
-32 Fahrenheits -> 0 Celsius
-212 Fahrenheits -> 100 Celsius
-
-a = ?, b = ?, c = ? => ? * ? = ?
-a = 2, b = ?, c = ? => 2 * ? = ?
-a = ?, b = 3, c = ? => ? * 3 = ?
-a = ?, b = ?, c = 6 => ? * ? = 6
-a = 2, b = 3, c = ? => 2 * 3 = 6
-a = 2, b = ?, c = 6 => 2 * 3 = 6
-a = ?, b = 3, c = 6 => 2 * 3 = 6
-a = 2, b = 3, c = 6 => 2 * 3 = 6
-
-a = 0, b = ?, c = ? => 0 * ? = 0
-a = ?, b = 0, c = ? => ? * 0 = 0
-a = ?, b = ?, c = 0 => ? * ? = 0
-a = 0, b = 7, c = ? => 0 * 7 = 0
-a = 7, b = 0, c = ? => 7 * 0 = 0
-a = 0, b = 0, c = ? => 0 * 0 = 0
-a = 0, b = ?, c = 0 => 0 * ? = 0
-a = ?, b = 0, c = 0 => ? * 0 = 0
-a = 0, b = 7, c = 0 => 0 * 7 = 0
-a = 7, b = 0, c = 0 => 7 * 0 = 0
-a = 0, b = 0, c = 0 => 0 * 0 = 0
-
-a = 3, b = 4 => c = 5
-a = 3, c = 5 => b = 4
-b = 4, c = 5 => a = 3
-
diff --git a/test/files/run/Course-2002-10-msil.check b/test/files/run/Course-2002-10-msil.check
deleted file mode 100644
index bbd9414370..0000000000
--- a/test/files/run/Course-2002-10-msil.check
+++ /dev/null
@@ -1,46 +0,0 @@
-fib(0) = 0
-fib(1) = 1
-fib(2) = 1
-fib(3) = 2
-fib(4) = 3
-fib(5) = 5
-fib(6) = 8
-fib(7) = 13
-fib(8) = 21
-fib(9) = 34
-fib(10) = 55
-fib(11) = 89
-fib(12) = 144
-fib(13) = 233
-fib(14) = 377
-fib(15) = 610
-fib(16) = 987
-fib(17) = 1597
-fib(18) = 2584
-fib(19) = 4181
-
-pi(0) = 4 , 3.16666666666667 , 4
-pi(1) = 2.66666666666667 , 3.13333333333333 , 3.16666666666667
-pi(2) = 3.46666666666667 , 3.1452380952381 , 3.1421052631579
-pi(3) = 2.8952380952381 , 3.13968253968254 , 3.141599357319
-pi(4) = 3.33968253968254 , 3.14271284271284 , 3.14159271403378
-pi(5) = 2.97604617604618 , 3.14088134088134 , 3.14159265397529
-pi(6) = 3.28373848373848 , 3.14207181707182 , 3.14159265359118
-pi(7) = 3.01707181707182 , 3.14125482360776 , 3.14159265358978
-pi(8) = 3.25236593471888 , 3.1418396189294 , 3.14159265358979
-pi(9) = 3.0418396189294 , 3.1414067184965 , 3.14159265358979
-pi = 3.14159265358979 , 3.14159265358979 , 3.14159265358979
-
-ln(0) = 1 , 0.7 , 1
-ln(1) = 0.5 , 0.69047619047619 , 0.7
-ln(2) = 0.833333333333333 , 0.694444444444444 , 0.69327731092437
-ln(3) = 0.583333333333333 , 0.692424242424242 , 0.693148869332925
-ln(4) = 0.783333333333333 , 0.693589743589744 , 0.693147196073549
-ln(5) = 0.616666666666667 , 0.692857142857143 , 0.693147180663564
-ln(6) = 0.759523809523809 , 0.693347338935574 , 0.693147180560404
-ln(7) = 0.634523809523809 , 0.693003341687552 , 0.693147180559944
-ln(8) = 0.745634920634921 , 0.693253968253968 , 0.693147180559943
-ln(9) = 0.645634920634921 , 0.693065750674446 , 0.693147180559945
-ln = 0.693147180559945 , 0.693147180559945 , 0.693147180559945
-
-prime numbers: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113
diff --git a/test/files/run/absoverride-msil.check b/test/files/run/absoverride-msil.check
deleted file mode 100644
index 938f62221f..0000000000
--- a/test/files/run/absoverride-msil.check
+++ /dev/null
@@ -1,20 +0,0 @@
-<sync>
-next: m
-</sync>
-log: m
-m
-<sync>
-next: s
-</sync>
-log: s
-s
-<sync>
-next: i
-</sync>
-log: i
-i
-<sync>
-next: l
-</sync>
-log: l
-l
diff --git a/test/files/run/abstypetags_core.check b/test/files/run/abstypetags_core.check
new file mode 100644
index 0000000000..55c8cb7e89
--- /dev/null
+++ b/test/files/run/abstypetags_core.check
@@ -0,0 +1,28 @@
+true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
+true
+TypeTag[java.lang.String]
diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala
new file mode 100644
index 0000000000..a49817f4d4
--- /dev/null
+++ b/test/files/run/abstypetags_core.scala
@@ -0,0 +1,32 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ println(implicitly[AbsTypeTag[Byte]] eq AbsTypeTag.Byte)
+ println(implicitly[AbsTypeTag[Byte]])
+ println(implicitly[AbsTypeTag[Short]] eq AbsTypeTag.Short)
+ println(implicitly[AbsTypeTag[Short]])
+ println(implicitly[AbsTypeTag[Char]] eq AbsTypeTag.Char)
+ println(implicitly[AbsTypeTag[Char]])
+ println(implicitly[AbsTypeTag[Int]] eq AbsTypeTag.Int)
+ println(implicitly[AbsTypeTag[Int]])
+ println(implicitly[AbsTypeTag[Long]] eq AbsTypeTag.Long)
+ println(implicitly[AbsTypeTag[Long]])
+ println(implicitly[AbsTypeTag[Float]] eq AbsTypeTag.Float)
+ println(implicitly[AbsTypeTag[Float]])
+ println(implicitly[AbsTypeTag[Double]] eq AbsTypeTag.Double)
+ println(implicitly[AbsTypeTag[Double]])
+ println(implicitly[AbsTypeTag[Boolean]] eq AbsTypeTag.Boolean)
+ println(implicitly[AbsTypeTag[Boolean]])
+ println(implicitly[AbsTypeTag[Unit]] eq AbsTypeTag.Unit)
+ println(implicitly[AbsTypeTag[Unit]])
+ println(implicitly[AbsTypeTag[Any]] eq AbsTypeTag.Any)
+ println(implicitly[AbsTypeTag[Any]])
+ println(implicitly[AbsTypeTag[Object]] eq AbsTypeTag.Object)
+ println(implicitly[AbsTypeTag[Object]])
+ println(implicitly[AbsTypeTag[Null]] eq AbsTypeTag.Null)
+ println(implicitly[AbsTypeTag[Null]])
+ println(implicitly[AbsTypeTag[Nothing]] eq AbsTypeTag.Nothing)
+ println(implicitly[AbsTypeTag[Nothing]])
+ println(implicitly[AbsTypeTag[String]] eq AbsTypeTag.String)
+ println(implicitly[AbsTypeTag[String]])
+} \ No newline at end of file
diff --git a/test/files/run/arrayclone-new.scala b/test/files/run/arrayclone-new.scala
index a4ba021409..506e4f527c 100644
--- a/test/files/run/arrayclone-new.scala
+++ b/test/files/run/arrayclone-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App{
BooleanArrayClone;
ByteArrayClone;
@@ -93,7 +95,7 @@ object PolymorphicArrayClone{
testIt(Array("one", "two"), "one", "two");
- class Mangler[T: ArrayTag](ts : T*){
+ class Mangler[T: ClassTag](ts : T*){
// this will always be a BoxedAnyArray even after we've unboxed its contents.
val it = ts.toArray[T];
}
@@ -103,4 +105,4 @@ object PolymorphicArrayClone{
val y : Array[Int] = mangled.it; // make sure it's unboxed
testIt(mangled.it, 0, 1);
-}
+} \ No newline at end of file
diff --git a/test/files/run/arraytags_basic.check b/test/files/run/arraytags_basic.check
deleted file mode 100644
index 92816b91bd..0000000000
--- a/test/files/run/arraytags_basic.check
+++ /dev/null
@@ -1,36 +0,0 @@
-class [I
-class [[I
-class [[[I
-class [Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [Lscala.collection.immutable.Map;
-class [[Lscala.collection.immutable.Map;
-class [[[Lscala.collection.immutable.Map;
-class [[I
-class [[[I
-class [[[[I
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [[[[Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [[[[Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.Map;
-class [[[Lscala.collection.immutable.Map;
-class [[[[Lscala.collection.immutable.Map;
-class [[[I
-class [[[[I
-class [[[[[I
-class [[[Lscala.collection.immutable.List;
-class [[[[Lscala.collection.immutable.List;
-class [[[[[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [[[[Lscala.collection.immutable.List;
-class [[[[[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.Map;
-class [[[[Lscala.collection.immutable.Map;
-class [[[[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/arraytags_basic.scala b/test/files/run/arraytags_basic.scala
deleted file mode 100644
index edc20e9bc1..0000000000
--- a/test/files/run/arraytags_basic.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-object Test extends App {
- def test[T: ArrayTag] = {
- println(implicitly[ArrayTag[T]].newArray(10).getClass)
- println(implicitly[ArrayTag[T]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[T]]].wrap.newArray(10).getClass)
- }
-
- test[Int]
- test[List[Int]]
- test[List[String]]
- test[Map[Int, String]]
-
- test[Array[Int]]
- test[Array[List[Int]]]
- test[Array[List[String]]]
- test[Array[Map[Int, String]]]
-
- test[Array[Array[Int]]]
- test[Array[Array[List[Int]]]]
- test[Array[Array[List[String]]]]
- test[Array[Array[Map[Int, String]]]]
-} \ No newline at end of file
diff --git a/test/files/run/arraytags_core.check b/test/files/run/arraytags_core.check
deleted file mode 100644
index 82ed84ad78..0000000000
--- a/test/files/run/arraytags_core.check
+++ /dev/null
@@ -1,48 +0,0 @@
-class [B
-class [[B
-class [[[B
-class [S
-class [[S
-class [[[S
-class [C
-class [[C
-class [[[C
-class [I
-class [[I
-class [[[I
-class [J
-class [[J
-class [[[J
-class [F
-class [[F
-class [[[F
-class [D
-class [[D
-class [[[D
-class [Z
-class [[Z
-class [[[Z
-class [Lscala.runtime.BoxedUnit;
-class [[Lscala.runtime.BoxedUnit;
-class [[[Lscala.runtime.BoxedUnit;
-class [Ljava.lang.Object;
-class [[Ljava.lang.Object;
-class [[[Ljava.lang.Object;
-class [Ljava.lang.Object;
-class [[Ljava.lang.Object;
-class [[[Ljava.lang.Object;
-class [Ljava.lang.Object;
-class [[Ljava.lang.Object;
-class [[[Ljava.lang.Object;
-class [Ljava.lang.Object;
-class [[Ljava.lang.Object;
-class [[[Ljava.lang.Object;
-class [Lscala.runtime.Null$;
-class [[Lscala.runtime.Null$;
-class [[[Lscala.runtime.Null$;
-class [Lscala.runtime.Nothing$;
-class [[Lscala.runtime.Nothing$;
-class [[[Lscala.runtime.Nothing$;
-class [Ljava.lang.String;
-class [[Ljava.lang.String;
-class [[[Ljava.lang.String;
diff --git a/test/files/run/arraytags_core.scala b/test/files/run/arraytags_core.scala
deleted file mode 100644
index a59ae24f30..0000000000
--- a/test/files/run/arraytags_core.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-object Test extends App {
- println(implicitly[ArrayTag[Byte]].newArray(10).getClass)
- println(implicitly[ArrayTag[Byte]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Byte]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Short]].newArray(10).getClass)
- println(implicitly[ArrayTag[Short]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Short]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Char]].newArray(10).getClass)
- println(implicitly[ArrayTag[Char]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Char]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Int]].newArray(10).getClass)
- println(implicitly[ArrayTag[Int]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Int]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Long]].newArray(10).getClass)
- println(implicitly[ArrayTag[Long]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Long]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Float]].newArray(10).getClass)
- println(implicitly[ArrayTag[Float]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Float]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Double]].newArray(10).getClass)
- println(implicitly[ArrayTag[Double]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Double]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Boolean]].newArray(10).getClass)
- println(implicitly[ArrayTag[Boolean]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Boolean]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Unit]].newArray(10).getClass)
- println(implicitly[ArrayTag[Unit]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Unit]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Any]].newArray(10).getClass)
- println(implicitly[ArrayTag[Any]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Any]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Object]].newArray(10).getClass)
- println(implicitly[ArrayTag[Object]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Object]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[AnyVal]].newArray(10).getClass)
- println(implicitly[ArrayTag[AnyVal]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[AnyVal]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[AnyRef]].newArray(10).getClass)
- println(implicitly[ArrayTag[AnyRef]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[AnyRef]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Null]].newArray(10).getClass)
- println(implicitly[ArrayTag[Null]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Null]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Nothing]].newArray(10).getClass)
- println(implicitly[ArrayTag[Nothing]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[Nothing]]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[String]].newArray(10).getClass)
- println(implicitly[ArrayTag[String]].wrap.newArray(10).getClass)
- println(implicitly[ArrayTag[Array[String]]].wrap.newArray(10).getClass)
-} \ No newline at end of file
diff --git a/test/files/run/arraytags_usage.check b/test/files/run/arraytags_usage.check
deleted file mode 100644
index b1d02b7bfe..0000000000
--- a/test/files/run/arraytags_usage.check
+++ /dev/null
@@ -1,3 +0,0 @@
-class [I
-class [I
-class [I
diff --git a/test/files/run/arraytags_usage.scala b/test/files/run/arraytags_usage.scala
deleted file mode 100644
index 60b0a8f218..0000000000
--- a/test/files/run/arraytags_usage.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-object Test extends App {
- def foo[T] = {
- class MyArrayTag extends ArrayTag[T] {
- def wrap: ArrayTag[Array[T]] = ???
- def newArray(len: Int): Array[T] = new Array[Int](len).asInstanceOf[Array[T]]
- }
-
- implicit val tag = new MyArrayTag()
- println(Array[T]().getClass)
- }
-
- foo[Int]
- foo[String]
- foo[Array[String]]
-} \ No newline at end of file
diff --git a/test/files/run/bitsets-msil.check b/test/files/run/bitsets-msil.check
deleted file mode 100644
index b187571bff..0000000000
--- a/test/files/run/bitsets-msil.check
+++ /dev/null
@@ -1,33 +0,0 @@
-ms0 = BitSet(2)
-ms1 = BitSet(2)
-ms2 = BitSet(2)
-mb0 = False
-mb1 = True
-mb2 = False
-xs0 = List(2)
-xs1 = List(2)
-xs2 = List(2)
-ma0 = List(2)
-ma1 = List(2)
-ma2 = List(2)
-mi0 = BitSet(2)
-mi1 = BitSet(2)
-mi2 = BitSet(2)
-
-is0 = BitSet()
-is1 = BitSet()
-is2 = BitSet(2)
-is3 = BitSet()
-ib0 = False
-ib1 = False
-ib2 = True
-ib3 = False
-ys0 = List()
-ys1 = List()
-ys2 = List(2)
-ys3 = List()
-ia0 = List()
-ia1 = List()
-ia2 = List(2)
-ia3 = List()
-
diff --git a/test/files/run/boolord-msil.check b/test/files/run/boolord-msil.check
deleted file mode 100644
index e5f1daa0e5..0000000000
--- a/test/files/run/boolord-msil.check
+++ /dev/null
@@ -1,4 +0,0 @@
-false < false = False
-false < true = True
-true < false = False
-true < true = False
diff --git a/test/files/run/bugs-msil.check b/test/files/run/bugs-msil.check
deleted file mode 100644
index 4e15409547..0000000000
--- a/test/files/run/bugs-msil.check
+++ /dev/null
@@ -1,96 +0,0 @@
-<<< bug 98
-mycase
->>> bug 98
-
-<<< bug 120
-one
-A
-B
-C
->>> bug 120
-
-<<< bug 135
-Some(The answer)
->>> bug 135
-
-<<< bug 142
-ok
-ok
-ok
-ok
-ok
-ok
-ok
-ok
->>> bug 142
-
-<<< bug 166
->>> bug 166
-
-<<< bug 167
->>> bug 167
-
-<<< bug 168
->>> bug 168
-
-<<< bug 174
->>> bug 174
-
-<<< bug 176
-1
->>> bug 176
-
-<<< bug 199
->>> bug 199
-
-<<< bug 213
-Cannot cast unit to Nothing
-Cannot cast empty string to Null
->>> bug 213
-
-<<< bug 217
->>> bug 217
-
-<<< bug 222
->>> bug 222
-
-<<< bug 225
->>> bug 225
-
-<<< bug 226
->>> bug 226
-
-<<< bug 233
-True
->>> bug 233
-
-<<< bug 250
->>> bug 250
-
-<<< bug 257
-I should come 1st and 2nd
-I should come 1st and 2nd
-I should come last
->>> bug 257
-
-<<< bug 266
-hello
-4
->>> bug 266
-
-<<< bug 316
->>> bug 316
-
-<<< bug 328
->>> bug 328
-
-<<< bug 396
-A
-B
-C
->>> bug 396
-
-<<< bug 399
-a
->>> bug 399
-
diff --git a/test/files/run/caseClassHash.scala b/test/files/run/caseClassHash.scala
index 7adfddedf8..c5cb09c355 100644
--- a/test/files/run/caseClassHash.scala
+++ b/test/files/run/caseClassHash.scala
@@ -11,8 +11,8 @@ object Test {
println("## method 1: " + foo1.##)
println("## method 2: " + foo2.##)
- println(" Murmur 1: " + scala.util.MurmurHash3.productHash(foo1))
- println(" Murmur 2: " + scala.util.MurmurHash3.productHash(foo2))
+ println(" Murmur 1: " + scala.util.hashing.MurmurHash3.productHash(foo1))
+ println(" Murmur 2: " + scala.util.hashing.MurmurHash3.productHash(foo2))
}
}
diff --git a/test/files/run/classtags_contextbound.scala b/test/files/run/classtags_contextbound.scala
index 5bb0ae8d80..2f12792154 100644
--- a/test/files/run/classtags_contextbound.scala
+++ b/test/files/run/classtags_contextbound.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
def mkArray[T: ClassTag] = Array[T]()
def foo[T: ClassTag] = mkArray[T]
diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check
index ebccfcd54c..7beada3f1c 100644
--- a/test/files/run/classtags_core.check
+++ b/test/files/run/classtags_core.check
@@ -1,32 +1,28 @@
-true
-ClassTag[byte]
-true
-ClassTag[short]
-true
-ClassTag[char]
-true
-ClassTag[int]
-true
-ClassTag[long]
-true
-ClassTag[float]
-true
-ClassTag[double]
-true
-ClassTag[boolean]
-true
-ClassTag[void]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class scala.runtime.Null$]
-true
-ClassTag[class scala.runtime.Nothing$]
-true
-ClassTag[class java.lang.String]
+true
+ClassTag[byte]
+true
+ClassTag[short]
+true
+ClassTag[char]
+true
+ClassTag[int]
+true
+ClassTag[long]
+true
+ClassTag[float]
+true
+ClassTag[double]
+true
+ClassTag[boolean]
+true
+ClassTag[void]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class scala.runtime.Null$]
+true
+ClassTag[class scala.runtime.Nothing$]
+true
+ClassTag[class java.lang.String]
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala
index 9f2031377d..17c69d9c41 100644
--- a/test/files/run/classtags_core.scala
+++ b/test/files/run/classtags_core.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
println(implicitly[ClassTag[Byte]] eq ClassTag.Byte)
println(implicitly[ClassTag[Byte]])
@@ -21,10 +23,6 @@ object Test extends App {
println(implicitly[ClassTag[Any]])
println(implicitly[ClassTag[Object]] eq ClassTag.Object)
println(implicitly[ClassTag[Object]])
- println(implicitly[ClassTag[AnyVal]] eq ClassTag.AnyVal)
- println(implicitly[ClassTag[AnyVal]])
- println(implicitly[ClassTag[AnyRef]] eq ClassTag.AnyRef)
- println(implicitly[ClassTag[AnyRef]])
println(implicitly[ClassTag[Null]] eq ClassTag.Null)
println(implicitly[ClassTag[Null]])
println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing)
diff --git a/test/files/run/classtags_multi.scala b/test/files/run/classtags_multi.scala
index 5aafb55223..b4b47bcf0e 100644
--- a/test/files/run/classtags_multi.scala
+++ b/test/files/run/classtags_multi.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
println(classTag[Int])
println(classTag[Array[Int]])
diff --git a/test/files/run/classtags_use_concretetypetags.scala b/test/files/run/classtags_use_concretetypetags.scala
deleted file mode 100644
index 57e7085cec..0000000000
--- a/test/files/run/classtags_use_concretetypetags.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test extends App {
- def foo[T: ConcreteTypeTag] = Array[T]()
-} \ No newline at end of file
diff --git a/test/files/run/concretetypetags_core.check b/test/files/run/concretetypetags_core.check
index f124aa6a35..d042e0900d 100644
--- a/test/files/run/concretetypetags_core.check
+++ b/test/files/run/concretetypetags_core.check
@@ -1,32 +1,28 @@
-true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
-true
-ConcreteTypeTag[String]
+true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
+true
+TypeTag[java.lang.String]
diff --git a/test/files/run/concretetypetags_core.scala b/test/files/run/concretetypetags_core.scala
index b6cfea3895..a870f77c5f 100644
--- a/test/files/run/concretetypetags_core.scala
+++ b/test/files/run/concretetypetags_core.scala
@@ -1,34 +1,32 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
- println(implicitly[ConcreteTypeTag[Byte]] eq ConcreteTypeTag.Byte)
- println(implicitly[ConcreteTypeTag[Byte]])
- println(implicitly[ConcreteTypeTag[Short]] eq ConcreteTypeTag.Short)
- println(implicitly[ConcreteTypeTag[Short]])
- println(implicitly[ConcreteTypeTag[Char]] eq ConcreteTypeTag.Char)
- println(implicitly[ConcreteTypeTag[Char]])
- println(implicitly[ConcreteTypeTag[Int]] eq ConcreteTypeTag.Int)
- println(implicitly[ConcreteTypeTag[Int]])
- println(implicitly[ConcreteTypeTag[Long]] eq ConcreteTypeTag.Long)
- println(implicitly[ConcreteTypeTag[Long]])
- println(implicitly[ConcreteTypeTag[Float]] eq ConcreteTypeTag.Float)
- println(implicitly[ConcreteTypeTag[Float]])
- println(implicitly[ConcreteTypeTag[Double]] eq ConcreteTypeTag.Double)
- println(implicitly[ConcreteTypeTag[Double]])
- println(implicitly[ConcreteTypeTag[Boolean]] eq ConcreteTypeTag.Boolean)
- println(implicitly[ConcreteTypeTag[Boolean]])
- println(implicitly[ConcreteTypeTag[Unit]] eq ConcreteTypeTag.Unit)
- println(implicitly[ConcreteTypeTag[Unit]])
- println(implicitly[ConcreteTypeTag[Any]] eq ConcreteTypeTag.Any)
- println(implicitly[ConcreteTypeTag[Any]])
- println(implicitly[ConcreteTypeTag[Object]] eq ConcreteTypeTag.Object)
- println(implicitly[ConcreteTypeTag[Object]])
- println(implicitly[ConcreteTypeTag[AnyVal]] eq ConcreteTypeTag.AnyVal)
- println(implicitly[ConcreteTypeTag[AnyVal]])
- println(implicitly[ConcreteTypeTag[AnyRef]] eq ConcreteTypeTag.AnyRef)
- println(implicitly[ConcreteTypeTag[AnyRef]])
- println(implicitly[ConcreteTypeTag[Null]] eq ConcreteTypeTag.Null)
- println(implicitly[ConcreteTypeTag[Null]])
- println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing)
- println(implicitly[ConcreteTypeTag[Nothing]])
- println(implicitly[ConcreteTypeTag[String]] eq ConcreteTypeTag.String)
- println(implicitly[ConcreteTypeTag[String]])
+ println(implicitly[TypeTag[Byte]] eq TypeTag.Byte)
+ println(implicitly[TypeTag[Byte]])
+ println(implicitly[TypeTag[Short]] eq TypeTag.Short)
+ println(implicitly[TypeTag[Short]])
+ println(implicitly[TypeTag[Char]] eq TypeTag.Char)
+ println(implicitly[TypeTag[Char]])
+ println(implicitly[TypeTag[Int]] eq TypeTag.Int)
+ println(implicitly[TypeTag[Int]])
+ println(implicitly[TypeTag[Long]] eq TypeTag.Long)
+ println(implicitly[TypeTag[Long]])
+ println(implicitly[TypeTag[Float]] eq TypeTag.Float)
+ println(implicitly[TypeTag[Float]])
+ println(implicitly[TypeTag[Double]] eq TypeTag.Double)
+ println(implicitly[TypeTag[Double]])
+ println(implicitly[TypeTag[Boolean]] eq TypeTag.Boolean)
+ println(implicitly[TypeTag[Boolean]])
+ println(implicitly[TypeTag[Unit]] eq TypeTag.Unit)
+ println(implicitly[TypeTag[Unit]])
+ println(implicitly[TypeTag[Any]] eq TypeTag.Any)
+ println(implicitly[TypeTag[Any]])
+ println(implicitly[TypeTag[Object]] eq TypeTag.Object)
+ println(implicitly[TypeTag[Object]])
+ println(implicitly[TypeTag[Null]] eq TypeTag.Null)
+ println(implicitly[TypeTag[Null]])
+ println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing)
+ println(implicitly[TypeTag[Nothing]])
+ println(implicitly[TypeTag[String]] eq TypeTag.String)
+ println(implicitly[TypeTag[String]])
} \ No newline at end of file
diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/concretetypetags_multi.check
index 613106985c..6110252c36 100644
--- a/test/files/run/concretetypetags_multi.check
+++ b/test/files/run/concretetypetags_multi.check
@@ -1,5 +1,5 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[Array[Int]]
-ConcreteTypeTag[Array[Array[Int]]]
-ConcreteTypeTag[Array[Array[Array[Int]]]]
-ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
+TypeTag[Int]
+TypeTag[Array[Int]]
+TypeTag[Array[Array[Int]]]
+TypeTag[Array[Array[Array[Int]]]]
+TypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/concretetypetags_multi.scala b/test/files/run/concretetypetags_multi.scala
index 7e19d7db34..b30aac80a6 100644
--- a/test/files/run/concretetypetags_multi.scala
+++ b/test/files/run/concretetypetags_multi.scala
@@ -1,7 +1,9 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
- println(concreteTypeTag[Int])
- println(concreteTypeTag[Array[Int]])
- println(concreteTypeTag[Array[Array[Int]]])
- println(concreteTypeTag[Array[Array[Array[Int]]]])
- println(concreteTypeTag[Array[Array[Array[Array[Int]]]]])
+ println(implicitly[TypeTag[Int]])
+ println(implicitly[TypeTag[Array[Int]]])
+ println(implicitly[TypeTag[Array[Array[Int]]]])
+ println(implicitly[TypeTag[Array[Array[Array[Int]]]]])
+ println(implicitly[TypeTag[Array[Array[Array[Array[Int]]]]]])
} \ No newline at end of file
diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala
index 1d40dab6c5..d7fe087e4d 100644
--- a/test/files/run/ctries-new/main.scala
+++ b/test/files/run/ctries-new/main.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
@@ -35,11 +37,11 @@ trait Spec {
var produced = false
try body
catch {
- case e => if (e.getClass == implicitly[ClassTag[T]].erasure) produced = true
+ case e => if (e.getClass == implicitly[ClassTag[T]].runtimeClass) produced = true
} finally {
assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]])
}
}
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/ctries-old/main.scala b/test/files/run/ctries-old/main.scala
index 8db7fcef54..78ba7f0db1 100644
--- a/test/files/run/ctries-old/main.scala
+++ b/test/files/run/ctries-old/main.scala
@@ -6,30 +6,30 @@
object Test {
-
+
def main(args: Array[String]) {
ConcurrentMapSpec.test()
IteratorSpec.test()
LNodeSpec.test()
SnapshotSpec.test()
}
-
+
}
trait Spec {
-
+
implicit def str2ops(s: String) = new {
def in[U](body: =>U) {
// just execute body
body
}
}
-
+
implicit def any2ops(a: Any) = new {
def shouldEqual(other: Any) = assert(a == other)
}
-
+
def evaluating[U](body: =>U) = new {
def shouldProduce[T <: Throwable: ClassManifest]() = {
var produced = false
@@ -41,5 +41,5 @@ trait Spec {
}
}
}
-
+
}
diff --git a/test/files/run/dynamic-proxy.check b/test/files/run/dynamic-proxy.check
deleted file mode 100644
index d1b85daff4..0000000000
--- a/test/files/run/dynamic-proxy.check
+++ /dev/null
@@ -1,20 +0,0 @@
-noargs
-noargs
-nullary
-value
-symbolic
-symbolic with args
-non-existent method
-before mutation
-mutation 1
-after mutation 1
-mutation 2
-after mutation 2
-overloaded with object
-overloaded with primitive
-overloaded with object in var
-overloaded with object in var 2
-typeArgs: I am a car
-default: 4
-default: 3
-named: 6
diff --git a/test/files/run/dynamic-proxy.flags b/test/files/run/dynamic-proxy.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/run/dynamic-proxy.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/run/dynamic-proxy.scala b/test/files/run/dynamic-proxy.scala
deleted file mode 100644
index ab5a8b1d66..0000000000
--- a/test/files/run/dynamic-proxy.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-import scala.reflect._
-
-class Car{ override def toString = "I am a car" }
-object x{
- def nullary = "nullary"
- def noargs() = "noargs"
- def - = "symbolic"
- def $(s:String) = "symbolic with args"
- val value = "value"
- def overloaded(i:Int) = "overloaded with primitive"
- def overloaded(s:String) = s
- def default( a:Int, b:Int = 2 ) = "default: "+(a+b)
- def named( a:Int, b:Int, c:Int ) = "named: "+(a+b+c)
- def typeArgs[T]( v:T ) = "typeArgs: "+v
- var mutable = "before mutation"
- def multiArgLists( a:String )( b:String ) = "multiArgList " + a + b
- def bar( s:String )(implicit car:Car) = s + car.toString
-}
-
-object Test extends App{
- val d = new DynamicProxy{ val dynamicProxyTarget = x }
-
- println( d.noargs )
- println( d.noargs() )
- println( d.nullary )
- println( d.value )
- println( d.- )
- println( d.$("x") )
-
- try{
- println( d.test )
- } catch {
- case _ => println("non-existent method")
- }
-
- println( d.mutable )
-
- println("mutation 1")
- d.mutable_=("after mutation 1")
- println( d.mutable )
-
- println("mutation 2")
- d.mutable = "after mutation 2"
- println( d.mutable )
-
- println( d.overloaded("overloaded with object") )
- println( d.overloaded(1) )
-
- // test some non-constant arguments
- def s = "overloaded with object in var"
- println( d.overloaded(s) )
- println( d.overloaded(s + " 2") )
-
- val car = new Car
- println( d.typeArgs(car) ) // inferred
- // println( d.typeArgs[Car](car) ) // explicit not working (yet)
-
- println( d.default( 1,3 ) )
- println( d.default( 1 ) )
-
- println( d.named(1,c=3,b=2) ) // applyDynamicNamed seems to be broken
-
- // println( d.multiArgLists("a")("b") ) // not working yet
-
- /*
- // may never work
- // testing implicit parameters (first test works when moving x into TestDynamicReflect)
- implicit val car2 = new Car
- println( d.bar( "Yeah, ") ); // FAILS: could not find implicit value for parameter car
- {println( d.bar( "Yeah, ") )} // FAILS: could not find implicit value for parameter car
- */
-}
diff --git a/test/files/run/erasuretags_abstract.check b/test/files/run/erasuretags_abstract.check
deleted file mode 100644
index 17e7204664..0000000000
--- a/test/files/run/erasuretags_abstract.check
+++ /dev/null
@@ -1,4 +0,0 @@
-class java.lang.Object
-class java.lang.Object
-class java.lang.Object
-int
diff --git a/test/files/run/erasuretags_abstract.scala b/test/files/run/erasuretags_abstract.scala
deleted file mode 100644
index 8e4ad0d090..0000000000
--- a/test/files/run/erasuretags_abstract.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def foo1[T] = erasureTag[T]
- println(foo1[Int].erasure)
- println(foo1[String].erasure)
- println(foo1[Array[Int]].erasure)
-
- def foo2[T <: Int] = erasureTag[T]
- println(foo2[Int].erasure)
-} \ No newline at end of file
diff --git a/test/files/run/erasuretags_basic.check b/test/files/run/erasuretags_basic.check
deleted file mode 100644
index c02a4d32af..0000000000
--- a/test/files/run/erasuretags_basic.check
+++ /dev/null
@@ -1,24 +0,0 @@
-int
-class [I
-class scala.collection.immutable.List
-class [Lscala.collection.immutable.List;
-class scala.collection.immutable.List
-class [Lscala.collection.immutable.List;
-interface scala.collection.immutable.Map
-class [Lscala.collection.immutable.Map;
-class [I
-class [[I
-class [Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [Lscala.collection.immutable.Map;
-class [[Lscala.collection.immutable.Map;
-class [[I
-class [[[I
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.List;
-class [[[Lscala.collection.immutable.List;
-class [[Lscala.collection.immutable.Map;
-class [[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/erasuretags_basic.scala b/test/files/run/erasuretags_basic.scala
deleted file mode 100644
index d894fdf2e9..0000000000
--- a/test/files/run/erasuretags_basic.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-object Test extends App {
- def test[T: ErasureTag] = {
- println(implicitly[ErasureTag[T]].erasure)
- println(implicitly[ErasureTag[Array[T]]].erasure)
- }
-
- test[Int]
- test[List[Int]]
- test[List[String]]
- test[Map[Int, String]]
-
- test[Array[Int]]
- test[Array[List[Int]]]
- test[Array[List[String]]]
- test[Array[Map[Int, String]]]
-
- test[Array[Array[Int]]]
- test[Array[Array[List[Int]]]]
- test[Array[Array[List[String]]]]
- test[Array[Array[Map[Int, String]]]]
-} \ No newline at end of file
diff --git a/test/files/run/erasuretags_core.check b/test/files/run/erasuretags_core.check
deleted file mode 100644
index 2c544678d1..0000000000
--- a/test/files/run/erasuretags_core.check
+++ /dev/null
@@ -1,32 +0,0 @@
-byte
-class [B
-short
-class [S
-char
-class [C
-int
-class [I
-long
-class [J
-float
-class [F
-double
-class [D
-boolean
-class [Z
-void
-class [Lscala.runtime.BoxedUnit;
-class java.lang.Object
-class [Ljava.lang.Object;
-class java.lang.Object
-class [Ljava.lang.Object;
-class java.lang.Object
-class [Ljava.lang.Object;
-class java.lang.Object
-class [Ljava.lang.Object;
-class scala.runtime.Null$
-class [Lscala.runtime.Null$;
-class scala.runtime.Nothing$
-class [Lscala.runtime.Nothing$;
-class java.lang.String
-class [Ljava.lang.String;
diff --git a/test/files/run/erasuretags_core.scala b/test/files/run/erasuretags_core.scala
deleted file mode 100644
index 5ed06dcd31..0000000000
--- a/test/files/run/erasuretags_core.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-object Test extends App {
- println(implicitly[ErasureTag[Byte]].erasure)
- println(implicitly[ErasureTag[Array[Byte]]].erasure)
- println(implicitly[ErasureTag[Short]].erasure)
- println(implicitly[ErasureTag[Array[Short]]].erasure)
- println(implicitly[ErasureTag[Char]].erasure)
- println(implicitly[ErasureTag[Array[Char]]].erasure)
- println(implicitly[ErasureTag[Int]].erasure)
- println(implicitly[ErasureTag[Array[Int]]].erasure)
- println(implicitly[ErasureTag[Long]].erasure)
- println(implicitly[ErasureTag[Array[Long]]].erasure)
- println(implicitly[ErasureTag[Float]].erasure)
- println(implicitly[ErasureTag[Array[Float]]].erasure)
- println(implicitly[ErasureTag[Double]].erasure)
- println(implicitly[ErasureTag[Array[Double]]].erasure)
- println(implicitly[ErasureTag[Boolean]].erasure)
- println(implicitly[ErasureTag[Array[Boolean]]].erasure)
- println(implicitly[ErasureTag[Unit]].erasure)
- println(implicitly[ErasureTag[Array[Unit]]].erasure)
- println(implicitly[ErasureTag[Any]].erasure)
- println(implicitly[ErasureTag[Array[Any]]].erasure)
- println(implicitly[ErasureTag[Object]].erasure)
- println(implicitly[ErasureTag[Array[Object]]].erasure)
- println(implicitly[ErasureTag[AnyVal]].erasure)
- println(implicitly[ErasureTag[Array[AnyVal]]].erasure)
- println(implicitly[ErasureTag[AnyRef]].erasure)
- println(implicitly[ErasureTag[Array[AnyRef]]].erasure)
- println(implicitly[ErasureTag[Null]].erasure)
- println(implicitly[ErasureTag[Array[Null]]].erasure)
- println(implicitly[ErasureTag[Nothing]].erasure)
- println(implicitly[ErasureTag[Array[Nothing]]].erasure)
- println(implicitly[ErasureTag[String]].erasure)
- println(implicitly[ErasureTag[Array[String]]].erasure)
-} \ No newline at end of file
diff --git a/test/files/run/erasuretags_usage.scala b/test/files/run/erasuretags_usage.scala
deleted file mode 100644
index 16e53af071..0000000000
--- a/test/files/run/erasuretags_usage.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-object Test extends App {
- def foo[T] = {
- class MyErasureTag(_erasure: Class[_]) extends ErasureTag[T] {
- def erasure: Class[T] = _erasure.asInstanceOf[Class[T]]
- }
-
- implicit val tag = new MyErasureTag(classOf[Int])
- println(typeTag[T])
- println(typeTag[T].tpe)
- println(typeTag[T].erasure)
- }
-} \ No newline at end of file
diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala
index 8c04e4782c..1f314aa4e0 100644
--- a/test/files/run/existentials-in-compiler.scala
+++ b/test/files/run/existentials-in-compiler.scala
@@ -4,6 +4,7 @@ import scala.collection.{ mutable, immutable, generic }
object Test extends CompilerTest {
import global._
+ import rootMirror._
import definitions._
override def code = """
@@ -21,7 +22,7 @@ package extest {
trait Cov07[-A <: AnyRef, +B] { }
trait Cov08[-A <: AnyRef, B] { }
trait Cov09[-A <: AnyRef, -B] { }
-
+
trait Cov11[+A <: AnyRef, +B <: List[_]] { }
trait Cov12[+A <: AnyRef, B <: List[_]] { }
trait Cov13[+A <: AnyRef, -B <: List[_]] { }
@@ -31,7 +32,7 @@ package extest {
trait Cov17[-A <: AnyRef, +B <: List[_]] { }
trait Cov18[-A <: AnyRef, B <: List[_]] { }
trait Cov19[-A <: AnyRef, -B <: List[_]] { }
-
+
trait Cov21[+A, +B] { }
trait Cov22[+A, B] { }
trait Cov23[+A, -B] { }
@@ -41,7 +42,7 @@ package extest {
trait Cov27[-A, +B] { }
trait Cov28[-A, B] { }
trait Cov29[-A, -B] { }
-
+
trait Cov31[+A, +B, C <: ((A, B))] { }
trait Cov32[+A, B, C <: ((A, B))] { }
trait Cov33[+A, -B, C <: ((A, _))] { }
@@ -51,7 +52,7 @@ package extest {
trait Cov37[-A, +B, C <: ((_, B))] { }
trait Cov38[-A, B, C <: ((_, B))] { }
trait Cov39[-A, -B, C <: ((_, _))] { }
-
+
trait Cov41[+A >: Null, +B] { }
trait Cov42[+A >: Null, B] { }
trait Cov43[+A >: Null, -B] { }
diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check
index 66674fbbd6..0d6f694a68 100644
--- a/test/files/run/existentials3-new.check
+++ b/test/files/run/existentials3-new.check
@@ -1,24 +1,24 @@
-ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f3
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f4
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f5
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS
-TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
-ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g3
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g4
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g5
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS
-TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
+Bar.type, t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+Bar, t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Test.ToS, t=RefinedType, s=f3
+Test.ToS, t=RefinedType, s=f4
+Test.ToS, t=RefinedType, s=f5
+() => Test.ToS, t=TypeRef, s=class Function0
+() => Test.ToS, t=TypeRef, s=class Function0
+$anon, t=AbstractTypeRef, s= <: B with Test.ToS
+$anon, t=AbstractTypeRef, s= <: B with A with Test.ToS
+List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
+List[Seq[Int]], t=TypeRef, s=class List
+List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
+Bar.type, t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+Bar, t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Test.ToS, t=RefinedType, s=g3
+Test.ToS, t=RefinedType, s=g4
+Test.ToS, t=RefinedType, s=g5
+() => Test.ToS, t=TypeRef, s=class Function0
+() => Test.ToS, t=TypeRef, s=class Function0
+$anon, t=AbstractTypeRef, s= <: B with Test.ToS
+$anon, t=AbstractTypeRef, s= <: B with A with Test.ToS
+List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
+List[Seq[Int]], t=TypeRef, s=class List
+List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala
index 32129a04c6..649fac8327 100644
--- a/test/files/run/existentials3-new.scala
+++ b/test/files/run/existentials3-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test {
trait ToS { final override def toString = getClass.getName }
@@ -31,12 +33,12 @@ object Test {
val g11 = { abstract class A extends Seq[Int] ; List[A]() }
val g12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() }
- def printTag(t: TypeTag[_]) = {
- val s = if (t.sym.isFreeType) t.sym.typeSignature.toString else t.sym.toString
- println("%s, t=%s, s=%s".format(t, t.tpe.kind, s))
+ def printTpe(t: Type) = {
+ val s = if (t.typeSymbol.isFreeType) t.typeSymbol.typeSignature.toString else t.typeSymbol.toString
+ println("%s, t=%s, s=%s".format(t, t.kind, s))
}
- def m[T: ConcreteTypeTag](x: T) = printTag(concreteTypeTag[T])
- def m2[T: TypeTag](x: T) = printTag(typeTag[T])
+ def m[T: TypeTag](x: T) = printTpe(typeOf[T])
+ def m2[T: AbsTypeTag](x: T) = printTpe(implicitly[AbsTypeTag[T]].tpe)
// tags do work for f10/g10
def main(args: Array[String]): Unit = {
@@ -75,4 +77,4 @@ object Misc {
}
def g1 = o1.f1 _
def g2 = o1.f2 _
-}
+} \ No newline at end of file
diff --git a/test/files/run/freetypes_false_alarm1.check b/test/files/run/freetypes_false_alarm1.check
new file mode 100644
index 0000000000..92efacc2b7
--- /dev/null
+++ b/test/files/run/freetypes_false_alarm1.check
@@ -0,0 +1 @@
+List[Int]
diff --git a/test/files/run/freetypes_false_alarm1.scala b/test/files/run/freetypes_false_alarm1.scala
new file mode 100644
index 0000000000..8d6797f792
--- /dev/null
+++ b/test/files/run/freetypes_false_alarm1.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ val ru = scala.reflect.runtime.universe
+ val tpe: ru.Type = ru.typeOf[List[Int]]
+ println(tpe)
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/freetypes_false_alarm2.check b/test/files/run/freetypes_false_alarm2.check
new file mode 100644
index 0000000000..02e4a84d62
--- /dev/null
+++ b/test/files/run/freetypes_false_alarm2.check
@@ -0,0 +1 @@
+false \ No newline at end of file
diff --git a/test/files/run/freetypes_false_alarm2.scala b/test/files/run/freetypes_false_alarm2.scala
new file mode 100644
index 0000000000..3499f13fba
--- /dev/null
+++ b/test/files/run/freetypes_false_alarm2.scala
@@ -0,0 +1,8 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ val tpe = typeOf[ru.Type]
+ println(tpe.typeSymbol.isFreeType)
+} \ No newline at end of file
diff --git a/test/files/run/getClassTest-new.scala b/test/files/run/getClassTest-new.scala
index 89778ca2d3..7d8ec930f4 100644
--- a/test/files/run/getClassTest-new.scala
+++ b/test/files/run/getClassTest-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
class AnyVals {
def f1 = (5: Any).getClass
def f2 = (5: AnyVal).getClass
@@ -52,7 +54,7 @@ class MoreAnyRefs {
object Test {
def returnTypes[T: ClassTag] = (
- classTag[T].erasure.getMethods.toList
+ classTag[T].runtimeClass.getMethods.toList
filter (_.getName startsWith "f")
sortBy (_.getName)
map (m => m.getName + ": " + m.getGenericReturnType.toString)
@@ -63,4 +65,4 @@ object Test {
returnTypes[AnyRefs] foreach println
returnTypes[MoreAnyRefs] foreach println
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/impconvtimes-msil.check b/test/files/run/impconvtimes-msil.check
deleted file mode 100644
index 082377e474..0000000000
--- a/test/files/run/impconvtimes-msil.check
+++ /dev/null
@@ -1 +0,0 @@
-3.0 * Hour = Measure(3,Hour)
diff --git a/test/files/run/infix-msil.check b/test/files/run/infix-msil.check
deleted file mode 100644
index b37cdcd80b..0000000000
--- a/test/files/run/infix-msil.check
+++ /dev/null
@@ -1,2 +0,0 @@
-op(op(op(,0,0),1,1),2,2)
-OK
diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.check b/test/files/run/interop_classmanifests_arepartially_typetags.check
deleted file mode 100644
index 3dfcdccbec..0000000000
--- a/test/files/run/interop_classmanifests_arepartially_typetags.check
+++ /dev/null
@@ -1,6 +0,0 @@
-T
-int
-T
-class java.lang.String
-T
-class [I
diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.scala b/test/files/run/interop_classmanifests_arepartially_typetags.scala
deleted file mode 100644
index 9bc1f32e86..0000000000
--- a/test/files/run/interop_classmanifests_arepartially_typetags.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-object Test extends App {
- def classManifestIspartiallyTypeTag[T: ClassManifest] = {
- println(typeTag[T].tpe)
- println(typeTag[T].erasure)
- }
-
- classManifestIspartiallyTypeTag[Int]
- classManifestIspartiallyTypeTag[String]
- classManifestIspartiallyTypeTag[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check
index 02393dff23..c59e92d4eb 100644
--- a/test/files/run/interop_classtags_are_classmanifests.check
+++ b/test/files/run/interop_classtags_are_classmanifests.check
@@ -1,6 +1,3 @@
Int
java.lang.String
Array[Int]
-Int
-java.lang.String
-Array[Int]
diff --git a/test/files/run/interop_classtags_are_classmanifests.scala b/test/files/run/interop_classtags_are_classmanifests.scala
index 309c99a3f5..91b9d89c6e 100644
--- a/test/files/run/interop_classtags_are_classmanifests.scala
+++ b/test/files/run/interop_classtags_are_classmanifests.scala
@@ -1,12 +1,6 @@
-object Test extends App {
- def arrayTagIsClassManifest[T: ArrayTag] = {
- println(classManifest[T])
- }
-
- arrayTagIsClassManifest[Int]
- arrayTagIsClassManifest[String]
- arrayTagIsClassManifest[Array[Int]]
+import scala.reflect.{ClassTag, classTag}
+object Test extends App {
def classTagIsClassManifest[T: ClassTag] = {
println(classManifest[T])
}
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.scala b/test/files/run/interop_concretetypetags_are_classmanifests.scala
deleted file mode 100644
index b578d7e626..0000000000
--- a/test/files/run/interop_concretetypetags_are_classmanifests.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def concreteTypeTagIsClassManifest[T: ConcreteTypeTag] = {
- println(classManifest[T])
- }
-
- concreteTypeTagIsClassManifest[Int]
- concreteTypeTagIsClassManifest[String]
- concreteTypeTagIsClassManifest[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/run/interop_concretetypetags_are_manifests.scala b/test/files/run/interop_concretetypetags_are_manifests.scala
deleted file mode 100644
index 731410bc10..0000000000
--- a/test/files/run/interop_concretetypetags_are_manifests.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-object Test extends App {
- def concreteTypeTagIsManifest[T: ConcreteTypeTag] = {
- println(manifest[T])
- }
-
- concreteTypeTagIsManifest[Int]
- concreteTypeTagIsManifest[String]
- concreteTypeTagIsManifest[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.check b/test/files/run/interop_manifests_are_abstypetags.check
index c59e92d4eb..c59e92d4eb 100644
--- a/test/files/run/interop_concretetypetags_are_classmanifests.check
+++ b/test/files/run/interop_manifests_are_abstypetags.check
diff --git a/test/files/run/interop_manifests_are_abstypetags.scala b/test/files/run/interop_manifests_are_abstypetags.scala
new file mode 100644
index 0000000000..1cba2fdb4b
--- /dev/null
+++ b/test/files/run/interop_manifests_are_abstypetags.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def manifestIsAbsTypeTag[T: Manifest] = {
+ println(implicitly[AbsTypeTag[T]].tpe)
+ }
+
+ manifestIsAbsTypeTag[Int]
+ manifestIsAbsTypeTag[String]
+ manifestIsAbsTypeTag[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/run/interop_manifests_are_classtags.check b/test/files/run/interop_manifests_are_classtags.check
index 07ff6b984a..aaf4aba012 100644
--- a/test/files/run/interop_manifests_are_classtags.check
+++ b/test/files/run/interop_manifests_are_classtags.check
@@ -1,24 +1,18 @@
Int
-Int
List()
List(0, 0, 0, 0, 0)
java.lang.String
-java.lang.String
List()
List(null, null, null, null, null)
Array[Int]
-Array[Int]
List()
List(null, null, null, null, null)
Int
-Int
List()
List(0, 0, 0, 0, 0)
java.lang.String
-java.lang.String
List()
List(null, null, null, null, null)
Array[Int]
-Array[Int]
List()
List(null, null, null, null, null)
diff --git a/test/files/run/interop_manifests_are_classtags.scala b/test/files/run/interop_manifests_are_classtags.scala
index 582cea3467..03479e527a 100644
--- a/test/files/run/interop_manifests_are_classtags.scala
+++ b/test/files/run/interop_manifests_are_classtags.scala
@@ -1,7 +1,8 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
def classManifestIsClassTag[T: ClassManifest] = {
- println(arrayTag[T])
- println(erasureTag[T])
+ println(classTag[T])
println(Array[T]().toList)
println(new Array[T](5).toList)
}
@@ -11,8 +12,7 @@ object Test extends App {
classManifestIsClassTag[Array[Int]]
def manifestIsClassTag[T: Manifest] = {
- println(arrayTag[T])
- println(erasureTag[T])
+ println(classTag[T])
println(Array[T]().toList)
println(new Array[T](5).toList)
}
diff --git a/test/files/run/interop_manifests_are_concretetypetags.check b/test/files/run/interop_manifests_are_concretetypetags.check
deleted file mode 100644
index edab85ecf1..0000000000
--- a/test/files/run/interop_manifests_are_concretetypetags.check
+++ /dev/null
@@ -1,6 +0,0 @@
-Int
-int
-String
-class java.lang.String
-Array[Int]
-class [I
diff --git a/test/files/run/interop_manifests_are_concretetypetags.scala b/test/files/run/interop_manifests_are_concretetypetags.scala
deleted file mode 100644
index 0b82a56d0a..0000000000
--- a/test/files/run/interop_manifests_are_concretetypetags.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-object Test extends App {
- def manifestIsConcreteTypeTag[T: Manifest] = {
- println(concreteTypeTag[T].tpe)
- println(concreteTypeTag[T].erasure)
- }
-
- manifestIsConcreteTypeTag[Int]
- manifestIsConcreteTypeTag[String]
- manifestIsConcreteTypeTag[Array[Int]]
-} \ No newline at end of file
diff --git a/test/files/run/interop_manifests_are_typetags.check b/test/files/run/interop_manifests_are_typetags.check
index edab85ecf1..c59e92d4eb 100644
--- a/test/files/run/interop_manifests_are_typetags.check
+++ b/test/files/run/interop_manifests_are_typetags.check
@@ -1,6 +1,3 @@
-Int
-int
-String
-class java.lang.String
-Array[Int]
-class [I
+Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_manifests_are_typetags.scala b/test/files/run/interop_manifests_are_typetags.scala
index 03a7b7b6d5..294d3c22de 100644
--- a/test/files/run/interop_manifests_are_typetags.scala
+++ b/test/files/run/interop_manifests_are_typetags.scala
@@ -1,7 +1,8 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
def manifestIsTypeTag[T: Manifest] = {
- println(typeTag[T].tpe)
- println(typeTag[T].erasure)
+ println(typeOf[T])
}
manifestIsTypeTag[Int]
diff --git a/test/files/run/interop_concretetypetags_are_manifests.check b/test/files/run/interop_typetags_are_manifests.check
index c59e92d4eb..871167e3ab 100644
--- a/test/files/run/interop_concretetypetags_are_manifests.check
+++ b/test/files/run/interop_typetags_are_manifests.check
@@ -1,3 +1,3 @@
-Int
+int
java.lang.String
Array[Int]
diff --git a/test/files/run/interop_typetags_are_manifests.scala b/test/files/run/interop_typetags_are_manifests.scala
new file mode 100644
index 0000000000..1aca7f52cc
--- /dev/null
+++ b/test/files/run/interop_typetags_are_manifests.scala
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+object Test extends App {
+ def typeTagIsManifest[T: TypeTag : ClassTag] = {
+ println(manifest[T])
+ }
+
+ typeTagIsManifest[Int]
+ typeTagIsManifest[String]
+ typeTagIsManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/run/iq-msil.check b/test/files/run/iq-msil.check
deleted file mode 100644
index 08f9fc755e..0000000000
--- a/test/files/run/iq-msil.check
+++ /dev/null
@@ -1,12 +0,0 @@
-Empty
-Head: 42
-q5: Queue(0,1,2,3,4,5,6,7,8,9)
-q5[5]: 5
-q5 == q5c: True
-q5c == q5: True
-q8: Queue(2,3,4,5,6,7,8,9,10,11)
-q8 == q9: True
-Elements: 1 2 3 4 5 6 7 8 9
-String: <1-2-3-4-5-6-7-8-9>
-Length: 9
-Front: 1
diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala
index 4186c4c4a6..440d1e2915 100644
--- a/test/files/run/macro-abort-fresh/Macros_1.scala
+++ b/test/files/run/macro-abort-fresh/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.makro.Context
object Impls {
def impl(c: Context) = {
- import c.mirror._
+ import c.universe._
println(c.fresh())
println(c.fresh("qwe"))
println(c.fresh(newTypeName("qwe")))
diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala
index ecf48b9752..c6caa2b585 100644
--- a/test/files/run/macro-abort-fresh/Test_2.scala
+++ b/test/files/run/macro-abort-fresh/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Select(Ident("Macros"), newTermName("foo"))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
} \ No newline at end of file
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 3f23e349d5..039488ba3e 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
@@ -2,20 +2,20 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
-}
+} \ No newline at end of file
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 44bfe861e3..6e1e37a485 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
@@ -2,21 +2,21 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
}
diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala
index 82d2cce2f5..96d26741f7 100644
--- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala
+++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala
@@ -2,18 +2,18 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))))
}
def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
- Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
+ import c.universe._
+ c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))))
}
def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
-}
+} \ 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 5c5ec2c999..7de1e59cc7 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
@@ -5,8 +5,8 @@ object Impls {
def refToFoo(dummy: Int) = macro refToFoo_impl
def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val body = Select(Ident(newTermName("Impls")), newTermName("foo"))
- Expr[Int](body)
+ c.Expr[Int](body)
}
} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-annotation/Impls_1.scala b/test/files/run/macro-declared-in-annotation/Impls_1.scala
index a1234a7374..2b309e1cc8 100644
--- a/test/files/run/macro-declared-in-annotation/Impls_1.scala
+++ b/test/files/run/macro-declared-in-annotation/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(List(printPrefix), Literal(Constant("this is deprecated")))
- Expr[String](body)
+ c.Expr[String](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-declared-in-anonymous/Impls_1.scala
index c0827ace31..d95dbd42c6 100644
--- a/test/files/run/macro-declared-in-anonymous/Impls_1.scala
+++ b/test/files/run/macro-declared-in-anonymous/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-block/Impls_1.scala b/test/files/run/macro-declared-in-block/Impls_1.scala
index c0827ace31..d95dbd42c6 100644
--- a/test/files/run/macro-declared-in-block/Impls_1.scala
+++ b/test/files/run/macro-declared-in-block/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-class-class/Impls_1.scala b/test/files/run/macro-declared-in-class-class/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-class-class/Impls_1.scala
+++ b/test/files/run/macro-declared-in-class-class/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-class-object/Impls_1.scala b/test/files/run/macro-declared-in-class-object/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-class-object/Impls_1.scala
+++ b/test/files/run/macro-declared-in-class-object/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-class/Impls_1.scala b/test/files/run/macro-declared-in-class/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-class/Impls_1.scala
+++ b/test/files/run/macro-declared-in-class/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-default-param/Impls_1.scala b/test/files/run/macro-declared-in-default-param/Impls_1.scala
index e45095812a..5e7351e954 100644
--- a/test/files/run/macro-declared-in-default-param/Impls_1.scala
+++ b/test/files/run/macro-declared-in-default-param/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(List(printPrefix), Literal(Constant("it works")))
- Expr[String](body)
+ c.Expr[String](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala
index 8605d4a8be..e5fb4bcdf3 100644
--- a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala
+++ b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala
@@ -3,10 +3,10 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def toOptionOfInt(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, newTermName("x")), newTermName("toInt")))))
- Expr[Option[Int]](body)
+ c.Expr[Option[Int]](body)
}
}
@@ -16,4 +16,4 @@ object Macros {
class Foo(val x: String) {
def toOptionOfInt = macro Impls.toOptionOfInt
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-method/Impls_1.scala b/test/files/run/macro-declared-in-method/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-method/Impls_1.scala
+++ b/test/files/run/macro-declared-in-method/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-object-class/Impls_1.scala b/test/files/run/macro-declared-in-object-class/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-object-class/Impls_1.scala
+++ b/test/files/run/macro-declared-in-object-class/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-object-object/Impls_1.scala b/test/files/run/macro-declared-in-object-object/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-object-object/Impls_1.scala
+++ b/test/files/run/macro-declared-in-object-object/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-object/Impls_1.scala b/test/files/run/macro-declared-in-object/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-object/Impls_1.scala
+++ b/test/files/run/macro-declared-in-object/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-package-object/Impls_1.scala b/test/files/run/macro-declared-in-package-object/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-package-object/Impls_1.scala
+++ b/test/files/run/macro-declared-in-package-object/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-refinement/Impls_1.scala b/test/files/run/macro-declared-in-refinement/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-refinement/Impls_1.scala
+++ b/test/files/run/macro-declared-in-refinement/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-declared-in-trait/Impls_1.scala b/test/files/run/macro-declared-in-trait/Impls_1.scala
index c2e6933582..5c61086a40 100644
--- a/test/files/run/macro-declared-in-trait/Impls_1.scala
+++ b/test/files/run/macro-declared-in-trait/Impls_1.scala
@@ -3,9 +3,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix))))
val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala
index f8f15b4224..0f84859545 100644
--- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala
+++ b/test/files/run/macro-def-infer-return-type-b/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
-} \ No newline at end of file
+}
diff --git a/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala
index 32f03e778e..aca7f999d5 100644
--- a/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala
+++ b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala
@@ -1,3 +1,4 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.Context
import scala.reflect.api.Universe
@@ -5,4 +6,4 @@ object Test {
def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T]
def materializeTypeTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala
index 39db275e1c..b59555539c 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(x.tree))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
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 0262485994..68ead9b9a5 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt"))))
- Expr[Option[Int]](body)
+ c.Expr[Option[Int]](body)
}
-}
+} \ No newline at end of file
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 510d8502f6..a1dd5aa801 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Literal(Constant(2))
- Expr[Int](body)
+ c.Expr[Int](body)
}
-}
+} \ No newline at end of file
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 0262485994..68ead9b9a5 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = {
- import c.mirror._
+ import c.universe._
val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt"))))
- Expr[Option[Int]](body)
+ c.Expr[Option[Int]](body)
}
-}
+} \ No newline at end of file
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 ae1c50eace..2c1748bc29 100644
--- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
+++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala
@@ -2,9 +2,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-nullary-generic.check b/test/files/run/macro-expand-nullary-generic.check
index 6dfe04af12..0895c30c3f 100644
--- a/test/files/run/macro-expand-nullary-generic.check
+++ b/test/files/run/macro-expand-nullary-generic.check
@@ -1,6 +1,6 @@
-it works ConcreteTypeTag[Int]
-it works ConcreteTypeTag[Int]
-it works ConcreteTypeTag[Int]
-it works ConcreteTypeTag[Int]
-it works ConcreteTypeTag[Int]
+it works TypeTag[Int]
+it works TypeTag[Int]
+it works TypeTag[Int]
+it works TypeTag[Int]
+it works TypeTag[Int]
kkthxbai
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 10352594f5..edbe6d504a 100644
--- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala
@@ -1,14 +1,15 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def impl[T: c.TypeTag](c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.TypeTag[T]]))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooNullary[T: c.TypeTag](c: Ctx) = impl[T](c)
def fooEmpty[T: c.TypeTag](c: Ctx)() = impl[T](c)
def barNullary[T: c.TypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c)
def barEmpty[T: c.TypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c)
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
index 7dc58abba8..0d849a085d 100644
--- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
+++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala
@@ -2,13 +2,13 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def impl(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooNullary(c: Ctx) = impl(c)
def fooEmpty(c: Ctx)() = impl(c)
def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c)
def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c)
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala
index 1dc4adc20e..f4646d43df 100644
--- a/test/files/run/macro-expand-overload/Impls_1.scala
+++ b/test/files/run/macro-expand-overload/Impls_1.scala
@@ -3,13 +3,13 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooObjectString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectString", x)
def fooObjectInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectInt", x)
def fooClassString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassString", x)
def fooClassInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassInt", x)
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala
index 0b127f5a59..d6493caad9 100644
--- a/test/files/run/macro-expand-override/Impls_1.scala
+++ b/test/files/run/macro-expand-override/Impls_1.scala
@@ -3,13 +3,13 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def impl(c: Ctx)(tag: String, x: c.Expr[_]) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x)
def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x)
def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x)
def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x)
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala
index 6eff805989..26833ca0b9 100644
--- a/test/files/run/macro-expand-recursive/Impls_1.scala
+++ b/test/files/run/macro-expand-recursive/Impls_1.scala
@@ -2,14 +2,14 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
def fooFoo(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Select(Ident(newTermName("Macros")), newTermName("foo"))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-explicit.check b/test/files/run/macro-expand-tparams-explicit.check
index 5670e27c4e..19e6d39bc8 100644
--- a/test/files/run/macro-expand-tparams-explicit.check
+++ b/test/files/run/macro-expand-tparams-explicit.check
@@ -1 +1 @@
-ConcreteTypeTag[Int]
+TypeTag[Int]
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 957d8331fc..d1843275d0 100644
--- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala
@@ -1,10 +1,11 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U: c.TypeTag](c: Ctx) = {
- import c.mirror._
+ import c.universe._
val U = implicitly[c.TypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check
index e57fc1217b..80c6b826ba 100644
--- a/test/files/run/macro-expand-tparams-implicit.check
+++ b/test/files/run/macro-expand-tparams-implicit.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[String]
+TypeTag[Int]
+TypeTag[String]
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 c25d12be60..cbc5460720 100644
--- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala
@@ -1,10 +1,11 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = {
- import c.mirror._
+ import c.universe._
val U = implicitly[c.TypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-optional/Impls_1.scala b/test/files/run/macro-expand-tparams-optional/Impls_1.scala
index 37efb009c4..97363edd9a 100644
--- a/test/files/run/macro-expand-tparams-optional/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-optional/Impls_1.scala
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U](c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("don't know U"))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check
index 922be1a6dd..6c23b47d64 100644
--- a/test/files/run/macro-expand-tparams-prefix-a.check
+++ b/test/files/run/macro-expand-tparams-prefix-a.check
@@ -1,4 +1,4 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[Int]
-ConcreteTypeTag[String]
-ConcreteTypeTag[Boolean]
+TypeTag[Int]
+TypeTag[Int]
+TypeTag[String]
+TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala
index c25d12be60..cbc5460720 100644
--- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala
@@ -1,10 +1,11 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = {
- import c.mirror._
+ import c.universe._
val U = implicitly[c.TypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check
index a336bb51ec..67dabff11e 100644
--- a/test/files/run/macro-expand-tparams-prefix-b.check
+++ b/test/files/run/macro-expand-tparams-prefix-b.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Boolean] ConcreteTypeTag[Int]
-ConcreteTypeTag[Boolean] ConcreteTypeTag[String]
+TypeTag[Boolean] TypeTag[Int]
+TypeTag[Boolean] TypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala
index 8af3ecc9ae..3d29fa467d 100644
--- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala
@@ -1,11 +1,12 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T: c.TypeTag, U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = {
- import c.mirror._
+ import c.universe._
val T = implicitly[c.TypeTag[T]]
val U = implicitly[c.TypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString))))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check
index 87f295aa49..8d1c4e3416 100644
--- a/test/files/run/macro-expand-tparams-prefix-c1.check
+++ b/test/files/run/macro-expand-tparams-prefix-c1.check
@@ -1,3 +1,3 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[String]
-ConcreteTypeTag[Boolean]
+TypeTag[Int]
+TypeTag[String]
+TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala
index 4da5a9b823..a834d809da 100644
--- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala
@@ -1,12 +1,13 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
- Expr(Block(List(
+ import c.universe._
+ c.Expr(Block(List(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))),
Literal(Constant(()))))
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check
index 87f295aa49..8d1c4e3416 100644
--- a/test/files/run/macro-expand-tparams-prefix-c2.check
+++ b/test/files/run/macro-expand-tparams-prefix-c2.check
@@ -1,3 +1,3 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[String]
-ConcreteTypeTag[Boolean]
+TypeTag[Int]
+TypeTag[String]
+TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala
index 4d137a4aef..e0de1f3f83 100644
--- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala
@@ -1,9 +1,10 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
- Expr(Block(List(
+ import c.universe._
+ c.Expr(Block(List(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))),
@@ -15,4 +16,4 @@ class D[T] {
class C[U] {
def foo[V] = macro Impls.foo[T, U, V]
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check
index ca7a220475..319edfbed0 100644
--- a/test/files/run/macro-expand-tparams-prefix-d1.check
+++ b/test/files/run/macro-expand-tparams-prefix-d1.check
@@ -1,3 +1,3 @@
-TypeTag[T]
-TypeTag[U]
-ConcreteTypeTag[Boolean]
+AbsTypeTag[T]
+AbsTypeTag[U]
+TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala
index 4da5a9b823..f497e5f7a9 100644
--- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala
@@ -1,12 +1,13 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
- def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
- Expr(Block(List(
+ def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = {
+ import c.universe._
+ c.Expr(Block(List(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))),
- Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))),
+ Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))),
Literal(Constant(()))))
}
-}
+} \ No newline at end of file
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 d97f0af786..b83fa046e5 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList)
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
index 01fc9d4462..c0319fcd6c 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
@@ -3,8 +3,10 @@ object Macros {
}
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR))))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
} \ No newline at end of file
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 f9667d78b8..5f550064e1 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
@@ -2,12 +2,12 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
- import c.mirror._
+ import c.universe._
val stripped_xs = xs map (_.tree) toList match {
case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped)
case _ => ???
}
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), stripped_xs)
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
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 8c609daa0e..8c75a7e0ea 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
@@ -6,8 +6,8 @@ object Impls {
}
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList)
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
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 d97f0af786..b83fa046e5 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList)
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
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 8c609daa0e..8c75a7e0ea 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
@@ -6,8 +6,8 @@ object Impls {
}
def foo(c: Ctx)(xs: c.Expr[Int]*) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList)
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
-}
+} \ No newline at end of file
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 cece1c09e4..8154ab0341 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,20 +1,21 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo_targs[T, U: c.TypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
import c.{prefix => prefix}
- import c.mirror._
+ import c.universe._
val U = implicitly[c.TypeTag[U]]
val body = Block(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))),
- Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.tpe)))),
+ Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticTpe)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe)))),
Literal(Constant(())))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
}
class Macros[T] {
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
-}
+} \ No newline at end of file
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 000e351f4d..367a45a2c3 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
@@ -2,11 +2,11 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = {
- import unconventionalName.mirror._
+ import unconventionalName.universe._
val body = Block(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo...")))),
Literal(Constant(())))
- Expr[Unit](body)
+ unconventionalName.Expr[Unit](body)
}
}
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala
index 828ccf34e2..5a7d1a6b9a 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx): c.Expr[Int] = {
- import c.mirror._
- Expr(Literal(Constant("42")))
+ import c.universe._
+ c.Expr(Literal(Constant("42")))
}
}
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala
index ecf48b9752..c6caa2b585 100644
--- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala
+++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Select(Ident("Macros"), newTermName("foo"))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
} \ No newline at end of file
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 f3a0476a35..04eef976c5 100644
--- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala
@@ -2,12 +2,12 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx) = {
- import c.mirror._
+ import c.universe._
val body = Ident("IDoNotExist")
- Expr[Int](body)
+ c.Expr[Int](body)
}
}
object Macros {
def foo = macro Impls.foo
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala
index ecf48b9752..c6caa2b585 100644
--- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala
+++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Select(Ident("Macros"), newTermName("foo"))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
} \ No newline at end of file
diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala
index aeb3c26eaa..8322e8a4e0 100644
--- a/test/files/run/macro-invalidusage-badret/Test_2.scala
+++ b/test/files/run/macro-invalidusage-badret/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Typed(Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String")))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
-} \ No newline at end of file
+}
diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check
new file mode 100644
index 0000000000..73f57b0b81
--- /dev/null
+++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check
@@ -0,0 +1,3 @@
+reflective compilation has failed:
+
+macros cannot be partially applied
diff --git a/test/files/neg/macro-argtype-mismatch.flags b/test/files/run/macro-invalidusage-partialapplication-with-tparams.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/files/neg/macro-argtype-mismatch.flags
+++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.flags
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
new file mode 100644
index 0000000000..67a19a6d62
--- /dev/null
+++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala
@@ -0,0 +1,13 @@
+import scala.reflect.makro.{Context => Ctx}
+
+object Impls {
+ def foo[T: c.TypeTag](c: Ctx)(x: c.Expr[T]) = {
+ import c.universe._
+ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString))))
+ c.Expr[Unit](body)
+ }
+}
+
+object Macros {
+ def foo[T](x: T) = macro Impls.foo[T]
+} \ No newline at end of file
diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala
new file mode 100644
index 0000000000..f51cc7e699
--- /dev/null
+++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala
@@ -0,0 +1,8 @@
+object Test extends App {
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
+ val tree = Select(Ident("Macros"), newTermName("foo"))
+ try cm.mkToolBox().runExpr(tree)
+ catch { case ex: Throwable => println(ex.getMessage) }
+}
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 449b91d074..e5bdca008e 100644
--- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
+++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val sum = Apply(Select(x.tree, newTermName("$plus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum))
- Expr[Unit](body)
+ c.Expr[Unit](body)
}
}
diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala
index 293d906048..64020b2aa9 100644
--- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala
+++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(40))))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
}
diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala
index 9fd658656e..ffeccce1e8 100644
--- a/test/files/run/macro-openmacros/Impls_Macros_1.scala
+++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
// we're macros, so we can reflect against our source path
// so we don't need any partests to clean up after us!
val c.CompilationUnit(file, _, _) = c.enclosingUnit
- val dir = file.getParentFile
+ val dir = file.getCanonicalFile.getParentFile
def normalizePaths(s: String) = {
val base = (dir.getCanonicalPath + java.io.File.separator).replace('\\', '/')
var regex = """\Q%s\E""" format base
@@ -13,12 +13,12 @@ object Macros {
if (isWin) regex = "(?i)" + regex
s.replace('\\', '/').replaceAll(regex, "")
}
-
- import c.mirror._
- val next = if (c.enclosingMacros.length < 3) Expr[Unit](Select(Ident(staticModule("Macros")), newTermName("foo"))) else c.literalUnit
+
+ import c.universe._
+ val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), newTermName("foo"))) else c.literalUnit
c.reify {
- println(c.literal(normalizePaths(c.enclosingMacros.toString)).eval)
- next.eval
+ println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice)
+ next.splice
}
}
diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala
index bd46e1f529..650257ae16 100644
--- a/test/files/run/macro-range/Common_1.scala
+++ b/test/files/run/macro-range/Common_1.scala
@@ -1,4 +1,3 @@
-import reflect.api.Modifier
import reflect.makro.Context
abstract class RangeDefault {
@@ -12,7 +11,7 @@ abstract class RangeDefault {
/** This class should go into reflect.macro once it is a bit more stable. */
abstract class Utils {
val context: Context
- import context.mirror._
+ import context.universe._
class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer {
override def transform(tree: Tree): Tree = tree match {
diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala
index 051afff99c..fecce6bc48 100644
--- a/test/files/run/macro-range/Expansion_Impossible_2.scala
+++ b/test/files/run/macro-range/Expansion_Impossible_2.scala
@@ -1,4 +1,3 @@
-import reflect.api.Modifier
import reflect.makro.Context
object Impls {
@@ -7,14 +6,15 @@ object Impls {
//println("macro-expand, _this = "+ _this)
object utils extends Utils { val context: c.type = c }
import utils._
- import c.mirror._
+ import c.universe._
+ import Flag._
- val initName = newTermName("<init>")
+ val initName = nme.CONSTRUCTOR
// Either:
// scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } }
// or:
// scala"($_this: RangeDefault).foreach($f)"
- Expr(c.prefix.tree match {
+ c.Expr(c.prefix.tree match {
case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" =>
val iname = newTermName("$i")
val hname = newTermName("$h")
@@ -28,7 +28,7 @@ object Impls {
val generated =
Block(
List(
- ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo),
+ ValDef(Modifiers(MUTABLE), iname, TypeTree(), lo),
ValDef(Modifiers(), hname, TypeTree(), hi)),
makeWhile(labelname, cond, body))
// todo. read the compiler config and print if -Ydebug is set
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 f6caf89dca..b10f4121a6 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
@@ -2,9 +2,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
}
diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala
index 632708a125..67666a632b 100644
--- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala
+++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala
@@ -1,5 +1,7 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
- println(Expr(tree).eval)
+ println(cm.mkToolBox().runExpr(tree))
}
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 dc7d42d23e..dd8fcd4d9e 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
@@ -2,8 +2,8 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
+ c.Expr[Int](body)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
index cf34f1685d..32a8958577 100644
--- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
+++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
@@ -3,15 +3,18 @@
//}
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.universe.Flag._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo"))
val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.asType), EmptyTree)
- val macrodef = DefDef(Modifiers(Set(scala.reflect.api.Modifier.`macro`)), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody)
+ val macrodef = DefDef(Modifiers(MACRO), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody)
val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(Apply(Select(Super(This(EmptyTypeName), EmptyTypeName), nme.CONSTRUCTOR), List())))
val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef)))
val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
val tree = Block(macrodef, module, macroapp)
- val toolbox = mkToolBox(options = "-language:experimental.macros")
+ val toolbox = cm.mkToolBox(options = "-language:experimental.macros")
println(toolbox.runExpr(tree))
}
diff --git a/test/files/run/macro-reify-abstypetag-notypeparams.check b/test/files/run/macro-reify-abstypetag-notypeparams.check
new file mode 100644
index 0000000000..aadd713bef
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-notypeparams.check
@@ -0,0 +1,2 @@
+TypeTag[Int]
+TypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala
new file mode 100644
index 0000000000..34f742b9fb
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala
@@ -0,0 +1,6 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ println(implicitly[AbsTypeTag[Int]])
+ println(implicitly[AbsTypeTag[List[Int]]])
+} \ No newline at end of file
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags.check b/test/files/run/macro-reify-abstypetag-typeparams-notags.check
new file mode 100644
index 0000000000..be62b59a69
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-typeparams-notags.check
@@ -0,0 +1,2 @@
+AbsTypeTag[T]
+AbsTypeTag[List[T]]
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala
new file mode 100644
index 0000000000..0b42cc07b5
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def fooNoTypeTag[T] = {
+ println(implicitly[AbsTypeTag[T]])
+ println(implicitly[AbsTypeTag[List[T]]])
+ }
+ fooNoTypeTag[Int]
+} \ No newline at end of file
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags.check b/test/files/run/macro-reify-abstypetag-typeparams-tags.check
new file mode 100644
index 0000000000..d6ca5a85ef
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-typeparams-tags.check
@@ -0,0 +1,2 @@
+TypeTag[Int]
+AbsTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala
new file mode 100644
index 0000000000..82a7b7971d
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def fooTypeTag[T: AbsTypeTag] = {
+ println(implicitly[AbsTypeTag[T]])
+ println(implicitly[AbsTypeTag[List[T]]])
+ }
+ fooTypeTag[Int]
+} \ No newline at end of file
diff --git a/test/files/run/macro-reify-abstypetag-usetypetag.check b/test/files/run/macro-reify-abstypetag-usetypetag.check
new file mode 100644
index 0000000000..d6ca5a85ef
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-usetypetag.check
@@ -0,0 +1,2 @@
+TypeTag[Int]
+AbsTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala
new file mode 100644
index 0000000000..3c62725c42
--- /dev/null
+++ b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def fooTypeTag[T: TypeTag] = {
+ println(implicitly[AbsTypeTag[T]])
+ println(implicitly[AbsTypeTag[List[T]]])
+ }
+ fooTypeTag[Int]
+} \ No newline at end of file
diff --git a/test/files/run/macro-reify-basic/Macros_1.scala b/test/files/run/macro-reify-basic/Macros_1.scala
index b2243d131c..7a43ee58be 100644
--- a/test/files/run/macro-reify-basic/Macros_1.scala
+++ b/test/files/run/macro-reify-basic/Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
object Impls {
def foo(c: Ctx)(s: c.Expr[String]) = c.reify {
- println("hello " + s.eval)
+ println("hello " + s.splice)
}
}
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-eval-eval.flags b/test/files/run/macro-reify-eval-eval.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-reify-eval-eval.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-reify-eval-outside-reify.flags b/test/files/run/macro-reify-eval-outside-reify.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-reify-eval-outside-reify.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala
deleted file mode 100644
index 086f9aeef2..0000000000
--- a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-import scala.reflect.makro.{Context => Ctx}
-
-object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
- val x1 = c.Expr[Int](c.resetAllAttrs(x.tree))
- c.literal(x1.eval)
- }
-}
-
-object Macros {
- def foo(x: Int) = macro Impls.foo
-}
diff --git a/test/files/run/macro-reify-eval-outside-reify/Test_2.scala b/test/files/run/macro-reify-eval-outside-reify/Test_2.scala
deleted file mode 100644
index 632708a125..0000000000
--- a/test/files/run/macro-reify-eval-outside-reify/Test_2.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-object Test extends App {
- import scala.reflect.mirror._
- val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
- println(Expr(tree).eval)
-}
diff --git a/test/files/run/macro-reify-freevars.check b/test/files/run/macro-reify-freevars.check
index 068742f0b6..2e925f9fa8 100644
--- a/test/files/run/macro-reify-freevars.check
+++ b/test/files/run/macro-reify-freevars.check
@@ -1,3 +1,3 @@
-reflective compilation has failed:
-
-Macro expansion contains free term variable code defined by map in Macros_1.scala:8:9. Have you forgotten to use eval when splicing this variable into a reifee? If you have troubles tracking free term variables, consider using -Xlog-free-terms
+reflective compilation has failed:
+
+Macro expansion contains free term variable code defined by map in Macros_1.scala:9:9. Have you forgotten to use splice when splicing this variable into a reifee? If you have troubles tracking free term variables, consider using -Xlog-free-terms
diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala
index 3cc559a0af..eafc7f9a82 100644
--- a/test/files/run/macro-reify-freevars/Macros_1.scala
+++ b/test/files/run/macro-reify-freevars/Macros_1.scala
@@ -1,13 +1,14 @@
package scala.collection.slick
+
object QueryableMacros{
def map[T:c.TypeTag, S:c.TypeTag]
(c: scala.reflect.makro.Context)
- (projection: c.mirror.Expr[T => S])
- : c.mirror.Expr[scala.collection.slick.Queryable[S]] = {
- import c.mirror._
+ (projection: c.Expr[T => S])
+ : c.Expr[scala.collection.slick.Queryable[S]] = {
+ import c.universe._
val code = EmptyTree
c.reify{
- Queryable.factory[S]( code.asInstanceOf[reflect.mirror.Tree] )
+ Queryable.factory[S]( code.asInstanceOf[reflect.runtime.universe.Tree] )
}
}
}
@@ -15,5 +16,5 @@ class Queryable[T]{
def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S]
}
object Queryable{
- def factory[S]( projection:scala.reflect.mirror.Tree ) : Queryable[S] = null
+ def factory[S]( projection:reflect.runtime.universe.Tree ) : Queryable[S] = null
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala
index e7077f9c7f..603cf10d41 100644
--- a/test/files/run/macro-reify-freevars/Test_2.scala
+++ b/test/files/run/macro-reify-freevars/Test_2.scala
@@ -1,9 +1,11 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val q = New(AppliedTypeTree(Select(Select(Select(Ident("scala"), newTermName("collection")), newTermName("slick")), newTypeName("Queryable")), List(Ident("Int"))))
val x = ValDef(NoMods, newTermName("x"), Ident("Int"), EmptyTree)
val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5")))))
val tree = Apply(Select(q, newTermName("map")), List(fn))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-groundtypetag-notypeparams.check b/test/files/run/macro-reify-groundtypetag-notypeparams.check
deleted file mode 100644
index d75b3c72b2..0000000000
--- a/test/files/run/macro-reify-groundtypetag-notypeparams.check
+++ /dev/null
@@ -1,2 +0,0 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala b/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala
deleted file mode 100644
index d2f8fab5ec..0000000000
--- a/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- println(implicitly[ConcreteTypeTag[Int]])
- println(implicitly[ConcreteTypeTag[List[Int]]])
-} \ No newline at end of file
diff --git a/test/files/run/macro-reify-groundtypetag-typeparams-tags.check b/test/files/run/macro-reify-groundtypetag-typeparams-tags.check
deleted file mode 100644
index d75b3c72b2..0000000000
--- a/test/files/run/macro-reify-groundtypetag-typeparams-tags.check
+++ /dev/null
@@ -1,2 +0,0 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala
deleted file mode 100644
index 6d7eab5f9a..0000000000
--- a/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- def fooTypeTag[T: ConcreteTypeTag] = {
- println(implicitly[ConcreteTypeTag[T]])
- println(implicitly[ConcreteTypeTag[List[T]]])
- }
- fooTypeTag[Int]
-} \ No newline at end of file
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 1ce8f44671..f9a08df90d 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,17 +1,19 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
import scala.reflect.makro.Context
case class Utils[C <: Context]( c:C ) {
- import c.mirror._
+ import c.universe._
import c.{Tree=>_}
- object removeDoubleReify extends c.mirror.Transformer {
+ object removeDoubleReify extends c.universe.Transformer {
def apply( tree:Tree ) = transform(tree)
override def transform(tree: Tree): Tree = {
super.transform {
tree match {
- case Apply(TypeApply(Select(_this, termname), _), reified::Nil )
- if termname.toString == "factory" => c.unreifyTree(reified)
- case Apply(Select(_this, termname), reified::Nil )
- if termname.toString == "factory" => c.unreifyTree(reified)
+ case Apply(TypeApply(Select(_this, termname), _), reification::Nil )
+ if termname.toString == "factory" => c.unreifyTree(reification)
+ case Apply(Select(_this, termname), reification::Nil )
+ if termname.toString == "factory" => c.unreifyTree(reification)
case _ => tree
}
}
@@ -19,25 +21,25 @@ case class Utils[C <: Context]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.mirror.Expr[_] ) = {
- import c.mirror._
- val element_type = implicitly[c.TypeTag[S]].tpe
- val foo = Expr[reflect.mirror.Expr[Queryable[S]]](
- c.reifyTree( c.reflectMirrorPrefix, c.typeCheck(
+ def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ import c.universe._
+ val element_type = c.typeOf[S]
+ val foo = c.Expr[ru.Expr[Queryable[S]]](
+ c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
)))
- c.reify{ Queryable.factory[S]( foo.eval )}
+ c.reify{ Queryable.factory[S]( foo.splice )}
}
def map[T:c.TypeTag, S:c.TypeTag]
(c: scala.reflect.makro.Context)
- (projection: c.mirror.Expr[T => S]): c.mirror.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
+ (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
}
class Queryable[T]{
def _map[S]( projection: T => S ) : Queryable[S] = ???
def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S]
}
object Queryable{
- def factory[S]( projection:scala.reflect.mirror.Expr[Queryable[S]] ) : Queryable[S] = null
+ def factory[S]( projection:ru.Expr[Queryable[S]] ) : Queryable[S] = null
} \ No newline at end of file
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 1ce8f44671..f9a08df90d 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,17 +1,19 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
import scala.reflect.makro.Context
case class Utils[C <: Context]( c:C ) {
- import c.mirror._
+ import c.universe._
import c.{Tree=>_}
- object removeDoubleReify extends c.mirror.Transformer {
+ object removeDoubleReify extends c.universe.Transformer {
def apply( tree:Tree ) = transform(tree)
override def transform(tree: Tree): Tree = {
super.transform {
tree match {
- case Apply(TypeApply(Select(_this, termname), _), reified::Nil )
- if termname.toString == "factory" => c.unreifyTree(reified)
- case Apply(Select(_this, termname), reified::Nil )
- if termname.toString == "factory" => c.unreifyTree(reified)
+ case Apply(TypeApply(Select(_this, termname), _), reification::Nil )
+ if termname.toString == "factory" => c.unreifyTree(reification)
+ case Apply(Select(_this, termname), reification::Nil )
+ if termname.toString == "factory" => c.unreifyTree(reification)
case _ => tree
}
}
@@ -19,25 +21,25 @@ case class Utils[C <: Context]( c:C ) {
}
}
object QueryableMacros{
- def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.mirror.Expr[_] ) = {
- import c.mirror._
- val element_type = implicitly[c.TypeTag[S]].tpe
- val foo = Expr[reflect.mirror.Expr[Queryable[S]]](
- c.reifyTree( c.reflectMirrorPrefix, c.typeCheck(
+ def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
+ import c.universe._
+ val element_type = c.typeOf[S]
+ val foo = c.Expr[ru.Expr[Queryable[S]]](
+ c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
)))
- c.reify{ Queryable.factory[S]( foo.eval )}
+ c.reify{ Queryable.factory[S]( foo.splice )}
}
def map[T:c.TypeTag, S:c.TypeTag]
(c: scala.reflect.makro.Context)
- (projection: c.mirror.Expr[T => S]): c.mirror.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
+ (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection )
}
class Queryable[T]{
def _map[S]( projection: T => S ) : Queryable[S] = ???
def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S]
}
object Queryable{
- def factory[S]( projection:scala.reflect.mirror.Expr[Queryable[S]] ) : Queryable[S] = null
+ def factory[S]( projection:ru.Expr[Queryable[S]] ) : Queryable[S] = null
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-eval-outside-reify.check b/test/files/run/macro-reify-splice-outside-reify.check
index 2f562a182f..2f562a182f 100644
--- a/test/files/run/macro-reify-eval-outside-reify.check
+++ b/test/files/run/macro-reify-splice-outside-reify.check
diff --git a/test/files/neg/macro-noncompilertree.flags b/test/files/run/macro-reify-splice-outside-reify.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/files/neg/macro-noncompilertree.flags
+++ b/test/files/run/macro-reify-splice-outside-reify.flags
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
new file mode 100644
index 0000000000..3ddfe6a737
--- /dev/null
+++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
@@ -0,0 +1,24 @@
+import scala.reflect.makro.{Context => Ctx}
+
+object Impls {
+ def foo(c: Ctx)(x: c.Expr[Int]) = {
+ val x1 = c.Expr[Int](c.resetAllAttrs(x.tree))
+// was: c.literal(x1.splice)
+ c.literal(eval(c)(x1))
+ }
+
+ private def eval[T](c: Ctx)(x: c.Expr[T]): T = {
+ import scala.reflect.runtime.{universe => ru}
+ val mirror = ru.runtimeMirror(c.libraryClassLoader)
+ import scala.tools.reflect.ToolBox
+ val toolBox = mirror.mkToolBox()
+ val importer = ru.mkImporter(c.universe).asInstanceOf[ru.Importer { val from: c.universe.type }]
+ val tree = c.resetAllAttrs(x.tree.duplicate)
+ val imported = importer.importTree(tree)
+ toolBox.runExpr(imported).asInstanceOf[T]
+ }
+}
+
+object Macros {
+ def foo(x: Int) = macro Impls.foo
+}
diff --git a/test/files/run/macro-reify-value-outside-reify/Test_2.scala b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala
index 128cad4510..5bca7db668 100644
--- a/test/files/run/macro-reify-value-outside-reify/Test_2.scala
+++ b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala
@@ -1,6 +1,8 @@
object Test extends App {
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
- try println(Expr(tree).eval)
+ try println(cm.mkToolBox().runExpr(tree))
catch { case ex: Throwable => println(ex.getMessage) }
}
diff --git a/test/files/run/macro-reify-eval-eval.check b/test/files/run/macro-reify-splice-splice.check
index f35d3e67b4..f35d3e67b4 100644
--- a/test/files/run/macro-reify-eval-eval.check
+++ b/test/files/run/macro-reify-splice-splice.check
diff --git a/test/files/neg/macro-nontree.flags b/test/files/run/macro-reify-splice-splice.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/files/neg/macro-nontree.flags
+++ b/test/files/run/macro-reify-splice-splice.flags
diff --git a/test/files/run/macro-reify-eval-eval/Macros_1.scala b/test/files/run/macro-reify-splice-splice/Macros_1.scala
index 6b8ac94f0e..030a0a217e 100644
--- a/test/files/run/macro-reify-eval-eval/Macros_1.scala
+++ b/test/files/run/macro-reify-splice-splice/Macros_1.scala
@@ -6,7 +6,7 @@ object Macros {
object Impls {
def foo(c: Ctx) = c.reify {
- { c.reify(c.reify("hello world")) }.eval.eval
+ { c.reify(c.reify("hello world")) }.splice.splice
}
}
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-eval-eval/Test_2.scala b/test/files/run/macro-reify-splice-splice/Test_2.scala
index f697da6020..f697da6020 100644
--- a/test/files/run/macro-reify-eval-eval/Test_2.scala
+++ b/test/files/run/macro-reify-splice-splice/Test_2.scala
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 2ff12091a1..63f117220a 100644
--- a/test/files/run/macro-reify-tagful-a/Macros_1.scala
+++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala
@@ -1,3 +1,4 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.{Context => Ctx}
object Macros {
@@ -5,7 +6,7 @@ object Macros {
object Impls {
def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.reify {
- List(s.eval)
+ List(s.splice)
}
}
} \ No newline at end of file
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 45e39d7d1c..3796ae99cb 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
@@ -5,7 +5,7 @@ object Macros {
object Impls {
def foo[T](c: Ctx)(s: c.Expr[T]) = c.reify {
- List[T](s.eval)
+ List[T](s.splice)
}
}
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala
index 94efbd0c37..7029e59ea1 100644
--- a/test/files/run/macro-reify-tagless-a/Test_2.scala
+++ b/test/files/run/macro-reify-tagless-a/Test_2.scala
@@ -2,11 +2,13 @@ object Test extends App {
//val list: List[String] = Macros.foo("hello world")
//println(list)
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass)))
val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world"))))
val list = ValDef(NoMods, newTermName("list"), tpt, rhs)
val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name))))
- try Expr(tree).eval
+ try cm.mkToolBox().runExpr(tree)
catch { case ex: Throwable => println(ex.getMessage) }
}
diff --git a/test/files/run/macro-reify-typetag-notypeparams.check b/test/files/run/macro-reify-typetag-notypeparams.check
index d75b3c72b2..aadd713bef 100644
--- a/test/files/run/macro-reify-typetag-notypeparams.check
+++ b/test/files/run/macro-reify-typetag-notypeparams.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[List[Int]]
+TypeTag[Int]
+TypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-notypeparams/Test.scala b/test/files/run/macro-reify-typetag-notypeparams/Test.scala
index 041a44273d..be9feac4ca 100644
--- a/test/files/run/macro-reify-typetag-notypeparams/Test.scala
+++ b/test/files/run/macro-reify-typetag-notypeparams/Test.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
println(implicitly[TypeTag[Int]])
diff --git a/test/files/run/macro-reify-typetag-typeparams-notags.check b/test/files/run/macro-reify-typetag-typeparams-notags.check
deleted file mode 100644
index 11d78ece41..0000000000
--- a/test/files/run/macro-reify-typetag-typeparams-notags.check
+++ /dev/null
@@ -1,2 +0,0 @@
-TypeTag[T]
-TypeTag[List[T]]
diff --git a/test/files/run/macro-reify-typetag-typeparams-tags.check b/test/files/run/macro-reify-typetag-typeparams-tags.check
index 458593c449..aadd713bef 100644
--- a/test/files/run/macro-reify-typetag-typeparams-tags.check
+++ b/test/files/run/macro-reify-typetag-typeparams-tags.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Int]
-*ConcreteTypeTag[List[Int]]
+TypeTag[Int]
+TypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala
index b32680a4b8..be0ce33e41 100644
--- a/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala
+++ b/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def fooTypeTag[T: TypeTag] = {
diff --git a/test/files/run/macro-reify-typetag-usegroundtypetag.check b/test/files/run/macro-reify-typetag-usegroundtypetag.check
deleted file mode 100644
index 458593c449..0000000000
--- a/test/files/run/macro-reify-typetag-usegroundtypetag.check
+++ /dev/null
@@ -1,2 +0,0 @@
-ConcreteTypeTag[Int]
-*ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-unreify.check b/test/files/run/macro-reify-unreify.check
index a5334cc355..8f8d9d944d 100644
--- a/test/files/run/macro-reify-unreify.check
+++ b/test/files/run/macro-reify-unreify.check
@@ -1 +1 @@
-hello world = Expr[String("hello world")]("hello world")
+hello world = Expr[java.lang.String("hello world")]("hello world")
diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala
index 1b0b9c6421..14777506d3 100644
--- a/test/files/run/macro-reify-unreify/Macros_1.scala
+++ b/test/files/run/macro-reify-unreify/Macros_1.scala
@@ -5,14 +5,14 @@ object Macros {
object Impls {
def foo(c: Ctx)(s: c.Expr[String]) = {
- import c.mirror._
+ import c.universe._
- val world = c.reifyTree(c.reflectMirrorPrefix, s.tree)
- val greeting = c.reifyTree(c.reflectMirrorPrefix, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world)))))
- val typedGreeting = Expr[String](greeting)
+ val world = c.reifyTree(c.runtimeUniverse, EmptyTree, s.tree)
+ val greeting = c.reifyTree(c.runtimeUniverse, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world)))))
+ val typedGreeting = c.Expr[String](greeting)
c.reify {
- println("hello " + s.eval + " = " + typedGreeting.eval)
+ println("hello " + s.splice + " = " + typedGreeting.splice)
}
}
}
diff --git a/test/files/run/macro-reify-value-outside-reify.check b/test/files/run/macro-reify-value-outside-reify.check
deleted file mode 100644
index 2f562a182f..0000000000
--- a/test/files/run/macro-reify-value-outside-reify.check
+++ /dev/null
@@ -1 +0,0 @@
-42
diff --git a/test/files/run/macro-reify-value-outside-reify.flags b/test/files/run/macro-reify-value-outside-reify.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-reify-value-outside-reify.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala
deleted file mode 100644
index 109e19e44a..0000000000
--- a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-import scala.reflect.makro.{Context => Ctx}
-
-object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
- val x1 = c.Expr[Int](c.resetAllAttrs(x.tree))
- c.literal(x1.value)
- }
-}
-
-object Macros {
- def foo(x: Int) = macro Impls.foo
-}
diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check
index 9e0f9aa1a2..dc65e5c55b 100644
--- a/test/files/run/macro-repl-basic.check
+++ b/test/files/run/macro-repl-basic.check
@@ -1,54 +1,54 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import language.experimental.macros
-import language.experimental.macros
-
-scala> import scala.reflect.makro.{Context => Ctx}
-import scala.reflect.makro.{Context=>Ctx}
-
-scala>
-
-scala> object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
- }
-
- def bar(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
- }
-
- def quux(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
- }
-}
-defined module Impls
-
-scala> object Macros {
- object Shmacros {
- def foo(x: Int): Int = macro Impls.foo
- }
- def bar(x: Int): Int = macro Impls.bar
-}; class Macros {
- def quux(x: Int): Int = macro Impls.quux
-}
-defined module Macros
-defined class Macros
-
-scala>
-
-scala> import Macros.Shmacros._
-import Macros.Shmacros._
-
-scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
-31
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import language.experimental.macros
+import language.experimental.macros
+
+scala> import scala.reflect.makro.{Context => Ctx}
+import scala.reflect.makro.{Context=>Ctx}
+
+scala>
+
+scala> object Impls {
+ def foo(c: Ctx)(x: c.Expr[Int]) = {
+ import c.universe._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
+ c.Expr[Int](body)
+ }
+
+ def bar(c: Ctx)(x: c.Expr[Int]) = {
+ import c.universe._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
+ c.Expr[Int](body)
+ }
+
+ def quux(c: Ctx)(x: c.Expr[Int]) = {
+ import c.universe._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
+ c.Expr[Int](body)
+ }
+}
+defined module Impls
+
+scala> object Macros {
+ object Shmacros {
+ def foo(x: Int): Int = macro Impls.foo
+ }
+ def bar(x: Int): Int = macro Impls.bar
+}; class Macros {
+ def quux(x: Int): Int = macro Impls.quux
+}
+defined module Macros
+defined class Macros
+
+scala>
+
+scala> import Macros.Shmacros._
+import Macros.Shmacros._
+
+scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
+31
+
+scala>
diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala
index e8849b4b56..fba0aab116 100644
--- a/test/files/run/macro-repl-basic.scala
+++ b/test/files/run/macro-repl-basic.scala
@@ -7,21 +7,21 @@ object Test extends ReplTest {
|
|object Impls {
| def foo(c: Ctx)(x: c.Expr[Int]) = {
- | import c.mirror._
+ | import c.universe._
| val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- | Expr[Int](body)
+ | c.Expr[Int](body)
| }
|
| def bar(c: Ctx)(x: c.Expr[Int]) = {
- | import c.mirror._
+ | import c.universe._
| val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- | Expr[Int](body)
+ | c.Expr[Int](body)
| }
|
| def quux(c: Ctx)(x: c.Expr[Int]) = {
- | import c.mirror._
+ | import c.universe._
| val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- | Expr[Int](body)
+ | c.Expr[Int](body)
| }
|}
|object Macros {
diff --git a/test/files/run/macro-rettype-mismatch.check b/test/files/run/macro-rettype-mismatch.check
deleted file mode 100644
index f6e4bc09fd..0000000000
--- a/test/files/run/macro-rettype-mismatch.check
+++ /dev/null
@@ -1,5 +0,0 @@
-error: type mismatch;
- found : Int(2)
- required: String
-
-java.lang.Error: reflective compilation has failed
diff --git a/test/files/run/macro-rettype-mismatch.flags b/test/files/run/macro-rettype-mismatch.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-rettype-mismatch.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala
index 8c7254c79a..56e28b506c 100644
--- a/test/files/run/macro-settings/Impls_Macros_1.scala
+++ b/test/files/run/macro-settings/Impls_Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.makro.Context
object Impls {
def impl(c: Context) = c.reify {
- println(c.literal(c.settings.toString).eval)
+ println(c.literal(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 e8f6e1df85..994421808e 100644
--- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
@@ -2,16 +2,16 @@ import scala.reflect.makro.Context
object Macros {
def impl(c: Context) = {
- import c.mirror._
+ import c.universe._
- val inscope = c.inferImplicitValue(staticClass("SourceLocation").asType)
- val outer = Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null)))
+ val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").asType)
+ val outer = c.Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null)))
val Apply(fun, args) = c.enclosingImplicits(0)._2
val fileName = fun.pos.fileInfo.getName
val line = fun.pos.line
val charOffset = fun.pos.point
- c.reify { SourceLocation1(outer.eval, c.literal(fileName).eval, c.literal(line).eval, c.literal(charOffset).eval) }
+ c.reify { SourceLocation1(outer.splice, c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) }
}
implicit def sourceLocation: SourceLocation1 = macro impl
@@ -31,4 +31,4 @@ trait SourceLocation {
val charOffset: Int
}
-case class SourceLocation1(val outer: SourceLocation, val fileName: String, val line: Int, val charOffset: Int) extends SourceLocation
+case class SourceLocation1(val outer: SourceLocation, val fileName: String, val line: Int, val charOffset: Int) extends SourceLocation \ No newline at end of file
diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala
index 39b29ad64c..c006ceb691 100644
--- a/test/files/run/macro-sip19/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19/Impls_Macros_1.scala
@@ -2,12 +2,12 @@ import scala.reflect.makro.Context
object Macros {
def impl(c: Context) = {
- import c.mirror._
+ import c.universe._
val Apply(fun, args) = c.enclosingImplicits(0)._2
val fileName = fun.pos.fileInfo.getName
val line = fun.pos.line
val charOffset = fun.pos.point
- c.reify { SourceLocation(c.literal(fileName).eval, c.literal(line).eval, c.literal(charOffset).eval) }
+ c.reify { SourceLocation(c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) }
}
implicit def sourceLocation: SourceLocation = macro impl
@@ -22,4 +22,4 @@ case class SourceLocation(
/** The character offset */
val charOffset: Int
-)
+) \ No newline at end of file
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 4f0f76aed6..8ed435d629 100644
--- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.makro.Context
object Macros {
def impl_with_implicits_enabled(c: Context) = {
- import c.mirror._
+ import c.universe._
val tree1 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2))))
val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false)
@@ -12,7 +12,7 @@ object Macros {
def foo_with_implicits_enabled = macro impl_with_implicits_enabled
def impl_with_implicits_disabled(c: Context) = {
- import c.mirror._
+ import c.universe._
try {
val tree2 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2))))
diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check
index 3e1057520b..da1a28bc24 100644
--- a/test/files/run/macro-typecheck-macrosdisabled.check
+++ b/test/files/run/macro-typecheck-macrosdisabled.check
@@ -1,5 +1,37 @@
{
- val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
- $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2)), classOf[scala.Int]))
+ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
+ val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
+ $u.Expr.apply[Int(2)]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $treecreator1.this.applyImpl[$u.type]($m).asInstanceOf[U#Tree]
+ };
+ private def applyImpl[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): scala.reflect.base.Universe#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Literal.apply($u.Constant.apply(2))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Int(2)]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.ConstantType.apply($u.Constant.apply(2))
+ }
+ };
+ new $typecreator2()
+ }))
}
-mr.reify[Int](2)
+ru.reify[Int](2)
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 3de9367994..2c9bce92a5 100644
--- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.makro.Context
object Macros {
def impl_with_macros_enabled(c: Context) = {
- import c.mirror._
+ import c.universe._
- val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror"))
- val tree1 = Apply(Select(mr, newTermName("reify")), List(Literal(Constant(2))))
+ val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe"))
+ val tree1 = Apply(Select(ru, newTermName("reify")), List(Literal(Constant(2))))
val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
c.literal(ttree1.toString)
}
@@ -13,14 +13,14 @@ object Macros {
def foo_with_macros_enabled = macro impl_with_macros_enabled
def impl_with_macros_disabled(c: Context) = {
- import c.mirror._
+ import c.universe._
- val mrPkg = staticModule("scala.reflect.package")
- val mrSym = selectTerm(mrPkg, "mirror")
- val NullaryMethodType(mrTpe) = mrSym.typeSignature
- val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror)
+ val rupkg = c.mirror.staticModule("scala.reflect.runtime.package")
+ val rusym = build.selectTerm(rupkg, "universe")
+ val NullaryMethodType(rutpe) = rusym.typeSignature
+ val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe)
- val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2))))
+ val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2))))
val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true)
c.literal(ttree2.toString)
}
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check
index 02da6ad0c7..e440b2c0cb 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2.check
+++ b/test/files/run/macro-typecheck-macrosdisabled2.check
@@ -1,5 +1,37 @@
{
- val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
- $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
+ val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
+ $u.Expr.apply[Array[Int]]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $treecreator1.this.applyImpl[$u.type]($m).asInstanceOf[U#Tree]
+ };
+ private def applyImpl[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): scala.reflect.base.Universe#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticModule("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Array[Int]]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.TypeRef.apply($u.ThisType.apply($m.staticModule("scala").asModuleSymbol.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asTypeSymbol.asTypeConstructor))
+ }
+ };
+ new $typecreator2()
+ }))
}
-mr.reify[Array[Int]](scala.Array.apply(2))
+ru.reify[Array[Int]](scala.Array.apply(2))
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 1b840a6204..0aca9781f4 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.makro.Context
object Macros {
def impl_with_macros_enabled(c: Context) = {
- import c.mirror._
+ import c.universe._
- val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror"))
- val tree1 = Apply(Select(mr, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
+ val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe"))
+ val tree1 = Apply(Select(ru, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
c.literal(ttree1.toString)
}
@@ -13,17 +13,17 @@ object Macros {
def foo_with_macros_enabled = macro impl_with_macros_enabled
def impl_with_macros_disabled(c: Context) = {
- import c.mirror._
+ import c.universe._
- val mrPkg = staticModule("scala.reflect.package")
- val mrSym = selectTerm(mrPkg, "mirror")
- val NullaryMethodType(mrTpe) = mrSym.typeSignature
- val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror)
+ val rupkg = c.mirror.staticModule("scala.reflect.runtime.package")
+ val rusym = build.selectTerm(rupkg, "universe")
+ val NullaryMethodType(rutpe) = rusym.typeSignature
+ val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe)
- val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
+ val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true)
c.literal(ttree2.toString)
}
def foo_with_macros_disabled = macro impl_with_macros_disabled
-} \ No newline at end of file
+}
diff --git a/test/files/run/macro-undetparams-consfromsls.check b/test/files/run/macro-undetparams-consfromsls.check
index 49e9140d5a..4b83c55437 100644
--- a/test/files/run/macro-undetparams-consfromsls.check
+++ b/test/files/run/macro-undetparams-consfromsls.check
@@ -1,5 +1,5 @@
-A = ConcreteTypeTag[Int]
-B = ConcreteTypeTag[Nothing]
+A = TypeTag[Int]
+B = TypeTag[Nothing]
List(1)
-A = ConcreteTypeTag[Any]
+A = TypeTag[Any]
List(abc, 1)
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 c22ff96028..b9bb2cfcca 100644
--- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala
+++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala
@@ -1,13 +1,14 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.Context
object Macros {
- def cons_impl[A: c.TypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.reify {
- println("A = " + c.literal(implicitly[c.TypeTag[A]].toString).eval)
- x.eval :: xs.eval
+ def cons_impl[A: c.AbsTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.reify {
+ println("A = " + c.literal(implicitly[c.AbsTypeTag[A]].toString).splice)
+ x.splice :: xs.splice
}
- def nil_impl[B: c.TypeTag](c: Context): c.Expr[List[B]] = c.reify {
- println("B = " + c.literal(implicitly[c.TypeTag[B]].toString).eval)
+ def nil_impl[B: c.AbsTypeTag](c: Context): c.Expr[List[B]] = c.reify {
+ println("B = " + c.literal(implicitly[c.AbsTypeTag[B]].toString).splice)
Nil
}
diff --git a/test/files/run/macro-undetparams-implicitval.check b/test/files/run/macro-undetparams-implicitval.check
index 6c2b601aa5..30681fa40d 100644
--- a/test/files/run/macro-undetparams-implicitval.check
+++ b/test/files/run/macro-undetparams-implicitval.check
@@ -1 +1 @@
-ConcreteTypeTag[Nothing]
+TypeTag[Nothing]
diff --git a/test/files/run/macro-undetparams-implicitval/Test.scala b/test/files/run/macro-undetparams-implicitval/Test.scala
index 5278295451..72fd2f3d72 100644
--- a/test/files/run/macro-undetparams-implicitval/Test.scala
+++ b/test/files/run/macro-undetparams-implicitval/Test.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
def foo[T: TypeTag] = println(implicitly[TypeTag[T]])
foo
diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check
index e57fc1217b..80c6b826ba 100644
--- a/test/files/run/macro-undetparams-macroitself.check
+++ b/test/files/run/macro-undetparams-macroitself.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[String]
+TypeTag[Int]
+TypeTag[String]
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 9d65e8b0da..9b1dd8e017 100644
--- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala
+++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala
@@ -1,7 +1,8 @@
+import scala.reflect.runtime.universe._
import scala.reflect.makro.Context
object Macros {
- def impl[T: c.TypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.reify { println(c.literal(implicitly[c.TypeTag[T]].toString).eval) }
+ def impl[T: c.TypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.reify { println(c.literal(implicitly[c.TypeTag[T]].toString).splice) }
def foo[T](foo: T) = macro impl[T]
} \ No newline at end of file
diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala
index 4485ce9124..f1596dee81 100644
--- a/test/files/run/manifests-new.scala
+++ b/test/files/run/manifests-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test
{
object Variances extends Enumeration {
@@ -54,15 +56,15 @@ object Test
}
def assertAnyRef[T: TypeTag] = List(
- typeTag[T].tpe <:< typeTag[Any].tpe,
- typeTag[T].tpe <:< typeTag[AnyRef].tpe,
- !(typeTag[T].tpe <:< typeTag[AnyVal].tpe)
+ typeOf[T] <:< typeOf[Any],
+ typeOf[T] <:< typeOf[AnyRef],
+ !(typeOf[T] <:< typeOf[AnyVal])
) foreach (assert(_, "assertAnyRef"))
def assertAnyVal[T: TypeTag] = List(
- typeTag[T].tpe <:< typeTag[Any].tpe,
- !(typeTag[T].tpe <:< typeTag[AnyRef].tpe),
- typeTag[T].tpe <:< typeTag[AnyVal].tpe
+ typeOf[T] <:< typeOf[Any],
+ !(typeOf[T] <:< typeOf[AnyRef]),
+ typeOf[T] <:< typeOf[AnyVal]
) foreach (assert(_, "assertAnyVal"))
def assertSameType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SAME, "assertSameType")
@@ -144,4 +146,4 @@ object Test
}
def main(args: Array[String]): Unit = runAllTests
-}
+} \ No newline at end of file
diff --git a/test/files/run/misc-msil.check b/test/files/run/misc-msil.check
deleted file mode 100644
index 480a840b9a..0000000000
--- a/test/files/run/misc-msil.check
+++ /dev/null
@@ -1,33 +0,0 @@
-### Hello
-### 17
-### Bye
-
-### fib(0) = 1
-### fib(1) = 1
-### fib(2) = 2
-### fib(3) = 3
-### fib(4) = 5
-=== MyClass::toString ===
-=== MySubclass::toString ===
-=== MyClass::test ===
-
-identity
-
-A.a = 1
-B.a = 5
-B.b = 2
-
-X.a = 4
-Y.a = 11
-Y.b = 5
-Y.b = 5
-
-X::foo
-
-Y::foo
-X::foo
-
-3
-3
-
-True
diff --git a/test/files/run/newTags.check b/test/files/run/newTags.check
new file mode 100644
index 0000000000..d83740c40c
--- /dev/null
+++ b/test/files/run/newTags.check
@@ -0,0 +1,5 @@
+TypeRef(ThisType(class immutable),class List,List(TypeRef(ThisType(class scala),class Int,List())))
+List[Int]
+TypeRef(ThisType(class immutable),class Map,List(TypeRef(ThisType(class lang),class String,List()), TypeRef(ThisType(class lang),class String,List())))
+scala.collection.immutable.Map[java.lang.String,java.lang.String]
+TypeTag[TypeRef(ThisType(class immutable),class Map,List(TypeRef(ThisType(class lang),class String,List()), TypeRef(ThisType(class lang),class String,List())))]
diff --git a/test/files/run/newTags.scala b/test/files/run/newTags.scala
new file mode 100644
index 0000000000..a758599515
--- /dev/null
+++ b/test/files/run/newTags.scala
@@ -0,0 +1,14 @@
+import scala.reflect.base.{Universe => BaseUniverse}
+import scala.reflect.{basis => rb}
+import scala.reflect.runtime.{universe => ru}
+
+object Test extends App {
+ println(rb.typeOf[List[Int]])
+ println(ru.typeOf[List[Int]])
+ def foo[T: rb.TypeTag] = {
+ println(rb.typeOf[T])
+ println(ru.typeOf[T])
+ println(implicitly[BaseUniverse#TypeTag[T]])
+ }
+ foo[Map[String, String]]
+} \ No newline at end of file
diff --git a/test/files/run/patmat_unapp_abstype-new.scala b/test/files/run/patmat_unapp_abstype-new.scala
index 45496f08a2..1141177504 100644
--- a/test/files/run/patmat_unapp_abstype-new.scala
+++ b/test/files/run/patmat_unapp_abstype-new.scala
@@ -1,10 +1,10 @@
+import reflect.{ClassTag, classTag}
+
// abstract types and extractors, oh my!
trait TypesAPI {
trait Type
- // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test)
- // that's what typeRefMani is for
- type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef]
+ type TypeRef <: Type
val TypeRef: TypeRefExtractor; trait TypeRefExtractor {
def apply(x: Int): TypeRef
def unapply(x: TypeRef): Option[(Int)]
@@ -19,11 +19,6 @@ trait TypesUser extends TypesAPI {
def shouldNotCrash(tp: Type): Unit = {
tp match {
case TypeRef(x) => println("TypeRef")
- // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type]
- // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type])
- // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass)
- // this is equivalent to manifest
- // it is NOT equivalent to manifest[Type] <:< typeRefMani
case MethodType(x) => println("MethodType")
case _ => println("none of the above")
}
@@ -34,7 +29,6 @@ trait TypesImpl extends TypesAPI {
object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef])
case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef
// --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser
- //lazy val typeRefMani = manifest[TypeRef]
}
trait Foos {
@@ -63,16 +57,15 @@ trait Intermed extends Foos {
object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser {
def test() = {
- shouldNotCrash(TypeRef(10)) // should and does print "TypeRef"
- // once #1697/#2337 are fixed, this should generate the correct output
- shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher!
+ shouldNotCrash(TypeRef(10)) // prints "TypeRef"
+ shouldNotCrash(MethodType(10)) // prints "MethodType"
}
}
object TestUnappDynamicSynth extends RealFoos with Intermed {
- case class FooToo(n: Int) extends Bar
+ case class NotAFoo(n: Int) extends Bar
def test() = {
- crash(FooToo(10))
+ crash(NotAFoo(10))
crash(new Foo(5))
}
}
diff --git a/test/files/run/primitive-sigs-2-new.check b/test/files/run/primitive-sigs-2-new.check
index b82ddbeaff..6f79d73d38 100644
--- a/test/files/run/primitive-sigs-2-new.check
+++ b/test/files/run/primitive-sigs-2-new.check
@@ -1,7 +1,7 @@
T<java.lang.Object>
List(A, char, class java.lang.Object)
a
-public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.ArrayTag<T>)
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.ClassTag<T>)
public float[] Arr.arr3(float[][])
public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/primitive-sigs-2-new.scala b/test/files/run/primitive-sigs-2-new.scala
index 7e13014cb2..cf6de9c81b 100644
--- a/test/files/run/primitive-sigs-2-new.scala
+++ b/test/files/run/primitive-sigs-2-new.scala
@@ -1,3 +1,4 @@
+import scala.reflect.{ClassTag, classTag}
import java.{ lang => jl }
trait T[A] {
@@ -10,7 +11,7 @@ class Arr {
def arr1(xs: Array[Int]): List[Int] = xs.toList
def arr2(xs: Array[jl.Character]): List[jl.Character] = xs.toList
def arr3(xss: Array[Array[Float]]): Array[Float] = xss map (_.sum)
- def arr4[T: ArrayTag](xss: Array[Array[T]]): Array[T] = xss map (_.head)
+ def arr4[T: ClassTag](xss: Array[Array[T]]): Array[T] = xss map (_.head)
}
object Test {
@@ -28,4 +29,4 @@ object Test {
println(new C f)
c3m.sorted foreach println
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/promotion-msil.check b/test/files/run/promotion-msil.check
deleted file mode 100644
index 41e36c369d..0000000000
--- a/test/files/run/promotion-msil.check
+++ /dev/null
@@ -1,4 +0,0 @@
-2
-6
-20
-30
diff --git a/test/files/run/reflect-overload.scala b/test/files/run/reflect-overload.scala
index af82a1948d..870a200813 100644
--- a/test/files/run/reflect-overload.scala
+++ b/test/files/run/reflect-overload.scala
@@ -1,16 +1,19 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
object Test extends App {
- import reflect.mirror._
val s = "hello world"
- val sc = symbolOfInstance(s)
+ val m = cm.reflect(s)
+ val sc = m.symbol
val st = sc.asType
- val m = st member newTermName("indexOf")
+ val meth = (st member newTermName("indexOf")).asTermSymbol
val IntType = definitions.IntClass.asType
- val indexOf = m resolveOverloaded(actuals = List(IntType))
- assert(invoke(s, indexOf)('w') == 6)
- assert((invoke(s, indexOf)('w') match { case x: Int => x }) == 6)
+ val indexOf = (meth resolveOverloaded(actuals = List(IntType))).asMethodSymbol
+ assert(m.reflectMethod(indexOf)('w') == 6)
+ assert((m.reflectMethod(indexOf)('w') match { case x: Int => x }) == 6)
- val m2 = st member newTermName("substring")
- val substring = m2 resolveOverloaded(actuals = List(IntType, IntType))
- assert(invoke(s, substring)(2, 6) == "llo ")
+ val meth2 = (st member newTermName("substring")).asTermSymbol
+ val substring = (meth2 resolveOverloaded(actuals = List(IntType, IntType))).asMethodSymbol
+ assert(m.reflectMethod(substring)(2, 6) == "llo ")
}
diff --git a/test/files/run/reflection-constructormirror-inner-badpath.check b/test/files/run/reflection-constructormirror-inner-badpath.check
new file mode 100644
index 0000000000..28b936eca1
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-inner-badpath.check
@@ -0,0 +1,2 @@
+this is an inner class, use reflectClass on an InstanceMirror to obtain its ClassMirror
+()
diff --git a/test/files/run/reflection-constructormirror-inner-badpath.scala b/test/files/run/reflection-constructormirror-inner-badpath.scala
new file mode 100644
index 0000000000..a42bedea83
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-inner-badpath.scala
@@ -0,0 +1,32 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+class Foo{
+ case class R(
+ sales : Int,
+ name : String
+ )
+
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ try {
+ val cls = cm.reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+
+}
+object Test extends App{
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-constructormirror-inner-good.check b/test/files/run/reflection-constructormirror-inner-good.check
new file mode 100644
index 0000000000..811ecb2e3f
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-inner-good.check
@@ -0,0 +1 @@
+R(5,test)
diff --git a/test/files/run/reflection-constructormirror-inner-good.scala b/test/files/run/reflection-constructormirror-inner-good.scala
new file mode 100644
index 0000000000..c09f464b24
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-inner-good.scala
@@ -0,0 +1,26 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+class Foo{
+ case class R(
+ sales : Int,
+ name : String
+ )
+
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ val cls = cm.reflect( this ).reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ }
+
+}
+object Test extends App{
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-constructormirror-nested-badpath.check b/test/files/run/reflection-constructormirror-nested-badpath.check
new file mode 100644
index 0000000000..9ceb603dc2
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-nested-badpath.check
@@ -0,0 +1,2 @@
+this is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror
+()
diff --git a/test/files/run/reflection-constructormirror-nested-badpath.scala b/test/files/run/reflection-constructormirror-nested-badpath.scala
new file mode 100644
index 0000000000..ece0044c61
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-nested-badpath.scala
@@ -0,0 +1,32 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+class Foo{
+ import Test._
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ try {
+ val cls = cm.reflect( this ).reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+
+}
+object Test extends App{
+ case class R(
+ sales : Int,
+ name : String
+ )
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-constructormirror-nested-good.check b/test/files/run/reflection-constructormirror-nested-good.check
new file mode 100644
index 0000000000..811ecb2e3f
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-nested-good.check
@@ -0,0 +1 @@
+R(5,test)
diff --git a/test/files/run/reflection-constructormirror-nested-good.scala b/test/files/run/reflection-constructormirror-nested-good.scala
new file mode 100644
index 0000000000..432e9d3707
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-nested-good.scala
@@ -0,0 +1,26 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+class Foo{
+ import Test._
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ val cls = cm.reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ }
+}
+
+object Test extends App{
+ case class R(
+ sales : Int,
+ name : String
+ )
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-constructormirror-toplevel-badpath.check b/test/files/run/reflection-constructormirror-toplevel-badpath.check
new file mode 100644
index 0000000000..9ceb603dc2
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-toplevel-badpath.check
@@ -0,0 +1,2 @@
+this is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror
+()
diff --git a/test/files/run/reflection-constructormirror-toplevel-badpath.scala b/test/files/run/reflection-constructormirror-toplevel-badpath.scala
new file mode 100644
index 0000000000..7a7adbd603
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-toplevel-badpath.scala
@@ -0,0 +1,33 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+case class R(
+ sales : Int,
+ name : String
+)
+
+class Foo{
+ import Test._
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ try {
+ val cls = cm.reflect( this ).reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-constructormirror-toplevel-good.check b/test/files/run/reflection-constructormirror-toplevel-good.check
new file mode 100644
index 0000000000..811ecb2e3f
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-toplevel-good.check
@@ -0,0 +1 @@
+R(5,test)
diff --git a/test/files/run/reflection-constructormirror-toplevel-good.scala b/test/files/run/reflection-constructormirror-toplevel-good.scala
new file mode 100644
index 0000000000..96713a11cb
--- /dev/null
+++ b/test/files/run/reflection-constructormirror-toplevel-good.scala
@@ -0,0 +1,27 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.ClassTag
+
+case class R(
+ sales : Int,
+ name : String
+)
+
+class Foo{
+ import Test._
+ def foo = {
+ val expectedType = implicitly[TypeTag[R]]
+ val classTag = implicitly[ClassTag[R]]
+ val cl = classTag.runtimeClass.getClassLoader
+ val cm = runtimeMirror(cl)
+ val constructor = expectedType.tpe.member( nme.CONSTRUCTOR ).asMethodSymbol
+ val sig = constructor.typeSignature
+ val sym = cm.classSymbol( classTag.runtimeClass )
+ val cls = cm.reflectClass( sym )
+ cls.reflectConstructor( constructor )( 5,"test" ).asInstanceOf[R]
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println( foo.foo )
+} \ No newline at end of file
diff --git a/test/files/run/reflection-fieldmirror-ctorparam.check b/test/files/run/reflection-fieldmirror-ctorparam.check
new file mode 100644
index 0000000000..8b99a6f772
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-ctorparam.check
@@ -0,0 +1 @@
+class java.lang.NoSuchFieldException: Test$A$$x
diff --git a/test/files/run/reflection-fieldmirror-ctorparam.scala b/test/files/run/reflection-fieldmirror-ctorparam.scala
new file mode 100644
index 0000000000..fa9dd81d7f
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-ctorparam.scala
@@ -0,0 +1,21 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A(x: Int) {
+ private[this] var xx = x
+ }
+
+ val a = new A(42)
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ val f = cs.typeSignature.declaration(newTermName("x")).asTermSymbol
+ try {
+ val fm: FieldMirror = im.reflectField(f)
+ println(fm.get)
+ } catch {
+ case ex: Throwable =>
+ println(s"${ex.getClass}: ${ex.getMessage}")
+ }
+}
diff --git a/test/files/run/reflection-fieldmirror-getsetval.check b/test/files/run/reflection-fieldmirror-getsetval.check
new file mode 100644
index 0000000000..707bbcccce
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-getsetval.check
@@ -0,0 +1,2 @@
+42
+cannot set an immutable field
diff --git a/test/files/run/reflection-fieldmirror-getsetval.scala b/test/files/run/reflection-fieldmirror-getsetval.scala
new file mode 100644
index 0000000000..af9a6e4c56
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-getsetval.scala
@@ -0,0 +1,24 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A {
+ val x: Int = 42
+ }
+
+ val a = new A
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTermSymbol
+ val fm: FieldMirror = im.reflectField(f)
+ try {
+ println(fm.get)
+ fm.set(2)
+ println(fm.get)
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+}
diff --git a/test/files/run/reflection-fieldmirror-getsetvar.check b/test/files/run/reflection-fieldmirror-getsetvar.check
new file mode 100644
index 0000000000..a9b0ccc6a0
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-getsetvar.check
@@ -0,0 +1,2 @@
+42
+2
diff --git a/test/files/run/reflection-fieldmirror-getsetvar.scala b/test/files/run/reflection-fieldmirror-getsetvar.scala
new file mode 100644
index 0000000000..d9fbdaade0
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-getsetvar.scala
@@ -0,0 +1,18 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A {
+ var x: Int = 42
+ }
+
+ val a = new A
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTermSymbol
+ val fm: FieldMirror = im.reflectField(f)
+ println(fm.get)
+ fm.set(2)
+ println(fm.get)
+}
diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.check b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.check
new file mode 100644
index 0000000000..fe75c80bca
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.check
@@ -0,0 +1 @@
+true
diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala
new file mode 100644
index 0000000000..d89e6a90ef
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala
@@ -0,0 +1,16 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A {
+ var x: Int = 42
+ }
+
+ val a = new A
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTermSymbol
+ val fm: FieldMirror = im.reflectField(f)
+ println(fm.symbol.isVariable)
+}
diff --git a/test/files/run/reflection-fieldmirror-privatethis.check b/test/files/run/reflection-fieldmirror-privatethis.check
new file mode 100644
index 0000000000..889b7c2c34
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-privatethis.check
@@ -0,0 +1,3 @@
+true
+42
+2
diff --git a/test/files/run/reflection-fieldmirror-privatethis.scala b/test/files/run/reflection-fieldmirror-privatethis.scala
new file mode 100644
index 0000000000..0c415e09e4
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-privatethis.scala
@@ -0,0 +1,19 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A {
+ private[this] var x: Int = 42
+ }
+
+ val a = new A
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ val f = cs.typeSignature.declaration(newTermName("x")).asTermSymbol
+ val fm: FieldMirror = im.reflectField(f)
+ println(fm.symbol.isVariable)
+ println(fm.get)
+ fm.set(2)
+ println(fm.get)
+}
diff --git a/test/files/run/reflection-fieldmirror-sanitycheck.check b/test/files/run/reflection-fieldmirror-sanitycheck.check
new file mode 100644
index 0000000000..e5134de4e3
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-sanitycheck.check
@@ -0,0 +1,6 @@
+expected a field symbol, you provided a method symbol
+A typical cause of this problem is using a field accessor symbol instead of a field symbol.
+To obtain a field symbol append nme.LOCAL_SUFFIX_STRING to the name of the field,
+when searching for a member with Type.members or Type.declarations.
+This is a temporary inconvenience that will be resolved before 2.10.0-final.
+More information can be found here: https://issues.scala-lang.org/browse/SI-5895.
diff --git a/test/files/run/reflection-fieldmirror-sanitycheck.scala b/test/files/run/reflection-fieldmirror-sanitycheck.scala
new file mode 100644
index 0000000000..6a992dd282
--- /dev/null
+++ b/test/files/run/reflection-fieldmirror-sanitycheck.scala
@@ -0,0 +1,22 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ class A {
+ var x: Int = 42
+ }
+
+ val a = new A
+
+ val im: InstanceMirror = cm.reflect(a)
+ val cs = im.symbol
+ //val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTermSymbol
+ val f = cs.typeSignature.declaration(newTermName("x")).asTermSymbol
+ try {
+ val fm: FieldMirror = im.reflectField(f)
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+}
diff --git a/test/files/run/reflection-implClass-new.scala b/test/files/run/reflection-implClass-new.scala
deleted file mode 100644
index 27374f2106..0000000000
--- a/test/files/run/reflection-implClass-new.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Tries to load a symbol for the `Foo$class` using Scala reflection.
- * Since trait implementation classes do not get pickling information
- * symbol for them should be created using fallback mechanism
- * that exposes Java reflection information dressed up in
- * a Scala symbol.
- */
-object Test extends App with Outer {
- import scala.reflect.mirror
-
- assert(mirror.classToSymbol(classTag[Foo].erasure).typeSignature.declaration(mirror.newTermName("bar")).typeSignature ==
- mirror.classToSymbol(classTag[Bar].erasure).typeSignature.declaration(mirror.newTermName("foo")).typeSignature)
-
- val s1 = implClass(classTag[Foo].erasure)
- assert(s1 != mirror.NoSymbol)
- assert(s1.typeSignature != mirror.NoType)
- assert(s1.companionSymbol.typeSignature != mirror.NoType)
- assert(s1.companionSymbol.typeSignature.declaration(mirror.newTermName("bar")) != mirror.NoSymbol)
- val s2 = implClass(classTag[Bar].erasure)
- assert(s2 != mirror.NoSymbol)
- assert(s2.typeSignature != mirror.NoType)
- assert(s2.companionSymbol.typeSignature != mirror.NoType)
- assert(s2.companionSymbol.typeSignature.declaration(mirror.newTermName("foo")) != mirror.NoSymbol)
- def implClass(clazz: Class[_]) = {
- val implClass = Class.forName(clazz.getName + "$class")
- mirror.classToSymbol(implClass)
- }
-}
-
-trait Foo {
- def bar = 1
-}
-
-trait Outer {
- trait Bar {
- def foo = 1
- }
-}
diff --git a/test/files/run/reflection-implClass-old.scala b/test/files/run/reflection-implClass-old.scala
deleted file mode 100644
index 6583624d8b..0000000000
--- a/test/files/run/reflection-implClass-old.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Tries to load a symbol for the `Foo$class` using Scala reflection.
- * Since trait implementation classes do not get pickling information
- * symbol for them should be created using fallback mechanism
- * that exposes Java reflection information dressed up in
- * a Scala symbol.
- */
-object Test extends App with Outer {
- import scala.reflect.mirror
-
- assert(mirror.classToSymbol(manifest[Foo].erasure).typeSignature.declaration(mirror.newTermName("bar")).typeSignature ==
- mirror.classToSymbol(manifest[Bar].erasure).typeSignature.declaration(mirror.newTermName("foo")).typeSignature)
-
- val s1 = implClass(manifest[Foo].erasure)
- assert(s1 != mirror.NoSymbol)
- assert(s1.typeSignature != mirror.NoType)
- assert(s1.companionSymbol.typeSignature != mirror.NoType)
- assert(s1.companionSymbol.typeSignature.declaration(mirror.newTermName("bar")) != mirror.NoSymbol)
- val s2 = implClass(manifest[Bar].erasure)
- assert(s2 != mirror.NoSymbol)
- assert(s2.typeSignature != mirror.NoType)
- assert(s2.companionSymbol.typeSignature != mirror.NoType)
- assert(s2.companionSymbol.typeSignature.declaration(mirror.newTermName("foo")) != mirror.NoSymbol)
- def implClass(clazz: Class[_]) = {
- val implClass = Class.forName(clazz.getName + "$class")
- mirror.classToSymbol(implClass)
- }
-}
-
-trait Foo {
- def bar = 1
-}
-
-trait Outer {
- trait Bar {
- def foo = 1
- }
-}
diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass.scala
new file mode 100644
index 0000000000..b3c0081ccf
--- /dev/null
+++ b/test/files/run/reflection-implClass.scala
@@ -0,0 +1,40 @@
+/**
+ * Tries to load a symbol for the `Foo$class` using Scala reflection.
+ * Since trait implementation classes do not get pickling information
+ * symbol for them should be created using fallback mechanism
+ * that exposes Java reflection information dressed up in
+ * a Scala symbol.
+ */
+object Test extends App with Outer {
+ import scala.reflect.{ClassTag, classTag}
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+
+ assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(newTermName("bar")).typeSignature ==
+ cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(newTermName("foo")).typeSignature)
+
+ val s1 = implClass(classTag[Foo].runtimeClass)
+ assert(s1 != NoSymbol)
+ assert(s1.typeSignature != NoType)
+ assert(s1.companionSymbol.typeSignature != NoType)
+ assert(s1.companionSymbol.typeSignature.declaration(newTermName("bar")) != NoSymbol)
+ val s2 = implClass(classTag[Bar].runtimeClass)
+ assert(s2 != NoSymbol)
+ assert(s2.typeSignature != NoType)
+ assert(s2.companionSymbol.typeSignature != NoType)
+ assert(s2.companionSymbol.typeSignature.declaration(newTermName("foo")) != NoSymbol)
+ def implClass(clazz: Class[_]) = {
+ val implClass = Class.forName(clazz.getName + "$class")
+ cm.classSymbol(implClass)
+ }
+}
+
+trait Foo {
+ def bar = 1
+}
+
+trait Outer {
+ trait Bar {
+ def foo = 1
+ }
+}
diff --git a/test/files/run/reflection-modulemirror-inner-badpath.check b/test/files/run/reflection-modulemirror-inner-badpath.check
new file mode 100644
index 0000000000..d3fe43336e
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-inner-badpath.check
@@ -0,0 +1,2 @@
+this is an inner module, use reflectModule on an InstanceMirror to obtain its ModuleMirror
+()
diff --git a/test/files/run/reflection-modulemirror-inner-badpath.scala b/test/files/run/reflection-modulemirror-inner-badpath.scala
new file mode 100644
index 0000000000..de200c548b
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-inner-badpath.scala
@@ -0,0 +1,24 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+class Foo{
+ object R { override def toString = "R" }
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ try {
+ val cls = cm.reflectModule(sym)
+ cls.instance
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println(foo.foo)
+} \ No newline at end of file
diff --git a/test/files/run/reflection-modulemirror-inner-good.check b/test/files/run/reflection-modulemirror-inner-good.check
new file mode 100644
index 0000000000..0bf38a73d1
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-inner-good.check
@@ -0,0 +1,2 @@
+inner and nested modules are not supported yet
+()
diff --git a/test/files/run/reflection-modulemirror-inner-good.scala b/test/files/run/reflection-modulemirror-inner-good.scala
new file mode 100644
index 0000000000..b5540dbe1c
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-inner-good.scala
@@ -0,0 +1,23 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+class Foo{
+ object R { override def toString = "R" }
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ val cls = cm.reflect(this).reflectModule(sym)
+ try {
+ cls.instance
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println(foo.foo)
+} \ No newline at end of file
diff --git a/test/files/run/reflection-modulemirror-nested-badpath.check b/test/files/run/reflection-modulemirror-nested-badpath.check
new file mode 100644
index 0000000000..16a5b10390
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-nested-badpath.check
@@ -0,0 +1,2 @@
+this is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror
+()
diff --git a/test/files/run/reflection-modulemirror-nested-badpath.scala b/test/files/run/reflection-modulemirror-nested-badpath.scala
new file mode 100644
index 0000000000..43cae00f9c
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-nested-badpath.scala
@@ -0,0 +1,26 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+class Foo{
+ import Test._
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ try {
+ val cls = cm.reflect(this).reflectModule(sym)
+ cls.instance
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+
+}
+
+object Test extends App{
+ object R { override def toString = "R" }
+ val foo = new Foo
+ println(foo.foo)
+}
diff --git a/test/files/run/reflection-modulemirror-nested-good.check b/test/files/run/reflection-modulemirror-nested-good.check
new file mode 100644
index 0000000000..0bf38a73d1
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-nested-good.check
@@ -0,0 +1,2 @@
+inner and nested modules are not supported yet
+()
diff --git a/test/files/run/reflection-modulemirror-nested-good.scala b/test/files/run/reflection-modulemirror-nested-good.scala
new file mode 100644
index 0000000000..8390bbaac7
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-nested-good.scala
@@ -0,0 +1,24 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+class Foo{
+ import Test._
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ val cls = cm.reflectModule(sym)
+ try {
+ cls.instance
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+}
+
+object Test extends App{
+ object R { override def toString = "R" }
+ val foo = new Foo
+ println(foo.foo)
+} \ No newline at end of file
diff --git a/test/files/run/reflection-modulemirror-toplevel-badpath.check b/test/files/run/reflection-modulemirror-toplevel-badpath.check
new file mode 100644
index 0000000000..16a5b10390
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-toplevel-badpath.check
@@ -0,0 +1,2 @@
+this is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror
+()
diff --git a/test/files/run/reflection-modulemirror-toplevel-badpath.scala b/test/files/run/reflection-modulemirror-toplevel-badpath.scala
new file mode 100644
index 0000000000..8b2994cabb
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-toplevel-badpath.scala
@@ -0,0 +1,26 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+object R { override def toString = "R" }
+
+class Foo{
+ import Test._
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ try {
+ val cls = cm.reflect(this).reflectModule(sym)
+ cls.instance
+ println("this indicates a failure")
+ } catch {
+ case ex: Throwable =>
+ println(ex.getMessage)
+ }
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println(foo.foo)
+} \ No newline at end of file
diff --git a/test/files/run/reflection-modulemirror-toplevel-good.check b/test/files/run/reflection-modulemirror-toplevel-good.check
new file mode 100644
index 0000000000..ac044e5e46
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-toplevel-good.check
@@ -0,0 +1 @@
+R \ No newline at end of file
diff --git a/test/files/run/reflection-modulemirror-toplevel-good.scala b/test/files/run/reflection-modulemirror-toplevel-good.scala
new file mode 100644
index 0000000000..0663136a22
--- /dev/null
+++ b/test/files/run/reflection-modulemirror-toplevel-good.scala
@@ -0,0 +1,20 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.ClassTag
+
+object R { override def toString = "R" }
+
+class Foo{
+ import Test._
+ def foo = {
+ val classTag = implicitly[ClassTag[R.type]]
+ val sym = cm.moduleSymbol(classTag.runtimeClass)
+ val cls = cm.reflectModule(sym)
+ cls.instance
+ }
+}
+
+object Test extends App{
+ val foo = new Foo
+ println(foo.foo)
+} \ No newline at end of file
diff --git a/test/files/run/reflection-repl.check b/test/files/run/reflection-repl.check
new file mode 100644
index 0000000000..e93fb6d6e7
--- /dev/null
+++ b/test/files/run/reflection-repl.check
@@ -0,0 +1,9 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> scala.reflect.runtime.universe.typeOf[List[Nothing]]
+res0: reflect.runtime.universe.Type = List[Nothing]
+
+scala>
diff --git a/test/files/run/reflection-repl.scala b/test/files/run/reflection-repl.scala
new file mode 100644
index 0000000000..72b65a1a70
--- /dev/null
+++ b/test/files/run/reflection-repl.scala
@@ -0,0 +1,7 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+ |scala.reflect.runtime.universe.typeOf[List[Nothing]]
+ |""".stripMargin
+}
diff --git a/test/files/run/reflection-simple.scala b/test/files/run/reflection-simple.scala
index fb3feec3cb..ec34b71cec 100644
--- a/test/files/run/reflection-simple.scala
+++ b/test/files/run/reflection-simple.scala
@@ -5,7 +5,8 @@ object Test {
def main(args: Array[String]) {
System.out.println("Running")
case class Foo(a: Int, b: Int, c: Int)
- val props = reflect.mirror.classToType(classOf[Foo]).members.filter(_.isTerm).map(_.toString)
+ import scala.reflect.runtime.{currentMirror => cm}
+ val props = cm.classSymbol(classOf[Foo]).typeSignature.members.filter(_.isTerm).map(_.toString)
props.toList.sorted foreach System.out.println
}
}
diff --git a/test/files/run/reflinit.check b/test/files/run/reflinit.check
new file mode 100644
index 0000000000..a9df3544ac
--- /dev/null
+++ b/test/files/run/reflinit.check
@@ -0,0 +1 @@
+List[Int]
diff --git a/test/files/run/reflinit.scala b/test/files/run/reflinit.scala
new file mode 100644
index 0000000000..6d3ba3a4df
--- /dev/null
+++ b/test/files/run/reflinit.scala
@@ -0,0 +1,6 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ val tt2 = typeOf[List[Int]]
+ println(tt2)
+} \ No newline at end of file
diff --git a/test/files/run/reify-repl-fail-gracefully.check b/test/files/run/reify-repl-fail-gracefully.check
index 680db12667..5a97983e54 100644
--- a/test/files/run/reify-repl-fail-gracefully.check
+++ b/test/files/run/reify-repl-fail-gracefully.check
@@ -1,21 +1,21 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import language.experimental.macros
-import language.experimental.macros
-
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
-
-scala>
-
-scala> reify
-<console>:12: error: macros cannot be partially applied
- reify
- ^
-
-scala>
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import language.experimental.macros
+import language.experimental.macros
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala>
+
+scala> reify
+<console>:12: error: macros cannot be partially applied
+ reify
+ ^
+
+scala>
+
+scala>
diff --git a/test/files/run/reify-repl-fail-gracefully.scala b/test/files/run/reify-repl-fail-gracefully.scala
index d7a06e8da8..ed6d6cb6c9 100644
--- a/test/files/run/reify-repl-fail-gracefully.scala
+++ b/test/files/run/reify-repl-fail-gracefully.scala
@@ -3,7 +3,7 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
|import language.experimental.macros
- |import scala.reflect.mirror._
+ |import scala.reflect.runtime.universe._
|
|reify
""".stripMargin
diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check
index a3944ae1ee..9df18b2362 100644
--- a/test/files/run/reify_ann1a.check
+++ b/test/files/run/reify_ann1a.check
@@ -14,15 +14,15 @@
()
}
{
- @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends Object {
- @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
- def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
+ @ann(immutable.this.List.apply[java.lang.String]("1a")) @ann(immutable.this.List.apply[java.lang.String]("1b")) class C[@ann(immutable.this.List.apply[java.lang.String]("2a")) @ann(immutable.this.List.apply[java.lang.String]("2b")) T] extends Object {
+ @ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a"))): C[T] = {
C.super.<init>();
()
};
- @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
- @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
- val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
+ @ann(immutable.this.List.apply[java.lang.String]("5a")) @ann(immutable.this.List.apply[java.lang.String]("5b")) def f(x: Int @ann(immutable.this.List.apply[java.lang.String]("6b")) @ann(immutable.this.List.apply[java.lang.String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[java.lang.String]("7a")) @ann(immutable.this.List.apply[java.lang.String]("7b")) val r: Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[java.lang.String]("8a"))): Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")) = (4: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")));
r.+(s)
}
};
diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala
index 6c062ca2c2..9f994fb2eb 100644
--- a/test/files/run/reify_ann1a.scala
+++ b/test/files/run/reify_ann1a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
class ann(bar: List[String]) extends annotation.StaticAnnotation
@@ -16,7 +19,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala
index 4faddef72c..3e0d3e0802 100644
--- a/test/files/run/reify_ann1b.scala
+++ b/test/files/run/reify_ann1b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
class ann(bar: String) extends annotation.ClassfileAnnotation
@@ -16,7 +19,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check
index 5022c50ca8..bb30441f8c 100644
--- a/test/files/run/reify_ann2a.check
+++ b/test/files/run/reify_ann2a.check
@@ -22,21 +22,21 @@
}
{
class ann extends scala.annotation.Annotation with scala.annotation.StaticAnnotation {
- <paramaccessor> private[this] val bar: List[String] = _;
- def <init>(bar: List[String]): ann = {
+ <paramaccessor> private[this] val bar: List[java.lang.String] = _;
+ def <init>(bar: List[java.lang.String]): ann = {
ann.super.<init>();
()
}
};
- @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends Object {
- @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
- def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
+ @ann(immutable.this.List.apply[java.lang.String]("1a")) @ann(immutable.this.List.apply[java.lang.String]("1b")) class C[@ann(immutable.this.List.apply[java.lang.String]("2a")) @ann(immutable.this.List.apply[java.lang.String]("2b")) T] extends Object {
+ @ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[java.lang.String]("3a")) @ann(immutable.this.List.apply[java.lang.String]("3b")) x: T @ann(immutable.this.List.apply[java.lang.String]("4b")) @ann(immutable.this.List.apply[java.lang.String]("4a"))): C[T] = {
C.super.<init>();
()
};
- @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
- @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
- val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
+ @ann(immutable.this.List.apply[java.lang.String]("5a")) @ann(immutable.this.List.apply[java.lang.String]("5b")) def f(x: Int @ann(immutable.this.List.apply[java.lang.String]("6b")) @ann(immutable.this.List.apply[java.lang.String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[java.lang.String]("7a")) @ann(immutable.this.List.apply[java.lang.String]("7b")) val r: Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[java.lang.String]("8a"))): Int @ann(immutable.this.List.apply[java.lang.String]("8b")) @ann(immutable.this.List.apply[java.lang.String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")) = (4: Int @ann(immutable.this.List.apply[java.lang.String]("9b")) @ann(immutable.this.List.apply[java.lang.String]("9a")));
r.+(s)
}
};
diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala
index a1723c221d..63a17ee192 100644
--- a/test/files/run/reify_ann2a.scala
+++ b/test/files/run/reify_ann2a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
// test 1: reify
@@ -16,7 +19,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala
index d65e641619..dbb6a1b443 100644
--- a/test/files/run/reify_ann3.scala
+++ b/test/files/run/reify_ann3.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
import scala.annotation._
import scala.annotation.meta._
@@ -10,10 +13,10 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
// test 3: import and compile
toolbox.runExpr(tree)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala
index 5655812689..b4845d1586 100644
--- a/test/files/run/reify_ann4.scala
+++ b/test/files/run/reify_ann4.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
import scala.annotation._
import scala.annotation.meta._
@@ -14,10 +17,10 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
// test 3: import and compile
toolbox.runExpr(tree)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala
index aecc61de46..0ae8d317ce 100644
--- a/test/files/run/reify_ann5.scala
+++ b/test/files/run/reify_ann5.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
import scala.annotation._
import scala.annotation.meta._
import scala.beans._
@@ -11,10 +14,10 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
// test 3: import and compile
toolbox.runExpr(tree)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_anonymous.scala b/test/files/run/reify_anonymous.scala
index cd740f0190..d743014dfd 100644
--- a/test/files/run/reify_anonymous.scala
+++ b/test/files/run/reify_anonymous.scala
@@ -1,7 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
println(new {def x = 2; def y = x * x}.y)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala
index 9aec69b4a3..0abb7b8154 100644
--- a/test/files/run/reify_classfileann_a.scala
+++ b/test/files/run/reify_classfileann_a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation
@@ -10,7 +13,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala
index a37f20e72e..5ceb652a8b 100644
--- a/test/files/run/reify_classfileann_b.scala
+++ b/test/files/run/reify_classfileann_b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation
@@ -14,7 +17,7 @@ object Test extends App {
println(tree.toString)
// test 2: import and typecheck
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
println(ttree.toString)
diff --git a/test/files/run/reify_closure1.scala b/test/files/run/reify_closure1.scala
index 3f5c8a8724..ce68975acc 100644
--- a/test/files/run/reify_closure1.scala
+++ b/test/files/run/reify_closure1.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
def foo[T](ys: List[T]): Int => Int = {
@@ -6,11 +9,11 @@ object Test extends App {
x
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(List(1, 2, 3))(10))
println(foo(List(1, 2, 3, 4))(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure2a.scala b/test/files/run/reify_closure2a.scala
index f5669a0e2c..cb53e7ffa8 100644
--- a/test/files/run/reify_closure2a.scala
+++ b/test/files/run/reify_closure2a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
def foo(y: Int): Int => Int = {
@@ -6,11 +9,11 @@ object Test extends App {
x + y
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure3a.scala b/test/files/run/reify_closure3a.scala
index 056a705d7d..cf8c161afa 100644
--- a/test/files/run/reify_closure3a.scala
+++ b/test/files/run/reify_closure3a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
def foo(y: Int): Int => Int = {
@@ -8,11 +11,11 @@ object Test extends App {
x + y1
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure4a.scala b/test/files/run/reify_closure4a.scala
index a63d20e561..1521295f16 100644
--- a/test/files/run/reify_closure4a.scala
+++ b/test/files/run/reify_closure4a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
def foo(y: Int): Int => Int = {
@@ -8,11 +11,11 @@ object Test extends App {
x + y1
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure5a.scala b/test/files/run/reify_closure5a.scala
index 2e8b413f4c..84c2c08727 100644
--- a/test/files/run/reify_closure5a.scala
+++ b/test/files/run/reify_closure5a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
def foo[T: TypeTag](ys: List[T]): Int => Int = {
@@ -6,7 +9,7 @@ object Test extends App {
x + ys.length
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
@@ -15,4 +18,4 @@ object Test extends App {
println(fun1(10))
var fun2 = foo(List(1, 2, 3, 4))
println(fun2(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure6.scala b/test/files/run/reify_closure6.scala
index 2cbd4ce819..d007e80899 100644
--- a/test/files/run/reify_closure6.scala
+++ b/test/files/run/reify_closure6.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
var q = 0
@@ -13,7 +16,7 @@ object Test extends App {
x + ys.length * z + q + y
}}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
dyn.asInstanceOf[Int => Int]
}
diff --git a/test/files/run/reify_closure7.scala b/test/files/run/reify_closure7.scala
index b9f87dbdeb..3d4956a724 100644
--- a/test/files/run/reify_closure7.scala
+++ b/test/files/run/reify_closure7.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
var q = 0
@@ -15,7 +18,7 @@ object Test extends App {
}}
if (clo == null) {
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun.tree)
clo = dyn.asInstanceOf[Int => Int]
}
@@ -27,4 +30,4 @@ object Test extends App {
println("first invocation = " + fun1(10))
val fun2 = foo(List(1, 2, 3, 4))
println("second invocation = " + fun2(10))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure8a.scala b/test/files/run/reify_closure8a.scala
index 9de121b42f..8db3d38241 100644
--- a/test/files/run/reify_closure8a.scala
+++ b/test/files/run/reify_closure8a.scala
@@ -1,12 +1,15 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
class Foo(val y: Int) {
def fun = reify{y}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(10).fun.tree)
val foo = dyn.asInstanceOf[Int]
println(foo)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closure8b.check b/test/files/run/reify_closure8b.check
index e0ec7d2c8f..585e6d5740 100644
--- a/test/files/run/reify_closure8b.check
+++ b/test/files/run/reify_closure8b.check
@@ -1,3 +1,3 @@
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective compilation has failed:
+scala.tools.reflect.ToolBoxError: reflective compilation has failed:
value y is not a member of Test.Foo
diff --git a/test/files/run/reify_closure8b.scala b/test/files/run/reify_closure8b.scala
index 431da3230e..9cdc0e997f 100644
--- a/test/files/run/reify_closure8b.scala
+++ b/test/files/run/reify_closure8b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
// will fail because y is a private field
@@ -8,11 +11,11 @@ object Test extends App {
}
try {
- val dyn = mkToolBox().runExpr(new Foo(10).fun.tree)
+ val dyn = cm.mkToolBox().runExpr(new Foo(10).fun.tree)
val foo = dyn.asInstanceOf[Int]
println(foo)
} catch {
case ex: Throwable =>
println(ex)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_closures10.scala b/test/files/run/reify_closures10.scala
index 0ccce77a94..2d9b833851 100644
--- a/test/files/run/reify_closures10.scala
+++ b/test/files/run/reify_closures10.scala
@@ -1,10 +1,13 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val x = 2
val y = 3
val code = reify{println(x + y); x + y}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(toolbox.runExpr(code.tree))
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_complex.scala b/test/files/run/reify_complex.scala
index ecc25ffca5..4abec3900e 100644
--- a/test/files/run/reify_complex.scala
+++ b/test/files/run/reify_complex.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -21,4 +22,4 @@ object Test extends App {
val x = new Complex(2, 1); val y = new Complex(1, 3)
println(x + y)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_copypaste1.check b/test/files/run/reify_copypaste1.check
new file mode 100644
index 0000000000..49a25ea881
--- /dev/null
+++ b/test/files/run/reify_copypaste1.check
@@ -0,0 +1,2 @@
+List(1, 2)
+
diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala
new file mode 100644
index 0000000000..7eaa4fa7b5
--- /dev/null
+++ b/test/files/run/reify_copypaste1.scala
@@ -0,0 +1,19 @@
+import scala.reflect.runtime._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe.definitions._
+import scala.reflect.runtime.universe.Flag._
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val stdout = System.out
+ val output = new java.io.ByteArrayOutputStream()
+ System.setOut(new java.io.PrintStream(output))
+ val toolBox = currentMirror.mkToolBox(options = "-Yreify-copypaste")
+ val reify = Select(Select(Select(Select(Ident(ScalaPackage), newTermName("reflect")), newTermName("runtime")), newTermName("universe")), newTermName("reify"))
+ val reifee = Block(List(ValDef(Modifiers(LAZY), newTermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(newTermName("x")))
+ toolBox.runExpr(Apply(reify, List(reifee)))
+ val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parseExpr(output.toString())
+ output.reset()
+ toolBox.runExpr(Block(stats, expr))
+ stdout.println(output.toString)
+} \ No newline at end of file
diff --git a/test/files/run/reify_copypaste2.check b/test/files/run/reify_copypaste2.check
new file mode 100644
index 0000000000..9c34f5179b
--- /dev/null
+++ b/test/files/run/reify_copypaste2.check
@@ -0,0 +1 @@
+scala.reflect.runtime.`package`.universe.reify(Test.this.x)
diff --git a/test/files/run/reify_copypaste2.scala b/test/files/run/reify_copypaste2.scala
new file mode 100644
index 0000000000..12d08cf244
--- /dev/null
+++ b/test/files/run/reify_copypaste2.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val x = 2
+ val outer = reify{reify{x}}
+ println(outer.tree)
+} \ No newline at end of file
diff --git a/test/files/run/reify_csv.scala b/test/files/run/reify_csv.scala
index 966521575c..c35624469c 100644
--- a/test/files/run/reify_csv.scala
+++ b/test/files/run/reify_csv.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
val csv = """
diff --git a/test/files/run/reify_extendbuiltins.scala b/test/files/run/reify_extendbuiltins.scala
index f95e9ab6ec..a2d546579d 100644
--- a/test/files/run/reify_extendbuiltins.scala
+++ b/test/files/run/reify_extendbuiltins.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -11,4 +12,4 @@ object Test extends App {
println("10! = " + (10!))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_for1.scala b/test/files/run/reify_for1.scala
index 9d1e32f7e5..e1f5347572 100644
--- a/test/files/run/reify_for1.scala
+++ b/test/files/run/reify_for1.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -6,4 +7,4 @@ object Test extends App {
val sumOfSquares2 = (1 to 100).filter(_ % 3 == 0).map(Math.pow(_, 2)).sum
assert(sumOfSquares1 == sumOfSquares2)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_fors.check b/test/files/run/reify_fors_newpatmat.check
index eefddedc20..eefddedc20 100644
--- a/test/files/run/reify_fors.check
+++ b/test/files/run/reify_fors_newpatmat.check
diff --git a/test/files/run/reify_fors.scala b/test/files/run/reify_fors_newpatmat.scala
index 635fce049e..6bee9538a8 100644
--- a/test/files/run/reify_fors.scala
+++ b/test/files/run/reify_fors_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -97,4 +98,4 @@ object Test extends App {
val ys = List(2.0, 1.0, 3.0)
println("scalProd(" + xs + ", " + ys +") = " + scalProd(xs, ys))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_fors_oldpatmat.check b/test/files/run/reify_fors_oldpatmat.check
new file mode 100644
index 0000000000..eefddedc20
--- /dev/null
+++ b/test/files/run/reify_fors_oldpatmat.check
@@ -0,0 +1,5 @@
+Persons over 20: John Richard
+divisors(34) = List(1, 2, 17, 34)
+findNums(15) = (4,1) (5,2) (6,1) (7,4) (8,3) (8,5) (9,2) (9,4) (10,1) (10,3) (10,7) (11,2) (11,6) (11,8) (12,1) (12,5) (12,7) (13,4) (13,6) (13,10) (14,3) (14,5) (14,9)
+average(List(3.5, 5.0, 4.5)) = 4.333333333333333
+scalProd(List(3.5, 5.0, 4.5), List(2.0, 1.0, 3.0)) = 25.5
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check b/test/files/run/reify_fors_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check
+++ b/test/files/run/reify_fors_oldpatmat.flags
diff --git a/test/files/run/reify_fors_oldpatmat.scala b/test/files/run/reify_fors_oldpatmat.scala
new file mode 100644
index 0000000000..6bee9538a8
--- /dev/null
+++ b/test/files/run/reify_fors_oldpatmat.scala
@@ -0,0 +1,101 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ object Persons {
+ /** A list of persons. To create a list, we use Predef.List
+ * which takes a variable number of arguments and constructs
+ * a list out of them.
+ */
+ val persons = List(
+ new Person("Bob", 17),
+ new Person("John", 40),
+ new Person("Richard", 68)
+ )
+
+ /** A Person class. 'val' constructor parameters become
+ * public members of the class.
+ */
+ class Person(val name: String, val age: Int)
+
+ /** Return an iterator over persons that are older than 20.
+ */
+ def olderThan20(xs: Seq[Person]): Iterator[String] =
+ olderThan20(xs.iterator)
+
+ /** Return an iterator over persons older than 20, given
+ * an iterator over persons.
+ */
+ def olderThan20(xs: Iterator[Person]): Iterator[String] = {
+
+ // The first expression is called a 'generator' and makes
+ // 'p' take values from 'xs'. The second expression is
+ // called a 'filter' and it is a boolean expression which
+ // selects only persons older than 20. There can be more than
+ // one generator and filter. The 'yield' expression is evaluated
+ // for each 'p' which satisfies the filters and used to assemble
+ // the resulting iterator
+ for (p <- xs if p.age > 20) yield p.name
+ }
+ }
+
+ /** Some functions over lists of numbers which demonstrate
+ * the use of for comprehensions.
+ */
+ object Numeric {
+
+ /** Return the divisors of n. */
+ def divisors(n: Int): List[Int] =
+ for (i <- List.range(1, n+1) if n % i == 0) yield i
+
+ /** Is 'n' a prime number? */
+ def isPrime(n: Int) = divisors(n).length == 2
+
+ /** Return pairs of numbers whose sum is prime. */
+ def findNums(n: Int): Iterable[(Int, Int)] = {
+
+ // a for comprehension using two generators
+ for (i <- 1 until n;
+ j <- 1 until (i-1);
+ if isPrime(i + j)) yield (i, j)
+ }
+
+ /** Return the sum of the elements of 'xs'. */
+ def sum(xs: List[Double]): Double =
+ xs.foldLeft(0.0) { (x, y) => x + y }
+
+ /** Return the sum of pairwise product of the two lists. */
+ def scalProd(xs: List[Double], ys: List[Double]) =
+ sum(for((x, y) <- xs zip ys) yield x * y);
+
+ /** Remove duplicate elements in 'xs'. */
+ def removeDuplicates[A](xs: List[A]): List[A] =
+ if (xs.isEmpty)
+ xs
+ else
+ xs.head :: removeDuplicates(for (x <- xs.tail if x != xs.head) yield x)
+ }
+
+ // import all members of object 'persons' in the current scope
+ import Persons._
+
+ print("Persons over 20:")
+ olderThan20(persons) foreach { x => print(" " + x) }
+ println
+
+ import Numeric._
+
+ println("divisors(34) = " + divisors(34))
+
+ print("findNums(15) =")
+ findNums(15) foreach { x => print(" " + x) }
+ println
+
+ val xs = List(3.5, 5.0, 4.5)
+ println("average(" + xs + ") = " + sum(xs) / xs.length)
+
+ val ys = List(2.0, 1.0, 3.0)
+ println("scalProd(" + xs + ", " + ys +") = " + scalProd(xs, ys))
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/reify_generic.scala b/test/files/run/reify_generic.scala
index 7033c4e237..7baffac6a3 100644
--- a/test/files/run/reify_generic.scala
+++ b/test/files/run/reify_generic.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
val product = List(1, 2, 3).head * List[Any](4, 2, 0).head.asInstanceOf[Int]
println(product)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_generic2.scala b/test/files/run/reify_generic2.scala
index 8f9def318e..36ab61e077 100644
--- a/test/files/run/reify_generic2.scala
+++ b/test/files/run/reify_generic2.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -6,4 +7,4 @@ object Test extends App {
val product = List(new C, new C).length * List[C](new C, new C).length
println(product)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_getter.scala b/test/files/run/reify_getter.scala
index 8bae293e72..26767603a0 100644
--- a/test/files/run/reify_getter.scala
+++ b/test/files/run/reify_getter.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -9,7 +12,7 @@ object Test extends App {
new C().x
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala
index 69198391d1..42a1deef26 100644
--- a/test/files/run/reify_implicits-new.scala
+++ b/test/files/run/reify_implicits-new.scala
@@ -1,8 +1,10 @@
-import scala.reflect.mirror._
+import scala.reflect.{ClassTag, classTag}
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
- implicit def arrayWrapper[A : ArrayTag](x: Array[A]) =
+ implicit def arrayWrapper[A : ClassTag](x: Array[A]) =
new {
def sort(p: (A, A) => Boolean) = {
util.Sorting.stableSort(x, p); x
@@ -11,4 +13,4 @@ object Test extends App {
val x = Array(2, 3, 1, 4)
println("x = "+ x.sort((x: Int, y: Int) => x < y).toList)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_implicits-old.scala b/test/files/run/reify_implicits-old.scala
index 60971c3cfb..8ff256d2d4 100644
--- a/test/files/run/reify_implicits-old.scala
+++ b/test/files/run/reify_implicits-old.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -11,4 +12,4 @@ object Test extends App {
val x = Array(2, 3, 1, 4)
println("x = "+ x.sort((x: Int, y: Int) => x < y).toList)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_inheritance.scala b/test/files/run/reify_inheritance.scala
index dd86c355a3..c732664438 100644
--- a/test/files/run/reify_inheritance.scala
+++ b/test/files/run/reify_inheritance.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -13,4 +14,4 @@ object Test extends App {
println(new D().y * new C().x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_inner1.scala b/test/files/run/reify_inner1.scala
index ea77ece6df..8da338ee4a 100644
--- a/test/files/run/reify_inner1.scala
+++ b/test/files/run/reify_inner1.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -12,4 +13,4 @@ object Test extends App {
val inner = new outer.D()
println(inner.x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_inner2.scala b/test/files/run/reify_inner2.scala
index 67c403f7e5..f82eff8f03 100644
--- a/test/files/run/reify_inner2.scala
+++ b/test/files/run/reify_inner2.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -12,4 +13,4 @@ object Test extends App {
val inner = outer.D
println(inner.x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_inner3.scala b/test/files/run/reify_inner3.scala
index ad401d81da..72f8d9a38a 100644
--- a/test/files/run/reify_inner3.scala
+++ b/test/files/run/reify_inner3.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -12,4 +13,4 @@ object Test extends App {
val inner = new outer.D
println(inner.x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_inner4.scala b/test/files/run/reify_inner4.scala
index 140c8e9ed4..ecbbf149a4 100644
--- a/test/files/run/reify_inner4.scala
+++ b/test/files/run/reify_inner4.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -12,4 +13,4 @@ object Test extends App {
val inner = outer.D
println(inner.x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_lazyevaluation.scala b/test/files/run/reify_lazyevaluation.scala
index 1a0c858914..5b310d95f7 100644
--- a/test/files/run/reify_lazyevaluation.scala
+++ b/test/files/run/reify_lazyevaluation.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/files/run/reify_maps.check b/test/files/run/reify_maps_newpatmat.check
index 08cbbb1359..08cbbb1359 100644
--- a/test/files/run/reify_maps.check
+++ b/test/files/run/reify_maps_newpatmat.check
diff --git a/test/files/run/reify_maps.scala b/test/files/run/reify_maps_newpatmat.scala
index 3fcc21892f..b538355b03 100644
--- a/test/files/run/reify_maps.scala
+++ b/test/files/run/reify_maps_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -16,4 +17,4 @@ object Test extends App {
}
)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_maps_oldpatmat.check b/test/files/run/reify_maps_oldpatmat.check
new file mode 100644
index 0000000000..08cbbb1359
--- /dev/null
+++ b/test/files/run/reify_maps_oldpatmat.check
@@ -0,0 +1,4 @@
+red has code: 16711680
+Unknown color: green
+Unknown color: blue
+turquoise has code: 65535
diff --git a/test/files/run/reify_fors.flags b/test/files/run/reify_maps_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/reify_fors.flags
+++ b/test/files/run/reify_maps_oldpatmat.flags
diff --git a/test/files/run/reify_maps_oldpatmat.scala b/test/files/run/reify_maps_oldpatmat.scala
new file mode 100644
index 0000000000..b538355b03
--- /dev/null
+++ b/test/files/run/reify_maps_oldpatmat.scala
@@ -0,0 +1,20 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ val colors = Map("red" -> 0xFF0000,
+ "turquoise" -> 0x00FFFF,
+ "black" -> 0x000000,
+ "orange" -> 0xFF8040,
+ "brown" -> 0x804000)
+ for (name <- List("red", "green", "blue", "turquoise")) println(
+ colors.get(name) match {
+ case Some(code) =>
+ name + " has code: " + code
+ case None =>
+ "Unknown color: " + name
+ }
+ )
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala
index fe23bc8438..8ea92c511b 100644
--- a/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala
+++ b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala
@@ -1,13 +1,18 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify{
val x = 2
val inner = reify{x}
+// was: inner.splice
inner.eval
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala
index 5d98a38592..7ff4f84de0 100644
--- a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala
+++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala
@@ -1,11 +1,16 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val x = 2
val outer = reify{reify{x}}
+// was: val code = reify{outer.splice.splice}
val code = reify{outer.eval.eval}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala
index ca31d83acd..7f1f9d8478 100644
--- a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala
+++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala
@@ -1,15 +1,21 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val x = 2
val code = reify{
{
val inner = reify{reify{x}}
+// was: inner.splice
inner.eval
+// was: }.splice
}.eval
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala
index 56d85c6ba1..65e0931b6e 100644
--- a/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala
+++ b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala
@@ -1,13 +1,18 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify{
val x = 2
val inner = reify{reify{x}}
+// was: inner.splice.splice
inner.eval.eval
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_nested_inner_refers_to_global.scala b/test/files/run/reify_nested_inner_refers_to_global.scala
index 14899bcf99..f45c1daed9 100644
--- a/test/files/run/reify_nested_inner_refers_to_global.scala
+++ b/test/files/run/reify_nested_inner_refers_to_global.scala
@@ -1,14 +1,17 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = {
val x = 2
reify{
- reify{x}.eval
+ reify{x}.splice
}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_nested_inner_refers_to_local.scala b/test/files/run/reify_nested_inner_refers_to_local.scala
index fd56585f72..4a3d8bb02b 100644
--- a/test/files/run/reify_nested_inner_refers_to_local.scala
+++ b/test/files/run/reify_nested_inner_refers_to_local.scala
@@ -1,12 +1,17 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify{
val x = 2
+// was: reify{x}.eval
reify{x}.eval
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_nested_outer_refers_to_global.scala b/test/files/run/reify_nested_outer_refers_to_global.scala
index f34e4fe04b..b628975e59 100644
--- a/test/files/run/reify_nested_outer_refers_to_global.scala
+++ b/test/files/run/reify_nested_outer_refers_to_global.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = {
@@ -6,11 +9,11 @@ object Test extends App {
val outer = reify{x}
reify{
val x = 42
- outer.eval
+ outer.splice
};
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_nested_outer_refers_to_local.scala b/test/files/run/reify_nested_outer_refers_to_local.scala
index e16c851d8d..80564fa9a2 100644
--- a/test/files/run/reify_nested_outer_refers_to_local.scala
+++ b/test/files/run/reify_nested_outer_refers_to_local.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val outer = {
@@ -7,10 +10,10 @@ object Test extends App {
}
val code = reify{
val x = 42
- outer.eval
+ outer.splice
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_01.scala b/test/files/run/reify_newimpl_01.scala
index f7539a15b0..e4b46e428f 100644
--- a/test/files/run/reify_newimpl_01.scala
+++ b/test/files/run/reify_newimpl_01.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_02.scala b/test/files/run/reify_newimpl_02.scala
index 2c085efa04..fa7ee17acf 100644
--- a/test/files/run/reify_newimpl_02.scala
+++ b/test/files/run/reify_newimpl_02.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_03.scala b/test/files/run/reify_newimpl_03.scala
index 361cfc50bb..8d65425528 100644
--- a/test/files/run/reify_newimpl_03.scala
+++ b/test/files/run/reify_newimpl_03.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_04.scala b/test/files/run/reify_newimpl_04.scala
index d80a7c9ffd..21341ed102 100644
--- a/test/files/run/reify_newimpl_04.scala
+++ b/test/files/run/reify_newimpl_04.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_05.scala b/test/files/run/reify_newimpl_05.scala
index 85c1711bdb..635eba3827 100644
--- a/test/files/run/reify_newimpl_05.scala
+++ b/test/files/run/reify_newimpl_05.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_06.scala b/test/files/run/reify_newimpl_06.scala
index 257b54167a..0bf37da8c6 100644
--- a/test/files/run/reify_newimpl_06.scala
+++ b/test/files/run/reify_newimpl_06.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C(val y: Int) {
diff --git a/test/files/run/reify_newimpl_09.scala b/test/files/run/reify_newimpl_09.scala
index 2c81945a2a..27fbd37b71 100644
--- a/test/files/run/reify_newimpl_09.scala
+++ b/test/files/run/reify_newimpl_09.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_10.scala b/test/files/run/reify_newimpl_10.scala
index 6e70b4d216..791e52943a 100644
--- a/test/files/run/reify_newimpl_10.scala
+++ b/test/files/run/reify_newimpl_10.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check
index e2a8206132..21bd28667e 100644
--- a/test/files/run/reify_newimpl_11.check
+++ b/test/files/run/reify_newimpl_11.check
@@ -1,2 +1,2 @@
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
-unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:4:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
+scala.tools.reflect.ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_11.scala b/test/files/run/reify_newimpl_11.scala
index 4e91c7a457..e8ca664418 100644
--- a/test/files/run/reify_newimpl_11.scala
+++ b/test/files/run/reify_newimpl_11.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C[T] {
diff --git a/test/files/run/reify_newimpl_12.scala b/test/files/run/reify_newimpl_12.scala
index 433168ce28..246d7b4d4c 100644
--- a/test/files/run/reify_newimpl_12.scala
+++ b/test/files/run/reify_newimpl_12.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C[T: TypeTag] {
diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check
index 7c47310cf2..e28732bd6a 100644
--- a/test/files/run/reify_newimpl_13.check
+++ b/test/files/run/reify_newimpl_13.check
@@ -1,2 +1,2 @@
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
-unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:5:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
+scala.tools.reflect.ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_13.scala b/test/files/run/reify_newimpl_13.scala
index dd1980b74f..1b2b8cb529 100644
--- a/test/files/run/reify_newimpl_13.scala
+++ b/test/files/run/reify_newimpl_13.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_14.scala b/test/files/run/reify_newimpl_14.scala
index 3f52f19cfb..284e87acd3 100644
--- a/test/files/run/reify_newimpl_14.scala
+++ b/test/files/run/reify_newimpl_14.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_15.scala b/test/files/run/reify_newimpl_15.scala
index b707b2583d..cb66e8549e 100644
--- a/test/files/run/reify_newimpl_15.scala
+++ b/test/files/run/reify_newimpl_15.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C {
diff --git a/test/files/run/reify_newimpl_16.scala b/test/files/run/reify_newimpl_16.scala
index 98fc15878c..a0cadf4d48 100644
--- a/test/files/run/reify_newimpl_16.scala
+++ b/test/files/run/reify_newimpl_16.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_17.check b/test/files/run/reify_newimpl_17.check
index 0fb9ddfc2d..e592e0e94e 100644
--- a/test/files/run/reify_newimpl_17.check
+++ b/test/files/run/reify_newimpl_17.check
@@ -1,2 +1,2 @@
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
-unresolved free type variables (namely: U defined by C in reify_newimpl_17.scala:4:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
+scala.tools.reflect.ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: U defined by C in reify_newimpl_17.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_17.scala b/test/files/run/reify_newimpl_17.scala
index 331777fcfb..8fbcd52502 100644
--- a/test/files/run/reify_newimpl_17.scala
+++ b/test/files/run/reify_newimpl_17.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C[U] {
diff --git a/test/files/run/reify_newimpl_18.scala b/test/files/run/reify_newimpl_18.scala
index 704e54928a..8456fd1b8f 100644
--- a/test/files/run/reify_newimpl_18.scala
+++ b/test/files/run/reify_newimpl_18.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C[U: TypeTag] {
diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check
index 32f9300f53..1d96992869 100644
--- a/test/files/run/reify_newimpl_19.check
+++ b/test/files/run/reify_newimpl_19.check
@@ -1,2 +1,2 @@
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
-unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:5:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
+scala.tools.reflect.ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_19.scala b/test/files/run/reify_newimpl_19.scala
index 0ea8ae6992..ba2d39cfdb 100644
--- a/test/files/run/reify_newimpl_19.scala
+++ b/test/files/run/reify_newimpl_19.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C {
diff --git a/test/files/run/reify_newimpl_20.scala b/test/files/run/reify_newimpl_20.scala
index 16895a449e..f8ddb53a22 100644
--- a/test/files/run/reify_newimpl_20.scala
+++ b/test/files/run/reify_newimpl_20.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C {
diff --git a/test/files/run/reify_newimpl_21.scala b/test/files/run/reify_newimpl_21.scala
index 99f9ac9089..97261b21ed 100644
--- a/test/files/run/reify_newimpl_21.scala
+++ b/test/files/run/reify_newimpl_21.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
trait C {
diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check
index 51699cbc29..ebcf42f52f 100644
--- a/test/files/run/reify_newimpl_22.check
+++ b/test/files/run/reify_newimpl_22.check
@@ -3,8 +3,14 @@ Type :help for more information.
scala>
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.tools.reflect.ToolBox
+import scala.tools.reflect.ToolBox
+
+scala> import scala.tools.reflect.Eval
+import scala.tools.reflect.Eval
scala> {
val x = 2
@@ -13,7 +19,7 @@ scala> {
}
println(code.eval)
}
-<console>:13: free term: Ident(newTermName("x")) defined by res0 in <console>:12:21
+<console>:15: free term: Ident(newTermName("x")) defined by res0 in <console>:14:21
val code = reify {
^
2
diff --git a/test/files/run/reify_newimpl_22.scala b/test/files/run/reify_newimpl_22.scala
index a211ad360c..8512620a16 100644
--- a/test/files/run/reify_newimpl_22.scala
+++ b/test/files/run/reify_newimpl_22.scala
@@ -3,7 +3,9 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-Xlog-free-terms"
def code = """
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
{
val x = 2
val code = reify {
@@ -12,4 +14,4 @@ import scala.reflect.mirror._
println(code.eval)
}
"""
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check
index 33d15190fb..c8ed424c86 100644
--- a/test/files/run/reify_newimpl_23.check
+++ b/test/files/run/reify_newimpl_23.check
@@ -3,8 +3,14 @@ Type :help for more information.
scala>
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.tools.reflect.ToolBox
+import scala.tools.reflect.ToolBox
+
+scala> import scala.tools.reflect.Eval
+import scala.tools.reflect.Eval
scala> def foo[T]{
val code = reify {
@@ -12,7 +18,7 @@ scala> def foo[T]{
}
println(code.eval)
}
-<console>:11: free type: Ident(newTypeName("T")) defined by foo in <console>:10:16
+<console>:13: free type: Ident(newTypeName("T")) defined by foo in <console>:12:16
val code = reify {
^
foo: [T]=> Unit
diff --git a/test/files/run/reify_newimpl_23.scala b/test/files/run/reify_newimpl_23.scala
index 15da4e497e..d4c2a68ce6 100644
--- a/test/files/run/reify_newimpl_23.scala
+++ b/test/files/run/reify_newimpl_23.scala
@@ -3,7 +3,9 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-Xlog-free-types"
def code = """
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
def foo[T]{
val code = reify {
List[T]()
@@ -11,4 +13,4 @@ def foo[T]{
println(code.eval)
}
"""
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_24.check b/test/files/run/reify_newimpl_24.check
deleted file mode 100644
index 66b18c790e..0000000000
--- a/test/files/run/reify_newimpl_24.check
+++ /dev/null
@@ -1,24 +0,0 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
-
-scala> {
- val x = 2
- val code = reify {
- val y = reify { x }
- y.eval
- }
- println(code.eval)
-}
-<console>:15: this splice cannot be resolved statically
- y.eval
- ^
-2
-
-scala>
-
-scala>
diff --git a/test/files/run/reify_newimpl_24.scala b/test/files/run/reify_newimpl_24.scala
deleted file mode 100644
index 7b21eeeb10..0000000000
--- a/test/files/run/reify_newimpl_24.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-import scala.tools.partest.ReplTest
-
-object Test extends ReplTest {
- override def extraSettings = "-Xlog-runtime-splices"
- def code = """
-import scala.reflect.mirror._
-{
- val x = 2
- val code = reify {
- val y = reify { x }
- y.eval
- }
- println(code.eval)
-}
- """
-}
diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check
index 37ff83c9ee..a688a98fbc 100644
--- a/test/files/run/reify_newimpl_25.check
+++ b/test/files/run/reify_newimpl_25.check
@@ -3,18 +3,16 @@ Type :help for more information.
scala>
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
-
scala> {
+ import scala.reflect.runtime.universe._
val x = "2"
val tt = implicitly[TypeTag[x.type]]
println(tt)
}
-<console>:13: free term: Ident(newTermName("x")) defined by res0 in <console>:12:21
+<console>:11: free term: Ident(newTermName("x")) defined by res0 in <console>:10:21
val tt = implicitly[TypeTag[x.type]]
^
-ConcreteTypeTag[x.type]
+TypeTag[x.type]
scala>
diff --git a/test/files/run/reify_newimpl_25.scala b/test/files/run/reify_newimpl_25.scala
index 1f66f5e681..01cc04b59f 100644
--- a/test/files/run/reify_newimpl_25.scala
+++ b/test/files/run/reify_newimpl_25.scala
@@ -3,11 +3,11 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-Xlog-free-terms"
def code = """
-import scala.reflect.mirror._
{
+ import scala.reflect.runtime.universe._
val x = "2"
val tt = implicitly[TypeTag[x.type]]
println(tt)
}
"""
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check
index d92b3bd817..6c5f124960 100644
--- a/test/files/run/reify_newimpl_26.check
+++ b/test/files/run/reify_newimpl_26.check
@@ -3,20 +3,18 @@ Type :help for more information.
scala>
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
-
scala> def foo[T]{
- val tt = implicitly[TypeTag[List[T]]]
+ import scala.reflect.runtime.universe._
+ val tt = implicitly[AbsTypeTag[List[T]]]
println(tt)
}
-<console>:11: free type: Ident(newTypeName("T")) defined by foo in <console>:10:16
- val tt = implicitly[TypeTag[List[T]]]
+<console>:9: free type: Ident(newTypeName("T")) defined by foo in <console>:7:16
+ val tt = implicitly[AbsTypeTag[List[T]]]
^
foo: [T]=> Unit
scala> foo[Int]
-TypeTag[List[T]]
+AbsTypeTag[List[T]]
scala>
diff --git a/test/files/run/reify_newimpl_26.scala b/test/files/run/reify_newimpl_26.scala
index f2dd1bfc4e..a12d8a2970 100644
--- a/test/files/run/reify_newimpl_26.scala
+++ b/test/files/run/reify_newimpl_26.scala
@@ -3,11 +3,11 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-Xlog-free-types"
def code = """
-import scala.reflect.mirror._
def foo[T]{
- val tt = implicitly[TypeTag[List[T]]]
+ import scala.reflect.runtime.universe._
+ val tt = implicitly[AbsTypeTag[List[T]]]
println(tt)
}
foo[Int]
"""
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_27.scala b/test/files/run/reify_newimpl_27.scala
index b3d6d5c865..db9ada36e4 100644
--- a/test/files/run/reify_newimpl_27.scala
+++ b/test/files/run/reify_newimpl_27.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
object C {
diff --git a/test/files/run/reify_newimpl_28.scala b/test/files/run/reify_newimpl_28.scala
index f7874b8548..524a110704 100644
--- a/test/files/run/reify_newimpl_28.scala
+++ b/test/files/run/reify_newimpl_28.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_29.scala b/test/files/run/reify_newimpl_29.scala
index e32762f335..033c360b8c 100644
--- a/test/files/run/reify_newimpl_29.scala
+++ b/test/files/run/reify_newimpl_29.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
class C {
diff --git a/test/files/run/reify_newimpl_30.scala b/test/files/run/reify_newimpl_30.scala
index e4ba3221e1..573d05a630 100644
--- a/test/files/run/reify_newimpl_30.scala
+++ b/test/files/run/reify_newimpl_30.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_31.scala b/test/files/run/reify_newimpl_31.scala
index 20a851e32e..2e20aa0f62 100644
--- a/test/files/run/reify_newimpl_31.scala
+++ b/test/files/run/reify_newimpl_31.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
object C {
diff --git a/test/files/run/reify_newimpl_32.scala b/test/files/run/reify_newimpl_32.scala
index 788486ec00..095e59d919 100644
--- a/test/files/run/reify_newimpl_32.scala
+++ b/test/files/run/reify_newimpl_32.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_33.scala b/test/files/run/reify_newimpl_33.scala
index 84a8258256..98bb2e5102 100644
--- a/test/files/run/reify_newimpl_33.scala
+++ b/test/files/run/reify_newimpl_33.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
object C {
diff --git a/test/files/run/reify_newimpl_34.scala b/test/files/run/reify_newimpl_34.scala
index 5935ab385c..a0a575ed7d 100644
--- a/test/files/run/reify_newimpl_34.scala
+++ b/test/files/run/reify_newimpl_34.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_35.check b/test/files/run/reify_newimpl_35.check
new file mode 100644
index 0000000000..f8306003b5
--- /dev/null
+++ b/test/files/run/reify_newimpl_35.check
@@ -0,0 +1,17 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> def foo[T: TypeTag] = reify{List[T]()}
+foo: [T](implicit evidence$1: reflect.runtime.universe.TypeTag[T])reflect.runtime.universe.Expr[List[T]]
+
+scala> println(foo)
+Expr[List[Nothing]](immutable.this.Nil)
+
+scala>
+
+scala>
diff --git a/test/pending/run/reify_newimpl_35.scala b/test/files/run/reify_newimpl_35.scala
index 5e1d163e9e..f2ebf5181b 100644
--- a/test/pending/run/reify_newimpl_35.scala
+++ b/test/files/run/reify_newimpl_35.scala
@@ -3,7 +3,7 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def extraSettings = "-Xlog-free-types"
def code = """
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
def foo[T: TypeTag] = reify{List[T]()}
println(foo)
"""
diff --git a/test/files/run/reify_newimpl_36.scala b/test/files/run/reify_newimpl_36.scala
index c76efce27a..490e645cf7 100644
--- a/test/files/run/reify_newimpl_36.scala
+++ b/test/files/run/reify_newimpl_36.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_37.scala b/test/files/run/reify_newimpl_37.scala
index e83d35dbe1..7c4d4af3dd 100644
--- a/test/files/run/reify_newimpl_37.scala
+++ b/test/files/run/reify_newimpl_37.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_38.scala b/test/files/run/reify_newimpl_38.scala
index 70ef49ecf7..fd898b9ab2 100644
--- a/test/files/run/reify_newimpl_38.scala
+++ b/test/files/run/reify_newimpl_38.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_39.scala b/test/files/run/reify_newimpl_39.scala
index faa45d917d..885c738275 100644
--- a/test/files/run/reify_newimpl_39.scala
+++ b/test/files/run/reify_newimpl_39.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_40.scala b/test/files/run/reify_newimpl_40.scala
index a983a92324..018bf720f3 100644
--- a/test/files/run/reify_newimpl_40.scala
+++ b/test/files/run/reify_newimpl_40.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_41.scala b/test/files/run/reify_newimpl_41.scala
index 9aedccc98a..9bb79fb2b9 100644
--- a/test/files/run/reify_newimpl_41.scala
+++ b/test/files/run/reify_newimpl_41.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_42.scala b/test/files/run/reify_newimpl_42.scala
index 1e21bd59bc..bd7deadea6 100644
--- a/test/files/run/reify_newimpl_42.scala
+++ b/test/files/run/reify_newimpl_42.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_43.scala b/test/files/run/reify_newimpl_43.scala
index 962461db8b..88ea224322 100644
--- a/test/files/run/reify_newimpl_43.scala
+++ b/test/files/run/reify_newimpl_43.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_44.scala b/test/files/run/reify_newimpl_44.scala
index 962461db8b..88ea224322 100644
--- a/test/files/run/reify_newimpl_44.scala
+++ b/test/files/run/reify_newimpl_44.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_45.scala b/test/files/run/reify_newimpl_45.scala
index b2b52eaf5b..d2254d6dde 100644
--- a/test/files/run/reify_newimpl_45.scala
+++ b/test/files/run/reify_newimpl_45.scala
@@ -1,11 +1,14 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
class C[T >: Null] {
val code = reify{val x: T = "2".asInstanceOf[T]; println("ima worx: %s".format(x)); x}
- println(freeTypes(code.tree))
- val T = freeTypes(code.tree)(0)
- mkToolBox().runExpr(code.tree, Map(T -> definitions.StringClass.asType))
+ println(code.tree.freeTypes)
+ val T = code.tree.freeTypes(0)
+ cm.mkToolBox().runExpr(code.tree, Map(T -> definitions.StringClass.asType))
}
new C[String]
diff --git a/test/files/run/reify_newimpl_47.scala b/test/files/run/reify_newimpl_47.scala
index bd1bd1fe65..8740132f6a 100644
--- a/test/files/run/reify_newimpl_47.scala
+++ b/test/files/run/reify_newimpl_47.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val outer = {
@@ -8,8 +10,8 @@ object Test extends App {
val code = reify{
val x = 42
- outer.eval
+ outer.splice
}
println(code.eval)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_48.scala b/test/files/run/reify_newimpl_48.scala
index 1522509907..9899bc09a0 100644
--- a/test/files/run/reify_newimpl_48.scala
+++ b/test/files/run/reify_newimpl_48.scala
@@ -1,4 +1,6 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val outer1 = {
@@ -13,8 +15,8 @@ object Test extends App {
val code = reify{
val x = 4
- x + outer1.eval + outer2.eval
+ x + outer1.splice + outer2.splice
}
println(code.eval)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_newimpl_49.scala b/test/files/run/reify_newimpl_49.scala
index 68d968e28b..2222bd69d5 100644
--- a/test/files/run/reify_newimpl_49.scala
+++ b/test/files/run/reify_newimpl_49.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_50.scala b/test/files/run/reify_newimpl_50.scala
index b81d72a4eb..279cb161a0 100644
--- a/test/files/run/reify_newimpl_50.scala
+++ b/test/files/run/reify_newimpl_50.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_51.scala b/test/files/run/reify_newimpl_51.scala
index ccbae2e160..f823bf4033 100644
--- a/test/files/run/reify_newimpl_51.scala
+++ b/test/files/run/reify_newimpl_51.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_newimpl_52.scala b/test/files/run/reify_newimpl_52.scala
index 60b16d3618..f01199e830 100644
--- a/test/files/run/reify_newimpl_52.scala
+++ b/test/files/run/reify_newimpl_52.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala
index dc092c1a85..1b1c6fdbb8 100644
--- a/test/files/run/reify_printf.scala
+++ b/test/files/run/reify_printf.scala
@@ -1,20 +1,20 @@
import java.io.{ ByteArrayOutputStream, PrintStream }
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
import scala.reflect.api._
import scala.reflect.api.Trees
import scala.reflect.internal.Types
import scala.util.matching.Regex
object Test extends App {
- val tree = tree_printf(reify("hello %s").tree, reify("world").tree)
-
- import scala.reflect.mirror._
- val toolbox = mkToolBox()
-
val output = new ByteArrayOutputStream()
Console.setOut(new PrintStream(output))
- val evaluated = toolbox.runExpr(tree)
+ val toolbox = cm.mkToolBox()
+ val tree = tree_printf(reify("hello %s").tree, reify("world").tree)
+ val evaluated = toolbox.runExpr(tree)
assert(output.toString() == "hello world", output.toString() +" == hello world")
/*
@@ -30,9 +30,9 @@ object Test extends App {
(
Some(
ValDef(
- Modifiers()
+ NoMods
, local
- , TypeTree().setType(tpe)
+ , TypeTree(tpe)
, value
)
)
@@ -44,8 +44,8 @@ object Test extends App {
val Literal(Constant(s_format: String)) = format
val paramsStack = scala.collection.mutable.Stack(params: _*)
val parsed = s_format.split("(?<=%[\\w%])|(?=%[\\w%])") map {
- case "%d" => createTempValDef( paramsStack.pop, classToType(classOf[Int]) )
- case "%s" => createTempValDef( paramsStack.pop, classToType(classOf[String]) )
+ case "%d" => createTempValDef( paramsStack.pop, IntTpe )
+ case "%s" => createTempValDef( paramsStack.pop, StringTpe )
case "%%" => {
(None:Option[Tree], Literal(Constant("%")))
}
@@ -68,4 +68,4 @@ object Test extends App {
): Tree
Block((evals ++ prints).toList, Literal(Constant(())))
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_properties.scala b/test/files/run/reify_properties.scala
index 5cacc262ac..01a9b12a92 100644
--- a/test/files/run/reify_properties.scala
+++ b/test/files/run/reify_properties.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/files/run/reify_sort.scala b/test/files/run/reify_sort.scala
index 0b373b358f..17e3976c09 100644
--- a/test/files/run/reify_sort.scala
+++ b/test/files/run/reify_sort.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -47,4 +48,4 @@ object Test extends App {
sort(ar)
println(ar)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_sort1.scala b/test/files/run/reify_sort1.scala
index 56125619e9..6fb3cc5895 100644
--- a/test/files/run/reify_sort1.scala
+++ b/test/files/run/reify_sort1.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -17,4 +18,4 @@ object Test extends App {
println(xs)
println(sort(xs))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_this.scala b/test/files/run/reify_this.scala
index 280d735ab6..ecbf394bba 100644
--- a/test/files/run/reify_this.scala
+++ b/test/files/run/reify_this.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
trait Eval {
def eval(tree: Expr[_]) = tree.eval
@@ -16,4 +17,4 @@ object Test extends App with Eval {
// select a value from module
val x = 2
eval(reify{println(x)})
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_timeofday.scala b/test/files/run/reify_timeofday.scala
index 481ab04df5..efeb81debf 100644
--- a/test/files/run/reify_timeofday.scala
+++ b/test/files/run/reify_timeofday.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -38,4 +39,4 @@ object Test extends App {
case e: Exception => println("Exception")
}
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_1a.scala b/test/files/run/reify_typerefs_1a.scala
index 15d8d17835..53033e210c 100644
--- a/test/files/run/reify_typerefs_1a.scala
+++ b/test/files/run/reify_typerefs_1a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
class Expression {
override def toString = "Expression"
@@ -9,7 +12,7 @@ object Test extends App {
List(new Expression, new Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_1b.scala b/test/files/run/reify_typerefs_1b.scala
index 06ce1e35ac..12604454ed 100644
--- a/test/files/run/reify_typerefs_1b.scala
+++ b/test/files/run/reify_typerefs_1b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Expression {
override def toString = "Expression"
@@ -9,7 +12,7 @@ object Test extends App {
List(Expression, Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_2a.scala b/test/files/run/reify_typerefs_2a.scala
index d03efea222..ffc3dfc942 100644
--- a/test/files/run/reify_typerefs_2a.scala
+++ b/test/files/run/reify_typerefs_2a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
package foo {
class Expression {
@@ -11,7 +14,7 @@ object Test extends App {
List(new foo.Expression, new foo.Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_2b.scala b/test/files/run/reify_typerefs_2b.scala
index 3d9f7d61b8..f5d1633d79 100644
--- a/test/files/run/reify_typerefs_2b.scala
+++ b/test/files/run/reify_typerefs_2b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
package foo {
object Expression {
@@ -11,7 +14,7 @@ object Test extends App {
List(foo.Expression, foo.Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_3a.scala b/test/files/run/reify_typerefs_3a.scala
index 4128073f60..67b2c2d8aa 100644
--- a/test/files/run/reify_typerefs_3a.scala
+++ b/test/files/run/reify_typerefs_3a.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object foo {
class Expression {
@@ -11,7 +14,7 @@ object Test extends App {
List(new foo.Expression, new foo.Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_typerefs_3b.scala b/test/files/run/reify_typerefs_3b.scala
index a7ede00c9c..41a0a667e2 100644
--- a/test/files/run/reify_typerefs_3b.scala
+++ b/test/files/run/reify_typerefs_3b.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object foo {
object Expression {
@@ -11,7 +14,7 @@ object Test extends App {
List(foo.Expression, foo.Expression)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/reify_varargs.scala b/test/files/run/reify_varargs.scala
index fe8f03b702..1cbc7c9473 100644
--- a/test/files/run/reify_varargs.scala
+++ b/test/files/run/reify_varargs.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -7,4 +8,4 @@ object Test extends App {
"Hoth", "the fifth of August", "a disturbance in the Force")
println("Message="+msg)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check
index cb0b9a6c8b..35cd04ba87 100644
--- a/test/files/run/repl-colon-type.check
+++ b/test/files/run/repl-colon-type.check
@@ -82,8 +82,10 @@ TypeRef(
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends Object)
args = List(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
- TypeRef(TypeSymbol(final class Boolean extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
+ TypeRef(
+ TypeSymbol(final abstract class Boolean extends AnyVal)
+ )
)
)
TypeRef(
@@ -92,7 +94,7 @@ TypeRef(
)
args = List(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
)
@@ -125,14 +127,14 @@ scala> :type -v def x = 1 ; def bar[T >: Null <: AnyRef](xyz: T) = 5
OverloadedType(
alts = List(
NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
PolyType(
typeParams = List(TypeParam(T >: Null <: AnyRef))
resultType = MethodType(
params = List(TermSymbol(xyz: T))
resultType = TypeRef(
- TypeSymbol(final class Int extends AnyVal)
+ TypeSymbol(final abstract class Int extends AnyVal)
)
)
)
@@ -147,7 +149,7 @@ Int => Iterator[List[Nothing]]
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends Object)
args = List(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
TypeRef(
TypeSymbol(
abstract trait Iterator[+A] extends TraversableOnce[A]
@@ -180,7 +182,7 @@ PolyType(
TypeRef(
TypeSymbol(abstract trait Function1[-T1, +R] extends Object)
args = List(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
TypeRef(
TypeSymbol(
abstract trait Iterator[+A] extends TraversableOnce[A]
diff --git a/test/files/run/repl-type-verbose.check b/test/files/run/repl-type-verbose.check
index 103ac3e64d..989c0735b0 100644
--- a/test/files/run/repl-type-verbose.check
+++ b/test/files/run/repl-type-verbose.check
@@ -11,7 +11,7 @@ scala> :type -v def f = 5
// Internal Type structure
NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
scala> :type -v def f() = 5
@@ -20,7 +20,9 @@ scala> :type -v def f() = 5
// Internal Type structure
NullaryMethodType(
- resultType = TypeRef(TypeSymbol(final class Int extends AnyVal))
+ resultType = TypeRef(
+ TypeSymbol(final abstract class Int extends AnyVal)
+ )
)
scala> :type -v def f[T] = 5
@@ -31,7 +33,7 @@ scala> :type -v def f[T] = 5
PolyType(
typeParams = List(TypeParam(T))
resultType = NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
@@ -43,7 +45,7 @@ scala> :type -v def f[T >: Null] = 5
PolyType(
typeParams = List(TypeParam(T >: Null))
resultType = NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
@@ -55,7 +57,7 @@ scala> :type -v def f[T <: String] = 5
PolyType(
typeParams = List(TypeParam(T <: String))
resultType = NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
@@ -67,7 +69,9 @@ scala> :type -v def f[T]() = 5
PolyType(
typeParams = List(TypeParam(T))
resultType = NullaryMethodType(
- resultType = TypeRef(TypeSymbol(final class Int extends AnyVal))
+ resultType = TypeRef(
+ TypeSymbol(final abstract class Int extends AnyVal)
+ )
)
)
@@ -79,7 +83,9 @@ scala> :type -v def f[T, U]() = 5
PolyType(
typeParams = List(TypeParam(T), TypeParam(U))
resultType = NullaryMethodType(
- resultType = TypeRef(TypeSymbol(final class Int extends AnyVal))
+ resultType = TypeRef(
+ TypeSymbol(final abstract class Int extends AnyVal)
+ )
)
)
@@ -93,7 +99,7 @@ PolyType(
resultType = NullaryMethodType(
resultType = NullaryMethodType(
resultType = TypeRef(
- TypeSymbol(final class Int extends AnyVal)
+ TypeSymbol(final abstract class Int extends AnyVal)
)
)
)
@@ -107,7 +113,7 @@ scala> :type -v def f[T, U <: T] = 5
PolyType(
typeParams = List(TypeParam(T), TypeParam(U <: T))
resultType = NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
@@ -123,7 +129,7 @@ PolyType(
resultType = MethodType(
params = List(TermSymbol(y: U))
resultType = TypeRef(
- TypeSymbol(final class Int extends AnyVal)
+ TypeSymbol(final abstract class Int extends AnyVal)
)
)
)
@@ -138,7 +144,9 @@ PolyType(
typeParams = List(TypeParam(T))
resultType = MethodType(
params = List(TermSymbol(implicit evidence$1: Ordering[T]))
- resultType = TypeRef(TypeSymbol(final class Int extends AnyVal))
+ resultType = TypeRef(
+ TypeSymbol(final abstract class Int extends AnyVal)
+ )
)
)
@@ -177,7 +185,7 @@ PolyType(
)
)
resultType = NullaryMethodType(
- TypeRef(TypeSymbol(final class Int extends AnyVal))
+ TypeRef(TypeSymbol(final abstract class Int extends AnyVal))
)
)
diff --git a/test/files/run/richs-msil.check b/test/files/run/richs-msil.check
deleted file mode 100644
index e628ad3998..0000000000
--- a/test/files/run/richs-msil.check
+++ /dev/null
@@ -1,66 +0,0 @@
-
-RichCharTest1:
-True
-True
-True
-False
-
-RichIntTest:
-10
-11
-12
-13
-0
-0
-
-RichStringTest1:
-s1: abc
-s2: abc\txyz\n
-s3: abc
- xyz
-s4: abc
- |xyz
-s5: abc
- #xyz
-
-RichStringTest2:
-s1: abc
-s2: abc\txyz\n
-s3: abc
- xyz
-s4: abc
- |xyz
-s5: abc
- #xyz
-
-RichStringTest3:
-s1: abc
-s2: abc\txyz\n
-s3: abc
- xyz
-s4: abc
- |xyz
-s5: abc
- #xyz
-
-RichStringTest4:
-s1: abc
-s2: abc\txyz\n
-s3: abc
- xyz
-s4: abc
-xyz
-s5: abc
- #xyz
-
-RichStringTest5:
-s1: abc
- xyz
-s2: abc
- xyz
-s3: abc
- xyz
-s4: abc
- |xyz
-s5: abc
-xyz
diff --git a/test/files/run/runtime-msil.check b/test/files/run/runtime-msil.check
deleted file mode 100644
index 70e7608a11..0000000000
--- a/test/files/run/runtime-msil.check
+++ /dev/null
@@ -1,64 +0,0 @@
-<<< Test0
-[False,True]
-[0,1,2]
-[3,4,5]
-[a,b,c]
-[6,7,8]
-[9,10,11]
-[12,13]
-[14,15]
-[string]
->>> Test0
-
-<<< Test1
-10
-14
-15
-16
-20
-23
-24
-25
-26
->>> Test1
-
-<<< Test2
-A
-M0
-N0
-
-A
-N0
-M0
-
-A
-M0
-M1
-N0
-
-A
-N0
-N1
-M0
-
->>> Test2
-
-<<< Test3
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
-Ok
->>> Test3
-
diff --git a/test/files/run/t5273_2a.check b/test/files/run/runtimeEval1.check
index d8263ee986..d8263ee986 100644
--- a/test/files/run/t5273_2a.check
+++ b/test/files/run/runtimeEval1.check
diff --git a/test/files/run/runtimeEval1.scala b/test/files/run/runtimeEval1.scala
new file mode 100644
index 0000000000..9497b52918
--- /dev/null
+++ b/test/files/run/runtimeEval1.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ val x = 2
+ println(x)
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/runtimeEval2.check b/test/files/run/runtimeEval2.check
new file mode 100644
index 0000000000..78c6baefdd
--- /dev/null
+++ b/test/files/run/runtimeEval2.check
@@ -0,0 +1 @@
+2
diff --git a/test/files/run/runtimeEval2.scala b/test/files/run/runtimeEval2.scala
new file mode 100644
index 0000000000..513b820129
--- /dev/null
+++ b/test/files/run/runtimeEval2.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ val x = 2
+ val outer = reify{reify{x}}
+ println(outer.eval.eval)
+} \ No newline at end of file
diff --git a/test/files/run/t0421-new.scala b/test/files/run/t0421-new.scala
index 7de6b7f2c4..8df5aa1992 100644
--- a/test/files/run/t0421-new.scala
+++ b/test/files/run/t0421-new.scala
@@ -1,7 +1,9 @@
+import scala.reflect.{ClassTag, classTag}
+
// ticket #421
object Test extends App {
- def transpose[A: ArrayTag](xss: Array[Array[A]]) = {
+ def transpose[A: ClassTag](xss: Array[Array[A]]) = {
for (i <- Array.range(0, xss(0).length)) yield
for (xs <- xss) yield xs(i)
}
@@ -27,4 +29,4 @@ object Test extends App {
println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deep.mkString("[", ",", "]"))
println(matmul(Array(Array(4)), Array(Array(6, 8))).deep.mkString("[", ",", "]"))
-}
+} \ No newline at end of file
diff --git a/test/files/run/t0677-new.scala b/test/files/run/t0677-new.scala
index bf7a3971dc..15c8b4aa19 100644
--- a/test/files/run/t0677-new.scala
+++ b/test/files/run/t0677-new.scala
@@ -1,8 +1,10 @@
+import scala.reflect.{ClassTag, classTag}
+
object Test extends App {
- class X[T: ArrayTag] {
+ class X[T: ClassTag] {
val a = Array.ofDim[T](3, 4)
}
val x = new X[String]
x.a(1)(2) = "hello"
assert(x.a(1)(2) == "hello")
-}
+} \ No newline at end of file
diff --git a/test/files/run/t1195-new.check b/test/files/run/t1195-new.check
index 554e3fd03d..4dd1661d1b 100644
--- a/test/files/run/t1195-new.check
+++ b/test/files/run/t1195-new.check
@@ -1,6 +1,6 @@
-ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
-ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
-ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
-ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
-ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
-ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
+Bar.type, underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+Bar, underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+Product with Serializable, underlying = Product with Serializable
+Bar.type, underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+Bar, underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+Product with Serializable, underlying = Product with Serializable
diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala
index 6f28a4a167..4edfb5073f 100644
--- a/test/files/run/t1195-new.scala
+++ b/test/files/run/t1195-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
object Test {
def f() = { case class Bar(x: Int); Bar }
def g() = { case class Bar(x: Int); Bar(5) }
@@ -7,7 +9,7 @@ object Test {
val g1 = g()
val h1 = h()
- def m[T: TypeTag](x: T) = println(typeTag[T] + ", underlying = " + typeTag[T].sym.typeSignature)
+ def m[T: TypeTag](x: T) = println(typeOf[T] + ", underlying = " + typeOf[T].typeSymbol.typeSignature)
def main(args: Array[String]): Unit = {
m(f)
@@ -23,4 +25,4 @@ class A1[T] {
class B1[U] {
def f = { case class D(x: Int) extends A1[String] ; new D(5) }
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/t2236-new.scala b/test/files/run/t2236-new.scala
index bbabe8e7d9..26d6945628 100644
--- a/test/files/run/t2236-new.scala
+++ b/test/files/run/t2236-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
class T[A](implicit val m:TypeTag[A])
class Foo
class Bar extends T[Foo]
@@ -14,4 +16,4 @@ object EvidenceTest {
implicit val e: E[T] = null
new B[T]{}
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala
index e0835a0a44..b919f13770 100644
--- a/test/files/run/t2886.scala
+++ b/test/files/run/t2886.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test {
def test(name: String, address: String) = null
@@ -6,4 +6,4 @@ object Test {
val tree = reify((x:String) => test(address=x,name=x)).tree
println(tree)
}
-}
+} \ No newline at end of file
diff --git a/test/files/run/t3507-new.check b/test/files/run/t3507-new.check
index 6e4fa4170e..b02c40fc26 100644
--- a/test/files/run/t3507-new.check
+++ b/test/files/run/t3507-new.check
@@ -1 +1 @@
-ConcreteTypeTag[_1.b.c.type]
+_1.b.c.type
diff --git a/test/files/run/t3507-new.scala b/test/files/run/t3507-new.scala
index c7a529e8b8..f045755b8f 100644
--- a/test/files/run/t3507-new.scala
+++ b/test/files/run/t3507-new.scala
@@ -1,3 +1,5 @@
+import scala.reflect.runtime.universe._
+
class A {
object b {
object c
@@ -9,7 +11,7 @@ object Test extends App {
var a: A = new A // mutable
val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential
- def mani[T: TypeTag](x: T) = println(typeTag[T])
+ def mani[T: TypeTag](x: T) = println(typeOf[T])
mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier
// --> _1 is not in scope here
} \ No newline at end of file
diff --git a/test/files/run/t4110-new.check b/test/files/run/t4110-new.check
index 28f220e1fe..5cbfb27f3e 100644
--- a/test/files/run/t4110-new.check
+++ b/test/files/run/t4110-new.check
@@ -1,2 +1,2 @@
-ConcreteTypeTag[Test.A with Test.B]
-ConcreteTypeTag[Test.A with Test.B]
+Test.A with Test.B
+Test.A with Test.B
diff --git a/test/files/run/t4110-new.scala b/test/files/run/t4110-new.scala
index 3285b82c61..24ecd66cce 100644
--- a/test/files/run/t4110-new.scala
+++ b/test/files/run/t4110-new.scala
@@ -1,5 +1,7 @@
+import scala.reflect.runtime.universe._
+
object Test extends App {
- def inferredType[T : TypeTag](v : T) = println(typeTag[T])
+ def inferredType[T : TypeTag](v : T) = println(typeOf[T])
trait A
trait B
diff --git a/test/files/run/t4216.check b/test/files/run/t4216.check
index ac19a98315..6f2684f42d 100644
--- a/test/files/run/t4216.check
+++ b/test/files/run/t4216.check
@@ -1,34 +1,37 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala> def f[A: ArrayTag](a: A) = java.util.Arrays.asList(Array(a): _*)
-f: [A](a: A)(implicit evidence$1: ArrayTag[A])java.util.List[A]
-
-scala> f(".")
-res0: java.util.List[String] = [.]
-
-scala> f(0)
-res1: java.util.List[Int] = [0]
-
-scala> def i(a: Int) = java.util.Arrays.asList(Array(a): _*)
-i: (a: Int)java.util.List[Int]
-
-scala> i(0)
-res2: java.util.List[Int] = [0]
-
-scala> def o(a: Any) = java.util.Arrays.asList(Array(a): _*)
-o: (a: Any)java.util.List[Any]
-
-scala> o(".")
-res3: java.util.List[Any] = [.]
-
-scala> class V(val a: Int) extends AnyVal
-defined class V
-
-scala> f(new V(0))
-res4: java.util.List[V] = [V@0]
-
-scala> o(new V(0))
-res5: java.util.List[Any] = [V@0]
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> import scala.reflect.ClassTag
+import scala.reflect.ClassTag
+
+scala> def f[A: ClassTag](a: A) = java.util.Arrays.asList(Array(a): _*)
+f: [A](a: A)(implicit evidence$1: scala.reflect.ClassTag[A])java.util.List[A]
+
+scala> f(".")
+res0: java.util.List[String] = [.]
+
+scala> f(0)
+res1: java.util.List[Int] = [0]
+
+scala> def i(a: Int) = java.util.Arrays.asList(Array(a): _*)
+i: (a: Int)java.util.List[Int]
+
+scala> i(0)
+res2: java.util.List[Int] = [0]
+
+scala> def o(a: Any) = java.util.Arrays.asList(Array(a): _*)
+o: (a: Any)java.util.List[Any]
+
+scala> o(".")
+res3: java.util.List[Any] = [.]
+
+scala> class V(val a: Int) extends AnyVal
+defined class V
+
+scala> f(new V(0))
+res4: java.util.List[V] = [V@0]
+
+scala> o(new V(0))
+res5: java.util.List[Any] = [V@0]
+
+scala>
diff --git a/test/files/run/t4216.scala b/test/files/run/t4216.scala
index 4ada8f48aa..ecaae5bea2 100644
--- a/test/files/run/t4216.scala
+++ b/test/files/run/t4216.scala
@@ -4,7 +4,8 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code =
"""
- |def f[A: ArrayTag](a: A) = java.util.Arrays.asList(Array(a): _*)
+ |import scala.reflect.ClassTag
+ |def f[A: ClassTag](a: A) = java.util.Arrays.asList(Array(a): _*)
|f(".")
|f(0)
|def i(a: Int) = java.util.Arrays.asList(Array(a): _*)
diff --git a/test/files/run/t5224.scala b/test/files/run/t5224.scala
index cf65f16457..600a4200bd 100644
--- a/test/files/run/t5224.scala
+++ b/test/files/run/t5224.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
class Foo(bar: String) extends annotation.ClassfileAnnotation
diff --git a/test/files/run/t5225_1.scala b/test/files/run/t5225_1.scala
index 5e1d3b1f17..917a239bdf 100644
--- a/test/files/run/t5225_1.scala
+++ b/test/files/run/t5225_1.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
val tree = reify{@transient @volatile var x = 2}.tree
diff --git a/test/files/run/t5225_2.scala b/test/files/run/t5225_2.scala
index 4cab640fe8..d1b607499c 100644
--- a/test/files/run/t5225_2.scala
+++ b/test/files/run/t5225_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
val tree = reify{def foo(@cloneable x: Int) = ""}.tree
diff --git a/test/files/run/t5229_1.scala b/test/files/run/t5229_1.scala
index 273079a89d..7e05b08348 100644
--- a/test/files/run/t5229_1.scala
+++ b/test/files/run/t5229_1.scala
@@ -1,7 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
object C
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5229_2.scala b/test/files/run/t5229_2.scala
index 85bf78ba31..75d7204911 100644
--- a/test/files/run/t5229_2.scala
+++ b/test/files/run/t5229_2.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -9,7 +12,7 @@ object Test extends App {
println(C.x)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5230.scala b/test/files/run/t5230.scala
index e0632f591c..5cd67766b4 100644
--- a/test/files/run/t5230.scala
+++ b/test/files/run/t5230.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -9,7 +12,7 @@ object Test extends App {
println(new C().x)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5256a.check b/test/files/run/t5256a.check
index 304f4ddd79..518663b3da 100644
--- a/test/files/run/t5256a.check
+++ b/test/files/run/t5256a.check
@@ -1,2 +1,6 @@
-A
-true
+class A
+A
+Object {
+ def <init>: <?>
+ def foo: <?>
+}
diff --git a/test/files/run/t5256a.scala b/test/files/run/t5256a.scala
index 05a935c770..84ef97b0d2 100644
--- a/test/files/run/t5256a.scala
+++ b/test/files/run/t5256a.scala
@@ -1,9 +1,11 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
-class A
+class A { def foo = ??? }
object Test extends App {
- val c = classToType(classOf[A])
+ val c = cm.classSymbol(classOf[A])
println(c)
- println(c.typeSymbol == classToSymbol(classOf[A]))
-}
+ println(c.fullName)
+ println(c.typeSignature)
+} \ No newline at end of file
diff --git a/test/files/run/t5256b.check b/test/files/run/t5256b.check
index 64f4c01166..d6015f2743 100644
--- a/test/files/run/t5256b.check
+++ b/test/files/run/t5256b.check
@@ -1,2 +1,6 @@
+class A
Test.A
-true \ No newline at end of file
+Object {
+ def <init>: <?>
+ def foo: <?>
+}
diff --git a/test/files/run/t5256b.scala b/test/files/run/t5256b.scala
index 5575211641..0ffab8a668 100644
--- a/test/files/run/t5256b.scala
+++ b/test/files/run/t5256b.scala
@@ -1,8 +1,10 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
object Test extends App {
- class A
- val c = classToType(classOf[A])
+ class A { def foo = ??? }
+ val c = cm.classSymbol(classOf[A])
println(c)
- println(c.typeSymbol == classToSymbol(classOf[A]))
-}
+ println(c.fullName)
+ println(c.typeSignature)
+} \ No newline at end of file
diff --git a/test/files/run/t5256c.check b/test/files/run/t5256c.check
new file mode 100644
index 0000000000..16bfc6c9d0
--- /dev/null
+++ b/test/files/run/t5256c.check
@@ -0,0 +1,6 @@
+class A$1
+Test.A$1
+java.lang.Object {
+ def foo(): Nothing
+ def <init>(): A$1
+}
diff --git a/test/files/run/t5256c.scala b/test/files/run/t5256c.scala
new file mode 100644
index 0000000000..d56215f6eb
--- /dev/null
+++ b/test/files/run/t5256c.scala
@@ -0,0 +1,12 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ {
+ class A { def foo = ??? }
+ val c = cm.classSymbol(classOf[A])
+ println(c)
+ println(c.fullName)
+ println(c.typeSignature)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t5256d.check b/test/files/run/t5256d.check
index 7924c15c5c..dd32c05a93 100644
--- a/test/files/run/t5256d.check
+++ b/test/files/run/t5256d.check
@@ -3,17 +3,29 @@ Type :help for more information.
scala>
-scala> import scala.reflect.mirror._
-import scala.reflect.mirror._
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
-scala> class A
+scala> import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.runtime.{currentMirror=>cm}
+
+scala> class A { def foo = ??? }
defined class A
-scala> val c = classToType(classOf[A])
-c: reflect.mirror.Type = A
+scala> val c = cm.classSymbol(classOf[A])
+c: reflect.runtime.universe.ClassSymbol = class A
+
+scala> println(c)
+class A
+
+scala> println(c.fullName)
+$line8.$read.$iw.$iw.$iw.$iw.A
-scala> println(c.typeSymbol == classToSymbol(classOf[A]))
-true
+scala> println(c.typeSignature)
+java.lang.Object {
+ def <init>: <?>
+ def foo: <?>
+}
scala>
diff --git a/test/files/run/t5256d.scala b/test/files/run/t5256d.scala
index 86404a9b63..24ac1eb316 100644
--- a/test/files/run/t5256d.scala
+++ b/test/files/run/t5256d.scala
@@ -2,9 +2,12 @@ import scala.tools.partest.ReplTest
object Test extends ReplTest {
def code = """
-import scala.reflect.mirror._
-class A
-val c = classToType(classOf[A])
-println(c.typeSymbol == classToSymbol(classOf[A]))
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+class A { def foo = ??? }
+val c = cm.classSymbol(classOf[A])
+println(c)
+println(c.fullName)
+println(c.typeSignature)
"""
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5256e.check b/test/files/run/t5256e.check
index e50f917e14..6c6de90acc 100644
--- a/test/files/run/t5256e.check
+++ b/test/files/run/t5256e.check
@@ -1,2 +1,6 @@
-C.this.A
-true \ No newline at end of file
+class A
+Test.C.A
+Object {
+ def <init>: <?>
+ def foo: <?>
+}
diff --git a/test/files/run/t5256e.scala b/test/files/run/t5256e.scala
index 9ed422ca44..f83546f2c0 100644
--- a/test/files/run/t5256e.scala
+++ b/test/files/run/t5256e.scala
@@ -1,9 +1,10 @@
-import scala.reflect.mirror._
-
-class C { class A }
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
object Test extends App {
- val c = classToType(classOf[C#A])
+ class C { class A { def foo = ??? } }
+ val c = cm.classSymbol(classOf[C#A])
println(c)
- println(c.typeSymbol == classToSymbol(classOf[C#A]))
-}
+ println(c.fullName)
+ println(c.typeSignature)
+} \ No newline at end of file
diff --git a/test/files/run/t5256f.check b/test/files/run/t5256f.check
index ad2f375d9a..c840793fd5 100644
--- a/test/files/run/t5256f.check
+++ b/test/files/run/t5256f.check
@@ -1,4 +1,12 @@
+class A1
Test.A1
-true
-Test.this.A2
-true
+Object {
+ def <init>: <?>
+ def foo: <?>
+}
+class A2
+Test.A2
+Object {
+ def <init>: <?>
+ def foo: <?>
+}
diff --git a/test/files/run/t5256f.scala b/test/files/run/t5256f.scala
index 45c80cbd63..80c7ad8018 100644
--- a/test/files/run/t5256f.scala
+++ b/test/files/run/t5256f.scala
@@ -1,19 +1,22 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
object Test extends App {
- class A1
+ class A1 { def foo = ??? }
- val c1 = classToType(classOf[A1])
+ val c1 = cm.classSymbol(classOf[A1])
println(c1)
- println(c1.typeSymbol == classToSymbol(classOf[A1]))
+ println(c1.fullName)
+ println(c1.typeSignature)
new Test
}
class Test {
- class A2
+ class A2 { def foo = ??? }
- val c2 = classToType(classOf[A2])
+ val c2 = cm.classSymbol(classOf[A2])
println(c2)
- println(c2.typeSymbol == classToSymbol(classOf[A2]))
+ println(c2.fullName)
+ println(c2.typeSignature)
}
diff --git a/test/files/run/t5256g.check b/test/files/run/t5256g.check
new file mode 100644
index 0000000000..5aac899694
--- /dev/null
+++ b/test/files/run/t5256g.check
@@ -0,0 +1,3 @@
+anonymous class $anon$1
+Test.$anon$1
+A with B{def <init>(): A with B}
diff --git a/test/files/run/t5256g.scala b/test/files/run/t5256g.scala
new file mode 100644
index 0000000000..358c18601a
--- /dev/null
+++ b/test/files/run/t5256g.scala
@@ -0,0 +1,13 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+class A
+trait B
+
+object Test extends App {
+ val mutant = new A with B
+ val c = cm.classSymbol(mutant.getClass)
+ println(c)
+ println(c.fullName)
+ println(c.typeSignature)
+}
diff --git a/test/files/run/t5256h.check b/test/files/run/t5256h.check
new file mode 100644
index 0000000000..2a6b292486
--- /dev/null
+++ b/test/files/run/t5256h.check
@@ -0,0 +1,7 @@
+anonymous class $anon$1
+Test.$anon$1
+java.lang.Object {
+ final private val x: Int
+ def x(): Int
+ def <init>(): java.lang.Object{def x(): Int}
+}
diff --git a/test/files/run/t5256h.scala b/test/files/run/t5256h.scala
new file mode 100644
index 0000000000..fd4ffd9b12
--- /dev/null
+++ b/test/files/run/t5256h.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+object Test extends App {
+ val mutant = new { val x = 2 }
+ val c = cm.classSymbol(mutant.getClass)
+ println(c)
+ println(c.fullName)
+ println(c.typeSignature)
+}
diff --git a/test/files/run/t5258a.scala b/test/files/run/t5258a.scala
index 127829c724..1b98b5920a 100644
--- a/test/files/run/t5258a.scala
+++ b/test/files/run/t5258a.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/files/run/t5266_1.scala b/test/files/run/t5266_1.scala
index ebb432be71..ee7ea6d335 100644
--- a/test/files/run/t5266_1.scala
+++ b/test/files/run/t5266_1.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -6,7 +9,7 @@ object Test extends App {
println(x)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
} \ No newline at end of file
diff --git a/test/files/run/t5266_2.scala b/test/files/run/t5266_2.scala
index 27c91c35a8..ca16f656ee 100644
--- a/test/files/run/t5266_2.scala
+++ b/test/files/run/t5266_2.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -7,7 +10,7 @@ object Test extends App {
println(y)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val evaluated = toolbox.runExpr(code.tree)
println("evaluated = " + evaluated)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5269.scala b/test/files/run/t5269.scala
index 9026090b29..dfdabdd6cc 100644
--- a/test/files/run/t5269.scala
+++ b/test/files/run/t5269.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -12,4 +13,4 @@ object Test extends App {
new X().println()
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5270.scala b/test/files/run/t5270.scala
index 476b610148..afd45a0875 100644
--- a/test/files/run/t5270.scala
+++ b/test/files/run/t5270.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -16,4 +17,4 @@ object Test extends App {
new X().println()
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5271_1.scala b/test/files/run/t5271_1.scala
index 20cafa6a08..9e2c7602b5 100644
--- a/test/files/run/t5271_1.scala
+++ b/test/files/run/t5271_1.scala
@@ -1,11 +1,15 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify {
case class C(foo: Int, bar: Int)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(code.tree)
println(code.eval)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5271_2.scala b/test/files/run/t5271_2.scala
index af6491407c..430738f4fb 100644
--- a/test/files/run/t5271_2.scala
+++ b/test/files/run/t5271_2.scala
@@ -1,4 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify {
@@ -7,7 +11,7 @@ object Test extends App {
println(c.foo * c.bar)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(code.tree)
println(code.eval)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5271_3.scala b/test/files/run/t5271_3.scala
index 646b10a8e5..f2ca2d496d 100644
--- a/test/files/run/t5271_3.scala
+++ b/test/files/run/t5271_3.scala
@@ -1,4 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify {
@@ -8,7 +12,7 @@ object Test extends App {
println(c.foo * c.bar == C.qwe)
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(code.tree)
println(code.eval)
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5271_4.scala b/test/files/run/t5271_4.scala
index e13a331d9c..f63e82bdbe 100644
--- a/test/files/run/t5271_4.scala
+++ b/test/files/run/t5271_4.scala
@@ -1,7 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
case object C
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5272_1.check b/test/files/run/t5272_1_newpatmat.check
index 9f8d6f24e7..9f8d6f24e7 100644
--- a/test/files/run/t5272_1.check
+++ b/test/files/run/t5272_1_newpatmat.check
diff --git a/test/files/run/t5272_1.scala b/test/files/run/t5272_1_newpatmat.scala
index 46472babf3..e8bb013248 100644
--- a/test/files/run/t5272_1.scala
+++ b/test/files/run/t5272_1_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -7,4 +8,4 @@ object Test extends App {
case _ => println("not okay")
}
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5272_1_oldpatmat.check b/test/files/run/t5272_1_oldpatmat.check
new file mode 100644
index 0000000000..9f8d6f24e7
--- /dev/null
+++ b/test/files/run/t5272_1_oldpatmat.check
@@ -0,0 +1 @@
+okay \ No newline at end of file
diff --git a/test/files/run/reify_maps.flags b/test/files/run/t5272_1_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/reify_maps.flags
+++ b/test/files/run/t5272_1_oldpatmat.flags
diff --git a/test/files/run/t5272_1_oldpatmat.scala b/test/files/run/t5272_1_oldpatmat.scala
new file mode 100644
index 0000000000..e8bb013248
--- /dev/null
+++ b/test/files/run/t5272_1_oldpatmat.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ 2 match {
+ case 2 => println("okay")
+ case _ => println("not okay")
+ }
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/t5272_2.check b/test/files/run/t5272_2_newpatmat.check
index 549f3f3af8..549f3f3af8 100644
--- a/test/files/run/t5272_2.check
+++ b/test/files/run/t5272_2_newpatmat.check
diff --git a/test/files/run/t5272_2.scala b/test/files/run/t5272_2_newpatmat.scala
index f5bab44205..be79cde18f 100644
--- a/test/files/run/t5272_2.scala
+++ b/test/files/run/t5272_2_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -6,4 +7,4 @@ object Test extends App {
case x => println("okay" + x)
}
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5272_2_oldpatmat.check b/test/files/run/t5272_2_oldpatmat.check
new file mode 100644
index 0000000000..549f3f3af8
--- /dev/null
+++ b/test/files/run/t5272_2_oldpatmat.check
@@ -0,0 +1 @@
+okay2 \ No newline at end of file
diff --git a/test/files/run/t5272_1.flags b/test/files/run/t5272_2_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/t5272_1.flags
+++ b/test/files/run/t5272_2_oldpatmat.flags
diff --git a/test/files/run/t5272_2_oldpatmat.scala b/test/files/run/t5272_2_oldpatmat.scala
new file mode 100644
index 0000000000..be79cde18f
--- /dev/null
+++ b/test/files/run/t5272_2_oldpatmat.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ 2 match {
+ case x => println("okay" + x)
+ }
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/t5273_1.check b/test/files/run/t5273_1_newpatmat.check
index 0cfbf08886..0cfbf08886 100644
--- a/test/files/run/t5273_1.check
+++ b/test/files/run/t5273_1_newpatmat.check
diff --git a/test/files/run/t5273_1.scala b/test/files/run/t5273_1_newpatmat.scala
index 1b491923b2..756f52e10b 100644
--- a/test/files/run/t5273_1.scala
+++ b/test/files/run/t5273_1_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -7,4 +8,4 @@ object Test extends App {
case _ => println("this is getting out of hand!")
}
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5273_1_oldpatmat.check b/test/files/run/t5273_1_oldpatmat.check
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/test/files/run/t5273_1_oldpatmat.check
@@ -0,0 +1 @@
+2
diff --git a/test/files/run/t5272_2.flags b/test/files/run/t5273_1_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/t5272_2.flags
+++ b/test/files/run/t5273_1_oldpatmat.flags
diff --git a/test/files/run/t5273_1_oldpatmat.scala b/test/files/run/t5273_1_oldpatmat.scala
new file mode 100644
index 0000000000..756f52e10b
--- /dev/null
+++ b/test/files/run/t5273_1_oldpatmat.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ List(1, 2, 3) match {
+ case foo :: bar :: _ => println(foo * bar)
+ case _ => println("this is getting out of hand!")
+ }
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/t5273_2a_newpatmat.check b/test/files/run/t5273_2a_newpatmat.check
new file mode 100644
index 0000000000..d8263ee986
--- /dev/null
+++ b/test/files/run/t5273_2a_newpatmat.check
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/test/files/run/t5273_2a.scala b/test/files/run/t5273_2a_newpatmat.scala
index 062ff79d11..c0d15496aa 100644
--- a/test/files/run/t5273_2a.scala
+++ b/test/files/run/t5273_2a_newpatmat.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
val foo :: bar :: _ = List(1, 2, 3)
println(foo * bar)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5273_2a_oldpatmat.check b/test/files/run/t5273_2a_oldpatmat.check
new file mode 100644
index 0000000000..d8263ee986
--- /dev/null
+++ b/test/files/run/t5273_2a_oldpatmat.check
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/test/files/run/t5273_1.flags b/test/files/run/t5273_2a_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/t5273_1.flags
+++ b/test/files/run/t5273_2a_oldpatmat.flags
diff --git a/test/files/run/t5273_2a_oldpatmat.scala b/test/files/run/t5273_2a_oldpatmat.scala
new file mode 100644
index 0000000000..c0d15496aa
--- /dev/null
+++ b/test/files/run/t5273_2a_oldpatmat.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ val foo :: bar :: _ = List(1, 2, 3)
+ println(foo * bar)
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/t5273_2b.flags b/test/files/run/t5273_2b.flags
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/run/t5273_2b.flags
+++ /dev/null
diff --git a/test/files/run/t5273_2b.check b/test/files/run/t5273_2b_newpatmat.check
index c551774ca5..c551774ca5 100644
--- a/test/files/run/t5273_2b.check
+++ b/test/files/run/t5273_2b_newpatmat.check
diff --git a/test/files/run/t5273_2b.scala b/test/files/run/t5273_2b_newpatmat.scala
index 82f1de89f7..31afd7e2ba 100644
--- a/test/files/run/t5273_2b.scala
+++ b/test/files/run/t5273_2b_newpatmat.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -6,4 +7,4 @@ object Test extends App {
val RegexParser(name, shortname, value) = "American Dollar 1USD | 2,8567 | sometext"
println("name = %s, shortname = %s, value = %s".format(name, shortname, value))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5273_2b_oldpatmat.check b/test/files/run/t5273_2b_oldpatmat.check
new file mode 100644
index 0000000000..c551774ca5
--- /dev/null
+++ b/test/files/run/t5273_2b_oldpatmat.check
@@ -0,0 +1 @@
+name = American Dollar, shortname = USD, value = 2,8567
diff --git a/test/files/run/t5273_2a.flags b/test/files/run/t5273_2b_oldpatmat.flags
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/t5273_2a.flags
+++ b/test/files/run/t5273_2b_oldpatmat.flags
diff --git a/test/files/run/t5273_2b_oldpatmat.scala b/test/files/run/t5273_2b_oldpatmat.scala
new file mode 100644
index 0000000000..31afd7e2ba
--- /dev/null
+++ b/test/files/run/t5273_2b_oldpatmat.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
+
+object Test extends App {
+ reify {
+ val RegexParser = """(.*) \d+([A-Z]+) \| (.*) \|.*""".r
+ val RegexParser(name, shortname, value) = "American Dollar 1USD | 2,8567 | sometext"
+ println("name = %s, shortname = %s, value = %s".format(name, shortname, value))
+ }.eval
+} \ No newline at end of file
diff --git a/test/files/run/t5274_1.scala b/test/files/run/t5274_1.scala
index 7ef332aa05..c1b842fd7f 100644
--- a/test/files/run/t5274_1.scala
+++ b/test/files/run/t5274_1.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -10,4 +11,4 @@ object Test extends App {
println("49! = " + f49)
println("50!/49! = " + (f50 / f49))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5274_2.scala b/test/files/run/t5274_2.scala
index 0b373b358f..17e3976c09 100644
--- a/test/files/run/t5274_2.scala
+++ b/test/files/run/t5274_2.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -47,4 +48,4 @@ object Test extends App {
sort(ar)
println(ar)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5275.scala b/test/files/run/t5275.scala
index 534672be3c..5c84df499f 100644
--- a/test/files/run/t5275.scala
+++ b/test/files/run/t5275.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
class C(val foo: Int)
println(new C(2).foo)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5276_1a.scala b/test/files/run/t5276_1a.scala
index a6e327c0e7..7f4b6ecb8d 100644
--- a/test/files/run/t5276_1a.scala
+++ b/test/files/run/t5276_1a.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
lazy val x = 2
println(x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5276_1b.scala b/test/files/run/t5276_1b.scala
index 1bc3e246c9..56e7dc1bf0 100644
--- a/test/files/run/t5276_1b.scala
+++ b/test/files/run/t5276_1b.scala
@@ -1,8 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
implicit lazy val x = 2
println(implicitly[Int])
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5276_2a.scala b/test/files/run/t5276_2a.scala
index cdd87ddc9e..af9272c693 100644
--- a/test/files/run/t5276_2a.scala
+++ b/test/files/run/t5276_2a.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -8,4 +9,4 @@ object Test extends App {
println(new C().x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5276_2b.scala b/test/files/run/t5276_2b.scala
index 2fac951731..b211901abe 100644
--- a/test/files/run/t5276_2b.scala
+++ b/test/files/run/t5276_2b.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -9,4 +10,4 @@ object Test extends App {
println(new C().y)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5277_1.scala b/test/files/run/t5277_1.scala
index f95e9ab6ec..a2d546579d 100644
--- a/test/files/run/t5277_1.scala
+++ b/test/files/run/t5277_1.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -11,4 +12,4 @@ object Test extends App {
println("10! = " + (10!))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5277_2.scala b/test/files/run/t5277_2.scala
index 5f1737f503..dd72452a7c 100644
--- a/test/files/run/t5277_2.scala
+++ b/test/files/run/t5277_2.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
@@ -8,4 +9,4 @@ object Test extends App {
println(p)
println(p(1))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5279.scala b/test/files/run/t5279.scala
index aab5588877..815c883732 100644
--- a/test/files/run/t5279.scala
+++ b/test/files/run/t5279.scala
@@ -1,7 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
println(new Integer(10))
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5334_1.scala b/test/files/run/t5334_1.scala
index 49dbea6b68..2b6418990a 100644
--- a/test/files/run/t5334_1.scala
+++ b/test/files/run/t5334_1.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -7,6 +10,6 @@ object Test extends App {
ret.asInstanceOf[Object]
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(toolbox.runExpr(code.tree))
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5334_2.scala b/test/files/run/t5334_2.scala
index c6a77158dd..815f78f951 100644
--- a/test/files/run/t5334_2.scala
+++ b/test/files/run/t5334_2.scala
@@ -1,4 +1,7 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
val code = reify {
@@ -7,6 +10,6 @@ object Test extends App {
ret.asInstanceOf[List[Any]]
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(toolbox.runExpr(code.tree))
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5335.scala b/test/files/run/t5335.scala
index a0fe6c5822..714846de21 100644
--- a/test/files/run/t5335.scala
+++ b/test/files/run/t5335.scala
@@ -1,7 +1,8 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
println(new {def x = 2}.x)
}.eval
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5415.scala b/test/files/run/t5415.scala
index c6552f69b3..c12e209bb7 100644
--- a/test/files/run/t5415.scala
+++ b/test/files/run/t5415.scala
@@ -2,9 +2,11 @@ object Test extends App{
case class Queryable2[T]() { def filter(predicate: T => Boolean) = ??? }
trait CoffeesTable{ def sales : Int }
val q = Queryable2[CoffeesTable]()
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{universe => ru}
val code = reify{q.filter(_.sales > 5)}
-
- val toolbox = mkToolBox()
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
+ val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(code.tree)
}
diff --git a/test/files/run/t5419.scala b/test/files/run/t5419.scala
index 5f11f5056c..686a79bafd 100644
--- a/test/files/run/t5419.scala
+++ b/test/files/run/t5419.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
class Foo extends annotation.StaticAnnotation
diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala
index ed1faf0429..9b8ba090fa 100644
--- a/test/files/run/t5423.scala
+++ b/test/files/run/t5423.scala
@@ -1,9 +1,11 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
final class table extends annotation.StaticAnnotation
@table class A
object Test extends App {
- val s = classToSymbol(classOf[A])
- println(s.annotations)
-}
+ val s = cm.classSymbol(classOf[A])
+ println(s.getAnnotations)
+} \ No newline at end of file
diff --git a/test/files/run/t5428.check b/test/files/run/t5428.check
new file mode 100644
index 0000000000..7b4b1d6558
--- /dev/null
+++ b/test/files/run/t5428.check
@@ -0,0 +1 @@
+Stack(8, 7, 6, 5, 4, 3) \ No newline at end of file
diff --git a/test/files/run/t5428.scala b/test/files/run/t5428.scala
new file mode 100644
index 0000000000..106bb7fc31
--- /dev/null
+++ b/test/files/run/t5428.scala
@@ -0,0 +1,29 @@
+
+
+
+import collection.mutable.{Stack, StackProxy}
+
+
+
+class A extends StackProxy[Int] {
+ val self = Stack[Int]()
+}
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val a = new A
+
+ a push 3
+ a push 4
+ a push 5
+
+ a.push(6, 7, 8)
+
+ println(a)
+
+ a pop
+ }
+
+}
diff --git a/test/files/run/t5704.check b/test/files/run/t5704.check
index 7b56bf2bfd..74c4610988 100644
--- a/test/files/run/t5704.check
+++ b/test/files/run/t5704.check
@@ -1 +1 @@
-String \ No newline at end of file
+java.lang.String
diff --git a/test/files/run/t5704.scala b/test/files/run/t5704.scala
index 8fd721d4e7..ddcbcc27b3 100644
--- a/test/files/run/t5704.scala
+++ b/test/files/run/t5704.scala
@@ -1,10 +1,13 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
class MyQuerycollection{
def findUserByName( name:String ) = {
val tree = reify{ "test" == name }.tree
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
toolbox.typeCheck(tree) match{
case Apply(Select(lhs,op),rhs::Nil) =>
println(rhs.tpe)
@@ -13,4 +16,4 @@ object Test extends App {
}
val qc = new MyQuerycollection
qc.findUserByName("some value")
-}
+} \ No newline at end of file
diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala
index b499bc7e4e..d16299a0c8 100644
--- a/test/files/run/t5713/Impls_Macros_1.scala
+++ b/test/files/run/t5713/Impls_Macros_1.scala
@@ -19,9 +19,10 @@ private object LoggerMacros {
log(c)(c.reify(Level.Error), message)
private def log(c: LoggerContext)(level: c.Expr[Level.Value], message: c.Expr[String]): c.Expr[Unit] =
- if (level.eval.id < 4) // TODO Remove hack!
+// was: if (level.splice.id < 4) // TODO Remove hack!
+ if (c.eval(level).id < 4) // TODO Remove hack!
c.reify(())
else {
- c.reify(println(message.eval))
+ c.reify(println(message.splice))
}
} \ No newline at end of file
diff --git a/test/files/run/t5843.check b/test/files/run/t5843.check
new file mode 100644
index 0000000000..2bf97f4cdb
--- /dev/null
+++ b/test/files/run/t5843.check
@@ -0,0 +1,9 @@
+ foo="1"
+ bar="2" foo="1"
+null
+ bar="2"
+ foo="1"
+ bar="2"
+ foo="1"
+ bar="2" foo="1"
+ bar="2" foo="1"
diff --git a/test/files/run/t5843.scala b/test/files/run/t5843.scala
new file mode 100644
index 0000000000..43d588c7b7
--- /dev/null
+++ b/test/files/run/t5843.scala
@@ -0,0 +1,15 @@
+object Test extends App {
+ val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null)
+ val bar = scala.xml.Attribute(null, "bar", "2", foo)
+ println(foo)
+ println(bar)
+ println(scala.xml.TopScope.getURI(foo.pre))
+ println(bar remove "foo")
+ println(bar remove "bar")
+ println(bar remove (null, scala.xml.TopScope, "foo"))
+ println(bar remove (null, scala.xml.TopScope, "bar"))
+
+ val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope)
+ println(bar remove (null, ns, "foo"))
+ println(bar remove (null, ns, "bar"))
+}
diff --git a/test/files/run/t5857.scala b/test/files/run/t5857.scala
new file mode 100644
index 0000000000..bf67bedf54
--- /dev/null
+++ b/test/files/run/t5857.scala
@@ -0,0 +1,45 @@
+
+
+
+object Test {
+
+ def time[U](b: =>U): Long = {
+ val start = System.currentTimeMillis
+ b
+ val end = System.currentTimeMillis
+
+ end - start
+ }
+
+ def main(args: Array[String]) {
+ val sz = 1000000000
+
+ val range = 1 to sz
+ check { assert(range.min == 1, range.min) }
+ check { assert(range.max == sz, range.max) }
+
+ val descending = sz to 1 by -1
+ check { assert(descending.min == 1) }
+ check { assert(descending.max == sz) }
+
+ val numeric = 1.0 to sz.toDouble by 1
+ check { assert(numeric.min == 1.0) }
+ check { assert(numeric.max == sz.toDouble) }
+
+ val numdesc = sz.toDouble to 1.0 by -1
+ check { assert(numdesc.min == 1.0) }
+ check { assert(numdesc.max == sz.toDouble) }
+ }
+
+ def check[U](b: =>U) {
+ val exectime = time {
+ b
+ }
+
+ // whatever it is, it should be less than, say, 250ms
+ // if `max` involves traversal, it takes over 5 seconds on a 3.2GHz i7 CPU
+ //println(exectime)
+ assert(exectime < 250, exectime)
+ }
+
+}
diff --git a/test/files/run/t5867.check b/test/files/run/t5867.check
new file mode 100644
index 0000000000..e1811eeefa
--- /dev/null
+++ b/test/files/run/t5867.check
@@ -0,0 +1 @@
+UnrolledBuffer(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50) \ No newline at end of file
diff --git a/test/files/run/t5867.scala b/test/files/run/t5867.scala
new file mode 100644
index 0000000000..6a86ac3e6d
--- /dev/null
+++ b/test/files/run/t5867.scala
@@ -0,0 +1,14 @@
+import collection.mutable.UnrolledBuffer
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val buf = UnrolledBuffer(1 to 50: _*)
+ val dub = buf ++ buf
+
+ println(dub)
+ }
+
+}
diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check
new file mode 100644
index 0000000000..b6cbda35a7
--- /dev/null
+++ b/test/files/run/t5879.check
@@ -0,0 +1,16 @@
+Map(1 -> 1)
+1
+Map(1 -> 1)
+1
+(1,1)
+Map(1 -> 1)
+1
+(1,1)
+Map(1 -> 1)
+1
+(1,2)
+Map(1 -> 2)
+2
+(1,2)
+Map(1 -> 2)
+2 \ No newline at end of file
diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala
new file mode 100644
index 0000000000..e1c07fc4c2
--- /dev/null
+++ b/test/files/run/t5879.scala
@@ -0,0 +1,74 @@
+import collection.immutable.HashMap
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ resolveDefault()
+ resolveFirst()
+ resolveSecond()
+ resolveMany()
+ }
+
+ def resolveDefault() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+
+ val r = a.merged(b)(null)
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveFirst() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+ def collision(a: (Int, String), b: (Int, String)) = {
+ println(a)
+ a
+ }
+
+ val r = a.merged(b) { collision }
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b, collision)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveSecond() {
+ val a = HashMap(1 -> "1")
+ val b = HashMap(1 -> "2")
+ def collision(a: (Int, String), b: (Int, String)) = {
+ println(b)
+ b
+ }
+
+ val r = a.merged(b) { collision }
+ println(r)
+ println(r(1))
+
+ val rold = a.merge(b, collision)
+ println(rold)
+ println(rold(1))
+ }
+
+ def resolveMany() {
+ val a = HashMap((0 until 100) zip (0 until 100): _*)
+ val b = HashMap((0 until 100) zip (100 until 200): _*)
+ def collision(a: (Int, Int), b: (Int, Int)) = {
+ (a._1, a._2 + b._2)
+ }
+
+ val r = a.merged(b) { collision }
+ for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v))
+
+ val rold = a.merge(b, collision)
+ for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v))
+ }
+
+}
diff --git a/test/files/run/t5880.scala b/test/files/run/t5880.scala
new file mode 100644
index 0000000000..4cda599f79
--- /dev/null
+++ b/test/files/run/t5880.scala
@@ -0,0 +1,41 @@
+
+
+import scala.collection.JavaConversions._
+
+
+
+object Test {
+
+ def main(args:Array[String]) = {
+ val tests = 5000
+ val jm: java.util.Map[Int, Int] = scala.collection.mutable.Map((0 until tests) zip (0 until tests).reverse: _*)
+ val es = jm.entrySet()
+ val it = es.iterator
+
+ // chi square test
+ val groups = 10
+ val hits = new Array[Int](groups)
+ def hit(hc: Int) {
+ val bucket = math.abs(hc) / (Int.MaxValue / groups)
+ hits(bucket) += 1
+ }
+ def expected = tests / groups
+ def Dstat = {
+ val diffs = for (i <- 0 until groups) yield math.abs(hits(i) - expected)
+ diffs.sum.toDouble / expected
+ }
+ def ChiSquare = {
+ val diffs = for (i <- 0 until groups) yield (hits(i) - expected) * (hits(i) - expected)
+ diffs.sum.toDouble / expected
+ }
+
+ while (it.hasNext) {
+ val x = it.next()
+ hit(x.##)
+ }
+ // println(hits.toBuffer)
+ // println(ChiSquare)
+ assert(ChiSquare < 4.0, ChiSquare + " -> " + hits.mkString(", "))
+ }
+
+}
diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala
index 1da9a6bc16..c5b788550e 100644
--- a/test/files/run/toolbox_console_reporter.scala
+++ b/test/files/run/toolbox_console_reporter.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
// todo. cannot test this unfortunately, because ConsoleFrontEnd grabs Console.out too early
@@ -13,4 +13,4 @@ object Test extends App {
//
// Utils.foo
//})
-}
+} \ No newline at end of file
diff --git a/test/files/run/toolbox_default_reporter_is_silent.scala b/test/files/run/toolbox_default_reporter_is_silent.scala
index 6908c001a3..5f3269b6fa 100644
--- a/test/files/run/toolbox_default_reporter_is_silent.scala
+++ b/test/files/run/toolbox_default_reporter_is_silent.scala
@@ -1,7 +1,10 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
toolbox.runExpr(reify{
object Utils {
@deprecated("test", "2.10.0")
@@ -10,4 +13,4 @@ object Test extends App {
Utils.foo
}.tree)
-}
+} \ No newline at end of file
diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala
index 6f5687ba4f..915734e6ad 100644
--- a/test/files/run/toolbox_silent_reporter.scala
+++ b/test/files/run/toolbox_silent_reporter.scala
@@ -1,7 +1,10 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
- val toolbox = mkToolBox(options = "-deprecation")
+ val toolbox = cm.mkToolBox(options = "-deprecation")
toolbox.runExpr(reify{
object Utils {
@deprecated("test", "2.10.0")
diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.check b/test/files/run/toolbox_typecheck_implicitsdisabled.check
index 4bc64530ab..e2f2dbe4b9 100644
--- a/test/files/run/toolbox_typecheck_implicitsdisabled.check
+++ b/test/files/run/toolbox_typecheck_implicitsdisabled.check
@@ -2,4 +2,4 @@
import scala.Predef._;
scala.Predef.any2ArrowAssoc[Int](1).->[Int](2)
}
-scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective typecheck has failed: value -> is not a member of Int
+scala.tools.reflect.ToolBoxError: reflective typecheck has failed: value -> is not a member of Int
diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala
index 9d52e91f73..f11f0192f3 100644
--- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala
+++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala
@@ -1,7 +1,10 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val tree1 = Block(
Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1))),
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check
index c4af175812..f4a67e3054 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.check
@@ -1,5 +1,37 @@
{
- val $mr: mr.type = mr;
- $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2)), classOf[scala.Int]))
+ val $u: ru.type = ru;
+ val $m: $u.Mirror = ru.rootMirror;
+ $u.Expr.apply[Int(2)]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $treecreator1.this.applyImpl[$u.type]($m).asInstanceOf[U#Tree]
+ };
+ private def applyImpl[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): scala.reflect.base.Universe#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Literal.apply($u.Constant.apply(2))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Int(2)]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.ConstantType.apply($u.Constant.apply(2))
+ }
+ };
+ new $typecreator2()
+ }))
}
-mr.reify[Int](2)
+ru.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala
index afbbce1736..bcbd637e02 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.scala
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala
@@ -1,17 +1,20 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
- val toolbox = mkToolBox()
- val mrPkg = staticModule("scala.reflect.package")
- val mrSym = selectTerm(mrPkg, "mirror")
- val NullaryMethodType(mrTpe) = mrSym.typeSignature
- val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror)
+ val toolbox = cm.mkToolBox()
+ val rupkg = cm.staticModule("scala.reflect.runtime.package")
+ val rusym = build.selectTerm(rupkg, "universe")
+ val NullaryMethodType(rutpe) = rusym.typeSignature
+ val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe)
- val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2))))
+ val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2))))
val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false)
println(ttree1)
- val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2))))
+ val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2))))
val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true)
println(ttree2)
-}
+} \ No newline at end of file
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check
index 271139b031..2e1e2696ab 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check
@@ -1,5 +1,37 @@
{
- val $mr: mr.type = mr;
- $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+ val $u: ru.type = ru;
+ val $m: $u.Mirror = ru.rootMirror;
+ $u.Expr.apply[Array[Int]]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $treecreator1.this.applyImpl[$u.type]($m).asInstanceOf[U#Tree]
+ };
+ private def applyImpl[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): scala.reflect.base.Universe#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticModule("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Array[Int]]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.TypeRef.apply($u.ThisType.apply($m.staticModule("scala").asModuleSymbol.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asTypeSymbol.asTypeConstructor))
+ }
+ };
+ new $typecreator2()
+ }))
}
-mr.reify[Array[Int]](scala.Array.apply(2))
+ru.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala
index b4c76d0600..51493ffc1c 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala
@@ -1,17 +1,20 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
- val toolbox = mkToolBox()
- val mrPkg = staticModule("scala.reflect.package")
- val mrSym = selectTerm(mrPkg, "mirror")
- val NullaryMethodType(mrTpe) = mrSym.typeSignature
- val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror)
+ val toolbox = cm.mkToolBox()
+ val rupkg = cm.staticModule("scala.reflect.runtime.package")
+ val rusym = build.selectTerm(rupkg, "universe")
+ val NullaryMethodType(rutpe) = rusym.typeSignature
+ val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe)
- val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
+ val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false)
println(ttree1)
- val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
+ val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2))))))
val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true)
println(ttree2)
}
diff --git a/test/files/run/triemap-hash.scala b/test/files/run/triemap-hash.scala
new file mode 100644
index 0000000000..7f19997da0
--- /dev/null
+++ b/test/files/run/triemap-hash.scala
@@ -0,0 +1,46 @@
+
+
+
+import util.hashing.Hashing
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ hashing()
+ equality()
+ }
+
+ def hashing() {
+ import collection._
+
+ val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x.length + x(0).toInt), Equiv.universal)
+ tm.put("a", "b")
+ tm.put("c", "d")
+
+ assert(tm("a") == "b")
+ assert(tm("c") == "d")
+
+ for (i <- 0 until 1000) tm(i.toString) = i.toString
+ for (i <- 0 until 1000) assert(tm(i.toString) == i.toString)
+ }
+
+ def equality() {
+ import collection._
+
+ val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x(0).toInt), Equiv.fromFunction(_(0) == _(0)))
+ tm.put("a", "b")
+ tm.put("a1", "d")
+ tm.put("b", "c")
+
+ assert(tm("a") == "d", tm)
+ assert(tm("b") == "c", tm)
+
+ for (i <- 0 until 1000) tm(i.toString) = i.toString
+ assert(tm.size == 12, tm)
+ assert(tm("0") == "0", tm)
+ for (i <- 1 to 9) assert(tm(i.toString) == i.toString + "99", tm)
+ }
+
+}
diff --git a/test/files/run/tuples-msil.check b/test/files/run/tuples-msil.check
deleted file mode 100644
index e56a796667..0000000000
--- a/test/files/run/tuples-msil.check
+++ /dev/null
@@ -1,2 +0,0 @@
-(1,abc,True)
-OK
diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check
deleted file mode 100644
index f124aa6a35..0000000000
--- a/test/files/run/typetags_core.check
+++ /dev/null
@@ -1,32 +0,0 @@
-true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
-true
-ConcreteTypeTag[String]
diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala
deleted file mode 100644
index 7d6be16379..0000000000
--- a/test/files/run/typetags_core.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-object Test extends App {
- println(implicitly[TypeTag[Byte]] eq TypeTag.Byte)
- println(implicitly[TypeTag[Byte]])
- println(implicitly[TypeTag[Short]] eq TypeTag.Short)
- println(implicitly[TypeTag[Short]])
- println(implicitly[TypeTag[Char]] eq TypeTag.Char)
- println(implicitly[TypeTag[Char]])
- println(implicitly[TypeTag[Int]] eq TypeTag.Int)
- println(implicitly[TypeTag[Int]])
- println(implicitly[TypeTag[Long]] eq TypeTag.Long)
- println(implicitly[TypeTag[Long]])
- println(implicitly[TypeTag[Float]] eq TypeTag.Float)
- println(implicitly[TypeTag[Float]])
- println(implicitly[TypeTag[Double]] eq TypeTag.Double)
- println(implicitly[TypeTag[Double]])
- println(implicitly[TypeTag[Boolean]] eq TypeTag.Boolean)
- println(implicitly[TypeTag[Boolean]])
- println(implicitly[TypeTag[Unit]] eq TypeTag.Unit)
- println(implicitly[TypeTag[Unit]])
- println(implicitly[TypeTag[Any]] eq TypeTag.Any)
- println(implicitly[TypeTag[Any]])
- println(implicitly[TypeTag[Object]] eq TypeTag.Object)
- println(implicitly[TypeTag[Object]])
- println(implicitly[TypeTag[AnyVal]] eq TypeTag.AnyVal)
- println(implicitly[TypeTag[AnyVal]])
- println(implicitly[TypeTag[AnyRef]] eq TypeTag.AnyRef)
- println(implicitly[TypeTag[AnyRef]])
- println(implicitly[TypeTag[Null]] eq TypeTag.Null)
- println(implicitly[TypeTag[Null]])
- println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing)
- println(implicitly[TypeTag[Nothing]])
- println(implicitly[TypeTag[String]] eq TypeTag.String)
- println(implicitly[TypeTag[String]])
-} \ No newline at end of file
diff --git a/test/files/run/typetags_multi.check b/test/files/run/typetags_multi.check
deleted file mode 100644
index 613106985c..0000000000
--- a/test/files/run/typetags_multi.check
+++ /dev/null
@@ -1,5 +0,0 @@
-ConcreteTypeTag[Int]
-ConcreteTypeTag[Array[Int]]
-ConcreteTypeTag[Array[Array[Int]]]
-ConcreteTypeTag[Array[Array[Array[Int]]]]
-ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/typetags_multi.scala b/test/files/run/typetags_multi.scala
deleted file mode 100644
index 868edc2b2a..0000000000
--- a/test/files/run/typetags_multi.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-object Test extends App {
- println(typeTag[Int])
- println(typeTag[Array[Int]])
- println(typeTag[Array[Array[Int]]])
- println(typeTag[Array[Array[Array[Int]]]])
- println(typeTag[Array[Array[Array[Array[Int]]]]])
-} \ No newline at end of file
diff --git a/test/files/run/virtpatmat_typetag.check b/test/files/run/virtpatmat_typetag.check
new file mode 100644
index 0000000000..f9800b84d0
--- /dev/null
+++ b/test/files/run/virtpatmat_typetag.check
@@ -0,0 +1,10 @@
+1 is not a ClassTag[int]; it's a class java.lang.Integer
+1 is a ClassTag[class java.lang.Integer]
+1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer
+true is a ClassTag[class java.lang.Object]
+woele is a ClassTag[class java.lang.String]
+1 is not a ClassTag[int]; it's a class java.lang.Integer
+1 is a ClassTag[class java.lang.Integer]
+1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer
+true is a ClassTag[class java.lang.Object]
+woele is a ClassTag[class java.lang.String]
diff --git a/test/files/run/virtpatmat_typetag.flags b/test/files/run/virtpatmat_typetag.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/run/virtpatmat_typetag.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/run/virtpatmat_typetag.scala b/test/files/run/virtpatmat_typetag.scala
new file mode 100644
index 0000000000..c1b1fd813a
--- /dev/null
+++ b/test/files/run/virtpatmat_typetag.scala
@@ -0,0 +1,36 @@
+import reflect.{ClassTag, classTag}
+
+trait Extractors {
+ type T
+ implicit val tTag: ClassTag[T]
+ object ExtractT {
+ def unapply(x: T) = Some(x)
+ }
+ def apply(a: Any) = a match {
+ case ExtractT(x) => println(x +" is a "+ implicitly[ClassTag[T]])
+ case _ => println(a+ " is not a "+ implicitly[ClassTag[T]] +"; it's a "+ a.getClass)
+ }
+}
+
+object Test extends App {
+ def typeMatch[T: ClassTag](a: Any) = a match {
+ case x : T => println(x +" is a "+ implicitly[ClassTag[T]])
+ case _ => println(a+ " is not a "+ implicitly[ClassTag[T]] +"; it's a "+ a.getClass)
+ }
+
+ // the same match as typeMatch, but using an extractor
+ def extractorMatch[S: ClassTag](a: Any) =
+ (new Extractors { type T = S; val tTag = classTag[T] })(a)
+
+ typeMatch[Int](1)
+ typeMatch[Integer](1)
+ typeMatch[String](1)
+ typeMatch[Any](true)
+ typeMatch[String]("woele")
+
+ extractorMatch[Int](1)
+ extractorMatch[Integer](1)
+ extractorMatch[String](1)
+ extractorMatch[Any](true)
+ extractorMatch[String]("woele")
+} \ No newline at end of file
diff --git a/test/files/scalacheck/array-new.scala b/test/files/scalacheck/array-new.scala
index 18d577ca6d..e13a47a5d5 100644
--- a/test/files/scalacheck/array-new.scala
+++ b/test/files/scalacheck/array-new.scala
@@ -1,3 +1,4 @@
+import scala.reflect.{ClassTag, classTag}
import org.scalacheck._
import Prop._
import Gen._
@@ -9,7 +10,7 @@ import scala.collection.mutable.ArraySeq
object Test extends Properties("Array") {
/** At this moment the authentic scalacheck Array Builder/Arb bits are commented out.
*/
- implicit def arbArray[T](implicit a: Arbitrary[T], m: ArrayTag[T]): Arbitrary[Array[T]] =
+ implicit def arbArray[T](implicit a: Arbitrary[T], m: ClassTag[T]): Arbitrary[Array[T]] =
Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray))
val arrGen: Gen[Array[_]] = oneOf(
@@ -33,4 +34,4 @@ object Test extends Properties("Array") {
val flattened = arr flatMap (x => x) flatMap (x => x)
flattened.length == i1 * i2 * i3
}
-}
+} \ No newline at end of file
diff --git a/test/files/specialized/spec-matrix-new.scala b/test/files/specialized/spec-matrix-new.scala
index 65b46e8d48..e9a6e35219 100644
--- a/test/files/specialized/spec-matrix-new.scala
+++ b/test/files/specialized/spec-matrix-new.scala
@@ -1,7 +1,9 @@
+import scala.reflect.{ClassTag, classTag}
+
/** Test matrix multiplication with specialization.
*/
-class Matrix[@specialized A: ArrayTag](val rows: Int, val cols: Int) {
+class Matrix[@specialized A: ClassTag](val rows: Int, val cols: Int) {
private val arr: Array[Array[A]] = Array.ofDim[A](rows, cols)
def apply(i: Int, j: Int): A = {
@@ -52,7 +54,7 @@ object Test {
}
}
- def multTag[@specialized(Int) T](m: Matrix[T], n: Matrix[T])(implicit at: ArrayTag[T], num: Numeric[T]) {
+ def multTag[@specialized(Int) T](m: Matrix[T], n: Matrix[T])(implicit at: ClassTag[T], num: Numeric[T]) {
val p = new Matrix[T](m.rows, n.cols)
import num._
@@ -77,4 +79,4 @@ object Test {
}
p
}
-}
+} \ No newline at end of file
diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1
index a7da67429e..24856fe19a 100644
--- a/test/files/speclib/instrumented.jar.desired.sha1
+++ b/test/files/speclib/instrumented.jar.desired.sha1
@@ -1 +1 @@
-15f200d9f0f25f9fd871bad2ebb4ba5cfc671db4 ?instrumented.jar
+474d8c20ab31438d5d4a2ba6bc07ebdcdb530b50 ?instrumented.jar
diff --git a/test/instrumented/library/scala/runtime/ScalaRunTime.scala b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
index 63908fcc29..5a3f83015f 100644
--- a/test/instrumented/library/scala/runtime/ScalaRunTime.scala
+++ b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
@@ -14,6 +14,7 @@ import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator }
import scala.collection.mutable.WrappedArray
import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: }
import scala.collection.generic.{ Sorted }
+import scala.reflect.{ ClassTag, classTag }
import scala.util.control.ControlThrowable
import scala.xml.{ Node, MetaData }
@@ -61,8 +62,7 @@ object ScalaRunTime {
*/
def arrayElementClass(schematic: Any): Class[_] = schematic match {
case cls: Class[_] => cls.getComponentType
- case tag: ClassTag[_] => tag.erasure
- case tag: ArrayTag[_] => tag.newArray(0).getClass.getComponentType
+ case tag: ClassTag[_] => tag.runtimeClass
case _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass))
}
@@ -71,7 +71,7 @@ object ScalaRunTime {
* rewrites expressions like 5.getClass to come here.
*/
def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] =
- classTag[T].erasure.asInstanceOf[Class[T]]
+ classTag[T].runtimeClass.asInstanceOf[Class[T]]
var arrayApplyCount = 0
@@ -142,16 +142,18 @@ object ScalaRunTime {
case null => throw new NullPointerException
}
- /** Convert a numeric value array to an object array.
+ /** Convert an array to an object array.
* Needed to deal with vararg arguments of primitive types that are passed
* to a generic Java vararg parameter T ...
*/
- def toObjectArray(src: AnyRef): Array[Object] = {
- val length = array_length(src)
- val dest = new Array[Object](length)
- for (i <- 0 until length)
- array_update(dest, i, array_apply(src, i))
- dest
+ def toObjectArray(src: AnyRef): Array[Object] = src match {
+ case x: Array[AnyRef] => x
+ case _ =>
+ val length = array_length(src)
+ val dest = new Array[Object](length)
+ for (i <- 0 until length)
+ array_update(dest, i, array_apply(src, i))
+ dest
}
def toArray[T](xs: collection.Seq[T]) = {
@@ -305,8 +307,12 @@ object ScalaRunTime {
*/
def stringOf(arg: Any): String = stringOf(arg, scala.Int.MaxValue)
def stringOf(arg: Any, maxElements: Int): String = {
- def isScalaClass(x: AnyRef) =
- Option(x.getClass.getPackage) exists (_.getName startsWith "scala.")
+ def packageOf(x: AnyRef) = x.getClass.getPackage match {
+ case null => ""
+ case p => p.getName
+ }
+ def isScalaClass(x: AnyRef) = packageOf(x) startsWith "scala."
+ def isScalaCompilerClass(x: AnyRef) = packageOf(x) startsWith "scala.tools.nsc."
// When doing our own iteration is dangerous
def useOwnToString(x: Any) = x match {
@@ -322,7 +328,8 @@ object ScalaRunTime {
case _: TraversableView[_, _] => true
// Don't want to a) traverse infinity or b) be overly helpful with peoples' custom
// collections which may have useful toString methods - ticket #3710
- case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x)
+ // or c) print AbstractFiles which are somehow also Iterable[AbstractFile]s.
+ case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x) || isScalaCompilerClass(x)
// Otherwise, nothing could possibly go wrong
case _ => false
}
diff --git a/test/instrumented/srt.patch b/test/instrumented/srt.patch
index 8d08550165..47dcfa2197 100644
--- a/test/instrumented/srt.patch
+++ b/test/instrumented/srt.patch
@@ -1,26 +1,67 @@
-9a10,11
+8a9,10
> /* INSTRUMENTED VERSION */
->
-43c45,48
-< def isTuple(x: Any) = x != null && tupleNames(x.getClass.getName)
----
+>
+73a76,77
> var arrayApplyCount = 0
-> var arrayUpdateCount = 0
->
-> def isTuple(x: Any) = tupleNames(x.getClass.getName)
-75c80,82
+>
+75,86c79,93
< def array_apply(xs: AnyRef, idx: Int): Any = xs match {
+< case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+< case x: Array[Int] => x(idx).asInstanceOf[Any]
+< case x: Array[Double] => x(idx).asInstanceOf[Any]
+< case x: Array[Long] => x(idx).asInstanceOf[Any]
+< case x: Array[Float] => x(idx).asInstanceOf[Any]
+< case x: Array[Char] => x(idx).asInstanceOf[Any]
+< case x: Array[Byte] => x(idx).asInstanceOf[Any]
+< case x: Array[Short] => x(idx).asInstanceOf[Any]
+< case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+< case x: Array[Unit] => x(idx).asInstanceOf[Any]
+< case null => throw new NullPointerException
---
> def array_apply(xs: AnyRef, idx: Int): Any = {
> arrayApplyCount += 1
> xs match {
-87a95
-> }
-90c98,100
+> case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+> case x: Array[Int] => x(idx).asInstanceOf[Any]
+> case x: Array[Double] => x(idx).asInstanceOf[Any]
+> case x: Array[Long] => x(idx).asInstanceOf[Any]
+> case x: Array[Float] => x(idx).asInstanceOf[Any]
+> case x: Array[Char] => x(idx).asInstanceOf[Any]
+> case x: Array[Byte] => x(idx).asInstanceOf[Any]
+> case x: Array[Short] => x(idx).asInstanceOf[Any]
+> case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+> case x: Array[Unit] => x(idx).asInstanceOf[Any]
+> case null => throw new NullPointerException
+> }
+88a96,97
+> var arrayUpdateCount = 0
+>
+90,101c99,113
< def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match {
+< case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+< case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+< case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+< case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+< case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+< case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+< case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+< case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+< case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+< case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+< case null => throw new NullPointerException
---
> def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
> arrayUpdateCount += 1
> xs match {
-101a112
-> }
+> case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+> case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+> case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+> case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+> case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+> case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+> case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+> case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+> case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+> case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+> case null => throw new NullPointerException
+> }
diff --git a/test/partest b/test/partest
index ebf6891fdc..8352f8a946 100755
--- a/test/partest
+++ b/test/partest
@@ -53,7 +53,7 @@ if [ -z "$EXT_CLASSPATH" ] ; then
fi
done
elif [ -f "$SCALA_HOME/build/pack/lib/scala-partest.jar" ] ; then
- for lib in `echo "partest library compiler"`; do
+ for lib in `echo "partest library reflect compiler"`; do
ext="$SCALA_HOME/build/pack/lib/scala-$lib.jar"
if [ -z "$EXT_CLASSPATH" ] ; then
EXT_CLASSPATH="$ext"
diff --git a/test/pending/jvm/t1464.check b/test/pending/jvm/t1464.check
deleted file mode 100644
index c508d5366f..0000000000
--- a/test/pending/jvm/t1464.check
+++ /dev/null
@@ -1 +0,0 @@
-false
diff --git a/test/pending/neg/reify_packed.scala b/test/pending/neg/reify_packed.scala
index 0240f2a4b5..2004e031d5 100644
--- a/test/pending/neg/reify_packed.scala
+++ b/test/pending/neg/reify_packed.scala
@@ -1,3 +1,8 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
reify {
class C { override def toString() = "C" }
@@ -5,6 +10,6 @@ object Test extends App {
ret.asInstanceOf[List[_]]
};
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
println(toolbox.runExpr(code.tree))
-}
+} \ No newline at end of file
diff --git a/test/pending/pos/inference.scala b/test/pending/pos/inference.scala
index 3672351fca..ee462b6bcc 100644
--- a/test/pending/pos/inference.scala
+++ b/test/pending/pos/inference.scala
@@ -1,14 +1,16 @@
+import scala.reflect.runtime.universe._
+
// inference illuminator
object Test {
- class D1[T1 : TypeTag, T2 <: T1 : TypeTag](x: T1) { println(typeTag[(T1, T2)]) }
- class D2[T1 : TypeTag, T2 >: T1 : TypeTag](x: T1) { println(typeTag[(T1, T2)]) }
- class D3[+T1 : TypeTag, T2 <: T1 : TypeTag](x: T1) { println(typeTag[(T1, T2)]) }
- class D4[-T1 : TypeTag, T2 >: T1 : TypeTag](x: T1) { println(typeTag[(T1, T2)]) }
+ class D1[T1 : TypeTag, T2 <: T1 : TypeTag](x: T1) { println(typeOf[(T1, T2)]) }
+ class D2[T1 : TypeTag, T2 >: T1 : TypeTag](x: T1) { println(typeOf[(T1, T2)]) }
+ class D3[+T1 : TypeTag, T2 <: T1 : TypeTag](x: T1) { println(typeOf[(T1, T2)]) }
+ class D4[-T1 : TypeTag, T2 >: T1 : TypeTag](x: T1) { println(typeOf[(T1, T2)]) }
- class E1[T1 : TypeTag, T2 <: T1 : TypeTag](x: D1[T1, T2]) { println(typeTag[(T1, T2)]) }
- class E2[T1 : TypeTag, T2 >: T1 : TypeTag](x: D2[T1, T2]) { println(typeTag[(T1, T2)]) }
- class E3[+T1 : TypeTag, T2 <: T1 : TypeTag](x: D3[T1, T2]) { println(typeTag[(T1, T2)]) }
- class E4[-T1 : TypeTag, T2 >: T1 : TypeTag](x: D4[T1, T2]) { println(typeTag[(T1, T2)]) }
+ class E1[T1 : TypeTag, T2 <: T1 : TypeTag](x: D1[T1, T2]) { println(typeOf[(T1, T2)]) }
+ class E2[T1 : TypeTag, T2 >: T1 : TypeTag](x: D2[T1, T2]) { println(typeOf[(T1, T2)]) }
+ class E3[+T1 : TypeTag, T2 <: T1 : TypeTag](x: D3[T1, T2]) { println(typeOf[(T1, T2)]) }
+ class E4[-T1 : TypeTag, T2 >: T1 : TypeTag](x: D4[T1, T2]) { println(typeOf[(T1, T2)]) }
def main(args: Array[String]): Unit = {
// WHY YOU NO LIKE NOTHING SO MUCH SCALAC?
@@ -36,4 +38,4 @@ object Test {
// new E3(d3)
// ^
// two errors found
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-default.flags b/test/pending/run/macro-expand-default.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-expand-default.flags
+++ b/test/pending/run/macro-expand-default.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-expand-default/Impls_1.scala b/test/pending/run/macro-expand-default/Impls_1.scala
index fefe8fc4e2..a539982b45 100644
--- a/test/pending/run/macro-expand-default/Impls_1.scala
+++ b/test/pending/run/macro-expand-default/Impls_1.scala
@@ -2,9 +2,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum))
Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference.check b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference.check
index 08f7cb9e3e..5af32f38e0 100644
--- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference.check
+++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference.check
@@ -1,6 +1,6 @@
openImplicits are: List()
enclosingImplicits are: List((List[Int],scala.this.Predef.implicitly[List[Int]]))
-typetag is: ConcreteTypeTag[Nothing]
+typetag is: TypeTag[Nothing]
openImplicits are: List()
enclosingImplicits are: List((List[String],Test.this.bar[String]))
-typetag is: ConcreteTypeTag[Nothing]
+typetag is: TypeTag[Nothing]
diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
index c096a83c5e..1740f40daf 100644
--- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
+++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala
@@ -2,9 +2,9 @@ import scala.reflect.makro.Context
object Impls {
def foo[T: c.TypeTag](c: Context): c.Expr[List[T]] = c.reify {
- println("openImplicits are: " + c.literal(c.openImplicits.toString).eval)
- println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).eval)
- println("typetag is: " + c.literal(c.tag[T].toString).eval)
+ println("openImplicits are: " + c.literal(c.openImplicits.toString).splice)
+ println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).splice)
+ println("typetag is: " + c.literal(c.tag[T].toString).splice)
null
}
} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags b/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags
deleted file mode 100644
index 7fea2ff901..0000000000
--- a/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xmacros \ No newline at end of file
diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound.check b/test/pending/run/macro-expand-macro-has-context-bound.check
index ac4213d6e9..ac4213d6e9 100644
--- a/test/pending/run/macro-expand-implicit-macro-has-context-bound.check
+++ b/test/pending/run/macro-expand-macro-has-context-bound.check
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags b/test/pending/run/macro-expand-macro-has-context-bound.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags
+++ b/test/pending/run/macro-expand-macro-has-context-bound.flags
diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala
index 5c50576281..3cee65ce72 100644
--- a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala
+++ b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala
@@ -2,9 +2,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[U](c: Ctx)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = {
- import c.mirror._
+ import c.universe._
val plusOne = Apply(Select(evidence.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne))
Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala b/test/pending/run/macro-expand-macro-has-context-bound/Macros_Test_2.scala
index 7d16b773a6..7d16b773a6 100644
--- a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala
+++ b/test/pending/run/macro-expand-macro-has-context-bound/Macros_Test_2.scala
diff --git a/test/pending/run/macro-expand-named.flags b/test/pending/run/macro-expand-named.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-expand-named.flags
+++ b/test/pending/run/macro-expand-named.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-expand-named/Impls_1.scala b/test/pending/run/macro-expand-named/Impls_1.scala
index fefe8fc4e2..a539982b45 100644
--- a/test/pending/run/macro-expand-named/Impls_1.scala
+++ b/test/pending/run/macro-expand-named/Impls_1.scala
@@ -2,9 +2,9 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = {
- import c.mirror._
+ import c.universe._
val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree))
val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum))
Expr[Unit](body)
}
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-tparams-prefix-e1.flags b/test/pending/run/macro-expand-tparams-prefix-e1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-expand-tparams-prefix-e1.flags
+++ b/test/pending/run/macro-expand-tparams-prefix-e1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
index bc880fdf77..d7df919552 100644
--- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala
@@ -2,11 +2,11 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
+ import c.universe._
Block(List(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))),
Literal(Constant(())))
}
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala
index 5c863804d0..d4fc52fca0 100644
--- a/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
class D[T: TypeTag] {
diff --git a/test/pending/run/macro-expand-tparams-prefix-f1.flags b/test/pending/run/macro-expand-tparams-prefix-f1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-expand-tparams-prefix-f1.flags
+++ b/test/pending/run/macro-expand-tparams-prefix-f1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
index bc880fdf77..d7df919552 100644
--- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala
@@ -2,11 +2,11 @@ import scala.reflect.makro.{Context => Ctx}
object Impls {
def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = {
- import c.mirror._
+ import c.universe._
Block(List(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))),
Literal(Constant(())))
}
-}
+} \ No newline at end of file
diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala
index bc8e7ac75c..9417cf663e 100644
--- a/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala
+++ b/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
class D[T] {
diff --git a/test/pending/run/macro-quasiinvalidbody-a.flags b/test/pending/run/macro-quasiinvalidbody-a.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-quasiinvalidbody-a.flags
+++ b/test/pending/run/macro-quasiinvalidbody-a.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-quasiinvalidbody-b.flags b/test/pending/run/macro-quasiinvalidbody-b.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-quasiinvalidbody-b.flags
+++ b/test/pending/run/macro-quasiinvalidbody-b.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-reify-array.flags b/test/pending/run/macro-reify-array.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-reify-array.flags
+++ b/test/pending/run/macro-reify-array.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala
index af42321484..c1bd4187a6 100644
--- a/test/pending/run/macro-reify-array/Macros_1.scala
+++ b/test/pending/run/macro-reify-array/Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
object Impls {
def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.reify {
- Array(s.eval)
+ Array(s.splice)
}
}
} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-eval-vs-value.flags b/test/pending/run/macro-reify-eval-vs-value.flags
deleted file mode 100644
index 7fea2ff901..0000000000
--- a/test/pending/run/macro-reify-eval-vs-value.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xmacros \ No newline at end of file
diff --git a/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala b/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala
deleted file mode 100644
index 98dd93b0f8..0000000000
--- a/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-import scala.reflect.makro.{Context => Ctx}
-
-object Macros {
- def fooEval(s: String) = macro Impls.fooEval
- def fooValue(s: String) = macro Impls.fooValue
-
- object Impls {
- def fooEval(c: Ctx)(s: c.Expr[String]) = c.reify {
- println("hello " + s.eval)
- println("hello " + s.eval)
- }
-
- def fooValue(c: Ctx)(s: c.Expr[String]) = c.reify {
- {
- println("hello " + s.value)
- def sayHello = println(s.value)
- sayHello
- }
- println("hello " + s.eval);
- {
- println("hello " + s.eval)
- }
- }
- }
-} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-eval-vs-value/Test_2.scala b/test/pending/run/macro-reify-eval-vs-value/Test_2.scala
deleted file mode 100644
index 8e62e6e0e7..0000000000
--- a/test/pending/run/macro-reify-eval-vs-value/Test_2.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-object Test extends App {
- Macros.fooEval({ println("in ur logz"); "world"})
- println("======================")
- Macros.fooValue({ println("i can has cheezburger?"); "world"})
-} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala
index ef70a66f1a..3252423375 100644
--- a/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala
+++ b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala
@@ -1,9 +1,9 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
- def fooTypeTagHK[C[_]: ConcreteTypeTag, T: ConcreteTypeTag] = {
- println(implicitly[ConcreteTypeTag[C[T]]])
- println(implicitly[ConcreteTypeTag[List[C[T]]]])
+ def fooTypeTagHK[C[_]: TypeTag, T: TypeTag] = {
+ println(implicitly[TypeTag[C[T]]])
+ println(implicitly[TypeTag[List[C[T]]]])
}
fooTypeTagHK[List, Int]
} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-tagful-b.flags b/test/pending/run/macro-reify-tagful-b.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-reify-tagful-b.flags
+++ b/test/pending/run/macro-reify-tagful-b.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala
index 38b839330b..04cf46d3a5 100644
--- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala
+++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
object Impls {
def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.reify {
- List(s.eval)
+ List(s.splice)
}
}
} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-tagless-b.flags b/test/pending/run/macro-reify-tagless-b.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/pending/run/macro-reify-tagless-b.flags
+++ b/test/pending/run/macro-reify-tagless-b.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
index fac7ba5b98..04366353eb 100644
--- a/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
+++ b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
object Impls {
def foo[T](c: Ctx)(s: c.Expr[T]) = c.reify {
- List(s.eval)
+ List(s.splice)
}
}
} \ No newline at end of file
diff --git a/test/pending/run/macro-reify-tagless-b/Test_2.scala b/test/pending/run/macro-reify-tagless-b/Test_2.scala
index 419ee42101..4649963d05 100644
--- a/test/pending/run/macro-reify-tagless-b/Test_2.scala
+++ b/test/pending/run/macro-reify-tagless-b/Test_2.scala
@@ -2,10 +2,12 @@ object Test extends App {
//val list: List[String] = Macros.foo("hello world")
//println(list)
- import scala.reflect.mirror._
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass)))
val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world"))))
val list = ValDef(NoMods, newTermName("list"), tpt, rhs)
val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name))))
- println(tree.eval)
+ println(cm.mkToolBox().runExpr(tree))
}
diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala b/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala
index 9a370189a7..c7b1cedcd2 100644
--- a/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala
+++ b/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def fooNoTypeTagHK[C[_], T] = {
diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala b/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala
index 0358da9b0d..3252423375 100644
--- a/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala
+++ b/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
def fooTypeTagHK[C[_]: TypeTag, T: TypeTag] = {
diff --git a/test/pending/run/reify_addressbook.scala b/test/pending/run/reify_addressbook.scala
index 7cb6dc08fd..d53a0f7bc0 100644
--- a/test/pending/run/reify_addressbook.scala
+++ b/test/pending/run/reify_addressbook.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/reify_brainf_ck.scala b/test/pending/run/reify_brainf_ck.scala
index e4bcb257bd..2af3bca1c7 100644
--- a/test/pending/run/reify_brainf_ck.scala
+++ b/test/pending/run/reify_brainf_ck.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala
index 0e23f75dcc..d9f7736769 100644
--- a/test/pending/run/reify_callccinterpreter.scala
+++ b/test/pending/run/reify_callccinterpreter.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/reify_closure2b.scala b/test/pending/run/reify_closure2b.scala
index f9ed16d309..565bb03b2f 100644
--- a/test/pending/run/reify_closure2b.scala
+++ b/test/pending/run/reify_closure2b.scala
@@ -1,16 +1,21 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo(y: Int): Int => Int = {
class Foo(y: Int) {
- val fun = reflect.mirror.reify{(x: Int) => {
+ val fun = reify{(x: Int) => {
x + y
}}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(y).fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closure3b.scala b/test/pending/run/reify_closure3b.scala
index 8ef0a60c66..0d806b148b 100644
--- a/test/pending/run/reify_closure3b.scala
+++ b/test/pending/run/reify_closure3b.scala
@@ -1,18 +1,23 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo(y: Int): Int => Int = {
class Foo(y: Int) {
def y1 = y
- val fun = reflect.mirror.reify{(x: Int) => {
+ val fun = reify{(x: Int) => {
x + y1
}}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(y).fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closure4b.scala b/test/pending/run/reify_closure4b.scala
index 9eeb01b459..1a349de072 100644
--- a/test/pending/run/reify_closure4b.scala
+++ b/test/pending/run/reify_closure4b.scala
@@ -1,18 +1,23 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo(y: Int): Int => Int = {
class Foo(y: Int) {
val y1 = y
- val fun = reflect.mirror.reify{(x: Int) => {
+ val fun = reify{(x: Int) => {
x + y1
}}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(y).fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(1)(10))
println(foo(2)(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closure5b.scala b/test/pending/run/reify_closure5b.scala
index 51f1ec318d..3e5e1bd328 100644
--- a/test/pending/run/reify_closure5b.scala
+++ b/test/pending/run/reify_closure5b.scala
@@ -1,16 +1,21 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo[T](ys: List[T]): Int => Int = {
class Foo[T](ys: List[T]) {
- val fun = reflect.mirror.reify{(x: Int) => {
+ val fun = reify{(x: Int) => {
x + ys.length
}}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(ys).fun.tree)
dyn.asInstanceOf[Int => Int]
}
println(foo(List(1, 2, 3))(10))
println(foo(List(1, 2, 3, 4))(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closure9a.scala b/test/pending/run/reify_closure9a.scala
index 1fc18cfa13..dddfa3f6c2 100644
--- a/test/pending/run/reify_closure9a.scala
+++ b/test/pending/run/reify_closure9a.scala
@@ -1,14 +1,18 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo(y: Int) = {
class Foo(val y: Int) {
def fun = reify{y}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(y).fun.tree)
dyn.asInstanceOf[Int]
}
println(foo(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closure9b.scala b/test/pending/run/reify_closure9b.scala
index 32b05d00ee..df9db9b806 100644
--- a/test/pending/run/reify_closure9b.scala
+++ b/test/pending/run/reify_closure9b.scala
@@ -1,14 +1,18 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def foo(y: Int) = {
class Foo(y: Int) {
def fun = reify{y}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(new Foo(y).fun.tree)
dyn.asInstanceOf[Int]
}
println(foo(10))
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_closures11.scala b/test/pending/run/reify_closures11.scala
index ceb224c6d6..4c21033cbc 100644
--- a/test/pending/run/reify_closures11.scala
+++ b/test/pending/run/reify_closures11.scala
@@ -1,12 +1,16 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
object Test extends App {
def fun() = {
def z() = 2
reify{z}
}
- val toolbox = mkToolBox()
+ val toolbox = cm.mkToolBox()
val dyn = toolbox.runExpr(fun().tree)
val foo = dyn.asInstanceOf[Int]
println(foo)
-}
+} \ No newline at end of file
diff --git a/test/pending/run/reify_gadts.scala b/test/pending/run/reify_gadts.scala
index 652a7d99d8..582c0802f7 100644
--- a/test/pending/run/reify_gadts.scala
+++ b/test/pending/run/reify_gadts.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/reify_newimpl_07.scala b/test/pending/run/reify_newimpl_07.scala
index 13ca6bda8b..b6886b8bb7 100644
--- a/test/pending/run/reify_newimpl_07.scala
+++ b/test/pending/run/reify_newimpl_07.scala
@@ -1,10 +1,11 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
{
class C(val y: Int) {
val code = reify {
- reify{y}.eval
+ reify{y}.splice
}
}
diff --git a/test/pending/run/reify_newimpl_08.scala b/test/pending/run/reify_newimpl_08.scala
index e2faa3c9af..6caa33f30d 100644
--- a/test/pending/run/reify_newimpl_08.scala
+++ b/test/pending/run/reify_newimpl_08.scala
@@ -1,14 +1,15 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
val code = reify {
class C(val y: Int) {
val code = reify {
- reify{y}.eval
+ reify{y}.splice
}
}
- new C(2).code.eval
+ new C(2).code.splice
}
println(code.eval)
diff --git a/test/pending/run/reify_newimpl_46.scala b/test/pending/run/reify_newimpl_46.scala
index 840d695e83..239c53953b 100644
--- a/test/pending/run/reify_newimpl_46.scala
+++ b/test/pending/run/reify_newimpl_46.scala
@@ -1,11 +1,14 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
class C[T[_] >: Null] {
- val code = reify{val x: T[String] = null; println("ima worx"); x}
- println(freeTypes(code))
- val T = freeTypes(code)(0)
- mkToolBox().runExpr(code, Map(T -> definitions.ListClass.asType))
+ val code = reify{val x: T[String] = null; println("ima worx"); x}.tree
+ println(code.freeTypes)
+ val T = code.freeTypes(0)
+ cm.mkToolBox().runExpr(code, Map(T -> definitions.ListClass.asType))
}
new C[List]
diff --git a/test/pending/run/reify_newimpl_53.scala b/test/pending/run/reify_newimpl_53.scala
index 26645dea6a..a73a0b94cb 100644
--- a/test/pending/run/reify_newimpl_53.scala
+++ b/test/pending/run/reify_newimpl_53.scala
@@ -1,14 +1,17 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
object Test extends App {
class C[T >: Null] {
val code = reify{
val tt = implicitly[TypeTag[T]]
println("mah typetag is: %s".format(tt))
- }
- println(freeTypes(code))
- val T = freeTypes(code)(0)
- mkToolBox().runExpr(code, Map(T -> definitions.StringClass.asType))
+ }.tree
+ println(code.freeTypes)
+ val T = code.freeTypes(0)
+ cm.mkToolBox().runExpr(code, Map(T -> definitions.StringClass.asType))
}
new C[String]
diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala
index 2193edeea7..6cf87ea7c5 100644
--- a/test/pending/run/reify_simpleinterpreter.scala
+++ b/test/pending/run/reify_simpleinterpreter.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Test extends App {
reify {
diff --git a/test/pending/run/subarray.check b/test/pending/run/subarray.check
deleted file mode 100644
index 814f4a4229..0000000000
--- a/test/pending/run/subarray.check
+++ /dev/null
@@ -1,2 +0,0 @@
-one
-two
diff --git a/test/pending/run/t0446.check b/test/pending/run/t0446.check
deleted file mode 100644
index 7c41a48cdb..0000000000
--- a/test/pending/run/t0446.check
+++ /dev/null
@@ -1,2 +0,0 @@
-List(1)
-List(3)
diff --git a/test/pending/run/t5256c.check b/test/pending/run/t5256c.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/pending/run/t5256c.check
+++ /dev/null
diff --git a/test/pending/run/t5256c.scala b/test/pending/run/t5256c.scala
deleted file mode 100644
index 8ebb51a009..0000000000
--- a/test/pending/run/t5256c.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- {
- class A
- val c = classToType(classOf[A])
- println(c)
- println(c.typeSymbol == classToSymbol(classOf[A]))
- }
-}
diff --git a/test/pending/run/t5256g.check b/test/pending/run/t5256g.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/pending/run/t5256g.check
+++ /dev/null
diff --git a/test/pending/run/t5256g.scala b/test/pending/run/t5256g.scala
deleted file mode 100644
index 6158a9281d..0000000000
--- a/test/pending/run/t5256g.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.reflect.mirror._
-
-class A
-trait B
-
-object Test extends App {
- val mutant = new A with B
- val c = classToType(mutant.getClass)
- println(c)
- println(c.typeSymbol == classToSymbol(mutant.getClass))
-}
diff --git a/test/pending/run/t5256h.check b/test/pending/run/t5256h.check
deleted file mode 100644
index 4f9b8faf71..0000000000
--- a/test/pending/run/t5256h.check
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- val mutant = new { val x = 2 }
- val c = classToType(mutant.getClass)
- println(c)
- println(c.typeSymbol == classToSymbol(mutant.getClass))
-}
diff --git a/test/pending/run/t5256h.scala b/test/pending/run/t5256h.scala
deleted file mode 100644
index 4f9b8faf71..0000000000
--- a/test/pending/run/t5256h.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import scala.reflect.mirror._
-
-object Test extends App {
- val mutant = new { val x = 2 }
- val c = classToType(mutant.getClass)
- println(c)
- println(c.typeSymbol == classToSymbol(mutant.getClass))
-}
diff --git a/test/pending/run/t5258b.scala b/test/pending/run/t5258b.scala
index 82555cde96..a280513d59 100644
--- a/test/pending/run/t5258b.scala
+++ b/test/pending/run/t5258b.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/t5258c.scala b/test/pending/run/t5258c.scala
index a0a1647486..4a656690ba 100644
--- a/test/pending/run/t5258c.scala
+++ b/test/pending/run/t5258c.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/t5418.scala b/test/pending/run/t5418.scala
index 9b0a954e47..e3cb20cf82 100644
--- a/test/pending/run/t5418.scala
+++ b/test/pending/run/t5418.scala
@@ -1,4 +1,5 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
+import scala.tools.reflect.Eval
object Test extends App {
reify {
diff --git a/test/pending/run/t5427a.scala b/test/pending/run/t5427a.scala
index 27b28da0ac..f7cd05158d 100644
--- a/test/pending/run/t5427a.scala
+++ b/test/pending/run/t5427a.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
object Foo { val bar = 2 }
diff --git a/test/pending/run/t5427b.scala b/test/pending/run/t5427b.scala
index 7a92b6ebbe..e80bd12369 100644
--- a/test/pending/run/t5427b.scala
+++ b/test/pending/run/t5427b.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
class Foo { val bar = 2 }
diff --git a/test/pending/run/t5427c.scala b/test/pending/run/t5427c.scala
index ab41d8b8cd..7095158e85 100644
--- a/test/pending/run/t5427c.scala
+++ b/test/pending/run/t5427c.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
class Foo(bar: Int)
diff --git a/test/pending/run/t5427d.scala b/test/pending/run/t5427d.scala
index fd4c62e876..f0cc07d27e 100644
--- a/test/pending/run/t5427d.scala
+++ b/test/pending/run/t5427d.scala
@@ -1,4 +1,4 @@
-import scala.reflect.mirror._
+import scala.reflect.runtime.universe._
class Foo(val bar: Int)
diff --git a/test/pending/run/t5629.check b/test/pending/run/t5629.check
deleted file mode 100644
index 6a2d630f4e..0000000000
--- a/test/pending/run/t5629.check
+++ /dev/null
@@ -1,2 +0,0 @@
-int child got: 33
-any child got: 33
diff --git a/test/pending/shootout/meteor.scala b/test/pending/shootout/meteor.scala
index 154695533b..6dbd3cf459 100644
--- a/test/pending/shootout/meteor.scala
+++ b/test/pending/shootout/meteor.scala
@@ -1,3 +1,5 @@
+import scala.reflect.{ClassTag, classTag}
+
/* The Computer Language Shootout
http://shootout.alioth.debian.org/
contributed by Isaac Gouy
@@ -493,4 +495,3 @@ final class PieceCell extends Cell {
-
diff --git a/test/files/specialized/SI-5005.check b/test/pending/specialized/SI-5005.check
index 81e8342dad..81e8342dad 100644
--- a/test/files/specialized/SI-5005.check
+++ b/test/pending/specialized/SI-5005.check
diff --git a/test/files/specialized/SI-5005.scala b/test/pending/specialized/SI-5005.scala
index 3d1ada49e2..280bf0aa2d 100644
--- a/test/files/specialized/SI-5005.scala
+++ b/test/pending/specialized/SI-5005.scala
@@ -1,6 +1,15 @@
import scala.tools.partest._
import java.io._
+
+
+// I think this may be due to a bug in partest where it uses some other version
+// of the scala-library.jar - _hashCode is in line 202 currently, not 212!
+//
+// [partest] testing: [...]/files/specialized/SI-5005.scala [FAILED]
+// [partest] java.lang.NoClassDefFoundError: scala/util/MurmurHash3$
+// [partest] java.lang.NoClassDefFoundError: scala/util/MurmurHash3$
+// [partest] at scala.runtime.ScalaRunTime$._hashCode(ScalaRunTime.scala:212)
object Test extends DirectTest {
override def extraSettings: String = "-usejavacp -Xprint:spec -optimize -Ylog:inliner -d " + testOutput.path
diff --git a/tools/buildcp b/tools/buildcp
new file mode 100755
index 0000000000..766ab81f90
--- /dev/null
+++ b/tools/buildcp
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+
+[[ $# -eq 1 ]] || { echo "Usage: $0 <locker|quick|...>"; exit 0; }
+
+dir=$(dirname $0)
+lib=$($dir/abspath $dir/../lib)
+build=$($dir/abspath $dir/../build)
+cp=$($dir/cpof $build/$1/classes):$build/asm/classes
+
+echo $cp:$lib/fjbg.jar:$lib/msil.jar:$lib/forkjoin.jar:$lib/jline.jar:$lib/extra/'*'
diff --git a/tools/cpof b/tools/cpof
index ab5a42b4fb..c09ed20d69 100755
--- a/tools/cpof
+++ b/tools/cpof
@@ -3,28 +3,16 @@
# Creates a classpath out of the contents of each directory
# given as an argument.
-if [ $# == 0 ] ; then
- echo "Usage: $0 [dir1 dir2 ...]"
- exit 1
-fi
+[[ $# == 0 ]] && { echo "Usage: $0 [dir1 dir2 ...]" && exit 0; }
-THISDIR=`dirname $0`
-ABSCMD="${THISDIR}/abspath"
-CPRES=""
+sdir=$(dirname $0)
+cp=""
-for dir in $* ; do
- absdir=`${ABSCMD} $dir`
- LS=`ls -1 ${absdir}`
-
- for x in $LS ; do
- ABS=`${ABSCMD} "${absdir}/${x}"`
- CPRES="${CPRES}:${ABS}"
+for dir in "$@" ; do
+ for x in $($sdir/abspath $dir)/* ; do
+ cp="$cp:$($sdir/abspath $x)"
done
done
-# shaving the : off the beginning. Applause to /bin/sh for
-# keeping us humble about how far we've come.
-LEN=$(( ${#CPRES} - 1 ))
-result=${CPRES:1:${LEN}}
-
-echo $result
+# shaving the : off the beginning.
+echo ${cp#:}
diff --git a/tools/lockercp b/tools/lockercp
index 3e8799596f..43c72dd629 100755
--- a/tools/lockercp
+++ b/tools/lockercp
@@ -1,10 +1,4 @@
#!/bin/sh
#
-THISDIR=`dirname $0`
-ABS=${THISDIR}/abspath
-LIBDIR=`$ABS $THISDIR/../lib`
-
-cp=`${THISDIR}/cpof ${THISDIR}/../build/locker/classes`
-
-echo ${cp}:$LIBDIR/fjbg.jar:$LIBDIR/msil.jar:$LIBDIR/forkjoin.jar:$LIBDIR/jline.jar:$LIBDIR/extra/'*'
+$(dirname $0)/buildcp locker
diff --git a/tools/packcp b/tools/packcp
index 42bce9e266..ecc7ee1b5d 100755
--- a/tools/packcp
+++ b/tools/packcp
@@ -1,5 +1,5 @@
#!/bin/sh
#
-THISDIR=`dirname $0`
-${THISDIR}/cpof ${THISDIR}/../build/pack/lib
+dir=$(dirname $0)
+$dir/cpof $dir/../build/pack/lib
diff --git a/tools/quickcp b/tools/quickcp
index dd5251d30f..25d46e56d9 100755
--- a/tools/quickcp
+++ b/tools/quickcp
@@ -1,10 +1,4 @@
#!/bin/sh
#
-THISDIR=`dirname $0`
-ABS=${THISDIR}/abspath
-LIBDIR=`$ABS $THISDIR/../lib`
-
-cp=`${THISDIR}/cpof ${THISDIR}/../build/quick/classes`
-
-echo ${cp}:$LIBDIR/fjbg.jar:$LIBDIR/msil.jar:$LIBDIR/forkjoin.jar:$LIBDIR/jline.jar:$LIBDIR/extra/'*'
+$(dirname $0)/buildcp quick
diff --git a/tools/rm-orphan-checkfiles b/tools/rm-orphan-checkfiles
new file mode 100755
index 0000000000..ca0a3f2938
--- /dev/null
+++ b/tools/rm-orphan-checkfiles
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# Scans for and removes .check and .flags files under test/
+# which don't have an accompanying test.
+
+shopt -s nullglob
+
+echo "Scanning for orphan check files..."
+for f in $(ls -1d test/{files,pending,disabled}/{jvm,neg,pos,run}/*.check); do
+ base=${f%%.check}
+ [[ -d $base ]] || [[ -f $base.scala ]] || git rm -f $f
+done
+
+echo "Scanning for orphan flags files..."
+for f in $(ls -1d test/{files,pending,disabled}/{jvm,neg,pos,run}/*.flags); do
+ base=${f%%.flags}
+ [[ -d $base ]] || [[ -f $base.scala ]] || git rm -f $f
+done
diff --git a/tools/starrcp b/tools/starrcp
index 6add5665b5..76f40fde03 100755
--- a/tools/starrcp
+++ b/tools/starrcp
@@ -1,5 +1,5 @@
#!/bin/sh
#
-THISDIR=`dirname $0`
-${THISDIR}/cpof ${THISDIR}/../lib \ No newline at end of file
+dir=$(dirname $0)
+$dir/cpof $dir/../lib
diff --git a/tools/strapcp b/tools/strapcp
index 61e4a61b2c..6a46b4e1c8 100755
--- a/tools/strapcp
+++ b/tools/strapcp
@@ -1,8 +1,12 @@
#!/bin/sh
#
-THISDIR=`dirname $0`
-cp=`${THISDIR}/cpof ${THISDIR}/../build/strap/classes`
-fjbg=`${THISDIR}/abspath ${THISDIR}/../lib/fjbg.jar`
+dir=$(dirname $0)
+strap="$dir/../build/strap/classes"
+[[ -d $strap ]] || { echo "Error: no directory at $strap"; exit 1; }
-echo ${cp}:${fjbg}
+cp=$($dir/cpof $strap)
+fjbg=$($dir/abspath $dir/../lib/fjbg.jar)
+asm=$($dir/abspath $dir/../build/asm/classes)
+
+echo $cp:$fjbg:$asm