summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/scala-compiler.jar.desired.sha12
-rw-r--r--lib/scala-library.jar.desired.sha12
-rw-r--r--src/compiler/scala/reflect/internal/AnnotationInfos.scala3
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala27
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala45
-rw-r--r--src/compiler/scala/reflect/internal/TreeInfo.scala6
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala21
-rw-r--r--src/compiler/scala/reflect/internal/pickling/UnPickler.scala4
-rw-r--r--src/compiler/scala/reflect/internal/util/Origins.scala2
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Reifiers.scala123
-rw-r--r--src/compiler/scala/reflect/reify/Errors.scala8
-rw-r--r--src/compiler/scala/reflect/reify/Reifier.scala38
-rw-r--r--src/compiler/scala/reflect/reify/codegen/Symbols.scala2
-rw-r--r--src/compiler/scala/reflect/reify/codegen/Types.scala18
-rw-r--r--src/compiler/scala/reflect/reify/package.scala38
-rw-r--r--src/compiler/scala/reflect/runtime/Mirror.scala2
-rw-r--r--src/compiler/scala/tools/cmd/FromString.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Phases.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala16
-rw-r--r--src/compiler/scala/tools/nsc/doc/Settings.scala15
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala8
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala14
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala23
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/NamedParam.scala12
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Power.scala43
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ReplVals.scala25
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/RichClass.scala8
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala20
-rw-r--r--src/compiler/scala/tools/nsc/io/ClassAndJarInfo.scala6
-rw-r--r--src/compiler/scala/tools/nsc/io/Pickler.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala11
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala134
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala52
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala30
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Taggings.scala71
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala50
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala12
-rw-r--r--src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala10
-rw-r--r--src/compiler/scala/tools/reflect/Invoked.scala2
-rw-r--r--src/compiler/scala/tools/reflect/UniversalFn.scala4
-rw-r--r--src/compiler/scala/tools/reflect/package.scala22
-rw-r--r--src/detach/library/scala/remoting/Channel.scala32
-rw-r--r--src/library/scala/Array.scala54
-rw-r--r--src/library/scala/Predef.scala37
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala6
-rw-r--r--src/library/scala/collection/Traversable.scala2
-rw-r--r--src/library/scala/collection/TraversableOnce.scala2
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala2
-rw-r--r--src/library/scala/collection/generic/ArrayTagTraversableFactory.scala (renamed from src/library/scala/collection/generic/ClassManifestTraversableFactory.scala)10
-rw-r--r--src/library/scala/collection/generic/GenericArrayTagCompanion.scala (renamed from src/library/scala/collection/generic/GenericClassManifestCompanion.scala)10
-rw-r--r--src/library/scala/collection/generic/GenericArrayTagTraversableTemplate.scala30
-rw-r--r--src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala26
-rw-r--r--src/library/scala/collection/generic/TraversableForwarder.scala2
-rw-r--r--src/library/scala/collection/generic/package.scala9
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala10
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala2
-rw-r--r--src/library/scala/collection/interfaces/IterableMethods.scala1
-rw-r--r--src/library/scala/collection/interfaces/SeqMethods.scala1
-rw-r--r--src/library/scala/collection/interfaces/SetMethods.scala1
-rw-r--r--src/library/scala/collection/interfaces/TraversableOnceMethods.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayBuilder.scala17
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala27
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala2
-rw-r--r--src/library/scala/collection/mutable/FlatArray.scala28
-rw-r--r--src/library/scala/collection/mutable/UnrolledBuffer.scala14
-rw-r--r--src/library/scala/collection/mutable/WrappedArray.scala43
-rw-r--r--src/library/scala/collection/mutable/WrappedArrayBuilder.scala16
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala20
-rw-r--r--src/library/scala/collection/parallel/mutable/ParArray.scala4
-rw-r--r--src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala2
-rw-r--r--src/library/scala/concurrent/Future.scala36
-rw-r--r--src/library/scala/math/Numeric.scala4
-rw-r--r--src/library/scala/reflect/ArrayTag.scala8
-rw-r--r--src/library/scala/reflect/ClassManifest.scala242
-rw-r--r--src/library/scala/reflect/ClassTag.scala206
-rw-r--r--src/library/scala/reflect/DummyMirror.scala14
-rw-r--r--src/library/scala/reflect/ErasureTag.scala23
-rw-r--r--src/library/scala/reflect/Manifest.scala259
-rw-r--r--src/library/scala/reflect/NoManifest.scala16
-rw-r--r--src/library/scala/reflect/OptManifest.scala18
-rw-r--r--src/library/scala/reflect/ReflectionUtils.scala1
-rw-r--r--src/library/scala/reflect/TagInterop.scala34
-rw-r--r--src/library/scala/reflect/TagMaterialization.scala122
-rwxr-xr-xsrc/library/scala/reflect/api/AnnotationInfos.scala2
-rwxr-xr-xsrc/library/scala/reflect/api/Symbols.scala8
-rw-r--r--src/library/scala/reflect/api/TreeBuildUtil.scala18
-rw-r--r--src/library/scala/reflect/api/TypeTags.scala246
-rwxr-xr-xsrc/library/scala/reflect/api/Universe.scala23
-rw-r--r--src/library/scala/reflect/makro/Context.scala21
-rw-r--r--src/library/scala/reflect/makro/Reifiers.scala25
-rw-r--r--src/library/scala/reflect/makro/internal/Utils.scala96
-rw-r--r--src/library/scala/reflect/package.scala21
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala21
-rw-r--r--src/library/scala/util/Marshal.scala34
-rw-r--r--src/library/scala/util/Sorting.scala16
-rw-r--r--src/library/scala/util/control/Exception.scala6
-rw-r--r--src/partest/scala/tools/partest/CompilerTest.scala11
-rw-r--r--src/partest/scala/tools/partest/SigTest.scala24
-rw-r--r--src/scalacheck/org/scalacheck/Arbitrary.scala2
-rw-r--r--src/scalacheck/org/scalacheck/util/Buildable.scala2
-rw-r--r--src/swing/scala/swing/Font.scala.disabled32
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/arrays/Resetting.scala8
-rw-r--r--test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/MatrixMultiplication.scala26
-rw-r--r--test/disabled/presentation/akka.check24
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/Actor.scala4
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/ActorRef.scala16
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/ActorRegistry.scala30
-rw-r--r--test/disabled/presentation/akka/src/akka/event/EventHandler.scala4
-rw-r--r--test/disabled/presentation/akka/src/akka/remoteinterface/RemoteInterface.scala4
-rw-r--r--test/disabled/presentation/akka/src/akka/util/Helpers.scala2
-rw-r--r--test/disabled/presentation/simple-tests.check2
-rw-r--r--test/files/jvm/manifests-new.check58
-rw-r--r--test/files/jvm/manifests-new.scala109
-rw-r--r--test/files/jvm/manifests-old.check55
-rw-r--r--test/files/jvm/manifests-old.scala (renamed from test/files/jvm/manifests.scala)9
-rw-r--r--test/files/jvm/manifests.check56
-rw-r--r--test/files/jvm/serialization-new.check313
-rw-r--r--test/files/jvm/serialization-new.scala651
-rw-r--r--test/files/jvm/si5471.check2
-rw-r--r--test/files/jvm/si5471.scala17
-rw-r--r--test/files/neg/classtags_contextbound_a.check2
-rw-r--r--test/files/neg/classtags_contextbound_c.check2
-rw-r--r--test/files/neg/classtags_dont_use_typetags.check4
-rw-r--r--test/files/neg/classtags_dont_use_typetags.scala3
-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_classtags_arenot_manifests.check7
-rw-r--r--test/files/neg/interop_classtags_arenot_manifests.scala17
-rw-r--r--test/files/neg/interop_erasuretags_arenot_classmanifests.check4
-rw-r--r--test/files/neg/interop_erasuretags_arenot_classmanifests.scala9
-rw-r--r--test/files/neg/interop_erasuretags_arenot_manifests.check4
-rw-r--r--test/files/neg/interop_erasuretags_arenot_manifests.scala9
-rw-r--r--test/files/neg/interop_typetags_arenot_classmanifests.check4
-rw-r--r--test/files/neg/interop_typetags_arenot_classmanifests.scala9
-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/macro-invalidret-nontree.check14
-rw-r--r--test/files/neg/macro-invalidret-nonuniversetree.check14
-rw-r--r--test/files/neg/t2386.check4
-rw-r--r--test/files/neg/t2386.scala3
-rw-r--r--test/files/neg/t3507-old.check4
-rw-r--r--test/files/neg/t3507-old.scala15
-rw-r--r--test/files/neg/t3692-new.check4
-rw-r--r--test/files/neg/t3692-new.flags (renamed from test/files/neg/t3692.flags)0
-rw-r--r--test/files/neg/t3692-new.scala19
-rw-r--r--test/files/neg/t3692-old.check8
-rw-r--r--test/files/neg/t3692-old.flags1
-rw-r--r--test/files/neg/t3692-old.scala (renamed from test/files/neg/t3692.scala)0
-rw-r--r--test/files/neg/t3692.check11
-rw-r--r--test/files/neg/t5452-new.check8
-rw-r--r--test/files/neg/t5452-new.scala29
-rw-r--r--test/files/neg/t5452-old.check (renamed from test/files/neg/t5452.check)16
-rw-r--r--test/files/neg/t5452-old.scala (renamed from test/files/neg/t5452.scala)0
-rw-r--r--test/files/neg/t5689.check2
-rw-r--r--test/files/pos/contextbounds-implicits-new.scala8
-rw-r--r--test/files/pos/contextbounds-implicits-old.scala (renamed from test/files/pos/contextbounds-implicits.scala)0
-rw-r--r--test/files/pos/implicits-new.scala89
-rw-r--r--test/files/pos/implicits-old.scala (renamed from test/files/pos/implicits.scala)0
-rw-r--r--test/files/pos/manifest1-new.scala21
-rw-r--r--test/files/pos/manifest1-old.scala (renamed from test/files/pos/manifest1.scala)0
-rw-r--r--test/files/pos/nothing_manifest_disambig-new.scala10
-rw-r--r--test/files/pos/nothing_manifest_disambig-old.scala (renamed from test/files/pos/nothing_manifest_disambig.scala)0
-rw-r--r--test/files/pos/spec-constr-new.scala7
-rw-r--r--test/files/pos/spec-constr-old.scala (renamed from test/files/pos/spec-constr.scala)0
-rw-r--r--test/files/pos/spec-doubledef-new.scala28
-rw-r--r--test/files/pos/spec-doubledef-old.scala (renamed from test/files/pos/spec-doubledef.scala)0
-rw-r--r--test/files/pos/spec-fields-new.scala10
-rw-r--r--test/files/pos/spec-fields-old.scala (renamed from test/files/pos/spec-fields.scala)0
-rw-r--r--test/files/pos/spec-params-new.scala32
-rw-r--r--test/files/pos/spec-params-old.scala (renamed from test/files/pos/spec-params.scala)0
-rw-r--r--test/files/pos/spec-sparsearray-new.scala24
-rw-r--r--test/files/pos/spec-sparsearray-old.scala (renamed from test/files/pos/spec-sparsearray.scala)0
-rw-r--r--test/files/pos/t1381-new.scala31
-rw-r--r--test/files/pos/t1381-old.scala (renamed from test/files/pos/t1381.scala)0
-rw-r--r--test/files/pos/t2795-new.scala17
-rw-r--r--test/files/pos/t2795-old.scala (renamed from test/files/pos/t2795.scala)0
-rw-r--r--test/files/pos/t3363-new.scala18
-rw-r--r--[-rwxr-xr-x]test/files/pos/t3363-old.scala (renamed from test/files/pos/t3363.scala)0
-rw-r--r--test/files/pos/t3498-new.scala15
-rw-r--r--test/files/pos/t3498-old.scala (renamed from test/files/pos/t3498.scala)0
-rw-r--r--test/files/presentation/ide-bug-1000531.check2
-rw-r--r--test/files/run/arrayclone-new.scala106
-rw-r--r--test/files/run/arrayclone-old.scala (renamed from test/files/run/arrayclone.scala)0
-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/classtags_core.check62
-rw-r--r--test/files/run/classtags_core.scala2
-rw-r--r--test/files/run/classtags_multi.check5
-rw-r--r--test/files/run/classtags_multi.scala7
-rw-r--r--test/files/run/classtags_use_concretetypetags.scala3
-rw-r--r--test/files/run/concretetypetags_core.check (renamed from test/files/run/groundtypetags_core.check)62
-rw-r--r--test/files/run/concretetypetags_core.scala (renamed from test/files/run/groundtypetags_core.scala)2
-rw-r--r--test/files/run/concretetypetags_multi.check5
-rw-r--r--test/files/run/concretetypetags_multi.scala7
-rw-r--r--test/files/run/ctries-new/DumbHash.scala (renamed from test/files/run/ctries/DumbHash.scala)0
-rw-r--r--test/files/run/ctries-new/Wrap.scala (renamed from test/files/run/ctries/Wrap.scala)0
-rw-r--r--test/files/run/ctries-new/concmap.scala (renamed from test/files/run/ctries/concmap.scala)0
-rw-r--r--test/files/run/ctries-new/iterator.scala (renamed from test/files/run/ctries/iterator.scala)0
-rw-r--r--test/files/run/ctries-new/lnode.scala (renamed from test/files/run/ctries/lnode.scala)0
-rw-r--r--test/files/run/ctries-new/main.scala45
-rw-r--r--test/files/run/ctries-new/snapshot.scala (renamed from test/files/run/ctries/snapshot.scala)0
-rw-r--r--test/files/run/ctries-old/DumbHash.scala14
-rw-r--r--test/files/run/ctries-old/Wrap.scala9
-rw-r--r--test/files/run/ctries-old/concmap.scala188
-rw-r--r--test/files/run/ctries-old/iterator.scala289
-rw-r--r--test/files/run/ctries-old/lnode.scala61
-rw-r--r--test/files/run/ctries-old/main.scala (renamed from test/files/run/ctries/main.scala)0
-rw-r--r--test/files/run/ctries-old/snapshot.scala267
-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/existentials3-new.check (renamed from test/files/run/existentials3.check)48
-rw-r--r--test/files/run/existentials3-new.scala (renamed from test/files/run/existentials3.scala)3
-rw-r--r--test/files/run/existentials3-old.check22
-rw-r--r--test/files/run/existentials3-old.scala73
-rw-r--r--test/files/run/getClassTest-new.check (renamed from test/files/run/getClassTest.check)0
-rw-r--r--test/files/run/getClassTest-new.scala66
-rw-r--r--test/files/run/getClassTest-old.check18
-rw-r--r--test/files/run/getClassTest-old.scala (renamed from test/files/run/getClassTest.scala)10
-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.check6
-rw-r--r--test/files/run/interop_classtags_are_classmanifests.scala17
-rw-r--r--test/files/run/interop_concretetypetags_are_classmanifests.check3
-rw-r--r--test/files/run/interop_concretetypetags_are_classmanifests.scala9
-rw-r--r--test/files/run/interop_concretetypetags_are_manifests.check3
-rw-r--r--test/files/run/interop_concretetypetags_are_manifests.scala9
-rw-r--r--test/files/run/interop_manifests_are_classtags.check24
-rw-r--r--test/files/run/interop_manifests_are_classtags.scala23
-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.check6
-rw-r--r--test/files/run/interop_manifests_are_typetags.scala10
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala7
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.check5
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.flags1
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala29
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala4
-rw-r--r--test/files/run/manifests-new.scala147
-rw-r--r--test/files/run/manifests-old.scala (renamed from test/files/run/manifests.scala)30
-rw-r--r--test/files/run/patmat_unapp_abstype-new.check (renamed from test/files/run/patmat_unapp_abstype.check)0
-rw-r--r--test/files/run/patmat_unapp_abstype-new.flags (renamed from test/files/run/patmat_unapp_abstype.flags)0
-rw-r--r--test/files/run/patmat_unapp_abstype-new.scala (renamed from test/files/run/patmat_unapp_abstype.scala)0
-rw-r--r--test/files/run/patmat_unapp_abstype-old.check4
-rw-r--r--test/files/run/patmat_unapp_abstype-old.flags1
-rw-r--r--test/files/run/patmat_unapp_abstype-old.scala83
-rw-r--r--test/files/run/primitive-sigs-2-new.check (renamed from test/files/run/primitive-sigs-2.check)2
-rw-r--r--test/files/run/primitive-sigs-2-new.scala31
-rw-r--r--test/files/run/primitive-sigs-2-old.check7
-rw-r--r--test/files/run/primitive-sigs-2-old.scala (renamed from test/files/run/primitive-sigs-2.scala)0
-rw-r--r--test/files/run/reflection-implClass-new.scala38
-rw-r--r--test/files/run/reflection-implClass-old.scala (renamed from test/files/run/reflection-implClass.scala)4
-rw-r--r--test/files/run/reify_implicits-new.check (renamed from test/files/run/reify_implicits.check)0
-rw-r--r--test/files/run/reify_implicits-new.scala14
-rw-r--r--test/files/run/reify_implicits-old.check1
-rw-r--r--test/files/run/reify_implicits-old.scala (renamed from test/files/run/reify_implicits.scala)0
-rw-r--r--test/files/run/repl-power.check64
-rw-r--r--test/files/run/repl-power.scala3
-rw-r--r--test/files/run/t0421-new.check (renamed from test/files/run/t0421.check)0
-rw-r--r--test/files/run/t0421-new.scala30
-rw-r--r--test/files/run/t0421-old.check3
-rw-r--r--test/files/run/t0421-old.scala (renamed from test/files/run/t0421.scala)0
-rw-r--r--test/files/run/t0677-new.scala8
-rw-r--r--test/files/run/t0677-old.scala (renamed from test/files/run/t0677.scala)0
-rw-r--r--test/files/run/t1195-new.check (renamed from test/files/run/t1195.check)0
-rw-r--r--test/files/run/t1195-new.scala (renamed from test/files/run/t1195.scala)2
-rw-r--r--test/files/run/t1195-old.check6
-rw-r--r--test/files/run/t1195-old.scala26
-rw-r--r--test/files/run/t2236-new.scala17
-rw-r--r--[-rwxr-xr-x]test/files/run/t2236-old.scala (renamed from test/files/run/t2236.scala)0
-rw-r--r--test/files/run/t2386-new.check2
-rw-r--r--test/files/run/t2386-new.scala5
-rw-r--r--test/files/run/t3507-new.check (renamed from test/files/run/t3507.check)0
-rw-r--r--test/files/run/t3507-new.scala (renamed from test/files/run/t3507.scala)2
-rw-r--r--test/files/run/t3758-old.scala10
-rw-r--r--test/files/run/t3758.check6
-rw-r--r--test/files/run/t3758.scala10
-rw-r--r--test/files/run/t4110-new.check (renamed from test/files/run/t4110.check)0
-rw-r--r--test/files/run/t4110-new.scala11
-rw-r--r--test/files/run/t4110-old.check2
-rw-r--r--test/files/run/t4110-old.scala (renamed from test/files/run/t4110.scala)2
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.check5
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.scala17
-rw-r--r--test/files/run/typetags_core.check62
-rw-r--r--test/files/run/typetags_core.scala2
-rw-r--r--test/files/run/typetags_multi.check5
-rw-r--r--test/files/run/typetags_multi.scala7
-rw-r--r--test/files/scalacheck/array-new.scala36
-rw-r--r--test/files/scalacheck/array-old.scala (renamed from test/files/scalacheck/array.scala)0
-rw-r--r--test/files/specialized/spec-matrix-new.check (renamed from test/files/specialized/spec-matrix.check)0
-rw-r--r--test/files/specialized/spec-matrix-new.scala80
-rw-r--r--test/files/specialized/spec-matrix-old.check2
-rw-r--r--test/files/specialized/spec-matrix-old.scala (renamed from test/files/specialized/spec-matrix.scala)0
-rw-r--r--test/files/speclib/instrumented.jar.desired.sha12
-rw-r--r--test/instrumented/boxes.patch40
-rw-r--r--test/instrumented/library/scala/runtime/BoxesRunTime.java384
-rw-r--r--test/instrumented/library/scala/runtime/ScalaRunTime.scala93
-rw-r--r--test/instrumented/srt.patch17
-rw-r--r--test/pending/pos/inference.scala20
-rw-r--r--test/pending/shootout/meteor.scala64
-rw-r--r--test/scaladoc/resources/implicits-base-res.scala3
318 files changed, 6319 insertions, 1882 deletions
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1
index 7479a1861e..5a541f8cf3 100644
--- a/lib/scala-compiler.jar.desired.sha1
+++ b/lib/scala-compiler.jar.desired.sha1
@@ -1 +1 @@
-5d99e65aaa8e00c4815e011a8dfc495cb38bdfcc ?scala-compiler.jar
+c020eccb8cf37963725985f36b44d070915cf4d2 ?scala-compiler.jar
diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1
index 76914369b5..d059e861f0 100644
--- a/lib/scala-library.jar.desired.sha1
+++ b/lib/scala-library.jar.desired.sha1
@@ -1 +1 @@
-53ddaba2c7d56b360eda1a56c3eef5ec23ef14ca ?scala-library.jar
+31c7188cef85c28b84b9ce35bc6780996e5dd139 ?scala-library.jar
diff --git a/src/compiler/scala/reflect/internal/AnnotationInfos.scala b/src/compiler/scala/reflect/internal/AnnotationInfos.scala
index b86c62661a..fe0175fe72 100644
--- a/src/compiler/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/compiler/scala/reflect/internal/AnnotationInfos.scala
@@ -260,8 +260,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
}
}
- lazy val classfileAnnotArgManifest: ClassManifest[ClassfileAnnotArg] =
- reflect.ClassManifest[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
+ lazy val classfileAnnotArgTag: ArrayTag[ClassfileAnnotArg] = arrayTag[ClassfileAnnotArg]
object UnmappableAnnotation extends CompleteAnnotationInfo(NoType, Nil, Nil)
}
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index 24fc7c7cc4..6cb935edad 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -380,6 +380,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
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)
// classes with special meanings
lazy val StringAddClass = getRequiredClass("scala.runtime.StringAdd")
@@ -409,7 +411,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val EqualsPatternClass = specialPolyClass(tpnme.EQUALS_PATTERN_NAME, 0L)(_ => AnyClass.tpe)
lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS_NAME, COVARIANT)(tparam => arrayType(tparam.tpe))
lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS_NAME, COVARIANT)(tparam => seqType(tparam.tpe))
-
+
lazy val MarkerCPSTypes = getClassIfDefined("scala.util.continuations.cpsParam")
def isByNameParamType(tp: Type) = tp.typeSymbol == ByNameParamClass
@@ -479,7 +481,16 @@ trait Definitions extends reflect.api.StandardDefinitions {
// scala.reflect
lazy val ReflectPackageClass = getMember(ScalaPackageClass, nme.reflect)
lazy val ReflectPackage = getPackageObject("scala.reflect")
- def Reflect_mirror = getMember(ReflectPackage, nme.mirror)
+ 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 PartialManifestClass = getRequiredClass("scala.reflect.ClassManifest")
+ lazy val PartialManifestModule = getRequiredModule("scala.reflect.ClassManifest")
+ lazy val FullManifestClass = getRequiredClass("scala.reflect.Manifest")
+ lazy val FullManifestModule = getRequiredModule("scala.reflect.Manifest")
+ lazy val OptManifestClass = getRequiredClass("scala.reflect.OptManifest")
+ lazy val NoManifest = getRequiredModule("scala.reflect.NoManifest")
lazy val ExprClass = getMember(getRequiredClass("scala.reflect.api.Exprs"), tpnme.Expr)
def ExprTree = getMemberClass(ExprClass, nme.tree)
@@ -488,6 +499,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
def ExprValue = getMember(ExprClass, nme.value)
lazy val ExprModule = getMember(getRequiredClass("scala.reflect.api.Exprs"), nme.Expr)
+ 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]
@@ -496,7 +509,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val ConcreteTypeTagClass = getMemberClass(TypeTagsClass, tpnme.ConcreteTypeTag)
lazy val ConcreteTypeTagModule = getMemberModule(TypeTagsClass, nme.ConcreteTypeTag)
- def ClassTagErasure = getMemberMethod(ClassTagClass, nme.erasure)
+ 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)
@@ -507,6 +522,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
def MacroContextReify = getMember(MacroContextClass, nme.reify)
lazy val MacroImplAnnotation = getRequiredClass("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)
@@ -524,9 +541,9 @@ trait Definitions extends reflect.api.StandardDefinitions {
// private lazy val importerFromRm = self.mkImporter(rm)
private lazy val importerFromRm = self.mkImporter(rm).asInstanceOf[self.Importer { val from: rm.type }]
- def manifestToType(m: Manifest[_]): Type = importerFromRm.importType(m.tpe)
+ def compilerTypeFromTag(t: rm.TypeTag[_]): Type = importerFromRm.importType(t.tpe)
- def manifestToSymbol(m: Manifest[_]): Symbol = importerFromRm.importSymbol(m.tpe.typeSymbol)
+ def compilerSymbolFromTag(t: rm.TypeTag[_]): Symbol = importerFromRm.importSymbol(t.sym)
// The given symbol represents either String.+ or StringAdd.+
def isStringAddition(sym: Symbol) = sym == String_+ || sym == StringAdd_+
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index 54be83c98f..a55efea2e6 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -562,6 +562,9 @@ trait StdNames {
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"
@@ -579,6 +582,7 @@ trait StdNames {
val checkInitialized: NameType = "checkInitialized"
val classOf: NameType = "classOf"
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 definitions: NameType = "definitions"
@@ -627,10 +631,13 @@ trait StdNames {
val macroContext : NameType = "c"
val main: NameType = "main"
val manifest: NameType = "manifest"
+ val manifestToConcreteTypeTag: NameType = "manifestToConcreteTypeTag"
val map: NameType = "map"
+ val materializeArrayTag: NameType = "materializeArrayTag"
val materializeClassTag: NameType = "materializeClassTag"
- val materializeTypeTag: NameType = "materializeTypeTag"
val materializeConcreteTypeTag: NameType = "materializeConcreteTypeTag"
+ val materializeErasureTag: NameType= "materializeErasureTag"
+ val materializeTypeTag: NameType = "materializeTypeTag"
val mirror : NameType = "mirror"
val moduleClass : NameType = "moduleClass"
val name: NameType = "name"
@@ -813,10 +820,11 @@ trait StdNames {
val ROOTPKG: TermName = "_root_"
val EQEQ_LOCAL_VAR: TermName = "eqEqTemp$"
- def getCause = sn.GetCause
- def getClass_ = sn.GetClass
- def getMethod_ = sn.GetMethod
- def invoke_ = sn.Invoke
+ def getCause = sn.GetCause
+ def getClass_ = sn.GetClass
+ def getComponentType = sn.GetComponentType
+ def getMethod_ = sn.GetMethod
+ def invoke_ = sn.Invoke
val ADD = encode("+")
val AND = encode("&")
@@ -1005,6 +1013,7 @@ trait StdNames {
val ForName : TermName
val GetCause : TermName
val GetClass : TermName
+ val GetComponentType : TermName
val GetMethod : TermName
val Invoke : TermName
val JavaLang : TermName
@@ -1090,12 +1099,13 @@ trait StdNames {
final val Throwable: TypeName = "java.lang.Throwable"
final val ValueType: TypeName = tpnme.NO_NAME
- final val ForName: TermName = newTermName("forName")
- final val GetCause: TermName = newTermName("getCause")
- final val GetClass: TermName = newTermName("getClass")
- final val GetMethod: TermName = newTermName("getMethod")
- final val Invoke: TermName = newTermName("invoke")
- final val JavaLang: TermName = newTermName("java.lang")
+ final val ForName: TermName = newTermName("forName")
+ final val GetCause: TermName = newTermName("getCause")
+ final val GetClass: TermName = newTermName("getClass")
+ final val GetComponentType: TermName = newTermName("getComponentType")
+ final val GetMethod: TermName = newTermName("getMethod")
+ final val Invoke: TermName = newTermName("invoke")
+ final val JavaLang: TermName = newTermName("java.lang")
val Boxed = immutable.Map[TypeName, TypeName](
tpnme.Boolean -> BoxedBoolean,
@@ -1127,12 +1137,13 @@ trait StdNames {
final val Throwable: TypeName = "System.Exception"
final val ValueType: TypeName = "System.ValueType"
- final val ForName: TermName = newTermName("GetType")
- final val GetCause: TermName = newTermName("InnerException") /* System.Reflection.TargetInvocationException.InnerException */
- final val GetClass: TermName = newTermName("GetType")
- final val GetMethod: TermName = newTermName("GetMethod")
- final val Invoke: TermName = newTermName("Invoke")
- final val JavaLang: TermName = newTermName("System")
+ final val ForName: TermName = newTermName("GetType")
+ final val GetCause: TermName = newTermName("InnerException") /* System.Reflection.TargetInvocationException.InnerException */
+ final val GetClass: TermName = newTermName("GetType")
+ final val GetComponentType: TermName = newTermName("GetElementType")
+ final val GetMethod: TermName = newTermName("GetMethod")
+ final val Invoke: TermName = newTermName("Invoke")
+ final val JavaLang: TermName = newTermName("System")
val Boxed = immutable.Map[TypeName, TypeName](
tpnme.Boolean -> "System.Boolean",
diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala
index 937b3ea5d6..48dfe8bcfc 100644
--- a/src/compiler/scala/reflect/internal/TreeInfo.scala
+++ b/src/compiler/scala/reflect/internal/TreeInfo.scala
@@ -676,14 +676,14 @@ abstract class TreeInfo {
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))))
+ 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))))
+ 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: " + showRaw(tree))
+ throw new Error("unsupported free type def: %s%n%s".format(value, showRaw(value)))
}
case _ =>
None
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 32b09eddeb..815a5c0710 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -264,7 +264,23 @@ trait Types extends api.Types { self: SymbolTable =>
def nonPrivateDeclaration(name: Name): Symbol = nonPrivateDecl(name)
def declarations = decls
def typeArguments = typeArgs
- def erasure = transformedType(this)
+ def erasure = this match {
+ case ConstantType(value) => widen.erasure // [Eugene to Martin] constant types are unaffected by erasure. weird.
+ case _ =>
+ var result = 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
+ }
+ // [Eugene] erasure screws up all ThisTypes for modules into PackageTypeRefs
+ // we need to unscrew them, or certain typechecks will fail mysteriously
+ // http://groups.google.com/group/scala-internals/browse_thread/thread/6d3277ae21b6d581
+ result = result.map(tpe => tpe match {
+ case tpe: PackageTypeRef => ThisType(tpe.sym)
+ case _ => tpe
+ })
+ result
+ }
def substituteTypes(from: List[Symbol], to: List[Type]): Type = subst(from, to)
// [Eugene] to be discussed and refactored
@@ -1342,7 +1358,8 @@ trait Types extends api.Types { self: SymbolTable =>
if (period != currentPeriod) {
tpe.underlyingPeriod = currentPeriod
if (!isValid(period)) {
- tpe.underlyingCache = tpe.pre.memberType(tpe.sym).resultType;
+ // [Eugene to Paul] needs review
+ tpe.underlyingCache = if (tpe.sym == NoSymbol) ThisType(RootClass) else tpe.pre.memberType(tpe.sym).resultType;
assert(tpe.underlyingCache ne tpe, tpe)
}
}
diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
index eb4bae78d0..fd3fac1b37 100644
--- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
@@ -447,7 +447,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(classfileAnnotArgManifest)
+ until(end, () => readClassfileAnnotArg(readNat())).toArray(classfileAnnotArgTag)
}
protected def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match {
case ANNOTINFO => NestedAnnotArg(at(i, readAnnotation))
@@ -843,7 +843,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
atPhase(p) (sym setInfo tp)
if (currentRunId != definedAtRunId)
sym.setInfo(adaptToNewRunMap(tp))
- }
+ }
catch {
case e: MissingRequirementError => throw toTypeError(e)
}
diff --git a/src/compiler/scala/reflect/internal/util/Origins.scala b/src/compiler/scala/reflect/internal/util/Origins.scala
index b9985c8f50..19b3adda9d 100644
--- a/src/compiler/scala/reflect/internal/util/Origins.scala
+++ b/src/compiler/scala/reflect/internal/util/Origins.scala
@@ -88,7 +88,7 @@ object Origins {
sys.addShutdownHook(counters foreach (_.purge()))
}
- def apply[T: Manifest](tag: String): Origins = apply(tag, manifest[T].erasure)
+ def apply[T: ClassTag](tag: String): Origins = apply(tag, classTag[T].erasure)
def apply(tag: String, clazz: Class[_]): Origins = apply(tag, new OneLine(clazz))
def apply(tag: String, orElse: => Origins): Origins = {
counters find (_.tag == tag) getOrElse {
diff --git a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
index d9a89d0e6d..1c5af4b752 100644
--- a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
@@ -12,124 +12,23 @@ trait Reifiers {
import mirror._
import definitions._
- private lazy val ClassTagModule = ClassTagClass.companionSymbol
+ lazy val reflectMirrorPrefix: Tree = ReflectMirrorPrefix
- // [Eugene] imho this logic should be moved into `erasure`
- private def calculateTagErasure(tpe: Type) = tpe match {
- case tpe if tpe.typeSymbol.isDerivedValueClass => tpe // [Eugene to Martin] is this correct?
- case ConstantType(value) => tpe.widen.erasure
- case _ =>
- // [Eugene] magikz. needs review
- // necessary to deal with erasures of HK types, typeConstructor won't work
- tpe.erasure.normalize match {
- // we don't want undets in the result
- case PolyType(undets, underlying) => existentialAbstraction(undets, underlying)
- case result => result
- }
- }
- private def classTagFromArgument(tpe: Type, arg: Tree) = {
- gen.mkMethodCall(ClassTagModule, nme.apply, List(tpe), List(arg))
- // val factory = TypeApply(Select(Ident(ClassTagModule), nme.apply), List(TypeTree(tpe)))
- // Apply(factory, List(typeArg))
- }
- private def classTagFromErasure(tpe: Type) = {
- val erasure = calculateTagErasure(tpe)
- classTagFromArgument(tpe, gen.mkNullaryCall(Predef_classOf, List(erasure)))
- // val targ = TypeApply(Select(Ident(PredefModule), nme.classOf), List(TypeTree(erasure)))
- // classTagFromArgument(tpe, targ)
- }
- private def typetagIsSynthetic(tree: Tree) = tree match {
- case Block(_, _) => true
- case _ => tree exists (_ hasSymbolWhich Set(TypeTagModule, ConcreteTypeTagModule))
+ def reifyTree(prefix: Tree, tree: Tree): Tree = {
+ val result = scala.reflect.reify.`package`.reifyTree(mirror)(callsiteTyper, prefix, tree)
+ logFreeVars(enclosingPosition, result)
+ result
}
- lazy val reflectMirrorPrefix: Tree = {
- // [Eugene] how do I typecheck this without undergoing this tiresome (and, in general, incorrect) procedure?
- val prefix: Tree = Select(Select(Ident(definitions.ScalaPackage), newTermName("reflect")), newTermName("mirror"))
- val prefixTpe = typeCheck(TypeApply(Select(prefix, newTermName("asInstanceOf")), List(SingletonTypeTree(prefix)))).tpe
- typeCheck(prefix) setType prefixTpe
+ 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)
+ logFreeVars(enclosingPosition, result)
+ result
}
- def reifyTree(prefix: Tree, tree: Tree): Tree =
- reifyTopLevel(prefix, tree)
-
- def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, requireConcreteTypeTag: Boolean = false): Tree =
- reifyTopLevel(prefix, tpe, dontSpliceAtTopLevel, requireConcreteTypeTag)
-
- def reifyErasure(tpe: Type): Tree = {
- val positionBearer = (enclosingMacros.find(_.macroApplication.pos != NoPosition) match {
- case None => EmptyTree
- case Some(m) => m.macroApplication
- }).asInstanceOf[Tree]
-
- val typetagInScope = callsiteTyper.context.withMacrosDisabled(
- callsiteTyper.resolveTypeTag(
- positionBearer,
- singleType(Reflect_mirror.owner.thisPrefix, Reflect_mirror),
- tpe,
- full = true
- )
- )
- typetagInScope match {
- case success if !success.isEmpty && !typetagIsSynthetic(success) =>
- classTagFromArgument(tpe, typetagInScope)
- case _ =>
- if (tpe.typeSymbol == ArrayClass) {
- val componentTpe = tpe.typeArguments(0)
- val componentTag = callsiteTyper.resolveClassTag(positionBearer, componentTpe)
- Select(componentTag, nme.wrap)
- }
- // [Eugene] what's the intended behavior? there's no spec on ClassManifests
- // for example, should we ban Array[T] or should we tag them with Array[AnyRef]?
- // if its the latter, what should be the result of tagging Array[T] where T <: Int?
- else if (tpe.isSpliceable) {
- throw new ReificationError(enclosingPosition,
- "tpe %s is an unresolved spliceable type".format(tpe))
- }
- else classTagFromErasure(tpe)
- }
- }
+ def reifyErasure(tpe: Type, concrete: Boolean = true): Tree =
+ scala.reflect.reify.`package`.reifyErasure(mirror)(callsiteTyper, tpe, concrete)
def unreifyTree(tree: Tree): Tree =
Select(tree, definitions.ExprEval)
-
- def reifyTopLevel(prefix: Tree, reifee: Any, dontSpliceAtTopLevel: Boolean = false, requireConcreteTypeTag: Boolean = false): Tree = {
- // [Eugene] the plumbing is not very pretty, but anyways factoring out the reifier seems like a necessary step to me
- import scala.reflect.reify._
- val reifier = mkReifier(mirror)(callsiteTyper, prefix, reifee, dontSpliceAtTopLevel, requireConcreteTypeTag)
-
- try {
- val result = reifier.reified
- logFreeVars(enclosingPosition, result)
- result
- } catch {
- case ex: reifier.ReificationError =>
-// // this is a "soft" exception - it will normally be caught by the macro
-// // consequently, we need to log the stack trace here, so that it doesn't get lost
-// if (settings.Yreifydebug.value) {
-// val message = new java.io.StringWriter()
-// ex.printStackTrace(new java.io.PrintWriter(message))
-// println(scala.compat.Platform.EOL + message)
-// }
- val xlated = new ReificationError(ex.pos, ex.msg)
- xlated.setStackTrace(ex.getStackTrace)
- throw xlated
- case ex: reifier.UnexpectedReificationError =>
- val xlated = new UnexpectedReificationError(ex.pos, ex.msg, ex.cause)
- xlated.setStackTrace(ex.getStackTrace)
- throw xlated
- }
- }
-
- class ReificationError(var pos: Position, val msg: String) extends Throwable(msg)
-
- object ReificationError extends ReificationErrorExtractor {
- def unapply(error: ReificationError): Option[(Position, String)] = Some((error.pos, error.msg))
- }
-
- class UnexpectedReificationError(val pos: Position, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause)
-
- object UnexpectedReificationError extends UnexpectedReificationErrorExtractor {
- def unapply(error: UnexpectedReificationError): Option[(Position, String, Throwable)] = Some((error.pos, error.msg, error.cause))
- }
}
diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala
index 30c6c06c7b..1a881455f2 100644
--- a/src/compiler/scala/reflect/reify/Errors.scala
+++ b/src/compiler/scala/reflect/reify/Errors.scala
@@ -1,7 +1,8 @@
package scala.reflect
package reify
-import scala.tools.nsc.Global
+import scala.reflect.makro.ReificationError
+import scala.reflect.makro.UnexpectedReificationError
trait Errors {
self: Reifier =>
@@ -9,9 +10,6 @@ trait Errors {
import mirror._
import definitions._
- class ReificationError(var pos: Position, val msg: String) extends Throwable(msg)
- class UnexpectedReificationError(val pos: Position, val msg: String, val cause: Throwable = null) extends Throwable(msg)
-
lazy val defaultErrorPosition: Position =
mirror.analyzer.openMacros.find(c => c.macroApplication.pos != NoPosition).map(_.macroApplication.pos).getOrElse(NoPosition)
@@ -60,4 +58,4 @@ trait Errors {
val msg = "internal error: erroneous reifees are not supported, make sure that your reifee has typechecked successfully before passing it to the reifier"
throw new UnexpectedReificationError(defaultErrorPosition, msg)
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala
index c89ebf0d39..fea825358e 100644
--- a/src/compiler/scala/reflect/reify/Reifier.scala
+++ b/src/compiler/scala/reflect/reify/Reifier.scala
@@ -2,6 +2,8 @@ package scala.reflect
package reify
import scala.tools.nsc.Global
+import scala.reflect.makro.ReificationError
+import scala.reflect.makro.UnexpectedReificationError
/** 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.
@@ -21,7 +23,7 @@ abstract class Reifier extends Phases
val prefix: Tree
val reifee: Any
val dontSpliceAtTopLevel: Boolean
- val requireConcreteTypeTag: Boolean
+ val concrete: Boolean
/**
* For ``reifee'' and other reification parameters, generate a tree of the form
@@ -47,15 +49,6 @@ abstract class Reifier extends Phases
if (prefix exists (_.isErroneous)) CannotReifyErroneousPrefix(prefix)
if (prefix.tpe == null) CannotReifyUntypedPrefix(prefix)
- def reifyErasure(tpe: Type): Tree = {
- val result = typer.resolveClassTag(positionBearer, tpe)
- if (result == EmptyTree) throw new Error("cannot reify erasure for %s: ".format(tpe))
- result match {
- case Apply(TypeApply(Select(_, _), _), List(clazz)) => clazz
- case _ => Select(result, nme.erasure)
- }
- }
-
val rtree = reifee match {
case tree: Tree =>
reifyTrace("reifying = ")(if (opt.showTrees) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString)
@@ -81,11 +74,11 @@ abstract class Reifier extends Phases
if (tree.tpe exists (sub => sub.typeSymbol.isLocalToReifee))
CannotReifyReifeeThatHasTypeLocalToReifee(tree)
- val manifestedType = typer.packedType(tree, NoSymbol)
- val tagModule = if (definitelyConcrete) ConcreteTypeTagModule else TypeTagModule
- val tagCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(manifestedType)))
- val exprCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), ExprModule.name), List(TypeTree(manifestedType)))
- val tagArgs = if (definitelyConcrete) List(reify(manifestedType), reifyErasure(manifestedType)) else List(reify(manifestedType))
+ 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)))
case tpe: Type =>
@@ -93,10 +86,10 @@ abstract class Reifier extends Phases
reifyTrace("prefix = ")(prefix)
val rtree = reify(tpe)
- val manifestedType = tpe
- val tagModule = if (definitelyConcrete) ConcreteTypeTagModule else TypeTagModule
- val ctor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(manifestedType)))
- val args = if (definitelyConcrete) List(rtree, reifyErasure(manifestedType)) else List(rtree)
+ 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)
case _ =>
@@ -137,9 +130,16 @@ abstract class Reifier extends Phases
// 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)
+ 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
case _ => false
})
diff --git a/src/compiler/scala/reflect/reify/codegen/Symbols.scala b/src/compiler/scala/reflect/reify/codegen/Symbols.scala
index 7f8b9c53b6..21a08b7efb 100644
--- a/src/compiler/scala/reflect/reify/codegen/Symbols.scala
+++ b/src/compiler/scala/reflect/reify/codegen/Symbols.scala
@@ -76,7 +76,7 @@ trait Symbols {
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))))
+ 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))))
}
diff --git a/src/compiler/scala/reflect/reify/codegen/Types.scala b/src/compiler/scala/reflect/reify/codegen/Types.scala
index e2a2a69828..841ec61e60 100644
--- a/src/compiler/scala/reflect/reify/codegen/Types.scala
+++ b/src/compiler/scala/reflect/reify/codegen/Types.scala
@@ -65,11 +65,11 @@ trait Types {
private var spliceTypesEnabled = !dontSpliceAtTopLevel
/** Keeps track of whether this reification contains abstract type parameters */
- private var _definitelyConcrete = true
- def definitelyConcrete = _definitelyConcrete
- def definitelyConcrete_=(value: Boolean) {
- _definitelyConcrete = value
- if (!value && requireConcreteTypeTag) {
+ 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)
@@ -89,7 +89,7 @@ trait Types {
if (reifyDebug) println("splicing " + tpe)
if (spliceTypesEnabled) {
- var tagClass = if (requireConcreteTypeTag) ConcreteTypeTagClass else TypeTagClass
+ 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?
@@ -99,13 +99,13 @@ trait Types {
// 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(positionBearer, prefix.tpe, tpe, requireConcreteTypeTag) match {
+ typer.resolveTypeTag(positionBearer.pos, prefix.tpe, tpe, 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)
- definitelyConcrete &= requireConcreteTypeTag
+ reificationIsConcrete &= concrete
var splice = Select(success, nme.tpe)
splice match {
case InlinedTypeSplice(_, inlinedSymbolTable, tpe) =>
@@ -123,7 +123,7 @@ trait Types {
if (reifyDebug) println("splicing has been cancelled: spliceTypesEnabled = false")
}
- definitelyConcrete = false
+ reificationIsConcrete = false
}
spliceTypesEnabled = true
diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala
index 85cf92fe2f..fa11c6313d 100644
--- a/src/compiler/scala/reflect/reify/package.scala
+++ b/src/compiler/scala/reflect/reify/package.scala
@@ -1,14 +1,16 @@
package scala.reflect
import scala.tools.nsc.Global
+import scala.reflect.makro.ReificationError
+import scala.reflect.makro.UnexpectedReificationError
package object reify {
- def mkReifier(global: Global)(typer: global.analyzer.Typer, prefix: global.Tree, reifee: Any, dontSpliceAtTopLevel: Boolean = false, requireConcreteTypeTag: Boolean = false): Reifier { val mirror: global.type } = {
+ 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 } = {
val typer1: typer.type = typer
val prefix1: prefix.type = prefix
val reifee1 = reifee
val dontSpliceAtTopLevel1 = dontSpliceAtTopLevel
- val requireConcreteTypeTag1 = requireConcreteTypeTag
+ val concrete1 = concrete
new {
val mirror: global.type = global
@@ -16,7 +18,37 @@ package object reify {
val prefix = prefix1
val reifee = reifee1
val dontSpliceAtTopLevel = dontSpliceAtTopLevel1
- val requireConcreteTypeTag = requireConcreteTypeTag1
+ 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]
+
+ 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 reifyErasure(global: Global)(typer0: global.analyzer.Typer, tpe: global.Type, concrete: Boolean = true): global.Tree = {
+ import global._
+ import definitions._
+ val positionBearer = analyzer.openMacros.find(_.macroApplication.pos != NoPosition).map(_.macroApplication).getOrElse(EmptyTree).asInstanceOf[Tree]
+ val inScope = typer0.context.withMacrosDisabled(typer0.resolveErasureTag(positionBearer.pos, tpe, concrete = concrete), typer0.resolveArrayTag(positionBearer.pos, tpe))
+ inScope match {
+ case (success, _) if !success.isEmpty =>
+ Select(success, nme.erasure)
+ case (_, success) if !success.isEmpty =>
+ gen.mkMethodCall(arrayElementClassMethod, List(success))
+ case _ =>
+ if (tpe.typeSymbol == ArrayClass) {
+ val componentTpe = tpe.typeArguments(0)
+ val componentErasure = reifyErasure(global)(typer0, componentTpe, concrete)
+ gen.mkMethodCall(arrayClassMethod, List(componentErasure))
+ } else {
+ if (tpe.isSpliceable && concrete) throw new ReificationError(positionBearer.pos, "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))
+ }
+ }
+ }
}
diff --git a/src/compiler/scala/reflect/runtime/Mirror.scala b/src/compiler/scala/reflect/runtime/Mirror.scala
index 20024ed058..bf4bc83bea 100644
--- a/src/compiler/scala/reflect/runtime/Mirror.scala
+++ b/src/compiler/scala/reflect/runtime/Mirror.scala
@@ -25,7 +25,7 @@ class Mirror(var classLoader: ClassLoader) extends Universe with api.Mirror {
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 : Manifest](x: T): Symbol = manifest[T].getClass
+ // def getClass[T <: AnyVal : ClassTag](x: T): Symbol = classTag[T].sym
def getValueOfField(receiver: AnyRef, field: Symbol): Any = {
fieldToJava(field).get(receiver)
diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala
index 9592e7a716..91356b3c19 100644
--- a/src/compiler/scala/tools/cmd/FromString.scala
+++ b/src/compiler/scala/tools/cmd/FromString.scala
@@ -7,19 +7,19 @@ package scala.tools
package cmd
import nsc.io.{ Path, File, Directory }
-import scala.reflect.Manifest
+import scala.reflect.TypeTag
/** 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 m: Manifest[T]) extends PartialFunction[String, T] {
+abstract class FromString[+T](implicit t: TypeTag[T]) extends PartialFunction[String, T] {
def apply(s: String): T
def isDefinedAt(s: String): Boolean = true
def zero: T = apply("")
- def targetString: String = m.toString
+ def targetString: String = t.toString
}
object FromString {
diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala
index 1fa576afb6..aa0ea1bdd8 100644
--- a/src/compiler/scala/tools/nsc/Phases.scala
+++ b/src/compiler/scala/tools/nsc/Phases.scala
@@ -14,7 +14,7 @@ object Phases {
/** A class for tracking something about each phase.
*/
- class Model[T: Manifest] {
+ class Model[T] {
case class Cell(ph: Phase, value: T) {
def name = ph.name
def id = ph.id
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index d3e64811d3..978d83616b 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -177,6 +177,22 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL {
def mkSysErrorCall(message: String): Tree =
mkMethodCall(Sys_error, List(Literal(Constant(message))))
+ /** A creator for a call to a scala.reflect.Manifest or ClassManifest factory method.
+ *
+ * @param full full or partial manifest (target will be Manifest or ClassManifest)
+ * @param constructor name of the factory method (e.g. "classType")
+ * @param tparg the type argument
+ * @param args value arguments
+ * @return the tree
+ */
+ def mkManifestFactoryCall(full: Boolean, constructor: String, tparg: Type, args: List[Tree]): Tree =
+ mkMethodCall(
+ if (full) FullManifestModule else PartialManifestModule,
+ newTermName(constructor),
+ List(tparg),
+ args
+ )
+
/** Make a synchronized block on 'monitor'. */
def mkSynchronized(monitor: Tree, body: Tree): Tree =
Apply(Select(monitor, Object_synchronized), List(body))
diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala
index 17bfb7d21d..d3a1d47de8 100644
--- a/src/compiler/scala/tools/nsc/doc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/doc/Settings.scala
@@ -150,12 +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.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"))
/**
* Set of classes to exclude from index and diagrams
diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
index f67abc58da..3ff973ec66 100644
--- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
@@ -41,13 +41,13 @@ private[html] object SyntaxHigh {
/** Standard library classes/objects, sorted alphabetically */
val standards = Array (
"Any", "AnyRef", "AnyVal", "App", "Application", "Array",
- "Boolean", "Byte", "Char", "Class", "Console", "Double",
- "Enumeration", "Float", "Function", "Int",
+ "Boolean", "Byte", "Char", "Class", "ClassTag", "ClassManifest", "ConcreteTypeTag",
+ "Console", "Double", "Enumeration", "Float", "Function", "Int",
"List", "Long", "Manifest", "Map",
- "None", "Nothing", "Null", "Object", "Option",
+ "NoManifest", "None", "Nothing", "Null", "Object", "Option", "OptManifest",
"Pair", "Predef",
"Seq", "Set", "Short", "Some", "String", "Symbol",
- "Triple", "Unit")
+ "Triple", "TypeTag", "Unit")
def apply(data: String): NodeSeq = {
val buf = data.getBytes
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index 4e03dc8788..61f3670f5f 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -137,7 +137,7 @@ trait ModelFactoryImplicitSupport {
// Members inherited by implicit conversions cannot override actual members
memberSyms = memberSyms.filterNot((sym1: Symbol) =>
- existingMembers.exists(sym2 => sym1.name == sym2.name &&
+ existingMembers.exists(sym2 => sym1.name == sym2.name &&
!isDistinguishableFrom(toType.memberInfo(sym1), sym.info.memberInfo(sym2))))
debug(" -> full type: " + toType)
@@ -199,12 +199,12 @@ trait ModelFactoryImplicitSupport {
* What? in details:
* - say we start from a class A[T1, T2, T3, T4]
* - we have an implicit function (view) in scope:
- * def pimpA[T3 <: Long, T4](a: A[Int, Foo[Bar[X]], T3, T4])(implicit ev1: Manifest[T4], ev2: Numeric[T4]): PimpedA
+ * def pimpA[T3 <: Long, T4](a: A[Int, Foo[Bar[X]], T3, T4])(implicit ev1: TypeTag[T4], ev2: Numeric[T4]): PimpedA
* - A is converted to PimpedA ONLY if a couple of constraints are satisfied:
* * T1 must be equal to Int
* * T2 must be equal to Foo[Bar[X]]
* * T3 must be upper bounded by Long
- * * there must be evidence of Numeric[T4] and a Mainfest[T4] within scope
+ * * there must be evidence of Numeric[T4] and a TypeTag[T4] within scope
* - the final type is PimpedA and A therefore inherits a couple of members from pimpedA
*
* How?
@@ -504,14 +504,14 @@ trait ModelFactoryImplicitSupport {
* class. We suppose the name of the two members coincides
*
* The trick here is that the resultType does not matter - the condition for removal it that paramss have the same
- * structure (A => B => C may not override (A, B) => C) and that all the types involved are
+ * structure (A => B => C may not override (A, B) => C) and that all the types involved are
* of the implcit conversion's member are subtypes of the parent members' parameters */
- def isDistinguishableFrom(t1: Type, t2: Type): Boolean =
+ def isDistinguishableFrom(t1: Type, t2: Type): Boolean =
if (t1.paramss.map(_.length) == t2.paramss.map(_.length)) {
for ((t1p, t2p) <- t1.paramss.flatten zip t2.paramss.flatten)
if (!isSubType(t1 memberInfo t1p, t2 memberInfo t2p))
- return true // if on the corresponding parameter you give a type that is in t1 but not in t2
- // example:
+ return true // if on the corresponding parameter you give a type that is in t1 but not in t2
+ // example:
// def foo(a: Either[Int, Double]): Int = 3
// def foo(b: Left[T1]): Int = 6
// a.foo(Right(4.5d)) prints out 3 :)
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index 9279d37464..297d6ad1b9 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -1053,11 +1053,11 @@ object ILoop {
// provide the enclosing type T
// in order to set up the interpreter's classpath and parent class loader properly
- def breakIf[T: Manifest](assertion: => Boolean, args: NamedParam*): Unit =
+ def breakIf[T: ClassTag](assertion: => Boolean, args: NamedParam*): Unit =
if (assertion) break[T](args.toList)
// start a repl, binding supplied args
- def break[T: Manifest](args: List[NamedParam]): Unit = savingContextLoader {
+ def break[T: ClassTag](args: List[NamedParam]): Unit = savingContextLoader {
val msg = if (args.isEmpty) "" else " Binding " + args.size + " value%s.".format(
if (args.size == 1) "" else "s"
)
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
index 2f02748e8f..6a9654732b 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala
@@ -100,7 +100,7 @@ trait ILoopInit {
withLock { while (!initIsComplete) initLoopCondition.await() }
}
// private def warningsThunks = List(
- // () => intp.bind("lastWarnings", "" + manifest[List[(Position, String)]], intp.lastWarnings _),
+ // () => intp.bind("lastWarnings", "" + typeTag[List[(Position, String)]], intp.lastWarnings _),
// )
protected def postInitThunks = List[Option[() => Unit]](
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index 923fc867a9..3d77344091 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -351,7 +351,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
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 manifests for the compiler
+ // 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
}
@@ -667,7 +667,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
result
}
def directBind(p: NamedParam): IR.Result = directBind(p.name, p.tpe, p.value)
- def directBind[T: Manifest](name: String, value: T): IR.Result = directBind((name, value))
+ def directBind[T: ClassTag](name: String, value: T): IR.Result = directBind((name, value))
def rebind(p: NamedParam): IR.Result = {
val name = p.name
@@ -683,12 +683,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: Manifest](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: 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)
/** Reset this interpreter, forgetting all user-specified requests. */
def reset() {
@@ -1185,9 +1185,10 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
val termname = newTypeName(name)
findName(termname) orElse getModuleIfDefined(termname)
}
- def types[T: ClassManifest] : Symbol = types(classManifest[T].erasure.getName)
- def terms[T: ClassManifest] : Symbol = terms(classManifest[T].erasure.getName)
- def apply[T: ClassManifest] : Symbol = apply(classManifest[T].erasure.getName)
+ // [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 classSymbols = allDefSymbols collect { case x: ClassSymbol => x }
def methodSymbols = allDefSymbols collect { case x: MethodSymbol => x }
diff --git a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
index e2b1bf34d6..a3cbfffc3b 100644
--- a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala
@@ -13,19 +13,19 @@ trait NamedParamCreator {
protected def freshName: () => String
def apply(name: String, tpe: String, value: Any): NamedParam = NamedParamClass(name, tpe, value)
- def apply[T: Manifest](name: String, x: T): NamedParam = new Typed[T](name, x)
- def apply[T: Manifest](x: T): NamedParam = apply(freshName(), x)
+ 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 clazz(name: String, x: Any): NamedParam = new Untyped(name, x)
def clazz(x: Any): NamedParam = clazz(freshName(), x)
- implicit def namedValue[T: Manifest](name: String, x: T): NamedParam = apply(name, x)
- implicit def tuple[T: Manifest](pair: (String, T)): NamedParam = apply(pair._1, pair._2)
+ 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)
}
object NamedParam extends NamedParamCreator {
- class Typed[T: Manifest](val name: String, val value: T) extends NamedParam {
- val tpe = TypeStrings.fromManifest[T]
+ class Typed[T: TypeTag](val name: String, val value: T) extends NamedParam {
+ val tpe = TypeStrings.fromTag[T]
}
class Untyped(val name: String, val value: Any) extends NamedParam {
val tpe = TypeStrings.fromValue(value)
diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala
index 2cb034f7ab..01ace0e984 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Power.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala
@@ -42,10 +42,10 @@ Lost after 18/flatten {
/** A class for methods to be injected into the intp in power mode.
*/
-class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: ReplValsImpl) {
+class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplValsImpl) {
import intp.{ beQuietDuring, typeOfExpression, interpret, parse }
import intp.global._
- import definitions.{ manifestToType, manifestToSymbol, getClassIfDefined, getModuleIfDefined }
+ import definitions.{ compilerTypeFromTag, compilerSymbolFromTag, getClassIfDefined, getModuleIfDefined }
abstract class SymSlurper {
def isKeep(sym: Symbol): Boolean
@@ -162,7 +162,7 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
}
trait LowPriorityInternalInfo {
- implicit def apply[T: Manifest] : InternalInfo[T] = new InternalInfo[T](None)
+ implicit def apply[T: TypeTag] : InternalInfo[T] = new InternalInfo[T](None)
}
object InternalInfo extends LowPriorityInternalInfo { }
@@ -173,21 +173,21 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
* of the conveniences exist on that wrapper.
*/
trait LowPriorityInternalInfoWrapper {
- implicit def apply[T: Manifest] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None)
+ implicit def apply[T: TypeTag] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None)
}
object InternalInfoWrapper extends LowPriorityInternalInfoWrapper {
}
- class InternalInfoWrapper[T: Manifest](value: Option[T] = None) {
+ class InternalInfoWrapper[T: TypeTag](value: Option[T] = None) {
def ? : InternalInfo[T] = new InternalInfo[T](value)
}
/** Todos...
- * translate manifest type arguments into applied types
+ * translate tag type arguments into applied types
* customizable symbol filter (had to hardcode no-spec to reduce noise)
*/
- class InternalInfo[T: Manifest](value: Option[T] = None) {
- private def newInfo[U: Manifest](value: U): InternalInfo[U] = new InternalInfo[U](Some(value))
+ class InternalInfo[T: TypeTag](value: Option[T] = None) {
+ private def newInfo[U: TypeTag](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"
@@ -198,8 +198,8 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
|| s.isAnonOrRefinementClass
|| s.isAnonymousFunction
)
- def symbol = manifestToSymbol(fullManifest)
- def tpe = manifestToType(fullManifest)
+ def symbol = compilerSymbolFromTag(tag)
+ def tpe = compilerTypeFromTag(tag)
def name = symbol.name
def companion = symbol.companionSymbol
def info = symbol.info
@@ -226,8 +226,8 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
def pkgClasses = pkgMembers filter (s => s.isClass && s.isDefinedInPackage)
def pkgSymbols = new PackageSlurper(pkgClass).slurp() filterNot excludeMember
- def fullManifest = manifest[T]
- def erasure = fullManifest.erasure
+ def tag = typeTag[T]
+ def erasure = tag.erasure
def shortClass = erasure.getName split "[$.]" last
def baseClasses = tpe.baseClasses
@@ -236,9 +236,9 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
def ancestorDeclares(name: String) = ancestors filter (_.info member newTermName(name) ne NoSymbol)
def baseTypes = tpe.baseTypeSeq.toList
- def <:<[U: Manifest](other: U) = tpe <:< newInfo(other).tpe
- def lub[U: Manifest](other: U) = intp.global.lub(List(tpe, newInfo(other).tpe))
- def glb[U: Manifest](other: U) = intp.global.glb(List(tpe, newInfo(other).tpe))
+ 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))
override def toString = value match {
case Some(x) => "%s (%s)".format(x, shortClass)
@@ -366,7 +366,7 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
implicit lazy val powerSymbolOrdering: Ordering[Symbol] = Ordering[Name] on (_.name)
implicit lazy val powerTypeOrdering: Ordering[Type] = Ordering[Symbol] on (_.typeSymbol)
- implicit def replInternalInfo[T: Manifest](x: T): InternalInfoWrapper[T] = new InternalInfoWrapper[T](Some(x))
+ implicit def replInternalInfo[T: TypeTag](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)
@@ -381,10 +381,13 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl
}
trait ReplUtilities {
- def module[T: Manifest] = getModuleIfDefined(manifest[T].erasure.getName stripSuffix nme.MODULE_SUFFIX_STRING)
- def clazz[T: Manifest] = getClassIfDefined(manifest[T].erasure.getName)
- def info[T: Manifest] = InternalInfo[T]
- def ?[T: Manifest] = InternalInfo[T]
+ // [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 url(s: String) = {
try new URL(s)
catch { case _: MalformedURLException =>
diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
index 4efab7e260..280247f20c 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc
package interpreter
+import scala.reflect.{mirror => rm}
import language.implicitConversions
/** A class which the repl utilizes to expose predefined objects.
@@ -39,8 +40,8 @@ class StdReplVals(final val r: ILoop) extends ReplVals {
class ReplImplicits extends power.Implicits2 {
import intp.global._
- private val manifestFn = ReplVals.mkManifestToType[intp.global.type](global)
- implicit def mkManifestToType(sym: Symbol) = manifestFn(sym)
+ private val tagFn = ReplVals.mkCompilerTypeFromTag[intp.global.type](global)
+ implicit def mkCompilerTypeFromTag(sym: Symbol) = tagFn(sym)
}
final lazy val replImplicits = new ReplImplicits
@@ -53,29 +54,29 @@ object ReplVals {
* not being seen as the same type as bar.global.Type even though
* the globals are the same. Dependent method types to the rescue.
*/
- def mkManifestToType[T <: Global](global: T) = {
+ def mkCompilerTypeFromTag[T <: Global](global: T) = {
import global._
import definitions._
- /** We can't use definitions.manifestToType directly because we're passing
+ /** We can't use definitions.compilerTypeFromTag directly because we're passing
* it to map and the compiler refuses to perform eta expansion on a method
* with a dependent return type. (Can this be relaxed?) To get around this
* I have this forwarder which widens the type and then cast the result back
* to the dependent type.
*/
- def manifestToType(m: Manifest[_]): Global#Type =
- definitions.manifestToType(m)
+ def compilerTypeFromTag(t: rm.TypeTag[_]): Global#Type =
+ definitions.compilerTypeFromTag(t)
- class AppliedTypeFromManifests(sym: Symbol) {
- def apply[M](implicit m1: Manifest[M]): Type =
+ class AppliedTypeFromTags(sym: Symbol) {
+ def apply[M](implicit m1: rm.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
- else appliedType(sym, manifestToType(m1).asInstanceOf[Type])
+ else appliedType(sym, compilerTypeFromTag(m1).asInstanceOf[Type])
- def apply[M1, M2](implicit m1: Manifest[M1], m2: Manifest[M2]): Type =
+ def apply[M1, M2](implicit m1: rm.TypeTag[M1], m2: rm.TypeTag[M2]): Type =
if (sym eq NoSymbol) NoType
- else appliedType(sym, manifestToType(m1).asInstanceOf[Type], manifestToType(m2).asInstanceOf[Type])
+ else appliedType(sym, compilerTypeFromTag(m1).asInstanceOf[Type], compilerTypeFromTag(m2).asInstanceOf[Type])
}
- (sym: Symbol) => new AppliedTypeFromManifests(sym)
+ (sym: Symbol) => new AppliedTypeFromTags(sym)
}
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
index b1bee6ce93..2e735e3b9b 100644
--- a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package interpreter
class RichClass[T](val clazz: Class[T]) {
- def toManifest: Manifest[T] = Manifest[T](ClassManifest[T](clazz).tpe)
+ def toTag: ClassTag[T] = ClassTag[T](clazz)
def toTypeString: String = TypeStrings.fromClazz(clazz)
// Sadly isAnonymousClass does not return true for scala anonymous
@@ -19,9 +19,9 @@ class RichClass[T](val clazz: Class[T]) {
)
/** It's not easy... to be... me... */
- def supermans: List[Manifest[_]] = supers map (_.toManifest)
- def superNames: List[String] = supers map (_.getName)
- def interfaces: List[JClass] = supers filter (_.isInterface)
+ def supermans: List[ClassTag[_]] = supers map (_.toTag)
+ def superNames: List[String] = supers map (_.getName)
+ def interfaces: List[JClass] = supers filter (_.isInterface)
def hasAncestorName(f: String => Boolean) = superNames exists f
def hasAncestor(f: JClass => Boolean) = supers exists f
diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
index 9ba75d9166..5d5123811e 100644
--- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
@@ -192,8 +192,8 @@ trait TypeStrings {
else enclClass.getName + "." + (name stripPrefix enclPre)
)
}
- def scalaName(m: ClassManifest[_]): String = scalaName(m.erasure)
- def anyClass(x: Any): JClass = if (x == null) null else x.getClass
+ def scalaName(m: ClassTag[_]): String = scalaName(m.erasure)
+ def anyClass(x: Any): JClass = if (x == null) null else x.getClass
private def brackets(tps: String*): String =
if (tps.isEmpty) ""
@@ -209,25 +209,25 @@ trait TypeStrings {
brackets(clazz.getTypeParameters map tvarString: _*)
}
- private def tparamString[T: Manifest] : String = {
+ private def tparamString[T: TypeTag] : String = {
// [Eugene to Paul] needs review!!
- def typeArguments: List[rm.Type] = manifest[T].tpe.typeArguments
+ def typeArguments: List[rm.Type] = typeTag[T].tpe.typeArguments
def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => rm.typeToClass(targ))
brackets(typeArguments map (jc => tvarString(List(jc))): _*)
}
/** Going for an overabundance of caution right now. Later these types
- * can be a lot more precise, but right now the manifests have a habit of
+ * can be a lot more precise, but right now the tags have a habit of
* introducing material which is not syntactically valid as scala source.
* When this happens it breaks the repl. It would be nice if we mandated
- * that manifest toString methods (or some other method, since it's bad
+ * that tag toString methods (or some other method, since it's bad
* practice to rely on toString for correctness) generated the VALID string
* representation of the type.
*/
- def fromTypedValue[T: Manifest](x: T): String = fromManifest[T]
- def fromValue(value: Any): String = if (value == null) "Null" else fromClazz(anyClass(value))
- def fromClazz(clazz: JClass): String = scalaName(clazz) + tparamString(clazz)
- def fromManifest[T: Manifest] : String = scalaName(manifest[T].erasure) + tparamString[T]
+ 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]
/** Reducing fully qualified noise for some common packages.
*/
diff --git a/src/compiler/scala/tools/nsc/io/ClassAndJarInfo.scala b/src/compiler/scala/tools/nsc/io/ClassAndJarInfo.scala
index d0a0b17494..c9ed535841 100644
--- a/src/compiler/scala/tools/nsc/io/ClassAndJarInfo.scala
+++ b/src/compiler/scala/tools/nsc/io/ClassAndJarInfo.scala
@@ -13,9 +13,9 @@ import collection.JavaConverters._
/** A convenience class for finding the jar with the bytecode for
* a given Class object and similar common tasks.
*/
-class ClassAndJarInfo[T: ClassManifest] {
- val man = classManifest[T]
- def clazz = man.erasure
+class ClassAndJarInfo[T: ClassTag] {
+ val tag = classTag[T]
+ def clazz = tag.erasure
def internalName = clazz.getName.replace('.', '/')
def resourceURL = new URLClassLoader(Array[URL]()) getResource internalName + ".class"
diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala
index 86c7ca7b9a..416b84eec6 100644
--- a/src/compiler/scala/tools/nsc/io/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/io/Pickler.scala
@@ -416,7 +416,7 @@ object Pickler {
iterPickler[T] .wrapped { Vector() ++ _ } { _.iterator } .labelled ("scala.Vector")
/** A pickler for array values */
- implicit def array[T : ClassManifest : Pickler]: Pickler[Array[T]] =
+ implicit def array[T : ClassTag : Pickler]: Pickler[Array[T]] =
iterPickler[T] .wrapped { _.toArray} { _.iterator } .labelled ("scala.Array")
}
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index a52e3b8bbe..c4dd9a2a36 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -183,8 +183,8 @@ class MutableSettings(val errorFn: String => Unit)
* The class loader defining `T` should provide resources `app.class.path`
* 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: Manifest]: Unit =
- embeddedDefaults(implicitly[Manifest[T]].erasure.getClassLoader)
+ def embeddedDefaults[T: ClassTag]: Unit =
+ embeddedDefaults(classTag[T].erasure.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`
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index fd15d92e37..bf01e142c9 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -611,7 +611,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
val ntree = typedWithPos(tree.pos)(safeREF(staticFieldSym))
super.transform(ntree)
- // This transform replaces Array(Predef.wrapArray(Array(...)), <manifest>)
+ // This transform replaces Array(Predef.wrapArray(Array(...)), <tag>)
// with just Array(...)
case Apply(appMeth, List(Apply(wrapRefArrayMeth, List(array)), _))
if (wrapRefArrayMeth.symbol == Predef_wrapRefArray &&
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 45dacd5c14..338c39dc5f 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -617,8 +617,12 @@ abstract class Erasure extends AddInterfaces
// See SI-4731 for one example of how this occurs.
log("Attempted to cast to Unit: " + tree)
tree.duplicate setType pt
- }
- else gen.mkAttributedCast(tree, pt)
+ } else if (tree.tpe != null && tree.tpe.typeSymbol == ArrayClass && pt.typeSymbol == ArrayClass) {
+ // See SI-2386 for one example of when this might be necessary.
+ val needsExtraCast = isScalaValueType(tree.tpe.typeArgs.head) && !isScalaValueType(pt.typeArgs.head)
+ val tree1 = if (needsExtraCast) gen.mkRuntimeCall(nme.toObjectArray, List(tree)) else tree
+ gen.mkAttributedCast(tree1, pt)
+ } else gen.mkAttributedCast(tree, pt)
}
/** Adapt `tree` to expected type `pt`.
@@ -664,6 +668,7 @@ 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 =>
@@ -992,7 +997,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.resolveClassTag(tree, qual.tpe.widen))))
+ global.typer.typed(gen.mkRuntimeCall(nme.anyValClass, List(qual, typer.resolveErasureTag(tree.pos, qual.tpe.widen, true))))
else
tree
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 6b894a724f..35e26b39b5 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -486,7 +486,7 @@ abstract class UnCurry extends InfoTransform
val toArraySym = tree.tpe member nme.toArray
assert(toArraySym != NoSymbol)
def getClassTag(tp: Type): Tree = {
- val tag = localTyper.resolveClassTag(tree, tp)
+ val tag = localTyper.resolveArrayTag(tree.pos, tp)
// Don't want bottom types getting any further than this (SI-4024)
if (tp.typeSymbol.isBottomClass) getClassTag(AnyClass.tpe)
else if (!tag.isEmpty) tag
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 8d26f66370..c13be0e39d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -861,7 +861,7 @@ trait ContextErrors {
// (note that this is not a compilation error, it's an artifact of implicit search algorithm)
// normally, such "errors" are discarded by `isCyclicOrErroneous` in Implicits.scala
// but in our case this won't work, because isCyclicOrErroneous catches CyclicReference exceptions
- // while our error will manifest itself as a "recursive method needs a return type"
+ // while our error will present itself as a "recursive method needs a return type"
//
// hence we (together with reportTypeError in TypeDiagnostics) make sure that this CyclicReference
// evades all the handlers on its way and successfully reaches `isCyclicOrErroneous` in Implicits
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index f8da6a462d..1612253dd6 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1120,15 +1120,19 @@ trait Implicits {
implicitInfoss1
}
- // these should be lazy, otherwise we wouldn't be able to compile scala-library with starr
- private val TagSymbols = Set[Symbol](ClassTagClass, TypeTagClass, ConcreteTypeTagClass)
- private val TagMaterializers = Map[Symbol, MethodSymbol](
+ 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
)
- def tagOfType(pre: Type, tp: Type, tagClass: Symbol): SearchResult = {
+ /** Creates a tree will produce a tag of the requested flavor.
+ * An EmptyTree is returned if materialization fails.
+ */
+ private def tagOfType(pre: Type, tp: Type, tagClass: Symbol): SearchResult = {
def success(arg: Tree) =
try {
val tree1 = typed(atPos(pos.focus)(arg))
@@ -1143,10 +1147,7 @@ trait Implicits {
val prefix = (
// ClassTags only exist for scala.reflect.mirror, so their materializer
// doesn't care about prefixes
- if (tagClass eq ClassTagClass) (
- gen.mkAttributedRef(Reflect_mirror)
- setType singleType(Reflect_mirror.owner.thisPrefix, Reflect_mirror)
- )
+ if ((tagClass eq ArrayTagClass) || (tagClass eq ErasureTagClass) || (tagClass eq ClassTagClass)) ReflectMirrorPrefix
else pre match {
// [Eugene to Martin] this is the crux of the interaction between
// implicits and reifiers here we need to turn a (supposedly
@@ -1173,9 +1174,120 @@ trait Implicits {
else failure(materializer, "macros are disabled")
}
- /** The manifest corresponding to type `pt`, provided `pt` is an instance of Manifest.
+ private val ManifestSymbols = Set[Symbol](PartialManifestClass, FullManifestClass, OptManifestClass)
+
+ /** Creates a tree that calls the relevant factory method in object
+ * reflect.Manifest for type 'tp'. An EmptyTree is returned if
+ * no manifest is found. todo: make this instantiate take type params as well?
+ */
+ private def manifestOfType(tp: Type, full: Boolean): SearchResult = {
+
+ /** Creates a tree that calls the factory method called constructor in object reflect.Manifest */
+ def manifestFactoryCall(constructor: String, tparg: Type, args: Tree*): Tree =
+ if (args contains EmptyTree) EmptyTree
+ else typedPos(tree.pos.focus) {
+ val mani = gen.mkManifestFactoryCall(full, constructor, tparg, args.toList)
+ if (settings.debug.value) println("generated manifest: "+mani) // DEBUG
+ mani
+ }
+
+ /** Creates a tree representing one of the singleton manifests.*/
+ def findSingletonManifest(name: String) = typedPos(tree.pos.focus) {
+ Select(gen.mkAttributedRef(FullManifestModule), name)
+ }
+
+ /** Re-wraps a type in a manifest before calling inferImplicit on the result */
+ def findManifest(tp: Type, manifestClass: Symbol = if (full) FullManifestClass else PartialManifestClass) =
+ inferImplicit(tree, appliedType(manifestClass, tp), true, false, context).tree
+
+ def findSubManifest(tp: Type) = findManifest(tp, if (full) FullManifestClass else OptManifestClass)
+ def mot(tp0: Type, from: List[Symbol], to: List[Type]): SearchResult = {
+ implicit def wrapResult(tree: Tree): SearchResult =
+ if (tree == EmptyTree) SearchFailure else new SearchResult(tree, if (from.isEmpty) EmptyTreeTypeSubstituter else new TreeTypeSubstituter(from, to))
+
+ val tp1 = tp0.normalize
+ tp1 match {
+ case ThisType(_) | SingleType(_, _) =>
+ // can't generate a reference to a value that's abstracted over by an existential
+ if (containsExistential(tp1)) EmptyTree
+ else manifestFactoryCall("singleType", tp, gen.mkAttributedQualifier(tp1))
+ case ConstantType(value) =>
+ manifestOfType(tp1.deconst, full)
+ case TypeRef(pre, sym, args) =>
+ if (isPrimitiveValueClass(sym) || isPhantomClass(sym)) {
+ findSingletonManifest(sym.name.toString)
+ } else if (sym == ObjectClass || sym == AnyRefClass) {
+ findSingletonManifest("Object")
+ } else if (sym == RepeatedParamClass || sym == ByNameParamClass) {
+ EmptyTree
+ } else if (sym == ArrayClass && args.length == 1) {
+ manifestFactoryCall("arrayType", args.head, findManifest(args.head))
+ } else if (sym.isClass) {
+ val classarg0 = gen.mkClassOf(tp1)
+ val classarg = tp match {
+ case _: ExistentialType => gen.mkCast(classarg0, ClassType(tp))
+ case _ => classarg0
+ }
+ val suffix = classarg :: (args map findSubManifest)
+ manifestFactoryCall(
+ "classType", tp,
+ (if ((pre eq NoPrefix) || pre.typeSymbol.isStaticOwner) suffix
+ else findSubManifest(pre) :: suffix): _*)
+ } else if (sym.isExistentiallyBound && full) {
+ manifestFactoryCall("wildcardType", tp,
+ findManifest(tp.bounds.lo), findManifest(tp.bounds.hi))
+ }
+ // looking for a manifest of a type parameter that hasn't been inferred by now,
+ // can't do much, but let's not fail
+ else if (undetParams contains sym) {
+ // #3859: need to include the mapping from sym -> NothingClass.tpe in the SearchResult
+ mot(NothingClass.tpe, sym :: from, NothingClass.tpe :: to)
+ } else {
+ // a manifest should have been found by normal searchImplicit
+ EmptyTree
+ }
+ case RefinedType(parents, decls) => // !!! not yet: if !full || decls.isEmpty =>
+ // refinement is not generated yet
+ if (hasLength(parents, 1)) findManifest(parents.head)
+ else if (full) manifestFactoryCall("intersectionType", tp, parents map findSubManifest: _*)
+ else mot(erasure.intersectionDominator(parents), from, to)
+ case ExistentialType(tparams, result) =>
+ mot(tp1.skolemizeExistential, from, to)
+ case _ =>
+ EmptyTree
+/* !!! the following is almost right, but we have to splice nested manifest
+ * !!! types into this type. This requires a substantial extension of
+ * !!! reifiers.
+ val reifier = new Reifier()
+ val rtree = reifier.reifyTopLevel(tp1)
+ manifestFactoryCall("apply", tp, rtree)
+*/
+ }
+ }
+
+ val tagInScope =
+ if (full) context.withMacrosDisabled(resolveTypeTag(pos, ReflectMirrorPrefix.tpe, tp, true))
+ else context.withMacrosDisabled(resolveArrayTag(pos, tp))
+ if (tagInScope.isEmpty) mot(tp, Nil, Nil)
+ else {
+ val interop =
+ if (full) gen.mkMethodCall(ReflectPackage, nme.concreteTypeTagToManifest, List(tp), List(tagInScope))
+ else gen.mkMethodCall(ReflectPackage, nme.arrayTagToClassManifest, List(tp), List(tagInScope))
+ wrapResult(interop)
+ }
+ }
+
+ def wrapResult(tree: Tree): SearchResult =
+ if (tree == EmptyTree) SearchFailure else new SearchResult(tree, EmptyTreeTypeSubstituter)
+
+ /** The tag corresponding to type `pt`, provided `pt` is a flavor of a tag.
*/
private def implicitTagOrOfExpectedType(pt: Type): SearchResult = pt.dealias match {
+ case TypeRef(pre, sym, arg :: Nil) if ManifestSymbols(sym) =>
+ manifestOfType(arg, sym == FullManifestClass) match {
+ case SearchFailure if sym == OptManifestClass => wrapResult(gen.mkAttributedRef(NoManifest))
+ case result => result
+ }
case TypeRef(pre, sym, arg :: Nil) if TagSymbols(sym) =>
tagOfType(pre, arg, sym)
case tp@TypeRef(_, sym, _) if sym.isAbstractType =>
@@ -1183,13 +1295,13 @@ trait Implicits {
case _ =>
searchImplicit(implicitsOfExpectedType, false)
// shouldn't we pass `pt` to `implicitsOfExpectedType`, or is the recursive case
- // for an abstract type really only meant for manifests?
+ // for an abstract type really only meant for tags?
}
/** The result of the implicit search:
* First search implicits visible in current context.
* If that fails, search implicits in expected type `pt`.
- * // [Eugene] the following two lines should be deleted after we migrate delegate manifest materialization to implicit macros
+ * // [Eugene] the following two lines should be deleted after we migrate delegate tag materialization to implicit macros
* If that fails, and `pt` is an instance of a ClassTag, try to construct a class tag.
* If that fails, and `pt` is an instance of a TypeTag, try to construct a type tag.
* If all fails return SearchFailure
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 9b4dd09c98..5d4cd0be77 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -155,7 +155,7 @@ trait Macros { self: Analyzer =>
case TypeRef(SingleType(NoPrefix, contextParam), sym, List(tparam)) =>
var wannabe = sym
while (wannabe.isAliasType) wannabe = wannabe.info.typeSymbol
- if (wannabe != definitions.TypeTagClass)
+ if (wannabe != definitions.TypeTagClass && wannabe != definitions.ConcreteTypeTagClass)
List(param)
else
transform(param, tparam.typeSymbol) map (_ :: Nil) getOrElse Nil
@@ -353,6 +353,16 @@ trait Macros { self: Analyzer =>
if (actparamss.length != reqparamss.length)
compatibilityError("number of parameter sections differ")
+ def checkSubType(slot: String, reqtpe: Type, acttpe: Type): Unit = {
+ val ok = if (macroDebug) {
+ if (reqtpe eq acttpe) println(reqtpe + " <: " + acttpe + "?" + EOL + "true")
+ withTypesExplained(reqtpe <:< acttpe)
+ } else reqtpe <:< acttpe
+ if (!ok) {
+ compatibilityError("type mismatch for %s: %s does not conform to %s".format(slot, reqtpe.toString.abbreviateCoreAliases, acttpe.toString.abbreviateCoreAliases))
+ }
+ }
+
if (!hasErrors) {
try {
for ((rparams, aparams) <- reqparamss zip actparamss) {
@@ -378,27 +388,19 @@ trait Macros { self: Analyzer =>
compatibilityError("types incompatible for parameter "+aparam.name+": corresponding is not a vararg parameter")
if (!hasErrors) {
var atpe = aparam.tpe.substSym(flatactparams, flatreqparams).instantiateTypeParams(tparams, tvars)
-
// strip the { type PrefixType = ... } refinement off the Context or otherwise we get compatibility errors
atpe = atpe match {
case RefinedType(List(tpe), Scope(sym)) if tpe == MacroContextClass.tpe && sym.allOverriddenSymbols.contains(MacroContextPrefixType) => tpe
case _ => atpe
}
-
- val ok = if (macroDebug) withTypesExplained(rparam.tpe <:< atpe) else rparam.tpe <:< atpe
- if (!ok) {
- compatibilityError("type mismatch for parameter "+rparam.name+": "+rparam.tpe.toString.abbreviateCoreAliases+" does not conform to "+atpe)
- }
+ checkSubType("parameter " + rparam.name, rparam.tpe, atpe)
}
}
}
}
if (!hasErrors) {
val atpe = actres.substSym(flatactparams, flatreqparams).instantiateTypeParams(tparams, tvars)
- val ok = if (macroDebug) withTypesExplained(atpe <:< reqres) else atpe <:< reqres
- if (!ok) {
- compatibilityError("type mismatch for return type : "+reqres.toString.abbreviateCoreAliases+" does not conform to "+(if (ddef.tpt.tpe != null) atpe.toString else atpe.toString.abbreviateCoreAliases))
- }
+ checkSubType("return type", atpe, reqres)
}
if (!hasErrors) {
val targs = solvedTypes(tvars, tparams, tparams map varianceInType(actres), false,
@@ -873,9 +875,8 @@ trait Macros { self: Analyzer =>
// 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
- paramss = transformTypeTagEvidenceParams(paramss, (param, tparam) => Some(tparam))
- if (paramss.lastOption map (params => !params.isEmpty && params.forall(_.isType)) getOrElse false) argss = argss :+ Nil
- val evidences = paramss.last takeWhile (_.isType) map (tparam => {
+ 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) {
@@ -892,12 +893,27 @@ trait Macros { self: Analyzer =>
} else
implRefTarg.tpe
if (macroDebug) println("resolved tparam %s as %s".format(tparam, tpe))
- tpe
- }) map (tpe => {
- val ttag = TypeTag(tpe)
+ resolved(tparam) = tpe
+ param.tpe.typeSymbol match {
+ case sym if sym == definitions.TypeTagClass =>
+ // do nothing
+ case sym if sym == 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: %s".format(tpe))
+ }
+ 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
})
- argss = argss.dropRight(1) :+ (evidences ++ argss.last)
+ 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 {
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index 9e06cbe0d3..4c71772929 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -8,6 +8,7 @@ package typechecker
import symtab.Flags._
import scala.collection.{ mutable, immutable }
import scala.tools.util.StringOps.{ ojoin }
+import scala.reflect.{ mirror => rm }
import language.higherKinds
/** Logic related to method synthesis which involves cooperation between
@@ -21,50 +22,51 @@ trait MethodSynthesis {
import CODE._
object synthesisUtil {
- type M[T] = Manifest[T]
- type CM[T] = ClassManifest[T]
+ type CTT[T] = rm.ConcreteTypeTag[T]
+ type CT[T] = ClassTag[T]
def ValOrDefDef(sym: Symbol, body: Tree) =
if (sym.isLazy) ValDef(sym, body)
else DefDef(sym, body)
- def applyTypeInternal(manifests: List[M[_]]): Type = {
+ def applyTypeInternal(tags: List[CTT[_]]): Type = {
// [Eugene to Paul] needs review!!
- val symbols = manifests map manifestToSymbol
+ val symbols = tags map compilerSymbolFromTag
val container :: args = symbols
val tparams = container.typeConstructor.typeParams
// Conservative at present - if manifests were more usable this could do a lot more.
- require(symbols forall (_ ne NoSymbol), "Must find all manifests: " + symbols)
+ // [Eugene to Paul] all right, they are now. what do you have in mind?
+ require(symbols forall (_ ne NoSymbol), "Must find all tags: " + symbols)
require(container.owner.isPackageClass, "Container must be a top-level class in a package: " + container)
require(tparams.size == args.size, "Arguments must match type constructor arity: " + tparams + ", " + args)
appliedType(container, args map (_.tpe): _*)
}
- def companionType[T](implicit m: M[T]) =
+ def companionType[T](implicit m: CTT[T]) =
getRequiredModule(m.erasure.getName).tpe
// Use these like `applyType[List, Int]` or `applyType[Map, Int, String]`
- def applyType[CC](implicit m1: M[CC]): Type =
+ def applyType[CC](implicit m1: CTT[CC]): Type =
applyTypeInternal(List(m1))
- def applyType[CC[X1], X1](implicit m1: M[CC[_]], m2: M[X1]): Type =
+ 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: M[CC[_,_]], m2: M[X1], m3: M[X2]): Type =
+ 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: M[CC[_,_,_]], m2: M[X1], m3: M[X2], m4: M[X3]): Type =
+ 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 m: Manifest[F]): Type = {
- val fnSymbol = manifestToSymbol(m)
- assert(fnSymbol isSubClass FunctionClass(m.tpe.typeArguments.size - 1), (owner, m))
+ def newMethodType[F](owner: Symbol)(implicit t: CTT[F]): Type = {
+ val fnSymbol = compilerSymbolFromTag(t)
+ assert(fnSymbol isSubClass FunctionClass(t.tpe.typeArguments.size - 1), (owner, t))
// [Eugene to Paul] needs review!!
// val symbols = m.typeArguments map (m => manifestToSymbol(m))
// val formals = symbols.init map (_.typeConstructor)
- val formals = manifestToType(m).typeArguments
+ val formals = compilerTypeFromTag(t).typeArguments
val params = owner newSyntheticValueParams formals
MethodType(params, formals.last)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index be269cf4b2..3d9fc67389 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -39,14 +39,14 @@ trait NamesDefaults { self: Analyzer =>
def isNamed(arg: Tree) = nameOf(arg).isDefined
/** @param pos maps indices from old to new */
- def reorderArgs[T: ClassManifest](args: List[T], pos: Int => Int): List[T] = {
+ def reorderArgs[T: ArrayTag](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: ClassManifest](args: List[T], pos: Int => Int): List[T] = {
+ def reorderArgsInv[T: ArrayTag](args: List[T], pos: Int => Int): List[T] = {
val argsArray = args.toArray
(argsArray.indices map (i => argsArray(pos(i)))).toList
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
index 88cea2231f..02e53cb624 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala
@@ -828,6 +828,7 @@ class Foo(x: Other) { x._1 } // no error in this order
private def typeTest(binderToTest: Symbol, expectedTp: Type, disableOuterCheck: Boolean = false, dynamic: Boolean = false): Tree = { import CODE._
// def coreTest =
if (disableOuterCheck) codegen._isInstanceOf(binderToTest, expectedTp) else maybeWithOuterCheck(binderToTest, expectedTp)(codegen._isInstanceOf(binderToTest, expectedTp))
+ // [Eugene to Adriaan] use `resolveErasureTag` instead of `findManifest`. please, provide a meaningful position
// if (opt.experimental && containsUnchecked(expectedTp)) {
// if (dynamic) {
// val expectedTpTagTree = findManifest(expectedTp, true)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 868c236ee9..31d064c824 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -74,7 +74,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// Option[Int] { def productIterator: Iterator[String] }
//
// appearing legitimately, but this breaks invariant places
- // like Manifests and Arrays which are not robust and infer things
+ // like Tags and Arrays which are not robust and infer things
// which they shouldn't.
val accessorLub = (
if (opt.experimental) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Taggings.scala b/src/compiler/scala/tools/nsc/typechecker/Taggings.scala
new file mode 100644
index 0000000000..d276b39f16
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/typechecker/Taggings.scala
@@ -0,0 +1,71 @@
+package scala.tools.nsc
+package typechecker
+
+trait Taggings {
+ self: Analyzer =>
+
+ import global._
+ import definitions._
+
+ trait Tagging {
+ self: Typer =>
+
+ private def resolveTag(pos: Position, taggedTp: Type) = 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 pos Position for error reporting. Please, provide meaningful value.
+ * @param tp Type we're looking an ArrayTag for, e.g. resolveArrayTag(pos, IntClass.tpe) will look for ArrayTag[Int].
+ *
+ * @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(pos: Position, tp: Type): Tree = {
+ val taggedTp = appliedType(ArrayTagClass.typeConstructor, List(tp))
+ resolveTag(pos, taggedTp)
+ }
+
+ /** 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 pos Position for error reporting. Please, provide meaningful value.
+ * @param tp Type we're looking an ErasureTag for, e.g. resolveErasureTag(pos, IntClass.tpe, true) will look for ClassTag[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 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(pos: Position, tp: Type, concrete: Boolean): Tree = {
+ val taggedTp = appliedType(if (concrete) ClassTagClass.typeConstructor else ErasureTagClass.typeConstructor, List(tp))
+ resolveTag(pos, taggedTp)
+ }
+
+ /** Finds in scope or materializes a TypeTag (if `concrete` is false) or a ConcreteTypeTag (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.
+ * @param tp Type we're looking a TypeTag for, e.g. resolveTypeTag(pos, reflectMirrorPrefix, IntClass.tpe, false) will look for scala.reflect.mirror.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).
+ *
+ * @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(pos: Position, pre: Type, tp: Type, concrete: Boolean): Tree = {
+ val taggedTp = appliedType(singleType(pre, pre member (if (concrete) ConcreteTypeTagClass else TypeTagClass).name), List(tp))
+ resolveTag(pos, taggedTp)
+ }
+ }
+} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 54be9c9a87..ba6a363095 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -26,7 +26,7 @@ import util.Statistics._
* @author Martin Odersky
* @version 1.0
*/
-trait Typers extends Modes with Adaptations with PatMatVirtualiser {
+trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser {
self: Analyzer =>
import global._
@@ -83,7 +83,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
private def isPastTyper = phase.id > currentRun.typerPhase.id
- abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with TyperContextErrors {
+ abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tagging with TyperContextErrors {
import context0.unit
import typeDebug.{ ptTree, ptBlock, ptLine }
import TyperErrorGen._
@@ -830,11 +830,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
context.undetparams = inferExprInstance(tree, context.extractUndetparams(), pt,
// approximate types that depend on arguments since dependency on implicit argument is like dependency on type parameter
mt.approximate,
- // if we are looking for a manifest, instantiate type to Nothing anyway,
- // as we would get ambiguity errors otherwise. Example
- // Looking for a manifest of Nil: This has many potential types,
- // so we need to instantiate to minimal type List[Nothing].
- keepNothings = false, // retract Nothing's that indicate failure, ambiguities in manifests are dealt with in manifestOfType
+ keepNothings = false,
useWeaklyCompatible = true) // #3808
}
@@ -3103,7 +3099,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
if (annInfo.atp.isErroneous) { hasError = true; None }
else Some(NestedAnnotArg(annInfo))
- // use of Array.apply[T: ClassManifest](xs: T*): Array[T]
+ // use of Array.apply[T: ArrayTag](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)
@@ -4840,12 +4836,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// [Eugene] no more MaxArrayDims. ClassTags are flexible enough to allow creation of arrays of arbitrary dimensionality (w.r.t JVM restrictions)
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 = resolveClassTag(tree, tagType)
+ val newArrayApp = atPos(tree.pos) {
+ val tag = resolveArrayTag(tree.pos, tagType)
if (tag.isEmpty) MissingClassTagError(tree, tagType)
else new ApplyToImplicitArgs(Select(tag, nme.newArray), args)
- }
- typed(newArrayApp, mode, pt)
+ }
+ typed(newArrayApp, mode, pt)
case tree1 =>
tree1
}
@@ -5210,36 +5206,6 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case None => typed(tree, mode, pt)
}
- // `tree` is only necessary here for its position
- // but that's invaluable for error reporting, so I decided to include it into this method's contract
- // before passing EmptyTree, please, consider passing something meaningful first
- def resolveClassTag(tree: Tree, tp: Type): Tree = beforeTyper {
- inferImplicit(
- EmptyTree,
- appliedType(ClassTagClass.typeConstructor, List(tp)),
- /*reportAmbiguous =*/ true,
- /*isView =*/ false,
- /*context =*/ context,
- /*saveAmbiguousDivergent =*/ true,
- /*pos =*/ tree.pos
- ).tree
- }
-
- // `tree` is only necessary here for its position
- // but that's invaluable for error reporting, so I decided to include it into this method's contract
- // before passing EmptyTree, please, consider passing something meaningful first
- def resolveTypeTag(tree: Tree, pre: Type, tp: Type, full: Boolean): Tree = beforeTyper {
- inferImplicit(
- EmptyTree,
- appliedType(singleType(pre, pre member (if (full) ConcreteTypeTagClass else TypeTagClass).name), List(tp)),
- /*reportAmbiguous =*/ true,
- /*isView =*/ false,
- /*context =*/ context,
- /*saveAmbiguousDivergent =*/ true,
- /*pos =*/ tree.pos
- ).tree
- }
-
/*
def convertToTypeTree(tree: Tree): Tree = tree match {
case TypeTree() => tree
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 5dd9ce0e02..48ec941b50 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -26,12 +26,12 @@ object ClassPath {
def scalaLibrary = locate[Option[_]]
def scalaCompiler = locate[Global]
- def infoFor[T](value: T) = info(value.getClass)
- def info[T](clazz: Class[T]) = new ClassAndJarInfo()(ClassManifest[T](clazz))
- def info[T: ClassManifest] = new ClassAndJarInfo[T]
- def locate[T: ClassManifest] = info[T].rootClasspath
- def locateJar[T: ClassManifest] = info[T].rootPossibles find (x => isJarOrZip(x)) map (x => File(x))
- def locateDir[T: ClassManifest] = info[T].rootPossibles find (_.isDirectory) map (_.toDirectory)
+ def infoFor[T](value: T) = info(value.getClass)
+ def info[T](clazz: Class[T]) = new ClassAndJarInfo()(ClassTag[T](clazz))
+ def info[T: ClassTag] = new ClassAndJarInfo[T]
+ def locate[T: ClassTag] = info[T].rootClasspath
+ def locateJar[T: ClassTag] = info[T].rootPossibles find (x => isJarOrZip(x)) map (x => File(x))
+ def locateDir[T: ClassTag] = info[T].rootPossibles find (_.isDirectory) map (_.toDirectory)
/** Expand single path entry */
private def expandS(pattern: String): List[String] = {
diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
index 700fe0c1a6..120cceb238 100644
--- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
+++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala
@@ -67,8 +67,8 @@ trait ScalaClassLoader extends JClassLoader {
result
}
- def constructorsOf[T <: AnyRef : Manifest]: List[Constructor[T]] =
- manifest[T].erasure.getConstructors.toList map (_.asInstanceOf[Constructor[T]])
+ def constructorsOf[T <: AnyRef : ClassTag]: List[Constructor[T]] =
+ classTag[T].erasure.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 {
@@ -125,9 +125,9 @@ object ScalaClassLoader {
def bootLoader = apply(null)
def contextChain = loaderChain(contextLoader)
- def pathToErasure[T: ClassManifest] = pathToClass(classManifest[T].erasure)
- def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class"
- def locate[T: ClassManifest] = contextLoader getResource pathToErasure[T]
+ def pathToErasure[T: ClassTag] = pathToClass(classTag[T].erasure)
+ def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class"
+ def locate[T: ClassTag] = contextLoader getResource pathToErasure[T]
/** Tries to guess the classpath by type matching the context classloader
* and its parents, looking for any classloaders which will reveal their
diff --git a/src/compiler/scala/tools/reflect/Invoked.scala b/src/compiler/scala/tools/reflect/Invoked.scala
index 30c6201a0d..516c6b9bf6 100644
--- a/src/compiler/scala/tools/reflect/Invoked.scala
+++ b/src/compiler/scala/tools/reflect/Invoked.scala
@@ -16,7 +16,7 @@ class Invoked private (val proxy: AnyRef, val m: Method, val args: List[AnyRef])
def name = m.getName
def arity = m.getParameterTypes.size
def returnType = m.getReturnType
- def returns[T: Manifest] = returnType == manifest[T].erasure
+ def returns[T: ClassTag] = returnType == classTag[T].erasure
def invokeOn(target: AnyRef) = m.invoke(target, args: _*)
def isObjectMethod = Set("toString", "equals", "hashCode") contains name
diff --git a/src/compiler/scala/tools/reflect/UniversalFn.scala b/src/compiler/scala/tools/reflect/UniversalFn.scala
index 9ccd580560..b0c2a19021 100644
--- a/src/compiler/scala/tools/reflect/UniversalFn.scala
+++ b/src/compiler/scala/tools/reflect/UniversalFn.scala
@@ -26,8 +26,8 @@ class UniversalFn private (val closure: AnyRef, val method: Method) extends (Seq
* them to this universal function. Will throw an exception in the
* face of any bad data.
*/
- def as[T: Manifest] : T = {
- val clazz = manifest[T].erasure
+ def as[T: ClassTag] : T = {
+ val clazz = classTag[T].erasure
require(clazz.isInterface, "Type argument must be an interface.")
val interfaceMethods = clazz.getDeclaredMethods.toSet
diff --git a/src/compiler/scala/tools/reflect/package.scala b/src/compiler/scala/tools/reflect/package.scala
index f5c836a4e9..0b0c0905cb 100644
--- a/src/compiler/scala/tools/reflect/package.scala
+++ b/src/compiler/scala/tools/reflect/package.scala
@@ -27,17 +27,17 @@ package object reflect {
}
}
- def zeroOfClass(clazz: Class[_]) = zeroOf(Manifest(ClassManifest(clazz).tpe))
- def zeroOf[T](implicit m: Manifest[T]): AnyRef = {
- if (m == manifest[Boolean] || m == manifest[jl.Boolean]) false: jl.Boolean
- else if (m == manifest[Unit] || m == manifest[jl.Void] || m == manifest[scala.runtime.BoxedUnit]) scala.runtime.BoxedUnit.UNIT
- else if (m == manifest[Char] || m == manifest[jl.Character]) 0.toChar: jl.Character
- else if (m == manifest[Byte] || m == manifest[jl.Byte]) 0.toByte: jl.Byte
- else if (m == manifest[Short] || m == manifest[jl.Short]) 0.toShort: jl.Short
- else if (m == manifest[Int] || m == manifest[jl.Integer]) 0: jl.Integer
- else if (m == manifest[Long] || m == manifest[jl.Long]) 0l: jl.Long
- else if (m == manifest[Float] || m == manifest[jl.Float]) 0f: jl.Float
- else if (m == manifest[Double] || m == manifest[jl.Double]) 0d: jl.Double
+ def zeroOfClass(clazz: Class[_]) = zeroOf(ClassTag(clazz))
+ def zeroOf[T](implicit t: ClassTag[T]): AnyRef = {
+ if (t == classTag[Boolean] || t == classTag[jl.Boolean]) false: jl.Boolean
+ else if (t == classTag[Unit] || t == classTag[jl.Void] || t == classTag[scala.runtime.BoxedUnit]) scala.runtime.BoxedUnit.UNIT
+ else if (t == classTag[Char] || t == classTag[jl.Character]) 0.toChar: jl.Character
+ else if (t == classTag[Byte] || t == classTag[jl.Byte]) 0.toByte: jl.Byte
+ else if (t == classTag[Short] || t == classTag[jl.Short]) 0.toShort: jl.Short
+ else if (t == classTag[Int] || t == classTag[jl.Integer]) 0: jl.Integer
+ else if (t == classTag[Long] || t == classTag[jl.Long]) 0l: jl.Long
+ else if (t == classTag[Float] || t == classTag[jl.Float]) 0f: jl.Float
+ else if (t == classTag[Double] || t == classTag[jl.Double]) 0d: jl.Double
else null
}
}
diff --git a/src/detach/library/scala/remoting/Channel.scala b/src/detach/library/scala/remoting/Channel.scala
index 541e45a477..54b8fb100e 100644
--- a/src/detach/library/scala/remoting/Channel.scala
+++ b/src/detach/library/scala/remoting/Channel.scala
@@ -116,20 +116,20 @@ class Channel protected (socket: Socket) {
* the expected type.
*/
@throws(classOf[ChannelException])
- def receive[T](implicit expected: reflect.Manifest[T]): T = {
- val found = in.readObject().asInstanceOf[reflect.Manifest[_]]
+ def receive[T](implicit expected: reflect.ClassTag[T]): T = {
+ val found = in.readObject().asInstanceOf[reflect.ClassTag[_]]
info("receive: found="+found+", expected="+expected)
- import scala.reflect.Manifest
+ import scala.reflect.ClassTag
val x = found match {
- case Manifest.Unit => ()
- case Manifest.Boolean => in.readBoolean()
- case Manifest.Byte => in.readByte()
- case Manifest.Char => in.readChar()
- case Manifest.Short => in.readShort()
- case Manifest.Int => in.readInt()
- case Manifest.Long => in.readLong()
- case Manifest.Float => in.readFloat()
- case Manifest.Double => in.readDouble()
+ case ClassTag.Unit => ()
+ case ClassTag.Boolean => in.readBoolean()
+ case ClassTag.Byte => in.readByte()
+ case ClassTag.Char => in.readChar()
+ case ClassTag.Short => in.readShort()
+ case ClassTag.Int => in.readInt()
+ case ClassTag.Long => in.readLong()
+ case ClassTag.Float => in.readFloat()
+ case ClassTag.Double => in.readDouble()
case _ => in.readObject()
}
val res = if (found <:< expected)
@@ -144,12 +144,12 @@ class Channel protected (socket: Socket) {
/** <code>?</code> method may throw either an
* <code>ClassNotFoundException</code> or an <code>IOException</code>.
*/
- def ?[T](implicit m: reflect.Manifest[T]): T = receive[T](m)
+ def ?[T](implicit t: reflect.ClassTag[T]): T = receive[T](t)
/** <code>send</code> method may throw an <code>IOException</code>.
*/
- def send[T](x: T)(implicit m: reflect.Manifest[T]) {
- out writeObject m
+ def send[T](x: T)(implicit t: reflect.ClassTag[T]) {
+ out writeObject t
x match {
case x: Unit => // nop
case x: Boolean => out writeBoolean x
@@ -168,7 +168,7 @@ class Channel protected (socket: Socket) {
/** <code>!</code> method may throw an <code>IOException</code>.
*/
- def ![T](x: T)(implicit m: reflect.Manifest[T]) { send(x)(m) }
+ def ![T](x: T)(implicit m: reflect.ClassTag[T]) { send(x)(m) }
def close() {
try { socket.close() }
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index 5b8ebde308..fd61cfd0a1 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -12,17 +12,17 @@ import scala.collection.generic._
import scala.collection.{ mutable, immutable }
import mutable.{ ArrayBuilder, ArraySeq }
import compat.Platform.arraycopy
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
import scala.runtime.ScalaRunTime.{ array_apply, array_update }
/** Contains a fallback builder for arrays when the element type
- * does not have a class manifest. In that case a generic array is built.
+ * does not have a class tag. In that case a generic array is built.
*/
class FallbackArrayBuilding {
/** A builder factory that generates a generic array.
* Called instead of `Array.newBuilder` if the element type of an array
- * does not have a class manifest. Note that fallbackBuilder factory
+ * does not have a class tag. Note that fallbackBuilder factory
* needs an implicit parameter (otherwise it would not be dominated in
* implicit search by `Array.canBuildFrom`). We make sure that
* implicit search is always successful.
@@ -48,16 +48,16 @@ class FallbackArrayBuilding {
* @version 1.0
*/
object Array extends FallbackArrayBuilding {
- implicit def canBuildFrom[T](implicit m: ClassManifest[T]): CanBuildFrom[Array[_], T, Array[T]] =
+ implicit def canBuildFrom[T](implicit t: ArrayTag[T]): CanBuildFrom[Array[_], T, Array[T]] =
new CanBuildFrom[Array[_], T, Array[T]] {
- def apply(from: Array[_]) = ArrayBuilder.make[T]()(m)
- def apply() = ArrayBuilder.make[T]()(m)
+ def apply(from: Array[_]) = ArrayBuilder.make[T]()(t)
+ def apply() = ArrayBuilder.make[T]()(t)
}
/**
* Returns a new [[scala.collection.mutable.ArrayBuilder]].
*/
- def newBuilder[T](implicit m: ClassManifest[T]): ArrayBuilder[T] = ArrayBuilder.make[T]()(m)
+ def newBuilder[T](implicit t: ArrayTag[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: ClassManifest]: Array[T] = new Array[T](0)
+ def empty[T: ArrayTag]: 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: ClassManifest](xs: T*): Array[T] = {
+ def apply[T: ArrayTag](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: ClassManifest](n1: Int): Array[T] =
+ def ofDim[T: ArrayTag](n1: Int): Array[T] =
new Array[T](n1)
/** Creates a 2-dimensional array */
- def ofDim[T: ClassManifest](n1: Int, n2: Int): Array[Array[T]] = {
+ def ofDim[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
+ def ofDim[T: ArrayTag](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
tabulate(n1)(_ => ofDim[T](n2, n3))
/** Creates a 4-dimensional array */
- def ofDim[T: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
+ def ofDim[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
+ def ofDim[T: ArrayTag](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: ClassManifest](xss: Array[T]*): Array[T] = {
+ def concat[T: ArrayTag](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: ClassManifest](n: Int)(elem: => T): Array[T] = {
+ def fill[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int)(elem: => T): Array[Array[T]] =
+ def fill[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int)(elem: => T): Array[Array[Array[T]]] =
+ def fill[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => T): Array[Array[Array[Array[T]]]] =
+ def fill[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => T): Array[Array[Array[Array[Array[T]]]]] =
+ def fill[T: ArrayTag](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: ClassManifest](n: Int)(f: Int => T): Array[T] = {
+ def tabulate[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int)(f: (Int, Int) => T): Array[Array[T]] =
+ def tabulate[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => T): Array[Array[Array[T]]] =
+ def tabulate[T: ArrayTag](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: ClassManifest](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => T): Array[Array[Array[Array[T]]]] =
+ def tabulate[T: ArrayTag](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: ClassManifest](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: ArrayTag](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: ClassManifest](start: T, len: Int)(f: T => T): Array[T] = {
+ def iterate[T: ArrayTag](start: T, len: Int)(f: T => T): Array[T] = {
val b = newBuilder[T]
if (len > 0) {
@@ -476,7 +476,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 a ClassManifest is available for B or `ArraySeq[B]` otherwise.
+ * `That` is either `Array[B]` if an ArrayTag 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/Predef.scala b/src/library/scala/Predef.scala
index 15e007528b..d2aa3a8b34 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -100,39 +100,36 @@ object Predef extends LowPriorityImplicits {
// def AnyRef = scala.AnyRef
// Manifest types, companions, and incantations for summoning
- @deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
type ClassManifest[T] = scala.reflect.ClassManifest[T]
- @deprecated("OptManifest is no longer supported and using it may lead to incorrect results, use `@scala.reflect.TypeTag` instead", "2.10.0")
type OptManifest[T] = scala.reflect.OptManifest[T]
- @deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
type Manifest[T] = scala.reflect.Manifest[T]
- @deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
val ClassManifest = scala.reflect.ClassManifest
- // [Paul to Eugene] No lazy vals in Predef. Too expensive. Have to work harder on breaking initialization dependencies.
- @deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
- lazy val Manifest = scala.reflect.Manifest // needs to be lazy, because requires scala.reflect.mirror instance
- @deprecated("NoManifest is no longer supported and using it may lead to incorrect results, use `@scala.reflect.TypeTag` instead", "2.10.0")
- lazy val NoManifest = scala.reflect.NoManifest // needs to be lazy, because requires scala.reflect.mirror instance
+ val Manifest = scala.reflect.Manifest
+ val NoManifest = scala.reflect.NoManifest
def manifest[T](implicit m: Manifest[T]) = m
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 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
+ 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
+ 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 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
+ 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
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index a7ec7618b7..fd8595ccb8 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -459,7 +459,7 @@ trait GenTraversableOnce[+A] extends Any {
/** Converts this $coll to an array.
*
- * @tparam B the type of the elements of the array. A `ClassManifest` for
+ * @tparam B the type of the elements of the array. An `ArrayTag` for
* this type must be available.
* @return an array containing all elements of this $coll.
*
@@ -469,9 +469,9 @@ trait GenTraversableOnce[+A] extends Any {
* $willNotTerminateInf
*
* @return an array containing all elements of this $coll.
- * A `ClassManifest` must be available for the element type of this $coll.
+ * An `ArrayTag` must be available for the element type of this $coll.
*/
- def toArray[A1 >: A: ClassManifest]: Array[A1]
+ def toArray[A1 >: A: ArrayTag]: Array[A1]
/** Converts this $coll to a list.
* $willNotTerminateInf
diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala
index 3fba3dfa79..a65be3ffcc 100644
--- a/src/library/scala/collection/Traversable.scala
+++ b/src/library/scala/collection/Traversable.scala
@@ -75,7 +75,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 : ClassManifest]: Array[B]
+ override def toArray[B >: A : ArrayTag]: 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 e68ef9e4de..5b5cee7f1b 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -229,7 +229,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 : ClassManifest]: Array[B] = {
+ def toArray[B >: A : ArrayTag]: 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 e7e797391e..20880e369d 100644
--- a/src/library/scala/collection/TraversableProxyLike.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -73,7 +73,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: ClassManifest]: Array[B] = self.toArray
+ override def toArray[B >: A: ArrayTag]: 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/generic/ClassManifestTraversableFactory.scala b/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala
index e418ca623f..d9ab17559e 100644
--- a/src/library/scala/collection/generic/ClassManifestTraversableFactory.scala
+++ b/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala
@@ -11,7 +11,7 @@ package generic
import language.higherKinds
-/** A template for companion objects of `ClassManifestTraversable` and
+/** A template for companion objects of `ClassTagTraversable` and
* subclasses thereof.
*
* @define coll collection
@@ -21,11 +21,11 @@ import language.higherKinds
* @author Aleksandar Prokopec
* @since 2.8
*/
-abstract class ClassManifestTraversableFactory[CC[X] <: Traversable[X] with GenericClassManifestTraversableTemplate[X, CC]]
- extends GenericClassManifestCompanion[CC] {
+abstract class ArrayTagTraversableFactory[CC[X] <: Traversable[X] with GenericArrayTagTraversableTemplate[X, CC]]
+ extends GenericArrayTagCompanion[CC] {
- class GenericCanBuildFrom[A](implicit manif: ClassManifest[A]) extends CanBuildFrom[CC[_], A, CC[A]] {
- def apply(from: CC[_]) = from.genericClassManifestBuilder[A]
+ class GenericCanBuildFrom[A](implicit tag: ArrayTag[A]) extends CanBuildFrom[CC[_], A, CC[A]] {
+ def apply(from: CC[_]) = from.genericArrayTagBuilder[A]
def apply = newBuilder[A]
}
}
diff --git a/src/library/scala/collection/generic/GenericClassManifestCompanion.scala b/src/library/scala/collection/generic/GenericArrayTagCompanion.scala
index f357091361..959adbce6d 100644
--- a/src/library/scala/collection/generic/GenericClassManifestCompanion.scala
+++ b/src/library/scala/collection/generic/GenericArrayTagCompanion.scala
@@ -12,19 +12,19 @@ package generic
import mutable.Builder
import language.higherKinds
-/** This class represents companions of classes which require ClassManifests
+/** This class represents companions of classes which require ArrayTags
* for their element types.
*
* @author Aleksandar Prokopec
*/
-abstract class GenericClassManifestCompanion[+CC[X] <: Traversable[X]] {
+abstract class GenericArrayTagCompanion[+CC[X] <: Traversable[X]] {
type Coll = CC[_]
- def newBuilder[A](implicit ord: ClassManifest[A]): Builder[A, CC[A]]
+ def newBuilder[A](implicit ord: ArrayTag[A]): Builder[A, CC[A]]
- def empty[A: ClassManifest]: CC[A] = newBuilder[A].result
+ def empty[A: ArrayTag]: CC[A] = newBuilder[A].result
- def apply[A](elems: A*)(implicit ord: ClassManifest[A]): CC[A] = {
+ def apply[A](elems: A*)(implicit ord: ArrayTag[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/GenericArrayTagTraversableTemplate.scala
new file mode 100644
index 0000000000..ac84683c59
--- /dev/null
+++ b/src/library/scala/collection/generic/GenericArrayTagTraversableTemplate.scala
@@ -0,0 +1,30 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.collection
+package generic
+
+import mutable.Builder
+import annotation.unchecked.uncheckedVariance
+import language.higherKinds
+
+/** This trait represents collections classes which require array
+ * 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)
+}
diff --git a/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala
deleted file mode 100644
index 1a5db4bab2..0000000000
--- a/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-package generic
-
-import mutable.Builder
-import annotation.unchecked.uncheckedVariance
-import language.higherKinds
-
-/** This trait represents collections classes which require class
- * manifests for their element types.
- *
- * @author Aleksandar Prokopec
- * @since 2.8
- */
-trait GenericClassManifestTraversableTemplate[+A, +CC[X] <: Traversable[X]] extends HasNewBuilder[A, CC[A] @uncheckedVariance] {
- implicit protected[this] val manifest: ClassManifest[A]
- def classManifestCompanion: GenericClassManifestCompanion[CC]
- def genericClassManifestBuilder[B](implicit man: ClassManifest[B]): Builder[B, CC[B]] = classManifestCompanion.newBuilder[B]
-}
diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala
index 3d723a1feb..3d5bc2704f 100644
--- a/src/library/scala/collection/generic/TraversableForwarder.scala
+++ b/src/library/scala/collection/generic/TraversableForwarder.scala
@@ -57,7 +57,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: ClassManifest]: Array[B] = underlying.toArray
+ override def toArray[B >: A: ArrayTag]: 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 0457fef227..32006b4bf0 100644
--- a/src/library/scala/collection/generic/package.scala
+++ b/src/library/scala/collection/generic/package.scala
@@ -3,4 +3,13 @@ import generic.CanBuildFrom
package object generic {
type CanBuild[-Elem, +To] = CanBuildFrom[Nothing, Elem, To]
+
+ @deprecated("use ArrayTagTraversableFactory instead", "2.10.0")
+ type ClassManifestTraversableFactory[CC[X] <: Traversable[X] with GenericClassManifestTraversableTemplate[X, CC]] = ArrayTagTraversableFactory[CC]
+
+ @deprecated("use GenericArrayTagCompanion instead", "2.10.0")
+ type GenericClassManifestCompanion[+CC[X] <: Traversable[X]] = GenericArrayTagCompanion[CC]
+
+ @deprecated("use GenericArrayTagTraversableTemplate instead", "2.10.0")
+ type GenericClassManifestTraversableTemplate[+A, +CC[X] <: Traversable[X]] = GenericArrayTagTraversableTemplate[A, CC]
} \ No newline at end of file
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index 97c7c789f8..68c75ee586 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -25,7 +25,7 @@ object PagedSeq {
final val UndeterminedEnd = Int.MaxValue
/** Constructs a paged sequence from an iterator */
- def fromIterator[T: ClassManifest](source: Iterator[T]): PagedSeq[T] =
+ def fromIterator[T: ArrayTag](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 +36,7 @@ object PagedSeq {
})
/** Constructs a paged sequence from an iterable */
- def fromIterable[T: ClassManifest](source: Iterable[T]): PagedSeq[T] =
+ def fromIterable[T: ArrayTag](source: Iterable[T]): PagedSeq[T] =
fromIterator(source.iterator)
/** Constructs a paged character sequence from a string iterator */
@@ -115,7 +115,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 a `ClassManifest` context bound.
+ * @tparam T the type of the elements contained in this paged sequence, with an `ArrayTag` context bound.
*
* @author Martin Odersky
* @since 2.7
@@ -124,7 +124,7 @@ import PagedSeq._
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
-class PagedSeq[T: ClassManifest] protected(
+class PagedSeq[T: ArrayTag] protected(
more: (Array[T], Int, Int) => Int,
first1: Page[T],
start: Int,
@@ -205,7 +205,7 @@ extends scala.collection.AbstractSeq[T]
/** Page containing up to PageSize characters of the input sequence.
*/
-private class Page[T: ClassManifest](val num: Int) {
+private class Page[T: ArrayTag](val num: Int) {
private final val PageSize = 4096
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index 06f09f359f..52032a1cde 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -239,7 +239,7 @@ self =>
else
throw new IllegalArgumentException("For input string: \"null\"")
- override def toArray[B >: Char : ClassManifest]: Array[B] =
+ override def toArray[B >: Char : ArrayTag]: Array[B] =
toString.toCharArray.asInstanceOf[Array[B]]
private def unwrapArg(arg: Any): AnyRef = arg match {
diff --git a/src/library/scala/collection/interfaces/IterableMethods.scala b/src/library/scala/collection/interfaces/IterableMethods.scala
index 2054922e59..8efc3fe6f9 100644
--- a/src/library/scala/collection/interfaces/IterableMethods.scala
+++ b/src/library/scala/collection/interfaces/IterableMethods.scala
@@ -11,7 +11,6 @@ package interfaces
import generic._
import mutable.Buffer
-import scala.reflect.ClassManifest
import annotation.unchecked.uncheckedVariance
/**
diff --git a/src/library/scala/collection/interfaces/SeqMethods.scala b/src/library/scala/collection/interfaces/SeqMethods.scala
index 1f5b08d036..4327073d21 100644
--- a/src/library/scala/collection/interfaces/SeqMethods.scala
+++ b/src/library/scala/collection/interfaces/SeqMethods.scala
@@ -11,7 +11,6 @@ package interfaces
import generic._
import mutable.Buffer
-import scala.reflect.ClassManifest
/**
* @since 2.8
diff --git a/src/library/scala/collection/interfaces/SetMethods.scala b/src/library/scala/collection/interfaces/SetMethods.scala
index ffe141ed82..3b6214f45c 100644
--- a/src/library/scala/collection/interfaces/SetMethods.scala
+++ b/src/library/scala/collection/interfaces/SetMethods.scala
@@ -11,7 +11,6 @@ package interfaces
import generic._
import mutable.Buffer
-import scala.reflect.ClassManifest
import annotation.unchecked.uncheckedVariance
/**
diff --git a/src/library/scala/collection/interfaces/TraversableOnceMethods.scala b/src/library/scala/collection/interfaces/TraversableOnceMethods.scala
index 471e977134..543d59d118 100644
--- a/src/library/scala/collection/interfaces/TraversableOnceMethods.scala
+++ b/src/library/scala/collection/interfaces/TraversableOnceMethods.scala
@@ -46,7 +46,7 @@ trait TraversableOnceMethods[+A] {
def copyToBuffer[B >: A](dest: mutable.Buffer[B]): Unit
// conversions
- def toArray[B >: A : ClassManifest]: Array[B]
+ def toArray[B >: A : ArrayTag]: Array[B]
def toBuffer[B >: A]: mutable.Buffer[B]
def toIndexedSeq: immutable.IndexedSeq[A]
def toIterable: Iterable[A]
diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala
index e396b0695e..293e85a97e 100644
--- a/src/library/scala/collection/mutable/ArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/ArrayBuilder.scala
@@ -12,7 +12,8 @@ package scala.collection
package mutable
import generic._
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
+import scala.runtime.ScalaRunTime
/** A builder class for arrays.
*
@@ -30,12 +31,12 @@ object ArrayBuilder {
/** Creates a new arraybuilder of type `T`.
*
- * @tparam T type of the elements for the array builder, with a `ClassManifest` context bound.
+ * @tparam T type of the elements for the array builder, with a `ArrayTag` context bound.
* @return a new empty array builder.
*/
- def make[T: ClassManifest](): ArrayBuilder[T] = {
- val manifest = implicitly[ClassManifest[T]]
- val erasure = manifest.erasure
+ def make[T: ArrayTag](): ArrayBuilder[T] = {
+ val tag = implicitly[ArrayTag[T]]
+ val erasure = ScalaRunTime.arrayElementClass(tag)
erasure match {
case java.lang.Byte.TYPE => new ArrayBuilder.ofByte().asInstanceOf[ArrayBuilder[T]]
case java.lang.Short.TYPE => new ArrayBuilder.ofShort().asInstanceOf[ArrayBuilder[T]]
@@ -46,15 +47,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]()(manifest.asInstanceOf[ClassManifest[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]]
+ case _ => new ArrayBuilder.ofRef[T with AnyRef]()(tag.asInstanceOf[ArrayTag[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 `ClassManifest` context bound.
+ * @tparam T type of elements for the array builder, subtype of `AnyRef` with a `ArrayTag` context bound.
*/
- class ofRef[T <: AnyRef : ClassManifest] extends ArrayBuilder[T] {
+ class ofRef[T <: AnyRef : ArrayTag] 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 875030ade0..5f0e1e1071 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -12,7 +12,8 @@ package scala.collection
package mutable
import compat.Platform.arraycopy
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
+import scala.runtime.ScalaRunTime._
import parallel.mutable.ParArray
@@ -37,10 +38,8 @@ import parallel.mutable.ParArray
*/
abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParallelizable[T, ParArray[T]] {
- private def rowBuilder[U]: Builder[U, Array[U]] =
- Array.newBuilder(
- ClassManifest[U](
- repr.getClass.getComponentType.getComponentType))
+ private def elementClass: Class[_] =
+ arrayElementClass(repr.getClass)
override def copyToArray[U >: T](xs: Array[U], start: Int, len: Int) {
var l = math.min(len, repr.length)
@@ -48,11 +47,13 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
Array.copy(repr, 0, xs, start, l)
}
- override def toArray[U >: T : ClassManifest]: Array[U] =
- if (implicitly[ClassManifest[U]].erasure eq repr.getClass.getComponentType)
+ override def toArray[U >: T : ArrayTag]: Array[U] = {
+ val thatElementClass = arrayElementClass(implicitly[ArrayTag[U]])
+ if (elementClass eq thatElementClass)
repr.asInstanceOf[Array[U]]
else
super.toArray[U]
+ }
override def par = ParArray.handoff(repr)
@@ -63,7 +64,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
* @param asArray 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: ClassManifest[U]): Array[U] = {
+ def flatten[U, To](implicit asTrav: T => collection.Traversable[U], m: ArrayTag[U]): Array[U] = {
val b = Array.newBuilder[U]
b.sizeHint(map{case is: collection.IndexedSeq[_] => is.size case _ => 0}.sum)
for (xs <- this)
@@ -78,7 +79,8 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
* @return An array obtained by replacing elements of this arrays with rows the represent.
*/
def transpose[U](implicit asArray: T => Array[U]): Array[Array[U]] = {
- val bs = asArray(head) map (_ => rowBuilder[U])
+ def mkRowBuilder() = Array.newBuilder(ClassTag[U](arrayElementClass(elementClass)))
+ val bs = asArray(head) map (_ => mkRowBuilder())
for (xs <- this) {
var i = 0
for (x <- asArray(xs)) {
@@ -86,9 +88,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
i += 1
}
}
- val bb: Builder[Array[U], Array[Array[U]]] = Array.newBuilder(
- ClassManifest[Array[U]](
- repr.getClass.getComponentType))
+ val bb: Builder[Array[U], Array[Array[U]]] = Array.newBuilder(ClassTag[Array[U]](elementClass))
for (b <- bs) bb += b.result
bb.result
}
@@ -109,8 +109,7 @@ object ArrayOps {
override protected[this] def thisCollection: WrappedArray[T] = new WrappedArray.ofRef[T](repr)
override protected[this] def toCollection(repr: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](repr)
- override protected[this] def newBuilder = new ArrayBuilder.ofRef[T]()(
- ClassManifest[T](repr.getClass.getComponentType))
+ override protected[this] def newBuilder = new ArrayBuilder.ofRef[T]()(ClassTag[T](arrayElementClass(repr.getClass)))
def length: Int = repr.length
def apply(index: Int): T = repr(index)
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index f5287312b9..b3a0534826 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -21,7 +21,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: ClassManifest](elems: A*): ArrayStack[A] = {
+ def apply[A: ArrayTag](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/FlatArray.scala b/src/library/scala/collection/mutable/FlatArray.scala
index 3e43b66ecf..5b4b5e777f 100644
--- a/src/library/scala/collection/mutable/FlatArray.scala
+++ b/src/library/scala/collection/mutable/FlatArray.scala
@@ -11,7 +11,7 @@
package scala.collection
package mutable
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
import generic.CanBuildFrom
/**
@@ -62,16 +62,16 @@ object FlatArray {
def ofDim[Boxed, Unboxed](size:Int)
(implicit boxings: BoxingConversions[Boxed, Unboxed],
- manifest: ClassManifest[Unboxed]): FlatArray[Boxed] = {
+ tag: ArrayTag[Unboxed]): FlatArray[Boxed] = {
val elems = Array.ofDim[Unboxed](size)
- new FlatArray.Impl(elems, boxings, manifest)
+ new FlatArray.Impl(elems, boxings, tag)
}
def empty[Boxed, Unboxed](implicit boxings: BoxingConversions[Boxed, Unboxed],
- elemManifest: ClassManifest[Unboxed]): FlatArray[Boxed] = apply()
+ elemTag: ArrayTag[Unboxed]): FlatArray[Boxed] = apply()
def apply[Boxed, Unboxed](elems: Boxed*)
- (implicit boxings: BoxingConversions[Boxed, Unboxed], elemManifest: ClassManifest[Unboxed]): FlatArray[Boxed] = {
+ (implicit boxings: BoxingConversions[Boxed, Unboxed], elemTag: ArrayTag[Unboxed]): FlatArray[Boxed] = {
val b = newBuilder[Boxed, Unboxed]
b.sizeHint(elems.length)
b ++= elems
@@ -79,13 +79,13 @@ object FlatArray {
}
def newBuilder[Boxed, Unboxed]
- (implicit boxings: BoxingConversions[Boxed, Unboxed], elemManifest: ClassManifest[Unboxed]): Builder[Boxed, FlatArray[Boxed]] =
- new Bldr[Boxed, Unboxed](boxings, elemManifest)
+ (implicit boxings: BoxingConversions[Boxed, Unboxed], elemTag: ArrayTag[Unboxed]): Builder[Boxed, FlatArray[Boxed]] =
+ new Bldr[Boxed, Unboxed](boxings, elemTag)
implicit def canBuildFrom[Boxed, Unboxed](
implicit
boxings: BoxingConversions[Boxed, Unboxed],
- elemManifest: ClassManifest[Unboxed]): CanBuildFrom[FlatArray[_], Boxed, FlatArray[Boxed]] =
+ elemTag: ArrayTag[Unboxed]): CanBuildFrom[FlatArray[_], Boxed, FlatArray[Boxed]] =
new CanBuildFrom[FlatArray[_], Boxed, FlatArray[Boxed]] {
def apply(from: FlatArray[_]): Builder[Boxed, FlatArray[Boxed]] =
newBuilder[Boxed, Unboxed]
@@ -93,14 +93,14 @@ object FlatArray {
newBuilder[Boxed, Unboxed]
}
- private class Bldr[Boxed, Unboxed](boxings: BoxingConversions[Boxed, Unboxed], manifest: ClassManifest[Unboxed]) extends Builder[Boxed, FlatArray[Boxed]] {
+ private class Bldr[Boxed, Unboxed](boxings: BoxingConversions[Boxed, Unboxed], tag: ArrayTag[Unboxed]) extends Builder[Boxed, FlatArray[Boxed]] {
private var elems: Array[Unboxed] = _
private var capacity: Int = 0
private var size: Int = 0
private def resize(size: Int) {
- val newelems = manifest.newArray(size)
+ val newelems = tag.newArray(size)
if (this.size > 0) Array.copy(elems, 0, newelems, 0, this.size)
elems = newelems
capacity = size
@@ -131,14 +131,14 @@ object FlatArray {
def result(): FlatArray[Boxed] = {
if (capacity == 0 || capacity != size) resize(size)
- new FlatArray.Impl(elems, boxings, manifest)
+ new FlatArray.Impl(elems, boxings, tag)
}
}
private class Impl[Boxed, Unboxed](
elems: Array[Unboxed],
boxings: BoxingConversions[Boxed, Unboxed],
- elemManifest: ClassManifest[Unboxed]) extends FlatArray[Boxed] {
+ elemTag: ArrayTag[Unboxed]) extends FlatArray[Boxed] {
def length = elems.length
@@ -149,9 +149,9 @@ object FlatArray {
/** Creates new builder for this collection ==> move to subclasses
*/
override protected[this] def newBuilder: Builder[Boxed, FlatArray[Boxed]] =
- new Bldr[Boxed, Unboxed](boxings, elemManifest)
+ new Bldr[Boxed, Unboxed](boxings, elemTag)
/** Clones this object, including the underlying Array. */
- override def clone: FlatArray[Boxed] = new Impl[Boxed, Unboxed](elems.clone(), boxings, elemManifest)
+ override def clone: FlatArray[Boxed] = new Impl[Boxed, Unboxed](elems.clone(), boxings, elemTag)
}
}
diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala
index 09e6088782..889768d471 100644
--- a/src/library/scala/collection/mutable/UnrolledBuffer.scala
+++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala
@@ -41,11 +41,11 @@ import annotation.tailrec
*
*/
@SerialVersionUID(1L)
-class UnrolledBuffer[T](implicit val manifest: ClassManifest[T])
+class UnrolledBuffer[T](implicit val tag: ArrayTag[T])
extends collection.mutable.AbstractBuffer[T]
with collection.mutable.Buffer[T]
with collection.mutable.BufferLike[T, UnrolledBuffer[T]]
- with GenericClassManifestTraversableTemplate[T, UnrolledBuffer]
+ with GenericArrayTagTraversableTemplate[T, UnrolledBuffer]
with collection.mutable.Builder[T, UnrolledBuffer[T]]
with Serializable
{
@@ -67,7 +67,7 @@ extends collection.mutable.AbstractBuffer[T]
private[collection] def calcNextLength(sz: Int) = sz
- def classManifestCompanion = UnrolledBuffer
+ def arrayTagCompanion = UnrolledBuffer
/** Concatenates the targer unrolled buffer to this unrolled buffer.
*
@@ -183,11 +183,11 @@ extends collection.mutable.AbstractBuffer[T]
}
-object UnrolledBuffer extends ClassManifestTraversableFactory[UnrolledBuffer] {
+object UnrolledBuffer extends ArrayTagTraversableFactory[UnrolledBuffer] {
/** $genericCanBuildFromInfo */
- implicit def canBuildFrom[T](implicit m: ClassManifest[T]): CanBuildFrom[Coll, T, UnrolledBuffer[T]] =
+ implicit def canBuildFrom[T](implicit t: ArrayTag[T]): CanBuildFrom[Coll, T, UnrolledBuffer[T]] =
new GenericCanBuildFrom[T]
- def newBuilder[T](implicit m: ClassManifest[T]): Builder[T, UnrolledBuffer[T]] = new UnrolledBuffer[T]
+ def newBuilder[T](implicit t: ArrayTag[T]): Builder[T, UnrolledBuffer[T]] = new UnrolledBuffer[T]
val waterline = 50
val waterlineDelim = 100
@@ -195,7 +195,7 @@ object UnrolledBuffer extends ClassManifestTraversableFactory[UnrolledBuffer] {
/** Unrolled buffer node.
*/
- class Unrolled[T: ClassManifest] private[collection] (var size: Int, var array: Array[T], var next: Unrolled[T], val buff: UnrolledBuffer[T] = null) {
+ class Unrolled[T: ArrayTag] 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 fac4eb77bb..9d170b2832 100644
--- a/src/library/scala/collection/mutable/WrappedArray.scala
+++ b/src/library/scala/collection/mutable/WrappedArray.scala
@@ -11,7 +11,8 @@
package scala.collection
package mutable
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
+import scala.runtime.ScalaRunTime._
import scala.collection.generic._
import scala.collection.parallel.mutable.ParArray
@@ -40,8 +41,11 @@ extends AbstractSeq[T]
override protected[this] def thisCollection: WrappedArray[T] = this
override protected[this] def toCollection(repr: WrappedArray[T]): WrappedArray[T] = repr
- /** The manifest of the element type */
- def elemManifest: ClassManifest[T]
+ /** The tag of the element type */
+ def elemTag: ArrayTag[T]
+
+ @deprecated("use elemTag instead", "2.10.0")
+ def elemManifest: ClassManifest[T] = ClassManifest.fromClass[T](arrayElementClass(elemTag).asInstanceOf[Class[T]])
/** The length of the array */
def length: Int
@@ -57,11 +61,16 @@ extends AbstractSeq[T]
override def par = ParArray.handoff(array)
- override def toArray[U >: T : ClassManifest]: Array[U] =
- if (implicitly[ClassManifest[U]].erasure eq array.getClass.getComponentType)
+ private def elementClass: Class[_] =
+ arrayElementClass(repr.getClass)
+
+ override def toArray[U >: T : ArrayTag]: Array[U] = {
+ val thatElementClass = arrayElementClass(implicitly[ArrayTag[U]])
+ if (elementClass eq thatElementClass)
array.asInstanceOf[Array[U]]
else
super.toArray[U]
+ }
override def stringPrefix = "WrappedArray"
@@ -71,7 +80,7 @@ extends AbstractSeq[T]
/** Creates new builder for this collection ==> move to subclasses
*/
override protected[this] def newBuilder: Builder[T, WrappedArray[T]] =
- new WrappedArrayBuilder[T](elemManifest)
+ new WrappedArrayBuilder[T](elemTag)
}
@@ -101,7 +110,7 @@ object WrappedArray {
case x: Array[Unit] => new ofUnit(x)
}).asInstanceOf[WrappedArray[T]]
- implicit def canBuildFrom[T](implicit m: ClassManifest[T]): CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] =
+ implicit def canBuildFrom[T](implicit m: ArrayTag[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]
@@ -112,70 +121,70 @@ object WrappedArray {
def newBuilder[A]: Builder[A, IndexedSeq[A]] = new ArrayBuffer
final class ofRef[T <: AnyRef](val array: Array[T]) extends WrappedArray[T] with Serializable {
- lazy val elemManifest = ClassManifest[T](array.getClass.getComponentType)
+ lazy val elemTag = ClassTag[T](arrayElementClass(array.getClass))
def length: Int = array.length
def apply(index: Int): T = array(index).asInstanceOf[T]
def update(index: Int, elem: T) { array(index) = elem }
}
final class ofByte(val array: Array[Byte]) extends WrappedArray[Byte] with Serializable {
- def elemManifest = ClassManifest.Byte
+ def elemTag = ClassTag.Byte
def length: Int = array.length
def apply(index: Int): Byte = array(index)
def update(index: Int, elem: Byte) { array(index) = elem }
}
final class ofShort(val array: Array[Short]) extends WrappedArray[Short] with Serializable {
- def elemManifest = ClassManifest.Short
+ def elemTag = ClassTag.Short
def length: Int = array.length
def apply(index: Int): Short = array(index)
def update(index: Int, elem: Short) { array(index) = elem }
}
final class ofChar(val array: Array[Char]) extends WrappedArray[Char] with Serializable {
- def elemManifest = ClassManifest.Char
+ def elemTag = ClassTag.Char
def length: Int = array.length
def apply(index: Int): Char = array(index)
def update(index: Int, elem: Char) { array(index) = elem }
}
final class ofInt(val array: Array[Int]) extends WrappedArray[Int] with Serializable {
- def elemManifest = ClassManifest.Int
+ def elemTag = ClassTag.Int
def length: Int = array.length
def apply(index: Int): Int = array(index)
def update(index: Int, elem: Int) { array(index) = elem }
}
final class ofLong(val array: Array[Long]) extends WrappedArray[Long] with Serializable {
- def elemManifest = ClassManifest.Long
+ def elemTag = ClassTag.Long
def length: Int = array.length
def apply(index: Int): Long = array(index)
def update(index: Int, elem: Long) { array(index) = elem }
}
final class ofFloat(val array: Array[Float]) extends WrappedArray[Float] with Serializable {
- def elemManifest = ClassManifest.Float
+ def elemTag = ClassTag.Float
def length: Int = array.length
def apply(index: Int): Float = array(index)
def update(index: Int, elem: Float) { array(index) = elem }
}
final class ofDouble(val array: Array[Double]) extends WrappedArray[Double] with Serializable {
- def elemManifest = ClassManifest.Double
+ def elemTag = ClassTag.Double
def length: Int = array.length
def apply(index: Int): Double = array(index)
def update(index: Int, elem: Double) { array(index) = elem }
}
final class ofBoolean(val array: Array[Boolean]) extends WrappedArray[Boolean] with Serializable {
- def elemManifest = ClassManifest.Boolean
+ def elemTag = ClassTag.Boolean
def length: Int = array.length
def apply(index: Int): Boolean = array(index)
def update(index: Int, elem: Boolean) { array(index) = elem }
}
final class ofUnit(val array: Array[Unit]) extends WrappedArray[Unit] with Serializable {
- def elemManifest = ClassManifest.Unit
+ def elemTag = ClassTag.Unit
def length: Int = array.length
def apply(index: Int): Unit = array(index)
def update(index: Int, elem: Unit) { array(index) = elem }
diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
index fce65468e9..99a0b0ede3 100644
--- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
@@ -12,23 +12,27 @@ package scala.collection
package mutable
import generic._
-import scala.reflect.ClassManifest
+import scala.reflect.ArrayTag
+import scala.runtime.ScalaRunTime._
/** A builder class for arrays.
*
- * @tparam A type of elements that can be added to this builder.
- * @param manifest class manifest for objects of type `A`.
+ * @tparam A type of elements that can be added to this builder.
+ * @param tag class tag for objects of type `A`.
*
* @since 2.8
*/
-class WrappedArrayBuilder[A](manifest: ClassManifest[A]) extends Builder[A, WrappedArray[A]] {
+class WrappedArrayBuilder[A](tag: ArrayTag[A]) extends Builder[A, WrappedArray[A]] {
+
+ @deprecated("use tag instead", "2.10.0")
+ val manifest: ArrayTag[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 = manifest.erasure
+ val erasure = arrayElementClass(tag)
val newelems = erasure 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]]
@@ -39,7 +43,7 @@ class WrappedArrayBuilder[A](manifest: ClassManifest[A]) extends Builder[A, Wrap
case java.lang.Double.TYPE => new WrappedArray.ofDouble(new Array[Double](size)).asInstanceOf[WrappedArray[A]]
case java.lang.Boolean.TYPE => new WrappedArray.ofBoolean(new Array[Boolean](size)).asInstanceOf[WrappedArray[A]]
case java.lang.Void.TYPE => new WrappedArray.ofUnit(new Array[Unit](size)).asInstanceOf[WrappedArray[A]]
- case _ => new WrappedArray.ofRef[A with AnyRef](manifest.newArray(size).asInstanceOf[Array[A with AnyRef]]).asInstanceOf[WrappedArray[A]]
+ case _ => new WrappedArray.ofRef[A with AnyRef](tag.newArray(size).asInstanceOf[Array[A with AnyRef]]).asInstanceOf[WrappedArray[A]]
}
if (this.size > 0) Array.copy(elems.array, 0, newelems.array, 0, this.size)
newelems
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 5bf338f560..014b9b1a42 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -155,15 +155,15 @@ extends GenIterableLike[T, Repr]
with HasNewCombiner[T, Repr]
{
self: ParIterableLike[T, Repr, Sequential] =>
-
+
@transient
@volatile
private var _tasksupport = defaultTaskSupport
-
+
protected def initTaskSupport() {
_tasksupport = defaultTaskSupport
}
-
+
def tasksupport = {
val ts = _tasksupport
if (ts eq null) {
@@ -171,9 +171,9 @@ self: ParIterableLike[T, Repr, Sequential] =>
defaultTaskSupport
} else ts
}
-
+
def tasksupport_=(ts: TaskSupport) = _tasksupport = ts
-
+
def seq: Sequential
def repr: Repr = this.asInstanceOf[Repr]
@@ -240,7 +240,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
trait BuilderOps[Elem, To] {
trait Otherwise[Cmb] {
- def otherwise(notbody: => Unit)(implicit m: ClassManifest[Cmb]): Unit
+ def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]): Unit
}
def ifIs[Cmb](isbody: Cmb => Unit): Otherwise[Cmb]
@@ -282,8 +282,8 @@ 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 m: ClassManifest[Cmb]) {
- if (cb.getClass == m.erasure) isbody(cb.asInstanceOf[Cmb]) else notbody
+ def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]) {
+ if (cb.getClass == t.erasure) isbody(cb.asInstanceOf[Cmb]) else notbody
}
}
def isCombiner = cb.isInstanceOf[Combiner[_, _]]
@@ -754,7 +754,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
cntx.setIndexFlag(Int.MaxValue)
tasksupport.executeAndWaitResult(
new Span(0, pred, combinerFactory, combinerFactory, splitter assign cntx) mapResult {
- _._2.resultWithTaskSupport
+ _._2.resultWithTaskSupport
}
)
}
@@ -802,7 +802,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def size = splitter.remaining
}
- override def toArray[U >: T: ClassManifest]: Array[U] = {
+ override def toArray[U >: T: ArrayTag]: 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 8cc0b95997..92ba701f7c 100644
--- a/src/library/scala/collection/parallel/mutable/ParArray.scala
+++ b/src/library/scala/collection/parallel/mutable/ParArray.scala
@@ -676,7 +676,7 @@ self =>
private def readObject(in: java.io.ObjectInputStream) {
in.defaultReadObject
-
+
// get raw array from arrayseq
array = arrayseq.array.asInstanceOf[Array[Any]]
}
@@ -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 : ClassManifest](arr: Array[T]): ParArray[T] = {
+ def createFromCopy[T <: AnyRef : ArrayTag](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 410b542a68..43d40776bf 100644
--- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
@@ -26,7 +26,7 @@ import scala.collection.parallel.Task
-private[mutable] class DoublingUnrolledBuffer[T](implicit m: ClassManifest[T]) extends UnrolledBuffer[T]()(m) {
+private[mutable] class DoublingUnrolledBuffer[T](implicit t: ArrayTag[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 9aaf05dbd6..def086bc03 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -134,26 +134,26 @@ trait Future[+T] extends Awaitable[T] {
/** Creates a new promise.
*/
protected def newPromise[S]: Promise[S]
-
+
/** Returns whether the future has already been completed with
* a value or an exception.
- *
+ *
* $nonDeterministic
- *
+ *
* @return `true` if the future is already completed, `false` otherwise
*/
def isCompleted: Boolean
-
+
/** The value of this `Future`.
- *
+ *
* If the future is not completed the returned value will be `None`.
* If the future is completed the value will be `Some(Success(t))`
* if it contains a valid result, or `Some(Failure(error))` if it contains
* an exception.
*/
def value: Option[Either[Throwable, T]]
-
-
+
+
/* Projections */
/** Returns a failed projection of this future.
@@ -421,11 +421,11 @@ trait Future[+T] extends Awaitable[T] {
}
p.future
}
-
+
/** Creates a new `Future[S]` which is completed with this `Future`'s result if
* that conforms to `S`'s erased type or a `ClassCastException` otherwise.
*/
- def mapTo[S](implicit m: Manifest[S]): Future[S] = {
+ def mapTo[S](implicit tag: ClassTag[S]): Future[S] = {
import java.{ lang => jl }
val toBoxed = Map[Class[_], Class[_]](
classOf[Boolean] -> classOf[jl.Boolean],
@@ -444,20 +444,20 @@ trait Future[+T] extends Awaitable[T] {
}
val p = newPromise[S]
-
+
onComplete {
case l: Left[Throwable, _] => p complete l.asInstanceOf[Either[Throwable, S]]
case Right(t) =>
p complete (try {
- Right(boxedType(m.erasure).cast(t).asInstanceOf[S])
+ Right(boxedType(tag.erasure).cast(t).asInstanceOf[S])
} catch {
case e: ClassCastException => Left(e)
})
}
-
+
p.future
}
-
+
/** Applies the side-effecting function to the result of this future, and returns
* a new future with the result of this future.
*
@@ -591,7 +591,7 @@ object Future {
* The fold is performed on the thread where the last future is completed,
* the result will be the first failure of any of the futures, or any failure in the actual fold,
* or the result of the fold.
- *
+ *
* Example:
* {{{
* val result = Await.result(Future.fold(futures)(0)(_ + _), 5 seconds)
@@ -603,7 +603,7 @@ object Future {
}
/** Initiates a fold over the supplied futures where the fold-zero is the result value of the `Future` that's completed first.
- *
+ *
* Example:
* {{{
* val result = Await.result(Futures.reduce(futures)(_ + _), 5 seconds)
@@ -613,11 +613,11 @@ object Future {
if (futures.isEmpty) Promise[R].failure(new NoSuchElementException("reduce attempted on empty collection")).future
else sequence(futures).map(_ reduceLeft op)
}
-
+
/** Transforms a `Traversable[A]` into a `Future[Traversable[B]]` using the provided function `A => Future[B]`.
* This is useful for performing a parallel map. For example, to apply a function to all items of a list
* in parallel:
- *
+ *
* {{{
* val myFutureList = Future.traverse(myList)(x => Future(myFunc(x)))
* }}}
@@ -627,7 +627,7 @@ object Future {
val fb = fn(a.asInstanceOf[A])
for (r <- fr; b <- fb) yield (r += b)
}.map(_.result)
-
+
}
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala
index 1f4e3c9865..ee62706e49 100644
--- a/src/library/scala/math/Numeric.scala
+++ b/src/library/scala/math/Numeric.scala
@@ -36,8 +36,8 @@ object Numeric {
def fromInt(x: Int): BigInt = BigInt(x)
def toInt(x: BigInt): Int = x.intValue
def toLong(x: BigInt): Long = x.longValue
- def toFloat(x: BigInt): Float = x.longValue.toFloat
- def toDouble(x: BigInt): Double = x.longValue.toDouble
+ def toFloat(x: BigInt): Float = x.floatValue
+ def toDouble(x: BigInt): Double = x.doubleValue
}
implicit object BigIntIsIntegral extends BigIntIsIntegral with Ordering.BigIntOrdering
diff --git a/src/library/scala/reflect/ArrayTag.scala b/src/library/scala/reflect/ArrayTag.scala
index 8df7fe5f4e..ba0c075723 100644
--- a/src/library/scala/reflect/ArrayTag.scala
+++ b/src/library/scala/reflect/ArrayTag.scala
@@ -3,11 +3,17 @@ 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.
+ * `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] {
diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala
new file mode 100644
index 0000000000..43e043fd40
--- /dev/null
+++ b/src/library/scala/reflect/ClassManifest.scala
@@ -0,0 +1,242 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.reflect
+
+import scala.collection.mutable.{ WrappedArray, ArrayBuilder }
+import java.lang.{ Class => jClass }
+
+/** A `ClassManifest[T]` is an opaque descriptor for type `T`.
+ * It is used by the compiler to preserve information necessary
+ * for instantiating `Arrays` in those cases where the element type
+ * is unknown at compile time.
+ *
+ * The type-relation operators make an effort to present a more accurate
+ * picture than can be realized with erased types, but they should not be
+ * relied upon to give correct answers. In particular they are likely to
+ * be wrong when variance is involved or when a subtype has a different
+ * number of type arguments than a supertype.
+ */
+@deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
+trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with Serializable {
+ /** 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[_]
+
+ private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = {
+ def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = {
+ left.nonEmpty && {
+ val next = left.head
+ val supers = next.getInterfaces.toSet ++ Option(next.getSuperclass)
+ supers(sup) || {
+ val xs = left ++ supers filterNot seen
+ loop(xs - next, seen + next)
+ }
+ }
+ }
+ loop(Set(sub), Set())
+ }
+
+ private def subargs(args1: List[OptManifest[_]], args2: List[OptManifest[_]]) = (args1 corresponds args2) {
+ // !!! [Martin] this is wrong, need to take variance into account
+ case (x: ClassManifest[_], y: ClassManifest[_]) => x <:< y
+ case (x, y) => (x eq NoManifest) && (y eq NoManifest)
+ }
+
+ /** Tests whether the type represented by this manifest is a subtype
+ * of the type represented by `that` manifest, subject to the limitations
+ * described in the header.
+ */
+ def <:<(that: ClassManifest[_]): Boolean = {
+ // All types which could conform to these types will override <:<.
+ def cannotMatch = {
+ import Manifest._
+ that.isInstanceOf[AnyValManifest[_]] || (that eq AnyVal) || (that eq Nothing) || (that eq Null)
+ }
+
+ // This is wrong, and I don't know how it can be made right
+ // without more development of Manifests, due to arity-defying
+ // relationships like:
+ //
+ // List[String] <: AnyRef
+ // Map[Int, Int] <: Iterable[(Int, Int)]
+ //
+ // Given the manifest for Map[A, B] how do I determine that a
+ // supertype has single type argument (A, B) ? I don't see how we
+ // can say whether X <:< Y when type arguments are involved except
+ // when the erasure is the same, even before considering variance.
+ !cannotMatch && {
+ // this part is wrong for not considering variance
+ if (this.erasure == that.erasure)
+ subargs(this.typeArguments, that.typeArguments)
+ // this part is wrong for punting unless the rhs has no type
+ // arguments, but it's better than a blindfolded pinata swing.
+ else
+ that.typeArguments.isEmpty && subtype(this.erasure, that.erasure)
+ }
+ }
+
+ /** Tests whether the type represented by this manifest is a supertype
+ * of the type represented by `that` manifest, subject to the limitations
+ * described in the header.
+ */
+ def >:>(that: ClassManifest[_]): Boolean =
+ that <:< this
+
+ override def canEqual(other: Any) = other match {
+ case _: ClassManifest[_] => true
+ case _ => false
+ }
+
+ /** Tests whether the type represented by this manifest is equal to
+ * the type represented by `that` manifest, subject to the limitations
+ * described in the header.
+ */
+ override def equals(that: Any): Boolean = that match {
+ case m: ClassManifest[_] => (m canEqual this) && (this.erasure == m.erasure)
+ case _ => false
+ }
+ override def hashCode = this.erasure.##
+
+ protected def arrayClass[T](tp: jClass[_]): jClass[Array[T]] =
+ java.lang.reflect.Array.newInstance(tp, 0).getClass.asInstanceOf[jClass[Array[T]]]
+
+ def arrayManifest: ClassManifest[Array[T]] =
+ ClassManifest.classType[Array[T]](arrayClass[T](erasure), this)
+
+ override def newArray(len: Int): Array[T] =
+ java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]]
+
+ def newArray2(len: Int): Array[Array[T]] =
+ java.lang.reflect.Array.newInstance(arrayClass[T](erasure), len)
+ .asInstanceOf[Array[Array[T]]]
+
+ def newArray3(len: Int): Array[Array[Array[T]]] =
+ java.lang.reflect.Array.newInstance(arrayClass[Array[T]](arrayClass[T](erasure)), len)
+ .asInstanceOf[Array[Array[Array[T]]]]
+
+ def newArray4(len: Int): Array[Array[Array[Array[T]]]] =
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure))), len)
+ .asInstanceOf[Array[Array[Array[Array[T]]]]]
+
+ def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] =
+ java.lang.reflect.Array.newInstance(arrayClass[Array[Array[Array[T]]]](arrayClass[Array[Array[T]]](arrayClass[Array[T]](arrayClass[T](erasure)))), len)
+ .asInstanceOf[Array[Array[Array[Array[Array[T]]]]]]
+
+ def newWrappedArray(len: Int): WrappedArray[T] =
+ // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests
+ new WrappedArray.ofRef[T with AnyRef](newArray(len).asInstanceOf[Array[T with AnyRef]]).asInstanceOf[WrappedArray[T]]
+
+ def newArrayBuilder(): ArrayBuilder[T] =
+ // it's safe to assume T <: AnyRef here because the method is overridden for all value type manifests
+ new ArrayBuilder.ofRef[T with AnyRef]()(this.asInstanceOf[ClassManifest[T with AnyRef]]).asInstanceOf[ArrayBuilder[T]]
+
+ def typeArguments: List[OptManifest[_]] = List()
+
+ protected def argString =
+ if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]")
+ else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]"
+ else ""
+}
+
+/** The object `ClassManifest` defines factory methods for manifests.
+ * It is intended for use by the compiler and should not be used in client code.
+ */
+@deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
+object ClassManifest {
+ val Byte = Manifest.Byte
+ val Short = Manifest.Short
+ val Char = Manifest.Char
+ val Int = Manifest.Int
+ val Long = Manifest.Long
+ val Float = Manifest.Float
+ val Double = Manifest.Double
+ val Boolean = Manifest.Boolean
+ val Unit = Manifest.Unit
+ val Any = Manifest.Any
+ val Object = Manifest.Object
+ val AnyVal = Manifest.AnyVal
+ val Nothing = Manifest.Nothing
+ val Null = Manifest.Null
+
+ def fromClass[T](clazz: jClass[T]): ClassManifest[T] = clazz match {
+ case java.lang.Byte.TYPE => Byte.asInstanceOf[ClassManifest[T]]
+ case java.lang.Short.TYPE => Short.asInstanceOf[ClassManifest[T]]
+ case java.lang.Character.TYPE => Char.asInstanceOf[ClassManifest[T]]
+ case java.lang.Integer.TYPE => Int.asInstanceOf[ClassManifest[T]]
+ case java.lang.Long.TYPE => Long.asInstanceOf[ClassManifest[T]]
+ case java.lang.Float.TYPE => Float.asInstanceOf[ClassManifest[T]]
+ case java.lang.Double.TYPE => Double.asInstanceOf[ClassManifest[T]]
+ case java.lang.Boolean.TYPE => Boolean.asInstanceOf[ClassManifest[T]]
+ case java.lang.Void.TYPE => Unit.asInstanceOf[ClassManifest[T]]
+ case _ => classType[T with AnyRef](clazz).asInstanceOf[ClassManifest[T]]
+ }
+
+ def singleType[T <: AnyRef](value: AnyRef): Manifest[T] = Manifest.singleType(value)
+
+ /** ClassManifest for the class type `clazz`, where `clazz` is
+ * a top-level or static class.
+ * @note This no-prefix, no-arguments case is separate because we
+ * it's called from ScalaRunTime.boxArray itself. If we
+ * pass varargs as arrays into this, we get an infinitely recursive call
+ * to boxArray. (Besides, having a separate case is more efficient)
+ */
+ def classType[T <: AnyRef](clazz: jClass[_]): ClassManifest[T] =
+ new ClassTypeManifest[T](None, clazz, Nil)
+
+ /** ClassManifest for the class type `clazz[args]`, where `clazz` is
+ * a top-level or static class and `args` are its type arguments */
+ def classType[T <: AnyRef](clazz: jClass[_], arg1: OptManifest[_], args: OptManifest[_]*): ClassManifest[T] =
+ new ClassTypeManifest[T](None, clazz, arg1 :: args.toList)
+
+ /** ClassManifest for the class type `clazz[args]`, where `clazz` is
+ * a class with non-package prefix type `prefix` and type arguments `args`.
+ */
+ def classType[T <: AnyRef](prefix: OptManifest[_], clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] =
+ new ClassTypeManifest[T](Some(prefix), clazz, args.toList)
+
+ def arrayType[T](arg: OptManifest[_]): ClassManifest[Array[T]] = arg match {
+ case NoManifest => Object.asInstanceOf[ClassManifest[Array[T]]]
+ case m: ClassManifest[_] => m.asInstanceOf[ClassManifest[T]].arrayManifest
+ }
+
+ /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not
+ * strictly necessary as it could be obtained by reflection. It was
+ * added so that erasure can be calculated without reflection. */
+ def abstractType[T](prefix: OptManifest[_], name: String, clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] =
+ new ClassManifest[T] {
+ def erasure = clazz
+ override val typeArguments = args.toList
+ override def toString = prefix.toString+"#"+name+argString
+ }
+
+ /** ClassManifest for the abstract type `prefix # name`. `upperBound` is not
+ * strictly necessary as it could be obtained by reflection. It was
+ * added so that erasure can be calculated without reflection.
+ * todo: remove after next boostrap
+ */
+ def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] =
+ new ClassManifest[T] {
+ def erasure = upperbound.erasure
+ override val typeArguments = args.toList
+ override def toString = prefix.toString+"#"+name+argString
+ }
+}
+
+/** Manifest for the class type `clazz[args]`, where `clazz` is
+ * a top-level or static class */
+private class ClassTypeManifest[T <: AnyRef](
+ prefix: Option[OptManifest[_]],
+ val erasure: jClass[_],
+ override val typeArguments: List[OptManifest[_]]) extends ClassManifest[T]
+{
+ override def toString =
+ (if (prefix.isEmpty) "" else prefix.get.toString+"#") +
+ (if (erasure.isArray) "Array" else erasure.getName) +
+ argString
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala
index 142025f600..e485691747 100644
--- a/src/library/scala/reflect/ClassTag.scala
+++ b/src/library/scala/reflect/ClassTag.scala
@@ -3,6 +3,7 @@ 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.
*
@@ -18,34 +19,17 @@ import language.{implicitConversions, existentials}
* 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). */
-// 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
+ * (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]]
+ */
@annotation.implicitNotFound(msg = "No ClassTag available for ${T}")
-abstract case class ClassTag[T](erasure: jClass[_]) extends ArrayTag[T] {
- // quick and dirty fix to a deadlock in Predef:
- // http://groups.google.com/group/scala-internals/browse_thread/thread/977de028a4e75d6f
- // todo. fix that in a sane way
- // assert(erasure != null)
-
- /** A Scala reflection type representing T.
- * For ClassTags this representation is lossy (in their case tpe is retrospectively constructed from erasure).
- * For TypeTags and ConcreteTypeTags the representation is almost precise, because they use reification
- * (information is lost only when T refers to non-locatable symbols, which are then reified as free variables). */
- def tpe: rm.Type = rm.classToType(erasure)
-
- /** A Scala reflection symbol representing T. */
- def symbol: rm.Symbol = rm.classToSymbol(erasure)
+trait ClassTag[T] extends ArrayTag[T] with ErasureTag[T] with 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
/** Produces a `ClassTag` that knows how to build `Array[Array[T]]` */
- def wrap: ClassTag[Array[T]] = {
- // newInstance throws an exception if the erasure is Void.TYPE
- // see SI-5680
- val arrayClazz =
- if (erasure == java.lang.Void.TYPE) classOf[Array[Unit]]
- else java.lang.reflect.Array.newInstance(erasure, 0).getClass.asInstanceOf[jClass[Array[T]]]
- ClassTag[Array[T]](arrayClazz)
- }
+ def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(erasure))
/** Produces a new array with element type `T` and length `len` */
def newArray(len: Int): Array[T] =
@@ -61,31 +45,39 @@ abstract case class ClassTag[T](erasure: jClass[_]) extends ArrayTag[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 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 + "]"
}
object ClassTag {
+ private val NothingTYPE = classOf[scala.runtime.Nothing$]
+ private val NullTYPE = classOf[scala.runtime.Null$]
private val ObjectTYPE = classOf[java.lang.Object]
private val StringTYPE = classOf[java.lang.String]
- val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte](java.lang.Byte.TYPE) { private def readResolve() = ClassTag.Byte }
- val Short : ClassTag[scala.Short] = new ClassTag[scala.Short](java.lang.Short.TYPE) { private def readResolve() = ClassTag.Short }
- val Char : ClassTag[scala.Char] = new ClassTag[scala.Char](java.lang.Character.TYPE) { private def readResolve() = ClassTag.Char }
- val Int : ClassTag[scala.Int] = new ClassTag[scala.Int](java.lang.Integer.TYPE) { private def readResolve() = ClassTag.Int }
- val Long : ClassTag[scala.Long] = new ClassTag[scala.Long](java.lang.Long.TYPE) { private def readResolve() = ClassTag.Long }
- val Float : ClassTag[scala.Float] = new ClassTag[scala.Float](java.lang.Float.TYPE) { private def readResolve() = ClassTag.Float }
- val Double : ClassTag[scala.Double] = new ClassTag[scala.Double](java.lang.Double.TYPE) { private def readResolve() = ClassTag.Double }
- val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean](java.lang.Boolean.TYPE) { private def readResolve() = ClassTag.Boolean }
- val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit](java.lang.Void.TYPE) { private def readResolve() = ClassTag.Unit }
- val Any : ClassTag[scala.Any] = new ClassTag[scala.Any](ObjectTYPE) { private def readResolve() = ClassTag.Any }
- val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object](ObjectTYPE) { private def readResolve() = ClassTag.Object }
- val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal](ObjectTYPE) { private def readResolve() = ClassTag.AnyVal }
- val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef](ObjectTYPE) { private def readResolve() = ClassTag.AnyRef }
- val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing](ObjectTYPE) { private def readResolve() = ClassTag.Nothing }
- val Null : ClassTag[scala.Null] = new ClassTag[scala.Null](ObjectTYPE) { private def readResolve() = ClassTag.Null }
- val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String](StringTYPE) { private def readResolve() = ClassTag.String }
-
- def apply[T](clazz: jClass[_]): ClassTag[T] =
- clazz match {
+ 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 }
+
+ def apply[T](erasure1: jClass[_]): ClassTag[T] =
+ erasure1 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]]
@@ -97,128 +89,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](clazz) {}
- }
-
- def apply[T](tpe: rm.Type): ClassTag[T] =
- tpe match {
- case rm.ByteTpe => ClassTag.Byte.asInstanceOf[ClassTag[T]]
- case rm.ShortTpe => ClassTag.Short.asInstanceOf[ClassTag[T]]
- case rm.CharTpe => ClassTag.Char.asInstanceOf[ClassTag[T]]
- case rm.IntTpe => ClassTag.Int.asInstanceOf[ClassTag[T]]
- case rm.LongTpe => ClassTag.Long.asInstanceOf[ClassTag[T]]
- case rm.FloatTpe => ClassTag.Float.asInstanceOf[ClassTag[T]]
- case rm.DoubleTpe => ClassTag.Double.asInstanceOf[ClassTag[T]]
- case rm.BooleanTpe => ClassTag.Boolean.asInstanceOf[ClassTag[T]]
- case rm.UnitTpe => ClassTag.Unit.asInstanceOf[ClassTag[T]]
- case rm.AnyTpe => ClassTag.Any.asInstanceOf[ClassTag[T]]
- case rm.ObjectTpe => ClassTag.Object.asInstanceOf[ClassTag[T]]
- case rm.AnyValTpe => ClassTag.AnyVal.asInstanceOf[ClassTag[T]]
- case rm.AnyRefTpe => ClassTag.AnyRef.asInstanceOf[ClassTag[T]]
- case rm.NothingTpe => ClassTag.Nothing.asInstanceOf[ClassTag[T]]
- case rm.NullTpe => ClassTag.Null.asInstanceOf[ClassTag[T]]
- case rm.StringTpe => ClassTag.String.asInstanceOf[ClassTag[T]]
- case _ => apply[T](rm.typeToClass(tpe.erasure))
+ case _ => new ClassTag[T]{ def erasure = erasure1 }
}
- def apply[T](ttag: rm.ConcreteTypeTag[T]): ClassTag[T] =
- if (ttag.erasure != null) ClassTag[T](ttag.erasure)
- else ClassTag[T](ttag.tpe)
-
- implicit def toDeprecatedClassManifestApis[T](ctag: ClassTag[T]): DeprecatedClassManifestApis[T] = new DeprecatedClassManifestApis[T](ctag)
-
- @deprecated("Use apply instead", "2.10.0")
- def fromClass[T](clazz: jClass[T]): ClassManifest[T] = apply(clazz)
-
- /** Manifest for the singleton type `value.type'. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def singleType[T <: AnyRef](value: AnyRef): Manifest[T] = ???
-
- /** ClassManifest for the class type `clazz', where `clazz' is
- * a top-level or static class.
- * @note This no-prefix, no-arguments case is separate because we
- * it's called from ScalaRunTime.boxArray itself. If we
- * pass varargs as arrays into this, we get an infinitely recursive call
- * to boxArray. (Besides, having a separate case is more efficient)
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T <: AnyRef](clazz: jClass[_]): ClassManifest[T] = ClassTag[T](clazz)
-
- /** ClassManifest for the class type `clazz[args]', where `clazz' is
- * a top-level or static class and `args` are its type arguments */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T <: AnyRef](clazz: jClass[_], arg1: OptManifest[_], args: OptManifest[_]*): ClassManifest[T] = ClassTag[T](clazz)
-
- /** ClassManifest for the class type `clazz[args]', where `clazz' is
- * a class with non-package prefix type `prefix` and type arguments `args`.
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T <: AnyRef](prefix: OptManifest[_], clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = ClassTag[T](clazz)
-
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def arrayType[T](arg: OptManifest[_]): ClassManifest[Array[T]] = arg match {
- case x: ConcreteTypeTag[_] => ClassManifest[Array[T]](x.erasure)
- case _ => Object.asInstanceOf[ClassManifest[Array[T]]] // was there in 2.9.x
- }
-
- /** ClassManifest for the abstract type `prefix # name'. `upperBound' is not
- * strictly necessary as it could be obtained by reflection. It was
- * added so that erasure can be calculated without reflection. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def abstractType[T](prefix: OptManifest[_], name: String, clazz: jClass[_], args: OptManifest[_]*): ClassManifest[T] = ClassTag[T](clazz)
-
- /** ClassManifest for the abstract type `prefix # name'. `upperBound' is not
- * strictly necessary as it could be obtained by reflection. It was
- * added so that erasure can be calculated without reflection.
- * todo: remove after next boostrap
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def abstractType[T](prefix: OptManifest[_], name: String, upperbound: ClassManifest[_], args: OptManifest[_]*): ClassManifest[T] = ClassTag[T](upperbound.erasure)
-
- class DeprecatedClassManifestApis[T](ctag: ClassTag[T]) {
- import scala.collection.mutable.{ WrappedArray, ArrayBuilder }
-
- @deprecated("Use `tpe` to analyze the underlying type", "2.10.0")
- def <:<(that: ClassManifest[_]): Boolean = ctag.tpe <:< that.tpe
-
- @deprecated("Use `tpe` to analyze the underlying type", "2.10.0")
- def >:>(that: ClassManifest[_]): Boolean = that <:< ctag
-
- @deprecated("Use `wrap` instead", "2.10.0")
- def arrayManifest: ClassManifest[Array[T]] = ctag.wrap
-
- @deprecated("Use a combination of `wrap` and `newArray` instead", "2.10.0")
- def newArray2(len: Int): Array[Array[T]] = ctag.wrap.newArray(len)
-
- @deprecated("Use a combination of `wrap` and `newArray` instead", "2.10.0")
- def newArray3(len: Int): Array[Array[Array[T]]] = ctag.wrap.wrap.newArray(len)
-
- @deprecated("Use a combination of `wrap` and `newArray` instead", "2.10.0")
- def newArray4(len: Int): Array[Array[Array[Array[T]]]] = ctag.wrap.wrap.wrap.newArray(len)
-
- @deprecated("Use a combination of `wrap` and `newArray` instead", "2.10.0")
- def newArray5(len: Int): Array[Array[Array[Array[Array[T]]]]] = ctag.wrap.wrap.wrap.wrap.newArray(len)
-
- @deprecated("Use `@scala.collection.mutable.WrappedArray` object instead", "2.10.0")
- def newWrappedArray(len: Int): WrappedArray[T] =
- ctag.erasure match {
- case java.lang.Byte.TYPE => new WrappedArray.ofByte(new Array[Byte](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Short.TYPE => new WrappedArray.ofShort(new Array[Short](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Character.TYPE => new WrappedArray.ofChar(new Array[Char](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Integer.TYPE => new WrappedArray.ofInt(new Array[Int](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Long.TYPE => new WrappedArray.ofLong(new Array[Long](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Float.TYPE => new WrappedArray.ofFloat(new Array[Float](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Double.TYPE => new WrappedArray.ofDouble(new Array[Double](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Boolean.TYPE => new WrappedArray.ofBoolean(new Array[Boolean](len)).asInstanceOf[WrappedArray[T]]
- case java.lang.Void.TYPE => new WrappedArray.ofUnit(new Array[Unit](len)).asInstanceOf[WrappedArray[T]]
- case _ => new WrappedArray.ofRef[T with AnyRef](ctag.newArray(len).asInstanceOf[Array[T with AnyRef]]).asInstanceOf[WrappedArray[T]]
- }
-
- @deprecated("Use `@scala.collection.mutable.ArrayBuilder` object instead", "2.10.0")
- def newArrayBuilder(): ArrayBuilder[T] = ArrayBuilder.make[T]()(ctag)
-
- @deprecated("`typeArguments` is no longer supported, and will always return an empty list. Use `@scala.reflect.TypeTag` or `@scala.reflect.ConcreteTypeTag` to capture and analyze type arguments", "2.10.0")
- def typeArguments: List[OptManifest[_]] = List()
- }
-}
-
+ def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.erasure)
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/DummyMirror.scala b/src/library/scala/reflect/DummyMirror.scala
index 741ff33be2..f5b757fdba 100644
--- a/src/library/scala/reflect/DummyMirror.scala
+++ b/src/library/scala/reflect/DummyMirror.scala
@@ -5,9 +5,10 @@ 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 classfileAnnotArgManifest: scala.reflect.ClassManifest[ClassfileAnnotArg] = notSupported()
+ implicit def classfileAnnotArgTag: scala.reflect.ClassTag[ClassfileAnnotArg] = notSupported()
type AnnotationInfo = DummyAnnotationInfo.type
object DummyAnnotationInfo
val AnnotationInfo: AnnotationInfoExtractor = DummyAnnotationInfoExtractor
@@ -443,6 +444,8 @@ class DummyMirror(cl: ClassLoader) extends api.Mirror {
def fullName: String = notSupported()
def id: Int = notSupported()
def orElse[T](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()
@@ -528,6 +531,7 @@ class DummyMirror(cl: ClassLoader) extends api.Mirror {
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()
@@ -535,6 +539,14 @@ class DummyMirror(cl: ClassLoader) extends api.Mirror {
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
diff --git a/src/library/scala/reflect/ErasureTag.scala b/src/library/scala/reflect/ErasureTag.scala
new file mode 100644
index 0000000000..f95451fab2
--- /dev/null
+++ b/src/library/scala/reflect/ErasureTag.scala
@@ -0,0 +1,23 @@
+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
new file mode 100644
index 0000000000..da029f046d
--- /dev/null
+++ b/src/library/scala/reflect/Manifest.scala
@@ -0,0 +1,259 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+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
+ * is necessary for the creation of native `Arrays` if the class is not
+ * known at compile time.
+ *
+ * The type-relation operators `<:<` and `=:=` should be considered
+ * approximations only, as there are numerous aspects of type conformance
+ * which are not yet adequately represented in manifests.
+ *
+ * Example usages:
+{{{
+ def arr[T] = new Array[T](0) // does not compile
+ def arr[T](implicit m: Manifest[T]) = new Array[T](0) // compiles
+ def arr[T: Manifest] = new Array[T](0) // shorthand for the preceding
+
+ // Methods manifest, classManifest, and optManifest are in [[scala.Predef]].
+ def isApproxSubType[T: Manifest, U: Manifest] = manifest[T] <:< manifest[U]
+ isApproxSubType[List[String], List[AnyRef]] // true
+ isApproxSubType[List[String], List[Int]] // false
+
+ def methods[T: ClassManifest] = classManifest[T].erasure.getMethods
+ def retType[T: ClassManifest](name: String) =
+ methods[T] find (_.getName == name) map (_.getGenericReturnType)
+
+ retType[Map[_, _]]("values") // Some(scala.collection.Iterable<B>)
+}}}
+ *
+ */
+@annotation.implicitNotFound(msg = "No Manifest available for ${T}.")
+@deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
+trait Manifest[T] extends ClassManifest[T] with Equals {
+ override def typeArguments: List[Manifest[_]] = Nil
+
+ override def arrayManifest: Manifest[Array[T]] =
+ Manifest.classType[Array[T]](arrayClass[T](erasure), this)
+
+ override def canEqual(that: Any): Boolean = that match {
+ case _: Manifest[_] => true
+ case _ => false
+ }
+ /** Note: testing for erasure here is important, as it is many times
+ * faster than <:< and rules out most comparisons.
+ */
+ override def equals(that: Any): Boolean = that match {
+ case m: Manifest[_] => (m canEqual this) && (this.erasure == m.erasure) && (this <:< m) && (m <:< this)
+ case _ => false
+ }
+ override def hashCode = this.erasure.##
+}
+
+@deprecated("Use type tags and manually check the corresponding class or type instead", "2.10.0")
+abstract class AnyValManifest[T <: AnyVal](override val toString: String) extends Manifest[T] with Equals {
+ override def <:<(that: ClassManifest[_]): Boolean =
+ (that eq this) || (that eq Manifest.Any) || (that eq Manifest.AnyVal)
+ override def canEqual(other: Any) = other match {
+ case _: AnyValManifest[_] => true
+ case _ => false
+ }
+ override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef]
+ override val hashCode = System.identityHashCode(this)
+}
+
+/** The object `Manifest` defines factory methods for manifests.
+ * 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")
+object Manifest {
+ def valueManifests: List[AnyValManifest[_]] =
+ List(Byte, Short, Char, Int, Long, Float, Double, Boolean, Unit)
+
+ val Byte: AnyValManifest[Byte] = new AnyValManifest[scala.Byte]("Byte") {
+ def erasure = java.lang.Byte.TYPE
+ override def newArray(len: Int): Array[Byte] = new Array[Byte](len)
+ override def newWrappedArray(len: Int): WrappedArray[Byte] = new WrappedArray.ofByte(new Array[Byte](len))
+ override def newArrayBuilder(): ArrayBuilder[Byte] = new ArrayBuilder.ofByte()
+ private def readResolve(): Any = Manifest.Byte
+ }
+
+ val Short: AnyValManifest[Short] = new AnyValManifest[scala.Short]("Short") {
+ def erasure = java.lang.Short.TYPE
+ override def newArray(len: Int): Array[Short] = new Array[Short](len)
+ override def newWrappedArray(len: Int): WrappedArray[Short] = new WrappedArray.ofShort(new Array[Short](len))
+ override def newArrayBuilder(): ArrayBuilder[Short] = new ArrayBuilder.ofShort()
+ private def readResolve(): Any = Manifest.Short
+ }
+
+ val Char: AnyValManifest[Char] = new AnyValManifest[scala.Char]("Char") {
+ def erasure = java.lang.Character.TYPE
+ override def newArray(len: Int): Array[Char] = new Array[Char](len)
+ override def newWrappedArray(len: Int): WrappedArray[Char] = new WrappedArray.ofChar(new Array[Char](len))
+ override def newArrayBuilder(): ArrayBuilder[Char] = new ArrayBuilder.ofChar()
+ private def readResolve(): Any = Manifest.Char
+ }
+
+ val Int: AnyValManifest[Int] = new AnyValManifest[scala.Int]("Int") {
+ def erasure = java.lang.Integer.TYPE
+ override def newArray(len: Int): Array[Int] = new Array[Int](len)
+ override def newWrappedArray(len: Int): WrappedArray[Int] = new WrappedArray.ofInt(new Array[Int](len))
+ override def newArrayBuilder(): ArrayBuilder[Int] = new ArrayBuilder.ofInt()
+ private def readResolve(): Any = Manifest.Int
+ }
+
+ val Long: AnyValManifest[Long] = new AnyValManifest[scala.Long]("Long") {
+ def erasure = java.lang.Long.TYPE
+ override def newArray(len: Int): Array[Long] = new Array[Long](len)
+ override def newWrappedArray(len: Int): WrappedArray[Long] = new WrappedArray.ofLong(new Array[Long](len))
+ override def newArrayBuilder(): ArrayBuilder[Long] = new ArrayBuilder.ofLong()
+ private def readResolve(): Any = Manifest.Long
+ }
+
+ val Float: AnyValManifest[Float] = new AnyValManifest[scala.Float]("Float") {
+ def erasure = java.lang.Float.TYPE
+ override def newArray(len: Int): Array[Float] = new Array[Float](len)
+ override def newWrappedArray(len: Int): WrappedArray[Float] = new WrappedArray.ofFloat(new Array[Float](len))
+ override def newArrayBuilder(): ArrayBuilder[Float] = new ArrayBuilder.ofFloat()
+ private def readResolve(): Any = Manifest.Float
+ }
+
+ val Double: AnyValManifest[Double] = new AnyValManifest[scala.Double]("Double") {
+ def erasure = java.lang.Double.TYPE
+ override def newArray(len: Int): Array[Double] = new Array[Double](len)
+ override def newWrappedArray(len: Int): WrappedArray[Double] = new WrappedArray.ofDouble(new Array[Double](len))
+ override def newArrayBuilder(): ArrayBuilder[Double] = new ArrayBuilder.ofDouble()
+ private def readResolve(): Any = Manifest.Double
+ }
+
+ val Boolean: AnyValManifest[Boolean] = new AnyValManifest[scala.Boolean]("Boolean") {
+ def erasure = java.lang.Boolean.TYPE
+ override def newArray(len: Int): Array[Boolean] = new Array[Boolean](len)
+ override def newWrappedArray(len: Int): WrappedArray[Boolean] = new WrappedArray.ofBoolean(new Array[Boolean](len))
+ override def newArrayBuilder(): ArrayBuilder[Boolean] = new ArrayBuilder.ofBoolean()
+ private def readResolve(): Any = Manifest.Boolean
+ }
+
+ val Unit: AnyValManifest[Unit] = new AnyValManifest[scala.Unit]("Unit") {
+ def erasure = java.lang.Void.TYPE
+ override def newArray(len: Int): Array[Unit] = new Array[Unit](len)
+ override def newWrappedArray(len: Int): WrappedArray[Unit] = new WrappedArray.ofUnit(new Array[Unit](len))
+ override def newArrayBuilder(): ArrayBuilder[Unit] = new ArrayBuilder.ofUnit()
+ private def readResolve(): Any = Manifest.Unit
+ }
+
+ val Any: Manifest[scala.Any] = new PhantomManifest[scala.Any]("Any") {
+ override def <:<(that: ClassManifest[_]): Boolean = (that eq this)
+ private def readResolve(): Any = Manifest.Any
+ }
+
+ val Object: Manifest[java.lang.Object] = new PhantomManifest[java.lang.Object]("Object") {
+ override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any)
+ private def readResolve(): Any = Manifest.Object
+ }
+
+ val AnyVal: Manifest[scala.AnyVal] = new PhantomManifest[scala.AnyVal]("AnyVal") {
+ override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any)
+ private def readResolve(): Any = Manifest.AnyVal
+ }
+
+ val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null]("Null") {
+ override def <:<(that: ClassManifest[_]): Boolean =
+ (that ne null) && (that ne Nothing) && !(that <:< AnyVal)
+ private def readResolve(): Any = Manifest.Null
+ }
+
+ val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing]("Nothing") {
+ override def <:<(that: ClassManifest[_]): Boolean = (that ne null)
+ private def readResolve(): Any = Manifest.Nothing
+ }
+
+ private class SingletonTypeManifest[T <: AnyRef](value: AnyRef) extends Manifest[T] {
+ lazy val erasure = value.getClass
+ override lazy val toString = value.toString + ".type"
+ }
+
+ /** Manifest for the singleton type `value.type`. */
+ def singleType[T <: AnyRef](value: AnyRef): Manifest[T] =
+ new SingletonTypeManifest[T](value)
+
+ /** Manifest for the class type `clazz[args]`, where `clazz` is
+ * a top-level or static class.
+ * @note This no-prefix, no-arguments case is separate because we
+ * it's called from ScalaRunTime.boxArray itself. If we
+ * pass varargs as arrays into this, we get an infinitely recursive call
+ * to boxArray. (Besides, having a separate case is more efficient)
+ */
+ def classType[T](clazz: Predef.Class[_]): Manifest[T] =
+ new ClassTypeManifest[T](None, clazz, Nil)
+
+ /** Manifest for the class type `clazz`, where `clazz` is
+ * a top-level or static class and args are its type arguments. */
+ def classType[T](clazz: Predef.Class[T], arg1: Manifest[_], args: Manifest[_]*): Manifest[T] =
+ new ClassTypeManifest[T](None, clazz, arg1 :: args.toList)
+
+ /** Manifest for the class type `clazz[args]`, where `clazz` is
+ * a class with non-package prefix type `prefix` and type arguments `args`.
+ */
+ def classType[T](prefix: Manifest[_], clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] =
+ new ClassTypeManifest[T](Some(prefix), clazz, args.toList)
+
+ private abstract class PhantomManifest[T](override val toString: String) extends ClassTypeManifest[T](None, classOf[java.lang.Object], Nil) {
+ override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef]
+ override val hashCode = System.identityHashCode(this)
+ }
+
+ /** Manifest for the class type `clazz[args]`, where `clazz` is
+ * a top-level or static class. */
+ private class ClassTypeManifest[T](prefix: Option[Manifest[_]],
+ val erasure: Predef.Class[_],
+ override val typeArguments: List[Manifest[_]]) extends Manifest[T] {
+ override def toString =
+ (if (prefix.isEmpty) "" else prefix.get.toString+"#") +
+ (if (erasure.isArray) "Array" else erasure.getName) +
+ argString
+ }
+
+ def arrayType[T](arg: Manifest[_]): Manifest[Array[T]] =
+ arg.asInstanceOf[Manifest[T]].arrayManifest
+
+ /** Manifest for the abstract type `prefix # name'. `upperBound` is not
+ * strictly necessary as it could be obtained by reflection. It was
+ * added so that erasure can be calculated without reflection. */
+ def abstractType[T](prefix: Manifest[_], name: String, upperBound: Predef.Class[_], args: Manifest[_]*): Manifest[T] =
+ new Manifest[T] {
+ def erasure = upperBound
+ override val typeArguments = args.toList
+ override def toString = prefix.toString+"#"+name+argString
+ }
+
+ /** Manifest for the unknown type `_ >: L <: U` in an existential.
+ */
+ def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] =
+ new Manifest[T] {
+ def erasure = upperBound.erasure
+ override def toString =
+ "_" +
+ (if (lowerBound eq Nothing) "" else " >: "+lowerBound) +
+ (if (upperBound eq Nothing) "" else " <: "+upperBound)
+ }
+
+ /** Manifest for the intersection type `parents_0 with ... with parents_n'. */
+ def intersectionType[T](parents: Manifest[_]*): Manifest[T] =
+ new Manifest[T] {
+ def erasure = parents.head.erasure
+ override def toString = parents.mkString(" with ")
+ }
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/NoManifest.scala b/src/library/scala/reflect/NoManifest.scala
new file mode 100644
index 0000000000..7b8037272c
--- /dev/null
+++ b/src/library/scala/reflect/NoManifest.scala
@@ -0,0 +1,16 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.reflect
+
+/** One of the branches of an [[scala.reflect.OptManifest]].
+ */
+@deprecated("Use `@scala.reflect.TypeTag` instead", "2.10.0")
+object NoManifest extends OptManifest[Nothing] with Serializable {
+ override def toString = "<?>"
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/OptManifest.scala b/src/library/scala/reflect/OptManifest.scala
new file mode 100644
index 0000000000..46f23c4e22
--- /dev/null
+++ b/src/library/scala/reflect/OptManifest.scala
@@ -0,0 +1,18 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2007-2011, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.reflect
+
+/** A `OptManifest[T]` is an optional [[scala.reflect.Manifest]].
+ *
+ * It is either a `Manifest` or the value `NoManifest`.
+ *
+ * @author Martin Odersky
+ */
+@deprecated("Use `@scala.reflect.TypeTag` instead", "2.10.0")
+trait OptManifest[+T] extends Serializable \ No newline at end of file
diff --git a/src/library/scala/reflect/ReflectionUtils.scala b/src/library/scala/reflect/ReflectionUtils.scala
index 79a42f6ec4..6ea69cb80d 100644
--- a/src/library/scala/reflect/ReflectionUtils.scala
+++ b/src/library/scala/reflect/ReflectionUtils.scala
@@ -5,6 +5,7 @@
package scala.reflect
+import java.lang.{Class => jClass}
import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableException }
/** A few java-reflection oriented utility functions useful during reflection bootstrapping.
diff --git a/src/library/scala/reflect/TagInterop.scala b/src/library/scala/reflect/TagInterop.scala
new file mode 100644
index 0000000000..6c6bfcc2f2
--- /dev/null
+++ b/src/library/scala/reflect/TagInterop.scala
@@ -0,0 +1,34 @@
+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/TagMaterialization.scala b/src/library/scala/reflect/TagMaterialization.scala
deleted file mode 100644
index e8d4571228..0000000000
--- a/src/library/scala/reflect/TagMaterialization.scala
+++ /dev/null
@@ -1,122 +0,0 @@
-package scala.reflect
-
-import api.Universe
-import makro.Context
-import language.implicitConversions
-
-// todo. unfortunately, current type inferencer doesn't infer type parameters of implicit values
-// this means that during macro expansion these macros will get Nothing instead of real T
-// Oh how much I'd love to implement this now, but I have to postpone this until we have a solution for type inference
-
-/** This object is required by the compiler and <b>should not be used in client code</b>. */
-
- /** !!! Some of this code is copy-pasted four places. This situation
- * should be resolved ASAP.
- */
-object TagMaterialization {
- def materializeClassTag[T: c.TypeTag](c: Context): c.Expr[ClassTag[T]] = {
- import c.mirror._
- val tpe = implicitly[c.TypeTag[T]].tpe
- c.materializeClassTag(tpe)
- }
-
- def materializeTypeTag[T: c.TypeTag](c: Context { type PrefixType = Universe }): c.Expr[c.prefix.value.TypeTag[T]] = {
- import c.mirror._
- val tpe = implicitly[c.TypeTag[T]].tpe
- c.materializeTypeTag(tpe, requireConcreteTypeTag = false)
- }
-
- def materializeConcreteTypeTag[T: c.TypeTag](c: Context { type PrefixType = Universe }): c.Expr[c.prefix.value.ConcreteTypeTag[T]] = {
- import c.mirror._
- val tpe = implicitly[c.TypeTag[T]].tpe
- c.materializeTypeTag(tpe, requireConcreteTypeTag = true)
- }
-
- private implicit def context2utils(c0: Context) : Utils { val c: c0.type } = new { val c: c0.type = c0 } with Utils
-
- private 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"))
-
- val ReflectPackage = staticModule("scala.reflect.package")
- val Reflect_mirror = selectTerm(ReflectPackage, "mirror")
- val ClassTagClass = staticClass("scala.reflect.ClassTag")
- val ClassTagErasure = selectTerm(ClassTagClass, "erasure")
- val ClassTagModule = staticModule("scala.reflect.ClassTag")
- val TypeTagsClass = staticClass("scala.reflect.api.TypeTags")
- val TypeTagClass = selectType(TypeTagsClass, "TypeTag")
- val TypeTagTpe = selectTerm(TypeTagClass, "tpe")
- val TypeTagModule = selectTerm(TypeTagsClass, "TypeTag")
- val ConcreteTypeTagClass = selectType(TypeTagsClass, "ConcreteTypeTag")
- val ConcreteTypeTagModule = selectTerm(TypeTagsClass, "ConcreteTypeTag")
-
- def materializeClassTag(tpe: Type): Tree =
- materializeTag(c.reflectMirrorPrefix, tpe, ClassTagModule, c.reifyErasure(tpe))
-
- def materializeTypeTag(tpe: Type, requireConcreteTypeTag: Boolean): Tree = {
- def prefix: Tree = ??? // todo. needs to be synthesized from c.prefix
- val tagModule = if (requireConcreteTypeTag) ConcreteTypeTagModule else TypeTagModule
- materializeTag(prefix, tpe, tagModule, c.reifyType(prefix, tpe, dontSpliceAtTopLevel = true, requireConcreteTypeTag = requireConcreteTypeTag))
- }
-
- private def materializeTag(prefix: Tree, tpe: Type, tagModule: Symbol, materializer: => Tree): Tree = {
- val result =
- tpe match {
- case coreTpe if coreTags contains coreTpe =>
- Select(Select(prefix, tagModule.name), coreTags(coreTpe))
- case _ =>
- try materializer
- catch {
- case ex: Throwable =>
- // [Eugene] cannot pattern match on an abstract type, so had to do this
- val ex1 = ex
- if (ex.getClass.toString.endsWith("$ReificationError")) {
- ex match {
- case c.ReificationError(pos, msg) =>
- c.error(pos, msg)
- EmptyTree
- }
- } else if (ex.getClass.toString.endsWith("$UnexpectedReificationError")) {
- ex match {
- case c.UnexpectedReificationError(pos, err, cause) =>
- if (cause != null) throw cause else throw ex
- }
- } else {
- throw ex
- }
- }
- }
- try c.typeCheck(result)
- catch { case terr @ c.TypeError(pos, msg) => fail(terr) }
- }
-
- private def fail(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))
- }
- }
-}
diff --git a/src/library/scala/reflect/api/AnnotationInfos.scala b/src/library/scala/reflect/api/AnnotationInfos.scala
index 96a65606e5..cc1c4d2b6b 100755
--- a/src/library/scala/reflect/api/AnnotationInfos.scala
+++ b/src/library/scala/reflect/api/AnnotationInfos.scala
@@ -12,7 +12,7 @@ trait AnnotationInfos { self: Universe =>
}
type ClassfileAnnotArg <: AnyRef
- implicit def classfileAnnotArgManifest: ClassManifest[ClassfileAnnotArg] // need a precise manifest to pass to UnPickle's toArray call
+ implicit def classfileAnnotArgTag: ArrayTag[ClassfileAnnotArg] // need a precise tag to pass to UnPickle's toArray call
type LiteralAnnotArg <: ClassfileAnnotArg
val LiteralAnnotArg: LiteralAnnotArgExtractor
diff --git a/src/library/scala/reflect/api/Symbols.scala b/src/library/scala/reflect/api/Symbols.scala
index 767246a294..dbd264c0ab 100755
--- a/src/library/scala/reflect/api/Symbols.scala
+++ b/src/library/scala/reflect/api/Symbols.scala
@@ -148,6 +148,14 @@ trait Symbols { self: Universe =>
*/
def orElse[T](alt: => Symbol): Symbol
+ /** ...
+ */
+ def filter(cond: Symbol => Boolean): Symbol
+
+ /** ...
+ */
+ def suchThat(cond: Symbol => Boolean): Symbol
+
/**
* Set when symbol has a modifier of the form private[X], NoSymbol otherwise.
*
diff --git a/src/library/scala/reflect/api/TreeBuildUtil.scala b/src/library/scala/reflect/api/TreeBuildUtil.scala
index 4f510337c2..87790b3812 100644
--- a/src/library/scala/reflect/api/TreeBuildUtil.scala
+++ b/src/library/scala/reflect/api/TreeBuildUtil.scala
@@ -138,4 +138,22 @@ trait AbsTreeGen {
/** 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
index b90475b15a..c58b0fcec2 100644
--- a/src/library/scala/reflect/api/TypeTags.scala
+++ b/src/library/scala/reflect/api/TypeTags.scala
@@ -6,7 +6,6 @@
package scala.reflect
package api
-import scala.reflect.{ mirror => rm }
import java.lang.{ Class => jClass }
import language.implicitConversions
@@ -15,22 +14,41 @@ import language.implicitConversions
* 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.
*
- * Type tags are organized in a hierarchy of two classes:
+ * === 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]].
- * 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 type tag that is guaranteed not to contain any references to type parameters or abstract types.
*
- * It is also possible to capture Java classes by using a different kind of tag.
- * A [[scala.reflect.ClassTag]] value wraps a Java class, which can be accessed via the erasure method.
+ * 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.
*
- * 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]].
+ * 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]].
*
- * Implicit in the contract for all Tag classes is that the reified type tpe represents the type parameter T.
- * Tags are typically created by the compiler, which makes sure that this contract is kept.
+ * 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._
@@ -44,6 +62,54 @@ import language.implicitConversions
* 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 =>
@@ -56,25 +122,20 @@ trait TypeTags { self: Universe =>
* @see [[scala.reflect.api.TypeTags]]
*/
@annotation.implicitNotFound(msg = "No TypeTag available for ${T}")
- abstract case class TypeTag[T](tpe: Type) {
- // it's unsafe to use assert here, because we might run into deadlocks with Predef
- // also see comments in ClassTags.scala
- // assert(tpe != null)
-
- def sym = tpe.typeSymbol
- def isConcrete = tpe.isConcrete
- def notConcrete = !isConcrete
- def toConcrete: ConcreteTypeTag[T] = ConcreteTypeTag[T](tpe)
-
- override def toString = {
- if (!self.isInstanceOf[DummyMirror]) {
- var prefix = if (isConcrete) "ConcreteTypeTag" else "TypeTag"
- if (prefix != this.productPrefix) prefix = "*" + prefix
- prefix + "[" + tpe + "]"
- } else {
- this.productPrefix + "[?]"
- }
- }
+ 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 {
@@ -95,8 +156,10 @@ trait TypeTags { self: Universe =>
val Null : TypeTag[scala.Null] = ConcreteTypeTag.Null
val String : TypeTag[java.lang.String] = ConcreteTypeTag.String
- def apply[T](tpe: Type): TypeTag[T] =
- tpe match {
+ // 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]]
@@ -113,8 +176,10 @@ trait TypeTags { self: Universe =>
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](tpe) {}
+ case _ => new TypeTag[T]{ def tpe = tpe1; def erasure = erasure1 }
}
+
+ def unapply[T](ttag: TypeTag[T]): Option[Type] = Some(ttag.tpe)
}
/**
@@ -124,36 +189,40 @@ trait TypeTags { self: Universe =>
* @see [[scala.reflect.api.TypeTags]]
*/
@annotation.implicitNotFound(msg = "No ConcreteTypeTag available for ${T}")
- abstract class ConcreteTypeTag[T](tpe: Type, val erasure: jClass[_]) extends TypeTag[T](tpe) {
+ trait ConcreteTypeTag[T] extends TypeTag[T] with ClassTag[T] with Equals with Serializable {
if (!self.isInstanceOf[DummyMirror]) {
-// it's unsafe to use assert here, because we might run into deadlocks with Predef
-// also see comments in ClassTags.scala
-// assert(isConcrete, tpe)
if (notConcrete) throw new Error("%s (%s) is not concrete and cannot be used to construct a concrete type tag".format(tpe, tpe.kind))
}
- override def productPrefix = "ConcreteTypeTag"
+
+ /** 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](ByteTpe, ClassTag.Byte.erasure) { private def readResolve() = ConcreteTypeTag.Byte }
- val Short : ConcreteTypeTag[scala.Short] = new ConcreteTypeTag[scala.Short](ShortTpe, ClassTag.Short.erasure) { private def readResolve() = ConcreteTypeTag.Short }
- val Char : ConcreteTypeTag[scala.Char] = new ConcreteTypeTag[scala.Char](CharTpe, ClassTag.Char.erasure) { private def readResolve() = ConcreteTypeTag.Char }
- val Int : ConcreteTypeTag[scala.Int] = new ConcreteTypeTag[scala.Int](IntTpe, ClassTag.Int.erasure) { private def readResolve() = ConcreteTypeTag.Int }
- val Long : ConcreteTypeTag[scala.Long] = new ConcreteTypeTag[scala.Long](LongTpe, ClassTag.Long.erasure) { private def readResolve() = ConcreteTypeTag.Long }
- val Float : ConcreteTypeTag[scala.Float] = new ConcreteTypeTag[scala.Float](FloatTpe, ClassTag.Float.erasure) { private def readResolve() = ConcreteTypeTag.Float }
- val Double : ConcreteTypeTag[scala.Double] = new ConcreteTypeTag[scala.Double](DoubleTpe, ClassTag.Double.erasure) { private def readResolve() = ConcreteTypeTag.Double }
- val Boolean : ConcreteTypeTag[scala.Boolean] = new ConcreteTypeTag[scala.Boolean](BooleanTpe, ClassTag.Boolean.erasure) { private def readResolve() = ConcreteTypeTag.Boolean }
- val Unit : ConcreteTypeTag[scala.Unit] = new ConcreteTypeTag[scala.Unit](UnitTpe, ClassTag.Unit.erasure) { private def readResolve() = ConcreteTypeTag.Unit }
- val Any : ConcreteTypeTag[scala.Any] = new ConcreteTypeTag[scala.Any](AnyTpe, ClassTag.Any.erasure) { private def readResolve() = ConcreteTypeTag.Any }
- val Object : ConcreteTypeTag[java.lang.Object] = new ConcreteTypeTag[java.lang.Object](ObjectTpe, ClassTag.Object.erasure) { private def readResolve() = ConcreteTypeTag.Object }
- val AnyVal : ConcreteTypeTag[scala.AnyVal] = new ConcreteTypeTag[scala.AnyVal](AnyValTpe, ClassTag.AnyVal.erasure) { private def readResolve() = ConcreteTypeTag.AnyVal }
- val AnyRef : ConcreteTypeTag[scala.AnyRef] = new ConcreteTypeTag[scala.AnyRef](AnyRefTpe, ClassTag.AnyRef.erasure) { private def readResolve() = ConcreteTypeTag.AnyRef }
- val Nothing : ConcreteTypeTag[scala.Nothing] = new ConcreteTypeTag[scala.Nothing](NothingTpe, ClassTag.Nothing.erasure) { private def readResolve() = ConcreteTypeTag.Nothing }
- val Null : ConcreteTypeTag[scala.Null] = new ConcreteTypeTag[scala.Null](NullTpe, ClassTag.Null.erasure) { private def readResolve() = ConcreteTypeTag.Null }
- val String : ConcreteTypeTag[java.lang.String] = new ConcreteTypeTag[java.lang.String](StringTpe, ClassTag.String.erasure) { private def readResolve() = ConcreteTypeTag.String }
-
- def apply[T](tpe: Type, erasure: jClass[_] = null): ConcreteTypeTag[T] =
- tpe match {
+ 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]]
@@ -170,69 +239,10 @@ trait TypeTags { self: Universe =>
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](tpe, erasure) {}
+ 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
-
- implicit def toClassTag[T](ttag: rm.ConcreteTypeTag[T]): ClassTag[T] = ClassTag[T](ttag)
-
- implicit def toDeprecatedManifestApis[T](ttag: rm.ConcreteTypeTag[T]): DeprecatedManifestApis[T] = new DeprecatedManifestApis[T](ttag)
-
- // this class should not be used directly in client code
- class DeprecatedManifestApis[T](ttag: rm.ConcreteTypeTag[T]) extends ClassTag.DeprecatedClassManifestApis[T](toClassTag(ttag)) {
- @deprecated("Use `tpe` to analyze the underlying type", "2.10.0")
- def <:<(that: Manifest[_]): Boolean = ttag.tpe <:< that.tpe
-
- @deprecated("Use `tpe` to analyze the underlying type", "2.10.0")
- def >:>(that: Manifest[_]): Boolean = that <:< ttag
-
- @deprecated("Use `tpe` to analyze the type arguments", "2.10.0")
- override def typeArguments: List[Manifest[_]] = ttag.tpe.typeArguments map (targ => rm.ConcreteTypeTag(targ))
- }
-
- /** Manifest for the singleton type `value.type'. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def singleType[T <: AnyRef](value: AnyRef): Manifest[T] = Manifest[T](???, value.getClass)
-
- /** Manifest for the class type `clazz[args]', where `clazz' is
- * a top-level or static class.
- * @note This no-prefix, no-arguments case is separate because we
- * it's called from ScalaRunTime.boxArray itself. If we
- * pass varargs as arrays into this, we get an infinitely recursive call
- * to boxArray. (Besides, having a separate case is more efficient)
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T](clazz: Predef.Class[_]): Manifest[T] = Manifest[T](???, clazz)
-
- /** Manifest for the class type `clazz', where `clazz' is
- * a top-level or static class and args are its type arguments. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T](clazz: Predef.Class[T], arg1: Manifest[_], args: Manifest[_]*): Manifest[T] = Manifest[T](???, clazz)
-
- /** Manifest for the class type `clazz[args]', where `clazz' is
- * a class with non-package prefix type `prefix` and type arguments `args`.
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def classType[T](prefix: Manifest[_], clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = Manifest[T](???, clazz)
-
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def arrayType[T](arg: Manifest[_]): Manifest[Array[T]] = Manifest[Array[T]](???, arg.asInstanceOf[Manifest[T]].arrayManifest.erasure)
-
- /** Manifest for the abstract type `prefix # name'. `upperBound' is not
- * strictly necessary as it could be obtained by reflection. It was
- * added so that erasure can be calculated without reflection. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def abstractType[T](prefix: Manifest[_], name: String, clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = Manifest[T](???, clazz)
-
- /** Manifest for the unknown type `_ >: L <: U' in an existential.
- */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def wildcardType[T](lowerBound: Manifest[_], upperBound: Manifest[_]): Manifest[T] = Manifest[T](???, upperBound.erasure)
-
- /** Manifest for the intersection type `parents_0 with ... with parents_n'. */
- @deprecated("Manifests aka type tags now support arbitrary types. Build a manifest directly from the type instead", "2.10.0")
- def intersectionType[T](parents: Manifest[_]*): Manifest[T] = Manifest[T](???, parents.head.erasure)
}
// incantations for summoning
diff --git a/src/library/scala/reflect/api/Universe.scala b/src/library/scala/reflect/api/Universe.scala
index 2b22839d39..2a7445c41c 100755
--- a/src/library/scala/reflect/api/Universe.scala
+++ b/src/library/scala/reflect/api/Universe.scala
@@ -1,5 +1,6 @@
package scala.reflect
package api
+
import language.experimental.macros
abstract class Universe extends Symbols
@@ -65,25 +66,7 @@ abstract class Universe extends Symbols
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 cc.mirror._
- try cc.reifyTree(cc.prefix, expr)
- catch {
- case ex: Throwable =>
- // [Eugene] cannot pattern match on an abstract type, so had to do this
- val ex1 = ex
- if (ex.getClass.toString.endsWith("$ReificationError")) {
- ex match {
- case cc.ReificationError(pos, msg) =>
- cc.error(pos, msg)
- EmptyTree
- }
- } else if (ex.getClass.toString.endsWith("$UnexpectedReificationError")) {
- ex match {
- case cc.UnexpectedReificationError(pos, err, cause) =>
- if (cause != null) throw cause else throw ex
- }
- } else {
- throw ex
- }
- }
+ import scala.reflect.makro.internal._
+ cc.materializeExpr(cc.prefix, expr)
}
}
diff --git a/src/library/scala/reflect/makro/Context.scala b/src/library/scala/reflect/makro/Context.scala
index b304d98a5a..668d239087 100644
--- a/src/library/scala/reflect/makro/Context.scala
+++ b/src/library/scala/reflect/makro/Context.scala
@@ -34,28 +34,11 @@ trait Context extends Aliases
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, newTermName("mirror"))
val prefixTpe = cc.typeCheck(TypeApply(Select(prefix, newTermName("asInstanceOf")), List(SingletonTypeTree(prefix)))).tpe
prefix setType prefixTpe
- try cc.reifyTree(prefix, expr)
- catch {
- case ex: Throwable =>
- // [Eugene] cannot pattern match on an abstract type, so had to do this
- if (ex.getClass.toString.endsWith("$ReificationError")) {
- ex match {
- case cc.ReificationError(pos, msg) =>
- cc.error(pos, msg)
- EmptyTree
- }
- } else if (ex.getClass.toString.endsWith("$UnexpectedReificationError")) {
- ex match {
- case cc.UnexpectedReificationError(pos, err, cause) =>
- if (cause != null) throw cause else throw ex
- }
- } else {
- throw ex
- }
- }
+ cc.materializeExpr(prefix, expr)
}
}
diff --git a/src/library/scala/reflect/makro/Reifiers.scala b/src/library/scala/reflect/makro/Reifiers.scala
index b9e82e0387..ae6669946c 100644
--- a/src/library/scala/reflect/makro/Reifiers.scala
+++ b/src/library/scala/reflect/makro/Reifiers.scala
@@ -46,11 +46,12 @@ trait Reifiers {
* The produced tree will be bound to the mirror specified by ``prefix'' (also see ``reflectMirrorPrefix'').
* For more information and examples see the documentation for ``Context.reifyTree'' and ``Universe.reify''.
*/
- def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, requireConcreteTypeTag: Boolean = false): Tree
+ def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): 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).
*/
- def reifyErasure(tpe: Type): Tree
+ def reifyErasure(tpe: Type, concrete: Boolean = true): Tree
/** Undoes reification of a tree.
*
@@ -67,20 +68,10 @@ trait Reifiers {
* 3) compileAndEval(unreifyTree(reifyTree(tree))) ~ compileAndEval(tree) // at runtime original and unreified trees are behaviorally equivalent
*/
def unreifyTree(tree: Tree): Tree
+}
- /** Represents an error during reification
- */
- type ReificationError <: Throwable
- val ReificationError: ReificationErrorExtractor
- abstract class ReificationErrorExtractor {
- def unapply(error: ReificationError): Option[(Position, String)]
- }
+// made these guys non path-dependent, otherwise exception handling quickly becomes a mess
- /** Wraps an unexpected error during reification
- */
- type UnexpectedReificationError <: Throwable
- val UnexpectedReificationError: UnexpectedReificationErrorExtractor
- abstract class UnexpectedReificationErrorExtractor {
- def unapply(error: UnexpectedReificationError): Option[(Position, String, Throwable)]
- }
-}
+case class ReificationError(var pos: reflect.api.Position, val msg: String) extends Throwable(msg)
+
+case class UnexpectedReificationError(val pos: reflect.api.Position, val msg: String, val cause: Throwable = null) extends Throwable(msg) \ 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
index 604bba10b6..3af58e1c88 100644
--- a/src/library/scala/reflect/makro/internal/Utils.scala
+++ b/src/library/scala/reflect/makro/internal/Utils.scala
@@ -7,6 +7,20 @@ 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>. */
@@ -18,14 +32,14 @@ package object internal {
/** 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, requireConcreteTypeTag = false))(c.TypeTag.Nothing)
+ 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, requireConcreteTypeTag = true))(c.TypeTag.Nothing)
+ 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
@@ -53,14 +67,27 @@ package internal {
AnyValClass.asType -> newTermName("AnyVal"),
AnyRefClass.asType -> newTermName("AnyRef"),
NothingClass.asType -> newTermName("Nothing"),
- NullClass.asType -> newTermName("Null"))
+ 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, c.reifyErasure(tpe))
+ 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, requireConcreteTypeTag: Boolean): Tree = {
- val tagModule = if (requireConcreteTypeTag) ConcreteTypeTagModule else TypeTagModule
- materializeTag(prefix, tpe, tagModule, c.reifyType(prefix, tpe, dontSpliceAtTopLevel = true, requireConcreteTypeTag = requireConcreteTypeTag))
+ 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 = {
@@ -70,32 +97,40 @@ package internal {
val ref = if (tagModule.owner.isPackageClass) Ident(tagModule) else Select(prefix, tagModule.name)
Select(ref, coreTags(coreTpe))
case _ =>
- try materializer
- catch {
- case ex: Throwable =>
- // [Eugene] cannot pattern match on an abstract type, so had to do this
- val ex1 = ex
- if (ex.getClass.toString.endsWith("$ReificationError")) {
- ex match {
- case c.ReificationError(pos, msg) =>
- c.error(pos, msg)
- EmptyTree
- }
- } else if (ex.getClass.toString.endsWith("$UnexpectedReificationError")) {
- ex match {
- case c.UnexpectedReificationError(pos, err, cause) =>
- if (cause != null) throw cause else throw ex
- }
- } else {
- throw ex
- }
- }
+ 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) => fail(terr) }
+ 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
}
- private def fail(reason: Any): Nothing = {
+ 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
@@ -104,5 +139,8 @@ package internal {
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/package.scala b/src/library/scala/reflect/package.scala
index 0958f2ce9a..38a144cd49 100644
--- a/src/library/scala/reflect/package.scala
+++ b/src/library/scala/reflect/package.scala
@@ -53,20 +53,9 @@ package object reflect {
@deprecated("Use `@scala.beans.ScalaBeanInfo` instead", "2.10.0")
type ScalaBeanInfo = scala.beans.ScalaBeanInfo
- @deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
- type ClassManifest[T] = ClassTag[T]
- @deprecated("OptManifest is no longer supported, and using it may lead to incorrect results, Use `@scala.reflect.TypeTag` instead", "2.10.0")
- type OptManifest[T] = TypeTag[T]
- @deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
- type Manifest[T] = ConcreteTypeTag[T]
-
- @deprecated("Use `@scala.reflect.ClassTag` instead", "2.10.0")
- val ClassManifest = ClassTag
- @deprecated("Use `@scala.reflect.ConcreteTypeTag` instead", "2.10.0")
- lazy val Manifest = ConcreteTypeTag
- @deprecated("NoManifest is no longer supported, and using it may lead to incorrect results, Use `@scala.reflect.TypeTag` instead", "2.10.0")
- object NoManifest extends OptManifest[Nothing](scala.reflect.mirror.TypeTag.Nothing.tpe)
-
+ // 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]
@@ -74,4 +63,8 @@ package object reflect {
// 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 d2adc26d66..9d67644d61 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -47,12 +47,29 @@ object ScalaRunTime {
names.toSet
}
+ /** Return the class object representing an array with element class `clazz`.
+ */
+ def arrayClass(clazz: Class[_]): Class[_] = {
+ // newInstance throws an exception if the erasure is Void.TYPE. see SI-5680
+ if (clazz == java.lang.Void.TYPE) classOf[Array[Unit]]
+ else java.lang.reflect.Array.newInstance(clazz, 0).getClass
+ }
+
+ /** Return the class object representing elements in arrays described by a given schematic.
+ */
+ 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 _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass))
+ }
+
/** Return the class object representing an unboxed value type,
* e.g. classOf[int], not classOf[java.lang.Integer]. The compiler
* rewrites expressions like 5.getClass to come here.
*/
- def anyValClass[T <: AnyVal : ClassManifest](value: T): Class[T] =
- classManifest[T].erasure.asInstanceOf[Class[T]]
+ def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] =
+ classTag[T].erasure.asInstanceOf[Class[T]]
/** Retrieve generic array element */
def array_apply(xs: AnyRef, idx: Int): Any = xs match {
diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala
index c2269cde45..e2ebe7851c 100644
--- a/src/library/scala/util/Marshal.scala
+++ b/src/library/scala/util/Marshal.scala
@@ -11,19 +11,19 @@
package scala.util
/**
- * Marshalling of Scala objects using Scala manifests.
+ * Marshalling of Scala objects using Scala tags.
*
* @author Stephane Micheloud
* @version 1.0
*/
object Marshal {
import java.io._
- import scala.reflect.ClassManifest
+ import scala.reflect.ClassTag
- def dump[A](o: A)(implicit m: ClassManifest[A]): Array[Byte] = {
+ def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
val ba = new ByteArrayOutputStream(512)
val out = new ObjectOutputStream(ba)
- out.writeObject(m)
+ out.writeObject(t)
out.writeObject(o)
out.close()
ba.toByteArray()
@@ -32,20 +32,20 @@ object Marshal {
@throws(classOf[IOException])
@throws(classOf[ClassCastException])
@throws(classOf[ClassNotFoundException])
- def load[A](buffer: Array[Byte])(implicit expected: ClassManifest[A]): A = {
+ def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
- val found = in.readObject.asInstanceOf[ClassManifest[_]]
- // todo. [Eugene] needs review, since ClassManifests no longer capture typeArguments
- if (found.tpe <:< expected.tpe) {
- val o = in.readObject.asInstanceOf[A]
- in.close()
- o
- } else {
- in.close()
- throw new ClassCastException("type mismatch;"+
- "\n found : "+found+
- "\n required: "+expected)
+ val found = in.readObject.asInstanceOf[ClassTag[_]]
+ try {
+ // [Eugene] needs review
+ // previously was: found <:< expected
+ found.erasure.asSubclass(expected.erasure)
+ in.readObject.asInstanceOf[A]
+ } catch {
+ case _: ClassCastException =>
+ in.close()
+ throw new ClassCastException("type mismatch;"+
+ "\n found : "+found+
+ "\n required: "+expected)
}
}
-
}
diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala
index bf460a118f..7d98e57741 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.ClassManifest
+import scala.reflect.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: ClassManifest: Ordering](a: Array[K]) {
+ def stableSort[K: ArrayTag: 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: ClassManifest](a: Array[K], f: (K, K) => Boolean) {
+ def stableSort[K: ArrayTag](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: ClassManifest](a: Seq[K], f: (K, K) => Boolean): Array[K] = {
+ def stableSort[K: ArrayTag](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: ClassManifest: Ordering](a: Seq[K]): Array[K] =
+ def stableSort[K: ArrayTag: 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: ClassManifest, M: Ordering](a: Seq[K], f: K => M): Array[K] =
- stableSort(a)(implicitly[ClassManifest[K]], Ordering[M] on f)
+ def stableSort[K: ArrayTag, M: Ordering](a: Seq[K], f: K => M): Array[K] =
+ stableSort(a)(implicitly[ArrayTag[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 : ClassManifest](a: Array[K], lo: Int, hi: Int, scratch: Array[K], f: (K,K) => Boolean) {
+ private def stableSort[K : ArrayTag](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 1cae8088f5..38f4abb20a 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -30,9 +30,9 @@ import language.implicitConversions
object Exception {
type Catcher[+T] = PartialFunction[Throwable, T]
- def mkCatcher[Ex <: Throwable: ClassManifest, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] {
+ def mkCatcher[Ex <: Throwable: ClassTag, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] {
private def downcast(x: Throwable): Option[Ex] =
- if (classManifest[Ex].erasure.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex])
+ if (classTag[Ex].erasure.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex])
else None
def isDefinedAt(x: Throwable) = downcast(x) exists isDef
@@ -41,7 +41,7 @@ object Exception {
def mkThrowableCatcher[T](isDef: Throwable => Boolean, f: Throwable => T) = mkCatcher(isDef, f)
- implicit def throwableSubtypeToCatcher[Ex <: Throwable: ClassManifest, T](pf: PartialFunction[Ex, T]) =
+ implicit def throwableSubtypeToCatcher[Ex <: Throwable: ClassTag, T](pf: PartialFunction[Ex, T]) =
mkCatcher(pf.isDefinedAt _, pf.apply _)
/** !!! Not at all sure of every factor which goes into this,
diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala
index aaea4416dd..86678760be 100644
--- a/src/partest/scala/tools/partest/CompilerTest.scala
+++ b/src/partest/scala/tools/partest/CompilerTest.scala
@@ -5,6 +5,7 @@
package scala.tools.partest
+import scala.reflect.{mirror => rm}
import scala.tools.nsc._
/** For testing compiler internals directly.
@@ -29,13 +30,13 @@ abstract class CompilerTest extends DirectTest {
// Override at least one of these...
def code = ""
def sources: List[String] = List(code)
-
+
// Utility functions
-
+
class MkType(sym: Symbol) {
- def apply[M](implicit m1: Manifest[M]): Type =
+ def apply[M](implicit t: rm.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
- else appliedType(sym, manifestToType(m1))
+ else appliedType(sym, compilerTypeFromTag(t))
}
implicit def mkMkType(sym: Symbol) = new MkType(sym)
@@ -47,7 +48,7 @@ abstract class CompilerTest extends DirectTest {
}
loop(Set(), List(root))
}
-
+
class SymsInPackage(pkgName: String) {
def pkg = getRequiredModule(pkgName)
def classes = allMembers(pkg) filter (_.isClass)
diff --git a/src/partest/scala/tools/partest/SigTest.scala b/src/partest/scala/tools/partest/SigTest.scala
index 072ec006f9..999d901d21 100644
--- a/src/partest/scala/tools/partest/SigTest.scala
+++ b/src/partest/scala/tools/partest/SigTest.scala
@@ -20,31 +20,31 @@ trait SigTest {
def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name)
- def fields[T: ClassManifest](p: JField => Boolean) = {
- val cl = classManifest[T].erasure
+ def fields[T: ClassTag](p: JField => Boolean) = {
+ val cl = classTag[T].erasure
val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName)
fs filter p
}
- def methods[T: ClassManifest](p: JMethod => Boolean) = {
- val cl = classManifest[T].erasure
+ def methods[T: ClassTag](p: JMethod => Boolean) = {
+ val cl = classTag[T].erasure
val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge))
ms filter p
}
- def allFields[T: ClassManifest]() = fields[T](_ => true)
- def allMethods[T: ClassManifest]() = methods[T](m => !isObjectMethodName(m.getName))
- def fieldsNamed[T: ClassManifest](name: String) = fields[T](_.getName == name)
- def methodsNamed[T: ClassManifest](name: String) = methods[T](_.getName == name)
+ def allFields[T: ClassTag]() = fields[T](_ => true)
+ def allMethods[T: ClassTag]() = methods[T](m => !isObjectMethodName(m.getName))
+ def fieldsNamed[T: ClassTag](name: String) = fields[T](_.getName == name)
+ def methodsNamed[T: ClassTag](name: String) = methods[T](_.getName == name)
- def allGenericStrings[T: ClassManifest]() =
+ def allGenericStrings[T: ClassTag]() =
(allMethods[T]() map mstr) ++ (allFields[T]() map fstr)
- def genericStrings[T: ClassManifest](name: String) =
+ def genericStrings[T: ClassTag](name: String) =
(methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr)
- def show[T: ClassManifest](name: String = "") = {
- println(classManifest[T].erasure.getName)
+ def show[T: ClassTag](name: String = "") = {
+ println(classTag[T].erasure.getName)
if (name == "") allGenericStrings[T]() foreach println
else genericStrings[T](name) foreach println
}
diff --git a/src/scalacheck/org/scalacheck/Arbitrary.scala b/src/scalacheck/org/scalacheck/Arbitrary.scala
index 91d56b0aec..9bb235f917 100644
--- a/src/scalacheck/org/scalacheck/Arbitrary.scala
+++ b/src/scalacheck/org/scalacheck/Arbitrary.scala
@@ -263,7 +263,7 @@ object Arbitrary {
): Arbitrary[C[T]] = Arbitrary(containerOf[C,T](arbitrary[T]))
/** Arbitrary instance of any array. */
- implicit def arbArray[T](implicit a: Arbitrary[T], c: ClassManifest[T]
+ implicit def arbArray[T](implicit a: Arbitrary[T], c: ClassTag[T]
): Arbitrary[Array[T]] = Arbitrary(containerOf[Array,T](arbitrary[T]))
diff --git a/src/scalacheck/org/scalacheck/util/Buildable.scala b/src/scalacheck/org/scalacheck/util/Buildable.scala
index 6378e72d4f..662bc6146b 100644
--- a/src/scalacheck/org/scalacheck/util/Buildable.scala
+++ b/src/scalacheck/org/scalacheck/util/Buildable.scala
@@ -30,7 +30,7 @@ object Buildable {
def builder = (new mutable.ListBuffer[T]).mapResult(_.toStream)
}
- implicit def buildableArray[T](implicit cm: ClassManifest[T]) =
+ implicit def buildableArray[T](implicit t: ClassTag[T]) =
new Buildable[T,Array] {
def builder = mutable.ArrayBuilder.make[T]
}
diff --git a/src/swing/scala/swing/Font.scala.disabled b/src/swing/scala/swing/Font.scala.disabled
index 6eebd667bd..9e21eb859c 100644
--- a/src/swing/scala/swing/Font.scala.disabled
+++ b/src/swing/scala/swing/Font.scala.disabled
@@ -1,36 +1,36 @@
package scala.swing
-/*object Font {
- def apply(fontFormat: Int, fontFile: java.io.File) = java.awt.Font.createFont(fontFormat, fontFile)
- def apply(fontFormat: Int, fontStream: java.io.InputStream) = java.awt.Font.createFont(fontFormat, fontStream)
+/*object Font {
+ def apply(fontFormat: Int, fontFile: java.io.File) = java.awt.Font.createFont(fontFormat, fontFile)
+ def apply(fontFormat: Int, fontStream: java.io.InputStream) = java.awt.Font.createFont(fontFormat, fontStream)
def decode(str: String) = java.awt.Font.decode(str)
-
+
/* TODO: finish implementation
/**
* See [java.awt.Font.getFont].
*/
- def get(attributes: Map[_ <: java.text.AttributedCharacterIterator.Attribute, _]) =
+ def get(attributes: Map[_ <: java.text.AttributedCharacterIterator.Attribute, _]) =
java.awt.Font.getFont(ImmutableMapWrapper(attributes))
-
+
import java.{util => ju}
- private case class ImmutableMapWrapper[A, B](underlying : Map[A, B])(m : ClassManifest[A]) extends ju.AbstractMap[A, B] {
+ private case class ImmutableMapWrapper[A, B](underlying : Map[A, B])(t : ClassTag[A]) extends ju.AbstractMap[A, B] {
self =>
override def size = underlying.size
- override def put(k : A, v : B) =
+ override def put(k : A, v : B) =
throw new UnsupportedOperationException("This is a wrapper that does not support mutation")
- override def remove(k : AnyRef) =
+ override def remove(k : AnyRef) =
throw new UnsupportedOperationException("This is a wrapper that does not support mutation")
-
+
override def entrySet : ju.Set[ju.Map.Entry[A, B]] = new ju.AbstractSet[ju.Map.Entry[A, B]] {
def size = self.size
def iterator = new ju.Iterator[ju.Map.Entry[A, B]] {
val ui = underlying.iterator
var prev : Option[A] = None
-
+
def hasNext = ui.hasNext
-
+
def next = {
val (k, v) = ui.next
prev = Some(k)
@@ -44,7 +44,7 @@ package scala.swing
}
}
}
-
+
def remove = prev match {
case Some(k) => val v = self.remove(k.asInstanceOf[AnyRef]) ; prev = None ; v
case _ => throw new IllegalStateException("next must be called at least once before remove")
@@ -53,7 +53,7 @@ package scala.swing
}
}
*/
-
+
/**
* See [java.awt.Font.getFont].
*/
@@ -62,9 +62,9 @@ package scala.swing
* See [java.awt.Font.getFont].
*/
def get(nm: String, font: Font) = java.awt.Font.getFont(nm, font)
-
+
def Insets(x: Int, y: Int, width: Int, height: Int) = new Insets(x, y, width, height)
def Rectangle(x: Int, y: Int, width: Int, height: Int) = new Insets(x, y, width, height)
def Point(x: Int, y: Int) = new Point(x, y)
- def Dimension(x: Int, y: Int) = new Dimension(x, y)
+ def Dimension(x: Int, y: Int) = new Dimension(x, y)
}*/ \ No newline at end of file
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/arrays/Resetting.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/arrays/Resetting.scala
index e6feb59fcd..22d2107f62 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/arrays/Resetting.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/arrays/Resetting.scala
@@ -4,19 +4,19 @@ package scala.collection.parallel.benchmarks.arrays
import scala.collection.parallel.benchmarks._
-abstract class Resetting[T: Manifest](elemcreate: Int => T, sz: Int, p: Int, what: String)
+abstract class Resetting[T: ClassTag](elemcreate: Int => T, sz: Int, p: Int, what: String)
extends Bench {
val size = sz
val parallelism = p
val runWhat = what
-
+
var anyarray: Array[Any] = null
var castarray: AnyRef = null
var gencastarray: Array[T] = null
var manifarray: Array[T] = null
-
+
reset
-
+
def reset = what match {
case "any" =>
anyarray = new Array[Any](sz)
diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/MatrixMultiplication.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/MatrixMultiplication.scala
index 5f902ff483..6d5b189c3a 100644
--- a/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/MatrixMultiplication.scala
+++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/parallel_array/MatrixMultiplication.scala
@@ -16,54 +16,54 @@ class MatrixMultiplication(sz: Int, p: Int, what: String)
extends Resettable(sz, p, what, new Cont(_), new Array[Any](_), classOf[Cont]) {
def companion = MatrixMultiplication
collection.parallel.tasksupport.environment = forkjoinpool
-
+
val a = Matrix.unit[Int](sz)
val b = Matrix.unit[Int](sz)
var c = new Matrix[Int](sz)
-
+
def runpar = c = a * b //{ c.assignProduct(a, b) } //; println("--------"); c.output }
def runseq = throw new UnsupportedOperationException
def comparisonMap = collection.Map()
-
- class Matrix[T](n: Int)(implicit num: Numeric[T], man: Manifest[T]) {
+
+ class Matrix[T](n: Int)(implicit num: Numeric[T], tag: ClassTag[T]) {
val array = new Array[T](n * n)
-
+
def apply(y: Int, x: Int) = array(y * n + x)
-
+
def update(y: Int, x: Int, elem: T) = array(y * n + x) = elem
-
+
def *(b: Matrix[T]) = {
val m = new Matrix[T](n)
m.assignProduct(this, b)
m
}
-
+
def assignProduct(a: Matrix[T], b: Matrix[T]) = {
val range = ParRange(0, n * n, 1, false)
for (i <- range) this(i / n, i % n) = calcProduct(a, b, i / n, i % n);
}
-
+
private def calcProduct(a: Matrix[T], b: Matrix[T], y: Int, x: Int): T = {
import num._
var sum = zero
for (i <- 0 until n) sum += a(y, i) * b(i, x)
sum
}
-
+
def output = for (y <- 0 until n) {
for (x <- 0 until n) print(this(y, x))
println
}
}
-
+
object Matrix {
- def unit[T](n: Int)(implicit num: Numeric[T], man: Manifest[T]) = {
+ def unit[T](n: Int)(implicit num: Numeric[T], tag: ClassTag[T]) = {
val m = new Matrix[T](n)
for (i <- 0 until n) m(i, i) = num.one
m
}
}
-
+
}
diff --git a/test/disabled/presentation/akka.check b/test/disabled/presentation/akka.check
index 9cd20ffb1c..5105d85a00 100644
--- a/test/disabled/presentation/akka.check
+++ b/test/disabled/presentation/akka.check
@@ -153,11 +153,11 @@ retrieved 131 members
`method spawn(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLink(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLinkRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: Manifest[T])akka.actor.ActorRef`
-`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: Manifest[T])akka.actor.ActorRef`
+`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: ClassTag[T])akka.actor.ActorRef`
+`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: ClassTag[T])akka.actor.ActorRef`
`method spawnRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: Manifest[T])akka.actor.ActorRef`
-`method spawn[T <: akka.actor.Actor](implicit evidence$1: Manifest[T])akka.actor.ActorRef`
+`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: ClassTag[T])akka.actor.ActorRef`
+`method spawn[T <: akka.actor.Actor](implicit evidence$1: ClassTag[T])akka.actor.ActorRef`
`method start()akka.actor.ActorRef`
`method startLink(actorRef: akka.actor.ActorRef)Unit`
`method stop()Unit`
@@ -286,11 +286,11 @@ retrieved 131 members
`method spawn(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLink(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLinkRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: Manifest[T])akka.actor.ActorRef`
-`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: Manifest[T])akka.actor.ActorRef`
+`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: ClassTag[T])akka.actor.ActorRef`
+`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: ClassTag[T])akka.actor.ActorRef`
`method spawnRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: Manifest[T])akka.actor.ActorRef`
-`method spawn[T <: akka.actor.Actor](implicit evidence$1: Manifest[T])akka.actor.ActorRef`
+`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: ClassTag[T])akka.actor.ActorRef`
+`method spawn[T <: akka.actor.Actor](implicit evidence$1: ClassTag[T])akka.actor.ActorRef`
`method start()akka.actor.ActorRef`
`method startLink(actorRef: akka.actor.ActorRef)Unit`
`method stop()Unit`
@@ -419,11 +419,11 @@ retrieved 131 members
`method spawn(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLink(clazz: Class[_ <: akka.actor.Actor])akka.actor.ActorRef`
`method spawnLinkRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: Manifest[T])akka.actor.ActorRef`
-`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: Manifest[T])akka.actor.ActorRef`
+`method spawnLinkRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$4: ClassTag[T])akka.actor.ActorRef`
+`method spawnLink[T <: akka.actor.Actor](implicit evidence$3: ClassTag[T])akka.actor.ActorRef`
`method spawnRemote(clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long)akka.actor.ActorRef`
-`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: Manifest[T])akka.actor.ActorRef`
-`method spawn[T <: akka.actor.Actor](implicit evidence$1: Manifest[T])akka.actor.ActorRef`
+`method spawnRemote[T <: akka.actor.Actor](hostname: String, port: Int, timeout: Long)(implicit evidence$2: ClassTag[T])akka.actor.ActorRef`
+`method spawn[T <: akka.actor.Actor](implicit evidence$1: ClassTag[T])akka.actor.ActorRef`
`method start()akka.actor.ActorRef`
`method startLink(actorRef: akka.actor.ActorRef)Unit`
`method stop()Unit`
diff --git a/test/disabled/presentation/akka/src/akka/actor/Actor.scala b/test/disabled/presentation/akka/src/akka/actor/Actor.scala
index b955c4c38b..b9bc51b635 100644
--- a/test/disabled/presentation/akka/src/akka/actor/Actor.scala
+++ b/test/disabled/presentation/akka/src/akka/actor/Actor.scala
@@ -135,7 +135,7 @@ object Actor extends ListenerManagement {
* val actor = actorOf[MyActor].start()
* </pre>
*/
- def actorOf[T <: Actor: Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
+ def actorOf[T <: Actor: ClassTag]: ActorRef = actorOf(classTag[T].erasure.asInstanceOf[Class[_ <: Actor]])
/** Creates an ActorRef out of the Actor of the specified Class.
* <pre>
@@ -481,7 +481,7 @@ private[actor] class AnyOptionAsTypedOption(anyOption: Option[Any]) {
/** Convenience helper to cast the given Option of Any to an Option of the given type. Will swallow a possible
* ClassCastException and return None in that case.
*/
- def asSilently[T: Manifest]: Option[T] = narrowSilently[T](anyOption)
+ def asSilently[T: ClassTag]: Option[T] = narrowSilently[T](anyOption)
}
/** Marker interface for proxyable actors (such as typed actor).
diff --git a/test/disabled/presentation/akka/src/akka/actor/ActorRef.scala b/test/disabled/presentation/akka/src/akka/actor/ActorRef.scala
index ff67c9468e..da0b63006a 100644
--- a/test/disabled/presentation/akka/src/akka/actor/ActorRef.scala
+++ b/test/disabled/presentation/akka/src/akka/actor/ActorRef.scala
@@ -1406,28 +1406,28 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
/**
* Atomically create (from actor class) and start an actor.
*/
- def spawn[T <: Actor: Manifest]: ActorRef =
- spawn(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
+ def spawn[T <: Actor: ClassTag]: ActorRef =
+ spawn(classTag[T].erasure.asInstanceOf[Class[_ <: Actor]])
/**
* Atomically create (from actor class), start and make an actor remote.
*/
- def spawnRemote[T <: Actor: Manifest](hostname: String, port: Int, timeout: Long): ActorRef = {
+ def spawnRemote[T <: Actor: ClassTag](hostname: String, port: Int, timeout: Long): ActorRef = {
ensureRemotingEnabled
- spawnRemote(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]], hostname, port, timeout)
+ spawnRemote(classTag[T].erasure.asInstanceOf[Class[_ <: Actor]], hostname, port, timeout)
}
/**
* Atomically create (from actor class), start and link an actor.
*/
- def spawnLink[T <: Actor: Manifest]: ActorRef =
- spawnLink(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
+ def spawnLink[T <: Actor: ClassTag]: ActorRef =
+ spawnLink(classTag[T].erasure.asInstanceOf[Class[_ <: Actor]])
/**
* Atomically create (from actor class), start, link and make an actor remote.
*/
- def spawnLinkRemote[T <: Actor: Manifest](hostname: String, port: Int, timeout: Long): ActorRef = {
+ def spawnLinkRemote[T <: Actor: ClassTag](hostname: String, port: Int, timeout: Long): ActorRef = {
ensureRemotingEnabled
- spawnLinkRemote(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]], hostname, port, timeout)
+ spawnLinkRemote(classTag[T].erasure.asInstanceOf[Class[_ <: Actor]], hostname, port, timeout)
}
}
diff --git a/test/disabled/presentation/akka/src/akka/actor/ActorRegistry.scala b/test/disabled/presentation/akka/src/akka/actor/ActorRegistry.scala
index df335dc8b4..5d649fcd36 100644
--- a/test/disabled/presentation/akka/src/akka/actor/ActorRegistry.scala
+++ b/test/disabled/presentation/akka/src/akka/actor/ActorRegistry.scala
@@ -5,7 +5,7 @@
package akka.actor
import scala.collection.mutable.{ ListBuffer, Map }
-import scala.reflect.Manifest
+import scala.reflect.ArrayTag
import java.util.concurrent.{ ConcurrentSkipListSet, ConcurrentHashMap }
import java.util.{ Set => JSet }
@@ -74,10 +74,10 @@ final class ActorRegistry private[actor] () extends ListenerManagement {
}
/**
- * Finds all actors that are subtypes of the class passed in as the Manifest argument and supporting passed message.
+ * Finds all actors that are subtypes of the class passed in as the ClassTag argument and supporting passed message.
*/
- def actorsFor[T <: Actor](message: Any)(implicit manifest: Manifest[T]): Array[ActorRef] =
- filter(a => manifest.erasure.isAssignableFrom(a.actor.getClass) && a.isDefinedAt(message))
+ def actorsFor[T <: Actor](message: Any)(implicit classTag: ClassTag[T]): Array[ActorRef] =
+ filter(a => classTag.erasure.isAssignableFrom(a.actor.getClass) && a.isDefinedAt(message))
/**
* Finds all actors that satisfy a predicate.
@@ -93,16 +93,16 @@ final class ActorRegistry private[actor] () extends ListenerManagement {
}
/**
- * Finds all actors that are subtypes of the class passed in as the Manifest argument.
+ * Finds all actors that are subtypes of the class passed in as the ClassTag argument.
*/
- def actorsFor[T <: Actor](implicit manifest: Manifest[T]): Array[ActorRef] =
- actorsFor[T](manifest.erasure.asInstanceOf[Class[T]])
+ def actorsFor[T <: Actor](implicit classTag: ClassTag[T]): Array[ActorRef] =
+ actorsFor[T](classTag.erasure.asInstanceOf[Class[T]])
/**
* Finds any actor that matches T. Very expensive, traverses ALL alive actors.
*/
- def actorFor[T <: Actor](implicit manifest: Manifest[T]): Option[ActorRef] =
- find({ case a: ActorRef if manifest.erasure.isAssignableFrom(a.actor.getClass) => a })
+ def actorFor[T <: Actor](implicit classTag: ClassTag[T]): Option[ActorRef] =
+ find({ case a: ActorRef if classTag.erasure.isAssignableFrom(a.actor.getClass) => a })
/**
* Finds all actors of type or sub-type specified by the class passed in as the Class argument.
@@ -166,21 +166,21 @@ final class ActorRegistry private[actor] () extends ListenerManagement {
}
/**
- * Finds all typed actors that are subtypes of the class passed in as the Manifest argument.
+ * Finds all typed actors that are subtypes of the class passed in as the ClassTag argument.
*/
- def typedActorsFor[T <: AnyRef](implicit manifest: Manifest[T]): Array[AnyRef] = {
+ def typedActorsFor[T <: AnyRef](implicit classTag: ClassTag[T]): Array[AnyRef] = {
TypedActorModule.ensureEnabled
- typedActorsFor[T](manifest.erasure.asInstanceOf[Class[T]])
+ typedActorsFor[T](classTag.erasure.asInstanceOf[Class[T]])
}
/**
* Finds any typed actor that matches T.
*/
- def typedActorFor[T <: AnyRef](implicit manifest: Manifest[T]): Option[AnyRef] = {
+ def typedActorFor[T <: AnyRef](implicit classTag: ClassTag[T]): Option[AnyRef] = {
TypedActorModule.ensureEnabled
def predicate(proxy: AnyRef): Boolean = {
val actorRef = TypedActorModule.typedActorObjectInstance.get.actorFor(proxy)
- actorRef.isDefined && manifest.erasure.isAssignableFrom(actorRef.get.actor.getClass)
+ actorRef.isDefined && classTag.erasure.isAssignableFrom(actorRef.get.actor.getClass)
}
findTypedActor({ case a: Some[AnyRef] if predicate(a.get) => a })
}
@@ -279,7 +279,7 @@ final class ActorRegistry private[actor] () extends ListenerManagement {
*
* @author Viktor Klang
*/
-class Index[K <: AnyRef, V <: AnyRef: Manifest] {
+class Index[K <: AnyRef, V <: AnyRef: ArrayTag] {
private val Naught = Array[V]() //Nil for Arrays
private val container = new ConcurrentHashMap[K, JSet[V]]
private val emptySet = new ConcurrentSkipListSet[V]
diff --git a/test/disabled/presentation/akka/src/akka/event/EventHandler.scala b/test/disabled/presentation/akka/src/akka/event/EventHandler.scala
index f3176b7c21..af2fee6c47 100644
--- a/test/disabled/presentation/akka/src/akka/event/EventHandler.scala
+++ b/test/disabled/presentation/akka/src/akka/event/EventHandler.scala
@@ -115,8 +115,8 @@ object EventHandler extends ListenerManagement {
notifyListeners(event)
}
- def notify[T <: Event: ClassManifest](event: => T) {
- if (level >= levelFor(classManifest[T].erasure.asInstanceOf[Class[_ <: Event]])) notifyListeners(event)
+ def notify[T <: Event: ClassTag](event: => T) {
+ if (level >= levelFor(classTag[T].erasure.asInstanceOf[Class[_ <: Event]])) notifyListeners(event)
}
def error(cause: Throwable, instance: AnyRef, message: => String) {
diff --git a/test/disabled/presentation/akka/src/akka/remoteinterface/RemoteInterface.scala b/test/disabled/presentation/akka/src/akka/remoteinterface/RemoteInterface.scala
index 0c5da82294..5219c49dcb 100644
--- a/test/disabled/presentation/akka/src/akka/remoteinterface/RemoteInterface.scala
+++ b/test/disabled/presentation/akka/src/akka/remoteinterface/RemoteInterface.scala
@@ -206,8 +206,8 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* </pre>
*/
@deprecated("Will be removed after 1.1", "1.1")
- def actorOf[T <: Actor: Manifest](host: String, port: Int): ActorRef =
- clientManagedActorOf(() => createActorFromClass(manifest.erasure), host, port)
+ def actorOf[T <: Actor: ClassTag](host: String, port: Int): ActorRef =
+ clientManagedActorOf(() => createActorFromClass(classTag[T].erasure), host, port)
protected def createActorFromClass(clazz: Class[_]): Actor = {
import ReflectiveAccess.{ createInstance, noParams, noArgs }
diff --git a/test/disabled/presentation/akka/src/akka/util/Helpers.scala b/test/disabled/presentation/akka/src/akka/util/Helpers.scala
index 48477426c9..0ff45408d0 100644
--- a/test/disabled/presentation/akka/src/akka/util/Helpers.scala
+++ b/test/disabled/presentation/akka/src/akka/util/Helpers.scala
@@ -37,7 +37,7 @@ object Helpers {
* Convenience helper to cast the given Option of Any to an Option of the given type. Will swallow a possible
* ClassCastException and return None in that case.
*/
- def narrowSilently[T: Manifest](o: Option[Any]): Option[T] =
+ def narrowSilently[T: ClassTag](o: Option[Any]): Option[T] =
try {
narrow(o)
} catch {
diff --git a/test/disabled/presentation/simple-tests.check b/test/disabled/presentation/simple-tests.check
index b90dfce77c..cdb80ed987 100644
--- a/test/disabled/presentation/simple-tests.check
+++ b/test/disabled/presentation/simple-tests.check
@@ -244,7 +244,7 @@ TypeMember(method disable,(s: Tester.this.settings.Setting)scala.collection.muta
TypeMember(value disable,Tester.this.settings.MultiStringSetting,false,true,<none>)
TypeMember(value elidebelow,Tester.this.settings.IntSetting,false,true,<none>)
TypeMember(method embeddedDefaults,(loader: java.lang.ClassLoader)Unit,true,true,<none>)
-TypeMember(method embeddedDefaults,[T](implicit evidence$1: Manifest[T])Unit,true,true,<none>)
+TypeMember(method embeddedDefaults,[T](implicit evidence$1: ClassTag[T])Unit,true,true,<none>)
TypeMember(value encoding,Tester.this.settings.StringSetting,false,true,<none>)
TypeMember(method ensuring,(cond: (scala.tools.nsc.Settings) => Boolean,msg: => Any)scala.tools.nsc.Settings,true,false,method any2Ensuring)
TypeMember(method ensuring,(cond: (scala.tools.nsc.Settings) => Boolean)scala.tools.nsc.Settings,true,false,method any2Ensuring)
diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check
new file mode 100644
index 0000000000..9fca856970
--- /dev/null
+++ b/test/files/jvm/manifests-new.check
@@ -0,0 +1,58 @@
+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=TypeRef, s=object Test
+x=scala.collection.immutable.List$, t=ConcreteTypeTag[scala.collection.immutable.List.type], k=TypeRef, 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>
+
+()=()
+true=true
+a=a
+1=1
+'abc='abc
+
+List(())=List(())
+List(true)=List(true)
+List('abc)=List('abc)
+
+Array()=Array()
+Array(true)=Array(true)
+Array(a)=Array(a)
+Array(1)=Array(1)
+
+((),())=((),())
+(true,false)=(true,false)
+
+List(List(1), List(2))=List(List(1), List(2))
+
+Array(Array(1), Array(2))=Array(Array(1), Array(2))
+
diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala
new file mode 100644
index 0000000000..d02f6ee608
--- /dev/null
+++ b/test/files/jvm/manifests-new.scala
@@ -0,0 +1,109 @@
+object Test extends App {
+ Test1
+ Test2
+}
+
+class Foo[T](x: T)
+trait Bar[T] { def f: T }
+
+object Test1 extends TestUtil {
+ print(())
+ print(true)
+ print('a')
+ print(1)
+ print("abc")
+ print('abc)
+ println()
+
+ print(List(()))
+ print(List(true))
+ print(List(1))
+ print(List("abc"))
+ print(List('abc))
+ println()
+
+ //print(Array(())) //Illegal class name "[V" in class file Test$
+ print(Array(true))
+ print(Array('a'))
+ print(Array(1))
+ print(Array("abc"))
+ print(Array('abc))
+ println()
+
+ print(((), ()))
+ print((true, false))
+ print((1, 2))
+ print(("abc", "xyz"))
+ print(('abc, 'xyz))
+ println()
+
+ print(Test)
+ print(List)
+ println()
+
+ print(new Foo(2))
+ print(new Foo(List(2)))
+ print(new Foo(new Foo(2)))
+ print(new Foo(List(new Foo(2))))
+ println()
+
+ print(new Bar[String] { def f = "abc" });
+ {print(new Bar[String] { def f = "abc" })}
+ println()
+}
+
+object Test2 {
+ import scala.util.Marshal._
+ println("()="+load[Unit](dump(())))
+ 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()
+
+ 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()
+
+ def loadArray[T](x: Array[Byte])(implicit t: reflect.ClassTag[Array[T]]) =
+ load[Array[T]](x)(t).deep.toString
+ println("Array()="+loadArray[Int](dump(Array(): Array[Int])))
+ println("Array(true)="+loadArray[Boolean](dump(Array(true))))
+ println("Array(a)="+loadArray[Char](dump(Array('a'))))
+ println("Array(1)="+loadArray[Int](dump(Array(1))))
+ println()
+
+ println("((),())="+load[(Unit, Unit)](dump(((), ()))))
+ println("(true,false)="+load[(Boolean, Boolean)](dump((true, false))))
+ println()
+
+ println("List(List(1), List(2))="+load[List[List[Int]]](dump(List(List(1), List(2)))))
+ println()
+
+ println("Array(Array(1), Array(2))="+loadArray[Array[Int]](dump(Array(Array(1), Array(2)))))
+ println()
+}
+
+trait TestUtil {
+ import java.io._
+ def write[A](o: A): Array[Byte] = {
+ val ba = new ByteArrayOutputStream(512)
+ val out = new ObjectOutputStream(ba)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+ def read[A](buffer: Array[Byte]): A = {
+ val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
+ in.readObject().asInstanceOf[A]
+ }
+ import scala.reflect._
+ def print[T](x: T)(implicit t: ConcreteTypeTag[T]) {
+ // todo. type tags are not yet serializable
+// val t1: ConcreteTypeTag[T] = read(write(t))
+ val t1: ConcreteTypeTag[T] = t
+ val x1 = x.toString.replaceAll("@[0-9a-z]+$", "")
+ println("x="+x1+", t="+t1+", k="+t1.tpe.kind+", s="+t1.sym.toString)
+ }
+}
diff --git a/test/files/jvm/manifests-old.check b/test/files/jvm/manifests-old.check
new file mode 100644
index 0000000000..54f504b929
--- /dev/null
+++ b/test/files/jvm/manifests-old.check
@@ -0,0 +1,55 @@
+x=(), m=Unit
+x=true, m=Boolean
+x=a, m=Char
+x=1, m=Int
+x=abc, m=java.lang.String
+x='abc, m=scala.Symbol
+
+x=List(()), m=scala.collection.immutable.List[Unit]
+x=List(true), m=scala.collection.immutable.List[Boolean]
+x=List(1), m=scala.collection.immutable.List[Int]
+x=List(abc), m=scala.collection.immutable.List[java.lang.String]
+x=List('abc), m=scala.collection.immutable.List[scala.Symbol]
+
+x=[Z, m=Array[Boolean]
+x=[C, m=Array[Char]
+x=[I, m=Array[Int]
+x=[Ljava.lang.String;, m=Array[java.lang.String]
+x=[Lscala.Symbol;, m=Array[scala.Symbol]
+
+x=((),()), m=scala.Tuple2[Unit, Unit]
+x=(true,false), m=scala.Tuple2[Boolean, Boolean]
+x=(1,2), m=scala.Tuple2[Int, Int]
+x=(abc,xyz), m=scala.Tuple2[java.lang.String, java.lang.String]
+x=('abc,'xyz), m=scala.Tuple2[scala.Symbol, scala.Symbol]
+
+
+x=Foo, m=Foo[Int]
+x=Foo, m=Foo[scala.collection.immutable.List[Int]]
+x=Foo, m=Foo[Foo[Int]]
+x=Foo, m=Foo[scala.collection.immutable.List[Foo[Int]]]
+
+x=Test1$$anon$1, m=Object with Bar[java.lang.String]
+
+()=()
+true=true
+a=a
+1=1
+'abc='abc
+
+List(())=List(())
+List(true)=List(true)
+List('abc)=List('abc)
+
+Array()=Array()
+Array(true)=Array(true)
+Array(a)=Array(a)
+Array(1)=Array(1)
+
+((),())=((),())
+(true,false)=(true,false)
+
+List(List(1), List(2))=List(List(1), List(2))
+
+Array(Array(1), Array(2))=Array(Array(1), Array(2))
+
diff --git a/test/files/jvm/manifests.scala b/test/files/jvm/manifests-old.scala
index 935427f5d4..241966fd9d 100644
--- a/test/files/jvm/manifests.scala
+++ b/test/files/jvm/manifests-old.scala
@@ -50,8 +50,7 @@ object Test1 extends TestUtil {
print(new Foo(List(new Foo(2))))
println()
- print(new Bar[String] { def f = "abc" });
- {print(new Bar[String] { def f = "abc" })}
+ print(new Bar[String] { def f = "abc" })
println()
}
@@ -103,10 +102,8 @@ trait TestUtil {
}
import scala.reflect._
def print[T](x: T)(implicit m: Manifest[T]) {
- // manifests are no longer serializable
-// val m1: Manifest[T] = read(write(m))
- val m1: Manifest[T] = m
+ val m1: Manifest[T] = read(write(m))
val x1 = x.toString.replaceAll("@[0-9a-z]+$", "")
- println("x="+x1+", m="+m1+", k="+m1.tpe.kind+", s="+m1.sym.toString)
+ println("x="+x1+", m="+m1)
}
}
diff --git a/test/files/jvm/manifests.check b/test/files/jvm/manifests.check
deleted file mode 100644
index be8ec2bb5b..0000000000
--- a/test/files/jvm/manifests.check
+++ /dev/null
@@ -1,56 +0,0 @@
-x=(), m=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit
-x=true, m=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean
-x=a, m=ConcreteTypeTag[Char], k=TypeRef, s=class Char
-x=1, m=ConcreteTypeTag[Int], k=TypeRef, s=class Int
-x=abc, m=ConcreteTypeTag[String], k=TypeRef, s=class String
-x='abc, m=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol
-
-x=List(()), m=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List
-x=List(true), m=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List
-x=List(1), m=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List
-x=List(abc), m=ConcreteTypeTag[List[String]], k=TypeRef, s=class List
-x=List('abc), m=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List
-
-x=[Z, m=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array
-x=[C, m=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array
-x=[I, m=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array
-x=[Ljava.lang.String;, m=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array
-x=[Lscala.Symbol;, m=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array
-
-x=((),()), m=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
-x=(true,false), m=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
-x=(1,2), m=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
-x=(abc,xyz), m=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2
-x=('abc,'xyz), m=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
-
-
-x=Foo, m=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo
-x=Foo, m=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
-x=Foo, m=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
-x=Foo, m=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
-
-x=Test1$$anon$1, m=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-x=Test1$$anon$2, m=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-
-()=()
-true=true
-a=a
-1=1
-'abc='abc
-
-List(())=List(())
-List(true)=List(true)
-List('abc)=List('abc)
-
-Array()=Array()
-Array(true)=Array(true)
-Array(a)=Array(a)
-Array(1)=Array(1)
-
-((),())=((),())
-(true,false)=(true,false)
-
-List(List(1), List(2))=List(List(1), List(2))
-
-Array(Array(1), Array(2))=Array(Array(1), Array(2))
-
diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check
new file mode 100644
index 0000000000..fa51c6a879
--- /dev/null
+++ b/test/files/jvm/serialization-new.check
@@ -0,0 +1,313 @@
+a1 = Array[1,2,3]
+_a1 = Array[1,2,3]
+arrayEquals(a1, _a1): true
+
+e1 = Left(1)
+_e1 = Left(1)
+e1 eq _e1: false, _e1 eq e1: false
+e1 equals _e1: true, _e1 equals e1: true
+
+x7 = RoundingMode
+y7 = RoundingMode
+x7 eq y7: true, y7 eq x7: true
+x7 equals y7: true, y7 equals x7: true
+
+x8 = WeekDay
+y8 = WeekDay
+x8 eq y8: true, y8 eq x8: true
+x8 equals y8: true, y8 equals x8: true
+
+x9 = UP
+y9 = UP
+x9 eq y9: true, y9 eq x9: true
+x9 equals y9: true, y9 equals x9: true
+
+x10 = Monday
+y10 = Monday
+x10 eq y10: true, y10 eq x10: true
+x10 equals y10: true, y10 equals x10: true
+
+x9 eq x10: false, x10 eq x9: false
+x9 equals x10: false, x10 equals x9: false
+x9 eq y10: false, y10 eq x9: false
+x9 equals y10: false, y10 equals x9: false
+
+f1 = <na>
+_f1 = <na>
+f1(2): 4, _f1(2): 4
+
+xs0 = List(1, 2, 3)
+_xs0 = List(1, 2, 3)
+xs0 eq _xs0: false, _xs0 eq xs0: false
+xs0 equals _xs0: true, _xs0 equals xs0: true
+
+xs1 = List()
+_xs1 = List()
+xs1 eq _xs1: true, _xs1 eq xs1: true
+
+o1 = None
+_o1 = None
+o1 eq _o1: true, _o1 eq o1: true
+
+o2 = Some(1)
+_o2 = Some(1)
+o2 eq _o2: false, _o2 eq o2: false
+o2 equals _o2: true, _o2 equals o2: true
+
+s1 = 'hello
+_s1 = 'hello
+s1 eq _s1: true, _s1 eq s1: true
+s1 equals _s1: true, _s1 equals s1: true
+
+t1 = (BannerLimit,12345)
+_t1 = (BannerLimit,12345)
+t1 eq _t1: false, _t1 eq t1: false
+t1 equals _t1: true, _t1 equals t1: true
+
+x = BitSet(1, 2)
+y = BitSet(1, 2)
+x equals y: true, y equals x: true
+
+x = BitSet(2, 3)
+y = BitSet(2, 3)
+x equals y: true, y equals x: true
+
+x = Map(1 -> A, 2 -> B, 3 -> C)
+y = Map(1 -> A, 2 -> B, 3 -> C)
+x equals y: true, y equals x: true
+
+x = Set(1, 2)
+y = Set(1, 2)
+x equals y: true, y equals x: true
+
+x = List((buffers,20), (layers,2), (title,3))
+y = List((buffers,20), (layers,2), (title,3))
+x equals y: true, y equals x: true
+
+x = Map(buffers -> 20, layers -> 2, title -> 3)
+y = Map(buffers -> 20, layers -> 2, title -> 3)
+x equals y: true, y equals x: true
+
+x = ListSet(5, 3)
+y = ListSet(5, 3)
+x equals y: true, y equals x: true
+
+x = Queue(a, b, c)
+y = Queue(a, b, c)
+x equals y: true, y equals x: true
+
+x = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+y = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+x equals y: true, y equals x: true
+
+x = NumericRange(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+y = NumericRange(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+x equals y: true, y equals x: true
+
+x = Map(1 -> A, 2 -> B, 3 -> C)
+y = Map(1 -> A, 2 -> B, 3 -> C)
+x equals y: true, y equals x: true
+
+x = TreeSet(1, 2, 3)
+y = TreeSet(1, 2, 3)
+x equals y: true, y equals x: true
+
+x = Stack(c, b, a)
+y = Stack(c, b, a)
+x equals y: true, y equals x: true
+
+x = Stream(0, ?)
+y = Stream(0, ?)
+x equals y: true, y equals x: true
+
+x = Map(42 -> FortyTwo)
+y = Map(42 -> FortyTwo)
+x equals y: true, y equals x: true
+
+x = TreeSet(0, 2)
+y = TreeSet(0, 2)
+x equals y: true, y equals x: true
+
+x = Vector('a, 'b, 'c)
+y = Vector('a, 'b, 'c)
+x equals y: true, y equals x: true
+
+x = ArrayBuffer(one, two)
+y = ArrayBuffer(one, two)
+x equals y: true, y equals x: true
+
+x = ArrayBuilder.ofLong
+y = ArrayBuilder.ofLong
+x equals y: true, y equals x: true
+
+x = ArrayBuilder.ofFloat
+y = ArrayBuilder.ofFloat
+x equals y: true, y equals x: true
+
+x = ArraySeq(1, 2, 3)
+y = ArraySeq(1, 2, 3)
+x equals y: true, y equals x: true
+
+x = ArrayStack(3, 2, 20)
+y = ArrayStack(3, 2, 20)
+x equals y: true, y equals x: true
+
+x = BitSet(0, 8, 9)
+y = BitSet(0, 8, 9)
+x equals y: true, y equals x: true
+
+x = Map(A -> 1, C -> 3, B -> 2)
+y = Map(A -> 1, C -> 3, B -> 2)
+x equals y: true, y equals x: true
+
+x = Set(buffers, title, layers)
+y = Set(buffers, title, layers)
+x equals y: true, y equals x: true
+
+x = History()
+y = History()
+x equals y: true, y equals x: true
+
+x = ListBuffer(white, black)
+y = ListBuffer(white, black)
+x equals y: true, y equals x: true
+
+x = Queue(20, 2, 3)
+y = Queue(20, 2, 3)
+x equals y: true, y equals x: true
+
+x = Stack(3, 2, 20)
+y = Stack(3, 2, 20)
+x equals y: true, y equals x: true
+
+x = abc
+y = abc
+x equals y: true, y equals x: true
+
+x = WrappedArray(1, 2, 3)
+y = WrappedArray(1, 2, 3)
+x equals y: true, y equals x: true
+
+x = TreeSet(1, 2, 3)
+y = TreeSet(1, 2, 3)
+x equals y: true, y equals x: true
+
+x = TrieMap(1 -> one, 2 -> two, 3 -> three)
+y = TrieMap(1 -> one, 2 -> two, 3 -> three)
+x equals y: true, y equals x: true
+
+x = xml:src="hello"
+y = xml:src="hello"
+x equals y: true, y equals x: true
+
+x = <title></title>
+y = <title></title>
+x equals y: true, y equals x: true
+
+x = <html><title>title</title><body></body></html>
+y = <html><title>title</title><body></body></html>
+x equals y: true, y equals x: true
+
+x = <html>
+ <body>
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ <tr>
+ <td> Tom </td>
+ <td> 20 </td>
+ </tr><tr>
+ <td> Bob </td>
+ <td> 22 </td>
+ </tr><tr>
+ <td> James </td>
+ <td> 19 </td>
+ </tr>
+ </table>
+ </body>
+ </html>
+y = <html>
+ <body>
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ <tr>
+ <td> Tom </td>
+ <td> 20 </td>
+ </tr><tr>
+ <td> Bob </td>
+ <td> 22 </td>
+ </tr><tr>
+ <td> James </td>
+ <td> 19 </td>
+ </tr>
+ </table>
+ </body>
+ </html>
+x equals y: true, y equals x: true
+
+x = Tim
+y = Tim
+x equals y: true, y equals x: true
+
+x = Bob
+y = Bob
+x equals y: true, y equals x: true
+
+x = John
+y = John
+x equals y: true, y equals x: true
+
+x = Bill
+y = Bill
+x equals y: true, y equals x: true
+
+x = Paul
+y = Paul
+x equals y: true, y equals x: true
+
+1
+2
+1
+2
+
+x = UnrolledBuffer(one, two)
+y = UnrolledBuffer(one, two)
+x equals y: true, y equals x: true
+
+x = ParArray(abc, def, etc)
+y = ParArray(abc, def, etc)
+x equals y: true, y equals x: true
+
+x = ParHashMap(2 -> 4, 1 -> 2)
+y = ParHashMap(2 -> 4, 1 -> 2)
+x equals y: true, y equals x: true
+
+x = ParTrieMap(1 -> 2, 2 -> 4)
+y = ParTrieMap(1 -> 2, 2 -> 4)
+x equals y: true, y equals x: true
+
+x = ParHashSet(1, 2, 3)
+y = ParHashSet(1, 2, 3)
+x equals y: true, y equals x: true
+
+x = ParRange(0, 1, 2, 3, 4)
+y = ParRange(0, 1, 2, 3, 4)
+x equals y: true, y equals x: true
+
+x = ParRange(0, 1, 2, 3)
+y = ParRange(0, 1, 2, 3)
+x equals y: true, y equals x: true
+
+x = ParMap(5 -> 1, 10 -> 2)
+y = ParMap(5 -> 1, 10 -> 2)
+x equals y: true, y equals x: true
+
+x = ParSet(two, one)
+y = ParSet(two, one)
+x equals y: true, y equals x: true
+
diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala
new file mode 100644
index 0000000000..bb971fdf36
--- /dev/null
+++ b/test/files/jvm/serialization-new.scala
@@ -0,0 +1,651 @@
+//############################################################################
+// Serialization
+//############################################################################
+
+object Serialize {
+ @throws(classOf[java.io.IOException])
+ def write[A](o: A): Array[Byte] = {
+ val ba = new java.io.ByteArrayOutputStream(512)
+ val out = new java.io.ObjectOutputStream(ba)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+ @throws(classOf[java.io.IOException])
+ @throws(classOf[ClassNotFoundException])
+ def read[A](buffer: Array[Byte]): A = {
+ val in =
+ new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(buffer))
+ in.readObject().asInstanceOf[A]
+ }
+ def check[A, B](x: A, y: B) {
+ println("x = " + x)
+ println("y = " + y)
+ println("x equals y: " + (x equals y) + ", y equals x: " + (y equals x))
+ assert((x equals y) && (y equals x))
+ println()
+ }
+}
+import Serialize._
+
+//############################################################################
+// Test classes in package "scala"
+
+object Test1_scala {
+
+ private def arrayToString[A](arr: Array[A]): String =
+ arr.mkString("Array[",",","]")
+
+ private def arrayEquals[A, B](a1: Array[A], a2: Array[B]): Boolean =
+ (a1.length == a2.length) &&
+ (Iterator.range(0, a1.length) forall { i => a1(i) == a2(i) })
+
+ object WeekDay extends Enumeration {
+ type WeekDay = Value
+ val Monday, Tuesday, Wednesday, Thusday, Friday, Saturday, Sunday = Value
+ }
+ import WeekDay._, BigDecimal._, RoundingMode._
+
+ // in alphabetic order
+ try {
+ // Array
+ val a1 = Array(1, 2, 3)
+ val _a1: Array[Int] = read(write(a1))
+ println("a1 = " + arrayToString(a1))
+ println("_a1 = " + arrayToString(_a1))
+ println("arrayEquals(a1, _a1): " + arrayEquals(a1, _a1))
+ println()
+
+ // Either
+ val e1 = Left(1)
+ val _e1: Either[Int, String] = read(write(e1))
+ println("e1 = " + e1)
+ println("_e1 = " + _e1)
+ println("e1 eq _e1: " + (e1 eq _e1) + ", _e1 eq e1: " + (_e1 eq e1))
+ println("e1 equals _e1: " + (e1 equals _e1) + ", _e1 equals e1: " + (_e1 equals e1))
+ println()
+
+ // Enumeration
+ val x7 = BigDecimal.RoundingMode
+ val y7: RoundingMode.type = read(write(x7))
+ println("x7 = " + x7)
+ println("y7 = " + y7)
+ println("x7 eq y7: " + (x7 eq y7) + ", y7 eq x7: " + (y7 eq x7))
+ println("x7 equals y7: " + (x7 equals y7) + ", y7 equals x7: " + (y7 equals x7))
+ println()
+
+ val x8 = WeekDay
+ val y8: WeekDay.type = read(write(x8))
+ println("x8 = " + x8)
+ println("y8 = " + y8)
+ println("x8 eq y8: " + (x8 eq y8) + ", y8 eq x8: " + (y8 eq x8))
+ println("x8 equals y8: " + (x8 equals y8) + ", y8 equals x8: " + (y8 equals x8))
+ println()
+
+ val x9 = UP
+ val y9: RoundingMode = read(write(x9))
+ println("x9 = " + x9)
+ println("y9 = " + y9)
+ println("x9 eq y9: " + (x9 eq y9) + ", y9 eq x9: " + (y9 eq x9))
+ println("x9 equals y9: " + (x9 equals y9) + ", y9 equals x9: " + (y9 equals x9))
+ println()
+
+ val x10 = Monday
+ val y10: WeekDay = read(write(x10))
+ println("x10 = " + x10)
+ println("y10 = " + y10)
+ println("x10 eq y10: " + (x10 eq y10) + ", y10 eq x10: " + (y10 eq x10))
+ println("x10 equals y10: " + (x10 equals y10) + ", y10 equals x10: " + (y10 equals x10))
+ println()
+
+ println("x9 eq x10: " + (x9 eq x10) + ", x10 eq x9: " + (x10 eq x9))
+ println("x9 equals x10: " + (x9 equals x10) + ", x10 equals x9: " + (x10 equals x9))
+ println("x9 eq y10: " + (x9 eq y10) + ", y10 eq x9: " + (y10 eq x9))
+ println("x9 equals y10: " + (x9 equals y10) + ", y10 equals x9: " + (y10 equals x9))
+ println()
+
+ // Function
+ val f1 = { x: Int => 2 * x }
+ val _f1: Function[Int, Int] = read(write(f1))
+ println("f1 = <na>")
+ println("_f1 = <na>")
+ println("f1(2): " + f1(2) + ", _f1(2): " + _f1(2))
+ println()
+
+ // List
+ val xs0 = List(1, 2, 3)
+ val _xs0: List[Int] = read(write(xs0))
+ println("xs0 = " + xs0)
+ println("_xs0 = " + _xs0)
+ println("xs0 eq _xs0: " + (xs0 eq _xs0) + ", _xs0 eq xs0: " + (_xs0 eq xs0))
+ println("xs0 equals _xs0: " + (xs0 equals _xs0) + ", _xs0 equals xs0: " + (_xs0 equals xs0))
+ println()
+
+ val xs1 = Nil
+ val _xs1: List[Nothing] = read(write(xs1))
+ println("xs1 = " + xs1)
+ println("_xs1 = " + _xs1)
+ println("xs1 eq _xs1: " + (xs1 eq _xs1) + ", _xs1 eq xs1: " + (_xs1 eq xs1))
+ println()
+
+ // Option
+ val o1 = None
+ val _o1: Option[Nothing] = read(write(o1))
+ println("o1 = " + o1)
+ println("_o1 = " + _o1)
+ println("o1 eq _o1: " + (o1 eq _o1) + ", _o1 eq o1: " + (_o1 eq o1))
+ println()
+
+ val o2 = Some(1)
+ val _o2: Option[Int] = read(write(o2))
+ println("o2 = " + o2)
+ println("_o2 = " + _o2)
+ println("o2 eq _o2: " + (o2 eq _o2) + ", _o2 eq o2: " + (_o2 eq o2))
+ println("o2 equals _o2: " + (o2 equals _o2) + ", _o2 equals o2: " + (_o2 equals o2))
+ println()
+/*
+ // Responder
+ val r1 = Responder.constant("xyz")
+ val _r1: Responder[String] = read(write(r1))
+ check(r1, _r1)
+*/
+ // Symbol
+ val s1 = 'hello
+ val _s1: Symbol = read(write(s1))
+ println("s1 = " + s1)
+ println("_s1 = " + _s1)
+ println("s1 eq _s1: " + (s1 eq _s1) + ", _s1 eq s1: " + (_s1 eq s1))
+ println("s1 equals _s1: " + (s1 equals _s1) + ", _s1 equals s1: " + (_s1 equals s1))
+ println()
+
+ // Tuple
+ val t1 = ("BannerLimit", 12345)
+ val _t1: (String, Int) = read(write(t1))
+ println("t1 = " + t1)
+ println("_t1 = " + _t1)
+ println("t1 eq _t1: " + (t1 eq _t1) + ", _t1 eq t1: " + (_t1 eq t1))
+ println("t1 equals _t1: " + (t1 equals _t1) + ", _t1 equals t1: " + (_t1 equals t1))
+ println()
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test1_scala: " + e)
+ throw e
+ }
+}
+
+//############################################################################
+// Test classes in package "scala.collection.immutable"
+
+object Test2_immutable {
+ import scala.collection.immutable.{
+ BitSet, HashMap, HashSet, ListMap, ListSet, Queue, Range, SortedMap,
+ SortedSet, Stack, Stream, TreeMap, TreeSet, Vector}
+
+ // in alphabetic order
+ try {
+ // BitSet
+ val bs1 = BitSet.empty + 1 + 2
+ val _bs1: BitSet = read(write(bs1))
+ check(bs1, _bs1)
+
+ val bs2 = {
+ val bs = new collection.mutable.BitSet()
+ bs += 2; bs += 3
+ bs.toImmutable
+ }
+ val _bs2: BitSet = read(write(bs2))
+ check(bs2, _bs2)
+
+ // HashMap
+ val hm1 = new HashMap[Int, String] + (1 -> "A", 2 -> "B", 3 -> "C")
+ val _hm1: HashMap[Int, String] = read(write(hm1))
+ check(hm1, _hm1)
+
+ // HashSet
+ val hs1 = new HashSet[Int] + 1 + 2
+ val _hs1: HashSet[Int] = read(write(hs1))
+ check(hs1, _hs1)
+
+ // List
+ val xs1 = List(("buffers", 20), ("layers", 2), ("title", 3))
+ val _xs1: List[(String, Int)] = read(write(xs1))
+ check(xs1, _xs1)
+
+ // ListMap
+ val lm1 = new ListMap[String, Int] + ("buffers" -> 20, "layers" -> 2, "title" -> 3)
+ val _lm1: ListMap[String, Int] = read(write(lm1))
+ check(lm1, _lm1)
+
+ // ListSet
+ val ls1 = new ListSet[Int] + 3 + 5
+ val _ls1: ListSet[Int] = read(write(ls1))
+ check(ls1, _ls1)
+
+ // Queue
+ val q1 = Queue("a", "b", "c")
+ val _q1: Queue[String] = read(write(q1))
+ check(q1, _q1)
+
+ // Range
+ val r1 = 0 until 10
+ val _r1: Range = read(write(r1))
+ check(r1, _r1)
+
+ val r2 = Range.Long(0L, 10L, 1)
+ val _r2: r2.type = read(write(r2))
+ check(r2, _r2)
+
+ // SortedMap
+ val sm1 = SortedMap.empty[Int, String] + (2 -> "B", 3 -> "C", 1 -> "A")
+ val _sm1: SortedMap[Int, String] = read(write(sm1))
+ check(sm1, _sm1)
+
+ // SortedSet
+ val ss1 = SortedSet.empty[Int] + 2 + 3 + 1
+ val _ss1: SortedSet[Int] = read(write(ss1))
+ check(ss1, _ss1)
+
+ // Stack
+ val s1 = new Stack().push("a", "b", "c")
+ val _s1: Stack[String] = read(write(s1))
+ check(s1, _s1)
+
+ // Stream
+ val st1 = Stream.range(0, 10)
+ val _st1: Stream[Int] = read(write(st1))
+ check(st1, _st1)
+
+ // TreeMap
+ val tm1 = new TreeMap[Int, String] + (42 -> "FortyTwo")
+ val _tm1: TreeMap[Int, String] = read(write(tm1))
+ check(tm1, _tm1)
+
+ // TreeSet
+ val ts1 = new TreeSet[Int]() + 2 + 0
+ val _ts1: TreeSet[Int] = read(write(ts1))
+ check(ts1, _ts1)
+
+ // Vector
+ val v1 = Vector('a, 'b, 'c)
+ val _v1: Vector[Symbol] = read(write(v1))
+ check(v1, _v1)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test2_immutable: " + e)
+ throw e
+ }
+}
+
+//############################################################################
+// Test classes in package "scala.collection.mutable"
+
+object Test3_mutable {
+ import scala.reflect.ArrayTag
+ import scala.collection.mutable.{
+ ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList,
+ HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue,
+ Stack, StringBuilder, WrappedArray, TreeSet}
+ import scala.collection.concurrent.TrieMap
+
+ // in alphabetic order
+ try {
+ // ArrayBuffer
+ val ab1 = new ArrayBuffer[String]
+ ab1 ++= List("one", "two")
+ val _ab1: ArrayBuffer[String] = read(write(ab1))
+ check(ab1, _ab1)
+
+ // ArrayBuilder
+ val abu1 = ArrayBuilder.make[Long]
+ val _abu1: ArrayBuilder[ArrayTag[Long]] = read(write(abu1))
+ check(abu1, _abu1)
+
+ val abu2 = ArrayBuilder.make[Float]
+ val _abu2: ArrayBuilder[ArrayTag[Float]] = read(write(abu2))
+ check(abu2, _abu2)
+
+ // ArraySeq
+ val aq1 = ArraySeq(1, 2, 3)
+ val _aq1: ArraySeq[Int] = read(write(aq1))
+ check(aq1, _aq1)
+
+ // ArrayStack
+ val as1 = new ArrayStack[Int]
+ as1 ++= List(20, 2, 3).iterator
+ val _as1: ArrayStack[Int] = read(write(as1))
+ check(as1, _as1)
+
+ // BitSet
+ val bs1 = new BitSet()
+ bs1 += 0
+ bs1 += 8
+ bs1 += 9
+ val _bs1: BitSet = read(write(bs1))
+ check(bs1, _bs1)
+/*
+ // DoubleLinkedList
+ val dl1 = new DoubleLinkedList[Int](2, null)
+ dl1.append(new DoubleLinkedList(3, null))
+ val _dl1: DoubleLinkedList[Int] = read(write(dl1))
+ check(dl1, _dl1)
+*/
+ // HashMap
+ val hm1 = new HashMap[String, Int]
+ hm1 ++= List(("A", 1), ("B", 2), ("C", 3)).iterator
+ val _hm1: HashMap[String, Int] = read(write(hm1))
+ check(hm1, _hm1)
+
+ // HashSet
+ val hs1 = new HashSet[String]
+ hs1 ++= List("layers", "buffers", "title").iterator
+ val _hs1: HashSet[String] = read(write(hs1))
+ check(hs1, _hs1)
+
+ val h1 = new History[String, Int]
+ val _h1: History[String, Int] = read(write(h1))
+ check(h1, _h1)
+/*
+ // LinkedList
+ val ll1 = new LinkedList[Int](2, null)
+ ll1.append(new LinkedList(3, null))
+ val _ll1: LinkedList[Int] = read(write(ll1))
+ check(ll1, _ll1)
+*/
+ // ListBuffer
+ val lb1 = new ListBuffer[String]
+ lb1 ++= List("white", "black")
+ val _lb1: ListBuffer[String] = read(write(lb1))
+ check(lb1, _lb1)
+
+ // Queue
+ val q1 = new Queue[Int]
+ q1 ++= List(20, 2, 3).iterator
+ val _q1: Queue[Int] = read(write(q1))
+ check(q1, _q1)
+
+ // Stack
+ val s1 = new Stack[Int]
+ s1 pushAll q1
+ val _s1: Stack[Int] = read(write(s1))
+ check(s1, _s1)
+
+ // StringBuilder
+ val sb1 = new StringBuilder
+ sb1 append "abc"
+ val _sb1: StringBuilder = read(write(sb1))
+ check(sb1, _sb1)
+
+ // WrappedArray
+ val wa1 = WrappedArray.make(Array(1, 2, 3))
+ val _wa1: WrappedArray[Int] = read(write(wa1))
+ check(wa1, _wa1)
+
+ // TreeSet
+ val ts1 = TreeSet[Int]() ++= Array(1, 2, 3)
+ val _ts1: TreeSet[Int] = read(write(ts1))
+ check(ts1, _ts1)
+
+ // concurrent.TrieMap
+ val ct1 = TrieMap[Int, String]() ++= Array(1 -> "one", 2 -> "two", 3 -> "three")
+ val _ct1: TrieMap[Int, String] = read(write(ct1))
+ check(ct1, _ct1)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test3_mutable: " + e)
+ throw e
+ }
+}
+
+
+//############################################################################
+// Test classes in package "scala.xml"
+
+object Test4_xml {
+ import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text}
+
+ case class Person(name: String, age: Int)
+
+ try {
+ // Attribute
+ val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null)
+ val _a1: Attribute = read(write(a1))
+ check(a1, _a1)
+
+ // Document
+ val d1 = new Document
+ d1.docElem = <title></title>
+ d1.encoding = Some("UTF-8")
+ val _d1: Document = read(write(d1))
+ check(d1, _d1)
+
+ // Elem
+ val e1 = <html><title>title</title><body></body></html>;
+ val _e1: Elem = read(write(e1))
+ check(e1, _e1)
+
+ class AddressBook(a: Person*) {
+ private val people: List[Person] = a.toList
+ def toXHTML =
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <th>Last Name</th>
+ <th>First Name</th>
+ </tr>
+ { for (p <- people) yield
+ <tr>
+ <td> { p.name } </td>
+ <td> { p.age.toString() } </td>
+ </tr> }
+ </table>;
+ }
+
+ val people = new AddressBook(
+ Person("Tom", 20),
+ Person("Bob", 22),
+ Person("James", 19))
+
+ val e2 =
+ <html>
+ <body>
+ { people.toXHTML }
+ </body>
+ </html>;
+ val _e2: Elem = read(write(e2))
+ check(e2, _e2)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test4_xml: " + e)
+ throw e
+ }
+}
+
+//############################################################################
+// Test user-defined classes WITHOUT nesting
+
+class Person(_name: String) extends Serializable {
+ private var name = _name
+ override def toString() = name
+ override def equals(that: Any): Boolean =
+ that.isInstanceOf[Person] &&
+ (name == that.asInstanceOf[Person].name)
+}
+
+class Employee(_name: String) extends Serializable {
+ private var name = _name
+ override def toString() = name
+}
+
+object bob extends Employee("Bob")
+
+object Test5 {
+ val x1 = new Person("Tim")
+ val x2 = bob
+
+ try {
+ val y1: Person = read(write(x1))
+ val y2: Employee = read(write(x2))
+
+ check(x1, y1)
+ check(x2, y2)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test5: " + e)
+ }
+}
+
+//############################################################################
+// Test user-defined classes WITH nesting
+
+object Test6 {
+ object bill extends Employee("Bill") {
+ val x = paul
+ }
+ object paul extends Person("Paul") {
+ val x = 4 // bill; => StackOverflowException !!!
+ }
+ val x1 = new Person("John")
+ val x2 = bill
+ val x3 = paul
+
+ try {
+ val y1: Person = read(write(x1))
+ val y2: Employee = read(write(x2))
+ val y3: Person = read(write(x3))
+
+ check(x1, y1)
+ check(x2, y2)
+ check(x3, y3)
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test6: " + e)
+ }
+}
+
+//############################################################################
+// Nested objects cannot get readresolve automatically because after deserialization
+// they would be null (they are treated as lazy vals)
+class Outer extends Serializable {
+ object Inner extends Serializable
+}
+
+object Test7 {
+ val x = new Outer
+ x.Inner // initialize
+ val y:Outer = read(write(x))
+ if (y.Inner == null)
+ println("Inner object is null")
+}
+
+// Verify that transient lazy vals don't get serialized
+class WithTransient extends Serializable {
+ @transient lazy val a1 = 1
+ @transient private lazy val a2 = 2
+ @transient object B extends Serializable
+ @transient private object C extends Serializable
+
+ def test = {
+ println(a1)
+ println(a2)
+ if (B == null || C == null)
+ println("Transient nested object failed to serialize properly")
+ }
+}
+
+object Test8 {
+ val x = new WithTransient
+ x.test
+ try {
+ val y:WithTransient = read(write(x))
+ y.test
+ }
+ catch {
+ case e: Exception =>
+ println("Error in Test8: " + e)
+ }
+}
+
+//############################################################################
+// Test code
+
+object Test {
+ def main(args: Array[String]) {
+ Test1_scala
+ Test2_immutable
+ Test3_mutable
+ Test4_xml
+ Test5
+ Test6
+ Test7
+ Test8
+ Test9_parallel
+ }
+}
+
+//############################################################################
+
+
+//############################################################################
+// Test classes in package "scala.collection.parallel" and subpackages
+object Test9_parallel {
+ import scala.collection.parallel._
+
+ try {
+ println()
+
+ // UnrolledBuffer
+ val ub = new collection.mutable.UnrolledBuffer[String]
+ ub ++= List("one", "two")
+ val _ub: collection.mutable.UnrolledBuffer[String] = read(write(ub))
+ check(ub, _ub)
+
+ // mutable.ParArray
+ val pa = mutable.ParArray("abc", "def", "etc")
+ val _pa: mutable.ParArray[String] = read(write(pa))
+ check(pa, _pa)
+
+ // mutable.ParHashMap
+ val mpm = mutable.ParHashMap(1 -> 2, 2 -> 4)
+ val _mpm: mutable.ParHashMap[Int, Int] = read(write(mpm))
+ check(mpm, _mpm)
+
+ // mutable.ParTrieMap
+ val mpc = mutable.ParTrieMap(1 -> 2, 2 -> 4)
+ val _mpc: mutable.ParTrieMap[Int, Int] = read(write(mpc))
+ check(mpc, _mpc)
+
+ // mutable.ParHashSet
+ val mps = mutable.ParHashSet(1, 2, 3)
+ val _mps: mutable.ParHashSet[Int] = read(write(mps))
+ check(mps, _mps)
+
+ // immutable.ParRange
+ val pr1 = immutable.ParRange(0, 4, 1, true)
+ val _pr1: immutable.ParRange = read(write(pr1))
+ check(pr1, _pr1)
+
+ val pr2 = immutable.ParRange(0, 4, 1, false)
+ val _pr2: immutable.ParRange = read(write(pr2))
+ check(pr2, _pr2)
+
+ // immutable.ParHashMap
+ val ipm = immutable.ParHashMap(5 -> 1, 10 -> 2)
+ val _ipm: immutable.ParHashMap[Int, Int] = read(write(ipm))
+ check(ipm, _ipm)
+
+ // immutable.ParHashSet
+ val ips = immutable.ParHashSet("one", "two")
+ val _ips: immutable.ParHashSet[String] = read(write(ips))
+ check(ips, _ips)
+
+ } catch {
+ case e: Exception =>
+ println("Error in Test5_parallel: " + e)
+ throw e
+ }
+}
diff --git a/test/files/jvm/si5471.check b/test/files/jvm/si5471.check
new file mode 100644
index 0000000000..bb101b641b
--- /dev/null
+++ b/test/files/jvm/si5471.check
@@ -0,0 +1,2 @@
+true
+true
diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/si5471.scala
new file mode 100644
index 0000000000..2c8c4205c5
--- /dev/null
+++ b/test/files/jvm/si5471.scala
@@ -0,0 +1,17 @@
+
+object Test {
+
+ def main(args: Array[String]) {
+ import scala.math.Numeric
+ import scala.math.Numeric.Implicits._
+
+ val b = BigInt(Long.MaxValue) + 1
+
+ def dbl[N :Numeric](n: N) = n.toDouble
+ def flt[N :Numeric](n: N) = n.toFloat
+
+ println(dbl(b) == b.toDouble)
+ println(flt(b) == b.toFloat)
+ }
+
+}
diff --git a/test/files/neg/classtags_contextbound_a.check b/test/files/neg/classtags_contextbound_a.check
index f4b6ff5af1..a4fd37506d 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 ClassTag available for T
+classtags_contextbound_a.scala:2: error: No ArrayTag available for T
def foo[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_contextbound_c.check b/test/files/neg/classtags_contextbound_c.check
index 54f630862a..a1c5eddfe1 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 ClassTag available for T
+classtags_contextbound_c.scala:2: error: No ArrayTag available for T
def mkArray[T] = Array[T]()
^
one error found
diff --git a/test/files/neg/classtags_dont_use_typetags.check b/test/files/neg/classtags_dont_use_typetags.check
new file mode 100644
index 0000000000..c7d2fba35b
--- /dev/null
+++ b/test/files/neg/classtags_dont_use_typetags.check
@@ -0,0 +1,4 @@
+classtags_dont_use_typetags.scala:2: error: No ArrayTag 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
new file mode 100644
index 0000000000..0f675f71aa
--- /dev/null
+++ b/test/files/neg/classtags_dont_use_typetags.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ def foo[T: TypeTag] = Array[T]()
+} \ 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
new file mode 100644
index 0000000000..d6fa564df4
--- /dev/null
+++ b/test/files/neg/interop_classmanifests_arenot_concretetypetags.check
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000000..5b1ed55e47
--- /dev/null
+++ b/test/files/neg/interop_classmanifests_arenot_concretetypetags.scala
@@ -0,0 +1,9 @@
+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_classtags_arenot_manifests.check b/test/files/neg/interop_classtags_arenot_manifests.check
new file mode 100644
index 0000000000..95f6a94d4b
--- /dev/null
+++ b/test/files/neg/interop_classtags_arenot_manifests.check
@@ -0,0 +1,7 @@
+interop_classtags_arenot_manifests.scala:3: 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
diff --git a/test/files/neg/interop_classtags_arenot_manifests.scala b/test/files/neg/interop_classtags_arenot_manifests.scala
new file mode 100644
index 0000000000..7351f7e305
--- /dev/null
+++ b/test/files/neg/interop_classtags_arenot_manifests.scala
@@ -0,0 +1,17 @@
+object Test extends App {
+ def arrayTagIsnotManifest[T: ArrayTag] = {
+ println(manifest[T])
+ }
+
+ arrayTagIsnotManifest[Int]
+ arrayTagIsnotManifest[String]
+ arrayTagIsnotManifest[Array[Int]]
+
+ def classTagIsnotManifest[T: ClassTag] = {
+ println(manifest[T])
+ }
+
+ classTagIsnotManifest[Int]
+ classTagIsnotManifest[String]
+ classTagIsnotManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.check b/test/files/neg/interop_erasuretags_arenot_classmanifests.check
new file mode 100644
index 0000000000..4bb81108d1
--- /dev/null
+++ b/test/files/neg/interop_erasuretags_arenot_classmanifests.check
@@ -0,0 +1,4 @@
+interop_erasuretags_arenot_classmanifests.scala:3: error: could not find implicit value for parameter m: ClassManifest[T]
+ println(classManifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_erasuretags_arenot_classmanifests.scala b/test/files/neg/interop_erasuretags_arenot_classmanifests.scala
new file mode 100644
index 0000000000..cf7d1ac257
--- /dev/null
+++ b/test/files/neg/interop_erasuretags_arenot_classmanifests.scala
@@ -0,0 +1,9 @@
+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.check b/test/files/neg/interop_erasuretags_arenot_manifests.check
new file mode 100644
index 0000000000..da3c03d371
--- /dev/null
+++ b/test/files/neg/interop_erasuretags_arenot_manifests.check
@@ -0,0 +1,4 @@
+interop_erasuretags_arenot_manifests.scala:3: error: No Manifest available for T.
+ println(manifest[T])
+ ^
+one error found
diff --git a/test/files/neg/interop_erasuretags_arenot_manifests.scala b/test/files/neg/interop_erasuretags_arenot_manifests.scala
new file mode 100644
index 0000000000..5c326549d8
--- /dev/null
+++ b/test/files/neg/interop_erasuretags_arenot_manifests.scala
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..9ed4fd43d4
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_classmanifests.check
@@ -0,0 +1,4 @@
+interop_typetags_arenot_classmanifests.scala:3: 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
new file mode 100644
index 0000000000..b1fbb7b5a6
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_classmanifests.scala
@@ -0,0 +1,9 @@
+object Test extends App {
+ def typeTagIsnotClassManifest[T: TypeTag] = {
+ println(classManifest[T])
+ }
+
+ typeTagIsnotClassManifest[Int]
+ typeTagIsnotClassManifest[String]
+ typeTagIsnotClassManifest[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
new file mode 100644
index 0000000000..7761a747ff
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_manifests.check
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000000..4e2a04489b
--- /dev/null
+++ b/test/files/neg/interop_typetags_arenot_manifests.scala
@@ -0,0 +1,9 @@
+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/macro-invalidret-nontree.check b/test/files/neg/macro-invalidret-nontree.check
index 7fcc396463..0b793cf421 100644
--- a/test/files/neg/macro-invalidret-nontree.check
+++ b/test/files/neg/macro-invalidret-nontree.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.makro.Context): Int
-type mismatch for return type : c.Expr[Any] does not conform to Int
- 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.makro.Context): Int
+type mismatch for return type: Int does not conform to c.Expr[Any]
+ def foo = macro Impls.foo
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check
index a97d6daaa9..4fc06b5ceb 100644
--- a/test/files/neg/macro-invalidret-nonuniversetree.check
+++ b/test/files/neg/macro-invalidret-nonuniversetree.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.makro.Context): reflect.mirror.Literal
-type mismatch for return type : c.Expr[Any] does not conform to reflect.mirror.Literal
- 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.makro.Context): reflect.mirror.Literal
+type mismatch for return type: reflect.mirror.Literal does not conform to c.Expr[Any]
+ def foo = macro Impls.foo
+ ^
+one error found
diff --git a/test/files/neg/t2386.check b/test/files/neg/t2386.check
deleted file mode 100644
index f70f12535f..0000000000
--- a/test/files/neg/t2386.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t2386.scala:2: error: No ClassTag available for Array[_ >: String with Int]
- val a = Array(Array(1, 2), Array("a","b"))
- ^
-one error found
diff --git a/test/files/neg/t2386.scala b/test/files/neg/t2386.scala
deleted file mode 100644
index 56146cc5c3..0000000000
--- a/test/files/neg/t2386.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- val a = Array(Array(1, 2), Array("a","b"))
-}
diff --git a/test/files/neg/t3507-old.check b/test/files/neg/t3507-old.check
new file mode 100644
index 0000000000..5c58444cb3
--- /dev/null
+++ b/test/files/neg/t3507-old.check
@@ -0,0 +1,4 @@
+t3507-old.scala:13: error: No Manifest available for _1.b.c.type.
+ mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier
+ ^
+one error found
diff --git a/test/files/neg/t3507-old.scala b/test/files/neg/t3507-old.scala
new file mode 100644
index 0000000000..32688d3934
--- /dev/null
+++ b/test/files/neg/t3507-old.scala
@@ -0,0 +1,15 @@
+class A {
+ object b {
+ object c
+ }
+ def m = b.c
+}
+
+object Test {
+ var a: A = new A // mutable
+ val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential
+
+ def mani[T: Manifest](x: 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/neg/t3692-new.check b/test/files/neg/t3692-new.check
new file mode 100644
index 0000000000..e013daca74
--- /dev/null
+++ b/test/files/neg/t3692-new.check
@@ -0,0 +1,4 @@
+t3692-new.scala:15: error: unreachable code
+ case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
+ ^
+one error found
diff --git a/test/files/neg/t3692.flags b/test/files/neg/t3692-new.flags
index 82becdfbfd..82becdfbfd 100644
--- a/test/files/neg/t3692.flags
+++ b/test/files/neg/t3692-new.flags
diff --git a/test/files/neg/t3692-new.scala b/test/files/neg/t3692-new.scala
new file mode 100644
index 0000000000..46874b02e3
--- /dev/null
+++ b/test/files/neg/t3692-new.scala
@@ -0,0 +1,19 @@
+import java.lang.Integer
+
+object Tester {
+ def main(args: Array[String]) = {
+ val map = Map("John" -> 1, "Josh" -> 2)
+ new Tester().toJavaMap(map)
+ }
+}
+
+class Tester {
+ private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: ClassTag[T], m2: ClassTag[V]): java.util.Map[_, _] = {
+ map match {
+ case m0: Map[Int, Int] => new java.util.HashMap[Integer, Integer]
+ case m1: Map[Int, V] => new java.util.HashMap[Integer, V]
+ case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
+ case _ => new java.util.HashMap[T, V]
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t3692-old.check b/test/files/neg/t3692-old.check
new file mode 100644
index 0000000000..9da7033239
--- /dev/null
+++ b/test/files/neg/t3692-old.check
@@ -0,0 +1,8 @@
+t3692-old.scala:6: warning: object Manifest in package reflect is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
+ new ManifestTester().toJavaMap(map)
+ ^
+t3692-old.scala:15: error: unreachable code
+ case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
+ ^
+one warning found
+one error found
diff --git a/test/files/neg/t3692-old.flags b/test/files/neg/t3692-old.flags
new file mode 100644
index 0000000000..82becdfbfd
--- /dev/null
+++ b/test/files/neg/t3692-old.flags
@@ -0,0 +1 @@
+ -Xoldpatmat \ No newline at end of file
diff --git a/test/files/neg/t3692.scala b/test/files/neg/t3692-old.scala
index 151535ae94..151535ae94 100644
--- a/test/files/neg/t3692.scala
+++ b/test/files/neg/t3692-old.scala
diff --git a/test/files/neg/t3692.check b/test/files/neg/t3692.check
deleted file mode 100644
index d83abd31e2..0000000000
--- a/test/files/neg/t3692.check
+++ /dev/null
@@ -1,11 +0,0 @@
-t3692.scala:11: warning: type Manifest in object Predef is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
- private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
- ^
-t3692.scala:11: warning: type Manifest in object Predef is deprecated: Use `@scala.reflect.ConcreteTypeTag` instead
- private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = {
- ^
-t3692.scala:15: error: unreachable code
- case m2: Map[T, Int] => new java.util.HashMap[T, Integer]
- ^
-two warnings found
-one error found
diff --git a/test/files/neg/t5452-new.check b/test/files/neg/t5452-new.check
new file mode 100644
index 0000000000..bbd3734f74
--- /dev/null
+++ b/test/files/neg/t5452-new.check
@@ -0,0 +1,8 @@
+t5452-new.scala:28: 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
+ cannot be applied to (Queryable[CoffeesTable])
+ Queryable[CoffeesTable]( q.treeFilter(null) )
+ ^
+one error found
diff --git a/test/files/neg/t5452-new.scala b/test/files/neg/t5452-new.scala
new file mode 100644
index 0000000000..c829de7d7c
--- /dev/null
+++ b/test/files/neg/t5452-new.scala
@@ -0,0 +1,29 @@
+// /scala/trac/5452/a.scala
+// Mon Feb 13 22:52:36 PST 2012
+
+// import scala.reflect.mirror._
+
+trait Tree
+
+object Bip {
+ def ??? = sys.error("")
+}
+import Bip._
+
+case class Queryable[T]() {
+ def treeFilter( t:Tree ) : Queryable[T] = ???
+}
+
+object Queryable {
+ def apply[T:ClassTag] = ???
+ def apply[T:ClassTag]( t:Tree ) = ???
+}
+
+trait CoffeesTable{
+ def sales : Int
+}
+
+object Test extends App{
+ val q = new Queryable[CoffeesTable]
+ Queryable[CoffeesTable]( q.treeFilter(null) )
+}
diff --git a/test/files/neg/t5452.check b/test/files/neg/t5452-old.check
index 2f35a45509..e5872a5759 100644
--- a/test/files/neg/t5452.check
+++ b/test/files/neg/t5452-old.check
@@ -1,8 +1,8 @@
-t5452.scala:28: error: overloaded method value apply with alternatives:
- ()Queryable[CoffeesTable] <and>
- (t: Tree)(implicit evidence$2: Manifest[CoffeesTable])Nothing <and>
- (implicit evidence$1: Manifest[CoffeesTable])Nothing
- cannot be applied to (Queryable[CoffeesTable])
- Queryable[CoffeesTable]( q.treeFilter(null) )
- ^
-one error found
+t5452-old.scala:28: error: overloaded method value apply with alternatives:
+ ()Queryable[CoffeesTable] <and>
+ (t: Tree)(implicit evidence$2: Manifest[CoffeesTable])Nothing <and>
+ (implicit evidence$1: Manifest[CoffeesTable])Nothing
+ cannot be applied to (Queryable[CoffeesTable])
+ Queryable[CoffeesTable]( q.treeFilter(null) )
+ ^
+one error found
diff --git a/test/files/neg/t5452.scala b/test/files/neg/t5452-old.scala
index 1032db7a4b..1032db7a4b 100644
--- a/test/files/neg/t5452.scala
+++ b/test/files/neg/t5452-old.scala
diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check
index f286d08cfa..6abc4c13f6 100644
--- a/test/files/neg/t5689.check
+++ b/test/files/neg/t5689.check
@@ -1,7 +1,7 @@
t5689.scala:4: error: macro implementation has wrong shape:
required: (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[String]
found : (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[Int]
-type mismatch for return type : c.Expr[String] does not conform to c.Expr[Int]
+type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String]
def returnsString(i: Double): String = macro returnsIntImpl
^
one error found
diff --git a/test/files/pos/contextbounds-implicits-new.scala b/test/files/pos/contextbounds-implicits-new.scala
new file mode 100644
index 0000000000..71b3cca36f
--- /dev/null
+++ b/test/files/pos/contextbounds-implicits-new.scala
@@ -0,0 +1,8 @@
+/* Tests implicit parameters in the presence of context bounds.
+ * See Section 7.4 of the Scala Language Specification.
+ */
+class C {
+
+ def f[T: TypeTag, S: TypeTag](x: T, y: S)(implicit p: C) { }
+
+}
diff --git a/test/files/pos/contextbounds-implicits.scala b/test/files/pos/contextbounds-implicits-old.scala
index f9113ee320..f9113ee320 100644
--- a/test/files/pos/contextbounds-implicits.scala
+++ b/test/files/pos/contextbounds-implicits-old.scala
diff --git a/test/files/pos/implicits-new.scala b/test/files/pos/implicits-new.scala
new file mode 100644
index 0000000000..7eb7e100c3
--- /dev/null
+++ b/test/files/pos/implicits-new.scala
@@ -0,0 +1,89 @@
+// #1435
+object t1435 {
+ implicit def a(s:String):String = error("")
+ implicit def a(i:Int):String = error("")
+ implicit def b(i:Int):String = error("")
+}
+
+class C1435 {
+ val v:String = {
+ import t1435.a
+ 2
+ }
+}
+
+// #1492
+class C1492 {
+
+ class X
+
+ def foo(x: X => X) {}
+
+ foo ( implicit x => implicitly[X] )
+ foo { implicit x => implicitly[X] }
+}
+
+// #1579
+object Test1579 {
+ class Column
+ class Query[E](val value: E)
+ class Invoker(q: Any) { val foo = null }
+
+ implicit def unwrap[C](q: Query[C]) = q.value
+ implicit def invoker(q: Query[Column]) = new Invoker(q)
+
+ val q = new Query(new Column)
+ q.foo
+}
+// #1625
+object Test1625 {
+
+ class Wrapped(x:Any) {
+ def unwrap() = x
+ }
+
+ implicit def byName[A](x: =>A) = new Wrapped(x)
+
+ implicit def byVal[A](x: A) = x
+
+ def main(args: Array[String]) = {
+
+// val res:Wrapped = 7 // works
+
+ val res = 7.unwrap() // doesn't work
+
+ println("=> result: " + res)
+ }
+}
+
+object Test2188 {
+ implicit def toJavaList[A: ArrayTag](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*)
+
+ val x: java.util.List[String] = List("foo")
+}
+
+object TestNumericWidening {
+ val y = 1
+ val x: java.lang.Long = y
+}
+
+// #2709
+package foo2709 {
+ class A
+ class B
+
+ package object bar {
+ implicit def a2b(a: A): B = new B
+ }
+
+ package bar {
+ object test {
+ new A: B
+ }
+ }
+}
+
+// Problem with specs
+object specsProblem {
+ println(implicitly[ConcreteTypeTag[Class[_]]])
+}
diff --git a/test/files/pos/implicits.scala b/test/files/pos/implicits-old.scala
index 2c01dd0ba8..2c01dd0ba8 100644
--- a/test/files/pos/implicits.scala
+++ b/test/files/pos/implicits-old.scala
diff --git a/test/files/pos/manifest1-new.scala b/test/files/pos/manifest1-new.scala
new file mode 100644
index 0000000000..645bd42665
--- /dev/null
+++ b/test/files/pos/manifest1-new.scala
@@ -0,0 +1,21 @@
+import scala.reflect.TypeTag
+
+object Test {
+ def foo[T](x: T)(implicit m: TypeTag[T]) {
+ foo(List(x))
+ }
+ foo(1)
+ foo("abc")
+ foo(List(1, 2, 3))
+ val x: List[Int] with Ordered[List[Int]] = null
+ foo(x)
+ foo[x.type](x)
+ abstract class C { type T = String; val x: T }
+ val c = new C { val x = "abc" }
+ foo(c.x)
+ abstract class D { type T; implicit val m: TypeTag[T]; val x: T }
+ val stringm = implicitly[TypeTag[String]]
+ val d: D = new D { type T = String; val m = stringm; val x = "x" }
+ import d.m
+ foo(d.x)
+}
diff --git a/test/files/pos/manifest1.scala b/test/files/pos/manifest1-old.scala
index 8901aa7437..8901aa7437 100644
--- a/test/files/pos/manifest1.scala
+++ b/test/files/pos/manifest1-old.scala
diff --git a/test/files/pos/nothing_manifest_disambig-new.scala b/test/files/pos/nothing_manifest_disambig-new.scala
new file mode 100644
index 0000000000..a60b0fdbf8
--- /dev/null
+++ b/test/files/pos/nothing_manifest_disambig-new.scala
@@ -0,0 +1,10 @@
+object Test {
+ def mani[T: TypeTag](xs: T) = xs
+ mani(List())
+
+ def listElMani[T: TypeTag](xs: List[T]) = xs
+ listElMani(List())
+
+ def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: TypeTag[A]): (C, A, TypeTag[A]) = (m, m.head, mani)
+ foo(List(1,2,3))
+} \ No newline at end of file
diff --git a/test/files/pos/nothing_manifest_disambig.scala b/test/files/pos/nothing_manifest_disambig-old.scala
index 076742033f..076742033f 100644
--- a/test/files/pos/nothing_manifest_disambig.scala
+++ b/test/files/pos/nothing_manifest_disambig-old.scala
diff --git a/test/files/pos/spec-constr-new.scala b/test/files/pos/spec-constr-new.scala
new file mode 100644
index 0000000000..7cd02b0680
--- /dev/null
+++ b/test/files/pos/spec-constr-new.scala
@@ -0,0 +1,7 @@
+class SparseArray2[@specialized(Int) T:ArrayTag](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;
+}
diff --git a/test/files/pos/spec-constr.scala b/test/files/pos/spec-constr-old.scala
index e908b65a41..e908b65a41 100644
--- a/test/files/pos/spec-constr.scala
+++ b/test/files/pos/spec-constr-old.scala
diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala
new file mode 100644
index 0000000000..33f1e82b6e
--- /dev/null
+++ b/test/files/pos/spec-doubledef-new.scala
@@ -0,0 +1,28 @@
+object Test {
+ def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T =
+ null.asInstanceOf[T]
+}
+
+trait A[@specialized(Int) T] {
+ var value: T
+ def getWith[@specialized(Int) Z](f: T => Z) = f(value)
+}
+
+class C extends A[Int] {
+ var value = 10
+ override def getWith[@specialized(Int) Z](f: Int => Z) = f(value)
+}
+
+abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int) V <% Ordered[V]] {
+ val u: U
+ val v: V
+
+ def f(t: T, v2: V): Pair[U, V] = {
+ val m: Array[U] = null
+ if (m.isEmpty) {
+ Pair(u, v)
+ } else {
+ Pair(u, v2)
+ }
+ }
+}
diff --git a/test/files/pos/spec-doubledef.scala b/test/files/pos/spec-doubledef-old.scala
index 86b0d857d3..86b0d857d3 100644
--- a/test/files/pos/spec-doubledef.scala
+++ b/test/files/pos/spec-doubledef-old.scala
diff --git a/test/files/pos/spec-fields-new.scala b/test/files/pos/spec-fields-new.scala
new file mode 100644
index 0000000000..ddd8bd6624
--- /dev/null
+++ b/test/files/pos/spec-fields-new.scala
@@ -0,0 +1,10 @@
+abstract class Foo[@specialized T: ArrayTag, U <: Ordered[U]](x: T, size: Int) {
+ var y: T
+ var z: T = x
+
+ def initialSize = 16
+ val array = new Array[T](initialSize + size)
+
+ def getZ = z
+ def setZ(zz: T) = z = zz
+}
diff --git a/test/files/pos/spec-fields.scala b/test/files/pos/spec-fields-old.scala
index 26a8c4ffbd..26a8c4ffbd 100644
--- a/test/files/pos/spec-fields.scala
+++ b/test/files/pos/spec-fields-old.scala
diff --git a/test/files/pos/spec-params-new.scala b/test/files/pos/spec-params-new.scala
new file mode 100644
index 0000000000..5fe0c82d40
--- /dev/null
+++ b/test/files/pos/spec-params-new.scala
@@ -0,0 +1,32 @@
+class Foo[@specialized A: ArrayTag] {
+
+ // conflicting in bounds, expect a normalized member calling m
+ // and bridge + implementation in specialized subclasses
+ // and overloads here according to specialization on A
+ def m1[@specialized B <: A](x: B, y: A) =
+ goal(x)
+
+ // conflicting, unsolvable, expect a warning
+ def m2[@specialized B <: String](x: B) = x.concat("a")
+
+ // conflicting in bounds, no mention of other spec members
+ // expect an overload here plus implementation in
+ // compatible specialized subclasses
+ def m3[@specialized B >: A](x: B) = ()
+
+ // non-conflicting, expect a normalized overload implementation here
+ def m4[@specialized T, U <: Ordered[T]](x: T, y: U) = ()
+
+ // non-conflicting, expect a normalized overload implementation here
+ def m5[@specialized B](x: B) = x
+
+ // non-conflicting, expect a normalized implementation here
+ // and specialized implementations for all expansions in specialized subclasses
+ def m6[@specialized B](x: B, y: A) =
+ goal(y)
+
+ def goal(x: A) = {
+ val xs = new Array[A](1)
+ xs(0) = x
+ }
+}
diff --git a/test/files/pos/spec-params.scala b/test/files/pos/spec-params-old.scala
index f522512846..f522512846 100644
--- a/test/files/pos/spec-params.scala
+++ b/test/files/pos/spec-params-old.scala
diff --git a/test/files/pos/spec-sparsearray-new.scala b/test/files/pos/spec-sparsearray-new.scala
new file mode 100644
index 0000000000..0659bf7926
--- /dev/null
+++ b/test/files/pos/spec-sparsearray-new.scala
@@ -0,0 +1,24 @@
+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]] {
+ override def get(x: Int) = {
+ val ind = findOffset(x)
+ if(ind < 0) None else Some(error("ignore"))
+ }
+
+ /**
+ * Returns the offset into index and data for the requested vector
+ * index. If the requested index is not found, the return value is
+ * negative and can be converted into an insertion point with -(rv+1).
+ */
+ private def findOffset(i : Int) : Int = {
+ error("impl doesn't matter")
+ }
+
+ override def apply(i : Int) : T = { error("ignore") }
+ override def update(i : Int, value : T) = error("ignore")
+ override def empty = new SparseArray[T]
+ def -=(ind: Int) = error("ignore")
+ def +=(kv: (Int,T)) = error("ignore")
+ override final def iterator = error("ignore")
+}
diff --git a/test/files/pos/spec-sparsearray.scala b/test/files/pos/spec-sparsearray-old.scala
index ea7710a785..ea7710a785 100644
--- a/test/files/pos/spec-sparsearray.scala
+++ b/test/files/pos/spec-sparsearray-old.scala
diff --git a/test/files/pos/t1381-new.scala b/test/files/pos/t1381-new.scala
new file mode 100644
index 0000000000..8781ef4fdb
--- /dev/null
+++ b/test/files/pos/t1381-new.scala
@@ -0,0 +1,31 @@
+import scala.reflect.TypeTag
+
+class D[V <: Variable]
+
+class ID[V<:IV] extends D[V] {
+ type E = V#ValueType
+ def index(value:E) : Int = 0
+ // Comment this out to eliminate crash. Or see below
+ def index(values:E*) : Iterable[Int] = null
+}
+
+abstract class Variable {
+ type VT <: Variable
+ def d : D[VT] = null
+}
+
+abstract class PV[T](initval:T) extends Variable {
+ type VT <: PV[T]
+ type ValueType = T
+}
+
+trait IV extends Variable {
+ type ValueType
+}
+
+abstract class EV[T](initval:T) extends PV[T](initval) with IV {
+ type VT <: EV[T]
+ override def d : ID[VT] = null
+ // Comment this out to eliminate crash
+ protected var indx = d.index(initval)
+}
diff --git a/test/files/pos/t1381.scala b/test/files/pos/t1381-old.scala
index 0762891898..0762891898 100644
--- a/test/files/pos/t1381.scala
+++ b/test/files/pos/t1381-old.scala
diff --git a/test/files/pos/t2795-new.scala b/test/files/pos/t2795-new.scala
new file mode 100644
index 0000000000..af9c4e8b1c
--- /dev/null
+++ b/test/files/pos/t2795-new.scala
@@ -0,0 +1,17 @@
+package t1
+
+trait Element[T] {
+}
+
+trait Config {
+ type T <: Element[T]
+ implicit val m: ArrayTag[T]
+ // XXX Following works fine:
+ // type T <: Element[_]
+}
+
+trait Transform { self: Config =>
+ def processBlock(block: Array[T]): Unit = {
+ var X = new Array[T](1)
+ }
+}
diff --git a/test/files/pos/t2795.scala b/test/files/pos/t2795-old.scala
index 935cb1f444..935cb1f444 100644
--- a/test/files/pos/t2795.scala
+++ b/test/files/pos/t2795-old.scala
diff --git a/test/files/pos/t3363-new.scala b/test/files/pos/t3363-new.scala
new file mode 100644
index 0000000000..270462745c
--- /dev/null
+++ b/test/files/pos/t3363-new.scala
@@ -0,0 +1,18 @@
+object TestCase {
+
+ //now matter if you put (abstract) class or trait it will fail in all cases
+ trait MapOps[T]
+
+ //if fs was reduced to List (generic type with one parameter) then the code compiles
+ //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine
+ implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] {
+ //if you remove this line, then code compiles
+ lazy val m: TypeTag[T] = error("just something to make it compile")
+ def is(xs: List[T]) = List(xs)
+ }
+
+ def main(args: Array[String]) {
+ println(Map(1 -> "2") is List(2))
+ }
+
+ }
diff --git a/test/files/pos/t3363.scala b/test/files/pos/t3363-old.scala
index bae54084ea..bae54084ea 100755..100644
--- a/test/files/pos/t3363.scala
+++ b/test/files/pos/t3363-old.scala
diff --git a/test/files/pos/t3498-new.scala b/test/files/pos/t3498-new.scala
new file mode 100644
index 0000000000..653c50042a
--- /dev/null
+++ b/test/files/pos/t3498-new.scala
@@ -0,0 +1,15 @@
+abstract class A[T, @specialized(scala.Int) U : ArrayTag] {
+ def f(state: T): Array[U]
+}
+
+abstract class B extends A[ Array[Byte], Int ] {
+ type T = Array[Byte]
+ type U = Int
+
+ val N = 0
+
+ def f(state: T): Array[U] =
+ {
+ new Array[U](N + state(N))
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t3498.scala b/test/files/pos/t3498-old.scala
index bcc90ca64c..bcc90ca64c 100644
--- a/test/files/pos/t3498.scala
+++ b/test/files/pos/t3498-old.scala
diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check
index ae202001eb..2b48a80d38 100644
--- a/test/files/presentation/ide-bug-1000531.check
+++ b/test/files/presentation/ide-bug-1000531.check
@@ -99,7 +99,7 @@ retrieved 123 members
`method synchronized[T0](x$1: T0)T0`
`method take(n: Int)Iterator[B]`
`method takeWhile(p: B => Boolean)Iterator[B]`
-`method toArray[B >: B](implicit evidence$1: ClassManifest[B])Array[B]`
+`method toArray[B >: B](implicit evidence$1: ArrayTag[B])Array[B]`
`method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]`
`method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]`
`method toIterable=> Iterable[B]`
diff --git a/test/files/run/arrayclone-new.scala b/test/files/run/arrayclone-new.scala
new file mode 100644
index 0000000000..a4ba021409
--- /dev/null
+++ b/test/files/run/arrayclone-new.scala
@@ -0,0 +1,106 @@
+object Test extends App{
+ BooleanArrayClone;
+ ByteArrayClone;
+ ShortArrayClone;
+ CharArrayClone;
+ IntArrayClone;
+ LongArrayClone;
+ FloatArrayClone;
+ DoubleArrayClone;
+ ObjectArrayClone;
+ PolymorphicArrayClone;
+}
+
+object BooleanArrayClone{
+ val it : Array[Boolean] = Array(true, false);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = false;
+ assert(it(0) == true)
+}
+
+object ByteArrayClone{
+ val it : Array[Byte] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object ShortArrayClone{
+ val it : Array[Short] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object CharArrayClone{
+ val it : Array[Char] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object IntArrayClone{
+ val it : Array[Int] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object LongArrayClone{
+ val it : Array[Long] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object FloatArrayClone{
+ val it : Array[Float] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object DoubleArrayClone{
+ val it : Array[Double] = Array(1, 0);
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = 0;
+ assert(it(0) == 1)
+}
+
+object ObjectArrayClone{
+ val it : Array[String] = Array("1", "0");
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = "0";
+ assert(it(0) == "1")
+}
+
+object PolymorphicArrayClone{
+ def testIt[T](it : Array[T], one : T, zero : T) = {
+ val cloned = it.clone();
+ assert(cloned.sameElements(it));
+ cloned(0) = zero;
+ assert(it(0) == one)
+ }
+
+ testIt(Array("one", "two"), "one", "two");
+
+ class Mangler[T: ArrayTag](ts : T*){
+ // this will always be a BoxedAnyArray even after we've unboxed its contents.
+ val it = ts.toArray[T];
+ }
+
+ val mangled = new Mangler[Int](0, 1);
+
+ val y : Array[Int] = mangled.it; // make sure it's unboxed
+
+ testIt(mangled.it, 0, 1);
+}
diff --git a/test/files/run/arrayclone.scala b/test/files/run/arrayclone-old.scala
index c9f7556b47..c9f7556b47 100644
--- a/test/files/run/arrayclone.scala
+++ b/test/files/run/arrayclone-old.scala
diff --git a/test/files/run/arraytags_basic.check b/test/files/run/arraytags_basic.check
new file mode 100644
index 0000000000..92816b91bd
--- /dev/null
+++ b/test/files/run/arraytags_basic.check
@@ -0,0 +1,36 @@
+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
new file mode 100644
index 0000000000..edc20e9bc1
--- /dev/null
+++ b/test/files/run/arraytags_basic.scala
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 0000000000..82ed84ad78
--- /dev/null
+++ b/test/files/run/arraytags_core.check
@@ -0,0 +1,48 @@
+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
new file mode 100644
index 0000000000..a59ae24f30
--- /dev/null
+++ b/test/files/run/arraytags_core.scala
@@ -0,0 +1,50 @@
+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
new file mode 100644
index 0000000000..b1d02b7bfe
--- /dev/null
+++ b/test/files/run/arraytags_usage.check
@@ -0,0 +1,3 @@
+class [I
+class [I
+class [I
diff --git a/test/files/run/arraytags_usage.scala b/test/files/run/arraytags_usage.scala
new file mode 100644
index 0000000000..60b0a8f218
--- /dev/null
+++ b/test/files/run/arraytags_usage.scala
@@ -0,0 +1,15 @@
+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/classtags_core.check b/test/files/run/classtags_core.check
index ce5a893b08..ebccfcd54c 100644
--- a/test/files/run/classtags_core.check
+++ b/test/files/run/classtags_core.check
@@ -1,30 +1,32 @@
-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 java.lang.Object)
-true
-ClassTag(class java.lang.Object)
+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]
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala
index 45c54b1fe0..9f2031377d 100644
--- a/test/files/run/classtags_core.scala
+++ b/test/files/run/classtags_core.scala
@@ -29,4 +29,6 @@ object Test extends App {
println(implicitly[ClassTag[Null]])
println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing)
println(implicitly[ClassTag[Nothing]])
+ println(implicitly[ClassTag[String]] eq ClassTag.String)
+ println(implicitly[ClassTag[String]])
} \ No newline at end of file
diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check
new file mode 100644
index 0000000000..3a7f16c3a0
--- /dev/null
+++ b/test/files/run/classtags_multi.check
@@ -0,0 +1,5 @@
+ClassTag[int]
+ClassTag[class [I]
+ClassTag[class [[I]
+ClassTag[class [[[I]
+ClassTag[class [[[[I]
diff --git a/test/files/run/classtags_multi.scala b/test/files/run/classtags_multi.scala
new file mode 100644
index 0000000000..5aafb55223
--- /dev/null
+++ b/test/files/run/classtags_multi.scala
@@ -0,0 +1,7 @@
+object Test extends App {
+ println(classTag[Int])
+ println(classTag[Array[Int]])
+ println(classTag[Array[Array[Int]]])
+ println(classTag[Array[Array[Array[Int]]]])
+ println(classTag[Array[Array[Array[Array[Int]]]]])
+} \ No newline at end of file
diff --git a/test/files/run/classtags_use_concretetypetags.scala b/test/files/run/classtags_use_concretetypetags.scala
new file mode 100644
index 0000000000..57e7085cec
--- /dev/null
+++ b/test/files/run/classtags_use_concretetypetags.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ def foo[T: ConcreteTypeTag] = Array[T]()
+} \ No newline at end of file
diff --git a/test/files/run/groundtypetags_core.check b/test/files/run/concretetypetags_core.check
index 62fcb481ae..f124aa6a35 100644
--- a/test/files/run/groundtypetags_core.check
+++ b/test/files/run/concretetypetags_core.check
@@ -1,30 +1,32 @@
-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[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/groundtypetags_core.scala b/test/files/run/concretetypetags_core.scala
index 8b81a0c795..b6cfea3895 100644
--- a/test/files/run/groundtypetags_core.scala
+++ b/test/files/run/concretetypetags_core.scala
@@ -29,4 +29,6 @@ object Test extends App {
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]])
} \ No newline at end of file
diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/concretetypetags_multi.check
new file mode 100644
index 0000000000..613106985c
--- /dev/null
+++ b/test/files/run/concretetypetags_multi.check
@@ -0,0 +1,5 @@
+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/concretetypetags_multi.scala b/test/files/run/concretetypetags_multi.scala
new file mode 100644
index 0000000000..7e19d7db34
--- /dev/null
+++ b/test/files/run/concretetypetags_multi.scala
@@ -0,0 +1,7 @@
+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]]]]])
+} \ No newline at end of file
diff --git a/test/files/run/ctries/DumbHash.scala b/test/files/run/ctries-new/DumbHash.scala
index 8ef325b67c..8ef325b67c 100644
--- a/test/files/run/ctries/DumbHash.scala
+++ b/test/files/run/ctries-new/DumbHash.scala
diff --git a/test/files/run/ctries/Wrap.scala b/test/files/run/ctries-new/Wrap.scala
index 7b645c1612..7b645c1612 100644
--- a/test/files/run/ctries/Wrap.scala
+++ b/test/files/run/ctries-new/Wrap.scala
diff --git a/test/files/run/ctries/concmap.scala b/test/files/run/ctries-new/concmap.scala
index 3ec0256afb..3ec0256afb 100644
--- a/test/files/run/ctries/concmap.scala
+++ b/test/files/run/ctries-new/concmap.scala
diff --git a/test/files/run/ctries/iterator.scala b/test/files/run/ctries-new/iterator.scala
index b953a40e00..b953a40e00 100644
--- a/test/files/run/ctries/iterator.scala
+++ b/test/files/run/ctries-new/iterator.scala
diff --git a/test/files/run/ctries/lnode.scala b/test/files/run/ctries-new/lnode.scala
index 92a31088e5..92a31088e5 100644
--- a/test/files/run/ctries/lnode.scala
+++ b/test/files/run/ctries-new/lnode.scala
diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala
new file mode 100644
index 0000000000..1d40dab6c5
--- /dev/null
+++ b/test/files/run/ctries-new/main.scala
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+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: ClassTag]() = {
+ var produced = false
+ try body
+ catch {
+ case e => if (e.getClass == implicitly[ClassTag[T]].erasure) produced = true
+ } finally {
+ assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]])
+ }
+ }
+ }
+
+}
diff --git a/test/files/run/ctries/snapshot.scala b/test/files/run/ctries-new/snapshot.scala
index 5fe77d445b..5fe77d445b 100644
--- a/test/files/run/ctries/snapshot.scala
+++ b/test/files/run/ctries-new/snapshot.scala
diff --git a/test/files/run/ctries-old/DumbHash.scala b/test/files/run/ctries-old/DumbHash.scala
new file mode 100644
index 0000000000..8ef325b67c
--- /dev/null
+++ b/test/files/run/ctries-old/DumbHash.scala
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+class DumbHash(val i: Int) {
+ override def equals(other: Any) = other match {
+ case that: DumbHash => that.i == this.i
+ case _ => false
+ }
+ override def hashCode = i % 5
+ override def toString = "DH(%s)".format(i)
+}
diff --git a/test/files/run/ctries-old/Wrap.scala b/test/files/run/ctries-old/Wrap.scala
new file mode 100644
index 0000000000..7b645c1612
--- /dev/null
+++ b/test/files/run/ctries-old/Wrap.scala
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+case class Wrap(i: Int) {
+ override def hashCode = i * 0x9e3775cd
+}
diff --git a/test/files/run/ctries-old/concmap.scala b/test/files/run/ctries-old/concmap.scala
new file mode 100644
index 0000000000..3ec0256afb
--- /dev/null
+++ b/test/files/run/ctries-old/concmap.scala
@@ -0,0 +1,188 @@
+
+
+
+import collection.concurrent.TrieMap
+
+
+object ConcurrentMapSpec extends Spec {
+
+ val initsz = 500
+ val secondsz = 750
+
+ def test() {
+ "support put" in {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until initsz) assert(ct.put(new Wrap(i), i) == None)
+ for (i <- 0 until initsz) assert(ct.put(new Wrap(i), -i) == Some(i))
+ }
+
+ "support put if absent" in {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until initsz) ct.update(new Wrap(i), i)
+ for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i))
+ for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i))
+ for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), -i) == None)
+ for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), i) == Some(-i))
+ }
+
+ "support remove if mapped to a specific value" in {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until initsz) ct.update(new Wrap(i), i)
+ for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), -i - 1) == false)
+ for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == true)
+ for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == false)
+ }
+
+ "support replace if mapped to a specific value" in {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until initsz) ct.update(new Wrap(i), i)
+ for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i - 1, -i - 2) == false)
+ for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == true)
+ for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == false)
+ for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i, 0) == false)
+ }
+
+ "support replace if present" in {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until initsz) ct.update(new Wrap(i), i)
+ for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i) == Some(i))
+ for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i) == Some(-i))
+ for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i) == None)
+ }
+
+ def assertEqual(a: Any, b: Any) = {
+ if (a != b) println(a, b)
+ assert(a == b)
+ }
+
+ "support replace if mapped to a specific value, using several threads" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 55000
+ for (i <- 0 until sz) ct.update(new Wrap(i), i)
+
+ class Updater(index: Int, offs: Int) extends Thread {
+ override def run() {
+ var repeats = 0
+ for (i <- 0 until sz) {
+ val j = (offs + i) % sz
+ var k = Int.MaxValue
+ do {
+ if (k != Int.MaxValue) repeats += 1
+ k = ct.lookup(new Wrap(j))
+ } while (!ct.replace(new Wrap(j), k, -k))
+ }
+ //println("Thread %d repeats: %d".format(index, repeats))
+ }
+ }
+
+ val threads = for (i <- 0 until 16) yield new Updater(i, sz / 32 * i)
+ threads.foreach(_.start())
+ threads.foreach(_.join())
+
+ for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), i)
+
+ val threads2 = for (i <- 0 until 15) yield new Updater(i, sz / 32 * i)
+ threads2.foreach(_.start())
+ threads2.foreach(_.join())
+
+ for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), -i)
+ }
+
+ "support put if absent, several threads" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 110000
+
+ class Updater(offs: Int) extends Thread {
+ override def run() {
+ for (i <- 0 until sz) {
+ val j = (offs + i) % sz
+ ct.putIfAbsent(new Wrap(j), j)
+ assert(ct.lookup(new Wrap(j)) == j)
+ }
+ }
+ }
+
+ val threads = for (i <- 0 until 16) yield new Updater(sz / 32 * i)
+ threads.foreach(_.start())
+ threads.foreach(_.join())
+
+ for (i <- 0 until sz) assert(ct(new Wrap(i)) == i)
+ }
+
+ "support remove if mapped to a specific value, several threads" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 55000
+ for (i <- 0 until sz) ct.update(new Wrap(i), i)
+
+ class Remover(offs: Int) extends Thread {
+ override def run() {
+ for (i <- 0 until sz) {
+ val j = (offs + i) % sz
+ ct.remove(new Wrap(j), j)
+ assert(ct.get(new Wrap(j)) == None)
+ }
+ }
+ }
+
+ val threads = for (i <- 0 until 16) yield new Remover(sz / 32 * i)
+ threads.foreach(_.start())
+ threads.foreach(_.join())
+
+ for (i <- 0 until sz) assert(ct.get(new Wrap(i)) == None)
+ }
+
+ "have all or none of the elements depending on the oddity" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 65000
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+
+ class Modifier(index: Int, offs: Int) extends Thread {
+ override def run() {
+ for (j <- 0 until sz) {
+ val i = (offs + j) % sz
+ var success = false
+ do {
+ if (ct.contains(new Wrap(i))) {
+ success = ct.remove(new Wrap(i)) != None
+ } else {
+ success = ct.putIfAbsent(new Wrap(i), i) == None
+ }
+ } while (!success)
+ }
+ }
+ }
+
+ def modify(n: Int) = {
+ val threads = for (i <- 0 until n) yield new Modifier(i, sz / n * i)
+ threads.foreach(_.start())
+ threads.foreach(_.join())
+ }
+
+ modify(16)
+ for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), Some(i))
+ modify(15)
+ for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None)
+ }
+
+ "compute size correctly" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 36450
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+
+ assertEqual(ct.size, sz)
+ assertEqual(ct.size, sz)
+ }
+
+ "compute size correctly in parallel" in {
+ val ct = new TrieMap[Wrap, Int]
+ val sz = 36450
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+ val pct = ct.par
+
+ assertEqual(pct.size, sz)
+ assertEqual(pct.size, sz)
+ }
+
+ }
+
+}
diff --git a/test/files/run/ctries-old/iterator.scala b/test/files/run/ctries-old/iterator.scala
new file mode 100644
index 0000000000..b953a40e00
--- /dev/null
+++ b/test/files/run/ctries-old/iterator.scala
@@ -0,0 +1,289 @@
+
+
+
+
+import collection._
+import collection.concurrent.TrieMap
+
+
+
+object IteratorSpec extends Spec {
+
+ def test() {
+ "work for an empty trie" in {
+ val ct = new TrieMap
+ val it = ct.iterator
+
+ it.hasNext shouldEqual (false)
+ evaluating { it.next() }.shouldProduce [NoSuchElementException]
+ }
+
+ def nonEmptyIteratorCheck(sz: Int) {
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct.put(new Wrap(i), i)
+
+ val it = ct.iterator
+ val tracker = mutable.Map[Wrap, Int]()
+ for (i <- 0 until sz) {
+ assert(it.hasNext == true)
+ tracker += it.next
+ }
+
+ it.hasNext shouldEqual (false)
+ evaluating { it.next() }.shouldProduce [NoSuchElementException]
+ tracker.size shouldEqual (sz)
+ tracker shouldEqual (ct)
+ }
+
+ "work for a 1 element trie" in {
+ nonEmptyIteratorCheck(1)
+ }
+
+ "work for a 2 element trie" in {
+ nonEmptyIteratorCheck(2)
+ }
+
+ "work for a 3 element trie" in {
+ nonEmptyIteratorCheck(3)
+ }
+
+ "work for a 5 element trie" in {
+ nonEmptyIteratorCheck(5)
+ }
+
+ "work for a 10 element trie" in {
+ nonEmptyIteratorCheck(10)
+ }
+
+ "work for a 20 element trie" in {
+ nonEmptyIteratorCheck(20)
+ }
+
+ "work for a 50 element trie" in {
+ nonEmptyIteratorCheck(50)
+ }
+
+ "work for a 100 element trie" in {
+ nonEmptyIteratorCheck(100)
+ }
+
+ "work for a 1k element trie" in {
+ nonEmptyIteratorCheck(1000)
+ }
+
+ "work for a 5k element trie" in {
+ nonEmptyIteratorCheck(5000)
+ }
+
+ "work for a 75k element trie" in {
+ nonEmptyIteratorCheck(75000)
+ }
+
+ "work for a 250k element trie" in {
+ nonEmptyIteratorCheck(500000)
+ }
+
+ def nonEmptyCollideCheck(sz: Int) {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until sz) ct.put(new DumbHash(i), i)
+
+ val it = ct.iterator
+ val tracker = mutable.Map[DumbHash, Int]()
+ for (i <- 0 until sz) {
+ assert(it.hasNext == true)
+ tracker += it.next
+ }
+
+ it.hasNext shouldEqual (false)
+ evaluating { it.next() }.shouldProduce [NoSuchElementException]
+ tracker.size shouldEqual (sz)
+ tracker shouldEqual (ct)
+ }
+
+ "work for colliding hashcodes, 2 element trie" in {
+ nonEmptyCollideCheck(2)
+ }
+
+ "work for colliding hashcodes, 3 element trie" in {
+ nonEmptyCollideCheck(3)
+ }
+
+ "work for colliding hashcodes, 5 element trie" in {
+ nonEmptyCollideCheck(5)
+ }
+
+ "work for colliding hashcodes, 10 element trie" in {
+ nonEmptyCollideCheck(10)
+ }
+
+ "work for colliding hashcodes, 100 element trie" in {
+ nonEmptyCollideCheck(100)
+ }
+
+ "work for colliding hashcodes, 500 element trie" in {
+ nonEmptyCollideCheck(500)
+ }
+
+ "work for colliding hashcodes, 5k element trie" in {
+ nonEmptyCollideCheck(5000)
+ }
+
+ def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) {
+ if (a != b) {
+ println(a.size + " vs " + b.size)
+ // println(a)
+ // println(b)
+ // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i))
+ // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i))
+ }
+ assert(a == b)
+ }
+
+ "be consistent when taken with concurrent modifications" in {
+ val sz = 25000
+ val W = 15
+ val S = 5
+ val checks = 5
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct.put(new Wrap(i), i)
+
+ class Modifier extends Thread {
+ override def run() {
+ for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match {
+ case Some(_) => ct.remove(new Wrap(i))
+ case None =>
+ }
+ }
+ }
+
+ def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) {
+ class Iter extends Thread {
+ override def run() {
+ val snap = ct.readOnlySnapshot()
+ val initial = mutable.Map[Wrap, Int]()
+ for (kv <- snap) initial += kv
+
+ for (i <- 0 until checks) {
+ assertEqual(snap.iterator.toMap, initial)
+ }
+ }
+ }
+
+ val iter = new Iter
+ iter.start()
+ iter.join()
+ }
+
+ val threads = for (_ <- 0 until W) yield new Modifier
+ threads.foreach(_.start())
+ for (_ <- 0 until S) consistentIteration(ct, checks)
+ threads.foreach(_.join())
+ }
+
+ "be consistent with a concurrent removal with a well defined order" in {
+ val sz = 150000
+ val sgroupsize = 10
+ val sgroupnum = 5
+ val removerslowdown = 50
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct.put(new Wrap(i), i)
+
+ class Remover extends Thread {
+ override def run() {
+ for (i <- 0 until sz) {
+ assert(ct.remove(new Wrap(i)) == Some(i))
+ for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate
+ }
+ //println("done removing")
+ }
+ }
+
+ def consistentIteration(it: Iterator[(Wrap, Int)]) = {
+ class Iter extends Thread {
+ override def run() {
+ val elems = it.toBuffer
+ if (elems.nonEmpty) {
+ val minelem = elems.minBy((x: (Wrap, Int)) => x._1.i)._1.i
+ assert(elems.forall(_._1.i >= minelem))
+ }
+ }
+ }
+ new Iter
+ }
+
+ val remover = new Remover
+ remover.start()
+ for (_ <- 0 until sgroupnum) {
+ val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator)
+ iters.foreach(_.start())
+ iters.foreach(_.join())
+ }
+ //println("done with iterators")
+ remover.join()
+ }
+
+ "be consistent with a concurrent insertion with a well defined order" in {
+ val sz = 150000
+ val sgroupsize = 10
+ val sgroupnum = 10
+ val inserterslowdown = 50
+ val ct = new TrieMap[Wrap, Int]
+
+ class Inserter extends Thread {
+ override def run() {
+ for (i <- 0 until sz) {
+ assert(ct.put(new Wrap(i), i) == None)
+ for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate
+ }
+ //println("done inserting")
+ }
+ }
+
+ def consistentIteration(it: Iterator[(Wrap, Int)]) = {
+ class Iter extends Thread {
+ override def run() {
+ val elems = it.toSeq
+ if (elems.nonEmpty) {
+ val maxelem = elems.maxBy((x: (Wrap, Int)) => x._1.i)._1.i
+ assert(elems.forall(_._1.i <= maxelem))
+ }
+ }
+ }
+ new Iter
+ }
+
+ val inserter = new Inserter
+ inserter.start()
+ for (_ <- 0 until sgroupnum) {
+ val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator)
+ iters.foreach(_.start())
+ iters.foreach(_.join())
+ }
+ //println("done with iterators")
+ inserter.join()
+ }
+
+ "work on a yet unevaluated snapshot" in {
+ val sz = 50000
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct.update(new Wrap(i), i)
+
+ val snap = ct.snapshot()
+ val it = snap.iterator
+
+ while (it.hasNext) it.next()
+ }
+
+ "be duplicated" in {
+ val sz = 50
+ val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*)
+ val it = ct.splitter
+ for (_ <- 0 until (sz / 2)) it.next()
+ val dupit = it.dup
+
+ it.toList shouldEqual dupit.toList
+ }
+
+ }
+
+}
diff --git a/test/files/run/ctries-old/lnode.scala b/test/files/run/ctries-old/lnode.scala
new file mode 100644
index 0000000000..92a31088e5
--- /dev/null
+++ b/test/files/run/ctries-old/lnode.scala
@@ -0,0 +1,61 @@
+
+
+
+import collection.concurrent.TrieMap
+
+
+object LNodeSpec extends Spec {
+
+ val initsz = 1500
+ val secondsz = 1750
+
+ def test() {
+ "accept elements with the same hash codes" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) ct.update(new DumbHash(i), i)
+ }
+
+ "lookup elements with the same hash codes" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) ct.update(new DumbHash(i), i)
+ for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == Some(i))
+ for (i <- initsz until secondsz) assert(ct.get(new DumbHash(i)) == None)
+ }
+
+ "remove elements with the same hash codes" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) ct.update(new DumbHash(i), i)
+ for (i <- 0 until initsz) {
+ val remelem = ct.remove(new DumbHash(i))
+ assert(remelem == Some(i), "removing " + i + " yields " + remelem)
+ }
+ for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == None)
+ }
+
+ "put elements with the same hash codes if absent" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) ct.put(new DumbHash(i), i)
+ for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i)
+ for (i <- 0 until initsz) assert(ct.putIfAbsent(new DumbHash(i), i) == Some(i))
+ for (i <- initsz until secondsz) assert(ct.putIfAbsent(new DumbHash(i), i) == None)
+ for (i <- initsz until secondsz) assert(ct.lookup(new DumbHash(i)) == i)
+ }
+
+ "replace elements with the same hash codes" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None)
+ for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i)
+ for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i) == Some(i))
+ for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == -i)
+ for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i, i) == true)
+ }
+
+ "remove elements with the same hash codes if mapped to a specific value" in {
+ val ct = new TrieMap[DumbHash, Int]
+ for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None)
+ for (i <- 0 until initsz) assert(ct.remove(new DumbHash(i), i) == true)
+ }
+
+ }
+
+}
diff --git a/test/files/run/ctries/main.scala b/test/files/run/ctries-old/main.scala
index 8db7fcef54..8db7fcef54 100644
--- a/test/files/run/ctries/main.scala
+++ b/test/files/run/ctries-old/main.scala
diff --git a/test/files/run/ctries-old/snapshot.scala b/test/files/run/ctries-old/snapshot.scala
new file mode 100644
index 0000000000..5fe77d445b
--- /dev/null
+++ b/test/files/run/ctries-old/snapshot.scala
@@ -0,0 +1,267 @@
+
+
+
+
+import collection._
+import collection.concurrent.TrieMap
+
+
+
+object SnapshotSpec extends Spec {
+
+ def test() {
+ "support snapshots" in {
+ val ctn = new TrieMap
+ ctn.snapshot()
+ ctn.readOnlySnapshot()
+
+ val ct = new TrieMap[Int, Int]
+ for (i <- 0 until 100) ct.put(i, i)
+ ct.snapshot()
+ ct.readOnlySnapshot()
+ }
+
+ "empty 2 quiescent snapshots in isolation" in {
+ val sz = 4000
+
+ class Worker(trie: TrieMap[Wrap, Int]) extends Thread {
+ override def run() {
+ for (i <- 0 until sz) {
+ assert(trie.remove(new Wrap(i)) == Some(i))
+ for (j <- 0 until sz)
+ if (j <= i) assert(trie.get(new Wrap(j)) == None)
+ else assert(trie.get(new Wrap(j)) == Some(j))
+ }
+ }
+ }
+
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct.put(new Wrap(i), i)
+ val snapt = ct.snapshot()
+
+ val original = new Worker(ct)
+ val snapshot = new Worker(snapt)
+ original.start()
+ snapshot.start()
+ original.join()
+ snapshot.join()
+
+ for (i <- 0 until sz) {
+ assert(ct.get(new Wrap(i)) == None)
+ assert(snapt.get(new Wrap(i)) == None)
+ }
+ }
+
+ def consistentReadOnly(name: String, readonly: Map[Wrap, Int], sz: Int, N: Int) {
+ @volatile var e: Exception = null
+
+ // reads possible entries once and stores them
+ // then reads all these N more times to check if the
+ // state stayed the same
+ class Reader(trie: Map[Wrap, Int]) extends Thread {
+ setName("Reader " + name)
+
+ override def run() =
+ try check()
+ catch {
+ case ex: Exception => e = ex
+ }
+
+ def check() {
+ val initial = mutable.Map[Wrap, Int]()
+ for (i <- 0 until sz) trie.get(new Wrap(i)) match {
+ case Some(i) => initial.put(new Wrap(i), i)
+ case None => // do nothing
+ }
+
+ for (k <- 0 until N) {
+ for (i <- 0 until sz) {
+ val tres = trie.get(new Wrap(i))
+ val ires = initial.get(new Wrap(i))
+ if (tres != ires) println(i, "initially: " + ires, "traversal %d: %s".format(k, tres))
+ assert(tres == ires)
+ }
+ }
+ }
+ }
+
+ val reader = new Reader(readonly)
+ reader.start()
+ reader.join()
+
+ if (e ne null) {
+ e.printStackTrace()
+ throw e
+ }
+ }
+
+ // traverses the trie `rep` times and modifies each entry
+ class Modifier(trie: TrieMap[Wrap, Int], index: Int, rep: Int, sz: Int) extends Thread {
+ setName("Modifier %d".format(index))
+
+ override def run() {
+ for (k <- 0 until rep) {
+ for (i <- 0 until sz) trie.putIfAbsent(new Wrap(i), i) match {
+ case Some(_) => trie.remove(new Wrap(i))
+ case None => // do nothing
+ }
+ }
+ }
+ }
+
+ // removes all the elements from the trie
+ class Remover(trie: TrieMap[Wrap, Int], index: Int, totremovers: Int, sz: Int) extends Thread {
+ setName("Remover %d".format(index))
+
+ override def run() {
+ for (i <- 0 until sz) trie.remove(new Wrap((i + sz / totremovers * index) % sz))
+ }
+ }
+
+ "have a consistent quiescent read-only snapshot" in {
+ val sz = 10000
+ val N = 100
+ val W = 10
+
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+ val readonly = ct.readOnlySnapshot()
+ val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz)
+
+ threads.foreach(_.start())
+ consistentReadOnly("qm", readonly, sz, N)
+ threads.foreach(_.join())
+ }
+
+ // now, we check non-quiescent snapshots, as these permit situations
+ // where a thread is caught in the middle of the update when a snapshot is taken
+
+ "have a consistent non-quiescent read-only snapshot, concurrent with removes only" in {
+ val sz = 1250
+ val W = 100
+ val S = 5000
+
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+ val threads = for (i <- 0 until W) yield new Remover(ct, i, W, sz)
+
+ threads.foreach(_.start())
+ for (i <- 0 until S) consistentReadOnly("non-qr", ct.readOnlySnapshot(), sz, 5)
+ threads.foreach(_.join())
+ }
+
+ "have a consistent non-quiescent read-only snapshot, concurrent with modifications" in {
+ val sz = 1000
+ val N = 7000
+ val W = 10
+ val S = 7000
+
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+ val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz)
+
+ threads.foreach(_.start())
+ for (i <- 0 until S) consistentReadOnly("non-qm", ct.readOnlySnapshot(), sz, 5)
+ threads.foreach(_.join())
+ }
+
+ def consistentNonReadOnly(name: String, trie: TrieMap[Wrap, Int], sz: Int, N: Int) {
+ @volatile var e: Exception = null
+
+ // reads possible entries once and stores them
+ // then reads all these N more times to check if the
+ // state stayed the same
+ class Worker extends Thread {
+ setName("Worker " + name)
+
+ override def run() =
+ try check()
+ catch {
+ case ex: Exception => e = ex
+ }
+
+ def check() {
+ val initial = mutable.Map[Wrap, Int]()
+ for (i <- 0 until sz) trie.get(new Wrap(i)) match {
+ case Some(i) => initial.put(new Wrap(i), i)
+ case None => // do nothing
+ }
+
+ for (k <- 0 until N) {
+ // modify
+ for ((key, value) <- initial) {
+ val oldv = if (k % 2 == 0) value else -value
+ val newv = -oldv
+ trie.replace(key, oldv, newv)
+ }
+
+ // check
+ for (i <- 0 until sz) if (initial.contains(new Wrap(i))) {
+ val expected = if (k % 2 == 0) -i else i
+ //println(trie.get(new Wrap(i)))
+ assert(trie.get(new Wrap(i)) == Some(expected))
+ } else {
+ assert(trie.get(new Wrap(i)) == None)
+ }
+ }
+ }
+ }
+
+ val worker = new Worker
+ worker.start()
+ worker.join()
+
+ if (e ne null) {
+ e.printStackTrace()
+ throw e
+ }
+ }
+
+ "have a consistent non-quiescent snapshot, concurrent with modifications" in {
+ val sz = 9000
+ val N = 1000
+ val W = 10
+ val S = 400
+
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+ val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz)
+
+ threads.foreach(_.start())
+ for (i <- 0 until S) {
+ consistentReadOnly("non-qm", ct.snapshot(), sz, 5)
+ consistentNonReadOnly("non-qsnap", ct.snapshot(), sz, 5)
+ }
+ threads.foreach(_.join())
+ }
+
+ "work when many concurrent snapshots are taken, concurrent with modifications" in {
+ val sz = 12000
+ val W = 10
+ val S = 10
+ val modifytimes = 1200
+ val snaptimes = 600
+ val ct = new TrieMap[Wrap, Int]
+ for (i <- 0 until sz) ct(new Wrap(i)) = i
+
+ class Snapshooter extends Thread {
+ setName("Snapshooter")
+ override def run() {
+ for (k <- 0 until snaptimes) {
+ val snap = ct.snapshot()
+ for (i <- 0 until sz) snap.remove(new Wrap(i))
+ for (i <- 0 until sz) assert(!snap.contains(new Wrap(i)))
+ }
+ }
+ }
+
+ val mods = for (i <- 0 until W) yield new Modifier(ct, i, modifytimes, sz)
+ val shooters = for (i <- 0 until S) yield new Snapshooter
+ val threads = mods ++ shooters
+ threads.foreach(_.start())
+ threads.foreach(_.join())
+ }
+
+ }
+
+}
diff --git a/test/files/run/erasuretags_abstract.check b/test/files/run/erasuretags_abstract.check
new file mode 100644
index 0000000000..17e7204664
--- /dev/null
+++ b/test/files/run/erasuretags_abstract.check
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000000..8e4ad0d090
--- /dev/null
+++ b/test/files/run/erasuretags_abstract.scala
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..c02a4d32af
--- /dev/null
+++ b/test/files/run/erasuretags_basic.check
@@ -0,0 +1,24 @@
+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
new file mode 100644
index 0000000000..d894fdf2e9
--- /dev/null
+++ b/test/files/run/erasuretags_basic.scala
@@ -0,0 +1,21 @@
+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
new file mode 100644
index 0000000000..2c544678d1
--- /dev/null
+++ b/test/files/run/erasuretags_core.check
@@ -0,0 +1,32 @@
+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
new file mode 100644
index 0000000000..5ed06dcd31
--- /dev/null
+++ b/test/files/run/erasuretags_core.scala
@@ -0,0 +1,34 @@
+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
new file mode 100644
index 0000000000..16e53af071
--- /dev/null
+++ b/test/files/run/erasuretags_usage.scala
@@ -0,0 +1,12 @@
+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/existentials3.check b/test/files/run/existentials3-new.check
index e2c9382ab4..66674fbbd6 100644
--- a/test/files/run/existentials3.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
+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
diff --git a/test/files/run/existentials3.scala b/test/files/run/existentials3-new.scala
index d6d5612687..32129a04c6 100644
--- a/test/files/run/existentials3.scala
+++ b/test/files/run/existentials3-new.scala
@@ -38,8 +38,7 @@ object Test {
def m[T: ConcreteTypeTag](x: T) = printTag(concreteTypeTag[T])
def m2[T: TypeTag](x: T) = printTag(typeTag[T])
- // manifests don't work for f10/g10
- // oh, they do now :)
+ // tags do work for f10/g10
def main(args: Array[String]): Unit = {
m(f1)
m(f2)
diff --git a/test/files/run/existentials3-old.check b/test/files/run/existentials3-old.check
new file mode 100644
index 0000000000..e166e53ba8
--- /dev/null
+++ b/test/files/run/existentials3-old.check
@@ -0,0 +1,22 @@
+_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with Test$ToS with scala.Product with scala.Serializable
+Object with Test$ToS
+Object with Test$ToS
+Object with Test$ToS
+scala.Function0[Object with Test$ToS]
+scala.Function0[Object with Test$ToS]
+_ <: Object with _ <: Object with Object with Test$ToS
+_ <: Object with _ <: Object with _ <: Object with Test$ToS
+scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
+scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
+_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with Test$ToS with scala.Product with scala.Serializable
+Object with Test$ToS
+Object with Test$ToS
+Object with Test$ToS
+scala.Function0[Object with Test$ToS]
+scala.Function0[Object with Test$ToS]
+_ <: Object with _ <: Object with Object with Test$ToS
+_ <: Object with _ <: Object with _ <: Object with Test$ToS
+scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
+scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
diff --git a/test/files/run/existentials3-old.scala b/test/files/run/existentials3-old.scala
new file mode 100644
index 0000000000..944160ff12
--- /dev/null
+++ b/test/files/run/existentials3-old.scala
@@ -0,0 +1,73 @@
+object Test {
+ trait ToS { final override def toString = getClass.getName }
+
+ def f1 = { case class Bar() extends ToS; Bar }
+ def f2 = { case class Bar() extends ToS; Bar() }
+ def f3 = { class Bar() extends ToS; object Bar extends ToS; Bar }
+ def f4 = { class Bar() extends ToS; new Bar() }
+ def f5 = { object Bar extends ToS; Bar }
+ def f6 = { () => { object Bar extends ToS ; Bar } }
+ def f7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f }
+
+ def f8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } }
+ def f9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } }
+
+ def f10 = { class A { type T1 } ; List[A#T1]() }
+ def f11 = { abstract class A extends Seq[Int] ; List[A]() }
+ def f12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() }
+
+ val g1 = { case class Bar() extends ToS; Bar }
+ val g2 = { case class Bar() extends ToS; Bar() }
+ val g3 = { class Bar() extends ToS; object Bar extends ToS; Bar }
+ val g4 = { class Bar() extends ToS; new Bar() }
+ val g5 = { object Bar extends ToS; Bar }
+ val g6 = { () => { object Bar extends ToS ; Bar } }
+ val g7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f }
+
+ val g8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } }
+ val g9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } }
+
+ val g10 = { class A { type T1 } ; List[A#T1]() }
+ 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 m[T: Manifest](x: T) = println(manifest[T])
+
+ // manifests don't work for f10/g10
+ def main(args: Array[String]): Unit = {
+ m(f1)
+ m(f2)
+ m(f3)
+ m(f4)
+ m(f5)
+ m(f6)
+ m(f7)
+ m(f8)
+ m(f9)
+ // m(f10)
+ m(f11)
+ m(f12)
+ m(g1)
+ m(g2)
+ m(g3)
+ m(g4)
+ m(g5)
+ m(g6)
+ m(g7)
+ m(g8)
+ m(g9)
+ // m(g10)
+ m(g11)
+ m(g12)
+ }
+}
+
+object Misc {
+ trait Bippy { def bippy = "I'm Bippy!" }
+ object o1 {
+ def f1 = { trait A extends Seq[U forSome { type U <: Bippy }] ; abstract class B extends A ; trait C extends B ; (null: C) }
+ def f2 = f1.head.bippy
+ }
+ def g1 = o1.f1 _
+ def g2 = o1.f2 _
+}
diff --git a/test/files/run/getClassTest.check b/test/files/run/getClassTest-new.check
index 94e86c3889..94e86c3889 100644
--- a/test/files/run/getClassTest.check
+++ b/test/files/run/getClassTest-new.check
diff --git a/test/files/run/getClassTest-new.scala b/test/files/run/getClassTest-new.scala
new file mode 100644
index 0000000000..89778ca2d3
--- /dev/null
+++ b/test/files/run/getClassTest-new.scala
@@ -0,0 +1,66 @@
+class AnyVals {
+ def f1 = (5: Any).getClass
+ def f2 = (5: AnyVal).getClass
+ def f3 = 5.getClass
+ def f4 = (5: java.lang.Integer).getClass
+ def f5 = (5.asInstanceOf[AnyRef]).getClass
+
+ // scalap says:
+ //
+ // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ }
+ // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ }
+ // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ }
+ // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ }
+ // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ }
+ //
+ // java generic signature says:
+ //
+ // f1: java.lang.Class<?>
+ // f2: java.lang.Class<?>
+ // f3: java.lang.Class<java.lang.Object>
+ // f4: java.lang.Class<? extends java.lang.Integer>
+ // f5: java.lang.Class<?>
+}
+
+class AnyRefs {
+ class A
+ class B extends A
+
+ def f1 = (new B: Any).getClass().newInstance()
+ def f2 = (new B: AnyRef).getClass().newInstance()
+ def f3 = (new B: A).getClass().newInstance()
+ def f4 = (new B: B).getClass().newInstance()
+
+ def f0[T >: B] = (new B: T).getClass().newInstance()
+
+ def f5 = f0[Any]
+ def f6 = f0[AnyRef]
+ def f7 = f0[A]
+ def f8 = f0[B]
+}
+
+class MoreAnyRefs {
+ trait A
+ trait B
+
+ // don't leak anon/refinements
+ def f1 = (new A with B { }).getClass()
+ def f2 = (new B with A { }).getClass()
+ def f3 = (new { def bippy() = 5 }).getClass()
+ def f4 = (new A { def bippy() = 5 }).getClass()
+}
+
+object Test {
+ def returnTypes[T: ClassTag] = (
+ classTag[T].erasure.getMethods.toList
+ filter (_.getName startsWith "f")
+ sortBy (_.getName)
+ map (m => m.getName + ": " + m.getGenericReturnType.toString)
+ )
+
+ def main(args: Array[String]): Unit = {
+ returnTypes[AnyVals] foreach println
+ returnTypes[AnyRefs] foreach println
+ returnTypes[MoreAnyRefs] foreach println
+ }
+}
diff --git a/test/files/run/getClassTest-old.check b/test/files/run/getClassTest-old.check
new file mode 100644
index 0000000000..94e86c3889
--- /dev/null
+++ b/test/files/run/getClassTest-old.check
@@ -0,0 +1,18 @@
+f1: java.lang.Class<?>
+f2: java.lang.Class<?>
+f3: java.lang.Class<java.lang.Object>
+f4: java.lang.Class<? extends java.lang.Integer>
+f5: java.lang.Class<?>
+f0: T
+f1: class java.lang.Object
+f2: class java.lang.Object
+f3: class AnyRefs$A
+f4: class AnyRefs$B
+f5: class java.lang.Object
+f6: class java.lang.Object
+f7: class AnyRefs$A
+f8: class AnyRefs$B
+f1: java.lang.Class<? extends MoreAnyRefs$A>
+f2: java.lang.Class<? extends MoreAnyRefs$B>
+f3: java.lang.Class<?>
+f4: java.lang.Class<? extends MoreAnyRefs$A>
diff --git a/test/files/run/getClassTest.scala b/test/files/run/getClassTest-old.scala
index 2485cd2c71..951cc8d931 100644
--- a/test/files/run/getClassTest.scala
+++ b/test/files/run/getClassTest-old.scala
@@ -4,7 +4,7 @@ class AnyVals {
def f3 = 5.getClass
def f4 = (5: java.lang.Integer).getClass
def f5 = (5.asInstanceOf[AnyRef]).getClass
-
+
// scalap says:
//
// def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ }
@@ -19,18 +19,18 @@ class AnyVals {
// f2: java.lang.Class<?>
// f3: java.lang.Class<java.lang.Object>
// f4: java.lang.Class<? extends java.lang.Integer>
- // f5: java.lang.Class<?>
+ // f5: java.lang.Class<?>
}
class AnyRefs {
class A
class B extends A
-
+
def f1 = (new B: Any).getClass().newInstance()
def f2 = (new B: AnyRef).getClass().newInstance()
def f3 = (new B: A).getClass().newInstance()
def f4 = (new B: B).getClass().newInstance()
-
+
def f0[T >: B] = (new B: T).getClass().newInstance()
def f5 = f0[Any]
@@ -52,7 +52,7 @@ class MoreAnyRefs {
object Test {
def returnTypes[T: Manifest] = (
- manifest[T].erasure.getMethods.toList
+ manifest[T].erasure.getMethods.toList
filter (_.getName startsWith "f")
sortBy (_.getName)
map (m => m.getName + ": " + m.getGenericReturnType.toString)
diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.check b/test/files/run/interop_classmanifests_arepartially_typetags.check
new file mode 100644
index 0000000000..3dfcdccbec
--- /dev/null
+++ b/test/files/run/interop_classmanifests_arepartially_typetags.check
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..9bc1f32e86
--- /dev/null
+++ b/test/files/run/interop_classmanifests_arepartially_typetags.scala
@@ -0,0 +1,10 @@
+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
new file mode 100644
index 0000000000..02393dff23
--- /dev/null
+++ b/test/files/run/interop_classtags_are_classmanifests.check
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..309c99a3f5
--- /dev/null
+++ b/test/files/run/interop_classtags_are_classmanifests.scala
@@ -0,0 +1,17 @@
+object Test extends App {
+ def arrayTagIsClassManifest[T: ArrayTag] = {
+ println(classManifest[T])
+ }
+
+ arrayTagIsClassManifest[Int]
+ arrayTagIsClassManifest[String]
+ arrayTagIsClassManifest[Array[Int]]
+
+ def classTagIsClassManifest[T: ClassTag] = {
+ println(classManifest[T])
+ }
+
+ classTagIsClassManifest[Int]
+ classTagIsClassManifest[String]
+ classTagIsClassManifest[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.check b/test/files/run/interop_concretetypetags_are_classmanifests.check
new file mode 100644
index 0000000000..c59e92d4eb
--- /dev/null
+++ b/test/files/run/interop_concretetypetags_are_classmanifests.check
@@ -0,0 +1,3 @@
+Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.scala b/test/files/run/interop_concretetypetags_are_classmanifests.scala
new file mode 100644
index 0000000000..b578d7e626
--- /dev/null
+++ b/test/files/run/interop_concretetypetags_are_classmanifests.scala
@@ -0,0 +1,9 @@
+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.check b/test/files/run/interop_concretetypetags_are_manifests.check
new file mode 100644
index 0000000000..c59e92d4eb
--- /dev/null
+++ b/test/files/run/interop_concretetypetags_are_manifests.check
@@ -0,0 +1,3 @@
+Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_manifests.scala b/test/files/run/interop_concretetypetags_are_manifests.scala
new file mode 100644
index 0000000000..731410bc10
--- /dev/null
+++ b/test/files/run/interop_concretetypetags_are_manifests.scala
@@ -0,0 +1,9 @@
+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_manifests_are_classtags.check b/test/files/run/interop_manifests_are_classtags.check
new file mode 100644
index 0000000000..07ff6b984a
--- /dev/null
+++ b/test/files/run/interop_manifests_are_classtags.check
@@ -0,0 +1,24 @@
+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
new file mode 100644
index 0000000000..582cea3467
--- /dev/null
+++ b/test/files/run/interop_manifests_are_classtags.scala
@@ -0,0 +1,23 @@
+object Test extends App {
+ def classManifestIsClassTag[T: ClassManifest] = {
+ println(arrayTag[T])
+ println(erasureTag[T])
+ println(Array[T]().toList)
+ println(new Array[T](5).toList)
+ }
+
+ classManifestIsClassTag[Int]
+ classManifestIsClassTag[String]
+ classManifestIsClassTag[Array[Int]]
+
+ def manifestIsClassTag[T: Manifest] = {
+ println(arrayTag[T])
+ println(erasureTag[T])
+ println(Array[T]().toList)
+ println(new Array[T](5).toList)
+ }
+
+ manifestIsClassTag[Int]
+ manifestIsClassTag[String]
+ manifestIsClassTag[Array[Int]]
+} \ No newline at end of file
diff --git a/test/files/run/interop_manifests_are_concretetypetags.check b/test/files/run/interop_manifests_are_concretetypetags.check
new file mode 100644
index 0000000000..edab85ecf1
--- /dev/null
+++ b/test/files/run/interop_manifests_are_concretetypetags.check
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..0b82a56d0a
--- /dev/null
+++ b/test/files/run/interop_manifests_are_concretetypetags.scala
@@ -0,0 +1,10 @@
+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
new file mode 100644
index 0000000000..edab85ecf1
--- /dev/null
+++ b/test/files/run/interop_manifests_are_typetags.check
@@ -0,0 +1,6 @@
+Int
+int
+String
+class java.lang.String
+Array[Int]
+class [I
diff --git a/test/files/run/interop_manifests_are_typetags.scala b/test/files/run/interop_manifests_are_typetags.scala
new file mode 100644
index 0000000000..03a7b7b6d5
--- /dev/null
+++ b/test/files/run/interop_manifests_are_typetags.scala
@@ -0,0 +1,10 @@
+object Test extends App {
+ def manifestIsTypeTag[T: Manifest] = {
+ println(typeTag[T].tpe)
+ println(typeTag[T].erasure)
+ }
+
+ manifestIsTypeTag[Int]
+ manifestIsTypeTag[String]
+ manifestIsTypeTag[Array[Int]]
+} \ No newline at end of file
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 a1f124f790..3de9367994 100644
--- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
@@ -4,13 +4,6 @@ object Macros {
def impl_with_macros_enabled(c: Context) = {
import c.mirror._
- // todo. doesn't work. why?
- //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 tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2))))
-
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 ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check
new file mode 100644
index 0000000000..02da6ad0c7
--- /dev/null
+++ b/test/files/run/macro-typecheck-macrosdisabled2.check
@@ -0,0 +1,5 @@
+{
+ 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])))
+}
+mr.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.flags b/test/files/run/macro-typecheck-macrosdisabled2.flags
new file mode 100644
index 0000000000..cd66464f2f
--- /dev/null
+++ b/test/files/run/macro-typecheck-macrosdisabled2.flags
@@ -0,0 +1 @@
+-language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
new file mode 100644
index 0000000000..1b840a6204
--- /dev/null
+++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
@@ -0,0 +1,29 @@
+import scala.reflect.makro.Context
+
+object Macros {
+ def impl_with_macros_enabled(c: Context) = {
+ import c.mirror._
+
+ 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 ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
+ c.literal(ttree1.toString)
+ }
+
+ def foo_with_macros_enabled = macro impl_with_macros_enabled
+
+ def impl_with_macros_disabled(c: Context) = {
+ import c.mirror._
+
+ 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 tree2 = Apply(Select(Ident(mr), 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-typecheck-macrosdisabled2/Test_2.scala b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala
new file mode 100644
index 0000000000..bdba39195b
--- /dev/null
+++ b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ println(Macros.foo_with_macros_enabled)
+ println(Macros.foo_with_macros_disabled)
+} \ No newline at end of file
diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala
new file mode 100644
index 0000000000..4485ce9124
--- /dev/null
+++ b/test/files/run/manifests-new.scala
@@ -0,0 +1,147 @@
+object Test
+{
+ object Variances extends Enumeration {
+ val CO, IN, CONTRA = Value
+ }
+ import Variances.{ CO, IN, CONTRA }
+
+ object SubtypeRelationship extends Enumeration {
+ val NONE, SAME, SUB, SUPER = Value
+ }
+ import SubtypeRelationship.{ NONE, SAME, SUB, SUPER }
+
+ class VarianceTester[T, U, CC[_]](expected: Variances.Value)(
+ implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) {
+
+ def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe)
+ def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe)
+
+ def isUnrelated = typeCompare[T, U] == NONE
+ def isSame = typeCompare[T, U] == SAME
+ def isSub = typeCompare[T, U] == SUB
+ def isSuper = typeCompare[T, U] == SUPER
+
+ def showsCovariance = (elements == containers)
+ def showsContravariance = (elements == containers.reverse)
+ def showsInvariance = containers forall (_ == isSame)
+
+ def allContainerVariances = List(showsCovariance, showsInvariance, showsContravariance)
+
+ def showsExpectedVariance =
+ if (isUnrelated) allContainerVariances forall (_ == false)
+ else if (isSame) allContainerVariances forall (_ == true)
+ else expected match {
+ case CO => showsCovariance && !showsContravariance && !showsInvariance
+ case IN => showsInvariance && !showsCovariance && !showsContravariance
+ case CONTRA => showsContravariance && !showsCovariance && !showsInvariance
+ }
+ }
+
+ def showsCovariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) =
+ new VarianceTester[T, U, CC](CO) showsExpectedVariance
+
+ def showsInvariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) =
+ new VarianceTester[T, U, CC](IN) showsExpectedVariance
+
+ def showsContravariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) =
+ new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance
+
+ def typeCompare[T, U](implicit ev1: TypeTag[T], ev2: TypeTag[U]) = (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match {
+ case (true, true) => SAME
+ case (true, false) => SUB
+ case (false, true) => SUPER
+ case (false, false) => NONE
+ }
+
+ def assertAnyRef[T: TypeTag] = List(
+ typeTag[T].tpe <:< typeTag[Any].tpe,
+ typeTag[T].tpe <:< typeTag[AnyRef].tpe,
+ !(typeTag[T].tpe <:< typeTag[AnyVal].tpe)
+ ) 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
+ ) foreach (assert(_, "assertAnyVal"))
+
+ def assertSameType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SAME, "assertSameType")
+ def assertSuperType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUPER, "assertSuperType")
+ def assertSubType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUB, "assertSubType")
+ def assertNoRelationship[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == NONE, "assertNoRelationship")
+
+ def testVariancesVia[T: TypeTag, U: TypeTag] = assert(
+ typeCompare[T, U] == SUB &&
+ showsCovariance[T, U, List] &&
+ showsInvariance[T, U, Set],
+ "testVariancesVia"
+ )
+
+ def runAllTests = {
+ assertAnyVal[AnyVal]
+ assertAnyVal[Unit]
+ assertAnyVal[Int]
+ assertAnyVal[Double]
+ assertAnyVal[Boolean]
+ assertAnyVal[Char]
+
+ assertAnyRef[AnyRef]
+ assertAnyRef[java.lang.Object]
+ assertAnyRef[java.lang.Integer]
+ assertAnyRef[java.lang.Double]
+ assertAnyRef[java.lang.Boolean]
+ assertAnyRef[java.lang.Character]
+ assertAnyRef[String]
+ assertAnyRef[scala.List[String]]
+ assertAnyRef[scala.List[_]]
+
+ // variance doesn't work yet
+ // testVariancesVia[String, Any]
+ // testVariancesVia[String, AnyRef]
+
+ assertSubType[List[String], List[Any]]
+ assertSubType[List[String], List[AnyRef]]
+ assertNoRelationship[List[String], List[AnyVal]]
+
+ assertSubType[List[Int], List[Any]]
+ assertSubType[List[Int], List[AnyVal]]
+ assertNoRelationship[List[Int], List[AnyRef]]
+
+ // Nothing
+ assertSubType[Nothing, Any]
+ assertSubType[Nothing, AnyVal]
+ assertSubType[Nothing, AnyRef]
+ assertSubType[Nothing, String]
+ assertSubType[Nothing, List[String]]
+ assertSubType[Nothing, Null]
+ assertSameType[Nothing, Nothing]
+
+ // Null
+ assertSubType[Null, Any]
+ assertNoRelationship[Null, AnyVal]
+ assertSubType[Null, AnyRef]
+ assertSubType[Null, String]
+ assertSubType[Null, List[String]]
+ assertSameType[Null, Null]
+ assertSuperType[Null, Nothing]
+
+ // Any
+ assertSameType[Any, Any]
+ assertSuperType[Any, AnyVal]
+ assertSuperType[Any, AnyRef]
+ assertSuperType[Any, String]
+ assertSuperType[Any, List[String]]
+ assertSuperType[Any, Null]
+ assertSuperType[Any, Nothing]
+
+ // Misc unrelated types
+ assertNoRelationship[Unit, AnyRef]
+ assertNoRelationship[Unit, Int]
+ assertNoRelationship[Int, Long]
+ assertNoRelationship[Boolean, String]
+ assertNoRelationship[List[Boolean], List[String]]
+ assertNoRelationship[Set[Boolean], Set[String]]
+ }
+
+ def main(args: Array[String]): Unit = runAllTests
+}
diff --git a/test/files/run/manifests.scala b/test/files/run/manifests-old.scala
index 2d64bf18a9..621689a254 100644
--- a/test/files/run/manifests.scala
+++ b/test/files/run/manifests-old.scala
@@ -13,8 +13,8 @@ object Test
class VarianceTester[T, U, CC[_]](expected: Variances.Value)(
implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) {
- def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe)
- def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe)
+ def elements = List(ev1 <:< ev2, ev2 <:< ev1)
+ def containers = List(ev3 <:< ev4, ev4 <:< ev3)
def isUnrelated = typeCompare[T, U] == NONE
def isSame = typeCompare[T, U] == SAME
@@ -46,25 +46,23 @@ object Test
def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) =
new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance
- def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = {
- (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match {
- case (true, true) => SAME
- case (true, false) => SUB
- case (false, true) => SUPER
- case (false, false) => NONE
- }
+ def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = (ev1 <:< ev2, ev2 <:< ev1) match {
+ case (true, true) => SAME
+ case (true, false) => SUB
+ case (false, true) => SUPER
+ case (false, false) => NONE
}
def assertAnyRef[T: Manifest] = List(
- manifest[T].tpe <:< manifest[Any].tpe,
- manifest[T].tpe <:< manifest[AnyRef].tpe,
- !(manifest[T].tpe <:< manifest[AnyVal].tpe)
+ manifest[T] <:< manifest[Any],
+ manifest[T] <:< manifest[AnyRef],
+ !(manifest[T] <:< manifest[AnyVal])
) foreach (assert(_, "assertAnyRef"))
def assertAnyVal[T: Manifest] = List(
- manifest[T].tpe <:< manifest[Any].tpe,
- !(manifest[T].tpe <:< manifest[AnyRef].tpe),
- manifest[T].tpe <:< manifest[AnyVal].tpe
+ manifest[T] <:< manifest[Any],
+ !(manifest[T] <:< manifest[AnyRef]),
+ manifest[T] <:< manifest[AnyVal]
) foreach (assert(_, "assertAnyVal"))
def assertSameType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SAME, "assertSameType")
@@ -146,4 +144,4 @@ object Test
}
def main(args: Array[String]): Unit = runAllTests
-}
+} \ No newline at end of file
diff --git a/test/files/run/patmat_unapp_abstype.check b/test/files/run/patmat_unapp_abstype-new.check
index 72239d16cd..72239d16cd 100644
--- a/test/files/run/patmat_unapp_abstype.check
+++ b/test/files/run/patmat_unapp_abstype-new.check
diff --git a/test/files/run/patmat_unapp_abstype.flags b/test/files/run/patmat_unapp_abstype-new.flags
index ba80cad69b..ba80cad69b 100644
--- a/test/files/run/patmat_unapp_abstype.flags
+++ b/test/files/run/patmat_unapp_abstype-new.flags
diff --git a/test/files/run/patmat_unapp_abstype.scala b/test/files/run/patmat_unapp_abstype-new.scala
index 45496f08a2..45496f08a2 100644
--- a/test/files/run/patmat_unapp_abstype.scala
+++ b/test/files/run/patmat_unapp_abstype-new.scala
diff --git a/test/files/run/patmat_unapp_abstype-old.check b/test/files/run/patmat_unapp_abstype-old.check
new file mode 100644
index 0000000000..72239d16cd
--- /dev/null
+++ b/test/files/run/patmat_unapp_abstype-old.check
@@ -0,0 +1,4 @@
+TypeRef
+none of the above
+Bar
+Foo
diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags
new file mode 100644
index 0000000000..ba80cad69b
--- /dev/null
+++ b/test/files/run/patmat_unapp_abstype-old.flags
@@ -0,0 +1 @@
+-Xoldpatmat
diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala
new file mode 100644
index 0000000000..45496f08a2
--- /dev/null
+++ b/test/files/run/patmat_unapp_abstype-old.scala
@@ -0,0 +1,83 @@
+// 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]
+ val TypeRef: TypeRefExtractor; trait TypeRefExtractor {
+ def apply(x: Int): TypeRef
+ def unapply(x: TypeRef): Option[(Int)]
+ }
+
+ // just for illustration, should follow the same pattern as TypeRef
+ case class MethodType(n: Int) extends Type
+}
+
+// user should not be exposed to the implementation
+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")
+ }
+ }
+}
+
+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 {
+ trait Bar
+ type Foo <: Bar
+ trait FooExtractor {
+ def unapply(foo: Foo): Option[Int]
+ }
+ val Foo: FooExtractor
+}
+
+trait RealFoos extends Foos {
+ class Foo(val x: Int) extends Bar
+ object Foo extends FooExtractor {
+ def unapply(foo: Foo): Option[Int] = Some(foo.x)
+ }
+}
+
+trait Intermed extends Foos {
+ def crash(bar: Bar): Unit =
+ bar match {
+ case Foo(x) => println("Foo")
+ case _ => println("Bar")
+ }
+}
+
+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!
+ }
+}
+
+object TestUnappDynamicSynth extends RealFoos with Intermed {
+ case class FooToo(n: Int) extends Bar
+ def test() = {
+ crash(FooToo(10))
+ crash(new Foo(5))
+ }
+}
+
+object Test extends App {
+ TestUnappStaticallyKnownSynthetic.test()
+ TestUnappDynamicSynth.test()
+}
diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2-new.check
index 1b6e24ed20..b82ddbeaff 100644
--- a/test/files/run/primitive-sigs-2.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.api.TypeTags.scala.reflect.api.TypeTags$ConcreteTypeTag<T>)
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.ArrayTag<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
new file mode 100644
index 0000000000..7e13014cb2
--- /dev/null
+++ b/test/files/run/primitive-sigs-2-new.scala
@@ -0,0 +1,31 @@
+import java.{ lang => jl }
+
+trait T[A] {
+ def f(): A
+}
+class C extends T[Char] {
+ def f(): Char = 'a'
+}
+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)
+}
+
+object Test {
+ val c1: Class[_] = classOf[T[_]]
+ val c2: Class[_] = classOf[C]
+ val c3: Class[_] = classOf[Arr]
+
+ val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString)
+ val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString)
+ val c3m = c3.getDeclaredMethods.toList map (_.toGenericString)
+
+ def main(args: Array[String]): Unit = {
+ println(c2.getGenericInterfaces.map(_.toString).sorted mkString " ")
+ println(c1m ++ c2m sorted)
+ println(new C f)
+ c3m.sorted foreach println
+ }
+}
diff --git a/test/files/run/primitive-sigs-2-old.check b/test/files/run/primitive-sigs-2-old.check
new file mode 100644
index 0000000000..9132b4d8ae
--- /dev/null
+++ b/test/files/run/primitive-sigs-2-old.check
@@ -0,0 +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.Manifest<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.scala b/test/files/run/primitive-sigs-2-old.scala
index b7152f7e3d..b7152f7e3d 100644
--- a/test/files/run/primitive-sigs-2.scala
+++ b/test/files/run/primitive-sigs-2-old.scala
diff --git a/test/files/run/reflection-implClass-new.scala b/test/files/run/reflection-implClass-new.scala
new file mode 100644
index 0000000000..27374f2106
--- /dev/null
+++ b/test/files/run/reflection-implClass-new.scala
@@ -0,0 +1,38 @@
+/**
+ * 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.scala b/test/files/run/reflection-implClass-old.scala
index 7718b52f33..6583624d8b 100644
--- a/test/files/run/reflection-implClass.scala
+++ b/test/files/run/reflection-implClass-old.scala
@@ -1,5 +1,5 @@
-/**
- * Tries to load a symbol for the `Foo$class` using Scala reflection.
+/**
+ * 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
diff --git a/test/files/run/reify_implicits.check b/test/files/run/reify_implicits-new.check
index e3aeb20f6b..e3aeb20f6b 100644
--- a/test/files/run/reify_implicits.check
+++ b/test/files/run/reify_implicits-new.check
diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala
new file mode 100644
index 0000000000..69198391d1
--- /dev/null
+++ b/test/files/run/reify_implicits-new.scala
@@ -0,0 +1,14 @@
+import scala.reflect.mirror._
+
+object Test extends App {
+ reify {
+ implicit def arrayWrapper[A : ArrayTag](x: Array[A]) =
+ new {
+ def sort(p: (A, A) => Boolean) = {
+ util.Sorting.stableSort(x, p); x
+ }
+ }
+ val x = Array(2, 3, 1, 4)
+ println("x = "+ x.sort((x: Int, y: Int) => x < y).toList)
+ }.eval
+}
diff --git a/test/files/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check
new file mode 100644
index 0000000000..e3aeb20f6b
--- /dev/null
+++ b/test/files/run/reify_implicits-old.check
@@ -0,0 +1 @@
+x = List(1, 2, 3, 4)
diff --git a/test/files/run/reify_implicits.scala b/test/files/run/reify_implicits-old.scala
index 60971c3cfb..60971c3cfb 100644
--- a/test/files/run/reify_implicits.scala
+++ b/test/files/run/reify_implicits-old.scala
diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check
index 1e7b6f0cd8..c509434116 100644
--- a/test/files/run/repl-power.check
+++ b/test/files/run/repl-power.check
@@ -1,32 +1,32 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala> :power
-** Power User mode enabled - BEEP WHIR GYVE **
-** :phase has been set to 'typer'. **
-** scala.tools.nsc._ has been imported **
-** global._, definitions._ also imported **
-** Try :help, :vals, power.<tab> **
-
-scala> // guarding against "error: reference to global is ambiguous"
-
-scala> global.emptyValDef // "it is imported twice in the same scope by ..."
-res0: $r.global.emptyValDef.type = private val _ = _
-
-scala> val tp = ArrayClass[scala.util.Random] // magic with manifests
-tp: $r.global.Type = Array[scala.util.Random]
-
-scala> tp.memberType(Array_apply) // evidence
-res1: $r.global.Type = (i: Int)scala.util.Random
-
-scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
-m: $r.treedsl.global.Match =
-10 match {
- case 5 => false
- case _ => true
-}
-
-scala> typed(m).tpe // typed is in scope
-res2: $r.treedsl.global.Type = Boolean
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> // guarding against "error: reference to global is ambiguous"
+
+scala> global.emptyValDef // "it is imported twice in the same scope by ..."
+res0: $r.global.emptyValDef.type = private val _ = _
+
+scala> val tp = ArrayClass[scala.util.Random] // magic with tags
+tp: $r.global.Type = Array[scala.util.Random]
+
+scala> tp.memberType(Array_apply) // evidence
+res1: $r.global.Type = (i: Int)scala.util.Random
+
+scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
+m: $r.treedsl.global.Match =
+10 match {
+ case 5 => false
+ case _ => true
+}
+
+scala> typed(m).tpe // typed is in scope
+res2: $r.treedsl.global.Type = Boolean
+
+scala>
diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala
index 27da3df106..f7c88c63ff 100644
--- a/test/files/run/repl-power.scala
+++ b/test/files/run/repl-power.scala
@@ -5,10 +5,9 @@ object Test extends ReplTest {
:power
// guarding against "error: reference to global is ambiguous"
global.emptyValDef // "it is imported twice in the same scope by ..."
-val tp = ArrayClass[scala.util.Random] // magic with manifests
+val tp = ArrayClass[scala.util.Random] // magic with tags
tp.memberType(Array_apply) // evidence
val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
typed(m).tpe // typed is in scope
""".trim
}
-
diff --git a/test/files/run/t0421.check b/test/files/run/t0421-new.check
index cdcf042f19..cdcf042f19 100644
--- a/test/files/run/t0421.check
+++ b/test/files/run/t0421-new.check
diff --git a/test/files/run/t0421-new.scala b/test/files/run/t0421-new.scala
new file mode 100644
index 0000000000..7de6b7f2c4
--- /dev/null
+++ b/test/files/run/t0421-new.scala
@@ -0,0 +1,30 @@
+// ticket #421
+object Test extends App {
+
+ def transpose[A: ArrayTag](xss: Array[Array[A]]) = {
+ for (i <- Array.range(0, xss(0).length)) yield
+ for (xs <- xss) yield xs(i)
+ }
+
+ def scalprod(xs: Array[Double], ys: Array[Double]) = {
+ var acc = 0.0
+ for ((x, y) <- xs zip ys) acc = acc + x * y
+ acc
+ }
+
+ def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = {
+ val ysst = transpose(yss)
+ val ysst1: Array[Array[Double]] = yss.transpose
+ assert(ysst.deep == ysst1.deep)
+ for (xs <- xss) yield
+ for (yst <- ysst) yield
+ scalprod(xs, yst)
+ }
+
+ val a1 = Array(Array(0, 2, 4), Array(1, 3, 5))
+ println(transpose(a1).deep.mkString("[", ",", "]"))
+
+ println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deep.mkString("[", ",", "]"))
+
+ println(matmul(Array(Array(4)), Array(Array(6, 8))).deep.mkString("[", ",", "]"))
+}
diff --git a/test/files/run/t0421-old.check b/test/files/run/t0421-old.check
new file mode 100644
index 0000000000..cdcf042f19
--- /dev/null
+++ b/test/files/run/t0421-old.check
@@ -0,0 +1,3 @@
+[Array(0, 1),Array(2, 3),Array(4, 5)]
+[Array(31.0)]
+[Array(24.0, 32.0)]
diff --git a/test/files/run/t0421.scala b/test/files/run/t0421-old.scala
index 8d51013924..8d51013924 100644
--- a/test/files/run/t0421.scala
+++ b/test/files/run/t0421-old.scala
diff --git a/test/files/run/t0677-new.scala b/test/files/run/t0677-new.scala
new file mode 100644
index 0000000000..bf7a3971dc
--- /dev/null
+++ b/test/files/run/t0677-new.scala
@@ -0,0 +1,8 @@
+object Test extends App {
+ class X[T: ArrayTag] {
+ val a = Array.ofDim[T](3, 4)
+ }
+ val x = new X[String]
+ x.a(1)(2) = "hello"
+ assert(x.a(1)(2) == "hello")
+}
diff --git a/test/files/run/t0677.scala b/test/files/run/t0677-old.scala
index 6c8a3a7e99..6c8a3a7e99 100644
--- a/test/files/run/t0677.scala
+++ b/test/files/run/t0677-old.scala
diff --git a/test/files/run/t1195.check b/test/files/run/t1195-new.check
index 554e3fd03d..554e3fd03d 100644
--- a/test/files/run/t1195.check
+++ b/test/files/run/t1195-new.check
diff --git a/test/files/run/t1195.scala b/test/files/run/t1195-new.scala
index 93b1dcbd07..6f28a4a167 100644
--- a/test/files/run/t1195.scala
+++ b/test/files/run/t1195-new.scala
@@ -7,7 +7,7 @@ object Test {
val g1 = g()
val h1 = h()
- def m[T: Manifest](x: T) = println(manifest[T] + ", underlying = " + manifest[T].sym.typeSignature)
+ def m[T: TypeTag](x: T) = println(typeTag[T] + ", underlying = " + typeTag[T].sym.typeSignature)
def main(args: Array[String]): Unit = {
m(f)
diff --git a/test/files/run/t1195-old.check b/test/files/run/t1195-old.check
new file mode 100644
index 0000000000..eb60eceb17
--- /dev/null
+++ b/test/files/run/t1195-old.check
@@ -0,0 +1,6 @@
+_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
+_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
diff --git a/test/files/run/t1195-old.scala b/test/files/run/t1195-old.scala
new file mode 100644
index 0000000000..b46a3b70f5
--- /dev/null
+++ b/test/files/run/t1195-old.scala
@@ -0,0 +1,26 @@
+object Test {
+ def f() = { case class Bar(x: Int); Bar }
+ def g() = { case class Bar(x: Int); Bar(5) }
+ def h() = { case object Bar ; Bar }
+
+ val f1 = f()
+ val g1 = g()
+ val h1 = h()
+
+ def m[T: Manifest](x: T) = println(manifest[T])
+
+ def main(args: Array[String]): Unit = {
+ m(f)
+ m(g)
+ m(h)
+ m(f1)
+ m(g1)
+ m(h1)
+ }
+}
+
+class A1[T] {
+ class B1[U] {
+ def f = { case class D(x: Int) extends A1[String] ; new D(5) }
+ }
+}
diff --git a/test/files/run/t2236-new.scala b/test/files/run/t2236-new.scala
new file mode 100644
index 0000000000..bbabe8e7d9
--- /dev/null
+++ b/test/files/run/t2236-new.scala
@@ -0,0 +1,17 @@
+class T[A](implicit val m:TypeTag[A])
+class Foo
+class Bar extends T[Foo]
+object Test extends App {
+ new Bar
+}
+
+object EvidenceTest {
+ trait E[T]
+ trait A[T] { implicit val e: E[T] = null }
+ class B[T : E] extends A[T] { override val e = null }
+
+ def f[T] {
+ implicit val e: E[T] = null
+ new B[T]{}
+ }
+}
diff --git a/test/files/run/t2236.scala b/test/files/run/t2236-old.scala
index 64ed18c805..64ed18c805 100755..100644
--- a/test/files/run/t2236.scala
+++ b/test/files/run/t2236-old.scala
diff --git a/test/files/run/t2386-new.check b/test/files/run/t2386-new.check
new file mode 100644
index 0000000000..98e226f946
--- /dev/null
+++ b/test/files/run/t2386-new.check
@@ -0,0 +1,2 @@
+a(0) = Array(1, 2)
+a(1) = Array("a", "b")
diff --git a/test/files/run/t2386-new.scala b/test/files/run/t2386-new.scala
new file mode 100644
index 0000000000..15d1859759
--- /dev/null
+++ b/test/files/run/t2386-new.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ val a = Array(Array(1, 2), Array("a","b"))
+ println("a(0) = Array(" + (a(0) mkString ", ") + ")")
+ println("a(1) = Array(" + (a(1) map (s => "\"" + s + "\"") mkString ", ") + ")")
+}
diff --git a/test/files/run/t3507.check b/test/files/run/t3507-new.check
index 6e4fa4170e..6e4fa4170e 100644
--- a/test/files/run/t3507.check
+++ b/test/files/run/t3507-new.check
diff --git a/test/files/run/t3507.scala b/test/files/run/t3507-new.scala
index 3cdd40a881..c7a529e8b8 100644
--- a/test/files/run/t3507.scala
+++ b/test/files/run/t3507-new.scala
@@ -9,7 +9,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: Manifest](x: T) = println(manifest[T])
+ def mani[T: TypeTag](x: T) = println(typeTag[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/t3758-old.scala b/test/files/run/t3758-old.scala
new file mode 100644
index 0000000000..f00254afee
--- /dev/null
+++ b/test/files/run/t3758-old.scala
@@ -0,0 +1,10 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(classManifest[Array[String]].typeArguments contains classManifest[String])
+ assert(classManifest[Array[Int]].typeArguments contains classManifest[Int])
+ assert(classManifest[Array[Float]].typeArguments contains classManifest[Float])
+ assert(manifest[Array[String]].typeArguments contains manifest[String])
+ assert(manifest[Array[Int]].typeArguments contains manifest[Int])
+ assert(manifest[Array[Float]].typeArguments contains manifest[Float])
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t3758.check b/test/files/run/t3758.check
deleted file mode 100644
index 9c6ab655a3..0000000000
--- a/test/files/run/t3758.check
+++ /dev/null
@@ -1,6 +0,0 @@
-List(String)
-List(Int)
-List(Float)
-List(String)
-List(Int)
-List(Float)
diff --git a/test/files/run/t3758.scala b/test/files/run/t3758.scala
deleted file mode 100644
index 10bfb5724b..0000000000
--- a/test/files/run/t3758.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-object Test {
- def main(args: Array[String]): Unit = {
- println(classManifest[Array[String]].tpe.typeArguments)
- println(classManifest[Array[Int]].tpe.typeArguments)
- println(classManifest[Array[Float]].tpe.typeArguments)
- println(manifest[Array[String]].tpe.typeArguments)
- println(manifest[Array[Int]].tpe.typeArguments)
- println(manifest[Array[Float]].tpe.typeArguments)
- }
-}
diff --git a/test/files/run/t4110.check b/test/files/run/t4110-new.check
index 28f220e1fe..28f220e1fe 100644
--- a/test/files/run/t4110.check
+++ b/test/files/run/t4110-new.check
diff --git a/test/files/run/t4110-new.scala b/test/files/run/t4110-new.scala
new file mode 100644
index 0000000000..3285b82c61
--- /dev/null
+++ b/test/files/run/t4110-new.scala
@@ -0,0 +1,11 @@
+object Test extends App {
+ def inferredType[T : TypeTag](v : T) = println(typeTag[T])
+
+ trait A
+ trait B
+
+ inferredType(new A with B)
+
+ val name = new A with B
+ inferredType(name)
+} \ No newline at end of file
diff --git a/test/files/run/t4110-old.check b/test/files/run/t4110-old.check
new file mode 100644
index 0000000000..8b005989de
--- /dev/null
+++ b/test/files/run/t4110-old.check
@@ -0,0 +1,2 @@
+Object with Test$A with Test$B
+Object with Test$A with Test$B
diff --git a/test/files/run/t4110.scala b/test/files/run/t4110-old.scala
index 4bd377b73e..a42646ce52 100644
--- a/test/files/run/t4110.scala
+++ b/test/files/run/t4110-old.scala
@@ -3,7 +3,7 @@ object Test extends App {
trait A
trait B
-
+
inferredType(new A with B)
val name = new A with B
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check
new file mode 100644
index 0000000000..271139b031
--- /dev/null
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check
@@ -0,0 +1,5 @@
+{
+ 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])))
+}
+mr.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
new file mode 100644
index 0000000000..b4c76d0600
--- /dev/null
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala
@@ -0,0 +1,17 @@
+import scala.reflect.mirror._
+
+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 tree1 = Apply(Select(Ident(mr), 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 ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true)
+ println(ttree2)
+}
diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check
index 62fcb481ae..f124aa6a35 100644
--- a/test/files/run/typetags_core.check
+++ b/test/files/run/typetags_core.check
@@ -1,30 +1,32 @@
-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[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
index 883c54b9a8..7d6be16379 100644
--- a/test/files/run/typetags_core.scala
+++ b/test/files/run/typetags_core.scala
@@ -29,4 +29,6 @@ object Test extends App {
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
new file mode 100644
index 0000000000..613106985c
--- /dev/null
+++ b/test/files/run/typetags_multi.check
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 0000000000..868edc2b2a
--- /dev/null
+++ b/test/files/run/typetags_multi.scala
@@ -0,0 +1,7 @@
+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/scalacheck/array-new.scala b/test/files/scalacheck/array-new.scala
new file mode 100644
index 0000000000..18d577ca6d
--- /dev/null
+++ b/test/files/scalacheck/array-new.scala
@@ -0,0 +1,36 @@
+import org.scalacheck._
+import Prop._
+import Gen._
+import Arbitrary._
+import util._
+import Buildable._
+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]] =
+ Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray))
+
+ val arrGen: Gen[Array[_]] = oneOf(
+ arbitrary[Array[Int]],
+ arbitrary[Array[Array[Int]]],
+ arbitrary[Array[List[String]]],
+ arbitrary[Array[String]],
+ arbitrary[Array[Boolean]],
+ arbitrary[Array[AnyVal]]
+ )
+
+ // inspired by #1857 and #2352
+ property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) =>
+ (c1 eq c2) || (c1 ne c2)
+ }
+
+ // inspired by #2299
+ def smallInt = choose(1, 10)
+ property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) =>
+ val arr = Array.ofDim[String](i1, i2, i3)
+ val flattened = arr flatMap (x => x) flatMap (x => x)
+ flattened.length == i1 * i2 * i3
+ }
+}
diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array-old.scala
index f262bc6320..f262bc6320 100644
--- a/test/files/scalacheck/array.scala
+++ b/test/files/scalacheck/array-old.scala
diff --git a/test/files/specialized/spec-matrix.check b/test/files/specialized/spec-matrix-new.check
index 5ec3e84597..5ec3e84597 100644
--- a/test/files/specialized/spec-matrix.check
+++ b/test/files/specialized/spec-matrix-new.check
diff --git a/test/files/specialized/spec-matrix-new.scala b/test/files/specialized/spec-matrix-new.scala
new file mode 100644
index 0000000000..65b46e8d48
--- /dev/null
+++ b/test/files/specialized/spec-matrix-new.scala
@@ -0,0 +1,80 @@
+/** Test matrix multiplication with specialization.
+ */
+
+class Matrix[@specialized A: ArrayTag](val rows: Int, val cols: Int) {
+ private val arr: Array[Array[A]] = Array.ofDim[A](rows, cols)
+
+ def apply(i: Int, j: Int): A = {
+ if (i < 0 || i >= rows || j < 0 || j >= cols)
+ throw new NoSuchElementException("Indexes out of bounds: " + (i, j))
+
+ arr(i)(j)
+ }
+
+ def update(i: Int, j: Int, e: A) {
+ arr(i)(j) = e
+ }
+
+ def rowsIterator: Iterator[Array[A]] = new Iterator[Array[A]] {
+ var idx = 0;
+ def hasNext = idx < rows
+ def next = {
+ idx += 1
+ arr(idx - 1)
+ }
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val m = randomMatrix(200, 100)
+ val n = randomMatrix(100, 200)
+
+ val p = mult(m, n)
+ println(p(0, 0))
+ println("Boxed doubles: " + runtime.BoxesRunTime.doubleBoxCount)
+// println("Boxed integers: " + runtime.BoxesRunTime.integerBoxCount)
+ }
+
+ def randomMatrix(n: Int, m: Int) = {
+ val r = new util.Random(10)
+ val x = new Matrix[Double](n, m)
+ for (i <- 0 until n; j <- 0 until m)
+ x(i, j) = (r.nextInt % 1000).toDouble
+ x
+ }
+
+ def printMatrix[Double](m: Matrix[Double]) {
+ for (i <- 0 until m.rows) {
+ for (j <- 0 until m.cols)
+ print("%5.3f ".format(m(i, j)))
+ println
+ }
+ }
+
+ def multTag[@specialized(Int) T](m: Matrix[T], n: Matrix[T])(implicit at: ArrayTag[T], num: Numeric[T]) {
+ val p = new Matrix[T](m.rows, n.cols)
+ import num._
+
+ for (i <- 0 until m.rows)
+ for (j <- 0 until n.cols) {
+ var sum = num.zero
+ for (k <- 0 until n.rows)
+ sum += m(i, k) * n(k, j)
+ p(i, j) = sum
+ }
+ }
+
+ def mult(m: Matrix[Double], n: Matrix[Double]) = {
+ val p = new Matrix[Double](m.rows, n.cols)
+
+ for (i <- 0 until m.rows)
+ for (j <- 0 until n.cols) {
+ var sum = 0.0
+ for (k <- 0 until n.rows)
+ sum += m(i, k) * n(k, j)
+ p(i, j) = sum
+ }
+ p
+ }
+}
diff --git a/test/files/specialized/spec-matrix-old.check b/test/files/specialized/spec-matrix-old.check
new file mode 100644
index 0000000000..5ec3e84597
--- /dev/null
+++ b/test/files/specialized/spec-matrix-old.check
@@ -0,0 +1,2 @@
+251437.0
+Boxed doubles: 1
diff --git a/test/files/specialized/spec-matrix.scala b/test/files/specialized/spec-matrix-old.scala
index 98735c8c03..98735c8c03 100644
--- a/test/files/specialized/spec-matrix.scala
+++ b/test/files/specialized/spec-matrix-old.scala
diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1
index 2d4cd04a92..a7da67429e 100644
--- a/test/files/speclib/instrumented.jar.desired.sha1
+++ b/test/files/speclib/instrumented.jar.desired.sha1
@@ -1 +1 @@
-d83c6bf3765ab1378943020a8d9cda8851604ffa ?instrumented.jar
+15f200d9f0f25f9fd871bad2ebb4ba5cfc671db4 ?instrumented.jar
diff --git a/test/instrumented/boxes.patch b/test/instrumented/boxes.patch
index 11c5b37aa8..6c5ff23f9f 100644
--- a/test/instrumented/boxes.patch
+++ b/test/instrumented/boxes.patch
@@ -1,7 +1,8 @@
-9a10,11
+9c9
+<
+---
> /* INSTRUMENTED VERSION */
->
-50a53,61
+51a52,59
> public static int booleanBoxCount = 0;
> public static int characterBoxCount = 0;
> public static int byteBoxCount = 0;
@@ -10,20 +11,19 @@
> public static int longBoxCount = 0;
> public static int floatBoxCount = 0;
> public static int doubleBoxCount = 0;
->
-51a63
-> booleanBoxCount++;
-55a68
-> characterBoxCount++;
-59a73
-> byteBoxCount++;
-63a78
-> shortBoxCount++;
-67a83
-> integerBoxCount++;
-71a88
-> longBoxCount++;
-75a93
-> floatBoxCount++;
-79a98
-> doubleBoxCount++;
+53a62
+> booleanBoxCount += 1;
+57a67
+> characterBoxCount += 1;
+61a72
+> byteBoxCount += 1;
+65a77
+> shortBoxCount += 1;
+69a82
+> integerBoxCount += 1;
+73a87
+> longBoxCount += 1;
+77a92
+> floatBoxCount += 1;
+83a99
+> doubleBoxCount += 1;
diff --git a/test/instrumented/library/scala/runtime/BoxesRunTime.java b/test/instrumented/library/scala/runtime/BoxesRunTime.java
index f06f86f2f2..172ed8ee14 100644
--- a/test/instrumented/library/scala/runtime/BoxesRunTime.java
+++ b/test/instrumented/library/scala/runtime/BoxesRunTime.java
@@ -6,10 +6,8 @@
** |/ **
\* */
-
/* INSTRUMENTED VERSION */
-
package scala.runtime;
import java.io.*;
@@ -33,14 +31,16 @@ public final class BoxesRunTime
{
private static final int CHAR = 0, BYTE = 1, SHORT = 2, INT = 3, LONG = 4, FLOAT = 5, DOUBLE = 6, OTHER = 7;
+ /** We don't need to return BYTE and SHORT, as everything which might
+ * care widens to INT.
+ */
private static int typeCode(Object a) {
if (a instanceof java.lang.Integer) return INT;
- if (a instanceof java.lang.Byte) return BYTE;
- if (a instanceof java.lang.Character) return CHAR;
- if (a instanceof java.lang.Long) return LONG;
if (a instanceof java.lang.Double) return DOUBLE;
- if (a instanceof java.lang.Short) return SHORT;
+ if (a instanceof java.lang.Long) return LONG;
+ if (a instanceof java.lang.Character) return CHAR;
if (a instanceof java.lang.Float) return FLOAT;
+ if ((a instanceof java.lang.Byte) || (a instanceof java.lang.Short)) return INT;
return OTHER;
}
@@ -49,7 +49,6 @@ public final class BoxesRunTime
}
/* BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING */
-
public static int booleanBoxCount = 0;
public static int characterBoxCount = 0;
public static int byteBoxCount = 0;
@@ -58,46 +57,46 @@ public final class BoxesRunTime
public static int longBoxCount = 0;
public static int floatBoxCount = 0;
public static int doubleBoxCount = 0;
-
+
public static java.lang.Boolean boxToBoolean(boolean b) {
- booleanBoxCount++;
+ booleanBoxCount += 1;
return java.lang.Boolean.valueOf(b);
}
public static java.lang.Character boxToCharacter(char c) {
- characterBoxCount++;
+ characterBoxCount += 1;
return java.lang.Character.valueOf(c);
}
public static java.lang.Byte boxToByte(byte b) {
- byteBoxCount++;
+ byteBoxCount += 1;
return java.lang.Byte.valueOf(b);
}
public static java.lang.Short boxToShort(short s) {
- shortBoxCount++;
+ shortBoxCount += 1;
return java.lang.Short.valueOf(s);
}
public static java.lang.Integer boxToInteger(int i) {
- integerBoxCount++;
+ integerBoxCount += 1;
return java.lang.Integer.valueOf(i);
}
public static java.lang.Long boxToLong(long l) {
- longBoxCount++;
+ longBoxCount += 1;
return java.lang.Long.valueOf(l);
}
public static java.lang.Float boxToFloat(float f) {
- floatBoxCount++;
+ floatBoxCount += 1;
return java.lang.Float.valueOf(f);
}
public static java.lang.Double boxToDouble(double d) {
- doubleBoxCount++;
// System.out.println("box " + d);
// (new Throwable()).printStackTrace();
+ doubleBoxCount += 1;
return java.lang.Double.valueOf(d);
}
@@ -138,15 +137,6 @@ public final class BoxesRunTime
/* COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON */
- private static int eqTypeCode(Number a) {
- if ((a instanceof java.lang.Integer) || (a instanceof java.lang.Byte)) return INT;
- if (a instanceof java.lang.Long) return LONG;
- if (a instanceof java.lang.Double) return DOUBLE;
- if (a instanceof java.lang.Short) return INT;
- if (a instanceof java.lang.Float) return FLOAT;
- return OTHER;
- }
-
public static boolean equals(Object x, Object y) {
if (x == y) return true;
return equals2(x, y);
@@ -178,8 +168,8 @@ public final class BoxesRunTime
}
public static boolean equalsNumNum(java.lang.Number xn, java.lang.Number yn) {
- int xcode = eqTypeCode(xn);
- int ycode = eqTypeCode(yn);
+ int xcode = typeCode(xn);
+ int ycode = typeCode(yn);
switch (ycode > xcode ? ycode : xcode) {
case INT:
return xn.intValue() == yn.intValue();
@@ -211,8 +201,11 @@ public final class BoxesRunTime
}
private static boolean equalsNumChar(java.lang.Number xn, java.lang.Character yc) {
+ if (yc == null)
+ return xn == null;
+
char ch = yc.charValue();
- switch (eqTypeCode(xn)) {
+ switch (typeCode(xn)) {
case INT:
return xn.intValue() == ch;
case LONG:
@@ -222,9 +215,6 @@ public final class BoxesRunTime
case DOUBLE:
return xn.doubleValue() == ch;
default:
- if (xn == null)
- return yc == null;
-
return xn.equals(yc);
}
}
@@ -290,6 +280,31 @@ public final class BoxesRunTime
else return a.hashCode();
}
+ private static int unboxCharOrInt(Object arg1, int code) {
+ if (code == CHAR)
+ return ((java.lang.Character) arg1).charValue();
+ else
+ return ((java.lang.Number) arg1).intValue();
+ }
+ private static long unboxCharOrLong(Object arg1, int code) {
+ if (code == CHAR)
+ return ((java.lang.Character) arg1).charValue();
+ else
+ return ((java.lang.Number) arg1).longValue();
+ }
+ private static float unboxCharOrFloat(Object arg1, int code) {
+ if (code == CHAR)
+ return ((java.lang.Character) arg1).charValue();
+ else
+ return ((java.lang.Number) arg1).floatValue();
+ }
+ private static double unboxCharOrDouble(Object arg1, int code) {
+ if (code == CHAR)
+ return ((java.lang.Character) arg1).charValue();
+ else
+ return ((java.lang.Number) arg1).doubleValue();
+ }
+
/* OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS */
/** arg1 + arg2 */
@@ -298,24 +313,16 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 + val2);
+ return boxToInteger(unboxCharOrInt(arg1, code1) + unboxCharOrInt(arg2, code2));
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 + val2);
+ return boxToLong(unboxCharOrLong(arg1, code1) + unboxCharOrLong(arg2, code2));
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
- return boxToFloat(val1 + val2);
+ return boxToFloat(unboxCharOrFloat(arg1, code1) + unboxCharOrFloat(arg2, code2));
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
- return boxToDouble(val1 + val2);
+ return boxToDouble(unboxCharOrDouble(arg1, code1) + unboxCharOrDouble(arg2, code2));
}
throw new NoSuchMethodException();
}
@@ -326,24 +333,16 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 - val2);
+ return boxToInteger(unboxCharOrInt(arg1, code1) - unboxCharOrInt(arg2, code2));
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 - val2);
+ return boxToLong(unboxCharOrLong(arg1, code1) - unboxCharOrLong(arg2, code2));
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
- return boxToFloat(val1 - val2);
+ return boxToFloat(unboxCharOrFloat(arg1, code1) - unboxCharOrFloat(arg2, code2));
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
- return boxToDouble(val1 - val2);
+ return boxToDouble(unboxCharOrDouble(arg1, code1) - unboxCharOrDouble(arg2, code2));
}
throw new NoSuchMethodException();
}
@@ -354,24 +353,16 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 * val2);
+ return boxToInteger(unboxCharOrInt(arg1, code1) * unboxCharOrInt(arg2, code2));
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 * val2);
+ return boxToLong(unboxCharOrLong(arg1, code1) * unboxCharOrLong(arg2, code2));
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
- return boxToFloat(val1 * val2);
+ return boxToFloat(unboxCharOrFloat(arg1, code1) * unboxCharOrFloat(arg2, code2));
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
- return boxToDouble(val1 * val2);
+ return boxToDouble(unboxCharOrDouble(arg1, code1) * unboxCharOrDouble(arg2, code2));
}
throw new NoSuchMethodException();
}
@@ -381,26 +372,16 @@ public final class BoxesRunTime
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
- if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 / val2);
- }
- if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 / val2);
- }
- if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
- return boxToFloat(val1 / val2);
- }
- if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
- return boxToDouble(val1 / val2);
- }
+
+ if (maxcode <= INT)
+ return boxToInteger(unboxCharOrInt(arg1, code1) / unboxCharOrInt(arg2, code2));
+ if (maxcode <= LONG)
+ return boxToLong(unboxCharOrLong(arg1, code1) / unboxCharOrLong(arg2, code2));
+ if (maxcode <= FLOAT)
+ return boxToFloat(unboxCharOrFloat(arg1, code1) / unboxCharOrFloat(arg2, code2));
+ if (maxcode <= DOUBLE)
+ return boxToDouble(unboxCharOrDouble(arg1, code1) / unboxCharOrDouble(arg2, code2));
+
throw new NoSuchMethodException();
}
@@ -409,26 +390,16 @@ public final class BoxesRunTime
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
- if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 % val2);
- }
- if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 % val2);
- }
- if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
- return boxToFloat(val1 % val2);
- }
- if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
- return boxToDouble(val1 % val2);
- }
+
+ if (maxcode <= INT)
+ return boxToInteger(unboxCharOrInt(arg1, code1) % unboxCharOrInt(arg2, code2));
+ if (maxcode <= LONG)
+ return boxToLong(unboxCharOrLong(arg1, code1) % unboxCharOrLong(arg2, code2));
+ if (maxcode <= FLOAT)
+ return boxToFloat(unboxCharOrFloat(arg1, code1) % unboxCharOrFloat(arg2, code2));
+ if (maxcode <= DOUBLE)
+ return boxToDouble(unboxCharOrDouble(arg1, code1) % unboxCharOrDouble(arg2, code2));
+
throw new NoSuchMethodException();
}
@@ -437,24 +408,24 @@ public final class BoxesRunTime
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
if (code1 <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToInteger(val1 >> val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToInteger(val1 >> val2);
}
}
if (code1 <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToLong(val1 >> val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToLong(val1 >> val2);
}
}
@@ -466,24 +437,24 @@ public final class BoxesRunTime
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
if (code1 <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToInteger(val1 << val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToInteger(val1 << val2);
}
}
if (code1 <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToLong(val1 << val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToLong(val1 << val2);
}
}
@@ -495,24 +466,24 @@ public final class BoxesRunTime
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
if (code1 <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToInteger(val1 >>> val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToInteger(val1 >>> val2);
}
}
if (code1 <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
if (code2 <= INT) {
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToLong(val1 >>> val2);
}
if (code2 <= LONG) {
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToLong(val1 >>> val2);
}
}
@@ -523,19 +494,19 @@ public final class BoxesRunTime
public static Object negate(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
if (code <= INT) {
- int val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).intValue();
+ int val = unboxCharOrInt(arg, code);
return boxToInteger(-val);
}
if (code <= LONG) {
- long val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).longValue();
+ long val = unboxCharOrLong(arg, code);
return boxToLong(-val);
}
if (code <= FLOAT) {
- float val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).floatValue();
+ float val = unboxCharOrFloat(arg, code);
return boxToFloat(-val);
}
if (code <= DOUBLE) {
- double val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).doubleValue();
+ double val = unboxCharOrDouble(arg, code);
return boxToDouble(-val);
}
throw new NoSuchMethodException();
@@ -545,20 +516,16 @@ public final class BoxesRunTime
public static Object positive(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
if (code <= INT) {
- int val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).intValue();
- return boxToInteger(+val);
+ return boxToInteger(+unboxCharOrInt(arg, code));
}
if (code <= LONG) {
- long val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).longValue();
- return boxToLong(+val);
+ return boxToLong(+unboxCharOrLong(arg, code));
}
if (code <= FLOAT) {
- float val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).floatValue();
- return boxToFloat(+val);
+ return boxToFloat(+unboxCharOrFloat(arg, code));
}
if (code <= DOUBLE) {
- double val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).doubleValue();
- return boxToDouble(+val);
+ return boxToDouble(+unboxCharOrDouble(arg, code));
}
throw new NoSuchMethodException();
}
@@ -566,72 +533,60 @@ public final class BoxesRunTime
/** arg1 & arg2 */
public static Object takeAnd(Object arg1, Object arg2) throws NoSuchMethodException {
if ((arg1 instanceof Boolean) || (arg2 instanceof Boolean)) {
- if (!((arg1 instanceof Boolean) && (arg2 instanceof Boolean))) {
+ if ((arg1 instanceof Boolean) && (arg2 instanceof Boolean))
+ return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() & ((java.lang.Boolean) arg2).booleanValue());
+ else
throw new NoSuchMethodException();
- }
- return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() & ((java.lang.Boolean) arg2).booleanValue());
}
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
- if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 & val2);
- }
- if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 & val2);
- }
+
+ if (maxcode <= INT)
+ return boxToInteger(unboxCharOrInt(arg1, code1) & unboxCharOrInt(arg2, code2));
+ if (maxcode <= LONG)
+ return boxToLong(unboxCharOrLong(arg1, code1) & unboxCharOrLong(arg2, code2));
+
throw new NoSuchMethodException();
}
/** arg1 | arg2 */
public static Object takeOr(Object arg1, Object arg2) throws NoSuchMethodException {
if ((arg1 instanceof Boolean) || (arg2 instanceof Boolean)) {
- if (!((arg1 instanceof Boolean) && (arg2 instanceof Boolean))) {
+ if ((arg1 instanceof Boolean) && (arg2 instanceof Boolean))
+ return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() | ((java.lang.Boolean) arg2).booleanValue());
+ else
throw new NoSuchMethodException();
- }
- return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() | ((java.lang.Boolean) arg2).booleanValue());
}
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
- if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 | val2);
- }
- if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 | val2);
- }
+
+ if (maxcode <= INT)
+ return boxToInteger(unboxCharOrInt(arg1, code1) | unboxCharOrInt(arg2, code2));
+ if (maxcode <= LONG)
+ return boxToLong(unboxCharOrLong(arg1, code1) | unboxCharOrLong(arg2, code2));
+
throw new NoSuchMethodException();
}
/** arg1 ^ arg2 */
public static Object takeXor(Object arg1, Object arg2) throws NoSuchMethodException {
if ((arg1 instanceof Boolean) || (arg2 instanceof Boolean)) {
- if (!((arg1 instanceof Boolean) && (arg2 instanceof Boolean))) {
+ if ((arg1 instanceof Boolean) && (arg2 instanceof Boolean))
+ return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() ^ ((java.lang.Boolean) arg2).booleanValue());
+ else
throw new NoSuchMethodException();
- }
- return boxToBoolean(((java.lang.Boolean) arg1).booleanValue() ^ ((java.lang.Boolean) arg2).booleanValue());
}
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
- if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
- return boxToInteger(val1 ^ val2);
- }
- if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
- return boxToLong(val1 ^ val2);
- }
+
+ if (maxcode <= INT)
+ return boxToInteger(unboxCharOrInt(arg1, code1) ^ unboxCharOrInt(arg2, code2));
+ if (maxcode <= LONG)
+ return boxToLong(unboxCharOrLong(arg1, code1) ^ unboxCharOrLong(arg2, code2));
+
throw new NoSuchMethodException();
}
@@ -655,12 +610,10 @@ public final class BoxesRunTime
public static Object complement(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
if (code <= INT) {
- int val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).intValue();
- return boxToInteger(~val);
+ return boxToInteger(~unboxCharOrInt(arg, code));
}
if (code <= LONG) {
- long val = (code == CHAR) ? ((java.lang.Character) arg).charValue() : ((java.lang.Number) arg).longValue();
- return boxToLong(~val);
+ return boxToLong(~unboxCharOrLong(arg, code));
}
throw new NoSuchMethodException();
}
@@ -686,23 +639,23 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToBoolean(val1 < val2);
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToBoolean(val1 < val2);
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
+ float val1 = unboxCharOrFloat(arg1, code1);
+ float val2 = unboxCharOrFloat(arg2, code2);
return boxToBoolean(val1 < val2);
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
+ double val1 = unboxCharOrDouble(arg1, code1);
+ double val2 = unboxCharOrDouble(arg2, code2);
return boxToBoolean(val1 < val2);
}
throw new NoSuchMethodException();
@@ -713,23 +666,23 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToBoolean(val1 <= val2);
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToBoolean(val1 <= val2);
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
+ float val1 = unboxCharOrFloat(arg1, code1);
+ float val2 = unboxCharOrFloat(arg2, code2);
return boxToBoolean(val1 <= val2);
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
+ double val1 = unboxCharOrDouble(arg1, code1);
+ double val2 = unboxCharOrDouble(arg2, code2);
return boxToBoolean(val1 <= val2);
}
throw new NoSuchMethodException();
@@ -740,23 +693,23 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToBoolean(val1 >= val2);
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToBoolean(val1 >= val2);
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
+ float val1 = unboxCharOrFloat(arg1, code1);
+ float val2 = unboxCharOrFloat(arg2, code2);
return boxToBoolean(val1 >= val2);
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
+ double val1 = unboxCharOrDouble(arg1, code1);
+ double val2 = unboxCharOrDouble(arg2, code2);
return boxToBoolean(val1 >= val2);
}
throw new NoSuchMethodException();
@@ -767,33 +720,30 @@ public final class BoxesRunTime
int code2 = typeCode(arg2);
int maxcode = (code1 < code2) ? code2 : code1;
if (maxcode <= INT) {
- int val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).intValue();
- int val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).intValue();
+ int val1 = unboxCharOrInt(arg1, code1);
+ int val2 = unboxCharOrInt(arg2, code2);
return boxToBoolean(val1 > val2);
}
if (maxcode <= LONG) {
- long val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).longValue();
- long val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).longValue();
+ long val1 = unboxCharOrLong(arg1, code1);
+ long val2 = unboxCharOrLong(arg2, code2);
return boxToBoolean(val1 > val2);
}
if (maxcode <= FLOAT) {
- float val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).floatValue();
- float val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).floatValue();
+ float val1 = unboxCharOrFloat(arg1, code1);
+ float val2 = unboxCharOrFloat(arg2, code2);
return boxToBoolean(val1 > val2);
}
if (maxcode <= DOUBLE) {
- double val1 = (code1 == CHAR) ? ((java.lang.Character) arg1).charValue() : ((java.lang.Number) arg1).doubleValue();
- double val2 = (code2 == CHAR) ? ((java.lang.Character) arg2).charValue() : ((java.lang.Number) arg2).doubleValue();
+ double val1 = unboxCharOrDouble(arg1, code1);
+ double val2 = unboxCharOrDouble(arg2, code2);
return boxToBoolean(val1 > val2);
}
throw new NoSuchMethodException();
}
-
+
public static boolean isBoxedNumberOrBoolean(Object arg) {
- if (arg instanceof java.lang.Boolean)
- return true;
- else
- return isBoxedNumber(arg);
+ return (arg instanceof java.lang.Boolean) || isBoxedNumber(arg);
}
public static boolean isBoxedNumber(Object arg) {
return (
diff --git a/test/instrumented/library/scala/runtime/ScalaRunTime.scala b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
index 9eb93a418d..63908fcc29 100644
--- a/test/instrumented/library/scala/runtime/ScalaRunTime.scala
+++ b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.runtime
/* INSTRUMENTED VERSION */
+package scala.runtime
import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator }
import scala.collection.mutable.WrappedArray
@@ -33,10 +33,7 @@ object ScalaRunTime {
clazz.isArray && (atLevel == 1 || isArrayClass(clazz.getComponentType, atLevel - 1))
def isValueClass(clazz: Class[_]) = clazz.isPrimitive()
- var arrayApplyCount = 0
- var arrayUpdateCount = 0
-
- def isTuple(x: Any) = tupleNames(x.getClass.getName)
+ def isTuple(x: Any) = x != null && tupleNames(x.getClass.getName)
def isAnyVal(x: Any) = x match {
case _: Byte | _: Short | _: Char | _: Int | _: Long | _: Float | _: Double | _: Boolean | _: Unit => true
case _ => false
@@ -52,56 +49,68 @@ object ScalaRunTime {
names.toSet
}
+ /** Return the class object representing an array with element class `clazz`.
+ */
+ def arrayClass(clazz: Class[_]): Class[_] = {
+ // newInstance throws an exception if the erasure is Void.TYPE. see SI-5680
+ if (clazz == java.lang.Void.TYPE) classOf[Array[Unit]]
+ else java.lang.reflect.Array.newInstance(clazz, 0).getClass
+ }
+
+ /** Return the class object representing elements in arrays described by a given schematic.
+ */
+ 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 _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass))
+ }
+
/** Return the class object representing an unboxed value type,
* e.g. classOf[int], not classOf[java.lang.Integer]. The compiler
* rewrites expressions like 5.getClass to come here.
*/
- def anyValClass[T <: AnyVal](value: T): Class[T] = (value match {
- case x: Byte => java.lang.Byte.TYPE
- case x: Short => java.lang.Short.TYPE
- case x: Char => java.lang.Character.TYPE
- case x: Int => java.lang.Integer.TYPE
- case x: Long => java.lang.Long.TYPE
- case x: Float => java.lang.Float.TYPE
- case x: Double => java.lang.Double.TYPE
- case x: Boolean => java.lang.Boolean.TYPE
- case x: Unit => java.lang.Void.TYPE
- }).asInstanceOf[Class[T]]
+ def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] =
+ classTag[T].erasure.asInstanceOf[Class[T]]
+
+ var arrayApplyCount = 0
/** Retrieve generic array element */
def array_apply(xs: AnyRef, idx: Int): Any = {
arrayApplyCount += 1
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
- }
+ 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
+ }
}
+ var arrayUpdateCount = 0
+
/** update generic array element */
def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
arrayUpdateCount += 1
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
- }
+ 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
+ }
}
/** Get generic array length */
@@ -340,14 +349,14 @@ object ScalaRunTime {
case null => "null"
case "" => "\"\""
case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x
- case x if useOwnToString(x) => x toString
+ case x if useOwnToString(x) => x.toString
case x: AnyRef if isArray(x) => arrayToString(x)
case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")")
case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")
case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")
case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)" // that special trailing comma
case x: Product if isTuple(x) => x.productIterator map inner mkString ("(", ",", ")")
- case x => x toString
+ case x => x.toString
}
// The try/catch is defense against iterables which aren't actually designed
diff --git a/test/instrumented/srt.patch b/test/instrumented/srt.patch
index 2f472ff1c0..8d08550165 100644
--- a/test/instrumented/srt.patch
+++ b/test/instrumented/srt.patch
@@ -1,23 +1,26 @@
9a10,11
> /* INSTRUMENTED VERSION */
->
-33a36,38
+>
+43c45,48
+< def isTuple(x: Any) = x != null && tupleNames(x.getClass.getName)
+---
> var arrayApplyCount = 0
> var arrayUpdateCount = 0
->
-35c40,42
+>
+> def isTuple(x: Any) = tupleNames(x.getClass.getName)
+75c80,82
< def array_apply(xs: AnyRef, idx: Int): Any = xs match {
---
> def array_apply(xs: AnyRef, idx: Int): Any = {
> arrayApplyCount += 1
> xs match {
-47a55
+87a95
> }
-50c58,60
+90c98,100
< def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match {
---
> def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
> arrayUpdateCount += 1
> xs match {
-62a73
+101a112
> }
diff --git a/test/pending/pos/inference.scala b/test/pending/pos/inference.scala
index d28d003435..3672351fca 100644
--- a/test/pending/pos/inference.scala
+++ b/test/pending/pos/inference.scala
@@ -1,15 +1,15 @@
// inference illuminator
object Test {
- class D1[T1 : Manifest, T2 <: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) }
- class D2[T1 : Manifest, T2 >: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) }
- class D3[+T1 : Manifest, T2 <: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) }
- class D4[-T1 : Manifest, T2 >: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) }
-
- class E1[T1 : Manifest, T2 <: T1 : Manifest](x: D1[T1, T2]) { println(manifest[(T1, T2)]) }
- class E2[T1 : Manifest, T2 >: T1 : Manifest](x: D2[T1, T2]) { println(manifest[(T1, T2)]) }
- class E3[+T1 : Manifest, T2 <: T1 : Manifest](x: D3[T1, T2]) { println(manifest[(T1, T2)]) }
- class E4[-T1 : Manifest, T2 >: T1 : Manifest](x: D4[T1, T2]) { println(manifest[(T1, T2)]) }
-
+ 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 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)]) }
+
def main(args: Array[String]): Unit = {
// WHY YOU NO LIKE NOTHING SO MUCH SCALAC?
val d1 = new D1(5)
diff --git a/test/pending/shootout/meteor.scala b/test/pending/shootout/meteor.scala
index 2fd702753a..154695533b 100644
--- a/test/pending/shootout/meteor.scala
+++ b/test/pending/shootout/meteor.scala
@@ -19,7 +19,7 @@ object meteor {
-// Solver.scala
+// Solver.scala
// import scala.collection.mutable._
final class Solver (n: Int) {
@@ -29,8 +29,8 @@ final class Solver (n: Int) {
private val board = new Board()
- val pieces = Array(
- new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4),
+ val pieces = Array(
+ new Piece(0), new Piece(1), new Piece(2), new Piece(3), new Piece(4),
new Piece(5), new Piece(6), new Piece(7), new Piece(8), new Piece(9) )
val unplaced = new BitSet(pieces.length)
@@ -71,8 +71,8 @@ final class Solver (n: Int) {
private def puzzleSolved() = {
val b = board.asString
- if (first == null){
- first = b; last = b
+ if (first == null){
+ first = b; last = b
} else {
if (b < first){ first = b } else { if (b > last){ last = b } }
}
@@ -81,7 +81,7 @@ final class Solver (n: Int) {
private def shouldPrune() = {
board.unmark
- !board.cells.forall(c => c.contiguousEmptyCells % Piece.size == 0)
+ !board.cells.forall(c => c.contiguousEmptyCells % Piece.size == 0)
}
@@ -108,8 +108,8 @@ final class Solver (n: Int) {
}
/*
- def printPieces() =
- for (i <- Iterator.range(0,Board.pieces)) pieces(i).print
+ def printPieces() =
+ for (i <- Iterator.range(0,Board.pieces)) pieces(i).print
*/
}
@@ -126,7 +126,7 @@ object Board {
val size = rows * cols
}
-final class Board {
+final class Board {
val cells = boardCells()
val cellsPieceWillFill = new Array[BoardCell](Piece.size)
@@ -134,9 +134,9 @@ final class Board {
def unmark() = for (c <- cells) c.unmark
- def asString() =
- new String( cells map(
- c => if (c.piece == null) '-'.toByte
+ def asString() =
+ new String( cells map(
+ c => if (c.piece == null) '-'.toByte
else (c.piece.number + 48).toByte ))
def firstEmptyCellIndex() = cells.findIndexOf(c => c.isEmpty)
@@ -144,13 +144,13 @@ final class Board {
def add(pieceIndex: Int, boardIndex: Int, p: Piece) = {
cellCount = 0
p.unmark
-
+
find( p.cells(pieceIndex), cells(boardIndex))
- val boardHasSpace = cellCount == Piece.size &&
- cellsPieceWillFill.forall(c => c.isEmpty)
+ val boardHasSpace = cellCount == Piece.size &&
+ cellsPieceWillFill.forall(c => c.isEmpty)
- if (boardHasSpace) cellsPieceWillFill.foreach(c => c.piece = p)
+ if (boardHasSpace) cellsPieceWillFill.foreach(c => c.piece = p)
boardHasSpace
}
@@ -180,10 +180,10 @@ final class Board {
if (row % 2 == 1) {
if (!isLast) c.next(Cell.NE) = a(i-(Board.cols-1))
- c.next(Cell.NW) = a(i-Board.cols)
+ c.next(Cell.NW) = a(i-Board.cols)
if (row != m) {
if (!isLast) c.next(Cell.SE) = a(i+(Board.cols+1))
- c.next(Cell.SW) = a(i+Board.cols)
+ c.next(Cell.SW) = a(i+Board.cols)
}
} else {
if (row != 0) {
@@ -212,9 +212,9 @@ final class Board {
Console.print(i + "\t")
for (j <- Iterator.range(0,Cell.sides)){
val c = cells(i).next(j)
- if (c == null)
- Console.print("-- ")
- else
+ if (c == null)
+ Console.print("-- ")
+ else
Console.printf("{0,number,00} ")(c.number)
}
Console.println("")
@@ -241,7 +241,7 @@ final class Piece(_number: Int) {
val number = _number
val cells = for (i <- Array.range(0,Piece.size)) yield new PieceCell()
- {
+ {
number match {
case 0 => make0
case 1 => make1
@@ -252,7 +252,7 @@ final class Piece(_number: Int) {
case 6 => make6
case 7 => make7
case 8 => make8
- case 9 => make9
+ case 9 => make9
}
}
@@ -395,12 +395,12 @@ final class Piece(_number: Int) {
Console.print(i + "\t")
for (j <- Iterator.range(0,Cell.sides)){
val c = cells(i).next(j)
- if (c == null)
- Console.print("-- ")
- else
+ if (c == null)
+ Console.print("-- ")
+ else
for (k <- Iterator.range(0,Piece.size)){
if (cells(k) == c) Console.printf(" {0,number,0} ")(k)
- }
+ }
}
Console.println("")
}
@@ -418,13 +418,13 @@ final class Piece(_number: Int) {
object Cell {
val NW = 0; val NE = 1
val W = 2; val E = 3
- val SW = 4; val SE = 5
+ val SW = 4; val SE = 5
val sides = 6
}
abstract class Cell {
- implicit def m: Manifest[T]
+ implicit def t: ClassTag[T]
type T
val next = new Array[T](Cell.sides)
var marked = false
@@ -437,7 +437,7 @@ abstract class Cell {
final class BoardCell(_number: Int) extends {
type T = BoardCell
- implicit val m = manifest[BoardCell]
+ implicit val t = classTag[BoardCell]
} with Cell {
val number = _number
var piece: Piece = _
@@ -448,10 +448,10 @@ final class BoardCell(_number: Int) extends {
def contiguousEmptyCells(): Int = {
if (!marked && isEmpty){
mark
- var count = 1
+ var count = 1
for (neighbour <- next)
- if (neighbour != null && neighbour.isEmpty)
+ if (neighbour != null && neighbour.isEmpty)
count = count + neighbour.contiguousEmptyCells
count } else { 0 }
diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala
index 3e3d0f01a6..65d7bdf67c 100644
--- a/test/scaladoc/resources/implicits-base-res.scala
+++ b/test/scaladoc/resources/implicits-base-res.scala
@@ -137,6 +137,8 @@ class ManifestA[W: Manifest](a: A[W]) {
def convToManifestA(x: W): W = sys.error("dunno")
}
+// [Eugene to Vlad] how do I test typetags here?
+
/** MyTraversableOps class <br/>
* - checks if any abstract members are added - should not happen!
*/
@@ -144,4 +146,3 @@ trait MyTraversableOps[S] {
/** The convToTraversableOps: S documentation... */
def convToTraversableOps(x: S): S
}
-